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
glotter/psims
models/pdssat45/source/csm45/Source045/p_plant.f90
1
28440
!======================================================================= ! P_Plant, Plant phosphorus model. ! ! DETERMINES PLANT P TRANSFORMATIONS ! Computes P concentration and total content for four plant ! components: shoot (leaf + stem), root, shell and seed. ! Optimum P concentration for each component is based on 3 ! stages: ! (1) stage A (e.g., emergence) ! (2) stage B (e.g., first flower) ! (3) stage C (e.g., physiological maturity) ! Optimum and minimum P concentrations for each plant component / ! stage are read from the species file. ! Fraction of development between stages is sent from each plant ! routine. This routine linearly interpolates optimum and ! minimum P concentrations between stages. ! Two options to read in P concentrations for either Shoot or for ! Leaf and Stem, as well as for root, shell and seed. Use ! -99 for data option not used. Logical variable, UseShoots, is ! set to TRUE when values of shoots are used, FALSE if leaf and stem ! are used. !----------------------------------------------------------------------- ! REVISION HISTORY ! 08/../1997 AG Written. ! 09/../1997 AG Built into CERES 3.1. ! 09/../1998 AG Built into CERES 3.5. ! 01/../1999 AG Replaced ISTAGE with XSTAGE in wh. ! 06/../1999 AG Added residue P carry-over. ! 08/../1999 AG Added seasonal analysis initalization option. ! 09/19/2003 AJG Brought into modular format and linked to the ! CENTURY-based SOM/residue module. ! 12/17/2003 AJG Renamed all the CH_ and CHEM_ variables to P_ variables. ! 02/12/2004 AJG Renamed the subroutine from CHEM_GEN to P_GEN. ! 03/23/2004 CHP Removed soil components ! 03/24/2004 CHP Added to CSM ! 09/17/2004 CHP Made generic for all plant routines to use a single routine. !----------------------------------------------------------------------- ! Called by: CROPGRO, MZ_CERES, RI_CERES... ! Calls: P_UPTAKE, OPPHOS !======================================================================= SUBROUTINE P_Plant (DYNAMIC, ISWPHO, !I Control & CROP, FILECC, MDATE, YRPLT, !I Crop & SPi_AVAIL, !I Soils & Leaf_kg, Stem_kg, Root_kg, Shel_kg, Seed_kg, !I Mass & PhFrac1, PhFrac2, !I Phase & RLV, !RWU, !I Roots & SenSoilP, SenSurfP, !I Senescence & PCNVEG, !I N conc. & PestShut, PestRoot, PestShel, PestSeed, !I Pest damage & ShutMob, RootMob, ShelMob, !I Mobilized & PConc_Shut, PConc_Root, PConc_Shel, PConc_Seed, !O P conc. & PShut_kg, PRoot_kg, PShel_kg, PSeed_kg, !O P amts. & PStres1, PStres2, !O P stress & PUptake) !O P uptake ! ------------------------------------------------------------------ ! Send DYNAMIC to accomodate emergence calculations ! (DYNAMIC=EMERG) within the integration section of CROPGRO. ! ------------------------------------------------------------------ USE ModuleDefs IMPLICIT NONE SAVE ! ------------------------------------------------------------------ ! Interface variables ! ------------------------------------------------------------------ ! INPUT INTEGER DYNAMIC !Processing control CHARACTER*1 ISWPHO !P switch (Y or N) CHARACTER*2 CROP !2-character crop code CHARACTER*92 FILECC !Path and name of species file INTEGER MDATE !Maturity date INTEGER YRPLT !Planting date REAL SPi_AVAIL(NL) !P available for uptake (kg/ha) !State variables - mass (kg/ha) - includes new growth REAL Leaf_kg !Leaf mass (kg/ha) REAL Stem_kg !Stem mass (kg/ha) REAL Root_kg !Root mass (kg/ha) REAL Shel_kg !Shell mass (kg/ha) REAL Seed_kg !Seed mass (kg/ha) REAL PhFrac1 !Fraction phys time betw St 1 & St 2 REAL PhFrac2 !Fraction phys time betw St 2 & St 3 REAL RLV(NL) !Root length density REAL SenSoilP !P senesced from leaf + stem REAL SenSurfP !P senesced from roots REAL PCNVEG !N percentage in veg. tissue !Pest damage variables: REAL PestShut !Pest damage to leaf and stem REAL PestRoot !Pest damage to root REAL PestShel !Pest damage to shell REAL PestSeed !Pest damage to seed !Plant mass lost due to mobilization of N and C REAL ShutMob !Mobilization loss for leaf and stem REAL RootMob !Mobilization loss for roots REAL ShelMob !Mobilization loss for shells ! OUTPUT REAL PConc_Shut !P conc in shoots (kg[P]/kg[shoots]) REAL PConc_Root !P conc in roots (kg[P]/kg[roots]) REAL PConc_Veg !P conc in veg tissue (kg[P]/kg[veg]) REAL PStres1 !P stress for partitioning REAL PStres2 !P stress for photosynthesis REAL PUptake(NL) !P uptake by soil layer (kg/ha) ! ------------------------------------------------------------------ CHARACTER*6, PARAMETER :: ERRKEY = 'PPLANT' LOGICAL UseShoots INTEGER I ! Shoot mass -- leaf + stem (kg/ha) REAL Shut_kg !, ShutNew_kg ! Change (increase or decrease) to P variable per day REAL DeltPShut, DeltPRoot, DeltPShel, DeltPSeed ! Daily values of optimum and minimum and actual P concs. REAL PConc_Shut_opt, PConc_Root_opt, PConc_Shel_opt,PConc_Seed_opt REAL PConc_Shut_min, PConc_Root_min, PConc_Shel_min,PConc_Seed_min REAL PConc_Shel, PConc_Seed, PConc_Plant ! P state variables by weight (kg/ha) REAL PShut_kg, PRoot_kg, PShel_kg, PSeed_kg, PPlant_kg ! Misc. REAL PShutDem, PRootDem, PShelDem, PSeedDem, PTotDem REAL PSTRESS_RATIO REAL PUptakeProf REAL Plant_kg REAL N2P, N2P_max, N2P_min REAL PestShutP, PestRootP, PestShelP, PestSeedP ! REAL PShutMob, PRootMob, PShelMob !, PTotMob ! REAL PShutMobPool, PRootMobPool, PShelMobPool ! From species file: REAL, DIMENSION(3) :: PCShutOpt, PCRootOpt, PCShelOpt, PCSeedOpt REAL, DIMENSION(3) :: PCLeafOpt, PCStemOpt REAL, DIMENSION(3) :: PCShutMin, PCRootMin, PCShelMin, PCSeedMin REAL, DIMENSION(3) :: PCLeafMin, PCStemMin REAL, DIMENSION(3) :: N2Pmin, N2Pmax REAL SRATPHOTO, SRATPART REAL FracPMobil, FracPUptake Real PValue !Function !*********************************************************************** !*********************************************************************** ! SEASONAL INITIALIZATION: RUN ONCE PER SEASON. !*********************************************************************** IF (DYNAMIC == SEASINIT .OR. DYNAMIC .EQ. RUNINIT) THEN ! ------------------------------------------------------------------ IF (CROP .NE. 'FA' .AND. & (ISWPHO .EQ. 'Y' .OR. ISWPHO .EQ. 'H')) THEN CALL P_IPPLNT(FILECC, & N2Pmax, N2Pmin, & PCShutMin, PCLeafMin, PCStemMin, PCRootMin, PCShelMin, PCSeedMin, & PCShutOpt, PCLeafOpt, PCStemOpt, PCRootOpt, PCShelOpt, PCSeedOpt, & FracPMobil, FracPUptake, SRATPHOTO, SRATPART, UseShoots) ENDIF ! ------------------------------------------------------------------ Call P_Demand(DYNAMIC, & PConc_Root, PConc_Root_min, PConc_Root_opt, !Input & PConc_Shel, PConc_Shel_min, PConc_Shel_opt, !Input & PConc_Shut, PConc_Shut_min, PConc_Shut_opt, !Input & PConc_Seed_opt, PRoot_kg, PSeed_kg, PShel_kg, !Input & PShut_kg, Root_kg, RootMob, Seed_kg, Shel_kg, !Input & ShelMob, Shut_kg, ShutMob, !Input & DeltPRoot, DeltPSeed, DeltPShel, DeltPShut, !I/O & PRootDem, PSeedDem, PShelDem, PShutDem, !Output & PTotDem) !Output ! ------------------------------------------------------------------ ! Initialize uptake variables - do this even if P not modelled. CALL P_Uptake (DYNAMIC, & N2P_min, PCNVeg, PConc_Veg, PTotDem, !Input & RLV, SPi_AVAIL, !Input & N2P, PUptake, PUptakeProf) !Output ! Optimum P concentration PConc_Shut_opt = 0.0 PConc_Root_opt = 0.0 PConc_Shel_opt = 0.0 PConc_Seed_opt = 0.0 ! Minimum P concentration PConc_Shut_min = 0.0 PConc_Root_min = 0.0 PConc_Shel_min = 0.0 PConc_Seed_min = 0.0 ! P concentration variables (fraction of plant tissue) PConc_Shut = 0.0 PConc_Root = 0.0 PConc_Shel = 0.0 PConc_Seed = 0.0 PConc_Plant = 0.0 ! P[kg/ha] variables PShut_kg = 0.0 PRoot_kg = 0.0 PShel_kg = 0.0 PSeed_kg = 0.0 PPlant_kg = 0.0 ! Demand variables PShutDem = 0.0 PRootDem = 0.0 PShelDem = 0.0 PSeedDem = 0.0 PTotDem = 0.0 PStres1 = 1.0 PStres2 = 1.0 PSTRESS_RATIO = 1.0 ! P in senesced tissue SenSoilP = 0.0 SenSurfP = 0.0 ! N:P ratio N2P = 0.0 ! Initial shoot mass Shut_kg = 0.0 IF (ISWPHO == 'N') RETURN CALL OPPlantP(DYNAMIC, MDATE, YRPLT, & PConc_Shut_opt, PConc_Root_opt, PConc_Shel_opt, PConc_Seed_opt, & PConc_Shut_min, PConc_Root_min, PConc_Shel_min, PConc_Seed_min, & PConc_Shut, PConc_Root, PConc_Shel, PConc_Seed, PConc_Plant, & PShut_kg, PRoot_kg, PShel_kg, PSeed_kg, PPlant_kg, & Shut_kg, Root_kg, Shel_kg, Seed_kg, N2P, PTotDem, & SenSoilP, SenSurfP, PhFrac1, PhFrac2, & PStres1, PStres2, PSTRESS_RATIO, PUptakeProf, & PestShutP, PestRootP, PestShelP, PestSeedP) !*********************************************************************** !*********************************************************************** ! EMERGENCE !*********************************************************************** ELSEIF (DYNAMIC == EMERG) THEN !----------------------------------------------------------------------- PTotDem = 0.0 Shut_kg = Leaf_kg + Stem_kg ! Optimum P concentration in vegetative matter at emergence (fraction) IF (UseShoots) THEN PConc_Shut_opt = PCShutOpt(1) ELSE PConc_Shut_opt = (PCLeafOpt(1)*Leaf_kg + PCStemOpt(1)*Stem_kg) / & Shut_kg ENDIF PConc_Root_opt = PCRootOpt(1) PConc_Shel_opt = PCShelOpt(1) PConc_Seed_opt = PCSeedOpt(1) ! Initial P concentration in vegetative matter at emergence (fraction) PConc_Shut = PConc_Shut_opt PConc_Root = PConc_Root_opt PConc_Shel = PConc_Shel_opt PConc_Seed = PConc_Seed_opt ! Total plant weight Plant_kg = Shut_kg + Root_kg + Shel_kg + Seed_kg ! What about nodules, tubers, etc.??? ! Plant P (kg/ha) PShut_kg = PConc_Shut * Shut_kg PRoot_kg = PConc_Root * Root_kg PShel_kg = PConc_Shel * Shel_kg PSeed_kg = PConc_Seed * Seed_kg PPlant_kg = PShut_kg + PRoot_kg + PShel_kg + PSeed_kg CALL OPPlantP(DYNAMIC, MDATE, YRPLT, & PConc_Shut_opt, PConc_Root_opt, PConc_Shel_opt, PConc_Seed_opt, & PConc_Shut_min, PConc_Root_min, PConc_Shel_min, PConc_Seed_min, & PConc_Shut, PConc_Root, PConc_Shel, PConc_Seed, PConc_Plant, & PShut_kg, PRoot_kg, PShel_kg, PSeed_kg, PPlant_kg, & Shut_kg, Root_kg, Shel_kg, Seed_kg, N2P, PTotDem, & SenSoilP, SenSurfP, PhFrac1, PhFrac2, & PStres1, PStres2, PSTRESS_RATIO, PUptakeProf, & PestShutP, PestRootP, PestShelP, PestSeedP) !*********************************************************************** !*********************************************************************** ! DAILY INTEGRATION !*********************************************************************** ELSEIF (DYNAMIC == INTEGR) THEN !----------------------------------------------------------------------- Shut_kg = Leaf_kg + Stem_kg Plant_kg = Shut_kg + Root_kg + Shel_kg + Seed_kg IF (.NOT. UseShoots .AND. Shut_kg > 0) THEN DO I = 1, 3 PCShutOpt(I) = (PCLeafOpt(I)*Leaf_kg + PCStemOpt(I)*Stem_kg) / & Shut_kg PCShutMin(I) = (PCLeafMin(I)*Leaf_kg + PCStemMin(I)*Stem_kg) / & Shut_kg ENDDO ENDIF !----------------------------------------------------------------------- ! Initialize delta variables DeltPShut = 0.0 DeltPRoot = 0.0 DeltPShel = 0.0 DeltPSeed = 0.0 !----------------------------------------------------------------------- ! Senesced plant matter - reduce P PShut_kg = PShut_kg - SenSurfP PRoot_kg = PRoot_kg - SenSoilP PPlant_kg = PPlant_kg - (SenSoilP + SenSurfP) ! Pest damage PestShutP = PestShut * PConc_Shut PestRootP = PestRoot * PConc_Root PestShelP = PestShel * PConc_Shel PestSeedP = PestSeed * PConc_Seed PShut_kg = PShut_kg - PestShutP PRoot_kg = PRoot_kg - PestRootP PShel_kg = PShel_kg - PestShelP PSeed_kg = PSeed_kg - PestSeedP PPlant_kg = PPlant_kg - & (PestShutP + PestRootP + PestShelP + PestSeedP) ! ------------------------------------------------------------------ ! Calculate optimum and minimum P concentrations in plant tissue. ! ------------------------------------------------------------------ PConc_Shut_opt = PValue(PhFrac1, PhFrac2, PCShutOpt) PConc_Root_opt = PValue(PhFrac1, PhFrac2, PCRootOpt) PConc_Shel_opt = PValue(PhFrac1, PhFrac2, PCShelOpt) PConc_Seed_opt = PValue(PhFrac1, PhFrac2, PCSeedOpt) PConc_Shut_min = PValue(PhFrac1, PhFrac2, PCShutMin) PConc_Root_min = PValue(PhFrac1, PhFrac2, PCRootMin) PConc_Shel_min = PValue(PhFrac1, PhFrac2, PCShelMin) PConc_Seed_min = PValue(PhFrac1, PhFrac2, PCSeedMin) N2P_max = PValue(PhFrac1, PhFrac2, N2Pmax) N2P_min = PValue(PhFrac1, PhFrac2, N2Pmin) !----------------------------------------------------------------------- ! CALCULATE DEMANDS in kg/ha Call P_Demand(DYNAMIC, & PConc_Root, PConc_Root_min, PConc_Root_opt, !Input & PConc_Shel, PConc_Shel_min, PConc_Shel_opt, !Input & PConc_Shut, PConc_Shut_min, PConc_Shut_opt, !Input & PConc_Seed_opt, PRoot_kg, PSeed_kg, PShel_kg, !Input & PShut_kg, Root_kg, RootMob, Seed_kg, Shel_kg, !Input & ShelMob, Shut_kg, ShutMob, !Input & DeltPRoot, DeltPSeed, DeltPShel, DeltPShut, !I/O & PRootDem, PSeedDem, PShelDem, PShutDem, !Output & PTotDem) !Output !----------------------------------------------------------------------- ! P uptake CALL P_Uptake (DYNAMIC, & N2P_min, PCNVeg, PConc_Veg, PTotDem, !Input & RLV, SPi_AVAIL, !Input & N2P, PUptake, PUptakeProf) !Output !----------------------------------------------------------------------- CALL P_Partition( & FracPMobil, PConc_Root_min, PConc_Shel_min, !Input & PConc_Shut_min, PRootDem, PRoot_kg, PSeedDem, !Input & PShelDem, PShel_kg, PShutDem, PShut_kg, !Input & PUptakeProf, Root_kg, Shel_kg, Shut_kg, !Input & DeltPRoot, DeltPSeed, DeltPShel, DeltPShut) !I/O !------------------------------------------------------------------------ ! P mass in plant matter (kg/ha) PShut_kg = PShut_kg + DeltPShut PRoot_kg = PRoot_kg + DeltPRoot PShel_kg = PShel_kg + DeltPShel PSeed_kg = PSeed_kg + DeltPSeed PPlant_kg = PPlant_kg + PUptakeProf !------------------------------------------------------------------------ C CALCULATE P CONCENTRATIONS (fractions) IF (Seed_kg > 0.) THEN PConc_Seed = PSeed_kg / Seed_kg ELSE PConc_Seed = 0. ENDIF IF (Shel_kg > 0.) THEN PConc_Shel = PShel_kg / Shel_kg ELSE PConc_Shel = 0. ENDIF IF (Shut_kg > 0.) THEN PConc_Shut = PShut_kg / Shut_kg ELSE PConc_Shut = 0. ENDIF IF (Root_kg > 0.) THEN PConc_Root = PRoot_kg / Root_kg ELSE PConc_Root = 0. ENDIF IF (Plant_kg > 0.) THEN PConc_Plant = PPlant_kg / Plant_kg ELSE PConc_Plant = 0.0 ENDIF ! Vegetative P concentration for N:P ratio IF (Shut_kg + Root_kg > 1.E-6) THEN PConc_Veg = (PConc_Shut * Shut_kg + PConc_Root * Root_kg) / & (Shut_kg + Root_kg) * 100. ENDIF !----------------------------------------------------------------------- ! From MB's P_Partition C Calculate PSTRESS_RATIO PSTRESS_RATIO = MIN(1.0, (PConc_Shut - PConc_Shut_Min) / & (PConc_Shut_opt - PConc_Shut_Min)) C Calculate PStres1 (Photosynthesis) IF (PSTRESS_RATIO .GE. SRATPHOTO) THEN PStres1 = 1.0 ELSEIF (PSTRESS_RATIO < SRATPHOTO .AND. PSTRESS_RATIO > 1.E-6)THEN PStres1 = PSTRESS_RATIO / SRATPHOTO ELSE PStres1 = 0.0 ENDIF C Calculate PStres2 (Partitioning) IF (PSTRESS_RATIO .GE. SRATPART) THEN PStres2 = 1.0 ELSEIF (PSTRESS_RATIO < SRATPART .AND. PSTRESS_RATIO > 1.E-6) THEN PStres2 = PSTRESS_RATIO / SRATPART ELSE PStres2 = 0.0 ENDIF !*********************************************************************** !*********************************************************************** ! DAILY OUTPUT AND SEASONAL SUMMARY !*********************************************************************** ELSEIF (DYNAMIC == OUTPUT .OR. DYNAMIC == SEASEND) THEN !----------------------------------------------------------------------- CALL OPPlantP(DYNAMIC, MDATE, YRPLT, & PConc_Shut_opt, PConc_Root_opt, PConc_Shel_opt, PConc_Seed_opt, & PConc_Shut_min, PConc_Root_min, PConc_Shel_min, PConc_Seed_min, & PConc_Shut, PConc_Root, PConc_Shel, PConc_Seed, PConc_Plant, & PShut_kg, PRoot_kg, PShel_kg, PSeed_kg, PPlant_kg, & Shut_kg, Root_kg, Shel_kg, Seed_kg, N2P, PTotDem, & SenSoilP, SenSurfP, PhFrac1, PhFrac2, & PStres1, PStres2, PSTRESS_RATIO, PUptakeProf, & PestShutP, PestRootP, PestShelP, PestSeedP) SenSoilP = 0.0 SenSurfP = 0.0 PUptakeProf = 0.0 !*********************************************************************** !*********************************************************************** ! END OF DYNAMIC IF CONSTRUCT !*********************************************************************** ENDIF !----------------------------------------------------------------------- RETURN END SUBROUTINE P_Plant C======================================================================= !----------------------------------------------------------------------- ! Variable definitions - updated 09-29-2004 !----------------------------------------------------------------------- ! CHAR Contains the contents of last record read ! CROP Two-character crop identification code ! DeltPRoot Portion of P uptake that is allocated to root (g[P]/m2) ! DeltPSeed Portion of P uptake that is allocated to seed (g[P]/m2) ! DeltPShel Portion of P uptake that is allocated to shell (g[P]/m2) ! DeltPShut Portion of P uptake that is allocated to leaf and stem ! (g[P]/m2) ! ERR Error code for file operation ! ERRKEY Subroutine name for error file ! FILECC Path plus filename for species file (*.spe) ! FOUND Indicator that good data was read from file by subroutine ! FIND (0 - End-of-file encountered, 1 - NAME was found) ! FracPMobil Portion of P in vegetative tissue which is available for ! mining to supply seed and shell P demand (fraction) ! ISECT Indicator of completion of IGNORE routine: 0 - End of file ! encountered, 1 - Found a good line to read, 2 - End of ! Section in file encountered denoted by * in column 1. ! ISWPHO Phosphorus simulation switch (Y or N) ! Leaf_kg Mass of leaf tissue (kg[leaf]/ha) ! LeafNew_kg Mass of today's new growth of leaves (kg[leaf]/ha) ! LNUM Current line number of input file ! LUNCRP Logical unit number for FILEC (*.spe file) ! MDATE Harvest maturity date (YYYYDDD) ! MSG Text array containing information to be written to ! WARNING.OUT file. ! NL Maximum number of soil layers = 20 ! NLAYR Actual number of soil layers ! PCLeafMin(3) Minimum P concentration in leaf defined at three critical ! stages (g[P]/g[leaf]) ! PCLeafOpt(3) Optimum P concentration in leaf defined at three critical ! stages (g[P]/g[leaf]) ! PConc_Plant P concentration in whole plant (g[P]/g[plant]) ! PConc_Root P concentration in root (g[P]/g[root]) ! PConc_Root_Min Minimum P concentration in root (g[P]/g[root]) ! PConc_Root_Opt Optimum P concentration in root (g[P]/g[root]) ! PConc_Seed Concentration of P in seed (g[P]/g[seed]) ! PConc_Seed_Min Minimum P concentration in seed (g[P]/g[seed]) ! PConc_Seed_Opt Optimum P concentration in seed (g[P]/g[seed]) ! PConc_Shel Concentration of P in shell (g[P]/g[shell]) ! PConc_Shel_Min Minimum P concentration in shell (g[P]/g[shell]) ! PConc_Shel_Opt Optimum P concentration in shell (g[P]/g[shell]) ! PConc_Shut P concentration in shoots (leaf and stem) (g[P]/g[shoot]) ! PConc_Shut_Min Minimum P concentration in leaf and stem (g[P]/g[shoot]) ! PConc_Shut_Opt Optimum P concentration in leaf and stem (g[P]/g[shoot]) ! PCRootMin(3) Minimum P concentration in root defined at three critical ! stages (g[P]/g[root]) ! PCRootOpt(3) Optimum P concentration in root defined at three critical ! stages (g[P]/g[root]) ! PCSeedMin(3) Minimum P concentration in seed defined at three critical ! stages (g[P]/g[seed]) ! PCSeedOpt(3) Optimum P concentration in seed defined at three critical ! stages (g[P]/g[seed]) ! PCShelMin(3) Minimum P concentration in shell defined at three critical ! stages (g[P]/g[shell]) ! PCShelOpt(3) Optimum P concentration in shell defined at three critical ! stages (g[P]/g[shell]) ! PCShutMin(3) Minimum P concentration in leaf and stem defined at three ! critical stages (g[P]/g[shoot]) ! PCShutOpt(3) Optimum P concentration in leaf and stem defined at three ! critical stages (g[P]/g[shoot]) ! PCStemMin(3) Minimum P concentration in stem defined at three critical ! stages (g[P]/g[stem]) ! PCStemOpt(3) Optimum P concentration in stem defined at three critical ! stages (g[P]/g[stem]) ! PHFRAC1_2 Fraction of physiological time which has occurred between ! first and second critical phases for computation of ! optimum and minimum plant P concentrations ! PHFRAC2_3 Fraction of physiological time which has occurred between ! second and third critical phases for computation of ! optimum and minimum plant P concentrations ! Pi_Avail(L) Soil P which is available for uptake by plants. (ppm) ! Plant_kg Mass of plant (kg/ha) ! PlantNew_kg Mass of today's new growth of plant tissue (kg/ha) ! PMined P mined from leaf, stem and root for seed or shell demand ! (kg[P]/ha) ! PMinedSd P mined from leaf, stem and root for seed demand ! (kg[P]/ha) ! PMinedSl P mined from leaf, stem and root for shell demand ! (kg[P]/ha) ! PPlant_kg P content in whole plant (kg[P]/ha) ! PRoot_kg P in roots (kg[P]/ha) ! PRoot_Min Minimum P for root growth (kg[P]/ha) ! PRootDem Root demand for P (kg[P]/ha) ! PSeed_kg P content in seed (kg[P]/ha) ! PSeedDem P demand by seed (g[P]/m2) ! PShel_kg P content in shell (kg[P]/ha) ! PShelDem P demand by shell (g[P]/m2) ! PShut_kg P in shoots (leaf and stem) (kg[P]/ha) ! ShutPMin Minimum P for root growth (kg[P]/ha) ! PShutDem Shoot demand for P (kg[P]/ha) ! PSTRES1 P stress which affects vegetative partitioning (1=no ! stress, 0=max stress) ! PSTRES2 P stress factor for reducing photosynthate (1=no stress, ! 0=max stress) ! PSTRESS_RATIO Ratio of P in vegetative tissue to optimum P as a measure ! of plant stress (g[P]/g[P]) ! PSUPPLY Supply of P from root uptake (kg[P]/ha) ! PTotDem Total daily plant demand for P (kg[P]/ha) ! PUptake(L) Plant uptake of P in soil layer L (kg[P]/ha/d) ! PUptakeProf Plant uptake of P over whole soil profile (kg[P]/ha/d) ! PMine_Avail P in vegetative tissue which is available for mining for ! growth of seed and shell (kg[P]/ha) ! P_Mobil_max Maximum amount of P in vegetative tissue which can be ! mined today (kg[P]/ha) ! RLV(L) Root length density for soil layer L ! (cm[root] / cm3[soil]) ! Root_kg Root mass (kg/ha) ! RootMineFrac Fraction of mined P which is taken from roots ! RootNew_kg Mass of today's new growth of roots (kg/ha) ! RWU(L) Root water uptake from soil layer L (cm/d) ! SECTION Section name in input file ! Seed_kg Seed mass (kg/ha) ! SeedNew_kg Mass of today's new growth of seed (kg/ha) ! SenSoilP P in senesced root and nodule tissue (kg[P]/ha/d) ! SenSurfP P in senesced canopy tissue (kg[P]/ha/d) ! Shel_kg Shell mass (kg/ha) ! ShelNew_kg Mass of today's new growth of shell (kg/ha) ! Shut_kg Shoots mass (kg/ha) ! ShutMineFrac Fraction of mined P which is taken from shoots ! ShutNew_kg Mass of today's new growth of shoots (kg/ha) ! SRATPART Minimum value of the ratio of P in vegetative tissue to ! the optimum P, below which vegetative partitioning will ! be affected (g[P]/g[P]) ! SRATPHOTO Minimum value of the ratio of P in vegetative tissue to ! the optimum P, below which reduced photosynthesis will ! occur (g[P]/g[P]) ! Stem_kg Stem mass (kg/ha) ! StemNew_kg Mass of today's new growth of stem (kg/ha) ! UseShoots Logical variable (true or false), indicates whether input ! from crop routine and species file will be for shoots ! (true) or leaf and stem (false) ! YRPLT Planting date (YYYYDDD) !----------------------------------------------------------------------- ! END SUBROUTINE PLANT !=======================================================================
agpl-3.0
nvarini/espresso_iohpc
GWW/gww/lanczos_polarization.f90
10
8544
! ! Copyright (C) 2001-2013 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 . ! ! MODULE lanczos !this module describes the structures for the calculation !of the polarization and of the self-energy through an !lanczos chain style USE kinds, ONLY : DP TYPE compact_q_lanczos !this structure describes the "compact" term: ! Q^v_in=\sum U_{vv'}V^v'_{i,l}T^v'_{l,n} INTEGER :: ii!corresponding KS state INTEGER :: numpw!dimension of polarization basis INTEGER :: numt!dimension of the basis {t_n} REAL(kind=DP), POINTER, DIMENSION(:,:) :: qlm!matrix Q(numpw,numt) END TYPE compact_q_lanczos TYPE lanczos_matrix !this structure describes the (H-i\alpha)^-1 matrix INTEGER :: iw!corresponding imaginary frequency INTEGER :: numt!dimension of the basis {t_n} COMPLEX(kind=DP), POINTER, DIMENSION(:,:) :: e_mat END TYPE lanczos_matrix CONTAINS SUBROUTINE initialize_compact_q_lanczos(cql) !this subroutine initializes compact_q_lanczos implicit none TYPE(compact_q_lanczos) :: cql nullify(cql%qlm) return END SUBROUTINE initialize_compact_q_lanczos SUBROUTINE free_memory_compact_q_lanczos(cql) !this subroutine initializes compact_q_lanczos implicit none TYPE(compact_q_lanczos) :: cql if(associated(cql%qlm)) deallocate(cql%qlm) nullify(cql%qlm) return END SUBROUTINE free_memory_compact_q_lanczos SUBROUTINE initialize_lanczos_matrix(lm) !this subroutine initializes compact_q_lanczos implicit none TYPE(lanczos_matrix) :: lm nullify(lm%e_mat) return END SUBROUTINE initialize_lanczos_matrix SUBROUTINE free_memory_lanczos_matrix(lm) !this subroutine initializes compact_q_lanczos implicit none TYPE(lanczos_matrix) :: lm if(associated(lm%e_mat)) deallocate(lm%e_mat) nullify(lm%e_mat) return END SUBROUTINE free_memory_lanczos_matrix SUBROUTINE write_compact_q_lanczos(cql) !this subroutine writes the compact_q_lanczos function on disk !the file name is taken from the label USE io_files, ONLY : prefix,tmp_dir implicit none INTEGER, EXTERNAL :: find_free_unit TYPE(compact_q_lanczos) :: cql!the compact_q_lanczos function to be written INTEGER :: iunq, ii CHARACTER(5) :: nfile write(nfile,'(5i1)') & & cql%ii/10000,mod(cql%ii,10000)/1000,mod(cql%ii,1000)/100,mod(cql%ii,100)/10,mod(cql%ii,10) iunq = find_free_unit() open( unit=iunq, file=trim(tmp_dir)//trim(prefix)//'-'//'q_lanczos.'// nfile, status='unknown',form='unformatted') write(iunq) cql%ii write(iunq) cql%numpw write(iunq) cql%numt do ii=1,cql%numt write(iunq) cql%qlm(1:cql%numpw,ii) enddo close(iunq) return END SUBROUTINE write_compact_q_lanczos SUBROUTINE read_compact_q_lanczos(cql, iv) !this subroutine reads the compact_q_lanczos function from disk USE io_files, ONLY : prefix,tmp_dir USE mp, ONLY : mp_barrier,mp_bcast, mp_sum USE mp_world, ONLY : world_comm USE io_global, ONLY : ionode,ionode_id implicit none INTEGER, EXTERNAL :: find_free_unit TYPE(compact_q_lanczos) :: cql!the compact_q_lanczos function to be read INTEGER, INTENT(in) :: iv!the index of the file to be read INTEGER :: iunq, ii CHARACTER(5) :: nfile call free_memory_compact_q_lanczos(cql) cql%ii=iv write(nfile,'(5i1)') & & cql%ii/10000,mod(cql%ii,10000)/1000,mod(cql%ii,1000)/100,mod(cql%ii,100)/10,mod(cql%ii,10) if(ionode) then iunq = find_free_unit() open( unit=iunq, file=trim(tmp_dir)//trim(prefix)//'-'//'q_lanczos.'// nfile, status='old',form='unformatted') read(iunq) cql%ii read(iunq) cql%numpw read(iunq) cql%numt endif call mp_bcast(cql%ii,ionode_id,world_comm) call mp_bcast(cql%numpw,ionode_id,world_comm) call mp_bcast(cql%numt,ionode_id,world_comm) allocate(cql%qlm(cql%numpw,cql%numt)) do ii=1,cql%numt if(ionode) then read(iunq) cql%qlm(1:cql%numpw,ii) else cql%qlm(1:cql%numpw,ii)=0.d0 endif !call mp_barrier !call mp_bcast(cql%qlm(1:cql%numpw,ii),ionode_id,world_comm) !call mp_sum(cql%qlm(1:cql%numpw,ii)) enddo call mp_bcast(cql%qlm(:,:), ionode_id,world_comm) if(ionode) close(iunq) return END SUBROUTINE read_compact_q_lanczos SUBROUTINE do_compact_q_lanczos(vtl,ttl,cql,alpha) !this subroutines performs the calculation: ! Q^v'_in= Q^v'_in +alpha*V^v'_{i,l}T^v'_{l,n} USE kinds, ONLY : DP USE basic_structures, ONLY : tt_mat_lanczos, vt_mat_lanczos USE io_global, ONLY : stdout, ionode, ionode_id implicit none TYPE(vt_mat_lanczos), INTENT(in) :: vtl!V matrix TYPE(tt_mat_lanczos), INTENT(in) :: ttl!T matrix TYPE(compact_q_lanczos), INTENT(out) :: cql!Q matrix to be calculated REAL(kind=DP), INTENT(in) :: alpha!constant alpha INTEGER il,it,ip if(ttl%ii /= vtl%ii) then write(stdout,*) 'Routine do_compact_q_lanczos: state v not equal' FLUSH(stdout) stop else cql%ii=ttl%ii endif cql%numpw=vtl%numpw cql%numt=ttl%numt call dgemm('N','T',cql%numpw,cql%numt,vtl%numl,alpha,vtl%vt_mat,vtl%numpw,ttl%tt_mat,ttl%numt,1.d0,cql%qlm,cql%numpw) ! cql%qlm(:,:)=0.d0 ! do ip=1,cql%numpw ! do it=1,cql%numt ! do il=1,vtl%numl ! cql%qlm(ip,it)=cql%qlm(ip,it)+vtl%vt_mat(ip,il)*ttl%tt_mat(it,il) ! enddo ! enddo ! enddo return END SUBROUTINE do_compact_q_lanczos SUBROUTINE write_lanczos_matrix(lm) !this subroutine writes the lanczos matrix on disk !the file name is taken from the label USE io_files, ONLY : prefix,tmp_dir implicit none INTEGER, EXTERNAL :: find_free_unit TYPE(lanczos_matrix) :: lm!the matrix to be written INTEGER :: iunm, ii CHARACTER(5) :: nfile if(lm%iw >= 0) then write(nfile,'(5i1)') & & lm%iw/10000,mod(lm%iw,10000)/1000,mod(lm%iw,1000)/100,mod(lm%iw,100)/10,mod(lm%iw,10) iunm = find_free_unit() open( unit=iunm, file=trim(tmp_dir)//trim(prefix)//'-'//'emat_lanczos.'// nfile, status='unknown',form='unformatted') else write(nfile,'(5i1)') & & -lm%iw/10000,mod(-lm%iw,10000)/1000,mod(-lm%iw,1000)/100,mod(-lm%iw,100)/10,mod(-lm%iw,10) iunm = find_free_unit() open( unit=iunm, file=trim(tmp_dir)//trim(prefix)//'-'//'emat_lanczos.-'// nfile, status='unknown',form='unformatted') endif write(iunm) lm%iw write(iunm) lm%numt do ii=1,lm%numt write(iunm) lm%e_mat(1:lm%numt,ii) enddo close(iunm) return end SUBROUTINE write_lanczos_matrix SUBROUTINE read_lanczos_matrix(lm,iw) !this subroutine reads the lanczos matrix from disk !the file name is taken from the label !it does not allocate the matrix USE io_files, ONLY : prefix,tmp_dir implicit none INTEGER, EXTERNAL :: find_free_unit TYPE(lanczos_matrix) :: lm!the matrix to be read INTEGER :: iw!index of matrix to be read INTEGER :: iunm, ii CHARACTER(5) :: nfile lm%iw=iw if(lm%iw >= 0) then write(nfile,'(5i1)') & & lm%iw/10000,mod(lm%iw,10000)/1000,mod(lm%iw,1000)/100,mod(lm%iw,100)/10,mod(lm%iw,10) iunm = find_free_unit() open( unit=iunm, file=trim(tmp_dir)//trim(prefix)//'-'//'emat_lanczos.'// nfile, status='old',form='unformatted') else write(nfile,'(5i1)') & & -lm%iw/10000,mod(-lm%iw,10000)/1000,mod(-lm%iw,1000)/100,mod(-lm%iw,100)/10,mod(-lm%iw,10) iunm = find_free_unit() open( unit=iunm, file=trim(tmp_dir)//trim(prefix)//'-'//'emat_lanczos.-'// nfile, status='unknown',form='unformatted') endif read(iunm) lm%iw read(iunm) lm%numt do ii=1,lm%numt read(iunm) lm%e_mat(1:lm%numt,ii) enddo close(iunm) return END SUBROUTINE read_lanczos_matrix END MODULE lanczos
gpl-2.0
nvarini/espresso_iohpc
PHonon/PH/compute_alphasum.f90
8
6027
! ! Copyright (C) 2001 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_alphasum !----------------------------------------------------------------------- ! ! This routine computes the alphasum term which is used to compute the ! change of the charge due to the displacement of the augmentation ! term and a part of the US contribution to the dynamical matrix. ! ! It implements Eq.B17 of Ref.[1]. This quantity is distributed ! among processors. ! [1] PRB 64, 235118 (2001). ! ! USE kinds, only : DP USE ions_base, ONLY : nat, ityp, ntyp => nsp USE lsda_mod, ONLY : current_spin, isk, lsda USE wvfct, ONLY : nbnd, wg USE noncollin_module, ONLY : noncolin, npol USE uspp, ONLY: okvan USE uspp_param, ONLY: upf, nh USE paw_variables, ONLY : okpaw USE phus, ONLY : alphasum, alphasum_nc, alphap USE lrus, ONLY : becp1 USE qpoint, ONLY : nksq, ikks, ikqs USE control_ph, ONLY : rec_code_read USE control_lr, ONLY : nbnd_occ implicit none integer :: ik, ikk, ikq, ijkb0, ijh, ikb, jkb, ih, jh, na, nt, & ipol, ibnd, is1, is2 ! counter on k points ! counters on beta functions ! counters on beta functions ! counters for atoms ! counter on polarizations ! counter on bands real(DP) :: wgg1 ! auxiliary weight if (.not.okvan) return IF (rec_code_read >= -20.AND..NOT.okpaw) RETURN alphasum = 0.d0 IF (noncolin) alphasum_nc=(0.d0,0.d0) do ik = 1, nksq ikk = ikks(ik) ikq = ikqs(ik) if (lsda) current_spin = isk (ikk) ijkb0 = 0 do nt = 1, ntyp if (upf(nt)%tvanp ) then do na = 1, nat if (ityp (na) == nt) then ijh = 0 do ih = 1, nh (nt) ikb = ijkb0 + ih ijh = ijh + 1 do ibnd = 1, nbnd_occ (ikk) wgg1 = wg (ibnd, ikk) do ipol = 1, 3 IF (noncolin) THEN DO is1=1,npol DO is2=1,npol alphasum_nc(ijh,ipol,na,is1,is2) = & alphasum_nc(ijh,ipol,na,is1,is2)+wgg1* & (CONJG(alphap(ipol,ik)%nc(ikb,is1,ibnd))*& becp1(ik)%nc(ikb,is2,ibnd) + & CONJG(becp1(ik)%nc(ikb,is1,ibnd))* & alphap(ipol,ik)%nc(ikb,is2,ibnd)) END DO END DO ELSE alphasum(ijh,ipol,na,current_spin) = & alphasum(ijh,ipol,na,current_spin) + 2.d0*wgg1*& DBLE (CONJG(alphap(ipol,ik)%k(ikb,ibnd) ) * & becp1(ik)%k(ikb,ibnd) ) END IF enddo enddo do jh = ih+1, nh (nt) jkb = ijkb0 + jh ijh = ijh + 1 do ibnd = 1, nbnd wgg1 = wg (ibnd, ikk) do ipol = 1, 3 IF (noncolin) THEN DO is1=1,npol DO is2=1,npol alphasum_nc(ijh,ipol,na,is1,is2) = & alphasum_nc(ijh,ipol,na,is1,is2) & +wgg1* & (CONJG(alphap(ipol,ik)%nc(ikb,is1,ibnd))* & becp1(ik)%nc(jkb,is2,ibnd)+ & CONJG(becp1(ik)%nc(ikb,is1,ibnd))* & alphap(ipol,ik)%nc(jkb,is2,ibnd) ) END DO END DO ELSE alphasum(ijh,ipol,na,current_spin) = & alphasum(ijh,ipol,na,current_spin) + & 2.d0 * wgg1 * & DBLE(CONJG(alphap(ipol,ik)%k(ikb,ibnd) )*& becp1(ik)%k(jkb,ibnd) + & CONJG( becp1(ik)%k(ikb,ibnd) ) * & alphap(ipol,ik)%k(jkb,ibnd) ) END IF enddo enddo enddo enddo ijkb0 = ijkb0 + nh (nt) endif enddo else do na = 1, nat if (ityp (na) == nt) ijkb0 = ijkb0 + nh (nt) enddo endif enddo enddo IF (noncolin.and.okvan) THEN DO nt = 1, ntyp IF ( upf(nt)%tvanp ) THEN DO na = 1, nat IF (ityp(na)==nt) THEN IF (upf(nt)%has_so) THEN CALL transform_alphasum_so(alphasum_nc,na) ELSE CALL transform_alphasum_nc(alphasum_nc,na) END IF END IF END DO END IF END DO END IF ! do na=1,nat ! nt=ityp(na) ! do ijh=1,nh(nt)*(nh(nt)+1)/2 ! do ipol=1,3 ! WRITE( stdout,'(3i5,f20.10)') na, ijh, ipol, ! + alphasum(ijh,ipol,na,1) ! enddo ! enddo ! enddo ! call stop_ph(.true.) return end subroutine compute_alphasum
gpl-2.0
nvarini/espresso_iohpc
PP/src/sym_band.f90
2
42528
! ! Copyright (C) 2006-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 sym_band(filband, spin_component, firstk, lastk) !----------------------------------------------------------------------- ! USE kinds, ONLY : DP USE ions_base, ONLY : nat, ityp, ntyp => nsp USE cell_base, ONLY : at, bg, ibrav USE constants, ONLY : rytoev USE fft_base, ONLY : dfftp USE gvect, ONLY : ngm, nl, g USE lsda_mod, ONLY : nspin USE wvfct, ONLY : et, nbnd, npwx USE klist, ONLY : xk, nks, nkstot, ngk, igk_k USE io_files, ONLY : nwordwfc, iunwfc USE symm_base, ONLY : s, ftau, nsym, t_rev, sname USE rap_point_group, ONLY : code_group, nclass, nelem, elem, which_irr, & char_mat, name_rap, name_class, gname, ir_ram USE rap_point_group_so, ONLY : nrap, nelem_so, elem_so, has_e, & which_irr_so, char_mat_so, name_rap_so, & name_class_so, d_spin, name_class_so1 USE rap_point_group_is, ONLY : nsym_is, sr_is, ftau_is, gname_is, & sname_is, code_group_is USE uspp, ONLY : nkb, vkb USE spin_orb, ONLY : domag USE noncollin_module, ONLY : noncolin USE wavefunctions_module, ONLY : evc USE io_global, ONLY : ionode, ionode_id, stdout USE mp, ONLY : mp_bcast USE mp_images, ONLY : intra_image_comm ! IMPLICIT NONE ! INTEGER :: ik, i, j, irot, iclass, ig, ibnd INTEGER :: npw, spin_component, nks1, nks2, firstk, lastk INTEGER :: nks1tot, nks2tot INTEGER :: iunout, igroup, irap, dim_rap, ios INTEGER :: sk(3,3,48), ftauk(3,48), gk(3,48), sk_is(3,3,48), & gk_is(3,48), t_revk(48), nsymk, isym, ipol, jpol LOGICAL :: is_complex, is_complex_so, is_symmorphic, search_sym LOGICAL, ALLOCATABLE :: high_symmetry(:) REAL(DP), PARAMETER :: accuracy=1.d-4 COMPLEX(DP) :: d_spink(2,2,48), d_spin_is(2,2,48), zdotc COMPLEX(DP),ALLOCATABLE :: times(:,:,:) REAL(DP) :: dxk(3), dkmod, dkmod_save, modk1, modk2, k1(3), k2(3), ps INTEGER, ALLOCATABLE :: rap_et(:,:), code_group_k(:) INTEGER, ALLOCATABLE :: ngroup(:), istart(:,:) CHARACTER(len=11) :: group_name CHARACTER(len=45) :: snamek(48) CHARACTER (len=256) :: filband, namefile ! IF (spin_component/=1.and.nspin/=2) & CALL errore('sym_band','incorrect spin_component',1) IF (spin_component<1.or.spin_component>2) & CALL errore('sym_band','incorrect lsda spin_component',1) ALLOCATE(rap_et(nbnd,nkstot)) ALLOCATE(code_group_k(nkstot)) ALLOCATE(times(nbnd,24,nkstot)) ALLOCATE(ngroup(nkstot)) ALLOCATE(istart(nbnd+1,nkstot)) ALLOCATE(high_symmetry(nkstot)) code_group_k=0 rap_et=-1 times=(0.0_DP,0.0_DP) CALL find_nks1nks2(firstk,lastk,nks1tot,nks1,nks2tot,nks2,spin_component) ios=0 IF ( ionode ) THEN iunout=58 namefile=trim(filband)//".rap" OPEN (unit = iunout, file = namefile, status = 'unknown', form = & 'formatted', iostat = ios) REWIND (iunout) ENDIF CALL mp_bcast ( ios, ionode_id, intra_image_comm ) IF ( ios /= 0) CALL errore ('sym_band', 'Opening filband file', abs (ios) ) DO ik = nks1, nks2 ! npw = ngk(ik) CALL init_us_2 (npw, igk_k(1,ik), xk (1, ik), vkb) ! ! read eigenfunctions ! CALL davcio (evc, 2*nwordwfc, iunwfc, ik, - 1) ! ! Find the small group of k ! CALL smallgk (xk(1,ik), at, bg, s, ftau, t_rev, sname, nsym, sk, ftauk, & gk, t_revk, snamek, nsymk) ! ! character of the irreducible representations ! CALL find_info_group(nsymk,sk,t_revk,ftauk,d_spink,gk,snamek,& sk_is,d_spin_is,gk_is, & is_symmorphic,search_sym) code_group_k(ik)=code_group ! IF (.not.search_sym) THEN rap_et(:,ik)=-1 GOTO 100 ENDIF ! ! Find the symmetry of each state ! IF (noncolin) THEN IF (domag) THEN CALL find_band_sym_so(ik,evc,et(1,ik),nsym_is, & sk_is,ftau_is,d_spin_is,gk_is,& rap_et(1,ik),times(1,1,ik), & ngroup(ik),istart(1,ik),accuracy) ELSE CALL find_band_sym_so(ik,evc,et(1,ik),nsymk,sk,ftauk,d_spink,& gk,rap_et(1,ik),times(1,1,ik),ngroup(ik),& istart(1,ik),accuracy) ENDIF ELSE CALL find_band_sym (ik,evc, et(1,ik), nsymk, sk, ftauk, gk, & rap_et(1,ik), times(1,1,ik), ngroup(ik),& istart(1,ik),accuracy) ENDIF 100 CONTINUE ENDDO #ifdef __MPI ! ! Only the symmetry of a set of k points is calculated by this ! processor with pool. Here we collect the results into ionode ! CALL ipoolrecover(code_group_k,1,nkstot,nks) CALL ipoolrecover(rap_et,nbnd,nkstot,nks) CALL poolrecover(times,2*24*nbnd,nkstot,nks) CALL ipoolrecover(ngroup,1,nkstot,nks) CALL ipoolrecover(istart,nbnd+1,nkstot,nks) #endif IF (ionode) THEN high_symmetry = .FALSE. DO ik=nks1tot,nks2tot IF ( ik==nks1tot .OR. ik==nks2tot ) THEN high_symmetry(ik) = .TRUE. ELSE k1(:) = xk(:,ik) - xk(:,ik-1) k2(:) = xk(:,ik+1) - xk(:,ik) modk1=sqrt( k1(1)*k1(1) + k1(2)*k1(2) + k1(3)*k1(3) ) modk2=sqrt( k2(1)*k2(1) + k2(2)*k2(2) + k2(3)*k2(3) ) IF (modk1 <1.d-6 .OR. modk2 < 1.d-6) CYCLE ps = ( k1(1)*k2(1) + k1(2)*k2(2) + k1(3)*k2(3) ) / & modk1 / modk2 high_symmetry(ik) = (ABS(ps-1.d0) >1.0d-4) ! ! The gamma point is a high symmetry point ! IF (xk(1,ik)**2+xk(2,ik)**2+xk(3,ik)**2 < 1.0d-9) & high_symmetry(ik)=.TRUE. END IF END DO ! DO ik=nks1tot, nks2tot CALL smallgk (xk(1,ik), at, bg, s, ftau, t_rev, sname, & nsym, sk, ftauk, gk, t_revk, snamek, nsymk) CALL find_info_group(nsymk,sk,t_revk,ftauk,d_spink,gk,snamek,& sk_is,d_spin_is,gk_is, & is_symmorphic,search_sym) IF (code_group_k(ik) /= code_group) & CALL errore('sym_band','problem with code_group',1) WRITE(stdout, '(/,1x,74("*"))') WRITE(stdout, '(/,20x,"xk=(",2(f10.5,","),f10.5," )")') & xk(1,ik), xk(2,ik), xk(3,ik) IF (.not.search_sym) THEN WRITE(stdout,'(/,5x,"zone border point and non-symmorphic group ")') WRITE(stdout,'(5x,"symmetry decomposition not available")') WRITE(stdout, '(/,1x,74("*"))') ENDIF IF (ik == nks1tot) THEN WRITE (iunout, '(" &plot_rap nbnd_rap=",i4,", nks_rap=",i4," /")') & nbnd, nks2tot-nks1tot+1 IF (search_sym) CALL write_group_info(.true.) dxk(:) = xk(:,nks1tot+1) - xk(:,nks1tot) dkmod_save = sqrt( dxk(1)**2 + dxk(2)**2 + dxk(3)**2 ) ELSE IF (code_group_k(ik)/=code_group_k(ik-1).and.search_sym) & CALL write_group_info(.true.) ! ! When the symmetry changes the point must be considered a high ! symmetry point. If the previous point was also high_symmetry, there ! are two possibilities. The two points are distant and in this case ! both of them must be considered high symmetry. If they are close only ! the first point is a high symmetry point. First compute the distance ! dxk(:) = xk(:,ik) - xk(:,ik-1) dkmod= sqrt( dxk(1)**2 + dxk(2)**2 + dxk(3)**2 ) IF (dkmod < 1.D-6) THEN ! ! In this case is_high_sym does not change because the point ! is the same high_symmetry(ik)=high_symmetry(ik-1) ! ELSE IF (dkmod < 5.0_DP * dkmod_save) THEN ! ! In this case the two points are considered close ! IF ( .NOT. high_symmetry(ik-1) ) & high_symmetry(ik)= ((code_group_k(ik)/=code_group_k(ik-1)) & .OR. high_symmetry(ik) ) IF (dkmod > 1.d-3) dkmod_save=dkmod ELSE ! ! Points are distant. They are all high symmetry ! high_symmetry(ik) = .TRUE. ENDIF ENDIF WRITE (iunout, '(10x,3f10.6,l5)') xk(1,ik),xk(2,ik),xk(3,ik), & high_symmetry(ik) WRITE (iunout, '(10i8)') (rap_et(ibnd,ik), ibnd=1,nbnd) IF (.not.search_sym) CYCLE IF (noncolin) THEN IF (domag) THEN WRITE(stdout,'(/,5x,"Band symmetry, ",a11," [",a11, & & "] magnetic double point group,")') gname, gname_is WRITE(stdout,'(5x,"using ",a11,/)') gname_is ELSE WRITE(stdout,'(/,5x,"Band symmetry, ",a11,& & " double point group:",/)') gname ENDIF ELSE WRITE(stdout,'(/,5x,"Band symmetry, ",a11," point group:",/)') & group_name(code_group_k(ik)) ENDIF DO igroup=1,ngroup(ik) dim_rap=istart(igroup+1,ik)-istart(igroup,ik) DO irap=1,nclass IF (noncolin) THEN IF ((abs(nint(dble(times(igroup,irap,ik)))- & dble(times(igroup,irap,ik))) > accuracy).or. & (abs(aimag(times(igroup,irap,ik))) > accuracy) ) THEN WRITE(stdout,'(5x,"e(",i3," -",i3,") = ",f12.5,2x,& &"eV",3x,i3,3x, "--> ?")') & istart(igroup,ik), istart(igroup+1,ik)-1, & et(istart(igroup,ik),ik)*rytoev, dim_rap exit ELSEIF (abs(times(igroup,irap,ik)) > accuracy) THEN IF (abs(nint(dble(times(igroup,irap,ik))-1.d0)) < & accuracy) THEN WRITE(stdout,'(5x, "e(",i3," -",i3,") = ",& &f12.5,2x,"eV",3x,i3,3x,"--> ",a15)') & istart(igroup,ik), istart(igroup+1,ik)-1, & et(istart(igroup,ik),ik)*rytoev, & dim_rap, name_rap_so(irap) ELSE WRITE(stdout,'(5x,"e(",i3," -",i3,") = ",& &f12.5,2x,"eV",3x,i3,3x,"--> ",i3," ",a15)') & istart(igroup,ik), istart(igroup+1,ik)-1, & et(istart(igroup,ik),ik)*rytoev, dim_rap, & nint(dble(times(igroup,irap,ik))), name_rap_so(irap) ENDIF ENDIF ELSE IF ((abs(nint(dble(times(igroup,irap,ik)))- & dble(times(igroup,irap,ik))) > accuracy).or. & (abs(aimag(times(igroup,irap,ik))) > accuracy) ) THEN WRITE(stdout,'(5x,"e(",i3," -",i3,") = ",f12.5,2x,& &"eV",3x,i3,3x, "--> ?")') & istart(igroup,ik), istart(igroup+1,ik)-1, & et(istart(igroup,ik),ik)*rytoev, dim_rap exit ELSEIF (abs(times(igroup,irap,ik)) > accuracy) THEN IF (abs(nint(dble(times(igroup,irap,ik))-1.d0)) < & accuracy) THEN WRITE(stdout,'(5x, "e(",i3," -",i3,") = ",& &f12.5,2x,"eV",3x,i3,3x,"--> ",a15)') & istart(igroup,ik), istart(igroup+1,ik)-1, & et(istart(igroup,ik),ik)*rytoev, & dim_rap, name_rap(irap) ELSE WRITE(stdout,'(5x,"e(",i3," -",i3,") = ",& &f12.5,2x,"eV",3x,i3,3x,"--> ",i3," ",a15)') & istart(igroup,ik), istart(igroup+1,ik)-1, & et(istart(igroup,ik),ik)*rytoev, dim_rap, & nint(dble(times(igroup,irap,ik))), name_rap(irap) ENDIF ENDIF ENDIF ENDDO ENDDO WRITE( stdout, '(/,1x,74("*"))') ENDDO CLOSE(iunout) ENDIF ! DEALLOCATE(times) DEALLOCATE(code_group_k) DEALLOCATE(rap_et) DEALLOCATE(ngroup) DEALLOCATE(istart) DEALLOCATE(high_symmetry) ! RETURN END SUBROUTINE sym_band ! SUBROUTINE find_band_sym (ik,evc,et,nsym,s,ftau,gk,rap_et,times,ngroup,& istart,accuracy) ! ! This subroutine finds the irreducible representations which give ! the transformation properties of the wavefunctions. ! Presently it does NOT work at zone border if the space group of ! the crystal has fractionary translations (non-symmorphic space groups). ! ! USE io_global, ONLY : stdout USE kinds, ONLY : DP USE constants, ONLY : rytoev USE rap_point_group, ONLY : code_group, nclass, nelem, elem, which_irr, & char_mat, name_rap, name_class, gname USE gvect, ONLY : ngm, nl USE wvfct, ONLY : nbnd, npwx USE klist, ONLY : ngk, igk_k USE uspp, ONLY : vkb, nkb, okvan USE becmod, ONLY : bec_type, becp, calbec, & allocate_bec_type, deallocate_bec_type USE fft_base, ONLY : dfftp USE fft_interfaces, ONLY : invfft USE mp_bands, ONLY : intra_bgrp_comm USE mp, ONLY : mp_sum IMPLICIT NONE INTEGER, INTENT(in) :: ik REAL(DP), INTENT(in) :: accuracy INTEGER :: & nsym, & rap_et(nbnd), & ftau(3,48), & gk(3,48), & s(3,3,48), & ngroup, & ! number of different frequencies groups istart(nbnd+1) REAL(DP) :: & et(nbnd) COMPLEX(DP) :: & times(nbnd,24), & evc(npwx, nbnd) REAL(DP), PARAMETER :: eps=1.d-5 INTEGER :: & ibnd, & igroup, & dim_rap, & irot, & irap, & iclass, & shift, & na, i, j, ig, dimen, nrxx, npw COMPLEX(DP) :: zdotc REAL(DP), ALLOCATABLE :: w1(:) COMPLEX(DP), ALLOCATABLE :: evcr(:,:), trace(:,:), psic(:,:) ! ! Divide the bands on the basis of the band degeneracy. ! nrxx=dfftp%nnr ALLOCATE(w1(nbnd)) ALLOCATE(evcr(npwx,nbnd)) ALLOCATE(psic(nrxx,nbnd)) ALLOCATE(trace(48,nbnd)) IF (okvan) CALL allocate_bec_type ( nkb, nbnd, becp ) rap_et=-1 w1=et*rytoev ngroup=1 istart(ngroup)=1 DO ibnd=2,nbnd IF (abs(w1(ibnd)-w1(ibnd-1)) > 0.0001d0) THEN ngroup=ngroup+1 istart(ngroup)=ibnd ENDIF ENDDO istart(ngroup+1)=nbnd+1 ! ! bring all the bands in real space ! npw = ngk(ik) psic=(0.0_DP,0.0_DP) DO ibnd=1,nbnd psic(nl(igk_k(1:npw,ik)),ibnd) = evc(1:npw,ibnd) CALL invfft ('Dense', psic(:,ibnd), dfftp) ENDDO ! ! Find the character of one symmetry operation per class ! DO iclass=1,nclass irot=elem(1,iclass) ! ! Rotate all the bands together. ! NB: rotate_psi assume that s is in the small group of k. It does not ! rotate the k point. ! ! IF (irot==1) THEN evcr=evc ELSE CALL rotate_all_psi(ik,psic,evcr,s(1,1,irot),ftau(1,irot),gk(1,irot)) ENDIF ! ! and apply S if necessary ! IF ( okvan ) THEN CALL calbec( npw, vkb, evcr, becp ) CALL s_psi( npwx, npw, nbnd, evcr, evcr ) ENDIF ! ! Compute the trace of the representation for each group of bands ! DO igroup=1,ngroup dim_rap=istart(igroup+1)-istart(igroup) trace(iclass,igroup)=(0.d0,0.d0) DO i=1,dim_rap ibnd=istart(igroup)+i-1 trace(iclass,igroup)=trace(iclass,igroup) + & zdotc(npw,evc(1,ibnd),1,evcr(1,ibnd),1) ENDDO ! write(6,*) igroup, iclass, trace(iclass,igroup) ENDDO ENDDO ! CALL mp_sum( trace, intra_bgrp_comm ) !DO iclass=1,nclass ! write(6,'(i5,3(2f11.8,1x))') iclass,trace(iclass,4),trace(iclass,5), & ! trace(iclass,6) !ENDDO ! ! And now use the character table to identify the symmetry representation ! of each group of bands ! !WRITE(stdout,'(/,5x,"Band symmetry, ",a11," point group:",/)') gname DO igroup=1,ngroup dim_rap=istart(igroup+1)-istart(igroup) shift=0 DO irap=1,nclass times(igroup,irap)=(0.d0,0.d0) DO iclass=1,nclass times(igroup,irap)=times(igroup,irap) & +trace(iclass,igroup)*char_mat(irap,which_irr(iclass))& *nelem(iclass) ENDDO times(igroup,irap)=times(igroup,irap)/nsym IF ((abs(nint(dble(times(igroup,irap)))-dble(times(igroup,irap))) & > accuracy).or. (abs(aimag(times(igroup,irap))) > eps) ) THEN ! WRITE(stdout,'(5x,"e(",i3," -",i3,") = ",f12.5,2x,"eV",3x,i3,3x,& ! & "--> ?")') & ! istart(igroup), istart(igroup+1)-1, w1(istart(igroup)), dim_rap ibnd=istart(igroup) IF (rap_et(ibnd)==-1) THEN DO i=1,dim_rap ibnd=istart(igroup)+i-1 rap_et(ibnd)=0 ENDDO ENDIF GOTO 300 ELSEIF (abs(times(igroup,irap)) > accuracy) THEN ibnd=istart(igroup)+shift dimen=nint(dble(char_mat(irap,1))) IF (rap_et(ibnd)==-1) THEN DO i=1,dimen*nint(dble(times(igroup,irap))) ibnd=istart(igroup)+shift+i-1 rap_et(ibnd)=irap ENDDO shift=shift+dimen*nint(dble(times(igroup,irap))) ENDIF ! IF (ABS(NINT(DBLE(times))-1.d0) < 1.d-4) THEN ! WRITE(stdout,'(5x, "e(",i3," -",i3,") = ",f12.5,2x,"eV",3x,i3,& ! & 3x,"--> ",a15)') & ! istart(igroup), istart(igroup+1)-1, w1(istart(igroup)), & ! dim_rap, name_rap(irap) ! ELSE ! WRITE(stdout,'(5x,"e(",i3," -",i3,") = ",f12.5,2x,"eV",3x,i3,3x,& ! & "--> ",i3," ",a15)') & ! istart(igroup), istart(igroup+1)-1, & ! w1(istart(igroup)), dim_rap, NINT(DBLE(times)), name_rap(irap) ! END IF ENDIF ENDDO 300 CONTINUE ENDDO !WRITE( stdout, '(/,1x,74("*"))') DEALLOCATE(trace) DEALLOCATE(w1) DEALLOCATE(evcr) DEALLOCATE(psic) IF (okvan) CALL deallocate_bec_type (becp) RETURN END SUBROUTINE find_band_sym SUBROUTINE rotate_all_psi(ik,psic,evcr,s,ftau,gk) USE kinds, ONLY : DP USE constants, ONLY : tpi USE gvect, ONLY : ngm, nl USE wvfct, ONLY : nbnd, npwx USE klist, ONLY : ngk, igk_k USE fft_base, ONLY : dfftp USE scatter_mod, ONLY : cgather_sym_many, cscatter_sym_many USE fft_interfaces, ONLY : fwfft, invfft USE mp_bands, ONLY : intra_bgrp_comm USE mp, ONLY : mp_sum IMPLICIT NONE INTEGER, INTENT(IN) :: ik INTEGER :: s(3,3), ftau(3), gk(3) COMPLEX(DP), ALLOCATABLE :: psir(:) COMPLEX(DP) :: psic(dfftp%nnr,nbnd), evcr(npwx,nbnd) COMPLEX(DP) :: phase REAL(DP) :: arg INTEGER :: i, j, k, ri, rj, rk, ir, rir, ipol, ibnd INTEGER :: nr1, nr2, nr3, nr1x, nr2x, nr3x, nrxx, npw LOGICAL :: zone_border INTEGER :: start_band, last_band, my_nbnd_proc INTEGER :: start_band_proc(dfftp%nproc), nbnd_proc(dfftp%nproc) #if defined (__MPI) ! COMPLEX (DP), ALLOCATABLE :: psir_collect(:) COMPLEX (DP), ALLOCATABLE :: psic_collect(:,:) ! #endif ! nr1=dfftp%nr1 nr2=dfftp%nr2 nr3=dfftp%nr3 nr1x=dfftp%nr1x nr2x=dfftp%nr2x nr3x=dfftp%nr3x nrxx=dfftp%nnr npw = ngk(ik) ! ALLOCATE(psir(nrxx)) ! zone_border=(gk(1)/=0.OR.gk(2)/=0.OR.gk(3)/=0) ! evcr= (0.0_DP, 0.0_DP) ! #if defined (__MPI) call divide (intra_bgrp_comm, nbnd, start_band, last_band) start_band_proc=0 start_band_proc(dfftp%mype+1)=start_band nbnd_proc=0 my_nbnd_proc=last_band-start_band+1 nbnd_proc(dfftp%mype+1)=my_nbnd_proc CALL mp_sum(start_band_proc, intra_bgrp_comm) CALL mp_sum(nbnd_proc, intra_bgrp_comm) ! ALLOCATE (psic_collect(nr1x*nr2x*nr3x, my_nbnd_proc)) ALLOCATE (psir_collect(nr1x*nr2x*nr3x)) ! CALL cgather_sym_many( dfftp, psic, psic_collect, nbnd, nbnd_proc, start_band_proc) ! DO ibnd = 1, my_nbnd_proc psir_collect=(0.d0,0.d0) ! IF (zone_border) THEN DO k = 1, nr3 DO j = 1, nr2 DO i = 1, nr1 CALL ruotaijk (s, ftau, i, j, k, nr1, nr2, nr3, ri, rj, rk ) ir=i+(j-1)*nr1x+(k-1)*nr1x*nr2x rir=ri+(rj-1)*nr1x+(rk-1)*nr1x*nr2x arg=tpi*( (gk(1)*(i-1))/dble(nr1)+(gk(2)*(j-1))/dble(nr2)+ & (gk(3)*(k-1))/dble(nr3) ) phase=cmplx(cos(arg),sin(arg),kind=DP) psir_collect(ir)=psic_collect(rir,ibnd)*phase ENDDO ENDDO ENDDO ELSE DO k = 1, nr3 DO j = 1, nr2 DO i = 1, nr1 CALL ruotaijk (s, ftau, i, j, k, nr1, nr2, nr3, ri, rj, rk ) ir=i+(j-1)*nr1x+(k-1)*nr1x*nr2x rir=ri+(rj-1)*nr1x+(rk-1)*nr1x*nr2x psir_collect(ir)=psic_collect(rir, ibnd) ENDDO ENDDO ENDDO ENDIF psic_collect(:,ibnd)=psir_collect(:) ENDDO ! DO ibnd=1, nbnd CALL cscatter_sym_many( dfftp, psic_collect, psir, ibnd, nbnd, & nbnd_proc, start_band_proc ) ! CALL fwfft ('Dense', psir, dfftp) ! evcr(1:npw,ibnd) = psir(nl(igk_k(1:npw,ik))) END DO DEALLOCATE (psic_collect) DEALLOCATE (psir_collect) ! #else psir=(0.d0,0.d0) DO ibnd=1,nbnd IF (zone_border) THEN DO k = 1, nr3 DO j = 1, nr2 DO i = 1, nr1 CALL ruotaijk (s, ftau, i, j, k, nr1, nr2, nr3, ri, rj, rk ) ir=i+(j-1)*nr1x+(k-1)*nr1x*nr2x rir=ri+(rj-1)*nr1x+(rk-1)*nr1x*nr2x arg=tpi*( (gk(1)*(i-1))/dble(nr1)+(gk(2)*(j-1))/dble(nr2)+ & (gk(3)*(k-1))/dble(nr3) ) phase=cmplx(cos(arg),sin(arg),kind=DP) psir(ir)=psic(rir,ibnd)*phase ENDDO ENDDO ENDDO ELSE DO k = 1, nr3 DO j = 1, nr2 DO i = 1, nr1 CALL ruotaijk (s, ftau, i, j, k, nr1, nr2, nr3, ri, rj, rk ) ir=i+(j-1)*nr1x+(k-1)*nr1x*nr2x rir=ri+(rj-1)*nr1x+(rk-1)*nr1x*nr2x psir(ir)=psic(rir,ibnd) ENDDO ENDDO ENDDO ENDIF CALL fwfft ('Dense', psir, dfftp) ! evcr(1:npw,ibnd) = psir(nl(igk_k(1:npw,ik))) ENDDO ! #endif ! DEALLOCATE(psir) ! RETURN END SUBROUTINE rotate_all_psi SUBROUTINE find_band_sym_so (ik,evc,et,nsym,s,ftau,d_spin,gk, & rap_et,times,ngroup,istart,accuracy) ! ! This subroutine finds the irreducible representations of the ! double group which give the transformation properties of the ! spinor wavefunctions evc. ! Presently it does NOT work at zone border if the space group of ! the crystal has fractionary translations (non-symmorphic space groups). ! ! USE io_global, ONLY : stdout USE kinds, ONLY : DP USE constants, ONLY : rytoev USE rap_point_group, ONLY : code_group, nclass, gname USE rap_point_group_so, ONLY : nrap, nelem_so, elem_so, has_e, which_irr_so, & char_mat_so, name_rap_so, name_class_so, & name_class_so1 USE rap_point_group_is, ONLY : gname_is USE gvect, ONLY : ngm, nl USE wvfct, ONLY : nbnd, npwx USE klist, ONLY : ngk USE spin_orb, ONLY : domag USE uspp, ONLY : vkb, nkb, okvan USE noncollin_module, ONLY : npol USE becmod, ONLY : bec_type, becp, calbec, allocate_bec_type, deallocate_bec_type USE mp_bands, ONLY : intra_bgrp_comm USE mp, ONLY : mp_sum IMPLICIT NONE INTEGER, INTENT(in) :: ik REAL(DP), INTENT(in) :: accuracy INTEGER :: & nsym, & ngroup, & istart(nbnd+1), & rap_et(nbnd), & ftau(3,48), & gk(3,48), & s(3,3,48) REAL(DP) :: & et(nbnd) COMPLEX(DP) :: & times(nbnd,24), & d_spin(2,2,48), & evc(npwx*npol, nbnd) REAL(DP), PARAMETER :: eps=1.d-5 INTEGER :: & ibnd, & igroup, & dim_rap, & ! counters irot, & irap, & shift, & iclass, & na, i, j, ig, ipol, jpol, jrap, dimen, npw COMPLEX(DP) :: zdotc ! moltiplication factors REAL(DP), ALLOCATABLE :: w1(:) ! list of energy eigenvalues in eV COMPLEX(DP), ALLOCATABLE :: evcr(:,:), & ! the rotated of each wave function trace(:,:) ! the trace of the symmetry matrix ! within a given group ! ! Divide the bands on the basis of the band degeneracy. ! ALLOCATE(w1(nbnd)) ALLOCATE(evcr(npwx*npol,nbnd)) ALLOCATE(trace(48,nbnd)) IF (okvan) CALL allocate_bec_type ( nkb, nbnd, becp ) rap_et=-1 w1=et*rytoev ! ! divide the energies in groups of degenerate eigenvalues. Two eigenvalues ! are assumed to be degenerate if their difference is less than 0.0001 eV. ! ngroup=1 istart(ngroup)=1 DO ibnd=2,nbnd IF (abs(w1(ibnd)-w1(ibnd-1)) > 0.0001d0) THEN ngroup=ngroup+1 istart(ngroup)=ibnd ENDIF ENDDO istart(ngroup+1)=nbnd+1 ! ! Find the character of one symmetry operation per class ! trace=(0.d0,0.d0) DO iclass=1,nclass irot=elem_so(1,iclass) ! ! Rotate all the bands together. ! NB: rotate_psi assumes that s is in the small group of k. It does not ! rotate the k point. ! CALL rotate_all_psi_so(ik,evc,evcr,s(1,1,irot), & ftau(1,irot),d_spin(1,1,irot),has_e(1,iclass),gk(1,irot)) ! ! and apply S in the US case. ! npw = ngk(ik) IF ( okvan ) THEN CALL calbec( npw, vkb, evcr, becp ) CALL s_psi( npwx, npw, nbnd, evcr, evcr ) ENDIF ! ! Compute the trace of the representation for each group of bands ! DO igroup=1,ngroup dim_rap=istart(igroup+1)-istart(igroup) DO i=1,dim_rap ibnd=istart(igroup)+i-1 trace(iclass,igroup)=trace(iclass,igroup) + & zdotc(2*npwx,evc(1,ibnd),1,evcr(1,ibnd),1) ENDDO ! write(6,*) igroup, iclass, dim_rap, trace(iclass,igroup) ENDDO ENDDO ! CALL mp_sum(trace,intra_bgrp_comm) ! !DO iclass=1,nclass ! write(6,'(i5,3(2f11.8,1x))') iclass,trace(iclass,1),trace(iclass,2), & ! trace(iclass,3) !ENDDO ! ! And now use the character table to identify the symmetry representation ! of each group of bands ! !IF (domag) THEN ! WRITE(stdout,'(/,5x,"Band symmetry, ",a11," [",a11, & ! & "] magnetic double point group,")') gname, gname_is ! WRITE(stdout,'(5x,"using ",a11,/)') gname_is !ELSE ! WRITE(stdout,'(/,5x,"Band symmetry, ",a11," double point group:",/)') gname !ENDIF DO igroup=1,ngroup dim_rap=istart(igroup+1)-istart(igroup) shift=0 DO irap=1,nrap times(igroup,irap)=(0.d0,0.d0) DO iclass=1,nclass times(igroup,irap)=times(igroup,irap) & +conjg(trace(iclass,igroup))*char_mat_so(irap, & which_irr_so(iclass))*dble(nelem_so(iclass)) ENDDO times(igroup,irap)=times(igroup,irap)/2/nsym IF ((abs(nint(dble(times(igroup,irap)))-dble(times(igroup,irap)))& > accuracy).or. (abs(aimag(times(igroup,irap))) > accuracy) ) THEN ! WRITE(stdout,'(5x,"e(",i3," -",i3,") = ",f12.5,2x,"eV",3x,i3,3x,& ! & "--> ?")') & ! istart(igroup), istart(igroup+1)-1, w1(istart(igroup)), dim_rap ibnd=istart(igroup) IF (rap_et(ibnd)==-1) THEN DO i=1,dim_rap ibnd=istart(igroup)+i-1 rap_et(ibnd)=0 ENDDO ENDIF GOTO 300 ENDIF IF (abs(times(igroup,irap)) > accuracy) THEN dimen=nint(dble(char_mat_so(irap,1))) ibnd=istart(igroup) + shift IF (rap_et(ibnd)==-1) THEN DO i=1,dimen*nint(dble(times(igroup,irap))) ibnd=istart(igroup)+shift+i-1 rap_et(ibnd)=irap ENDDO shift=shift+dimen*nint(dble(times(igroup,irap))) ENDIF ! IF (ABS(NINT(DBLE(times))-1.d0) < 1.d-4) THEN ! WRITE(stdout,'(5x, "e(",i3," -",i3,") = ",f12.5,2x,"eV",3x,i3,3x,& ! & "--> ",a15)') & ! istart(igroup), istart(igroup+1)-1, w1(istart(igroup)), & ! dim_rap, name_rap_so(irap) ! ELSE ! WRITE(stdout,'(5x,"e(",i3," -",i3,") = ",f12.5,2x,"eV",3x,i3,& ! & 3x,"--> ",i3," ",a15)') & ! istart(igroup), istart(igroup+1)-1, & ! w1(istart(igroup)), dim_rap, NINT(DBLE(times)), name_rap_so(irap) ! END IF ENDIF ENDDO 300 CONTINUE ENDDO !WRITE( stdout, '(/,1x,74("*"))') DEALLOCATE(trace) DEALLOCATE(w1) DEALLOCATE(evcr) IF (okvan) CALL deallocate_bec_type ( becp ) RETURN END SUBROUTINE find_band_sym_so SUBROUTINE rotate_all_psi_so(ik,evc_nc,evcr,s,ftau,d_spin,has_e,gk) ! ! This subroutine rotates a spinor wavefunction according to the symmetry ! s. d_spin contains the 2x2 rotation matrix in the spin space. ! has_e=-1 means that also a 360 degrees rotation is applied in spin space. ! USE kinds, ONLY : DP USE constants, ONLY : tpi USE fft_base, ONLY : dfftp USE scatter_mod, ONLY : cgather_sym_many, cscatter_sym_many USE fft_interfaces, ONLY : fwfft, invfft USE gvect, ONLY : ngm, nl USE wvfct, ONLY : nbnd, npwx USE klist, ONLY : ngk, igk_k USE noncollin_module, ONLY : npol USE mp_bands, ONLY : intra_bgrp_comm USE mp, ONLY : mp_sum IMPLICIT NONE INTEGER, INTENT(in) :: ik INTEGER :: s(3,3), ftau(3), gk(3), has_e COMPLEX(DP) :: evc_nc(npwx,2,nbnd), evcr(npwx,2,nbnd), d_spin(2,2) COMPLEX(DP), ALLOCATABLE :: psic(:,:), psir(:), evcr_save(:,:,:) COMPLEX(DP) :: phase REAL(DP) :: arg INTEGER :: i, j, k, ri, rj, rk, ir, rir, ipol, jpol, ibnd INTEGER :: nr1, nr2, nr3, nr1x, nr2x, nr3x, nrxx, npw LOGICAL :: zone_border INTEGER :: start_band, last_band, my_nbnd_proc INTEGER :: start_band_proc(dfftp%nproc), nbnd_proc(dfftp%nproc) ! #if defined (__MPI) ! COMPLEX (DP), ALLOCATABLE :: psir_collect(:) COMPLEX (DP), ALLOCATABLE :: psic_collect(:,:) ! #endif nr1=dfftp%nr1 nr2=dfftp%nr2 nr3=dfftp%nr3 nr1x=dfftp%nr1x nr2x=dfftp%nr2x nr3x=dfftp%nr3x nrxx=dfftp%nnr #if defined (__MPI) call divide (intra_bgrp_comm, nbnd, start_band, last_band) start_band_proc=0 start_band_proc(dfftp%mype+1)=start_band nbnd_proc=0 my_nbnd_proc=last_band-start_band+1 nbnd_proc(dfftp%mype+1)=my_nbnd_proc CALL mp_sum(start_band_proc, intra_bgrp_comm) CALL mp_sum(nbnd_proc, intra_bgrp_comm) ALLOCATE (psic_collect(nr1x*nr2x*nr3x,my_nbnd_proc)) ALLOCATE (psir_collect(nr1x*nr2x*nr3x)) #endif ! ALLOCATE(psic(nrxx,nbnd)) ALLOCATE(psir(nrxx)) ALLOCATE(evcr_save(npwx,npol,nbnd)) ! zone_border=(gk(1)/=0.or.gk(2)/=0.or.gk(3)/=0) ! npw = ngk(ik) DO ipol=1,npol ! psic = ( 0.D0, 0.D0 ) psir = ( 0.D0, 0.D0 ) ! DO ibnd=1,nbnd psic(nl(igk_k(1:npw,ik)),ibnd) = evc_nc(1:npw,ipol,ibnd) CALL invfft ('Dense', psic(:,ibnd), dfftp) ENDDO ! #if defined (__MPI) ! ! CALL cgather_sym_many( dfftp, psic, psic_collect, nbnd, nbnd_proc, & start_band_proc ) ! psir_collect=(0.d0,0.d0) DO ibnd=1,my_nbnd_proc ! IF (zone_border) THEN DO k = 1, nr3 DO j = 1, nr2 DO i = 1, nr1 CALL ruotaijk (s, ftau, i, j, k, nr1, nr2, nr3, ri, rj, rk ) ir=i+(j-1)*nr1x+(k-1)*nr1x*nr2x rir=ri+(rj-1)*nr1x+(rk-1)*nr1x*nr2x arg=tpi*( (gk(1)*(i-1))/dble(nr1)+(gk(2)*(j-1))/dble(nr2)+ & (gk(3)*(k-1))/dble(nr3) ) phase=cmplx(cos(arg),sin(arg),kind=DP) psir_collect(ir)=psic_collect(rir,ibnd)*phase ENDDO ENDDO ENDDO ELSE DO k = 1, nr3 DO j = 1, nr2 DO i = 1, nr1 CALL ruotaijk (s, ftau, i, j, k, nr1, nr2, nr3, ri, rj, rk ) ir=i+(j-1)*nr1x+(k-1)*nr1x*nr2x rir=ri+(rj-1)*nr1x+(rk-1)*nr1x*nr2x psir_collect(ir)=psic_collect(rir,ibnd) ENDDO ENDDO ENDDO ENDIF psic_collect(:,ibnd) = psir_collect(:) ENDDO DO ibnd=1,nbnd ! CALL cscatter_sym_many(dfftp, psic_collect, psir, ibnd, nbnd, nbnd_proc, & start_band_proc) CALL fwfft ('Dense', psir, dfftp) ! evcr_save(1:npw,ipol,ibnd) = psir(nl(igk_k(1:npw,ik))) ENDDO ! #else DO ibnd=1,nbnd IF (zone_border) THEN DO k = 1, nr3 DO j = 1, nr2 DO i = 1, nr1 CALL ruotaijk (s, ftau, i, j, k, nr1, nr2, nr3, ri, rj, rk ) ir=i+(j-1)*nr1x+(k-1)*nr1x*nr2x rir=ri+(rj-1)*nr1x+(rk-1)*nr1x*nr2x arg=tpi*( (gk(1)*(i-1))/dble(nr1)+(gk(2)*(j-1))/dble(nr2)+ & (gk(3)*(k-1))/dble(nr3) ) phase=cmplx(cos(arg),sin(arg),kind=DP) psir(ir)=psic(rir,ibnd)*phase ENDDO ENDDO ENDDO ELSE DO k = 1, nr3 DO j = 1, nr2 DO i = 1, nr1 CALL ruotaijk (s, ftau, i, j, k, nr1, nr2, nr3, ri, rj, rk ) ir=i+(j-1)*nr1x+(k-1)*nr1x*nr2x rir=ri+(rj-1)*nr1x+(rk-1)*nr1x*nr2x psir(ir)=psic(rir,ibnd) ENDDO ENDDO ENDDO ENDIF CALL fwfft ('Dense', psir(:), dfftp) ! evcr_save(1:npw,ipol,ibnd) = psir(nl(igk_k(1:npw,ik))) ENDDO ! #endif ! ! ENDDO evcr=(0.d0,0.d0) DO ibnd=1,nbnd DO ipol=1,npol DO jpol=1,npol evcr(:,ipol,ibnd)=evcr(:,ipol,ibnd)+ & conjg(d_spin(jpol,ipol))*evcr_save(:,jpol,ibnd) ENDDO ENDDO ENDDO IF (has_e==-1) evcr=-evcr ! DEALLOCATE(evcr_save) DEALLOCATE(psic) DEALLOCATE(psir) #if defined (__MPI) DEALLOCATE (psic_collect) DEALLOCATE (psir_collect) #endif RETURN END SUBROUTINE rotate_all_psi_so SUBROUTINE find_nks1nks2(firstk,lastk,nks1tot,nks1,nks2tot,nks2,spin_component) ! ! This routine selects the first (nks1) and last (nks2) k point calculated ! by the current pool. ! USE lsda_mod, ONLY : nspin USE klist, ONLY : nks, nkstot USE mp_global, ONLY : my_pool_id, npool, kunit IMPLICIT NONE INTEGER, INTENT(out) :: nks1tot,nks1,nks2tot,nks2 INTEGER, INTENT(in) :: firstk, lastk, spin_component INTEGER :: nbase, rest IF (nspin==1.or.nspin==4) THEN nks1tot=max(1,firstk) nks2tot=min(nkstot, lastk) ELSEIF (nspin==2) THEN IF (spin_component == 1) THEN nks1tot=max(1,firstk) nks2tot=min(nkstot/2,lastk) ELSEIF (spin_component==2) THEN nks1tot=nkstot/2 + max(1,firstk) nks2tot=nkstot/2 + min(nkstot/2,lastk) ENDIF ENDIF IF (nks1tot>nks2tot) CALL errore('findnks1nks2','wrong nks1tot or nks2tot',1) #ifdef __MPI nks = kunit * ( nkstot / kunit / npool ) rest = ( nkstot - nks * npool ) / kunit IF ( ( my_pool_id + 1 ) <= rest ) nks = nks + kunit ! ! ... calculates nbase = the position in the list of the first point that ! ... belong to this npool - 1 ! nbase = nks * my_pool_id IF ( ( my_pool_id + 1 ) > rest ) nbase = nbase + rest * kunit nks1=max(1,nks1tot-nbase) IF (nks1>nks) nks1=nks+1 nks2=min(nks,nks2tot-nbase) IF (nks2<1) nks2=nks1-1 #else nks1=nks1tot nks2=nks2tot #endif END SUBROUTINE find_nks1nks2 SUBROUTINE find_info_group(nsym,s,t_rev,ftau,d_spink,gk,sname, & s_is,d_spin_is,gk_is, & is_symmorphic,search_sym) ! ! This routine receives as input a point group and sets the corresponding ! variables for the description of the classes and of the irreducible ! representations. It sets also the group name and code. ! In the magnetic case it selects the invariat subgroup. ! USE kinds, ONLY : DP USE cell_base, ONLY : at, bg USE noncollin_module, ONLY : noncolin USE spin_orb, ONLY : domag USE rap_point_group, ONLY : code_group, nclass, nelem, elem, which_irr, & char_mat, name_rap, name_class, gname, ir_ram USE rap_point_group_so, ONLY : nrap, nelem_so, elem_so, has_e, & which_irr_so, char_mat_so, name_rap_so, & name_class_so, d_spin, name_class_so1 USE rap_point_group_is, ONLY : nsym_is, sr_is, ftau_is, gname_is, & sname_is, code_group_is IMPLICIT NONE INTEGER, INTENT(in) :: nsym, & ! dimension of the group s(3,3,48), & ! rotation matrices t_rev(48), & ! if time reversal is need ftau(3,48), & ! fractionary translation gk(3,48) INTEGER, INTENT(out) :: s_is(3,3,48), & ! rotation matrices gk_is(3,48) COMPLEX(DP),INTENT(out) :: d_spink(2,2,48), & ! rotation in spin space d_spin_is(2,2,48) ! rotation in spin space LOGICAL, INTENT(out) :: is_symmorphic, & ! true if the gruop is symmorphic search_sym ! true if gk CHARACTER(len=45), INTENT(in) :: sname(48) REAL(DP) :: sr(3,3,48) INTEGER :: isym is_symmorphic=.true. search_sym=.true. DO isym=1,nsym is_symmorphic=( is_symmorphic.and.(ftau(1,isym)==0).and. & (ftau(2,isym)==0).and. & (ftau(3,isym)==0) ) ENDDO IF (.not.is_symmorphic) THEN DO isym=1,nsym search_sym=( search_sym.and.(gk(1,isym)==0).and. & (gk(2,isym)==0).and. & (gk(3,isym)==0) ) ENDDO ENDIF ! ! Set the group name, divide it in classes and set the irreducible ! representations ! nsym_is=0 DO isym=1,nsym CALL s_axis_to_cart (s(1,1,isym), sr(1,1,isym), at, bg) IF (noncolin) THEN ! ! In the noncollinear magnetic case finds the invariant subgroup of the point ! group of k. Presently we use only this subgroup to classify the levels. ! IF (domag) THEN IF (t_rev(isym)==0) THEN nsym_is=nsym_is+1 CALL s_axis_to_cart (s(1,1,isym), sr_is(1,1,nsym_is), at, bg) CALL find_u(sr_is(1,1,nsym_is),d_spin_is(1,1,nsym_is)) s_is(:,:,nsym_is)=s(:,:,isym) gk_is(:,nsym_is)=gk(:,isym) ftau_is(:,nsym_is)=ftau(:,isym) sname_is(nsym_is)=sname(isym) ENDIF ELSE CALL find_u(sr(1,1,isym),d_spink(1,1,isym)) ENDIF ENDIF ENDDO CALL find_group(nsym,sr,gname,code_group) IF (noncolin) THEN IF (domag) THEN CALL find_group(nsym_is,sr_is,gname_is,code_group_is) CALL set_irr_rap_so(code_group_is,nclass,nrap,char_mat_so, & name_rap_so,name_class_so,name_class_so1) CALL divide_class_so(code_group_is,nsym_is,sr_is,d_spin_is,& has_e,nclass,nelem_so,elem_so,which_irr_so) ELSE CALL set_irr_rap_so(code_group,nclass,nrap,char_mat_so, & name_rap_so,name_class_so,name_class_so1) CALL divide_class_so(code_group,nsym,sr,d_spink, & has_e,nclass,nelem_so,elem_so,which_irr_so) ENDIF ELSE CALL set_irr_rap(code_group,nclass,char_mat,name_rap,name_class,ir_ram) CALL divide_class(code_group,nsym,sr,nclass,nelem,elem,which_irr) ENDIF RETURN END SUBROUTINE find_info_group ! ! Copyright (C) 2001 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 s_axis_to_cart (s, sr, at, bg) !---------------------------------------------------------------------- ! ! This routine transform a symmetry matrix expressed in the ! basis of the crystal axis in the cartesian basis. ! ! last revised 3 may 1995 by A. Dal Corso ! ! USE kinds IMPLICIT NONE ! ! first the input parameters ! INTEGER :: s (3, 3) ! input: matrix in crystal axis real(DP) :: sr (3, 3), at (3, 3), bg (3, 3) ! output: matrix in cartesian axis ! input: direct lattice vectors ! input: reciprocal lattice vectors ! ! here the local variable ! INTEGER :: apol, bpol, kpol, lpol ! ! counters on polarizations ! DO apol = 1, 3 DO bpol = 1, 3 sr (apol, bpol) = 0.d0 DO kpol = 1, 3 DO lpol = 1, 3 sr (apol, bpol) = sr (apol, bpol) + at (apol, kpol) * & dble ( s (lpol, kpol) ) * bg (bpol, lpol) ENDDO ENDDO ENDDO ENDDO RETURN END SUBROUTINE s_axis_to_cart
gpl-2.0
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/sstebz.f
28
23658
*> \brief \b SSTEBZ * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download SSTEBZ + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sstebz.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sstebz.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sstebz.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE SSTEBZ( RANGE, ORDER, N, VL, VU, IL, IU, ABSTOL, D, E, * M, NSPLIT, W, IBLOCK, ISPLIT, WORK, IWORK, * INFO ) * * .. Scalar Arguments .. * CHARACTER ORDER, RANGE * INTEGER IL, INFO, IU, M, N, NSPLIT * REAL ABSTOL, VL, VU * .. * .. Array Arguments .. * INTEGER IBLOCK( * ), ISPLIT( * ), IWORK( * ) * REAL D( * ), E( * ), W( * ), WORK( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> SSTEBZ computes the eigenvalues of a symmetric tridiagonal *> matrix T. The user may ask for all eigenvalues, all eigenvalues *> in the half-open interval (VL, VU], or the IL-th through IU-th *> eigenvalues. *> *> To avoid overflow, the matrix must be scaled so that its *> largest element is no greater than overflow**(1/2) * underflow**(1/4) in absolute value, and for greatest *> accuracy, it should not be much smaller than that. *> *> See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal *> Matrix", Report CS41, Computer Science Dept., Stanford *> University, July 21, 1966. *> \endverbatim * * Arguments: * ========== * *> \param[in] RANGE *> \verbatim *> RANGE is CHARACTER*1 *> = 'A': ("All") all eigenvalues will be found. *> = 'V': ("Value") all eigenvalues in the half-open interval *> (VL, VU] will be found. *> = 'I': ("Index") the IL-th through IU-th eigenvalues (of the *> entire matrix) will be found. *> \endverbatim *> *> \param[in] ORDER *> \verbatim *> ORDER is CHARACTER*1 *> = 'B': ("By Block") the eigenvalues will be grouped by *> split-off block (see IBLOCK, ISPLIT) and *> ordered from smallest to largest within *> the block. *> = 'E': ("Entire matrix") *> the eigenvalues for the entire matrix *> will be ordered from smallest to *> largest. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the tridiagonal matrix T. N >= 0. *> \endverbatim *> *> \param[in] VL *> \verbatim *> VL is REAL *> \endverbatim *> *> \param[in] VU *> \verbatim *> VU is REAL *> *> If RANGE='V', the lower and upper bounds of the interval to *> be searched for eigenvalues. Eigenvalues less than or equal *> to VL, or greater than VU, will not be returned. VL < VU. *> Not referenced if RANGE = 'A' or 'I'. *> \endverbatim *> *> \param[in] IL *> \verbatim *> IL is INTEGER *> \endverbatim *> *> \param[in] IU *> \verbatim *> IU is INTEGER *> *> If RANGE='I', the indices (in ascending order) of the *> smallest and largest eigenvalues to be returned. *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. *> Not referenced if RANGE = 'A' or 'V'. *> \endverbatim *> *> \param[in] ABSTOL *> \verbatim *> ABSTOL is REAL *> The absolute tolerance for the eigenvalues. An eigenvalue *> (or cluster) is considered to be located if it has been *> determined to lie in an interval whose width is ABSTOL or *> less. If ABSTOL is less than or equal to zero, then ULP*|T| *> will be used, where |T| means the 1-norm of T. *> *> Eigenvalues will be computed most accurately when ABSTOL is *> set to twice the underflow threshold 2*SLAMCH('S'), not zero. *> \endverbatim *> *> \param[in] D *> \verbatim *> D is REAL array, dimension (N) *> The n diagonal elements of the tridiagonal matrix T. *> \endverbatim *> *> \param[in] E *> \verbatim *> E is REAL array, dimension (N-1) *> The (n-1) off-diagonal elements of the tridiagonal matrix T. *> \endverbatim *> *> \param[out] M *> \verbatim *> M is INTEGER *> The actual number of eigenvalues found. 0 <= M <= N. *> (See also the description of INFO=2,3.) *> \endverbatim *> *> \param[out] NSPLIT *> \verbatim *> NSPLIT is INTEGER *> The number of diagonal blocks in the matrix T. *> 1 <= NSPLIT <= N. *> \endverbatim *> *> \param[out] W *> \verbatim *> W is REAL array, dimension (N) *> On exit, the first M elements of W will contain the *> eigenvalues. (SSTEBZ may use the remaining N-M elements as *> workspace.) *> \endverbatim *> *> \param[out] IBLOCK *> \verbatim *> IBLOCK is INTEGER array, dimension (N) *> At each row/column j where E(j) is zero or small, the *> matrix T is considered to split into a block diagonal *> matrix. On exit, if INFO = 0, IBLOCK(i) specifies to which *> block (from 1 to the number of blocks) the eigenvalue W(i) *> belongs. (SSTEBZ may use the remaining N-M elements as *> workspace.) *> \endverbatim *> *> \param[out] ISPLIT *> \verbatim *> ISPLIT is INTEGER array, dimension (N) *> The splitting points, at which T breaks up into submatrices. *> The first submatrix consists of rows/columns 1 to ISPLIT(1), *> the second of rows/columns ISPLIT(1)+1 through ISPLIT(2), *> etc., and the NSPLIT-th consists of rows/columns *> ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N. *> (Only the first NSPLIT elements will actually be used, but *> since the user cannot know a priori what value NSPLIT will *> have, N words must be reserved for ISPLIT.) *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is REAL array, dimension (4*N) *> \endverbatim *> *> \param[out] IWORK *> \verbatim *> IWORK is INTEGER array, dimension (3*N) *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> > 0: some or all of the eigenvalues failed to converge or *> were not computed: *> =1 or 3: Bisection failed to converge for some *> eigenvalues; these eigenvalues are flagged by a *> negative block number. The effect is that the *> eigenvalues may not be as accurate as the *> absolute and relative tolerances. This is *> generally caused by unexpectedly inaccurate *> arithmetic. *> =2 or 3: RANGE='I' only: Not all of the eigenvalues *> IL:IU were found. *> Effect: M < IU+1-IL *> Cause: non-monotonic arithmetic, causing the *> Sturm sequence to be non-monotonic. *> Cure: recalculate, using RANGE='A', and pick *> out eigenvalues IL:IU. In some cases, *> increasing the PARAMETER "FUDGE" may *> make things work. *> = 4: RANGE='I', and the Gershgorin interval *> initially used was too small. No eigenvalues *> were computed. *> Probable cause: your machine has sloppy *> floating-point arithmetic. *> Cure: Increase the PARAMETER "FUDGE", *> recompile, and try again. *> \endverbatim * *> \par Internal Parameters: * ========================= *> *> \verbatim *> RELFAC REAL, default = 2.0e0 *> The relative tolerance. An interval (a,b] lies within *> "relative tolerance" if b-a < RELFAC*ulp*max(|a|,|b|), *> where "ulp" is the machine precision (distance from 1 to *> the next larger floating point number.) *> *> FUDGE REAL, default = 2 *> A "fudge factor" to widen the Gershgorin intervals. Ideally, *> a value of 1 should work, but on machines with sloppy *> arithmetic, this needs to be larger. The default for *> publicly released versions should be large enough to handle *> the worst machine around. Note that this has no effect *> on accuracy of the solution. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup auxOTHERcomputational * * ===================================================================== SUBROUTINE SSTEBZ( RANGE, ORDER, N, VL, VU, IL, IU, ABSTOL, D, E, $ M, NSPLIT, W, IBLOCK, ISPLIT, WORK, IWORK, $ INFO ) * * -- LAPACK computational routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER ORDER, RANGE INTEGER IL, INFO, IU, M, N, NSPLIT REAL ABSTOL, VL, VU * .. * .. Array Arguments .. INTEGER IBLOCK( * ), ISPLIT( * ), IWORK( * ) REAL D( * ), E( * ), W( * ), WORK( * ) * .. * * ===================================================================== * * .. Parameters .. REAL ZERO, ONE, TWO, HALF PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0, TWO = 2.0E0, $ HALF = 1.0E0 / TWO ) REAL FUDGE, RELFAC PARAMETER ( FUDGE = 2.1E0, RELFAC = 2.0E0 ) * .. * .. Local Scalars .. LOGICAL NCNVRG, TOOFEW INTEGER IB, IBEGIN, IDISCL, IDISCU, IE, IEND, IINFO, $ IM, IN, IOFF, IORDER, IOUT, IRANGE, ITMAX, $ ITMP1, IW, IWOFF, J, JB, JDISC, JE, NB, NWL, $ NWU REAL ATOLI, BNORM, GL, GU, PIVMIN, RTOLI, SAFEMN, $ TMP1, TMP2, TNORM, ULP, WKILL, WL, WLU, WU, WUL * .. * .. Local Arrays .. INTEGER IDUMMA( 1 ) * .. * .. External Functions .. LOGICAL LSAME INTEGER ILAENV REAL SLAMCH EXTERNAL LSAME, ILAENV, SLAMCH * .. * .. External Subroutines .. EXTERNAL SLAEBZ, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC ABS, INT, LOG, MAX, MIN, SQRT * .. * .. Executable Statements .. * INFO = 0 * * Decode RANGE * IF( LSAME( RANGE, 'A' ) ) THEN IRANGE = 1 ELSE IF( LSAME( RANGE, 'V' ) ) THEN IRANGE = 2 ELSE IF( LSAME( RANGE, 'I' ) ) THEN IRANGE = 3 ELSE IRANGE = 0 END IF * * Decode ORDER * IF( LSAME( ORDER, 'B' ) ) THEN IORDER = 2 ELSE IF( LSAME( ORDER, 'E' ) ) THEN IORDER = 1 ELSE IORDER = 0 END IF * * Check for Errors * IF( IRANGE.LE.0 ) THEN INFO = -1 ELSE IF( IORDER.LE.0 ) THEN INFO = -2 ELSE IF( N.LT.0 ) THEN INFO = -3 ELSE IF( IRANGE.EQ.2 ) THEN IF( VL.GE.VU ) INFO = -5 ELSE IF( IRANGE.EQ.3 .AND. ( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) ) $ THEN INFO = -6 ELSE IF( IRANGE.EQ.3 .AND. ( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) ) $ THEN INFO = -7 END IF * IF( INFO.NE.0 ) THEN CALL XERBLA( 'SSTEBZ', -INFO ) RETURN END IF * * Initialize error flags * INFO = 0 NCNVRG = .FALSE. TOOFEW = .FALSE. * * Quick return if possible * M = 0 IF( N.EQ.0 ) $ RETURN * * Simplifications: * IF( IRANGE.EQ.3 .AND. IL.EQ.1 .AND. IU.EQ.N ) $ IRANGE = 1 * * Get machine constants * NB is the minimum vector length for vector bisection, or 0 * if only scalar is to be done. * SAFEMN = SLAMCH( 'S' ) ULP = SLAMCH( 'P' ) RTOLI = ULP*RELFAC NB = ILAENV( 1, 'SSTEBZ', ' ', N, -1, -1, -1 ) IF( NB.LE.1 ) $ NB = 0 * * Special Case when N=1 * IF( N.EQ.1 ) THEN NSPLIT = 1 ISPLIT( 1 ) = 1 IF( IRANGE.EQ.2 .AND. ( VL.GE.D( 1 ) .OR. VU.LT.D( 1 ) ) ) THEN M = 0 ELSE W( 1 ) = D( 1 ) IBLOCK( 1 ) = 1 M = 1 END IF RETURN END IF * * Compute Splitting Points * NSPLIT = 1 WORK( N ) = ZERO PIVMIN = ONE * DO 10 J = 2, N TMP1 = E( J-1 )**2 IF( ABS( D( J )*D( J-1 ) )*ULP**2+SAFEMN.GT.TMP1 ) THEN ISPLIT( NSPLIT ) = J - 1 NSPLIT = NSPLIT + 1 WORK( J-1 ) = ZERO ELSE WORK( J-1 ) = TMP1 PIVMIN = MAX( PIVMIN, TMP1 ) END IF 10 CONTINUE ISPLIT( NSPLIT ) = N PIVMIN = PIVMIN*SAFEMN * * Compute Interval and ATOLI * IF( IRANGE.EQ.3 ) THEN * * RANGE='I': Compute the interval containing eigenvalues * IL through IU. * * Compute Gershgorin interval for entire (split) matrix * and use it as the initial interval * GU = D( 1 ) GL = D( 1 ) TMP1 = ZERO * DO 20 J = 1, N - 1 TMP2 = SQRT( WORK( J ) ) GU = MAX( GU, D( J )+TMP1+TMP2 ) GL = MIN( GL, D( J )-TMP1-TMP2 ) TMP1 = TMP2 20 CONTINUE * GU = MAX( GU, D( N )+TMP1 ) GL = MIN( GL, D( N )-TMP1 ) TNORM = MAX( ABS( GL ), ABS( GU ) ) GL = GL - FUDGE*TNORM*ULP*N - FUDGE*TWO*PIVMIN GU = GU + FUDGE*TNORM*ULP*N + FUDGE*PIVMIN * * Compute Iteration parameters * ITMAX = INT( ( LOG( TNORM+PIVMIN )-LOG( PIVMIN ) ) / $ LOG( TWO ) ) + 2 IF( ABSTOL.LE.ZERO ) THEN ATOLI = ULP*TNORM ELSE ATOLI = ABSTOL END IF * WORK( N+1 ) = GL WORK( N+2 ) = GL WORK( N+3 ) = GU WORK( N+4 ) = GU WORK( N+5 ) = GL WORK( N+6 ) = GU IWORK( 1 ) = -1 IWORK( 2 ) = -1 IWORK( 3 ) = N + 1 IWORK( 4 ) = N + 1 IWORK( 5 ) = IL - 1 IWORK( 6 ) = IU * CALL SLAEBZ( 3, ITMAX, N, 2, 2, NB, ATOLI, RTOLI, PIVMIN, D, E, $ WORK, IWORK( 5 ), WORK( N+1 ), WORK( N+5 ), IOUT, $ IWORK, W, IBLOCK, IINFO ) * IF( IWORK( 6 ).EQ.IU ) THEN WL = WORK( N+1 ) WLU = WORK( N+3 ) NWL = IWORK( 1 ) WU = WORK( N+4 ) WUL = WORK( N+2 ) NWU = IWORK( 4 ) ELSE WL = WORK( N+2 ) WLU = WORK( N+4 ) NWL = IWORK( 2 ) WU = WORK( N+3 ) WUL = WORK( N+1 ) NWU = IWORK( 3 ) END IF * IF( NWL.LT.0 .OR. NWL.GE.N .OR. NWU.LT.1 .OR. NWU.GT.N ) THEN INFO = 4 RETURN END IF ELSE * * RANGE='A' or 'V' -- Set ATOLI * TNORM = MAX( ABS( D( 1 ) )+ABS( E( 1 ) ), $ ABS( D( N ) )+ABS( E( N-1 ) ) ) * DO 30 J = 2, N - 1 TNORM = MAX( TNORM, ABS( D( J ) )+ABS( E( J-1 ) )+ $ ABS( E( J ) ) ) 30 CONTINUE * IF( ABSTOL.LE.ZERO ) THEN ATOLI = ULP*TNORM ELSE ATOLI = ABSTOL END IF * IF( IRANGE.EQ.2 ) THEN WL = VL WU = VU ELSE WL = ZERO WU = ZERO END IF END IF * * Find Eigenvalues -- Loop Over Blocks and recompute NWL and NWU. * NWL accumulates the number of eigenvalues .le. WL, * NWU accumulates the number of eigenvalues .le. WU * M = 0 IEND = 0 INFO = 0 NWL = 0 NWU = 0 * DO 70 JB = 1, NSPLIT IOFF = IEND IBEGIN = IOFF + 1 IEND = ISPLIT( JB ) IN = IEND - IOFF * IF( IN.EQ.1 ) THEN * * Special Case -- IN=1 * IF( IRANGE.EQ.1 .OR. WL.GE.D( IBEGIN )-PIVMIN ) $ NWL = NWL + 1 IF( IRANGE.EQ.1 .OR. WU.GE.D( IBEGIN )-PIVMIN ) $ NWU = NWU + 1 IF( IRANGE.EQ.1 .OR. ( WL.LT.D( IBEGIN )-PIVMIN .AND. WU.GE. $ D( IBEGIN )-PIVMIN ) ) THEN M = M + 1 W( M ) = D( IBEGIN ) IBLOCK( M ) = JB END IF ELSE * * General Case -- IN > 1 * * Compute Gershgorin Interval * and use it as the initial interval * GU = D( IBEGIN ) GL = D( IBEGIN ) TMP1 = ZERO * DO 40 J = IBEGIN, IEND - 1 TMP2 = ABS( E( J ) ) GU = MAX( GU, D( J )+TMP1+TMP2 ) GL = MIN( GL, D( J )-TMP1-TMP2 ) TMP1 = TMP2 40 CONTINUE * GU = MAX( GU, D( IEND )+TMP1 ) GL = MIN( GL, D( IEND )-TMP1 ) BNORM = MAX( ABS( GL ), ABS( GU ) ) GL = GL - FUDGE*BNORM*ULP*IN - FUDGE*PIVMIN GU = GU + FUDGE*BNORM*ULP*IN + FUDGE*PIVMIN * * Compute ATOLI for the current submatrix * IF( ABSTOL.LE.ZERO ) THEN ATOLI = ULP*MAX( ABS( GL ), ABS( GU ) ) ELSE ATOLI = ABSTOL END IF * IF( IRANGE.GT.1 ) THEN IF( GU.LT.WL ) THEN NWL = NWL + IN NWU = NWU + IN GO TO 70 END IF GL = MAX( GL, WL ) GU = MIN( GU, WU ) IF( GL.GE.GU ) $ GO TO 70 END IF * * Set Up Initial Interval * WORK( N+1 ) = GL WORK( N+IN+1 ) = GU CALL SLAEBZ( 1, 0, IN, IN, 1, NB, ATOLI, RTOLI, PIVMIN, $ D( IBEGIN ), E( IBEGIN ), WORK( IBEGIN ), $ IDUMMA, WORK( N+1 ), WORK( N+2*IN+1 ), IM, $ IWORK, W( M+1 ), IBLOCK( M+1 ), IINFO ) * NWL = NWL + IWORK( 1 ) NWU = NWU + IWORK( IN+1 ) IWOFF = M - IWORK( 1 ) * * Compute Eigenvalues * ITMAX = INT( ( LOG( GU-GL+PIVMIN )-LOG( PIVMIN ) ) / $ LOG( TWO ) ) + 2 CALL SLAEBZ( 2, ITMAX, IN, IN, 1, NB, ATOLI, RTOLI, PIVMIN, $ D( IBEGIN ), E( IBEGIN ), WORK( IBEGIN ), $ IDUMMA, WORK( N+1 ), WORK( N+2*IN+1 ), IOUT, $ IWORK, W( M+1 ), IBLOCK( M+1 ), IINFO ) * * Copy Eigenvalues Into W and IBLOCK * Use -JB for block number for unconverged eigenvalues. * DO 60 J = 1, IOUT TMP1 = HALF*( WORK( J+N )+WORK( J+IN+N ) ) * * Flag non-convergence. * IF( J.GT.IOUT-IINFO ) THEN NCNVRG = .TRUE. IB = -JB ELSE IB = JB END IF DO 50 JE = IWORK( J ) + 1 + IWOFF, $ IWORK( J+IN ) + IWOFF W( JE ) = TMP1 IBLOCK( JE ) = IB 50 CONTINUE 60 CONTINUE * M = M + IM END IF 70 CONTINUE * * If RANGE='I', then (WL,WU) contains eigenvalues NWL+1,...,NWU * If NWL+1 < IL or NWU > IU, discard extra eigenvalues. * IF( IRANGE.EQ.3 ) THEN IM = 0 IDISCL = IL - 1 - NWL IDISCU = NWU - IU * IF( IDISCL.GT.0 .OR. IDISCU.GT.0 ) THEN DO 80 JE = 1, M IF( W( JE ).LE.WLU .AND. IDISCL.GT.0 ) THEN IDISCL = IDISCL - 1 ELSE IF( W( JE ).GE.WUL .AND. IDISCU.GT.0 ) THEN IDISCU = IDISCU - 1 ELSE IM = IM + 1 W( IM ) = W( JE ) IBLOCK( IM ) = IBLOCK( JE ) END IF 80 CONTINUE M = IM END IF IF( IDISCL.GT.0 .OR. IDISCU.GT.0 ) THEN * * Code to deal with effects of bad arithmetic: * Some low eigenvalues to be discarded are not in (WL,WLU], * or high eigenvalues to be discarded are not in (WUL,WU] * so just kill off the smallest IDISCL/largest IDISCU * eigenvalues, by simply finding the smallest/largest * eigenvalue(s). * * (If N(w) is monotone non-decreasing, this should never * happen.) * IF( IDISCL.GT.0 ) THEN WKILL = WU DO 100 JDISC = 1, IDISCL IW = 0 DO 90 JE = 1, M IF( IBLOCK( JE ).NE.0 .AND. $ ( W( JE ).LT.WKILL .OR. IW.EQ.0 ) ) THEN IW = JE WKILL = W( JE ) END IF 90 CONTINUE IBLOCK( IW ) = 0 100 CONTINUE END IF IF( IDISCU.GT.0 ) THEN * WKILL = WL DO 120 JDISC = 1, IDISCU IW = 0 DO 110 JE = 1, M IF( IBLOCK( JE ).NE.0 .AND. $ ( W( JE ).GT.WKILL .OR. IW.EQ.0 ) ) THEN IW = JE WKILL = W( JE ) END IF 110 CONTINUE IBLOCK( IW ) = 0 120 CONTINUE END IF IM = 0 DO 130 JE = 1, M IF( IBLOCK( JE ).NE.0 ) THEN IM = IM + 1 W( IM ) = W( JE ) IBLOCK( IM ) = IBLOCK( JE ) END IF 130 CONTINUE M = IM END IF IF( IDISCL.LT.0 .OR. IDISCU.LT.0 ) THEN TOOFEW = .TRUE. END IF END IF * * If ORDER='B', do nothing -- the eigenvalues are already sorted * by block. * If ORDER='E', sort the eigenvalues from smallest to largest * IF( IORDER.EQ.1 .AND. NSPLIT.GT.1 ) THEN DO 150 JE = 1, M - 1 IE = 0 TMP1 = W( JE ) DO 140 J = JE + 1, M IF( W( J ).LT.TMP1 ) THEN IE = J TMP1 = W( J ) END IF 140 CONTINUE * IF( IE.NE.0 ) THEN ITMP1 = IBLOCK( IE ) W( IE ) = W( JE ) IBLOCK( IE ) = IBLOCK( JE ) W( JE ) = TMP1 IBLOCK( JE ) = ITMP1 END IF 150 CONTINUE END IF * INFO = 0 IF( NCNVRG ) $ INFO = INFO + 1 IF( TOOFEW ) $ INFO = INFO + 2 RETURN * * End of SSTEBZ * END
bsd-3-clause
buaasun/grappa
applications/NPB/SERIAL/LU/setiv.f
11
2104
c--------------------------------------------------------------------- c--------------------------------------------------------------------- subroutine setiv c--------------------------------------------------------------------- c--------------------------------------------------------------------- c--------------------------------------------------------------------- c c set the initial values of independent variables based on tri-linear c interpolation of boundary values in the computational space. c c--------------------------------------------------------------------- implicit none include 'applu.incl' c--------------------------------------------------------------------- c local variables c--------------------------------------------------------------------- integer i, j, k, m double precision xi, eta, zeta double precision pxi, peta, pzeta double precision ue_1jk(5),ue_nx0jk(5),ue_i1k(5), > ue_iny0k(5),ue_ij1(5),ue_ijnz(5) do k = 2, nz - 1 zeta = ( dble (k-1) ) / (nz-1) do j = 2, ny - 1 eta = ( dble (j-1) ) / (ny0-1) do i = 2, nx - 1 xi = ( dble (i-1) ) / (nx0-1) call exact (1,j,k,ue_1jk) call exact (nx0,j,k,ue_nx0jk) call exact (i,1,k,ue_i1k) call exact (i,ny0,k,ue_iny0k) call exact (i,j,1,ue_ij1) call exact (i,j,nz,ue_ijnz) do m = 1, 5 pxi = ( 1.0d+00 - xi ) * ue_1jk(m) > + xi * ue_nx0jk(m) peta = ( 1.0d+00 - eta ) * ue_i1k(m) > + eta * ue_iny0k(m) pzeta = ( 1.0d+00 - zeta ) * ue_ij1(m) > + zeta * ue_ijnz(m) u( m, i, j, k ) = pxi + peta + pzeta > - pxi * peta - peta * pzeta - pzeta * pxi > + pxi * peta * pzeta end do end do end do end do return end
bsd-3-clause
czchen/debian-sourcenav-ng
CONTRIB/testcases/fortran/tokenspace.f
7
50041
call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA)) call Z(1,2,3,4,opsx(AA),opsy(AA))
gpl-2.0
UPenn-RoboCup/OpenBLAS
lapack-netlib/TESTING/LIN/dchksy_rook.f
21
26715
*> \brief \b DCHKSY_ROOK * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE DCHKSY_ROOK( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL, * THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X, * XACT, WORK, RWORK, IWORK, NOUT ) * * .. Scalar Arguments .. * LOGICAL TSTERR * INTEGER NMAX, NN, NNB, NNS, NOUT * DOUBLE PRECISION THRESH * .. * .. Array Arguments .. * LOGICAL DOTYPE( * ) * INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * ) * DOUBLE PRECISION A( * ), AFAC( * ), AINV( * ), B( * ), * $ RWORK( * ), WORK( * ), X( * ), XACT( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DCHKSY_ROOK tests DSYTRF_ROOK, -TRI_ROOK, -TRS_ROOK, *> and -CON_ROOK. *> \endverbatim * * Arguments: * ========== * *> \param[in] DOTYPE *> \verbatim *> DOTYPE is LOGICAL array, dimension (NTYPES) *> The matrix types to be used for testing. Matrices of type j *> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = *> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. *> \endverbatim *> *> \param[in] NN *> \verbatim *> NN is INTEGER *> The number of values of N contained in the vector NVAL. *> \endverbatim *> *> \param[in] NVAL *> \verbatim *> NVAL is INTEGER array, dimension (NN) *> The values of the matrix dimension N. *> \endverbatim *> *> \param[in] NNB *> \verbatim *> NNB is INTEGER *> The number of values of NB contained in the vector NBVAL. *> \endverbatim *> *> \param[in] NBVAL *> \verbatim *> NBVAL is INTEGER array, dimension (NBVAL) *> The values of the blocksize NB. *> \endverbatim *> *> \param[in] NNS *> \verbatim *> NNS is INTEGER *> The number of values of NRHS contained in the vector NSVAL. *> \endverbatim *> *> \param[in] NSVAL *> \verbatim *> NSVAL is INTEGER array, dimension (NNS) *> The values of the number of right hand sides NRHS. *> \endverbatim *> *> \param[in] THRESH *> \verbatim *> THRESH is DOUBLE PRECISION *> The threshold value for the test ratios. A result is *> included in the output file if RESULT >= THRESH. To have *> every test ratio printed, use THRESH = 0. *> \endverbatim *> *> \param[in] TSTERR *> \verbatim *> TSTERR is LOGICAL *> Flag that indicates whether error exits are to be tested. *> \endverbatim *> *> \param[in] NMAX *> \verbatim *> NMAX is INTEGER *> The maximum value permitted for N, used in dimensioning the *> work arrays. *> \endverbatim *> *> \param[out] A *> \verbatim *> A is DOUBLE PRECISION array, dimension (NMAX*NMAX) *> \endverbatim *> *> \param[out] AFAC *> \verbatim *> AFAC is DOUBLE PRECISION array, dimension (NMAX*NMAX) *> \endverbatim *> *> \param[out] AINV *> \verbatim *> AINV is DOUBLE PRECISION array, dimension (NMAX*NMAX) *> \endverbatim *> *> \param[out] B *> \verbatim *> B is DOUBLE PRECISION array, dimension (NMAX*NSMAX) *> where NSMAX is the largest entry in NSVAL. *> \endverbatim *> *> \param[out] X *> \verbatim *> X is DOUBLE PRECISION array, dimension (NMAX*NSMAX) *> \endverbatim *> *> \param[out] XACT *> \verbatim *> XACT is DOUBLE PRECISION array, dimension (NMAX*NSMAX) *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is DOUBLE PRECISION array, dimension (NMAX*max(3,NSMAX)) *> \endverbatim *> *> \param[out] RWORK *> \verbatim *> RWORK is DOUBLE PRECISION array, dimension (max(NMAX,2*NSMAX)) *> \endverbatim *> *> \param[out] IWORK *> \verbatim *> IWORK is INTEGER array, dimension (2*NMAX) *> \endverbatim *> *> \param[in] NOUT *> \verbatim *> NOUT is INTEGER *> The unit number for output. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2013 * *> \ingroup double_lin * * ===================================================================== SUBROUTINE DCHKSY_ROOK( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL, $ THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X, $ XACT, WORK, RWORK, IWORK, NOUT ) * * -- LAPACK test routine (version 3.5.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2013 * * .. Scalar Arguments .. LOGICAL TSTERR INTEGER NMAX, NN, NNB, NNS, NOUT DOUBLE PRECISION THRESH * .. * .. Array Arguments .. LOGICAL DOTYPE( * ) INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * ) DOUBLE PRECISION A( * ), AFAC( * ), AINV( * ), B( * ), $ RWORK( * ), WORK( * ), X( * ), XACT( * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) DOUBLE PRECISION EIGHT, SEVTEN PARAMETER ( EIGHT = 8.0D+0, SEVTEN = 17.0D+0 ) INTEGER NTYPES PARAMETER ( NTYPES = 10 ) INTEGER NTESTS PARAMETER ( NTESTS = 7 ) * .. * .. Local Scalars .. LOGICAL TRFCON, ZEROT CHARACTER DIST, TYPE, UPLO, XTYPE CHARACTER*3 PATH, MATPATH INTEGER I, I1, I2, IMAT, IN, INB, INFO, IOFF, IRHS, $ ITEMP, IUPLO, IZERO, J, K, KL, KU, LDA, LWORK, $ MODE, N, NB, NERRS, NFAIL, NIMAT, NRHS, NRUN, $ NT DOUBLE PRECISION ALPHA, ANORM, CNDNUM, CONST, DTEMP, LAM_MAX, $ LAM_MIN, RCOND, RCONDC * .. * .. Local Arrays .. CHARACTER UPLOS( 2 ) INTEGER IDUMMY( 1 ), ISEED( 4 ), ISEEDY( 4 ) DOUBLE PRECISION DDUMMY( 1 ), RESULT( NTESTS ) * .. * .. External Functions .. DOUBLE PRECISION DGET06, DLANGE, DLANSY EXTERNAL DGET06, DLANGE, DLANSY * .. * .. External Subroutines .. EXTERNAL ALAERH, ALAHD, ALASUM, DERRSY, DGET04, DLACPY, $ DLARHS, DLATB4, DLATMS, DPOT02, DPOT03, DSYEVX, $ DSYCON_ROOK, DSYT01_ROOK, DSYTRF_ROOK, $ DSYTRI_ROOK, DSYTRS_ROOK, XLAENV * .. * .. Intrinsic Functions .. INTRINSIC ABS, MAX, MIN, SQRT * .. * .. Scalars in Common .. LOGICAL LERR, OK CHARACTER*32 SRNAMT INTEGER INFOT, NUNIT * .. * .. Common blocks .. COMMON / INFOC / INFOT, NUNIT, OK, LERR COMMON / SRNAMC / SRNAMT * .. * .. Data statements .. DATA ISEEDY / 1988, 1989, 1990, 1991 / DATA UPLOS / 'U', 'L' / * .. * .. Executable Statements .. * * Initialize constants and the random number seed. * ALPHA = ( ONE+SQRT( SEVTEN ) ) / EIGHT * * Test path * PATH( 1: 1 ) = 'Double precision' PATH( 2: 3 ) = 'SR' * * Path to generate matrices * MATPATH( 1: 1 ) = 'Double precision' MATPATH( 2: 3 ) = 'SY' * NRUN = 0 NFAIL = 0 NERRS = 0 DO 10 I = 1, 4 ISEED( I ) = ISEEDY( I ) 10 CONTINUE * * Test the error exits * IF( TSTERR ) $ CALL DERRSY( PATH, NOUT ) INFOT = 0 * * Set the minimum block size for which the block routine should * be used, which will be later returned by ILAENV * CALL XLAENV( 2, 2 ) * * Do for each value of N in NVAL * DO 270 IN = 1, NN N = NVAL( IN ) LDA = MAX( N, 1 ) XTYPE = 'N' NIMAT = NTYPES IF( N.LE.0 ) $ NIMAT = 1 * IZERO = 0 * * Do for each value of matrix type IMAT * DO 260 IMAT = 1, NIMAT * * Do the tests only if DOTYPE( IMAT ) is true. * IF( .NOT.DOTYPE( IMAT ) ) $ GO TO 260 * * Skip types 3, 4, 5, or 6 if the matrix size is too small. * ZEROT = IMAT.GE.3 .AND. IMAT.LE.6 IF( ZEROT .AND. N.LT.IMAT-2 ) $ GO TO 260 * * Do first for UPLO = 'U', then for UPLO = 'L' * DO 250 IUPLO = 1, 2 UPLO = UPLOS( IUPLO ) * * Begin generate the test matrix A. * * Set up parameters with DLATB4 for the matrix generator * based on the type of matrix to be generated. * CALL DLATB4( MATPATH, IMAT, N, N, TYPE, KL, KU, ANORM, $ MODE, CNDNUM, DIST ) * * Generate a matrix with DLATMS. * SRNAMT = 'DLATMS' CALL DLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE, $ CNDNUM, ANORM, KL, KU, UPLO, A, LDA, WORK, $ INFO ) * * Check error code from DLATMS and handle error. * IF( INFO.NE.0 ) THEN CALL ALAERH( PATH, 'DLATMS', INFO, 0, UPLO, N, N, -1, $ -1, -1, IMAT, NFAIL, NERRS, NOUT ) * * Skip all tests for this generated matrix * GO TO 250 END IF * * For matrix types 3-6, zero one or more rows and * columns of the matrix to test that INFO is returned * correctly. * IF( ZEROT ) THEN IF( IMAT.EQ.3 ) THEN IZERO = 1 ELSE IF( IMAT.EQ.4 ) THEN IZERO = N ELSE IZERO = N / 2 + 1 END IF * IF( IMAT.LT.6 ) THEN * * Set row and column IZERO to zero. * IF( IUPLO.EQ.1 ) THEN IOFF = ( IZERO-1 )*LDA DO 20 I = 1, IZERO - 1 A( IOFF+I ) = ZERO 20 CONTINUE IOFF = IOFF + IZERO DO 30 I = IZERO, N A( IOFF ) = ZERO IOFF = IOFF + LDA 30 CONTINUE ELSE IOFF = IZERO DO 40 I = 1, IZERO - 1 A( IOFF ) = ZERO IOFF = IOFF + LDA 40 CONTINUE IOFF = IOFF - IZERO DO 50 I = IZERO, N A( IOFF+I ) = ZERO 50 CONTINUE END IF ELSE IF( IUPLO.EQ.1 ) THEN * * Set the first IZERO rows and columns to zero. * IOFF = 0 DO 70 J = 1, N I2 = MIN( J, IZERO ) DO 60 I = 1, I2 A( IOFF+I ) = ZERO 60 CONTINUE IOFF = IOFF + LDA 70 CONTINUE ELSE * * Set the last IZERO rows and columns to zero. * IOFF = 0 DO 90 J = 1, N I1 = MAX( J, IZERO ) DO 80 I = I1, N A( IOFF+I ) = ZERO 80 CONTINUE IOFF = IOFF + LDA 90 CONTINUE END IF END IF ELSE IZERO = 0 END IF * * End generate the test matrix A. * * * Do for each value of NB in NBVAL * DO 240 INB = 1, NNB * * Set the optimal blocksize, which will be later * returned by ILAENV. * NB = NBVAL( INB ) CALL XLAENV( 1, NB ) * * Copy the test matrix A into matrix AFAC which * will be factorized in place. This is needed to * preserve the test matrix A for subsequent tests. * CALL DLACPY( UPLO, N, N, A, LDA, AFAC, LDA ) * * Compute the L*D*L**T or U*D*U**T factorization of the * matrix. IWORK stores details of the interchanges and * the block structure of D. AINV is a work array for * block factorization, LWORK is the length of AINV. * LWORK = MAX( 2, NB )*LDA SRNAMT = 'DSYTRF_ROOK' CALL DSYTRF_ROOK( UPLO, N, AFAC, LDA, IWORK, AINV, $ LWORK, INFO ) * * Adjust the expected value of INFO to account for * pivoting. * K = IZERO IF( K.GT.0 ) THEN 100 CONTINUE IF( IWORK( K ).LT.0 ) THEN IF( IWORK( K ).NE.-K ) THEN K = -IWORK( K ) GO TO 100 END IF ELSE IF( IWORK( K ).NE.K ) THEN K = IWORK( K ) GO TO 100 END IF END IF * * Check error code from DSYTRF_ROOK and handle error. * IF( INFO.NE.K) $ CALL ALAERH( PATH, 'DSYTRF_ROOK', INFO, K, $ UPLO, N, N, -1, -1, NB, IMAT, $ NFAIL, NERRS, NOUT ) * * Set the condition estimate flag if the INFO is not 0. * IF( INFO.NE.0 ) THEN TRFCON = .TRUE. ELSE TRFCON = .FALSE. END IF * *+ TEST 1 * Reconstruct matrix from factors and compute residual. * CALL DSYT01_ROOK( UPLO, N, A, LDA, AFAC, LDA, IWORK, $ AINV, LDA, RWORK, RESULT( 1 ) ) NT = 1 * *+ TEST 2 * Form the inverse and compute the residual, * if the factorization was competed without INFO > 0 * (i.e. there is no zero rows and columns). * Do it only for the first block size. * IF( INB.EQ.1 .AND. .NOT.TRFCON ) THEN CALL DLACPY( UPLO, N, N, AFAC, LDA, AINV, LDA ) SRNAMT = 'DSYTRI_ROOK' CALL DSYTRI_ROOK( UPLO, N, AINV, LDA, IWORK, WORK, $ INFO ) * * Check error code from DSYTRI_ROOK and handle error. * IF( INFO.NE.0 ) $ CALL ALAERH( PATH, 'DSYTRI_ROOK', INFO, -1, $ UPLO, N, N, -1, -1, -1, IMAT, $ NFAIL, NERRS, NOUT ) * * Compute the residual for a symmetric matrix times * its inverse. * CALL DPOT03( UPLO, N, A, LDA, AINV, LDA, WORK, LDA, $ RWORK, RCONDC, RESULT( 2 ) ) NT = 2 END IF * * Print information about the tests that did not pass * the threshold. * DO 110 K = 1, NT IF( RESULT( K ).GE.THRESH ) THEN IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) $ CALL ALAHD( NOUT, PATH ) WRITE( NOUT, FMT = 9999 )UPLO, N, NB, IMAT, K, $ RESULT( K ) NFAIL = NFAIL + 1 END IF 110 CONTINUE NRUN = NRUN + NT * *+ TEST 3 * Compute largest element in U or L * RESULT( 3 ) = ZERO DTEMP = ZERO * CONST = ONE / ( ONE-ALPHA ) * IF( IUPLO.EQ.1 ) THEN * * Compute largest element in U * K = N 120 CONTINUE IF( K.LE.1 ) $ GO TO 130 * IF( IWORK( K ).GT.ZERO ) THEN * * Get max absolute value from elements * in column k in in U * DTEMP = DLANGE( 'M', K-1, 1, $ AFAC( ( K-1 )*LDA+1 ), LDA, RWORK ) ELSE * * Get max absolute value from elements * in columns k and k-1 in U * DTEMP = DLANGE( 'M', K-2, 2, $ AFAC( ( K-2 )*LDA+1 ), LDA, RWORK ) K = K - 1 * END IF * * DTEMP should be bounded by CONST * DTEMP = DTEMP - CONST + THRESH IF( DTEMP.GT.RESULT( 3 ) ) $ RESULT( 3 ) = DTEMP * K = K - 1 * GO TO 120 130 CONTINUE * ELSE * * Compute largest element in L * K = 1 140 CONTINUE IF( K.GE.N ) $ GO TO 150 * IF( IWORK( K ).GT.ZERO ) THEN * * Get max absolute value from elements * in column k in in L * DTEMP = DLANGE( 'M', N-K, 1, $ AFAC( ( K-1 )*LDA+K+1 ), LDA, RWORK ) ELSE * * Get max absolute value from elements * in columns k and k+1 in L * DTEMP = DLANGE( 'M', N-K-1, 2, $ AFAC( ( K-1 )*LDA+K+2 ), LDA, RWORK ) K = K + 1 * END IF * * DTEMP should be bounded by CONST * DTEMP = DTEMP - CONST + THRESH IF( DTEMP.GT.RESULT( 3 ) ) $ RESULT( 3 ) = DTEMP * K = K + 1 * GO TO 140 150 CONTINUE END IF * * *+ TEST 4 * Compute largest 2-Norm of 2-by-2 diag blocks * RESULT( 4 ) = ZERO DTEMP = ZERO * CONST = ( ONE+ALPHA ) / ( ONE-ALPHA ) CALL DLACPY( UPLO, N, N, AFAC, LDA, AINV, LDA ) * IF( IUPLO.EQ.1 ) THEN * * Loop backward for UPLO = 'U' * K = N 160 CONTINUE IF( K.LE.1 ) $ GO TO 170 * IF( IWORK( K ).LT.ZERO ) THEN * * Get the two eigenvalues of a 2-by-2 block, * store them in RWORK array * CALL DSYEVX( 'N', 'A', UPLO, 2, $ AINV( ( K-2 )*LDA+K-1 ), LDA, DTEMP, $ DTEMP, ITEMP, ITEMP, ZERO, ITEMP, $ RWORK, DDUMMY, 1, WORK, 16, $ IWORK( N+1 ), IDUMMY, INFO ) * LAM_MAX = MAX( ABS( RWORK( 1 ) ), $ ABS( RWORK( 2 ) ) ) LAM_MIN = MIN( ABS( RWORK( 1 ) ), $ ABS( RWORK( 2 ) ) ) * DTEMP = LAM_MAX / LAM_MIN * * DTEMP should be bounded by CONST * DTEMP = ABS( DTEMP ) - CONST + THRESH IF( DTEMP.GT.RESULT( 4 ) ) $ RESULT( 4 ) = DTEMP K = K - 1 * END IF * K = K - 1 * GO TO 160 170 CONTINUE * ELSE * * Loop forward for UPLO = 'L' * K = 1 180 CONTINUE IF( K.GE.N ) $ GO TO 190 * IF( IWORK( K ).LT.ZERO ) THEN * * Get the two eigenvalues of a 2-by-2 block, * store them in RWORK array * CALL DSYEVX( 'N', 'A', UPLO, 2, $ AINV( ( K-1 )*LDA+K ), LDA, DTEMP, $ DTEMP, ITEMP, ITEMP, ZERO, ITEMP, $ RWORK, DDUMMY, 1, WORK, 16, $ IWORK( N+1 ), IDUMMY, INFO ) * LAM_MAX = MAX( ABS( RWORK( 1 ) ), $ ABS( RWORK( 2 ) ) ) LAM_MIN = MIN( ABS( RWORK( 1 ) ), $ ABS( RWORK( 2 ) ) ) * DTEMP = LAM_MAX / LAM_MIN * * DTEMP should be bounded by CONST * DTEMP = ABS( DTEMP ) - CONST + THRESH IF( DTEMP.GT.RESULT( 4 ) ) $ RESULT( 4 ) = DTEMP K = K + 1 * END IF * K = K + 1 * GO TO 180 190 CONTINUE END IF * * Print information about the tests that did not pass * the threshold. * DO 200 K = 3, 4 IF( RESULT( K ).GE.THRESH ) THEN IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) $ CALL ALAHD( NOUT, PATH ) WRITE( NOUT, FMT = 9999 )UPLO, N, NB, IMAT, K, $ RESULT( K ) NFAIL = NFAIL + 1 END IF 200 CONTINUE NRUN = NRUN + 2 * * Skip the other tests if this is not the first block * size. * IF( INB.GT.1 ) $ GO TO 240 * * Do only the condition estimate if INFO is not 0. * IF( TRFCON ) THEN RCONDC = ZERO GO TO 230 END IF * * Do for each value of NRHS in NSVAL. * DO 220 IRHS = 1, NNS NRHS = NSVAL( IRHS ) * *+ TEST 5 ( Using TRS_ROOK) * Solve and compute residual for A * X = B. * * Choose a set of NRHS random solution vectors * stored in XACT and set up the right hand side B * SRNAMT = 'DLARHS' CALL DLARHS( MATPATH, XTYPE, UPLO, ' ', N, N, $ KL, KU, NRHS, A, LDA, XACT, LDA, $ B, LDA, ISEED, INFO ) CALL DLACPY( 'Full', N, NRHS, B, LDA, X, LDA ) * SRNAMT = 'DSYTRS_ROOK' CALL DSYTRS_ROOK( UPLO, N, NRHS, AFAC, LDA, IWORK, $ X, LDA, INFO ) * * Check error code from DSYTRS_ROOK and handle error. * IF( INFO.NE.0 ) $ CALL ALAERH( PATH, 'DSYTRS_ROOK', INFO, 0, $ UPLO, N, N, -1, -1, NRHS, IMAT, $ NFAIL, NERRS, NOUT ) * CALL DLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA ) * * Compute the residual for the solution * CALL DPOT02( UPLO, N, NRHS, A, LDA, X, LDA, WORK, $ LDA, RWORK, RESULT( 5 ) ) * *+ TEST 6 * Check solution from generated exact solution. * CALL DGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC, $ RESULT( 6 ) ) * * Print information about the tests that did not pass * the threshold. * DO 210 K = 5, 6 IF( RESULT( K ).GE.THRESH ) THEN IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) $ CALL ALAHD( NOUT, PATH ) WRITE( NOUT, FMT = 9998 )UPLO, N, NRHS, $ IMAT, K, RESULT( K ) NFAIL = NFAIL + 1 END IF 210 CONTINUE NRUN = NRUN + 2 * * End do for each value of NRHS in NSVAL. * 220 CONTINUE * *+ TEST 7 * Get an estimate of RCOND = 1/CNDNUM. * 230 CONTINUE ANORM = DLANSY( '1', UPLO, N, A, LDA, RWORK ) SRNAMT = 'DSYCON_ROOK' CALL DSYCON_ROOK( UPLO, N, AFAC, LDA, IWORK, ANORM, $ RCOND, WORK, IWORK( N+1 ), INFO ) * * Check error code from DSYCON_ROOK and handle error. * IF( INFO.NE.0 ) $ CALL ALAERH( PATH, 'DSYCON_ROOK', INFO, 0, $ UPLO, N, N, -1, -1, -1, IMAT, $ NFAIL, NERRS, NOUT ) * * Compute the test ratio to compare to values of RCOND * RESULT( 7 ) = DGET06( RCOND, RCONDC ) * * Print information about the tests that did not pass * the threshold. * IF( RESULT( 7 ).GE.THRESH ) THEN IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) $ CALL ALAHD( NOUT, PATH ) WRITE( NOUT, FMT = 9997 )UPLO, N, IMAT, 7, $ RESULT( 7 ) NFAIL = NFAIL + 1 END IF NRUN = NRUN + 1 240 CONTINUE * 250 CONTINUE 260 CONTINUE 270 CONTINUE * * Print a summary of the results. * CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS ) * 9999 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NB =', I4, ', type ', $ I2, ', test ', I2, ', ratio =', G12.5 ) 9998 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NRHS=', I3, ', type ', $ I2, ', test(', I2, ') =', G12.5 ) 9997 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ',', 10X, ' type ', I2, $ ', test(', I2, ') =', G12.5 ) RETURN * * End of DCHKSY_ROOK * END
bsd-3-clause
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/sgeequ.f
29
7926
*> \brief \b SGEEQU * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download SGEEQU + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgeequ.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgeequ.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgeequ.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE SGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, * INFO ) * * .. Scalar Arguments .. * INTEGER INFO, LDA, M, N * REAL AMAX, COLCND, ROWCND * .. * .. Array Arguments .. * REAL A( LDA, * ), C( * ), R( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> SGEEQU computes row and column scalings intended to equilibrate an *> M-by-N matrix A and reduce its condition number. R returns the row *> scale factors and C the column scale factors, chosen to try to make *> the largest element in each row and column of the matrix B with *> elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1. *> *> R(i) and C(j) are restricted to be between SMLNUM = smallest safe *> number and BIGNUM = largest safe number. Use of these scaling *> factors is not guaranteed to reduce the condition number of A but *> works well in practice. *> \endverbatim * * Arguments: * ========== * *> \param[in] M *> \verbatim *> M is INTEGER *> The number of rows of the matrix A. M >= 0. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of columns of the matrix A. N >= 0. *> \endverbatim *> *> \param[in] A *> \verbatim *> A is REAL array, dimension (LDA,N) *> The M-by-N matrix whose equilibration factors are *> to be computed. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. LDA >= max(1,M). *> \endverbatim *> *> \param[out] R *> \verbatim *> R is REAL array, dimension (M) *> If INFO = 0 or INFO > M, R contains the row scale factors *> for A. *> \endverbatim *> *> \param[out] C *> \verbatim *> C is REAL array, dimension (N) *> If INFO = 0, C contains the column scale factors for A. *> \endverbatim *> *> \param[out] ROWCND *> \verbatim *> ROWCND is REAL *> If INFO = 0 or INFO > M, ROWCND contains the ratio of the *> smallest R(i) to the largest R(i). If ROWCND >= 0.1 and *> AMAX is neither too large nor too small, it is not worth *> scaling by R. *> \endverbatim *> *> \param[out] COLCND *> \verbatim *> COLCND is REAL *> If INFO = 0, COLCND contains the ratio of the smallest *> C(i) to the largest C(i). If COLCND >= 0.1, it is not *> worth scaling by C. *> \endverbatim *> *> \param[out] AMAX *> \verbatim *> AMAX is REAL *> Absolute value of largest matrix element. If AMAX is very *> close to overflow or very close to underflow, the matrix *> should be scaled. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> > 0: if INFO = i, and i is *> <= M: the i-th row of A is exactly zero *> > M: the (i-M)-th column of A is exactly zero *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup realGEcomputational * * ===================================================================== SUBROUTINE SGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, $ INFO ) * * -- LAPACK computational routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER INFO, LDA, M, N REAL AMAX, COLCND, ROWCND * .. * .. Array Arguments .. REAL A( LDA, * ), C( * ), R( * ) * .. * * ===================================================================== * * .. Parameters .. REAL ONE, ZERO PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) * .. * .. Local Scalars .. INTEGER I, J REAL BIGNUM, RCMAX, RCMIN, SMLNUM * .. * .. External Functions .. REAL SLAMCH EXTERNAL SLAMCH * .. * .. External Subroutines .. EXTERNAL XERBLA * .. * .. Intrinsic Functions .. INTRINSIC ABS, MAX, MIN * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 IF( M.LT.0 ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN INFO = -4 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'SGEEQU', -INFO ) RETURN END IF * * Quick return if possible * IF( M.EQ.0 .OR. N.EQ.0 ) THEN ROWCND = ONE COLCND = ONE AMAX = ZERO RETURN END IF * * Get machine constants. * SMLNUM = SLAMCH( 'S' ) BIGNUM = ONE / SMLNUM * * Compute row scale factors. * DO 10 I = 1, M R( I ) = ZERO 10 CONTINUE * * Find the maximum element in each row. * DO 30 J = 1, N DO 20 I = 1, M R( I ) = MAX( R( I ), ABS( A( I, J ) ) ) 20 CONTINUE 30 CONTINUE * * Find the maximum and minimum scale factors. * RCMIN = BIGNUM RCMAX = ZERO DO 40 I = 1, M RCMAX = MAX( RCMAX, R( I ) ) RCMIN = MIN( RCMIN, R( I ) ) 40 CONTINUE AMAX = RCMAX * IF( RCMIN.EQ.ZERO ) THEN * * Find the first zero scale factor and return an error code. * DO 50 I = 1, M IF( R( I ).EQ.ZERO ) THEN INFO = I RETURN END IF 50 CONTINUE ELSE * * Invert the scale factors. * DO 60 I = 1, M R( I ) = ONE / MIN( MAX( R( I ), SMLNUM ), BIGNUM ) 60 CONTINUE * * Compute ROWCND = min(R(I)) / max(R(I)) * ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM ) END IF * * Compute column scale factors * DO 70 J = 1, N C( J ) = ZERO 70 CONTINUE * * Find the maximum element in each column, * assuming the row scaling computed above. * DO 90 J = 1, N DO 80 I = 1, M C( J ) = MAX( C( J ), ABS( A( I, J ) )*R( I ) ) 80 CONTINUE 90 CONTINUE * * Find the maximum and minimum scale factors. * RCMIN = BIGNUM RCMAX = ZERO DO 100 J = 1, N RCMIN = MIN( RCMIN, C( J ) ) RCMAX = MAX( RCMAX, C( J ) ) 100 CONTINUE * IF( RCMIN.EQ.ZERO ) THEN * * Find the first zero scale factor and return an error code. * DO 110 J = 1, N IF( C( J ).EQ.ZERO ) THEN INFO = M + J RETURN END IF 110 CONTINUE ELSE * * Invert the scale factors. * DO 120 J = 1, N C( J ) = ONE / MIN( MAX( C( J ), SMLNUM ), BIGNUM ) 120 CONTINUE * * Compute COLCND = min(C(J)) / max(C(J)) * COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM ) END IF * RETURN * * End of SGEEQU * END
bsd-3-clause
UPenn-RoboCup/OpenBLAS
lapack-netlib/TESTING/LIN/zrqt03.f
32
8043
*> \brief \b ZRQT03 * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE ZRQT03( M, N, K, AF, C, CC, Q, LDA, TAU, WORK, LWORK, * RWORK, RESULT ) * * .. Scalar Arguments .. * INTEGER K, LDA, LWORK, M, N * .. * .. Array Arguments .. * DOUBLE PRECISION RESULT( * ), RWORK( * ) * COMPLEX*16 AF( LDA, * ), C( LDA, * ), CC( LDA, * ), * $ Q( LDA, * ), TAU( * ), WORK( LWORK ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> ZRQT03 tests ZUNMRQ, which computes Q*C, Q'*C, C*Q or C*Q'. *> *> ZRQT03 compares the results of a call to ZUNMRQ with the results of *> forming Q explicitly by a call to ZUNGRQ and then performing matrix *> multiplication by a call to ZGEMM. *> \endverbatim * * Arguments: * ========== * *> \param[in] M *> \verbatim *> M is INTEGER *> The number of rows or columns of the matrix C; C is n-by-m if *> Q is applied from the left, or m-by-n if Q is applied from *> the right. M >= 0. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the orthogonal matrix Q. N >= 0. *> \endverbatim *> *> \param[in] K *> \verbatim *> K is INTEGER *> The number of elementary reflectors whose product defines the *> orthogonal matrix Q. N >= K >= 0. *> \endverbatim *> *> \param[in] AF *> \verbatim *> AF is COMPLEX*16 array, dimension (LDA,N) *> Details of the RQ factorization of an m-by-n matrix, as *> returned by ZGERQF. See CGERQF for further details. *> \endverbatim *> *> \param[out] C *> \verbatim *> C is COMPLEX*16 array, dimension (LDA,N) *> \endverbatim *> *> \param[out] CC *> \verbatim *> CC is COMPLEX*16 array, dimension (LDA,N) *> \endverbatim *> *> \param[out] Q *> \verbatim *> Q is COMPLEX*16 array, dimension (LDA,N) *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the arrays AF, C, CC, and Q. *> \endverbatim *> *> \param[in] TAU *> \verbatim *> TAU is COMPLEX*16 array, dimension (min(M,N)) *> The scalar factors of the elementary reflectors corresponding *> to the RQ factorization in AF. *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is COMPLEX*16 array, dimension (LWORK) *> \endverbatim *> *> \param[in] LWORK *> \verbatim *> LWORK is INTEGER *> The length of WORK. LWORK must be at least M, and should be *> M*NB, where NB is the blocksize for this environment. *> \endverbatim *> *> \param[out] RWORK *> \verbatim *> RWORK is DOUBLE PRECISION array, dimension (M) *> \endverbatim *> *> \param[out] RESULT *> \verbatim *> RESULT is DOUBLE PRECISION array, dimension (4) *> The test ratios compare two techniques for multiplying a *> random matrix C by an n-by-n orthogonal matrix Q. *> RESULT(1) = norm( Q*C - Q*C ) / ( N * norm(C) * EPS ) *> RESULT(2) = norm( C*Q - C*Q ) / ( N * norm(C) * EPS ) *> RESULT(3) = norm( Q'*C - Q'*C )/ ( N * norm(C) * EPS ) *> RESULT(4) = norm( C*Q' - C*Q' )/ ( N * norm(C) * EPS ) *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup complex16_lin * * ===================================================================== SUBROUTINE ZRQT03( M, N, K, AF, C, CC, Q, LDA, TAU, WORK, LWORK, $ RWORK, RESULT ) * * -- LAPACK test routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER K, LDA, LWORK, M, N * .. * .. Array Arguments .. DOUBLE PRECISION RESULT( * ), RWORK( * ) COMPLEX*16 AF( LDA, * ), C( LDA, * ), CC( LDA, * ), $ Q( LDA, * ), TAU( * ), WORK( LWORK ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) COMPLEX*16 ROGUE PARAMETER ( ROGUE = ( -1.0D+10, -1.0D+10 ) ) * .. * .. Local Scalars .. CHARACTER SIDE, TRANS INTEGER INFO, ISIDE, ITRANS, J, MC, MINMN, NC DOUBLE PRECISION CNORM, EPS, RESID * .. * .. External Functions .. LOGICAL LSAME DOUBLE PRECISION DLAMCH, ZLANGE EXTERNAL LSAME, DLAMCH, ZLANGE * .. * .. External Subroutines .. EXTERNAL ZGEMM, ZLACPY, ZLARNV, ZLASET, ZUNGRQ, ZUNMRQ * .. * .. Local Arrays .. INTEGER ISEED( 4 ) * .. * .. Intrinsic Functions .. INTRINSIC DBLE, DCMPLX, MAX, MIN * .. * .. Scalars in Common .. CHARACTER*32 SRNAMT * .. * .. Common blocks .. COMMON / SRNAMC / SRNAMT * .. * .. Data statements .. DATA ISEED / 1988, 1989, 1990, 1991 / * .. * .. Executable Statements .. * EPS = DLAMCH( 'Epsilon' ) MINMN = MIN( M, N ) * * Quick return if possible * IF( MINMN.EQ.0 ) THEN RESULT( 1 ) = ZERO RESULT( 2 ) = ZERO RESULT( 3 ) = ZERO RESULT( 4 ) = ZERO RETURN END IF * * Copy the last k rows of the factorization to the array Q * CALL ZLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA ) IF( K.GT.0 .AND. N.GT.K ) $ CALL ZLACPY( 'Full', K, N-K, AF( M-K+1, 1 ), LDA, $ Q( N-K+1, 1 ), LDA ) IF( K.GT.1 ) $ CALL ZLACPY( 'Lower', K-1, K-1, AF( M-K+2, N-K+1 ), LDA, $ Q( N-K+2, N-K+1 ), LDA ) * * Generate the n-by-n matrix Q * SRNAMT = 'ZUNGRQ' CALL ZUNGRQ( N, N, K, Q, LDA, TAU( MINMN-K+1 ), WORK, LWORK, $ INFO ) * DO 30 ISIDE = 1, 2 IF( ISIDE.EQ.1 ) THEN SIDE = 'L' MC = N NC = M ELSE SIDE = 'R' MC = M NC = N END IF * * Generate MC by NC matrix C * DO 10 J = 1, NC CALL ZLARNV( 2, ISEED, MC, C( 1, J ) ) 10 CONTINUE CNORM = ZLANGE( '1', MC, NC, C, LDA, RWORK ) IF( CNORM.EQ.ZERO ) $ CNORM = ONE * DO 20 ITRANS = 1, 2 IF( ITRANS.EQ.1 ) THEN TRANS = 'N' ELSE TRANS = 'C' END IF * * Copy C * CALL ZLACPY( 'Full', MC, NC, C, LDA, CC, LDA ) * * Apply Q or Q' to C * SRNAMT = 'ZUNMRQ' IF( K.GT.0 ) $ CALL ZUNMRQ( SIDE, TRANS, MC, NC, K, AF( M-K+1, 1 ), LDA, $ TAU( MINMN-K+1 ), CC, LDA, WORK, LWORK, $ INFO ) * * Form explicit product and subtract * IF( LSAME( SIDE, 'L' ) ) THEN CALL ZGEMM( TRANS, 'No transpose', MC, NC, MC, $ DCMPLX( -ONE ), Q, LDA, C, LDA, $ DCMPLX( ONE ), CC, LDA ) ELSE CALL ZGEMM( 'No transpose', TRANS, MC, NC, NC, $ DCMPLX( -ONE ), C, LDA, Q, LDA, $ DCMPLX( ONE ), CC, LDA ) END IF * * Compute error in the difference * RESID = ZLANGE( '1', MC, NC, CC, LDA, RWORK ) RESULT( ( ISIDE-1 )*2+ITRANS ) = RESID / $ ( DBLE( MAX( 1, N ) )*CNORM*EPS ) * 20 CONTINUE 30 CONTINUE * RETURN * * End of ZRQT03 * END
bsd-3-clause
nvarini/espresso_iohpc
PW/src/martyna_tuckerman.f90
4
10373
! ! Copyright (C) 2001-2006 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 . ! #undef TESTING MODULE martyna_tuckerman ! ! ... The variables needed to the Martyna-Tuckerman method for isolated ! systems ! USE kinds, ONLY: dp USE constants, ONLY : e2, pi, tpi, fpi USE ws_base ! IMPLICIT NONE ! TYPE (ws_type) :: ws REAL (DP) :: alpha, beta REAL (DP), ALLOCATABLE :: wg_corr(:) LOGICAL :: wg_corr_is_updated = .FALSE. LOGICAL :: do_comp_mt = .FALSE. LOGICAL :: gamma_only = .FALSE. integer :: gstart = 1 ! SAVE PRIVATE PUBLIC :: tag_wg_corr_as_obsolete, do_comp_mt, & wg_corr_ewald, wg_corr_loc, wg_corr_h, wg_corr_force CONTAINS !---------------------------------------------------------------------------- SUBROUTINE tag_wg_corr_as_obsolete !---------------------------------------------------------------------------- wg_corr_is_updated = .FALSE. END SUBROUTINE tag_wg_corr_as_obsolete !---------------------------------------------------------------------------- SUBROUTINE wg_corr_h( omega, ngm, rho, v, eh_corr ) !---------------------------------------------------------------------------- INTEGER, INTENT(IN) :: ngm REAL(DP), INTENT(IN) :: omega COMPLEX(DP), INTENT(IN) :: rho(ngm) COMPLEX(DP), INTENT(OUT) :: v(ngm) REAL(DP), INTENT(OUT) :: eh_corr INTEGER :: ig IF (.NOT.wg_corr_is_updated) CALL init_wg_corr ! v(:) = (0._dp,0._dp) eh_corr = 0._dp DO ig = 1,ngm v(ig) = e2 * wg_corr(ig) * rho(ig) eh_corr = eh_corr + ABS(rho(ig))**2 * wg_corr(ig) END DO iF (gamma_only) v(gstart:ngm) = 0.5_dp * v(gstart:ngm) eh_corr = 0.5_dp * e2 * eh_corr * omega RETURN END SUBROUTINE wg_corr_h !---------------------------------------------------------------------------- SUBROUTINE wg_corr_loc( omega, ntyp, ngm, zv, strf, v ) !---------------------------------------------------------------------------- INTEGER, INTENT(IN) :: ntyp, ngm REAL(DP), INTENT(IN) :: omega, zv(ntyp) COMPLEX(DP), INTENT(IN) :: strf(ngm,ntyp) COMPLEX(DP), INTENT(OUT) :: v(ngm) INTEGER :: ig IF (.NOT.wg_corr_is_updated) CALL init_wg_corr ! do ig=1,ngm v(ig) = - e2 * wg_corr(ig) * SUM(zv(1:ntyp)*strf(ig,1:ntyp)) / omega end do iF (gamma_only) v(gstart:ngm) = 0.5_dp * v(gstart:ngm) RETURN END SUBROUTINE wg_corr_loc !---------------------------------------------------------------------------- SUBROUTINE wg_corr_force( lnuclei, omega, nat, ntyp, ityp, ngm, g, tau, zv, strf, nspin, & rho, force ) !---------------------------------------------------------------------------- USE cell_base, ONLY : tpiba USE mp_bands, ONLY : intra_bgrp_comm USE mp, ONLY : mp_sum INTEGER, INTENT(IN) :: nat, ntyp, ityp(nat), ngm, nspin REAL(DP), INTENT(IN) :: omega, zv(ntyp), tau(3,nat), g(3,ngm) COMPLEX(DP), INTENT(IN) :: strf(ngm,ntyp), rho(ngm,nspin) LOGICAL, INTENT(IN) :: lnuclei ! this variable is used in wg_corr_force to select if ! corr should be done on rho and nuclei or only on rho REAL(DP), INTENT(OUT) :: force(3,nat) INTEGER :: ig, na REAL (DP) :: arg COMPLEX(DP), ALLOCATABLE :: v(:) COMPLEX(DP) :: rho_tot ! IF (.NOT.wg_corr_is_updated) CALL init_wg_corr ! allocate ( v(ngm) ) do ig=1,ngm rho_tot = rho(ig,1) if(lnuclei) rho_tot = rho_tot - SUM(zv(1:ntyp)*strf(ig,1:ntyp)) / omega if (nspin==2) rho_tot = rho_tot + rho(ig,2) v(ig) = e2 * wg_corr(ig) * rho_tot end do force(:,:) = 0._dp do na=1,nat do ig=1,ngm arg = tpi * SUM ( g(:,ig)*tau(:, na) ) force(:,na) = force(:,na) + g(:,ig) * CMPLX(SIN(arg),-COS(ARG)) * v(ig) end do force(:,na) = - force(:,na) * zv(ityp(na)) * tpiba end do deallocate ( v ) ! call mp_sum( force, intra_bgrp_comm ) ! RETURN END SUBROUTINE wg_corr_force !---------------------------------------------------------------------------- SUBROUTINE init_wg_corr !---------------------------------------------------------------------------- USE mp_bands, ONLY : me_bgrp USE fft_base, ONLY : dfftp USE fft_interfaces,ONLY : fwfft, invfft USE control_flags, ONLY : gamma_only_ => gamma_only USE gvect, ONLY : ngm, gg, gstart_ => gstart, nl, nlm, ecutrho USE cell_base, ONLY : at, alat, tpiba2, omega INTEGER :: idx0, idx, ir, i,j,k, ig, nt REAL(DP) :: r(3), rws, upperbound, rws2 COMPLEX (DP), ALLOCATABLE :: aux(:) REAL(DP), EXTERNAL :: qe_erfc #ifdef TESTING REAL(DP), ALLOCATABLE :: plot(:) CHARACTER (LEN=25) :: filplot LOGICAL, SAVE :: first = .TRUE. #endif IF ( ALLOCATED(wg_corr) ) DEALLOCATE(wg_corr) ALLOCATE(wg_corr(ngm)) ! ! choose alpha in order to have convergence in the sum over G ! upperbound is a safe upper bound for the error in the sum over G ! alpha = 2.9d0 upperbound = 1._dp DO WHILE ( upperbound > 1.e-7_dp) alpha = alpha - 0.1_dp if (alpha<=0._dp) call errore('init_wg_corr','optimal alpha not found',1) upperbound = e2 * sqrt (2.d0 * alpha / tpi) * & qe_erfc ( sqrt ( ecutrho / 4.d0 / alpha) ) END DO beta = 0.5_dp/alpha ! 1._dp/alpha ! write (*,*) " alpha, beta MT = ", alpha, beta ! call ws_init(at,ws) ! gstart = gstart_ gamma_only = gamma_only_ ! ! idx0 = starting index of real-space FFT arrays for this processor ! idx0 = dfftp%nr1x*dfftp%nr2x * dfftp%ipp(me_bgrp+1) ! ALLOCATE (aux(dfftp%nnr)) aux = CMPLX(0._dp,0._dp) DO ir = 1, dfftp%nr1x*dfftp%nr2x * dfftp%npl ! ! ... three dimensional indices ! idx = idx0 + ir - 1 k = idx / (dfftp%nr1x*dfftp%nr2x) idx = idx - (dfftp%nr1x*dfftp%nr2x)*k j = idx / dfftp%nr1x idx = idx - dfftp%nr1x*j i = idx r(:) = ( at(:,1)/dfftp%nr1*i + at(:,2)/dfftp%nr2*j + at(:,3)/dfftp%nr3*k ) rws = ws_dist(r,ws) #ifdef TESTING rws2 = ws_dist_stupid(r,ws) if (abs (rws-rws2) > 1.e-5 ) then write (*,'(4i8)') ir, i,j,k write (*,'(5f14.8)') r(:), rws, rws2 stop end if #endif aux(ir) = smooth_coulomb_r( rws*alat ) END DO CALL fwfft ('Dense', aux, dfftp) do ig =1, ngm wg_corr(ig) = omega * REAL(aux(nl(ig))) - smooth_coulomb_g( tpiba2*gg(ig)) end do wg_corr(:) = wg_corr(:) * exp(-tpiba2*gg(:)*beta/4._dp)**2 ! if (gamma_only) wg_corr(gstart:ngm) = 2.d0 * wg_corr(gstart:ngm) ! wg_corr_is_updated = .true. #ifdef TESTING if (first) then ALLOCATE(plot(dfftp%nnr)) filplot = 'wg_corr_r' CALL invfft ('Dense', aux, dfftp) plot(:) = REAL(aux(:)) call write_wg_on_file(filplot, plot) filplot = 'wg_corr_g' aux(:) = CMPLX(0._dp,0._dp) do ig =1, ngm aux(nl(ig)) = smooth_coulomb_g( tpiba2*gg(ig))/omega end do if (gamma_only) aux(nlm(1:ngm)) = CONJG( aux(nl(1:ngm)) ) CALL invfft ('Dense', aux, dfftp) plot(:) = REAL(aux(:)) call write_wg_on_file(filplot, plot) filplot = 'wg_corr_diff' aux(:) = CMPLX(0._dp,0._dp) aux(nl(1:ngm)) = wg_corr(1:ngm) / omega if (gamma_only) then aux(:) = 0.5_dp * aux(:) aux(nlm(1:ngm)) = aux(nlm(1:ngm)) + CONJG( aux(nl(1:ngm)) ) end if CALL invfft ('Dense', aux, dfftp) plot(:) = REAL(aux(:)) call write_wg_on_file(filplot, plot) DEALLOCATE (plot) first = .false. end if #endif DEALLOCATE (aux) RETURN END SUBROUTINE init_wg_corr !---------------------------------------------------------------------------- SUBROUTINE write_wg_on_file(filplot, plot) !---------------------------------------------------------------------------- USE fft_base, ONLY : dfftp USE gvect, ONLY : gcutm USE gvecw, ONLY : ecutwfc USE gvecs, ONLY : dual USE cell_base, ONLY : at, alat, tpiba2, omega, ibrav, celldm USE ions_base, ONLY : zv, ntyp => nsp, nat, ityp, atm, tau CHARACTER (LEN=25), INTENT(IN) :: filplot REAL(DP) :: plot(dfftp%nnr) CHARACTER (LEN=25) :: title INTEGER :: plot_num=0, iflag=+1 CALL plot_io (filplot, title, dfftp%nr1x, dfftp%nr2x, dfftp%nr3x, & dfftp%nr1, dfftp%nr2, dfftp%nr3, nat, ntyp, ibrav, celldm, at, & gcutm, dual, ecutwfc, plot_num, atm, ityp, zv, tau, plot, iflag) RETURN END SUBROUTINE write_wg_on_file !---------------------------------------------------------------------------- REAL(DP) FUNCTION wg_corr_ewald ( omega, ntyp, ngm, zv, strf ) !---------------------------------------------------------------------------- INTEGER, INTENT(IN) :: ntyp, ngm REAL(DP), INTENT(IN) :: omega, zv(ntyp) COMPLEX(DP), INTENT(IN) :: strf(ngm,ntyp) INTEGER :: ig COMPLEX(DP) :: rhoion IF (.NOT.wg_corr_is_updated) CALL init_wg_corr ! wg_corr_ewald = 0._dp DO ig=1,ngm rhoion = SUM (zv(1:ntyp)* strf(ig,1:ntyp) ) / omega wg_corr_ewald = wg_corr_ewald + ABS(rhoion)**2 * wg_corr(ig) END DO wg_corr_ewald = 0.5_dp * e2 * wg_corr_ewald * omega ! write(*,*) "ewald correction = ", wg_corr_ewald END FUNCTION wg_corr_ewald !---------------------------------------------------------------------------- REAL(DP) FUNCTION smooth_coulomb_r(r) !---------------------------------------------------------------------------- REAL(DP), INTENT(IN) :: r REAL(DP), EXTERNAL :: qe_erf ! smooth_coulomb_r = sqrt(2._dp*alpha/tpi)**3 * exp(-alpha*r*r) ! to be modified IF (r>1.e-6_dp) THEN smooth_coulomb_r = qe_erf(sqrt(alpha)*r)/r ELSE smooth_coulomb_r = 2._dp/sqrt(pi) * sqrt(alpha) END IF END FUNCTION smooth_coulomb_r !---------------------------------------------------------------------------- REAL(DP) FUNCTION smooth_coulomb_g(q2) !---------------------------------------------------------------------------- REAL(DP), INTENT(IN) :: q2 ! smooth_coulomb_g = exp(-q2/4._dp/alpha) ! to be modified IF (q2>1.e-6_dp) THEN smooth_coulomb_g = fpi * exp(-q2/4._dp/alpha)/q2 ! to be modified ELSE smooth_coulomb_g = - 1._dp * fpi * (1._dp/4._dp/alpha + 2._dp*beta/4._dp) END IF END FUNCTION smooth_coulomb_g !---------------------------------------------------------------------------- END MODULE martyna_tuckerman
gpl-2.0
nvarini/espresso_iohpc
GIPAW/src/gipaw_setup.f90
1
17029
! ! Copyright (C) 2001-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 gipaw_setup !----------------------------------------------------------------------- ! ! ... GIPAW setup ! USE kinds, ONLY : dp USE io_global, ONLY : stdout USE wvfct, ONLY : nbnd, et, wg USE lsda_mod, ONLY : nspin USE scf, ONLY : v, vrs, vltot, kedtau, rho USE fft_base, ONLY : dfftp USE gvecs, ONLY : doublegrid USE klist, ONLY : degauss, ngauss, nks, lgauss, wk, two_fermi_energies USE ktetra, ONLY : ltetra USE noncollin_module, ONLY : noncolin USE constants, ONLY : degspin, pi USE mp_pools, ONLY : inter_pool_comm USE mp, ONLY : mp_max, mp_min USE dfunct, ONLY : newd USE pwcom, ONLY : ef USE constants, ONLY : rytoev USE gipaw_module USE ions_base, only: tau, ityp implicit none integer :: ik, ibnd real(dp) :: emin, emax, xmax, small, fac, target call start_clock ('gipaw_setup') ! TODO: test whether the symmetry operations map the Cartesian axis to each ! call test_symmetries ( s, nsym ) ! initialize pseudopotentials and projectors for LDA+U call init_us_1 call init_at_1 call plugin_initbase() call plugin_init_cell() call plugin_init_ions() ! setup GIPAW operators call gipaw_setup_integrals call gipaw_setup_l ! computes the total local potential (external+scf) on the smooth grid call setlocal call plugin_scf_potential(rho, .false., -1d0) call set_vrs (vrs, vltot, v%of_r, kedtau, v%kin_r, dfftp%nnr, nspin, doublegrid) ! compute the D for the pseudopotentials call newd !! set non linear core correction stuff (IS THIS REALLY NEEDED?) !! nlcc_any = ANY ( upf(1:ntyp)%nlcc ) !!if (nlcc_any) allocate (drc( ngm, ntyp)) !! setup all gradient correction stuff !!call setup_dgc ! some pre-conditions if (ltetra) call errore('gipaw_setup','GIPAW + tetrahedra not implemented', 1) if (noncolin) call errore('gipaw_setup','GIPAW + non-collinear not implemented', 1) if (two_fermi_energies .and. lgauss) & call errore('gipaw_setup','GIPAW + two Fermi energies not implemented', 1) ! computes the number of occupied bands for each k point nbnd_occ (:) = 0 if (lgauss) then write(stdout,*) write(stdout,'(5X,''smearing ngauss='',I4,2X,''degauss='',F8.4,'' Ry'')') & ngauss, degauss ! discard conduction bands such that w0gauss(x,n) < small ! hint: ! small = 1.0333492677046d-2 ! corresponds to 2 gaussian sigma ! small = 6.9626525973374d-5 ! corresponds to 3 gaussian sigma ! small = 6.3491173359333d-8 ! corresponds to 4 gaussian sigma small = 6.3491173359333d-8 ! appropriate limit for gaussian broadening (used for all ngauss) xmax = sqrt(-log(sqrt(pi)*small)) ! appropriate limit for Fermi-Dirac if (ngauss == -99) then fac = 1.d0 / sqrt(small) xmax = 2.d0 * log(0.5d0*(fac + sqrt(fac*fac-4.d0))) endif target = ef + xmax * degauss do ik = 1, nks do ibnd = 1, nbnd !DEBUG if (ionode) write(70,*) et(ibnd,ik), wg(ibnd,ik)/wk(ik) if (et(ibnd,ik) < target) nbnd_occ(ik) = ibnd enddo if (nbnd_occ (ik) == nbnd) & write(stdout,'(5X,''Possibly too few bands at k-point:'',I6)') ik enddo else ! general case do ik = 1, nks do ibnd = 1, nbnd if (wk(ik) > 0.d0) then if (wg(ibnd,ik)/wk(ik) > 1d-4 ) nbnd_occ(ik) = ibnd endif end do end do end if ! computes alpha_pv emin = et (1, 1) do ik = 1, nks do ibnd = 1, nbnd emin = min (emin, et (ibnd, ik) ) enddo enddo #ifdef __MPI ! find the minimum across pools call mp_min( emin, inter_pool_comm ) #endif if (lgauss) then ! metal emax = target alpha_pv = emax - emin else ! insulator emax = et(1,1) do ik = 1, nks do ibnd = 1, nbnd_occ(ik) emax = max(emax, et(ibnd,ik)) enddo enddo #ifdef __MPI ! find the maximum across pools call mp_max( emax, inter_pool_comm ) #endif alpha_pv = 2.d0 * (emax - emin) endif ! avoid zero value for alpha_pv alpha_pv = max(alpha_pv, 1.0d-2) write(stdout,'(5X,''alpha_pv='',F12.4,'' eV'')') alpha_pv*rytoev if (iverbosity > 10) then write(stdout,*) write(stdout,'(5X,''Number of occupied bands for each k-point:'')') do ik = 1, nks write(stdout,'(5X,''k-point:'',I6,4X,''nbnd_occ='',I4)') ik, nbnd_occ(ik) enddo write(stdout,*) endif call stop_clock('gipaw_setup') END SUBROUTINE gipaw_setup !----------------------------------------------------------------------- SUBROUTINE gipaw_setup_integrals !----------------------------------------------------------------------- ! ! ... Setup the GIPAW integrals: NMR core contribution, diamagnetic 'E' ! ... and paramagnetic 'F' terms, relativistic mass corrections ! USE gipaw_module USE kinds, ONLY : dp USE ions_base, ONLY : ntyp => nsp, atm USE atom, ONLY : rgrid USE paw_gipaw, ONLY : paw_recon, paw_nkb, paw_vkb, paw_becp, set_paw_upf USE uspp_param, ONLY : upf USE io_global, ONLY : stdout USE wvfct, ONLY : nbnd, npwx implicit none real(dp), allocatable :: work(:), kinetic_aephi(:), kinetic_psphi(:) real(dp), allocatable :: aephi_dvloc_dr(:), psphi_dvloc_dr(:) integer :: nt, il, il1, il2, l1, l2, j, kkpsi, nrc integer :: core_orb real(dp) :: integral, occupation ! initialize data, also for the case that no GIPAW is present if ( .not. allocated(paw_recon) ) allocate(paw_recon(ntyp)) paw_recon(:)%gipaw_data_in_upf_file = .false. paw_recon(:)%paw_nbeta = 0 paw_recon(:)%paw_nh = 0 paw_recon(:)%paw_kkbeta = 0 paw_recon(:)%gipaw_ncore_orbital = 0 paw_recon(:)%vloc_present = .false. do nt = 1, ntyp paw_recon(nt)%paw_lll(:) = 0 end do ! setup GIPAW projectors do nt = 1, ntyp call set_paw_upf(nt, upf(nt)) !!call read_recon(file_reconstruction(nt), nt, paw_recon(nt)) enddo do nt = 1, ntyp do il = 1, paw_recon(nt)%paw_nbeta if ( paw_recon(nt)%psphi(il)%label%rc < -0.99d0 ) then rc(nt,paw_recon(nt)%psphi(il)%label%l) = 1.6d0 rc(nt,paw_recon(nt)%aephi(il)%label%l) = 1.6d0 paw_recon(nt)%psphi(il)%label%rc = rc(nt,paw_recon(nt)%psphi(il)%label%l) paw_recon(nt)%aephi(il)%label%rc = rc(nt,paw_recon(nt)%aephi(il)%label%l) else rc(nt,paw_recon(nt)%psphi(il)%label%l) = paw_recon(nt)%psphi(il)%label%rc rc(nt,paw_recon(nt)%aephi(il)%label%l) = paw_recon(nt)%aephi(il)%label%rc endif enddo enddo call init_gipaw_1() ! allocate GIPAW projectors allocate ( paw_vkb(npwx,paw_nkb) ) allocate ( paw_becp(paw_nkb,nbnd) ) allocate ( paw_becp2(paw_nkb,nbnd) ) allocate ( paw_becp3(paw_nkb,nbnd) ) ! allocate GIPAW integrals allocate ( radial_integral_diamagnetic(nbrx,nbrx,ntypx) ) allocate ( radial_integral_paramagnetic(nbrx,nbrx,ntypx) ) allocate ( radial_integral_diamagnetic_so(nbrx,nbrx,ntypx) ) allocate ( radial_integral_paramagnetic_so(nbrx,nbrx,ntypx) ) allocate ( radial_integral_rmc(nbrx,nbrx,ntypx) ) radial_integral_diamagnetic = 0.d0 radial_integral_paramagnetic = 0.d0 radial_integral_diamagnetic_so = 0.d0 radial_integral_paramagnetic_so = 0.d0 radial_integral_rmc = 0.d0 ! calculate GIPAW integrals do nt = 1, ntyp do il1 = 1, paw_recon(nt)%paw_nbeta l1 = paw_recon(nt)%psphi(il1)%label%l kkpsi = paw_recon(nt)%aephi(il1)%kkpsi nrc = paw_recon(nt)%psphi(il1)%label%nrc allocate ( work(kkpsi) ) do il2 = 1, paw_recon(nt)%paw_nbeta l2 = paw_recon(nt)%psphi(il2)%label%l if ( l1 /= l2 ) cycle ! NMR diamagnetic: (1/r) do j = 1, nrc work(j) = ( paw_recon(nt)%aephi(il1)%psi(j) * paw_recon(nt)%aephi(il2)%psi(j) & - paw_recon(nt)%psphi(il1)%psi(j) * paw_recon(nt)%psphi(il2)%psi(j) ) & / rgrid(nt)%r(j) enddo call simpson( nrc, work, rgrid(nt)%rab(:nrc), radial_integral_diamagnetic(il1,il2,nt) ) ! NMR paramagnetic: (1/r^3) do j = 1, nrc work(j) = ( paw_recon(nt)%aephi(il1)%psi(j) * paw_recon(nt)%aephi(il2)%psi(j) & - paw_recon(nt)%psphi(il1)%psi(j) * paw_recon(nt)%psphi(il2)%psi(j) ) & / rgrid(nt)%r(j) ** 3 enddo call simpson( nrc, work, rgrid(nt)%rab(:nrc), radial_integral_paramagnetic(il1,il2,nt) ) ! calculate the radial integral only if the radial potential is present if ( .not. paw_recon(nt)%vloc_present ) cycle ! g-tensor relativistic mass correction: (-nabla^2) allocate ( kinetic_aephi ( kkpsi ), kinetic_psphi ( kkpsi ) ) call radial_kinetic_energy (nrc, l2, rgrid(nt)%r(:nrc), paw_recon(nt)%aephi(il2)%psi(:nrc), & kinetic_aephi(:nrc)) call radial_kinetic_energy (nrc, l2, rgrid(nt)%r(:nrc), paw_recon(nt)%psphi(il2)%psi(:nrc), & kinetic_psphi(:nrc)) do j = 1, nrc work(j) = ( paw_recon(nt)%aephi(il1)%psi(j) * kinetic_aephi(j) & - paw_recon(nt)%psphi(il1)%psi(j) * kinetic_psphi(j) ) enddo deallocate ( kinetic_aephi, kinetic_psphi ) call simpson ( nrc, work, rgrid(nt)%rab(:nrc), radial_integral_rmc(il1,il2,nt) ) ! calculate dV/dr allocate ( aephi_dvloc_dr(nrc), psphi_dvloc_dr(nrc) ) call radial_derivative (nrc, rgrid(nt)%r(:nrc), paw_recon(nt)%gipaw_ae_vloc(:nrc), aephi_dvloc_dr(:nrc)) call radial_derivative (nrc, rgrid(nt)%r(:nrc), paw_recon(nt)%gipaw_ps_vloc(:nrc), psphi_dvloc_dr(:nrc)) ! g tensor diamagnetic: (r*dV/dr) do j = 1, nrc work(j) = ( paw_recon(nt)%aephi(il1)%psi(j) * aephi_dvloc_dr(j) * paw_recon(nt)%aephi(il2)%psi(j) & - paw_recon(nt)%psphi(il1)%psi(j) * psphi_dvloc_dr(j) * paw_recon(nt)%psphi(il2)%psi(j) ) & * rgrid(nt)%r(j) enddo call simpson( nrc, work, rgrid(nt)%rab(:nrc), radial_integral_diamagnetic_so(il1,il2,nt) ) ! g tensor paramagnetic: (1/r*dV/dr) do j = 1, nrc work(j) = ( paw_recon(nt)%aephi(il1)%psi(j) * aephi_dvloc_dr(j) * paw_recon(nt)%aephi(il2)%psi(j) & - paw_recon(nt)%psphi(il1)%psi(j) * psphi_dvloc_dr(j) * paw_recon(nt)%psphi(il2)%psi(j) ) & / rgrid(nt)%r(j) enddo call simpson( nrc,work,rgrid(nt)%rab(:nrc), radial_integral_paramagnetic_so(il1,il2,nt) ) deallocate ( aephi_dvloc_dr, psphi_dvloc_dr ) enddo ! l2 deallocate ( work ) enddo ! l1 enddo ! nt ! Compute the shift due to core orbitals (purely diamagnetic) do nt = 1, ntyp if ( paw_recon(nt)%gipaw_ncore_orbital == 0 ) cycle allocate ( work(rgrid(nt)%mesh) ) nmr_shift_core(nt) = 0.0 do core_orb = 1, paw_recon(nt)%gipaw_ncore_orbital do j = 1, size(work) work(j) = paw_recon(nt)%gipaw_core_orbital(j,core_orb) ** 2 / rgrid(nt)%r(j) end do call simpson( size(work), work, rgrid(nt)%rab(:), integral ) occupation = 2 * ( 2 * paw_recon(nt)%gipaw_core_orbital_l(core_orb) + 1 ) nmr_shift_core(nt) = nmr_shift_core(nt) + occupation * integral enddo deallocate ( work ) nmr_shift_core(nt) = nmr_shift_core(nt) * 17.75045395 * 1e-6 enddo ! print integrals if (iverbosity > 10) then write(stdout,'(5X,''GIPAW integrals: -------------------------------------------'')') write(stdout,'(5X,''Atom i/j nmr_para nmr_dia epr_rmc epr_para epr_dia'')') do nt = 1, ntyp do il1 = 1, paw_recon(nt)%paw_nbeta l1 = paw_recon(nt)%psphi(il1)%label%l do il2 = 1, paw_recon(nt)%paw_nbeta l2 = paw_recon(nt)%psphi(il2)%label%l if (l1 /= l2) cycle if (il1 < il2) cycle write(stdout,1000) atm(nt), il1, il2, & radial_integral_paramagnetic(il1,il2,nt), & radial_integral_diamagnetic(il1,il2,nt), & radial_integral_rmc(il1,il2,nt), & radial_integral_paramagnetic_so(il1,il2,nt), & radial_integral_diamagnetic_so(il1,il2,nt) enddo enddo enddo write(stdout,'(5X,''------------------------------------------------------------'')') write(stdout,*) endif 1000 format(5X,A5,1X,I1,1X,I1,1X,5E10.2) END SUBROUTINE gipaw_setup_integrals !----------------------------------------------------------------------- SUBROUTINE gipaw_setup_l !----------------------------------------------------------------------- ! ! ... Setup the L operator using the properties of the cubic harmonics. ! ... Written by Ari P. Seitsonen and Uwe Gerstman ! USE gipaw_module USE kinds, ONLY : dp USE parameters, ONLY : lmaxx #ifdef DEBUG_CUBIC_HARMONIC USE io_global, ONLY : stdout, ionode #endif implicit none integer :: lm, l, m, lm1, lm2, m1, m2, abs_m1, abs_m2 integer :: sign_m1, sign_m2 real(dp) :: alpha_lm, beta_lm integer, allocatable :: lm2l(:),lm2m (:) #ifdef DEBUG_CUBIC_HARMONIC real(dp) :: mysum1(3,lmaxx+1) real(dp) :: mysum2(3,lmaxx+1) #endif ! L_x, L_y and L_z allocate ( lx((lmaxx+1)**2,(lmaxx+1)**2) ) allocate ( ly((lmaxx+1)**2,(lmaxx+1)**2) ) allocate ( lz((lmaxx+1)**2,(lmaxx+1)**2) ) allocate ( lm2l((lmaxx+1)**2), lm2m((lmaxx+1)**2) ) lm = 0 do l = 0, lmaxx do m = 0, l lm = lm + 1 lm2l ( lm ) = l lm2m ( lm ) = m if ( m /= 0 ) then lm = lm + 1 lm2l ( lm ) = l lm2m ( lm ) = - m end if end do end do lx = 0.d0 ly = 0.d0 lz = 0.d0 do lm2 = 1, (lmaxx+1)**2 do lm1 = 1, (lmaxx+1)**2 if ( lm2l ( lm1 ) /= lm2l ( lm2 ) ) cycle l = lm2l ( lm1 ) m1 = lm2m ( lm1 ) m2 = lm2m ( lm2 ) ! L_x, L_y if ( m2 == 0 ) then if ( m1 == -1 ) then lx ( lm1, lm2 ) = - sqrt(real(l*(l+1),dp)) / sqrt(2.0_dp) else if ( m1 == +1 ) then ly ( lm1, lm2 ) = + sqrt(real(l*(l+1),dp)) / sqrt(2.0_dp) end if else if ( m1 == 0 ) then if ( m2 == -1 ) then lx ( lm1, lm2 ) = + sqrt(real(l*(l+1),dp)) / sqrt(2.0_dp) else if ( m2 == +1 ) then ly ( lm1, lm2 ) = - sqrt(real(l*(l+1),dp)) / sqrt(2.0_dp) end if else abs_m1 = abs ( m1 ) abs_m2 = abs ( m2 ) sign_m1 = sign ( 1, m1 ) sign_m2 = sign ( 1, m2 ) alpha_lm = sqrt(real(l*(l+1)-abs_m2*(abs_m2+1),dp)) beta_lm = sqrt(real(l*(l+1)-abs_m2*(abs_m2-1),dp)) if ( abs_m1 == abs_m2 + 1 ) then lx ( lm1, lm2 ) =-( sign_m2 - sign_m1 ) * alpha_lm / 4.0_dp ly ( lm1, lm2 ) = ( sign_m2 + sign_m1 ) * alpha_lm / 4.0_dp / sign_m2 else if ( abs_m1 == abs_m2 - 1 ) then lx ( lm1, lm2 ) =-( sign_m2 - sign_m1 ) * beta_lm / 4.0_dp ly ( lm1, lm2 ) =-( sign_m2 + sign_m1 ) * beta_lm / 4.0_dp / sign_m2 end if end if ! L_z if ( m1 == - m2 ) then lz ( lm1, lm2 ) = - m2 end if end do end do #ifdef DEBUG_CUBIC_HARMONICS write(stdout,'(A)') "lx:" write(stdout,'(9F8.5)') lx write(stdout,'(A)') "ly:" write(stdout,'(9F8.5)') ly write(stdout,'(A)') "lz:" write(stdout,'(9F8.5)') lz ! checks mysum1 = 0 mysum2 = 0 do lm2 = 1, (lmaxx+1)**2 do lm1 = 1, (lmaxx+1)**2 if ( lm2l ( lm1 ) /= lm2l ( lm2 ) ) cycle l = lm2l ( lm2 ) mysum1(1,l+1) = mysum1(1,l+1) + lx(lm1,lm2) mysum2(1,l+1) = mysum2(1,l+1) + lx(lm1,lm2)**2 mysum1(2,l+1) = mysum1(2,l+1) + ly(lm1,lm2) mysum2(2,l+1) = mysum2(2,l+1) + ly(lm1,lm2)**2 mysum1(3,l+1) = mysum1(3,l+1) + lz(lm1,lm2) mysum2(3,l+1) = mysum2(3,l+1) + lz(lm1,lm2)**2 end do end do write(stdout,'(A,9F8.4)') "Debug, sum1: x = ", mysum1(1,:) write(stdout,'(A,9F8.4)') "Debug, sum1: y = ", mysum1(2,:) write(stdout,'(A,9F8.4)') "Debug, sum1: z = ", mysum1(3,:) write(stdout,'(A,9F8.4)') "Debug, sum2: x = ", mysum2(1,:) write(stdout,'(A,9F8.4)') "Debug, sum2: y = ", mysum2(2,:) write(stdout,'(A,9F8.4)') "Debug, sum2: z = ", mysum2(3,:) #endif deallocate ( lm2l, lm2m ) END SUBROUTINE gipaw_setup_l
gpl-2.0
vfonov/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/datapac/camsun.f
17
9443
SUBROUTINE CHSCDF(X,NU,CDF) C C PURPOSE--THIS SUBROUTINE COMPUTES THE CUMULATIVE DISTRIBUTION C FUNCTION VALUE FOR THE CHI-SQUARED DISTRIBUTION C WITH INTEGER DEGREES OF FREEDOM PARAMETER = NU. C THIS DISTRIBUTION IS DEFINED FOR ALL NON-NEGATIVE X. C THE PROBABILITY DENSITY FUNCTION IS GIVEN C IN THE REFERENCES BELOW. C INPUT ARGUMENTS--X = THE SINGLE PRECISION VALUE AT C WHICH THE CUMULATIVE DISTRIBUTION C FUNCTION IS TO BE EVALUATED. C X SHOULD BE NON-NEGATIVE. C --NU = THE INTEGER NUMBER OF DEGREES C OF FREEDOM. C NU SHOULD BE POSITIVE. C OUTPUT ARGUMENTS--CDF = THE SINGLE PRECISION CUMULATIVE C DISTRIBUTION FUNCTION VALUE. C OUTPUT--THE SINGLE PRECISION CUMULATIVE DISTRIBUTION C FUNCTION VALUE CDF FOR THE CHI-SQUARED DISTRIBUTION C WITH DEGREES OF FREEDOM PARAMETER = NU. C PRINTING--NONE UNLESS AN INPUT ARGUMENT ERROR CONDITION EXISTS. C RESTRICTIONS--X SHOULD BE NON-NEGATIVE. C --NU SHOULD BE A POSITIVE INTEGER VARIABLE. C OTHER DATAPAC SUBROUTINES NEEDED--NORCDF. C FORTRAN LIBRARY SUBROUTINES NEEDED--DSQRT, DEXP. C MODE OF INTERNAL OPERATIONS--DOUBLE PRECISION. C LANGUAGE--ANSI FORTRAN. C REFERENCES--NATIONAL BUREAU OF STANDARDS APPLIED MATHEMATICS C SERIES 55, 1964, PAGE 941, FORMULAE 26.4.4 AND 26.4.5. C --JOHNSON AND KOTZ, CONTINUOUS UNIVARIATE C DISTRIBUTIONS--1, 1970, PAGE 176, C FORMULA 28, AND PAGE 180, FORMULA 33.1. C --OWEN, HANDBOOK OF STATISTICAL TABLES, C 1962, PAGES 50-55. C --PEARSON AND HARTLEY, BIOMETRIKA TABLES C FOR STATISTICIANS, VOLUME 1, 1954, C PAGES 122-131. C WRITTEN BY--JAMES J. FILLIBEN C STATISTICAL ENGINEERING LABORATORY (205.03) C NATIONAL BUREAU OF STANDARDS C WASHINGTON, D. C. 20234 C PHONE: 301-921-2315 C ORIGINAL VERSION--JUNE 1972. C UPDATED --MAY 1974. C UPDATED --SEPTEMBER 1975. C UPDATED --NOVEMBER 1975. C UPDATED --OCTOBER 1976. C C--------------------------------------------------------------------- C DOUBLE PRECISION DX,PI,CHI,SUM,TERM,AI,DCDFN DOUBLE PRECISION DNU DOUBLE PRECISION DSQRT,DEXP DOUBLE PRECISION DLOG DOUBLE PRECISION DFACT,DPOWER DOUBLE PRECISION DW DOUBLE PRECISION D1,D2,D3 DOUBLE PRECISION TERM0,TERM1,TERM2,TERM3,TERM4 DOUBLE PRECISION B11 DOUBLE PRECISION B21 DOUBLE PRECISION B31,B32 DOUBLE PRECISION B41,B42,B43 DATA NUCUT/1000/ DATA PI/3.14159265358979D0/ DATA DPOWER/0.33333333333333D0/ DATA B11/0.33333333333333D0/ DATA B21/-0.02777777777778D0/ DATA B31/-0.00061728395061D0/ DATA B32/-13.0D0/ DATA B41/0.00018004115226D0/ DATA B42/6.0D0/ DATA B43/17.0D0/ C IPR=6 C C CHECK THE INPUT ARGUMENTS FOR ERRORS C IF(NU.LE.0)GOTO50 IF(X.LT.0.0)GOTO55 GOTO90 50 WRITE(IPR,15) WRITE(IPR,47)NU CDF=0.0 RETURN 55 WRITE(IPR,4) WRITE(IPR,46)X CDF=0.0 RETURN 90 CONTINUE 4 FORMAT(1H , 96H***** NON-FATAL DIAGNOSTIC--THE FIRST INPUT ARGUME 1NT TO THE CHSCDF SUBROUTINE IS NEGATIVE *****) 15 FORMAT(1H , 91H***** FATAL ERROR--THE SECOND INPUT ARGUMENT TO THE 1 CHSCDF SUBROUTINE IS NON-POSITIVE *****) 46 FORMAT(1H , 35H***** THE VALUE OF THE ARGUMENT IS ,E15.8,6H *****) 47 FORMAT(1H , 35H***** THE VALUE OF THE ARGUMENT IS ,I8 ,6H *****) C C-----START POINT----------------------------------------------------- C DX=X ANU=NU DNU=NU C C IF X IS NON-POSITIVE, SET CDF = 0.0 AND RETURN. C IF NU IS SMALLER THAN 10 AND X IS MORE THAN 200 C STANDARD DEVIATIONS BELOW THE MEAN, C SET CDF = 0.0 AND RETURN. C IF NU IS 10 OR LARGER AND X IS MORE THAN 100 C STANDARD DEVIATIONS BELOW THE MEAN, C SET CDF = 0.0 AND RETURN. C IF NU IS SMALLER THAN 10 AND X IS MORE THAN 200 C STANDARD DEVIATIONS ABOVE THE MEAN, C SET CDF = 1.0 AND RETURN. C IF NU IS 10 OR LARGER AND X IS MORE THAN 100 C STANDARD DEVIATIONS ABOVE THE MEAN, C SET CDF = 1.0 AND RETURN. C IF(X.LE.0.0)GOTO105 AMEAN=ANU SD=SQRT(2.0*ANU) Z=(X-AMEAN)/SD IF(NU.LT.10.AND.Z.LT.-200.0)GOTO105 IF(NU.GE.10.AND.Z.LT.-100.0)GOTO105 IF(NU.LT.10.AND.Z.GT.200.0)GOTO107 IF(NU.GE.10.AND.Z.GT.100.0)GOTO107 GOTO109 105 CDF=0.0 RETURN 107 CDF=1.0 RETURN 109 CONTINUE C C DISTINGUISH BETWEEN 3 SEPARATE REGIONS C OF THE (X,NU) SPACE. C BRANCH TO THE PROPER COMPUTATIONAL METHOD C DEPENDING ON THE REGION. C NUCUT HAS THE VALUE 1000. C IF(NU.LT.NUCUT)GOTO1000 IF(NU.GE.NUCUT.AND.X.LE.ANU)GOTO2000 IF(NU.GE.NUCUT.AND.X.GT.ANU)GOTO3000 IBRAN=1 WRITE(IPR,99)IBRAN 99 FORMAT(1H ,42H*****INTERNAL ERROR IN CHSCDF SUBROUTINE--, 146HIMPOSSIBLE BRANCH CONDITION AT BRANCH POINT = ,I8) RETURN C C TREAT THE SMALL AND MODERATE DEGREES OF FREEDOM CASE C (THAT IS, WHEN NU IS SMALLER THAN 1000). C METHOD UTILIZED--EXACT FINITE SUM C (SEE AMS 55, PAGE 941, FORMULAE 26.4.4 AND 26.4.5). C 1000 CONTINUE CHI=DSQRT(DX) IEVODD=NU-2*(NU/2) IF(IEVODD.EQ.0)GOTO120 C SUM=0.0D0 TERM=1.0/CHI IMIN=1 IMAX=NU-1 GOTO130 C 120 SUM=1.0D0 TERM=1.0D0 IMIN=2 IMAX=NU-2 C 130 IF(IMIN.GT.IMAX)GOTO160 DO100I=IMIN,IMAX,2 AI=I TERM=TERM*(DX/AI) SUM=SUM+TERM 100 CONTINUE 160 CONTINUE C SUM=SUM*DEXP(-DX/2.0D0) IF(IEVODD.EQ.0)GOTO170 SUM=(DSQRT(2.0D0/PI))*SUM SPCHI=CHI CALL NORCDF(SPCHI,CDFN) DCDFN=CDFN SUM=SUM+2.0D0*(1.0D0-DCDFN) 170 CDF=1.0D0-SUM RETURN C C TREAT THE CASE WHEN NU IS LARGE C (THAT IS, WHEN NU IS EQUAL TO OR GREATER THAN 1000) C AND X IS LESS THAN OR EQUAL TO NU. C METHOD UTILIZED--WILSON-HILFERTY APPROXIMATION C (SEE JOHNSON AND KOTZ, VOLUME 1, PAGE 176, FORMULA 28). C 2000 CONTINUE DFACT=4.5D0*DNU U=(((DX/DNU)**DPOWER)-1.0D0+(1.0D0/DFACT))*DSQRT(DFACT) CALL NORCDF(U,CDFN) CDF=CDFN RETURN C C TREAT THE CASE WHEN NU IS LARGE C (THAT IS, WHEN NU IS EQUAL TO OR GREATER THAN 1000) C AND X IS LARGER THAN NU. C METHOD UTILIZED--HILL'S ASYMPTOTIC EXPANSION C (SEE JOHNSON AND KOTZ, VOLUME 1, PAGE 180, FORMULA 33.1). C 3000 CONTINUE DW=DSQRT(DX-DNU-DNU*DLOG(DX/DNU)) DANU=DSQRT(2.0D0/DNU) D1=DW D2=DW**2 D3=DW**3 TERM0=DW TERM1=B11*DANU TERM2=B21*D1*(DANU**2) TERM3=B31*(D2+B32)*(DANU**3) TERM4=B41*(B42*D3+B43*D1)*(DANU**4) U=TERM0+TERM1+TERM2+TERM3+TERM4 CALL NORCDF(U,CDFN) CDF=CDFN RETURN C END * NORCDF SUBROUTINE NORCDF(X,CDF) C C PURPOSE--THIS SUBROUTINE COMPUTES THE CUMULATIVE DISTRIBUTION C FUNCTION VALUE FOR THE NORMAL (GAUSSIAN) C DISTRIBUTION WITH MEAN = 0 AND STANDARD DEVIATION = 1. C THIS DISTRIBUTION IS DEFINED FOR ALL X AND HAS C THE PROBABILITY DENSITY FUNCTION C F(X) = (1/SQRT(2*PI))*EXP(-X*X/2). C INPUT ARGUMENTS--X = THE SINGLE PRECISION VALUE AT C WHICH THE CUMULATIVE DISTRIBUTION C FUNCTION IS TO BE EVALUATED. C OUTPUT ARGUMENTS--CDF = THE SINGLE PRECISION CUMULATIVE C DISTRIBUTION FUNCTION VALUE. C OUTPUT--THE SINGLE PRECISION CUMULATIVE DISTRIBUTION C FUNCTION VALUE CDF. C PRINTING--NONE. C RESTRICTIONS--NONE. C OTHER DATAPAC SUBROUTINES NEEDED--NONE. C FORTRAN LIBRARY SUBROUTINES NEEDED--EXP. C MODE OF INTERNAL OPERATIONS--SINGLE PRECISION. C LANGUAGE--ANSI FORTRAN. C REFERENCES--NATIONAL BUREAU OF STANDARDS APPLIED MATHEMATICS C SERIES 55, 1964, PAGE 932, FORMULA 26.2.17. C --JOHNSON AND KOTZ, CONTINUOUS UNIVARIATE C DISTRIBUTIONS--1, 1970, PAGES 40-111. C WRITTEN BY--JAMES J. FILLIBEN C STATISTICAL ENGINEERING LABORATORY (205.03) C NATIONAL BUREAU OF STANDARDS C WASHINGTON, D. C. 20234 C PHONE: 301-921-2315 C ORIGINAL VERSION--JUNE 1972. C UPDATED --SEPTEMBER 1975. C UPDATED --NOVEMBER 1975. C C--------------------------------------------------------------------- C DATA B1,B2,B3,B4,B5,P/.319381530,-0.356563782,1.781477937,-1.82125 15978,1.330274429,.2316419/ C IPR=6 C C CHECK THE INPUT ARGUMENTS FOR ERRORS. C NO INPUT ARGUMENT ERRORS POSSIBLE C FOR THIS DISTRIBUTION. C C-----START POINT----------------------------------------------------- C Z=X IF(X.LT.0.0)Z=-Z T=1.0/(1.0+P*Z) CDF=1.0-((0.39894228040143 )*EXP(-0.5*Z*Z))*(B1*T+B2*T**2+B3*T**3 1+B4*T**4+B5*T**5) IF(X.LT.0.0)CDF=1.0-CDF C RETURN END
apache-2.0
nvarini/espresso_iohpc
atomic/src/write_resultsps.f90
18
8721
! ! Copyright (C) 2004-2010 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 write_resultsps ( ) !-------------------------------------------------------------- USE kinds, ONLY : dp USE radial_grids, ONLY : ndmx USE io_global, ONLY : stdout, ionode, ionode_id USE mp, ONLY : mp_bcast USE constants, ONLY : eps6 USE ld1inc, ONLY : title, rel, zed, zval, lsd, isic, latt, beta, tr2, & nwfts, nnts, llts, jjts, elts, octs, iswts, enlts, nstoaets, & grid, enl, eps0, iter, etot, etots, etot0, lpaw, & etots0, ekin, encl, ehrt, ecxc, nlcc, ecc, evxt, epseu, & dhrsic, dxcsic, file_wavefunctionsps, phits, rytoev_fact, & verbosity, frozen_core, ae_fc_energy, jj, max_out_wfc USE ld1inc, ONLY : nwf, el, psi, rcut USE funct, ONLY: get_dft_name IMPLICIT NONE INTEGER :: counter real(DP) :: psiaux(ndmx,2*max_out_wfc), phase CHARACTER (len=2) :: elaux(2*max_out_wfc) INTEGER :: i, j, n, wfc_num, ios CHARACTER (len=20) :: dft_name ! ! dft_name = get_dft_name() WRITE(stdout,"(/,5x,22('-'),' Testing the pseudopotential ',22('-'),/)") WRITE(stdout,'(5x,a75)') title IF(rel==1) WRITE(stdout,'(5x,''scalar relativistic calculation'')') IF(rel==2) WRITE(stdout,'(5x,''dirac relativistic calculation'')') WRITE(stdout,"(/5x,'atomic number is',f6.2,' valence charge is',f6.2)") & zed, zval WRITE(stdout,100) dft_name(1:len_trim(dft_name)),lsd,isic,latt,beta,tr2 100 FORMAT(5x,'dft =',a,' lsd =',i1,' sic =',i1,' latt =',i1, & ' beta=',f4.2,' tr2=',1pe7.1) WRITE(stdout,200) grid%mesh,grid%r(grid%mesh),grid%xmin,grid%dx 200 FORMAT(5x,'mesh =',i4,' r(mesh) =',f10.5,' xmin =',f6.2,' dx =',f8.5) IF (rel<2) THEN WRITE(stdout,300) 300 FORMAT(/5x,'n l nl e AE (Ry) ', & ' e PS (Ry) De AE-PS (Ry) ') DO n=1,nwfts IF (verbosity=='high') THEN IF (octs(n)>-eps6) THEN IF (ABS(enl(nstoaets(n))-enlts(n))< 5.d-3) THEN WRITE(stdout,401) & nnts(n),llts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), & enl(nstoaets(n))-enlts(n) ELSE ! ! put a ! close to the eigenvalues that differ more than 5 mRy ! WRITE(stdout,403) & nnts(n),llts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), & enl(nstoaets(n))-enlts(n) ENDIF ENDIF ELSE IF (octs(n)>-eps6) THEN IF (ABS(enl(nstoaets(n))-enlts(n))< 5.d-3) THEN WRITE(stdout,400) & nnts(n),llts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), & enl(nstoaets(n))-enlts(n) ELSE WRITE(stdout,402) & nnts(n),llts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), & enl(nstoaets(n))-enlts(n) ENDIF ENDIF ENDIF ENDDO IF (ionode) WRITE(13,400) & (nnts(n),llts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), & enl(nstoaets(n))-enlts(n), n=1,nwfts) 400 FORMAT(4x,2i2,5x,a2,i4,'(',f5.2,')',f15.5,f15.5,f15.5) 401 FORMAT(4x,2i2,5x,a2,i4,'(',f5.2,')',f15.5,f15.5,f15.8) 402 FORMAT(4x,2i2,5x,a2,i4,'(',f5.2,')',f15.5,f15.5,f15.5," !") 403 FORMAT(4x,2i2,5x,a2,i4,'(',f5.2,')',f15.5,f15.5,f15.8," !") ELSE WRITE(stdout,500) 500 FORMAT(/5x,'n l j nl e AE (Ry)', & ' e PS (Ry) De AE-PS (Ry) ') DO n=1,nwfts IF (verbosity=='high') THEN IF(octs(n)>-eps6) THEN IF (ABS(enl(nstoaets(n))-enlts(n))< 5.d-3) THEN WRITE(stdout,601) & nnts(n),llts(n),jjts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), enl(nstoaets(n))-enlts(n) ELSE WRITE(stdout,603) & nnts(n),llts(n),jjts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), enl(nstoaets(n))-enlts(n) ENDIF ENDIF ELSE IF(octs(n)>-eps6) THEN IF (ABS(enl(nstoaets(n))-enlts(n))< 5.d-3) THEN WRITE(stdout,600) & nnts(n),llts(n),jjts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), enl(nstoaets(n))-enlts(n) ELSE WRITE(stdout,602) & nnts(n),llts(n),jjts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), enl(nstoaets(n))-enlts(n) ENDIF ENDIF ENDIF ENDDO IF (ionode) WRITE(13,600) & (nnts(n),llts(n),jjts(n),elts(n),iswts(n),octs(n), & enl(nstoaets(n)),enlts(n), & enl(nstoaets(n))-enlts(n), n=1,nwfts) 600 FORMAT(4x,2i2,f4.1,1x,a2,i4,'(',f5.2,')',f15.5,f15.5,f15.5) 601 FORMAT(4x,2i2,f4.1,1x,a2,i4,'(',f5.2,')',f15.5,f15.5,f15.8) 602 FORMAT(4x,2i2,f4.1,1x,a2,i4,'(',f5.2,')',f15.5,f15.5,f15.5," !") 603 FORMAT(4x,2i2,f4.1,1x,a2,i4,'(',f5.2,')',f15.5,f15.5,f15.8," !") ENDIF WRITE(stdout,"(/5x,'eps =',1pe8.1,' iter =',i3)") eps0,iter WRITE(stdout,*) WRITE(stdout,700) etot, etot*0.5_dp, etot*rytoev_fact 700 FORMAT (5x,'Etot =',f15.6,' Ry,',f15.6, ' Ha,',f15.6,' eV') WRITE(stdout,800) etots, etots*0.5_dp, etots*rytoev_fact 800 FORMAT (5x,'Etotps =',f13.6,' Ry,',f15.6,' Ha,',f15.6,' eV') IF (frozen_core.or.(verbosity=='high'.and.lpaw)) & WRITE(stdout,900) ae_fc_energy, ae_fc_energy*0.5_dp, & ae_fc_energy*rytoev_fact 900 FORMAT (5x,'Etotfc =',f13.6,' Ry,',f15.6,' Ha,',f15.6,' eV') IF (abs(etot-etot0)> 1.d-9) THEN WRITE(stdout,"(5x,'dEtot_ae =',f15.6,' Ry')") etot-etot0 WRITE(stdout,1000) etots-etots0, etot-etot0 - (etots-etots0) 1000 FORMAT (5x,'dEtot_ps =',f15.6,' Ry,',' Delta E=',f15.6,' Ry' ) IF (ionode) WRITE(13,'(5x,''dEtot_ae ='',f15.6,'' Ry'')') etot-etot0 IF (ionode) WRITE(13,& '(5x,''dEtot_ps ='',f15.6,'' Ry,'','' Delta E='', f15.6,'' Ry'' )') & etots-etots0, etot-etot0-(etots-etots0) ELSE IF (ionode) WRITE(13,700) etot, etot*0.5_dp, etot*rytoev_fact IF (ionode) WRITE(13,800) etots, etots*0.5_dp, etots*rytoev_fact ENDIF WRITE(stdout,1100) ekin, ekin*0.5_dp, ekin*rytoev_fact 1100 FORMAT (/,5x,'Ekin =',f15.6,' Ry,',f15.6,' Ha,',f15.6,' eV') WRITE(stdout,1200) encl, encl*0.5_dp, encl*rytoev_fact 1200 FORMAT (5x,'Encl =',f15.6,' Ry,',f15.6, ' Ha,',f15.6,' eV') WRITE(stdout,1271) ehrt, ehrt*0.5_dp, ehrt*rytoev_fact 1271 FORMAT (5x,'Ehrt =',f15.6,' Ry,',f15.6,' Ha,',f15.6,' eV') WRITE(stdout,1281) ecxc, ecxc*0.5_dp, ecxc*rytoev_fact 1281 FORMAT (5x,'Ecxc =',f15.6,' Ry,',f15.6,' Ha,',f15.6,' eV') IF (nlcc) WRITE(stdout,1282) ecc, ecc*0.5_dp, ecc*rytoev_fact 1282 FORMAT (5x,'(Ecc =',f15.6,' Ry,',f15.6,' Ha,',f15.6,' eV)') IF (abs(evxt)>0.0_DP) & WRITE(stdout,1291) evxt, evxt*0.5_dp, evxt*rytoev_fact 1291 FORMAT(5x,'Evxt =',f15.6,' Ry,',f15.6,' Ha,',f15.6,' eV') IF (abs(epseu)>0.0_DP) & WRITE(stdout,1292) epseu, epseu*0.5_dp, epseu*rytoev_fact 1292 FORMAT (5x,'Epseu=',f15.6,' Ry,',f15.6, ' Ha,',f15.6,' eV') IF(isic/=0) WRITE(stdout,1300) dhrsic+dxcsic, dhrsic, dxcsic 1300 FORMAT(5x,'desic:'/5x,0pf12.4,24x,2(0pf12.4)) WRITE(stdout,120) 120 FORMAT (/,5x,22('-'), ' End of pseudopotential test ',22('-'),/) ! IF (ionode) WRITE(13,*) ! IF (file_wavefunctionsps/=' ') THEN counter=1 wfc_num=MIN(nwfts, max_out_wfc) DO i=1,nwfts IF (counter > max_out_wfc) exit elaux(counter)=elts(i) psiaux(:,counter)=phits(:,i) DO j=nwf,1,-1 IF ( elts(i) == el(j) .and. jjts(i)==jj(j) ) THEN DO n=grid%mesh,1,-1 phase = psiaux(n,counter)*psi(n,1,j) IF ( abs(phase) > 1.d-12 ) THEN phase = phase / abs(phase) exit ENDIF ENDDO psiaux(:,wfc_num+counter)=psi(:,1,j)*phase elaux(wfc_num+counter)=el(j) exit ENDIF ENDDO counter=counter+1 ENDDO counter = counter - 1 CALL write_wfcfile(file_wavefunctionsps,psiaux,elaux,2*counter) ENDIF RETURN END SUBROUTINE write_resultsps
gpl-2.0
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/dlatps.f
24
24237
*> \brief \b DLATPS solves a triangular system of equations with the matrix held in packed storage. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DLATPS + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlatps.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlatps.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlatps.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DLATPS( UPLO, TRANS, DIAG, NORMIN, N, AP, X, SCALE, * CNORM, INFO ) * * .. Scalar Arguments .. * CHARACTER DIAG, NORMIN, TRANS, UPLO * INTEGER INFO, N * DOUBLE PRECISION SCALE * .. * .. Array Arguments .. * DOUBLE PRECISION AP( * ), CNORM( * ), X( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DLATPS solves one of the triangular systems *> *> A *x = s*b or A**T*x = s*b *> *> with scaling to prevent overflow, where A is an upper or lower *> triangular matrix stored in packed form. Here A**T denotes the *> transpose of A, x and b are n-element vectors, and s is a scaling *> factor, usually less than or equal to 1, chosen so that the *> components of x will be less than the overflow threshold. If the *> unscaled problem will not cause overflow, the Level 2 BLAS routine *> DTPSV is called. If the matrix A is singular (A(j,j) = 0 for some j), *> then s is set to 0 and a non-trivial solution to A*x = 0 is returned. *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> Specifies whether the matrix A is upper or lower triangular. *> = 'U': Upper triangular *> = 'L': Lower triangular *> \endverbatim *> *> \param[in] TRANS *> \verbatim *> TRANS is CHARACTER*1 *> Specifies the operation applied to A. *> = 'N': Solve A * x = s*b (No transpose) *> = 'T': Solve A**T* x = s*b (Transpose) *> = 'C': Solve A**T* x = s*b (Conjugate transpose = Transpose) *> \endverbatim *> *> \param[in] DIAG *> \verbatim *> DIAG is CHARACTER*1 *> Specifies whether or not the matrix A is unit triangular. *> = 'N': Non-unit triangular *> = 'U': Unit triangular *> \endverbatim *> *> \param[in] NORMIN *> \verbatim *> NORMIN is CHARACTER*1 *> Specifies whether CNORM has been set or not. *> = 'Y': CNORM contains the column norms on entry *> = 'N': CNORM is not set on entry. On exit, the norms will *> be computed and stored in CNORM. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the matrix A. N >= 0. *> \endverbatim *> *> \param[in] AP *> \verbatim *> AP is DOUBLE PRECISION array, dimension (N*(N+1)/2) *> The upper or lower triangular matrix A, packed columnwise in *> a linear array. The j-th column of A is stored in the array *> AP as follows: *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; *> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. *> \endverbatim *> *> \param[in,out] X *> \verbatim *> X is DOUBLE PRECISION array, dimension (N) *> On entry, the right hand side b of the triangular system. *> On exit, X is overwritten by the solution vector x. *> \endverbatim *> *> \param[out] SCALE *> \verbatim *> SCALE is DOUBLE PRECISION *> The scaling factor s for the triangular system *> A * x = s*b or A**T* x = s*b. *> If SCALE = 0, the matrix A is singular or badly scaled, and *> the vector x is an exact or approximate solution to A*x = 0. *> \endverbatim *> *> \param[in,out] CNORM *> \verbatim *> CNORM is DOUBLE PRECISION array, dimension (N) *> *> If NORMIN = 'Y', CNORM is an input argument and CNORM(j) *> contains the norm of the off-diagonal part of the j-th column *> of A. If TRANS = 'N', CNORM(j) must be greater than or equal *> to the infinity-norm, and if TRANS = 'T' or 'C', CNORM(j) *> must be greater than or equal to the 1-norm. *> *> If NORMIN = 'N', CNORM is an output argument and CNORM(j) *> returns the 1-norm of the offdiagonal part of the j-th column *> of A. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -k, the k-th argument had an illegal value *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup doubleOTHERauxiliary * *> \par Further Details: * ===================== *> *> \verbatim *> *> A rough bound on x is computed; if that is less than overflow, DTPSV *> is called, otherwise, specific code is used which checks for possible *> overflow or divide-by-zero at every operation. *> *> A columnwise scheme is used for solving A*x = b. The basic algorithm *> if A is lower triangular is *> *> x[1:n] := b[1:n] *> for j = 1, ..., n *> x(j) := x(j) / A(j,j) *> x[j+1:n] := x[j+1:n] - x(j) * A[j+1:n,j] *> end *> *> Define bounds on the components of x after j iterations of the loop: *> M(j) = bound on x[1:j] *> G(j) = bound on x[j+1:n] *> Initially, let M(0) = 0 and G(0) = max{x(i), i=1,...,n}. *> *> Then for iteration j+1 we have *> M(j+1) <= G(j) / | A(j+1,j+1) | *> G(j+1) <= G(j) + M(j+1) * | A[j+2:n,j+1] | *> <= G(j) ( 1 + CNORM(j+1) / | A(j+1,j+1) | ) *> *> where CNORM(j+1) is greater than or equal to the infinity-norm of *> column j+1 of A, not counting the diagonal. Hence *> *> G(j) <= G(0) product ( 1 + CNORM(i) / | A(i,i) | ) *> 1<=i<=j *> and *> *> |x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + CNORM(i) / |A(i,i)| ) *> 1<=i< j *> *> Since |x(j)| <= M(j), we use the Level 2 BLAS routine DTPSV if the *> reciprocal of the largest M(j), j=1,..,n, is larger than *> max(underflow, 1/overflow). *> *> The bound on x(j) is also used to determine when a step in the *> columnwise method can be performed without fear of overflow. If *> the computed bound is greater than a large constant, x is scaled to *> prevent overflow, but if the bound overflows, x is set to 0, x(j) to *> 1, and scale to 0, and a non-trivial solution to A*x = 0 is found. *> *> Similarly, a row-wise scheme is used to solve A**T*x = b. The basic *> algorithm for A upper triangular is *> *> for j = 1, ..., n *> x(j) := ( b(j) - A[1:j-1,j]**T * x[1:j-1] ) / A(j,j) *> end *> *> We simultaneously compute two bounds *> G(j) = bound on ( b(i) - A[1:i-1,i]**T * x[1:i-1] ), 1<=i<=j *> M(j) = bound on x(i), 1<=i<=j *> *> The initial values are G(0) = 0, M(0) = max{b(i), i=1,..,n}, and we *> add the constraint G(j) >= G(j-1) and M(j) >= M(j-1) for j >= 1. *> Then the bound on x(j) is *> *> M(j) <= M(j-1) * ( 1 + CNORM(j) ) / | A(j,j) | *> *> <= M(0) * product ( ( 1 + CNORM(i) ) / |A(i,i)| ) *> 1<=i<=j *> *> and we can safely call DTPSV if 1/M(n) and 1/G(n) are both greater *> than max(underflow, 1/overflow). *> \endverbatim *> * ===================================================================== SUBROUTINE DLATPS( UPLO, TRANS, DIAG, NORMIN, N, AP, X, SCALE, $ CNORM, INFO ) * * -- LAPACK auxiliary routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. CHARACTER DIAG, NORMIN, TRANS, UPLO INTEGER INFO, N DOUBLE PRECISION SCALE * .. * .. Array Arguments .. DOUBLE PRECISION AP( * ), CNORM( * ), X( * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO, HALF, ONE PARAMETER ( ZERO = 0.0D+0, HALF = 0.5D+0, ONE = 1.0D+0 ) * .. * .. Local Scalars .. LOGICAL NOTRAN, NOUNIT, UPPER INTEGER I, IMAX, IP, J, JFIRST, JINC, JLAST, JLEN DOUBLE PRECISION BIGNUM, GROW, REC, SMLNUM, SUMJ, TJJ, TJJS, $ TMAX, TSCAL, USCAL, XBND, XJ, XMAX * .. * .. External Functions .. LOGICAL LSAME INTEGER IDAMAX DOUBLE PRECISION DASUM, DDOT, DLAMCH EXTERNAL LSAME, IDAMAX, DASUM, DDOT, DLAMCH * .. * .. External Subroutines .. EXTERNAL DAXPY, DSCAL, DTPSV, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC ABS, MAX, MIN * .. * .. Executable Statements .. * INFO = 0 UPPER = LSAME( UPLO, 'U' ) NOTRAN = LSAME( TRANS, 'N' ) NOUNIT = LSAME( DIAG, 'N' ) * * Test the input parameters. * IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN INFO = -1 ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT. $ LSAME( TRANS, 'C' ) ) THEN INFO = -2 ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN INFO = -3 ELSE IF( .NOT.LSAME( NORMIN, 'Y' ) .AND. .NOT. $ LSAME( NORMIN, 'N' ) ) THEN INFO = -4 ELSE IF( N.LT.0 ) THEN INFO = -5 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'DLATPS', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * * Determine machine dependent parameters to control overflow. * SMLNUM = DLAMCH( 'Safe minimum' ) / DLAMCH( 'Precision' ) BIGNUM = ONE / SMLNUM SCALE = ONE * IF( LSAME( NORMIN, 'N' ) ) THEN * * Compute the 1-norm of each column, not including the diagonal. * IF( UPPER ) THEN * * A is upper triangular. * IP = 1 DO 10 J = 1, N CNORM( J ) = DASUM( J-1, AP( IP ), 1 ) IP = IP + J 10 CONTINUE ELSE * * A is lower triangular. * IP = 1 DO 20 J = 1, N - 1 CNORM( J ) = DASUM( N-J, AP( IP+1 ), 1 ) IP = IP + N - J + 1 20 CONTINUE CNORM( N ) = ZERO END IF END IF * * Scale the column norms by TSCAL if the maximum element in CNORM is * greater than BIGNUM. * IMAX = IDAMAX( N, CNORM, 1 ) TMAX = CNORM( IMAX ) IF( TMAX.LE.BIGNUM ) THEN TSCAL = ONE ELSE TSCAL = ONE / ( SMLNUM*TMAX ) CALL DSCAL( N, TSCAL, CNORM, 1 ) END IF * * Compute a bound on the computed solution vector to see if the * Level 2 BLAS routine DTPSV can be used. * J = IDAMAX( N, X, 1 ) XMAX = ABS( X( J ) ) XBND = XMAX IF( NOTRAN ) THEN * * Compute the growth in A * x = b. * IF( UPPER ) THEN JFIRST = N JLAST = 1 JINC = -1 ELSE JFIRST = 1 JLAST = N JINC = 1 END IF * IF( TSCAL.NE.ONE ) THEN GROW = ZERO GO TO 50 END IF * IF( NOUNIT ) THEN * * A is non-unit triangular. * * Compute GROW = 1/G(j) and XBND = 1/M(j). * Initially, G(0) = max{x(i), i=1,...,n}. * GROW = ONE / MAX( XBND, SMLNUM ) XBND = GROW IP = JFIRST*( JFIRST+1 ) / 2 JLEN = N DO 30 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 50 * * M(j) = G(j-1) / abs(A(j,j)) * TJJ = ABS( AP( IP ) ) XBND = MIN( XBND, MIN( ONE, TJJ )*GROW ) IF( TJJ+CNORM( J ).GE.SMLNUM ) THEN * * G(j) = G(j-1)*( 1 + CNORM(j) / abs(A(j,j)) ) * GROW = GROW*( TJJ / ( TJJ+CNORM( J ) ) ) ELSE * * G(j) could overflow, set GROW to 0. * GROW = ZERO END IF IP = IP + JINC*JLEN JLEN = JLEN - 1 30 CONTINUE GROW = XBND ELSE * * A is unit triangular. * * Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}. * GROW = MIN( ONE, ONE / MAX( XBND, SMLNUM ) ) DO 40 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 50 * * G(j) = G(j-1)*( 1 + CNORM(j) ) * GROW = GROW*( ONE / ( ONE+CNORM( J ) ) ) 40 CONTINUE END IF 50 CONTINUE * ELSE * * Compute the growth in A**T * x = b. * IF( UPPER ) THEN JFIRST = 1 JLAST = N JINC = 1 ELSE JFIRST = N JLAST = 1 JINC = -1 END IF * IF( TSCAL.NE.ONE ) THEN GROW = ZERO GO TO 80 END IF * IF( NOUNIT ) THEN * * A is non-unit triangular. * * Compute GROW = 1/G(j) and XBND = 1/M(j). * Initially, M(0) = max{x(i), i=1,...,n}. * GROW = ONE / MAX( XBND, SMLNUM ) XBND = GROW IP = JFIRST*( JFIRST+1 ) / 2 JLEN = 1 DO 60 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 80 * * G(j) = max( G(j-1), M(j-1)*( 1 + CNORM(j) ) ) * XJ = ONE + CNORM( J ) GROW = MIN( GROW, XBND / XJ ) * * M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j)) * TJJ = ABS( AP( IP ) ) IF( XJ.GT.TJJ ) $ XBND = XBND*( TJJ / XJ ) JLEN = JLEN + 1 IP = IP + JINC*JLEN 60 CONTINUE GROW = MIN( GROW, XBND ) ELSE * * A is unit triangular. * * Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}. * GROW = MIN( ONE, ONE / MAX( XBND, SMLNUM ) ) DO 70 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 80 * * G(j) = ( 1 + CNORM(j) )*G(j-1) * XJ = ONE + CNORM( J ) GROW = GROW / XJ 70 CONTINUE END IF 80 CONTINUE END IF * IF( ( GROW*TSCAL ).GT.SMLNUM ) THEN * * Use the Level 2 BLAS solve if the reciprocal of the bound on * elements of X is not too small. * CALL DTPSV( UPLO, TRANS, DIAG, N, AP, X, 1 ) ELSE * * Use a Level 1 BLAS solve, scaling intermediate results. * IF( XMAX.GT.BIGNUM ) THEN * * Scale X so that its components are less than or equal to * BIGNUM in absolute value. * SCALE = BIGNUM / XMAX CALL DSCAL( N, SCALE, X, 1 ) XMAX = BIGNUM END IF * IF( NOTRAN ) THEN * * Solve A * x = b * IP = JFIRST*( JFIRST+1 ) / 2 DO 110 J = JFIRST, JLAST, JINC * * Compute x(j) = b(j) / A(j,j), scaling x if necessary. * XJ = ABS( X( J ) ) IF( NOUNIT ) THEN TJJS = AP( IP )*TSCAL ELSE TJJS = TSCAL IF( TSCAL.EQ.ONE ) $ GO TO 100 END IF TJJ = ABS( TJJS ) IF( TJJ.GT.SMLNUM ) THEN * * abs(A(j,j)) > SMLNUM: * IF( TJJ.LT.ONE ) THEN IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale x by 1/b(j). * REC = ONE / XJ CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF END IF X( J ) = X( J ) / TJJS XJ = ABS( X( J ) ) ELSE IF( TJJ.GT.ZERO ) THEN * * 0 < abs(A(j,j)) <= SMLNUM: * IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM * to avoid overflow when dividing by A(j,j). * REC = ( TJJ*BIGNUM ) / XJ IF( CNORM( J ).GT.ONE ) THEN * * Scale by 1/CNORM(j) to avoid overflow when * multiplying x(j) times column j. * REC = REC / CNORM( J ) END IF CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF X( J ) = X( J ) / TJJS XJ = ABS( X( J ) ) ELSE * * A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and * scale = 0, and compute a solution to A*x = 0. * DO 90 I = 1, N X( I ) = ZERO 90 CONTINUE X( J ) = ONE XJ = ONE SCALE = ZERO XMAX = ZERO END IF 100 CONTINUE * * Scale x if necessary to avoid overflow when adding a * multiple of column j of A. * IF( XJ.GT.ONE ) THEN REC = ONE / XJ IF( CNORM( J ).GT.( BIGNUM-XMAX )*REC ) THEN * * Scale x by 1/(2*abs(x(j))). * REC = REC*HALF CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC END IF ELSE IF( XJ*CNORM( J ).GT.( BIGNUM-XMAX ) ) THEN * * Scale x by 1/2. * CALL DSCAL( N, HALF, X, 1 ) SCALE = SCALE*HALF END IF * IF( UPPER ) THEN IF( J.GT.1 ) THEN * * Compute the update * x(1:j-1) := x(1:j-1) - x(j) * A(1:j-1,j) * CALL DAXPY( J-1, -X( J )*TSCAL, AP( IP-J+1 ), 1, X, $ 1 ) I = IDAMAX( J-1, X, 1 ) XMAX = ABS( X( I ) ) END IF IP = IP - J ELSE IF( J.LT.N ) THEN * * Compute the update * x(j+1:n) := x(j+1:n) - x(j) * A(j+1:n,j) * CALL DAXPY( N-J, -X( J )*TSCAL, AP( IP+1 ), 1, $ X( J+1 ), 1 ) I = J + IDAMAX( N-J, X( J+1 ), 1 ) XMAX = ABS( X( I ) ) END IF IP = IP + N - J + 1 END IF 110 CONTINUE * ELSE * * Solve A**T * x = b * IP = JFIRST*( JFIRST+1 ) / 2 JLEN = 1 DO 160 J = JFIRST, JLAST, JINC * * Compute x(j) = b(j) - sum A(k,j)*x(k). * k<>j * XJ = ABS( X( J ) ) USCAL = TSCAL REC = ONE / MAX( XMAX, ONE ) IF( CNORM( J ).GT.( BIGNUM-XJ )*REC ) THEN * * If x(j) could overflow, scale x by 1/(2*XMAX). * REC = REC*HALF IF( NOUNIT ) THEN TJJS = AP( IP )*TSCAL ELSE TJJS = TSCAL END IF TJJ = ABS( TJJS ) IF( TJJ.GT.ONE ) THEN * * Divide by A(j,j) when scaling x if A(j,j) > 1. * REC = MIN( ONE, REC*TJJ ) USCAL = USCAL / TJJS END IF IF( REC.LT.ONE ) THEN CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF END IF * SUMJ = ZERO IF( USCAL.EQ.ONE ) THEN * * If the scaling needed for A in the dot product is 1, * call DDOT to perform the dot product. * IF( UPPER ) THEN SUMJ = DDOT( J-1, AP( IP-J+1 ), 1, X, 1 ) ELSE IF( J.LT.N ) THEN SUMJ = DDOT( N-J, AP( IP+1 ), 1, X( J+1 ), 1 ) END IF ELSE * * Otherwise, use in-line code for the dot product. * IF( UPPER ) THEN DO 120 I = 1, J - 1 SUMJ = SUMJ + ( AP( IP-J+I )*USCAL )*X( I ) 120 CONTINUE ELSE IF( J.LT.N ) THEN DO 130 I = 1, N - J SUMJ = SUMJ + ( AP( IP+I )*USCAL )*X( J+I ) 130 CONTINUE END IF END IF * IF( USCAL.EQ.TSCAL ) THEN * * Compute x(j) := ( x(j) - sumj ) / A(j,j) if 1/A(j,j) * was not used to scale the dotproduct. * X( J ) = X( J ) - SUMJ XJ = ABS( X( J ) ) IF( NOUNIT ) THEN * * Compute x(j) = x(j) / A(j,j), scaling if necessary. * TJJS = AP( IP )*TSCAL ELSE TJJS = TSCAL IF( TSCAL.EQ.ONE ) $ GO TO 150 END IF TJJ = ABS( TJJS ) IF( TJJ.GT.SMLNUM ) THEN * * abs(A(j,j)) > SMLNUM: * IF( TJJ.LT.ONE ) THEN IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale X by 1/abs(x(j)). * REC = ONE / XJ CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF END IF X( J ) = X( J ) / TJJS ELSE IF( TJJ.GT.ZERO ) THEN * * 0 < abs(A(j,j)) <= SMLNUM: * IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. * REC = ( TJJ*BIGNUM ) / XJ CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF X( J ) = X( J ) / TJJS ELSE * * A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and * scale = 0, and compute a solution to A**T*x = 0. * DO 140 I = 1, N X( I ) = ZERO 140 CONTINUE X( J ) = ONE SCALE = ZERO XMAX = ZERO END IF 150 CONTINUE ELSE * * Compute x(j) := x(j) / A(j,j) - sumj if the dot * product has already been divided by 1/A(j,j). * X( J ) = X( J ) / TJJS - SUMJ END IF XMAX = MAX( XMAX, ABS( X( J ) ) ) JLEN = JLEN + 1 IP = IP + JINC*JLEN 160 CONTINUE END IF SCALE = SCALE / TSCAL END IF * * Scale the column norms by 1/TSCAL for return. * IF( TSCAL.NE.ONE ) THEN CALL DSCAL( N, ONE / TSCAL, CNORM, 1 ) END IF * RETURN * * End of DLATPS * END
bsd-3-clause
UPenn-RoboCup/OpenBLAS
reference/cpotrif.f
50
2587
SUBROUTINE CPOTRIF( UPLO, N, A, LDA, INFO ) * * -- LAPACK routine (version 3.1) -- * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. * November 2006 * * .. Scalar Arguments .. CHARACTER UPLO INTEGER INFO, LDA, N * .. * .. Array Arguments .. COMPLEX A( LDA, * ) * .. * * Purpose * ======= * * CPOTRI computes the inverse of a complex Hermitian positive definite * matrix A using the Cholesky factorization A = U**H*U or A = L*L**H * computed by CPOTRF. * * Arguments * ========= * * UPLO (input) CHARACTER*1 * = 'U': Upper triangle of A is stored; * = 'L': Lower triangle of A is stored. * * N (input) INTEGER * The order of the matrix A. N >= 0. * * A (input/output) COMPLEX array, dimension (LDA,N) * On entry, the triangular factor U or L from the Cholesky * factorization A = U**H*U or A = L*L**H, as computed by * CPOTRF. * On exit, the upper or lower triangle of the (Hermitian) * inverse of A, overwriting the input factor U or L. * * LDA (input) INTEGER * The leading dimension of the array A. LDA >= max(1,N). * * INFO (output) INTEGER * = 0: successful exit * < 0: if INFO = -i, the i-th argument had an illegal value * > 0: if INFO = i, the (i,i) element of the factor U or L is * zero, and the inverse could not be computed. * * ===================================================================== * * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL CLAUUM, CTRTRI, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN INFO = -4 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'CPOTRI', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * * Invert the triangular Cholesky factor U or L. * CALL CTRTRI( UPLO, 'Non-unit', N, A, LDA, INFO ) IF( INFO.GT.0 ) $ RETURN * * Form inv(U)*inv(U)' or inv(L)'*inv(L). * CALL CLAUUM( UPLO, N, A, LDA, INFO ) * RETURN * * End of CPOTRI * END
bsd-3-clause
nvarini/espresso_iohpc
PW/src/wannier_enrg.f90
21
1317
! Copyright (C) 2006-2008 Dmitry Korotin dmitry@korotin.name ! 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 . ! #define ZERO (0.d0,0.d0) #define ONE (1.d0,0.d0) !---------------------------------------------------------------------- subroutine wannier_enrg(enrg) !---------------------------------------------------------------------- ! ! ... This routine computes energy of each wannier. It is assumed that WF generated already and stored if the buffer. ! use kinds, only: DP use wannier_new, only: nwan, pp use io_global, only : stdout use wvfct, only: nbnd, et, wg use klist, only: nks, wk use lsda_mod, only: current_spin, lsda, nspin, isk USE io_files USE buffers implicit none real(DP), intent(out) :: enrg(nwan,nspin) integer :: i,j, ik enrg = ZERO current_spin = 1 DO ik=1, nks IF (lsda) current_spin = isk(ik) CALL get_buffer( pp, nwordwpp, iunwpp, ik) DO i=1, nwan DO j=1, nbnd enrg(i,current_spin) = enrg(i,current_spin) + pp(i,j)*conjg(pp(i,j))*wk(ik)*et(j,ik) END DO END DO END DO IF(nspin.eq.1) enrg=enrg*0.5D0 return end subroutine wannier_enrg
gpl-2.0
buaasun/grappa
applications/NPB/OMP/LU/jacld.f
6
14506
c--------------------------------------------------------------------- c--------------------------------------------------------------------- subroutine jacld(k) c--------------------------------------------------------------------- c--------------------------------------------------------------------- c--------------------------------------------------------------------- c compute the lower triangular part of the jacobian matrix c--------------------------------------------------------------------- implicit none include 'applu.incl' c--------------------------------------------------------------------- c input parameters c--------------------------------------------------------------------- integer k c--------------------------------------------------------------------- c local variables c--------------------------------------------------------------------- integer i, j double precision r43 double precision c1345 double precision c34 double precision tmp1, tmp2, tmp3 r43 = ( 4.0d+00 / 3.0d+00 ) c1345 = c1 * c3 * c4 * c5 c34 = c3 * c4 !$omp do schedule(static) do j = jst, jend do i = ist, iend c--------------------------------------------------------------------- c form the block daigonal c--------------------------------------------------------------------- tmp1 = rho_i(i,j,k) tmp2 = tmp1 * tmp1 tmp3 = tmp1 * tmp2 d(1,1,i,j) = 1.0d+00 > + dt * 2.0d+00 * ( tx1 * dx1 > + ty1 * dy1 > + tz1 * dz1 ) d(1,2,i,j) = 0.0d+00 d(1,3,i,j) = 0.0d+00 d(1,4,i,j) = 0.0d+00 d(1,5,i,j) = 0.0d+00 d(2,1,i,j) = -dt * 2.0d+00 > * ( tx1 * r43 + ty1 + tz1 ) > * c34 * tmp2 * u(2,i,j,k) d(2,2,i,j) = 1.0d+00 > + dt * 2.0d+00 * c34 * tmp1 > * ( tx1 * r43 + ty1 + tz1 ) > + dt * 2.0d+00 * ( tx1 * dx2 > + ty1 * dy2 > + tz1 * dz2 ) d(2,3,i,j) = 0.0d+00 d(2,4,i,j) = 0.0d+00 d(2,5,i,j) = 0.0d+00 d(3,1,i,j) = -dt * 2.0d+00 > * ( tx1 + ty1 * r43 + tz1 ) > * c34 * tmp2 * u(3,i,j,k) d(3,2,i,j) = 0.0d+00 d(3,3,i,j) = 1.0d+00 > + dt * 2.0d+00 * c34 * tmp1 > * ( tx1 + ty1 * r43 + tz1 ) > + dt * 2.0d+00 * ( tx1 * dx3 > + ty1 * dy3 > + tz1 * dz3 ) d(3,4,i,j) = 0.0d+00 d(3,5,i,j) = 0.0d+00 d(4,1,i,j) = -dt * 2.0d+00 > * ( tx1 + ty1 + tz1 * r43 ) > * c34 * tmp2 * u(4,i,j,k) d(4,2,i,j) = 0.0d+00 d(4,3,i,j) = 0.0d+00 d(4,4,i,j) = 1.0d+00 > + dt * 2.0d+00 * c34 * tmp1 > * ( tx1 + ty1 + tz1 * r43 ) > + dt * 2.0d+00 * ( tx1 * dx4 > + ty1 * dy4 > + tz1 * dz4 ) d(4,5,i,j) = 0.0d+00 d(5,1,i,j) = -dt * 2.0d+00 > * ( ( ( tx1 * ( r43*c34 - c1345 ) > + ty1 * ( c34 - c1345 ) > + tz1 * ( c34 - c1345 ) ) * ( u(2,i,j,k) ** 2 ) > + ( tx1 * ( c34 - c1345 ) > + ty1 * ( r43*c34 - c1345 ) > + tz1 * ( c34 - c1345 ) ) * ( u(3,i,j,k) ** 2 ) > + ( tx1 * ( c34 - c1345 ) > + ty1 * ( c34 - c1345 ) > + tz1 * ( r43*c34 - c1345 ) ) * ( u(4,i,j,k) ** 2 ) > ) * tmp3 > + ( tx1 + ty1 + tz1 ) * c1345 * tmp2 * u(5,i,j,k) ) d(5,2,i,j) = dt * 2.0d+00 * tmp2 * u(2,i,j,k) > * ( tx1 * ( r43*c34 - c1345 ) > + ty1 * ( c34 - c1345 ) > + tz1 * ( c34 - c1345 ) ) d(5,3,i,j) = dt * 2.0d+00 * tmp2 * u(3,i,j,k) > * ( tx1 * ( c34 - c1345 ) > + ty1 * ( r43*c34 -c1345 ) > + tz1 * ( c34 - c1345 ) ) d(5,4,i,j) = dt * 2.0d+00 * tmp2 * u(4,i,j,k) > * ( tx1 * ( c34 - c1345 ) > + ty1 * ( c34 - c1345 ) > + tz1 * ( r43*c34 - c1345 ) ) d(5,5,i,j) = 1.0d+00 > + dt * 2.0d+00 * ( tx1 + ty1 + tz1 ) * c1345 * tmp1 > + dt * 2.0d+00 * ( tx1 * dx5 > + ty1 * dy5 > + tz1 * dz5 ) c--------------------------------------------------------------------- c form the first block sub-diagonal c--------------------------------------------------------------------- tmp1 = rho_i(i,j,k-1) tmp2 = tmp1 * tmp1 tmp3 = tmp1 * tmp2 a(1,1,i,j) = - dt * tz1 * dz1 a(1,2,i,j) = 0.0d+00 a(1,3,i,j) = 0.0d+00 a(1,4,i,j) = - dt * tz2 a(1,5,i,j) = 0.0d+00 a(2,1,i,j) = - dt * tz2 > * ( - ( u(2,i,j,k-1)*u(4,i,j,k-1) ) * tmp2 ) > - dt * tz1 * ( - c34 * tmp2 * u(2,i,j,k-1) ) a(2,2,i,j) = - dt * tz2 * ( u(4,i,j,k-1) * tmp1 ) > - dt * tz1 * c34 * tmp1 > - dt * tz1 * dz2 a(2,3,i,j) = 0.0d+00 a(2,4,i,j) = - dt * tz2 * ( u(2,i,j,k-1) * tmp1 ) a(2,5,i,j) = 0.0d+00 a(3,1,i,j) = - dt * tz2 > * ( - ( u(3,i,j,k-1)*u(4,i,j,k-1) ) * tmp2 ) > - dt * tz1 * ( - c34 * tmp2 * u(3,i,j,k-1) ) a(3,2,i,j) = 0.0d+00 a(3,3,i,j) = - dt * tz2 * ( u(4,i,j,k-1) * tmp1 ) > - dt * tz1 * ( c34 * tmp1 ) > - dt * tz1 * dz3 a(3,4,i,j) = - dt * tz2 * ( u(3,i,j,k-1) * tmp1 ) a(3,5,i,j) = 0.0d+00 a(4,1,i,j) = - dt * tz2 > * ( - ( u(4,i,j,k-1) * tmp1 ) ** 2 > + c2 * qs(i,j,k-1) * tmp1 ) > - dt * tz1 * ( - r43 * c34 * tmp2 * u(4,i,j,k-1) ) a(4,2,i,j) = - dt * tz2 > * ( - c2 * ( u(2,i,j,k-1) * tmp1 ) ) a(4,3,i,j) = - dt * tz2 > * ( - c2 * ( u(3,i,j,k-1) * tmp1 ) ) a(4,4,i,j) = - dt * tz2 * ( 2.0d+00 - c2 ) > * ( u(4,i,j,k-1) * tmp1 ) > - dt * tz1 * ( r43 * c34 * tmp1 ) > - dt * tz1 * dz4 a(4,5,i,j) = - dt * tz2 * c2 a(5,1,i,j) = - dt * tz2 > * ( ( c2 * 2.0d0 * qs(i,j,k-1) > - c1 * u(5,i,j,k-1) ) > * u(4,i,j,k-1) * tmp2 ) > - dt * tz1 > * ( - ( c34 - c1345 ) * tmp3 * (u(2,i,j,k-1)**2) > - ( c34 - c1345 ) * tmp3 * (u(3,i,j,k-1)**2) > - ( r43*c34 - c1345 )* tmp3 * (u(4,i,j,k-1)**2) > - c1345 * tmp2 * u(5,i,j,k-1) ) a(5,2,i,j) = - dt * tz2 > * ( - c2 * ( u(2,i,j,k-1)*u(4,i,j,k-1) ) * tmp2 ) > - dt * tz1 * ( c34 - c1345 ) * tmp2 * u(2,i,j,k-1) a(5,3,i,j) = - dt * tz2 > * ( - c2 * ( u(3,i,j,k-1)*u(4,i,j,k-1) ) * tmp2 ) > - dt * tz1 * ( c34 - c1345 ) * tmp2 * u(3,i,j,k-1) a(5,4,i,j) = - dt * tz2 > * ( c1 * ( u(5,i,j,k-1) * tmp1 ) > - c2 > * ( qs(i,j,k-1) * tmp1 > + u(4,i,j,k-1)*u(4,i,j,k-1) * tmp2 ) ) > - dt * tz1 * ( r43*c34 - c1345 ) * tmp2 * u(4,i,j,k-1) a(5,5,i,j) = - dt * tz2 > * ( c1 * ( u(4,i,j,k-1) * tmp1 ) ) > - dt * tz1 * c1345 * tmp1 > - dt * tz1 * dz5 c--------------------------------------------------------------------- c form the second block sub-diagonal c--------------------------------------------------------------------- tmp1 = rho_i(i,j-1,k) tmp2 = tmp1 * tmp1 tmp3 = tmp1 * tmp2 b(1,1,i,j) = - dt * ty1 * dy1 b(1,2,i,j) = 0.0d+00 b(1,3,i,j) = - dt * ty2 b(1,4,i,j) = 0.0d+00 b(1,5,i,j) = 0.0d+00 b(2,1,i,j) = - dt * ty2 > * ( - ( u(2,i,j-1,k)*u(3,i,j-1,k) ) * tmp2 ) > - dt * ty1 * ( - c34 * tmp2 * u(2,i,j-1,k) ) b(2,2,i,j) = - dt * ty2 * ( u(3,i,j-1,k) * tmp1 ) > - dt * ty1 * ( c34 * tmp1 ) > - dt * ty1 * dy2 b(2,3,i,j) = - dt * ty2 * ( u(2,i,j-1,k) * tmp1 ) b(2,4,i,j) = 0.0d+00 b(2,5,i,j) = 0.0d+00 b(3,1,i,j) = - dt * ty2 > * ( - ( u(3,i,j-1,k) * tmp1 ) ** 2 > + c2 * ( qs(i,j-1,k) * tmp1 ) ) > - dt * ty1 * ( - r43 * c34 * tmp2 * u(3,i,j-1,k) ) b(3,2,i,j) = - dt * ty2 > * ( - c2 * ( u(2,i,j-1,k) * tmp1 ) ) b(3,3,i,j) = - dt * ty2 * ( ( 2.0d+00 - c2 ) > * ( u(3,i,j-1,k) * tmp1 ) ) > - dt * ty1 * ( r43 * c34 * tmp1 ) > - dt * ty1 * dy3 b(3,4,i,j) = - dt * ty2 > * ( - c2 * ( u(4,i,j-1,k) * tmp1 ) ) b(3,5,i,j) = - dt * ty2 * c2 b(4,1,i,j) = - dt * ty2 > * ( - ( u(3,i,j-1,k)*u(4,i,j-1,k) ) * tmp2 ) > - dt * ty1 * ( - c34 * tmp2 * u(4,i,j-1,k) ) b(4,2,i,j) = 0.0d+00 b(4,3,i,j) = - dt * ty2 * ( u(4,i,j-1,k) * tmp1 ) b(4,4,i,j) = - dt * ty2 * ( u(3,i,j-1,k) * tmp1 ) > - dt * ty1 * ( c34 * tmp1 ) > - dt * ty1 * dy4 b(4,5,i,j) = 0.0d+00 b(5,1,i,j) = - dt * ty2 > * ( ( c2 * 2.0d0 * qs(i,j-1,k) > - c1 * u(5,i,j-1,k) ) > * ( u(3,i,j-1,k) * tmp2 ) ) > - dt * ty1 > * ( - ( c34 - c1345 )*tmp3*(u(2,i,j-1,k)**2) > - ( r43*c34 - c1345 )*tmp3*(u(3,i,j-1,k)**2) > - ( c34 - c1345 )*tmp3*(u(4,i,j-1,k)**2) > - c1345*tmp2*u(5,i,j-1,k) ) b(5,2,i,j) = - dt * ty2 > * ( - c2 * ( u(2,i,j-1,k)*u(3,i,j-1,k) ) * tmp2 ) > - dt * ty1 > * ( c34 - c1345 ) * tmp2 * u(2,i,j-1,k) b(5,3,i,j) = - dt * ty2 > * ( c1 * ( u(5,i,j-1,k) * tmp1 ) > - c2 > * ( qs(i,j-1,k) * tmp1 > + u(3,i,j-1,k)*u(3,i,j-1,k) * tmp2 ) ) > - dt * ty1 > * ( r43*c34 - c1345 ) * tmp2 * u(3,i,j-1,k) b(5,4,i,j) = - dt * ty2 > * ( - c2 * ( u(3,i,j-1,k)*u(4,i,j-1,k) ) * tmp2 ) > - dt * ty1 * ( c34 - c1345 ) * tmp2 * u(4,i,j-1,k) b(5,5,i,j) = - dt * ty2 > * ( c1 * ( u(3,i,j-1,k) * tmp1 ) ) > - dt * ty1 * c1345 * tmp1 > - dt * ty1 * dy5 c--------------------------------------------------------------------- c form the third block sub-diagonal c--------------------------------------------------------------------- tmp1 = rho_i(i-1,j,k) tmp2 = tmp1 * tmp1 tmp3 = tmp1 * tmp2 c(1,1,i,j) = - dt * tx1 * dx1 c(1,2,i,j) = - dt * tx2 c(1,3,i,j) = 0.0d+00 c(1,4,i,j) = 0.0d+00 c(1,5,i,j) = 0.0d+00 c(2,1,i,j) = - dt * tx2 > * ( - ( u(2,i-1,j,k) * tmp1 ) ** 2 > + c2 * qs(i-1,j,k) * tmp1 ) > - dt * tx1 * ( - r43 * c34 * tmp2 * u(2,i-1,j,k) ) c(2,2,i,j) = - dt * tx2 > * ( ( 2.0d+00 - c2 ) * ( u(2,i-1,j,k) * tmp1 ) ) > - dt * tx1 * ( r43 * c34 * tmp1 ) > - dt * tx1 * dx2 c(2,3,i,j) = - dt * tx2 > * ( - c2 * ( u(3,i-1,j,k) * tmp1 ) ) c(2,4,i,j) = - dt * tx2 > * ( - c2 * ( u(4,i-1,j,k) * tmp1 ) ) c(2,5,i,j) = - dt * tx2 * c2 c(3,1,i,j) = - dt * tx2 > * ( - ( u(2,i-1,j,k) * u(3,i-1,j,k) ) * tmp2 ) > - dt * tx1 * ( - c34 * tmp2 * u(3,i-1,j,k) ) c(3,2,i,j) = - dt * tx2 * ( u(3,i-1,j,k) * tmp1 ) c(3,3,i,j) = - dt * tx2 * ( u(2,i-1,j,k) * tmp1 ) > - dt * tx1 * ( c34 * tmp1 ) > - dt * tx1 * dx3 c(3,4,i,j) = 0.0d+00 c(3,5,i,j) = 0.0d+00 c(4,1,i,j) = - dt * tx2 > * ( - ( u(2,i-1,j,k)*u(4,i-1,j,k) ) * tmp2 ) > - dt * tx1 * ( - c34 * tmp2 * u(4,i-1,j,k) ) c(4,2,i,j) = - dt * tx2 * ( u(4,i-1,j,k) * tmp1 ) c(4,3,i,j) = 0.0d+00 c(4,4,i,j) = - dt * tx2 * ( u(2,i-1,j,k) * tmp1 ) > - dt * tx1 * ( c34 * tmp1 ) > - dt * tx1 * dx4 c(4,5,i,j) = 0.0d+00 c(5,1,i,j) = - dt * tx2 > * ( ( c2 * 2.0d0 * qs(i-1,j,k) > - c1 * u(5,i-1,j,k) ) > * u(2,i-1,j,k) * tmp2 ) > - dt * tx1 > * ( - ( r43*c34 - c1345 ) * tmp3 * ( u(2,i-1,j,k)**2 ) > - ( c34 - c1345 ) * tmp3 * ( u(3,i-1,j,k)**2 ) > - ( c34 - c1345 ) * tmp3 * ( u(4,i-1,j,k)**2 ) > - c1345 * tmp2 * u(5,i-1,j,k) ) c(5,2,i,j) = - dt * tx2 > * ( c1 * ( u(5,i-1,j,k) * tmp1 ) > - c2 > * ( u(2,i-1,j,k)*u(2,i-1,j,k) * tmp2 > + qs(i-1,j,k) * tmp1 ) ) > - dt * tx1 > * ( r43*c34 - c1345 ) * tmp2 * u(2,i-1,j,k) c(5,3,i,j) = - dt * tx2 > * ( - c2 * ( u(3,i-1,j,k)*u(2,i-1,j,k) ) * tmp2 ) > - dt * tx1 > * ( c34 - c1345 ) * tmp2 * u(3,i-1,j,k) c(5,4,i,j) = - dt * tx2 > * ( - c2 * ( u(4,i-1,j,k)*u(2,i-1,j,k) ) * tmp2 ) > - dt * tx1 > * ( c34 - c1345 ) * tmp2 * u(4,i-1,j,k) c(5,5,i,j) = - dt * tx2 > * ( c1 * ( u(2,i-1,j,k) * tmp1 ) ) > - dt * tx1 * c1345 * tmp1 > - dt * tx1 * dx5 end do end do !$omp end do nowait return end
bsd-3-clause
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/cgtcon.f
25
6909
*> \brief \b CGTCON * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download CGTCON + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgtcon.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgtcon.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgtcon.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE CGTCON( NORM, N, DL, D, DU, DU2, IPIV, ANORM, RCOND, * WORK, INFO ) * * .. Scalar Arguments .. * CHARACTER NORM * INTEGER INFO, N * REAL ANORM, RCOND * .. * .. Array Arguments .. * INTEGER IPIV( * ) * COMPLEX D( * ), DL( * ), DU( * ), DU2( * ), WORK( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> CGTCON estimates the reciprocal of the condition number of a complex *> tridiagonal matrix A using the LU factorization as computed by *> CGTTRF. *> *> An estimate is obtained for norm(inv(A)), and the reciprocal of the *> condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). *> \endverbatim * * Arguments: * ========== * *> \param[in] NORM *> \verbatim *> NORM is CHARACTER*1 *> Specifies whether the 1-norm condition number or the *> infinity-norm condition number is required: *> = '1' or 'O': 1-norm; *> = 'I': Infinity-norm. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the matrix A. N >= 0. *> \endverbatim *> *> \param[in] DL *> \verbatim *> DL is COMPLEX array, dimension (N-1) *> The (n-1) multipliers that define the matrix L from the *> LU factorization of A as computed by CGTTRF. *> \endverbatim *> *> \param[in] D *> \verbatim *> D is COMPLEX array, dimension (N) *> The n diagonal elements of the upper triangular matrix U from *> the LU factorization of A. *> \endverbatim *> *> \param[in] DU *> \verbatim *> DU is COMPLEX array, dimension (N-1) *> The (n-1) elements of the first superdiagonal of U. *> \endverbatim *> *> \param[in] DU2 *> \verbatim *> DU2 is COMPLEX array, dimension (N-2) *> The (n-2) elements of the second superdiagonal of U. *> \endverbatim *> *> \param[in] IPIV *> \verbatim *> IPIV is 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. *> \endverbatim *> *> \param[in] ANORM *> \verbatim *> ANORM is REAL *> If NORM = '1' or 'O', the 1-norm of the original matrix A. *> If NORM = 'I', the infinity-norm of the original matrix A. *> \endverbatim *> *> \param[out] RCOND *> \verbatim *> RCOND is REAL *> The reciprocal of the condition number of the matrix A, *> computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an *> estimate of the 1-norm of inv(A) computed in this routine. *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is COMPLEX array, dimension (2*N) *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup complexGTcomputational * * ===================================================================== SUBROUTINE CGTCON( NORM, N, DL, D, DU, DU2, IPIV, ANORM, RCOND, $ WORK, INFO ) * * -- LAPACK computational routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. CHARACTER NORM INTEGER INFO, N REAL ANORM, RCOND * .. * .. Array Arguments .. INTEGER IPIV( * ) COMPLEX D( * ), DL( * ), DU( * ), DU2( * ), WORK( * ) * .. * * ===================================================================== * * .. Parameters .. REAL ONE, ZERO PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) * .. * .. Local Scalars .. LOGICAL ONENRM INTEGER I, KASE, KASE1 REAL AINVNM * .. * .. Local Arrays .. INTEGER ISAVE( 3 ) * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL CGTTRS, CLACN2, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC CMPLX * .. * .. Executable Statements .. * * Test the input arguments. * INFO = 0 ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' ) IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( ANORM.LT.ZERO ) THEN INFO = -8 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'CGTCON', -INFO ) RETURN END IF * * Quick return if possible * RCOND = ZERO IF( N.EQ.0 ) THEN RCOND = ONE RETURN ELSE IF( ANORM.EQ.ZERO ) THEN RETURN END IF * * Check that D(1:N) is non-zero. * DO 10 I = 1, N IF( D( I ).EQ.CMPLX( ZERO ) ) $ RETURN 10 CONTINUE * AINVNM = ZERO IF( ONENRM ) THEN KASE1 = 1 ELSE KASE1 = 2 END IF KASE = 0 20 CONTINUE CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE ) IF( KASE.NE.0 ) THEN IF( KASE.EQ.KASE1 ) THEN * * Multiply by inv(U)*inv(L). * CALL CGTTRS( 'No transpose', N, 1, DL, D, DU, DU2, IPIV, $ WORK, N, INFO ) ELSE * * Multiply by inv(L**H)*inv(U**H). * CALL CGTTRS( 'Conjugate transpose', N, 1, DL, D, DU, DU2, $ IPIV, WORK, N, INFO ) END IF GO TO 20 END IF * * Compute the estimate of the reciprocal condition number. * IF( AINVNM.NE.ZERO ) $ RCOND = ( ONE / AINVNM ) / ANORM * RETURN * * End of CGTCON * END
bsd-3-clause
nvarini/espresso_iohpc
Modules/hdf5_qe.f90
1
33394
module hdf5_qe USE HDF5 USE Kinds, ONLY : DP TYPE HDF5_type INTEGER(HID_T) :: file_id ! File identifier INTEGER(HID_T) :: dset_id ! Dataset identifier INTEGER(HID_T) :: filespace ! Dataspace identifier in file INTEGER(HID_T) :: memspace ! Dataspace identifier in memory INTEGER(HID_T) :: plist_id ! Property list identifier INTEGER(HID_T) :: group_id ! Group identifier CHARACTER(LEN=40) :: dsetname ! Dataset name INTEGER :: rank INTEGER(HSIZE_T), DIMENSION(2) :: counts, counts_g, offset INTEGER(HSIZE_T), DIMENSION(1:2) :: size INTEGER(HID_T) :: crp_list ! Dataset creation property identifier INTEGER :: comm INTEGER(HSIZE_T), DIMENSION(1:2) :: maxdims INTEGER(HSIZE_T), DIMENSION(1:2) :: chunk_dim character(len=256) filename END TYPE HDF5_type TYPE(HDF5_type), save :: evc_hdf5, evc_hdf5_write, evq_hdf5_write TYPE(HDF5_type), save :: rho_hdf5_write, eig_hdf5_write TYPE(HDF5_type), save :: g_hdf5_write, gk_hdf5_write INTEGER, save :: off_npw, npw_g, idone_debug INTERFACE add_attributes_hdf5 MODULE PROCEDURE add_attributes_hdf5_i, add_attributes_hdf5_r, & add_attributes_hdf5_c END INTERFACE INTERFACE read_attributes_hdf5 MODULE PROCEDURE read_attributes_hdf5_i, read_attributes_hdf5_r END INTERFACE contains subroutine initialize_hdf5() implicit none integer :: error call h5open_f(error) end subroutine initialize_hdf5 subroutine finalize_hdf5(hdf5desc) implicit none type(HDF5_type), intent(in) :: hdf5desc integer :: error call h5pclose_f(hdf5desc%plist_id,error) call h5close_f(error) end subroutine finalize_hdf5 subroutine setup_file_property_hdf5(hdf5desc ,filename, hyperslab, write, kpoint) use parallel_include use mp_world, only : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc character(len=*), intent(inout) :: filename logical, intent(in) :: hyperslab, write integer, intent(in) :: kpoint integer(HID_T) :: plist_id integer :: error, info character*12 kstring write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring info = MPI_INFO_NULL if(hyperslab .eqv. .true. ) then CALL h5pcreate_f(H5P_FILE_ACCESS_F, hdf5desc%plist_id, error) ! Properties for file creation CALL h5pset_fapl_mpio_f(hdf5desc%plist_id, hdf5desc%comm, info, error) ! Stores MPI IO communicator information to the file access property list if(kpoint.eq.1)then CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, hdf5desc%file_id, error, access_prp = hdf5desc%plist_id) ! create the file collectively else CALL h5fopen_f(filename, H5F_ACC_RDWR_F, hdf5desc%file_id, error, access_prp = hdf5desc%plist_id) ! create the file collectively endif CALL h5pclose_f(hdf5desc%plist_id, error) else if(write .eqv. .true.)then if(kpoint.eq.1)then !CALL h5pcreate_f(H5P_FILE_ACCESS_F, hdf5desc%plist_id, error) !CALL h5pset_fapl_mpio_f(hdf5desc%plist_id, hdf5desc%comm, info, error) !CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, hdf5desc%file_id, error, access_prp=hdf5desc%plist_id) ! create the file collectively CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, hdf5desc%file_id, error) endif else CALL h5fopen_f(filename, H5F_ACC_RDONLY_F, hdf5desc%file_id, error) ! create the file collectively !CALL h5dopen_f(hdf5desc%file_id, hdf5desc%dsetname, hdf5desc%dset_id, error) endif endif end subroutine setup_file_property_hdf5 subroutine define_dataset_hdf5_hyperslab(hdf5desc, kpoint) USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc integer,intent(in) :: kpoint integer :: error character*12 :: kstring write(kstring,'(I0)') kpoint kstring=trim('KPOINT')//kstring hdf5desc%dsetname = 'evc' CALL h5gcreate_f(hdf5desc%file_id, kstring, hdf5desc%group_id, error) CALL h5screate_simple_f(hdf5desc%rank, hdf5desc%counts_g, hdf5desc%filespace, error) !define HDF5 dataset CALL h5dcreate_f(hdf5desc%group_id, hdf5desc%dsetname, H5T_NATIVE_DOUBLE, hdf5desc%filespace, & hdf5desc%dset_id, error) CALL h5sclose_f(hdf5desc%filespace, error) CALL h5dclose_f(hdf5desc%dset_id, error) CALL h5gclose_f(hdf5desc%group_id, error) end subroutine define_dataset_hdf5_hyperslab subroutine write_data_hdf5(hdf5desc, data, kpoint) USE kinds, ONLY : DP USE ISO_C_BINDING USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc complex(kind=dp), target, intent(inout) :: data(:,:) integer, intent(in) :: kpoint integer :: error, datadim1, datadim2 real(kind=dp) :: tmp integer(HID_T) :: complex_id, double_id integer(HSIZE_T) :: double_size, complex_size TYPE(C_PTR) :: f_ptr character*12 :: kstring write(kstring,'(I0)') kpoint kstring=trim('KPOINT')//kstring CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5dopen_f(hdf5desc%group_id, hdf5desc%dsetname, hdf5desc%dset_id, error) CALL h5screate_simple_f(hdf5desc%rank, hdf5desc%counts, hdf5desc%memspace, error) CALL h5dget_space_f(hdf5desc%dset_id, hdf5desc%filespace, error) CALL h5sselect_hyperslab_f(hdf5desc%filespace, H5S_SELECT_SET_F, hdf5desc%offset, hdf5desc%counts, error) ! create hyperslab to read from more than 1 proc CALL h5pcreate_f(H5P_DATASET_XFER_F, hdf5desc%plist_id, error) CALL h5pset_dxpl_mpio_f(hdf5desc%plist_id, H5FD_MPIO_COLLECTIVE_F, error) f_ptr = C_LOC(data(1,1)) CALL h5dwrite_f(hdf5desc%dset_id, H5T_NATIVE_DOUBLE, f_ptr, error,& file_space_id = hdf5desc%filespace, mem_space_id = hdf5desc%memspace, & xfer_prp = hdf5desc%plist_id) CALL h5dclose_f(hdf5desc%dset_id, error) CALL h5gclose_f(hdf5desc%group_id, error) end subroutine write_data_hdf5 subroutine read_data_hdf5(hdf5desc, data, kpoint) type(HDF5_type), intent(inout) :: hdf5desc complex(kind=dp),target, intent(inout) :: data(:,:) integer,intent(in) :: kpoint integer :: error TYPE(C_PTR) :: f_ptr character*12 :: kstring write(kstring,'(I0)') kpoint kstring=trim('KPOINT')//kstring CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5dopen_f(hdf5desc%group_id, hdf5desc%dsetname, hdf5desc%dset_id, error) CALL h5dget_space_f(hdf5desc%dset_id, hdf5desc%filespace, error) CALL h5sselect_hyperslab_f(hdf5desc%filespace, H5S_SELECT_SET_F, hdf5desc%offset, hdf5desc%counts, error) CALL h5screate_simple_f(hdf5desc%rank, hdf5desc%counts, hdf5desc%memspace, error) f_ptr = C_LOC(data(1,1)) CALL H5dread_f(hdf5desc%dset_id, H5T_NATIVE_DOUBLE, f_ptr, error, & mem_space_id = hdf5desc%memspace, file_space_id = hdf5desc%filespace ,& xfer_prp = hdf5desc%plist_id) CALL h5dclose_f(hdf5desc%dset_id, error) CALL h5gclose_f(hdf5desc%group_id, error) end subroutine read_data_hdf5 SUBROUTINE prepare_index_hdf5(sendm,recm,globalm,comm,nproc) USE parallel_include USE mp, ONLY : mp_sum IMPLICIT NONE INTEGER, INTENT(IN) :: comm, nproc INTEGER, INTENT(INOUT) :: sendm, recm, globalm INTEGER :: errore call mpi_scan(sendm,recm,1,MPI_INTEGER,MPI_SUM,comm,errore) recm=recm-sendm globalm=sendm call mp_sum(globalm,comm) END SUBROUTINE prepare_index_hdf5 subroutine prepare_for_writing_final(hdf5desc,comm,filename_input,kpoint) USE mp_world, ONLY : mpime USE io_files, ONLY : wfc_dir, prefix, tmp_dir implicit none type(HDF5_type), intent(inout) :: hdf5desc character(len=*), intent(in):: filename_input integer, intent(in) :: comm integer, intent(in), optional :: kpoint character(len=256) filename character*4 mpimestring integer :: ik, error character*12 kstring hdf5desc%comm=comm hdf5desc%filename=filename_input if(present(kpoint)) then write(kstring,'(I0)') kpoint kstring=trim('KPOINT')//kstring CALL setup_file_property_hdf5(hdf5desc,hdf5desc%filename ,.false.,.true.,kpoint) if(kpoint>1) CALL h5fopen_f(hdf5desc%filename, H5F_ACC_RDWR_F, hdf5desc%file_id, error) ! create the file collectively CALL h5gcreate_f(hdf5desc%file_id, kstring, hdf5desc%group_id, error) CALL h5gclose_f(hdf5desc%group_id, error) else CALL setup_file_property_hdf5(hdf5desc,hdf5desc%filename ,.false.,.true.,1) endif end subroutine prepare_for_writing_final subroutine prepare_for_reading_final(hdf5desc,comm,filename_input,kpoint) USE mp_world, ONLY : mpime USE io_files, ONLY : wfc_dir, prefix, tmp_dir implicit none type(HDF5_type), intent(inout) :: hdf5desc character(len=*), intent(in):: filename_input integer, intent(in) :: comm integer, intent(in), optional :: kpoint character(len=256) filename character*4 mpimestring integer :: ik hdf5desc%comm=comm hdf5desc%rank =1 !filename = trim(filename_input) //".wfchdf5" filename=filename_input if(present(kpoint))then CALL setup_file_property_hdf5(hdf5desc,filename ,.false.,.false.,kpoint) else CALL setup_file_property_hdf5(hdf5desc,filename ,.false.,.false.,1) end if end subroutine prepare_for_reading_final subroutine read_rho(hdf5desc,dsetname,var) USE kinds, ONLY : DP USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc integer, intent(in) :: dsetname real(kind=DP), target, intent(in) :: var(:) INTEGER(HID_T) :: dspace_id, dset_id, dtype_id ! Dataspace identifier integer :: error INTEGER(HSIZE_T), DIMENSION(1) :: counts character*12 dset_name TYPE(C_PTR) :: f_ptr write(dset_name,'(I0)') dsetname dset_name='K'//dset_name counts=size(var) CALL h5dopen_f(hdf5desc%file_id, dset_name, dset_id, error) CALL h5dget_type_f(dset_id, dtype_id, error) f_ptr = C_LOC(var(1)) CALL h5dread_f(dset_id, dtype_id, f_ptr, error) CALL h5dclose_f(dset_id, error) end subroutine read_rho subroutine write_rho(hdf5desc,dsetname,var) USE kinds, ONLY : DP USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc integer, intent(in) :: dsetname real(kind=DP), target, intent(in) :: var(:) INTEGER(HID_T) :: dspace_id, dset_id ! Dataspace identifier integer :: error INTEGER(HSIZE_T), DIMENSION(1) :: counts character*12 dset_name TYPE(C_PTR) :: f_ptr write(dset_name,'(I0)') dsetname dset_name='K'//dset_name counts=size(var) CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5dcreate_f(hdf5desc%file_id, dset_name, H5T_NATIVE_DOUBLE, dspace_id, & dset_id, error) f_ptr = C_LOC(var(1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) end subroutine write_rho subroutine write_eig(hdf5desc,var,kpoint) USE kinds, ONLY : DP USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc integer, intent(in) :: kpoint real(kind=DP), target, intent(in) :: var(:) INTEGER(HID_T) :: dspace_id, dset_id ! Dataspace identifier integer :: error INTEGER(HSIZE_T), DIMENSION(1) :: counts TYPE(C_PTR) :: f_ptr character*12 kstring write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring counts=size(var) CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5dcreate_f(hdf5desc%group_id, kstring, H5T_NATIVE_DOUBLE, dspace_id, & dset_id, error) f_ptr = C_LOC(var(1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) CALL h5gclose_f(hdf5desc%group_id, error) end subroutine write_eig subroutine read_eig(hdf5desc,var,kpoint) USE kinds, ONLY : DP USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc integer, intent(in) :: kpoint real(kind=DP), target, intent(inout) :: var(:) INTEGER(HID_T) :: dtype_id, dset_id ! Dataspace identifier integer :: error INTEGER(HSIZE_T), DIMENSION(1) :: counts TYPE(C_PTR) :: f_ptr character*12 kstring character*100 errmsg write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring counts=size(var) CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5dopen_f(hdf5desc%group_id, kstring, dset_id, error) CALL h5dget_type_f(dset_id, dtype_id, error) f_ptr = C_LOC(var(1)) !CALL h5dread_f(dset_id, H5T_NATIVE_DOUBLE, f_ptr, error) CALL h5dread_f(dset_id, dtype_id, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5gclose_f(hdf5desc%group_id, error) end subroutine read_eig subroutine write_evc(hdf5desc,dsetname,var,kpoint) USE kinds, ONLY : DP USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc integer, intent(in) :: dsetname integer, intent(in), optional :: kpoint complex(kind=DP), target, intent(in) :: var(:) INTEGER(HID_T) :: dspace_id, dset_id ! Dataspace identifier integer :: error INTEGER(HSIZE_T), DIMENSION(1) :: counts character*12 dset_name TYPE(C_PTR) :: f_ptr character*12 kstring write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring write(dset_name,'(I0)') dsetname dset_name='BAND'//dset_name counts=size(var)*2 CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace if(present(kpoint))CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) if(present(kpoint)) then CALL h5dcreate_f(hdf5desc%group_id, dset_name, H5T_NATIVE_DOUBLE, dspace_id, & dset_id, error) else CALL h5dcreate_f(hdf5desc%file_id, dset_name, H5T_NATIVE_DOUBLE, dspace_id, & dset_id, error) endif f_ptr = C_LOC(var(1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) if(present(kpoint))CALL h5gclose_f(hdf5desc%group_id, error) end subroutine write_evc subroutine read_evc(hdf5desc,dsetname,var,kpoint) USE kinds, ONLY : DP USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc integer, intent(in) :: dsetname, kpoint complex(kind=DP), target ,intent(inout) :: var(:) INTEGER(HID_T) :: dtype_id, dset_id ! Dataspace identifier integer :: error INTEGER(HSIZE_T), DIMENSION(1) :: counts character*12 dset_name TYPE(C_PTR) :: f_ptr character*12 kstring character*100 errmsg write(dset_name,'(I0)') dsetname write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring dset_name='BAND'//dset_name counts=size(var)*2 CALL h5gopen_f(hdf5desc%file_id, kstring, hdf5desc%group_id, error) !if(error.ne.0) call errore('error in h5gopen_f','',error) CALL h5dopen_f(hdf5desc%group_id, dset_name, dset_id, error) !if(error.ne.0) call errore('error in h5dopen_f','',error) !CALL h5dget_type_f(dset_id, dtype_id, error) f_ptr = C_LOC(var(1)) CALL h5dread_f(dset_id, H5T_NATIVE_DOUBLE, f_ptr, error) if(error.ne.0) call errore('error in h5dread_f','',error) !CALL h5dread_f(dset_id, dtype_id, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5gclose_f(hdf5desc%group_id, error) end subroutine read_evc subroutine write_g(hdf5desc,var,kpoint) USE kinds, ONLY : DP USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc integer, intent(in), optional :: kpoint integer, target, intent(in) :: var(:,:) INTEGER(HID_T) :: dspace_id, dset_id ! Dataspace identifier integer :: error INTEGER(HSIZE_T), DIMENSION(1) :: counts TYPE(C_PTR) :: f_ptr character*12 kstring if(present(kpoint))then write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring counts=size(var) CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5dcreate_f(hdf5desc%group_id, kstring, H5T_NATIVE_INTEGER, dspace_id, & dset_id, error) f_ptr = C_LOC(var(1,1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) CALL h5gclose_f(hdf5desc%group_id, error) else CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5dcreate_f(hdf5desc%file_id, 'gvec', H5T_NATIVE_INTEGER, dspace_id, & dset_id, error) f_ptr = C_LOC(var(1,1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) endif end subroutine write_g subroutine write_gkhdf5(hdf5desc,xk,igwk,mill_g,kpoint) USE kinds, ONLY : DP USE mp_world, ONLY : mpime implicit none type(HDF5_type), intent(inout) :: hdf5desc integer, intent(in), optional :: kpoint real(kind=DP), target, intent(in) :: xk(:) integer, target, intent(in) :: igwk(:), mill_g(:,:) INTEGER(HID_T) :: dspace_id, dset_id ! Dataspace identifier integer :: error INTEGER(HSIZE_T), DIMENSION(1) :: counts TYPE(C_PTR) :: f_ptr character*12 kstring if(present(kpoint))then write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) write(kstring,'(I0)') kpoint kstring='xk'//kstring counts=size(xk) CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5dcreate_f(hdf5desc%group_id, kstring, H5T_NATIVE_DOUBLE, dspace_id, & dset_id, error) f_ptr = C_LOC(xk(1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) write(kstring,'(I0)') kpoint kstring='igwk'//kstring counts=size(igwk) CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5dcreate_f(hdf5desc%group_id, kstring, H5T_NATIVE_INTEGER, dspace_id, & dset_id, error) f_ptr = C_LOC(igwk(1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) write(kstring,'(I0)') kpoint kstring='mill_g'//kstring counts=size(mill_g) CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5dcreate_f(hdf5desc%group_id, kstring, H5T_NATIVE_INTEGER, dspace_id, & dset_id, error) f_ptr = C_LOC(mill_g(1,1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) CALL h5gclose_f(hdf5desc%group_id, error) else counts=size(xk) CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5dcreate_f(hdf5desc%file_id, 'xk', H5T_NATIVE_DOUBLE, dspace_id, & dset_id, error) f_ptr = C_LOC(xk(1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) counts=size(igwk) CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5dcreate_f(hdf5desc%file_id, 'igwk', H5T_NATIVE_INTEGER, dspace_id, & dset_id, error) f_ptr = C_LOC(igwk(1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) counts=size(mill_g) CALL h5screate_simple_f(1, counts, dspace_id, error) !create the dataspace CALL h5dcreate_f(hdf5desc%group_id, 'mill_g', H5T_NATIVE_INTEGER, dspace_id, & dset_id, error) f_ptr = C_LOC(mill_g(1,1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, f_ptr, error) CALL h5dclose_f(dset_id, error) CALL h5sclose_f(dspace_id, error) endif end subroutine write_gkhdf5 subroutine initialize_io_hdf5(hdf5desc,comm, data, write,kpoint) USE io_files, ONLY : wfc_dir, prefix, tmp_dir USE mp_world, ONLY : mpime USE kinds, ONLY : dp USE mp_world, ONLY : nproc implicit none TYPE(HDF5_type), intent(inout) :: hdf5desc complex(kind=dp), intent(in) :: data(:,:) integer, intent(in) :: comm, kpoint logical, intent(in) :: write character(len=80) :: filename character*4 mpimestring integer :: npwx, nbnd !write(mpimestring,'(I0)') mpime npwx=size(data(:,1)) nbnd=size(data(1,:)) filename=trim(tmp_dir) //TRIM(prefix) //".wfchdf5" call initialize_hdf5_array(hdf5desc,comm,npwx,nbnd) if(write .eqv. .true.)then CALL setup_file_property_hdf5(hdf5desc, filename,.true.,.true.,kpoint) else CALL setup_file_property_hdf5(hdf5desc, filename,.false.,.false.,kpoint) endif CALL prepare_index_hdf5(npwx,off_npw,npw_g,hdf5desc%comm,nproc) CALL set_index_hdf5(hdf5desc,data,off_npw,npw_g,2) end subroutine initialize_io_hdf5 subroutine initialize_hdf5_array(hdf5desc,comm,n1,n2) use mp_world, only : mpime implicit none integer, intent(in) :: n1, n2, comm type(HDF5_type), intent(inout) :: hdf5desc hdf5desc%dsetname="evc" hdf5desc%comm=comm hdf5desc%rank =2 hdf5desc%chunk_dim=(/n1,n2/) hdf5desc%size(1) = n1*2 hdf5desc%size(2) = n2 hdf5desc%offset(1) = 0 hdf5desc%offset(2) = 0 end subroutine initialize_hdf5_array SUBROUTINE set_index_hdf5(hdf5desc, var, offset, nglobal,tsize) USE kinds, only : DP implicit none COMPLEX(DP), intent(in) :: var(:,:) type(HDF5_type), intent(inout) :: hdf5desc INTEGER, intent(in) :: offset, nglobal,tsize hdf5desc%counts(1) = size(var(:,1))*tsize hdf5desc%counts(2) = size(var(1,:)) hdf5desc%counts_g(1) = nglobal*tsize hdf5desc%counts_g(2) = size(var(1,:)) hdf5desc%offset(1) = offset*tsize hdf5desc%offset(2) = 0 END SUBROUTINE set_index_hdf5 SUBROUTINE add_attributes_hdf5_i(hdf5desc, attr_data, attr_name, kpoint) implicit none TYPE(HDF5_type), intent(inout) :: hdf5desc integer, intent(in) :: attr_data integer, intent(in),optional :: kpoint CHARACTER(LEN=*), intent(in) :: attr_name character*12 kstring integer :: error INTEGER :: arank = 1 ! Attribure rank INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/1/) ! Attribute dimension INTEGER(SIZE_T) :: attrlen ! Length of the attribute string INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier INTEGER(HID_T) :: attr_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: data_dims data_dims(1) = 1 if(present(kpoint)) then write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5screate_simple_f(arank, adims, aspace_id, error) CALL h5acreate_f(hdf5desc%group_id, attr_name, H5T_NATIVE_INTEGER, aspace_id, attr_id, error) CALL h5awrite_f(attr_id, H5T_NATIVE_INTEGER, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) ! ! Terminate access to the data space. ! CALL h5sclose_f(aspace_id, error) ! ! End access to the dataset and release resources used by it. ! CALL h5gclose_f(hdf5desc%group_id, error) else CALL h5screate_simple_f(arank, adims, aspace_id, error) CALL h5acreate_f(hdf5desc%file_id, attr_name, H5T_NATIVE_INTEGER, aspace_id, attr_id, error) CALL h5awrite_f(attr_id, H5T_NATIVE_INTEGER, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) ! ! Terminate access to the data space. ! CALL h5sclose_f(aspace_id, error) endif END SUBROUTINE add_attributes_hdf5_i SUBROUTINE add_attributes_hdf5_r(hdf5desc, attr_data, attr_name, kpoint) implicit none TYPE(HDF5_type), intent(inout) :: hdf5desc integer, intent(in), optional :: kpoint real(DP), intent(in) :: attr_data CHARACTER(LEN=*), intent(in) :: attr_name character*12 kstring integer :: error INTEGER :: arank = 1 ! Attribure rank INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/1/) ! Attribute dimension INTEGER(SIZE_T) :: attrlen ! Length of the attribute string INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier INTEGER(HID_T) :: attr_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: data_dims data_dims(1) = 1 if(present(kpoint)) then write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5screate_simple_f(arank, adims, aspace_id, error) CALL h5acreate_f(hdf5desc%group_id, attr_name, H5T_NATIVE_DOUBLE, aspace_id, attr_id, error) CALL h5awrite_f(attr_id, H5T_NATIVE_DOUBLE, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) ! ! Terminate access to the data space. ! CALL h5sclose_f(aspace_id, error) ! ! End access to the dataset and release resources used by it. ! CALL h5gclose_f(hdf5desc%group_id, error) else CALL h5screate_simple_f(arank, adims, aspace_id, error) CALL h5acreate_f(hdf5desc%file_id, attr_name, H5T_NATIVE_DOUBLE, aspace_id, attr_id, error) CALL h5awrite_f(attr_id, H5T_NATIVE_DOUBLE, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) ! ! Terminate access to the data space. ! CALL h5sclose_f(aspace_id, error) ! ! End access to the dataset and release resources used by it. ! endif END SUBROUTINE add_attributes_hdf5_r SUBROUTINE add_attributes_hdf5_c(hdf5desc, attr_data, attr_name, kpoint) USE mp_world, ONLY : mpime implicit none TYPE(HDF5_type), intent(inout) :: hdf5desc integer, intent(in), optional :: kpoint !LOGICAL, intent(in) :: attr_data CHARACTER(LEN=*), intent(in) :: attr_data CHARACTER(LEN=*), intent(in) :: attr_name character*100 kstring integer :: error INTEGER :: arank = 1 ! Attribure rank INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/1/) ! Attribute dimension INTEGER(SIZE_T) :: attrlen ! Length of the attribute string INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier INTEGER(HID_T) :: attr_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: data_dims !data_dims(1) = 1 data_dims(1) = len(attr_name) if(present(kpoint)) then write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring !write(attrdata,'(I0)') attr_data CALL h5tcopy_f(H5T_NATIVE_CHARACTER, atype_id, error) CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5screate_simple_f(arank, adims, aspace_id, error) CALL h5acreate_f(hdf5desc%group_id, attr_name, H5T_NATIVE_CHARACTER, aspace_id, attr_id, error) CALL h5awrite_f(attr_id, H5T_NATIVE_CHARACTER, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) ! ! Terminate access to the data space. ! CALL h5sclose_f(aspace_id, error) ! ! End access to the dataset and release resources used by it. ! CALL h5gclose_f(hdf5desc%group_id, error) else !write(attrdata,'(I0)') attr_data CALL h5tcopy_f(H5T_NATIVE_CHARACTER, atype_id, error) CALL h5screate_simple_f(arank, adims, aspace_id, error) CALL h5acreate_f(hdf5desc%file_id, attr_name, H5T_NATIVE_CHARACTER, aspace_id, attr_id, error) CALL h5awrite_f(attr_id, H5T_NATIVE_CHARACTER, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) ! ! Terminate access to the data space. ! CALL h5sclose_f(aspace_id, error) endif END SUBROUTINE add_attributes_hdf5_c SUBROUTINE read_attributes_hdf5_i(hdf5desc, attr_data, attr_name, kpoint, debug) USE mp_world, ONLY : mpime implicit none TYPE(HDF5_type), intent(inout) :: hdf5desc integer, intent(in), optional :: kpoint, debug integer, intent(out) :: attr_data CHARACTER(LEN=*), intent(in) :: attr_name character*12 kstring integer :: error INTEGER :: arank = 1 ! Attribure rank INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/1/) ! Attribute dimension INTEGER(SIZE_T) :: attrlen ! Length of the attribute string INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier INTEGER(HID_T) :: attr_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: data_dims data_dims(1) = 1 attrlen = 1 if(present(kpoint))then write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5aopen_name_f(hdf5desc%group_id,attr_name,attr_id,error) CALL h5aread_f(attr_id, H5T_NATIVE_INTEGER, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) CALL h5gclose_f(hdf5desc%group_id, error) else CALL h5aopen_name_f(hdf5desc%file_id,attr_name,attr_id,error) CALL h5aget_type_f(attr_id, atype_id, error) CALL h5aread_f(attr_id, atype_id, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) endif END SUBROUTINE read_attributes_hdf5_i SUBROUTINE read_attributes_hdf5_r(hdf5desc, attr_data, attr_name, kpoint) USE mp_world, ONLY : mpime implicit none TYPE(HDF5_type), intent(inout) :: hdf5desc integer, intent(in), optional :: kpoint real(DP), intent(out) :: attr_data CHARACTER(LEN=*), intent(in) :: attr_name character*12 kstring integer :: error INTEGER :: arank = 1 ! Attribure rank INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/1/) ! Attribute dimension INTEGER(SIZE_T) :: attrlen ! Length of the attribute string INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier INTEGER(HID_T) :: attr_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: data_dims data_dims(1) = 1 attrlen = 1 if(present(kpoint))then write(kstring,'(I0)') kpoint kstring='KPOINT'//kstring CALL h5gopen_f(hdf5desc%file_id,kstring,hdf5desc%group_id,error) CALL h5aopen_name_f(hdf5desc%group_id,attr_name,attr_id,error) CALL h5aread_f(attr_id, H5T_NATIVE_DOUBLE, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) CALL h5gclose_f(hdf5desc%group_id, error) else CALL h5aopen_name_f(hdf5desc%file_id,attr_name,attr_id,error) CALL h5aread_f(attr_id, H5T_NATIVE_DOUBLE, attr_data, data_dims, error) CALL h5aclose_f(attr_id, error) endif END SUBROUTINE read_attributes_hdf5_r SUBROUTINE hdf5_close(hdf5desc) implicit none TYPE(HDF5_type), intent(inout) :: hdf5desc integer :: errore CALL h5fclose_f(hdf5desc%file_id,errore) END SUBROUTINE hdf5_close SUBROUTINE write_attributes(hdf5desc, ngw, gamma_only, igwx, & nbnd, ik, nk, ispin, nspin, scalef) implicit none INTEGER, INTENT(IN) :: ik, nk, ispin, nspin REAL(DP), INTENT(IN) :: scalef LOGICAL, INTENT(IN) :: gamma_only INTEGER, INTENT(IN) :: nbnd, ngw, igwx TYPE(HDF5_type), intent(inout) :: hdf5desc integer :: gammaonly CALL add_attributes_hdf5(hdf5desc,ngw,"ngw",ik) write(gammaonly,'(I0)') gamma_only CALL add_attributes_hdf5(evc_hdf5_write,gammaonly,"gamma_only",ik) CALL add_attributes_hdf5(evc_hdf5_write,igwx,"igwx",ik) CALL add_attributes_hdf5(evc_hdf5_write,nbnd,"nbnd",ik) CALL add_attributes_hdf5(evc_hdf5_write,ik,"ik",ik) CALL add_attributes_hdf5(evc_hdf5_write,nk,"nk",ik) CALL add_attributes_hdf5(evc_hdf5_write,ispin,"ispin",ik) CALL add_attributes_hdf5(evc_hdf5_write,nspin,"nspin",ik) CALL add_attributes_hdf5(evc_hdf5_write,scalef,"scale_factor",ik) END SUBROUTINE write_attributes end module hdf5_qe
gpl-2.0
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/slasd8.f
19
10911
*> \brief \b SLASD8 finds the square roots of the roots of the secular equation, and stores, for each element in D, the distance to its two nearest poles. Used by sbdsdc. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download SLASD8 + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slasd8.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slasd8.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slasd8.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE SLASD8( ICOMPQ, K, D, Z, VF, VL, DIFL, DIFR, LDDIFR, * DSIGMA, WORK, INFO ) * * .. Scalar Arguments .. * INTEGER ICOMPQ, INFO, K, LDDIFR * .. * .. Array Arguments .. * REAL D( * ), DIFL( * ), DIFR( LDDIFR, * ), * $ DSIGMA( * ), VF( * ), VL( * ), WORK( * ), * $ Z( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> SLASD8 finds the square roots of the roots of the secular equation, *> as defined by the values in DSIGMA and Z. It makes the appropriate *> calls to SLASD4, and stores, for each element in D, the distance *> to its two nearest poles (elements in DSIGMA). It also updates *> the arrays VF and VL, the first and last components of all the *> right singular vectors of the original bidiagonal matrix. *> *> SLASD8 is called from SLASD6. *> \endverbatim * * Arguments: * ========== * *> \param[in] ICOMPQ *> \verbatim *> ICOMPQ is INTEGER *> Specifies whether singular vectors are to be computed in *> factored form in the calling routine: *> = 0: Compute singular values only. *> = 1: Compute singular vectors in factored form as well. *> \endverbatim *> *> \param[in] K *> \verbatim *> K is INTEGER *> The number of terms in the rational function to be solved *> by SLASD4. K >= 1. *> \endverbatim *> *> \param[out] D *> \verbatim *> D is REAL array, dimension ( K ) *> On output, D contains the updated singular values. *> \endverbatim *> *> \param[in,out] Z *> \verbatim *> Z is REAL array, dimension ( K ) *> On entry, the first K elements of this array contain the *> components of the deflation-adjusted updating row vector. *> On exit, Z is updated. *> \endverbatim *> *> \param[in,out] VF *> \verbatim *> VF is REAL array, dimension ( K ) *> On entry, VF contains information passed through DBEDE8. *> On exit, VF contains the first K components of the first *> components of all right singular vectors of the bidiagonal *> matrix. *> \endverbatim *> *> \param[in,out] VL *> \verbatim *> VL is REAL array, dimension ( K ) *> On entry, VL contains information passed through DBEDE8. *> On exit, VL contains the first K components of the last *> components of all right singular vectors of the bidiagonal *> matrix. *> \endverbatim *> *> \param[out] DIFL *> \verbatim *> DIFL is REAL array, dimension ( K ) *> On exit, DIFL(I) = D(I) - DSIGMA(I). *> \endverbatim *> *> \param[out] DIFR *> \verbatim *> DIFR is REAL array, *> dimension ( LDDIFR, 2 ) if ICOMPQ = 1 and *> dimension ( K ) if ICOMPQ = 0. *> On exit, DIFR(I,1) = D(I) - DSIGMA(I+1), DIFR(K,1) is not *> defined and will not be referenced. *> *> If ICOMPQ = 1, DIFR(1:K,2) is an array containing the *> normalizing factors for the right singular vector matrix. *> \endverbatim *> *> \param[in] LDDIFR *> \verbatim *> LDDIFR is INTEGER *> The leading dimension of DIFR, must be at least K. *> \endverbatim *> *> \param[in,out] DSIGMA *> \verbatim *> DSIGMA is REAL array, dimension ( K ) *> On entry, the first K elements of this array contain the old *> roots of the deflated updating problem. These are the poles *> of the secular equation. *> On exit, the elements of DSIGMA may be very slightly altered *> in value. *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is REAL array, dimension at least 3 * K *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit. *> < 0: if INFO = -i, the i-th argument had an illegal value. *> > 0: if INFO = 1, a singular value did not converge *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup auxOTHERauxiliary * *> \par Contributors: * ================== *> *> Ming Gu and Huan Ren, Computer Science Division, University of *> California at Berkeley, USA *> * ===================================================================== SUBROUTINE SLASD8( ICOMPQ, K, D, Z, VF, VL, DIFL, DIFR, LDDIFR, $ DSIGMA, WORK, INFO ) * * -- LAPACK auxiliary routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. INTEGER ICOMPQ, INFO, K, LDDIFR * .. * .. Array Arguments .. REAL D( * ), DIFL( * ), DIFR( LDDIFR, * ), $ DSIGMA( * ), VF( * ), VL( * ), WORK( * ), $ Z( * ) * .. * * ===================================================================== * * .. Parameters .. REAL ONE PARAMETER ( ONE = 1.0E+0 ) * .. * .. Local Scalars .. INTEGER I, IWK1, IWK2, IWK2I, IWK3, IWK3I, J REAL DIFLJ, DIFRJ, DJ, DSIGJ, DSIGJP, RHO, TEMP * .. * .. External Subroutines .. EXTERNAL SCOPY, SLASCL, SLASD4, SLASET, XERBLA * .. * .. External Functions .. REAL SDOT, SLAMC3, SNRM2 EXTERNAL SDOT, SLAMC3, SNRM2 * .. * .. Intrinsic Functions .. INTRINSIC ABS, SIGN, SQRT * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 * IF( ( ICOMPQ.LT.0 ) .OR. ( ICOMPQ.GT.1 ) ) THEN INFO = -1 ELSE IF( K.LT.1 ) THEN INFO = -2 ELSE IF( LDDIFR.LT.K ) THEN INFO = -9 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'SLASD8', -INFO ) RETURN END IF * * Quick return if possible * IF( K.EQ.1 ) THEN D( 1 ) = ABS( Z( 1 ) ) DIFL( 1 ) = D( 1 ) IF( ICOMPQ.EQ.1 ) THEN DIFL( 2 ) = ONE DIFR( 1, 2 ) = ONE END IF RETURN END IF * * Modify values DSIGMA(i) to make sure all DSIGMA(i)-DSIGMA(j) can * be computed with high relative accuracy (barring over/underflow). * This is a problem on machines without a guard digit in * add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). * The following code replaces DSIGMA(I) by 2*DSIGMA(I)-DSIGMA(I), * which on any of these machines zeros out the bottommost * bit of DSIGMA(I) if it is 1; this makes the subsequent * subtractions DSIGMA(I)-DSIGMA(J) unproblematic when cancellation * occurs. On binary machines with a guard digit (almost all * machines) it does not change DSIGMA(I) at all. On hexadecimal * and decimal machines with a guard digit, it slightly * changes the bottommost bits of DSIGMA(I). It does not account * for hexadecimal or decimal machines without guard digits * (we know of none). We use a subroutine call to compute * 2*DLAMBDA(I) to prevent optimizing compilers from eliminating * this code. * DO 10 I = 1, K DSIGMA( I ) = SLAMC3( DSIGMA( I ), DSIGMA( I ) ) - DSIGMA( I ) 10 CONTINUE * * Book keeping. * IWK1 = 1 IWK2 = IWK1 + K IWK3 = IWK2 + K IWK2I = IWK2 - 1 IWK3I = IWK3 - 1 * * Normalize Z. * RHO = SNRM2( K, Z, 1 ) CALL SLASCL( 'G', 0, 0, RHO, ONE, K, 1, Z, K, INFO ) RHO = RHO*RHO * * Initialize WORK(IWK3). * CALL SLASET( 'A', K, 1, ONE, ONE, WORK( IWK3 ), K ) * * Compute the updated singular values, the arrays DIFL, DIFR, * and the updated Z. * DO 40 J = 1, K CALL SLASD4( K, J, DSIGMA, Z, WORK( IWK1 ), RHO, D( J ), $ WORK( IWK2 ), INFO ) * * If the root finder fails, the computation is terminated. * IF( INFO.NE.0 ) THEN CALL XERBLA( 'SLASD4', -INFO ) RETURN END IF WORK( IWK3I+J ) = WORK( IWK3I+J )*WORK( J )*WORK( IWK2I+J ) DIFL( J ) = -WORK( J ) DIFR( J, 1 ) = -WORK( J+1 ) DO 20 I = 1, J - 1 WORK( IWK3I+I ) = WORK( IWK3I+I )*WORK( I )* $ WORK( IWK2I+I ) / ( DSIGMA( I )- $ DSIGMA( J ) ) / ( DSIGMA( I )+ $ DSIGMA( J ) ) 20 CONTINUE DO 30 I = J + 1, K WORK( IWK3I+I ) = WORK( IWK3I+I )*WORK( I )* $ WORK( IWK2I+I ) / ( DSIGMA( I )- $ DSIGMA( J ) ) / ( DSIGMA( I )+ $ DSIGMA( J ) ) 30 CONTINUE 40 CONTINUE * * Compute updated Z. * DO 50 I = 1, K Z( I ) = SIGN( SQRT( ABS( WORK( IWK3I+I ) ) ), Z( I ) ) 50 CONTINUE * * Update VF and VL. * DO 80 J = 1, K DIFLJ = DIFL( J ) DJ = D( J ) DSIGJ = -DSIGMA( J ) IF( J.LT.K ) THEN DIFRJ = -DIFR( J, 1 ) DSIGJP = -DSIGMA( J+1 ) END IF WORK( J ) = -Z( J ) / DIFLJ / ( DSIGMA( J )+DJ ) DO 60 I = 1, J - 1 WORK( I ) = Z( I ) / ( SLAMC3( DSIGMA( I ), DSIGJ )-DIFLJ ) $ / ( DSIGMA( I )+DJ ) 60 CONTINUE DO 70 I = J + 1, K WORK( I ) = Z( I ) / ( SLAMC3( DSIGMA( I ), DSIGJP )+DIFRJ ) $ / ( DSIGMA( I )+DJ ) 70 CONTINUE TEMP = SNRM2( K, WORK, 1 ) WORK( IWK2I+J ) = SDOT( K, WORK, 1, VF, 1 ) / TEMP WORK( IWK3I+J ) = SDOT( K, WORK, 1, VL, 1 ) / TEMP IF( ICOMPQ.EQ.1 ) THEN DIFR( J, 2 ) = TEMP END IF 80 CONTINUE * CALL SCOPY( K, WORK( IWK2 ), 1, VF, 1 ) CALL SCOPY( K, WORK( IWK3 ), 1, VL, 1 ) * RETURN * * End of SLASD8 * END
bsd-3-clause
nvarini/espresso_iohpc
West/Tools/set_isz.f90
1
1794
! ! Copyright (C) 2015 M. Govoni ! 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 . ! ! Contributors to this file: ! Marco Govoni ! !----------------------------------------------------------------------- SUBROUTINE set_isz( isz_mode, isz ) !----------------------------------------------------------------------- ! USE kinds, ONLY : DP USE cell_base, ONLY : omega USE constants, ONLY : pi,fpi USE pwcom, ONLY : tpiba2,npw USE gvect, ONLY : g,gstart USE mp, ONLY : mp_sum USE mp_global, ONLY : intra_bgrp_comm USE io_global, ONLY : stdout ! IMPLICIT NONE ! ! I/O ! INTEGER,INTENT(IN) :: isz_mode REAL(DP),INTENT(OUT) :: isz ! ! Workspace ! REAL(DP) :: gammafact, g2 INTEGER :: ig, partial ! WRITE(stdout,'(5x,"isz_mode = ",i6)') isz_mode ! SELECT CASE ( isz_mode ) ! CASE(1) ! spherical region ! isz = ( (6._DP * pi * pi / omega )**(1._DP/3._DP) ) / ( 2._DP * pi * pi ) ! CASE(2) ! gygi-baldereschi ! gammafact = 1._DP ! partial = 0._DP DO ig = gstart, npw g2 = ( g(1,ig)*g(1,ig) + g(2,ig)*g(2,ig) + g(3,ig)*g(3,ig) ) * tpiba2 partial = partial + DEXP( - gammafact * g2 ) / g2 ENDDO ! CALL mp_sum( partial, intra_bgrp_comm ) ! isz = 1._DP / ( fpi * SQRT( pi * gammafact ) ) - 2._DP * partial / omega + gammafact / omega ! CASE DEFAULT ! isz = 0._DP ! END SELECT ! END SUBROUTINE
gpl-2.0
vfonov/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
feilen/OSVR-Core
vendor/eigen-3.2.6/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
apache-2.0
TSC21/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
bsd-3-clause
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/zspsv.f
29
6945
*> \brief <b> ZSPSV computes the solution to system of linear equations A * X = B for OTHER matrices</b> * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download ZSPSV + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zspsv.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zspsv.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zspsv.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE ZSPSV( UPLO, N, NRHS, AP, IPIV, B, LDB, INFO ) * * .. Scalar Arguments .. * CHARACTER UPLO * INTEGER INFO, LDB, N, NRHS * .. * .. Array Arguments .. * INTEGER IPIV( * ) * COMPLEX*16 AP( * ), B( LDB, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> ZSPSV computes the solution to a complex system of linear equations *> A * X = B, *> where A is an N-by-N symmetric matrix stored in packed format and X *> and B are N-by-NRHS matrices. *> *> The diagonal pivoting method is used to factor A as *> A = U * D * U**T, if UPLO = 'U', or *> A = L * D * L**T, if UPLO = 'L', *> where U (or L) is a product of permutation and unit upper (lower) *> triangular matrices, D is symmetric and block diagonal with 1-by-1 *> and 2-by-2 diagonal blocks. The factored form of A is then used to *> solve the system of equations A * X = B. *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> = 'U': Upper triangle of A is stored; *> = 'L': Lower triangle of A is stored. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of linear equations, i.e., the order of the *> matrix A. N >= 0. *> \endverbatim *> *> \param[in] NRHS *> \verbatim *> NRHS is INTEGER *> The number of right hand sides, i.e., the number of columns *> of the matrix B. NRHS >= 0. *> \endverbatim *> *> \param[in,out] AP *> \verbatim *> AP is COMPLEX*16 array, dimension (N*(N+1)/2) *> On entry, the upper or lower triangle of the symmetric matrix *> A, packed columnwise in a linear array. The j-th column of A *> is stored in the array AP as follows: *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; *> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. *> See below for further details. *> *> On exit, the block diagonal matrix D and the multipliers used *> to obtain the factor U or L from the factorization *> A = U*D*U**T or A = L*D*L**T as computed by ZSPTRF, stored as *> a packed triangular matrix in the same storage format as A. *> \endverbatim *> *> \param[out] IPIV *> \verbatim *> IPIV is INTEGER array, dimension (N) *> Details of the interchanges and the block structure of D, as *> determined by ZSPTRF. If IPIV(k) > 0, then rows and columns *> k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1 *> diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, *> then rows and columns k-1 and -IPIV(k) were interchanged and *> D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and *> IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and *> -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2 *> diagonal block. *> \endverbatim *> *> \param[in,out] B *> \verbatim *> B is COMPLEX*16 array, dimension (LDB,NRHS) *> On entry, the N-by-NRHS right hand side matrix B. *> On exit, if INFO = 0, the N-by-NRHS solution matrix X. *> \endverbatim *> *> \param[in] LDB *> \verbatim *> LDB is INTEGER *> The leading dimension of the array B. LDB >= max(1,N). *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> > 0: if INFO = i, D(i,i) is exactly zero. The factorization *> has been completed, but the block diagonal matrix D is *> exactly singular, so the solution could not be *> computed. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup complex16OTHERsolve * *> \par Further Details: * ===================== *> *> \verbatim *> *> The packed storage scheme is illustrated by the following example *> when N = 4, UPLO = 'U': *> *> Two-dimensional storage of the symmetric matrix A: *> *> a11 a12 a13 a14 *> a22 a23 a24 *> a33 a34 (aij = aji) *> a44 *> *> Packed storage of the upper triangle of A: *> *> AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] *> \endverbatim *> * ===================================================================== SUBROUTINE ZSPSV( UPLO, N, NRHS, AP, IPIV, B, LDB, INFO ) * * -- LAPACK driver routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER UPLO INTEGER INFO, LDB, N, NRHS * .. * .. Array Arguments .. INTEGER IPIV( * ) COMPLEX*16 AP( * ), B( LDB, * ) * .. * * ===================================================================== * * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL XERBLA, ZSPTRF, ZSPTRS * .. * .. Intrinsic Functions .. INTRINSIC MAX * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( NRHS.LT.0 ) THEN INFO = -3 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN INFO = -7 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'ZSPSV ', -INFO ) RETURN END IF * * Compute the factorization A = U*D*U**T or A = L*D*L**T. * CALL ZSPTRF( UPLO, N, AP, IPIV, INFO ) IF( INFO.EQ.0 ) THEN * * Solve the system A*X = B, overwriting B with X. * CALL ZSPTRS( UPLO, N, NRHS, AP, IPIV, B, LDB, INFO ) * END IF RETURN * * End of ZSPSV * END
bsd-3-clause
UPenn-RoboCup/OpenBLAS
lapack-netlib/TESTING/LIN/dchkqrt.f
31
5384
*> \brief \b DCHKQRT * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE DCHKQRT( THRESH, TSTERR, NM, MVAL, NN, NVAL, NNB, * NBVAL, NOUT ) * * .. Scalar Arguments .. * LOGICAL TSTERR * INTEGER NM, NN, NNB, NOUT * DOUBLE PRECISION THRESH * .. * .. Array Arguments .. * INTEGER MVAL( * ), NBVAL( * ), NVAL( * ) * *> \par Purpose: * ============= *> *> \verbatim *> *> DCHKQRT tests DGEQRT and DGEMQRT. *> \endverbatim * * Arguments: * ========== * *> \param[in] THRESH *> \verbatim *> THRESH is DOUBLE PRECISION *> The threshold value for the test ratios. A result is *> included in the output file if RESULT >= THRESH. To have *> every test ratio printed, use THRESH = 0. *> \endverbatim *> *> \param[in] TSTERR *> \verbatim *> TSTERR is LOGICAL *> Flag that indicates whether error exits are to be tested. *> \endverbatim *> *> \param[in] NM *> \verbatim *> NM is INTEGER *> The number of values of M contained in the vector MVAL. *> \endverbatim *> *> \param[in] MVAL *> \verbatim *> MVAL is INTEGER array, dimension (NM) *> The values of the matrix row dimension M. *> \endverbatim *> *> \param[in] NN *> \verbatim *> NN is INTEGER *> The number of values of N contained in the vector NVAL. *> \endverbatim *> *> \param[in] NVAL *> \verbatim *> NVAL is INTEGER array, dimension (NN) *> The values of the matrix column dimension N. *> \endverbatim *> *> \param[in] NNB *> \verbatim *> NNB is INTEGER *> The number of values of NB contained in the vector NBVAL. *> \endverbatim *> *> \param[in] NBVAL *> \verbatim *> NBVAL is INTEGER array, dimension (NBVAL) *> The values of the blocksize NB. *> \endverbatim *> *> \param[in] NOUT *> \verbatim *> NOUT is INTEGER *> The unit number for output. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup double_lin * * ===================================================================== SUBROUTINE DCHKQRT( THRESH, TSTERR, NM, MVAL, NN, NVAL, NNB, $ NBVAL, NOUT ) IMPLICIT NONE * * -- LAPACK test routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. LOGICAL TSTERR INTEGER NM, NN, NNB, NOUT DOUBLE PRECISION THRESH * .. * .. Array Arguments .. INTEGER MVAL( * ), NBVAL( * ), NVAL( * ) * .. * * ===================================================================== * * .. Parameters .. INTEGER NTESTS PARAMETER ( NTESTS = 6 ) * .. * .. Local Scalars .. CHARACTER*3 PATH INTEGER I, J, K, T, M, N, NB, NFAIL, NERRS, NRUN, $ MINMN * * .. Local Arrays .. DOUBLE PRECISION RESULT( NTESTS ) * .. * .. External Subroutines .. EXTERNAL ALAERH, ALAHD, ALASUM, DERRQRT, DQRT04 * .. * .. Scalars in Common .. LOGICAL LERR, OK CHARACTER*32 SRNAMT INTEGER INFOT, NUNIT * .. * .. Common blocks .. COMMON / INFOC / INFOT, NUNIT, OK, LERR COMMON / SRNAMC / SRNAMT * .. * .. Executable Statements .. * * Initialize constants * PATH( 1: 1 ) = 'D' PATH( 2: 3 ) = 'QT' NRUN = 0 NFAIL = 0 NERRS = 0 * * Test the error exits * IF( TSTERR ) CALL DERRQRT( PATH, NOUT ) INFOT = 0 * * Do for each value of M in MVAL. * DO I = 1, NM M = MVAL( I ) * * Do for each value of N in NVAL. * DO J = 1, NN N = NVAL( J ) * * Do for each possible value of NB * MINMN = MIN( M, N ) DO K = 1, NNB NB = NBVAL( K ) * * Test DGEQRT and DGEMQRT * IF( (NB.LE.MINMN).AND.(NB.GT.0) ) THEN CALL DQRT04( M, N, NB, RESULT ) * * Print information about the tests that did not * pass the threshold. * DO T = 1, NTESTS IF( RESULT( T ).GE.THRESH ) THEN IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) $ CALL ALAHD( NOUT, PATH ) WRITE( NOUT, FMT = 9999 )M, N, NB, $ T, RESULT( T ) NFAIL = NFAIL + 1 END IF END DO NRUN = NRUN + NTESTS END IF END DO END DO END DO * * Print a summary of the results. * CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS ) * 9999 FORMAT( ' M=', I5, ', N=', I5, ', NB=', I4, $ ' test(', I2, ')=', G12.5 ) RETURN * * End of DCHKQRT * END
bsd-3-clause
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/cpbequ.f
29
6687
*> \brief \b CPBEQU * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download CPBEQU + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cpbequ.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cpbequ.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cpbequ.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE CPBEQU( UPLO, N, KD, AB, LDAB, S, SCOND, AMAX, INFO ) * * .. Scalar Arguments .. * CHARACTER UPLO * INTEGER INFO, KD, LDAB, N * REAL AMAX, SCOND * .. * .. Array Arguments .. * REAL S( * ) * COMPLEX AB( LDAB, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> CPBEQU computes row and column scalings intended to equilibrate a *> Hermitian positive definite band matrix A and reduce its condition *> number (with respect to the two-norm). S contains the scale factors, *> S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with *> elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal. This *> choice of S puts the condition number of B within a factor N of the *> smallest possible condition number over all possible diagonal *> scalings. *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> = 'U': Upper triangular of A is stored; *> = 'L': Lower triangular of A is stored. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the matrix A. N >= 0. *> \endverbatim *> *> \param[in] KD *> \verbatim *> KD is INTEGER *> The number of superdiagonals of the matrix A if UPLO = 'U', *> or the number of subdiagonals if UPLO = 'L'. KD >= 0. *> \endverbatim *> *> \param[in] AB *> \verbatim *> AB is COMPLEX array, dimension (LDAB,N) *> The upper or lower triangle of the Hermitian band matrix A, *> stored in the first KD+1 rows of the array. The j-th column *> of A is stored in the j-th column of the array AB as follows: *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). *> \endverbatim *> *> \param[in] LDAB *> \verbatim *> LDAB is INTEGER *> The leading dimension of the array A. LDAB >= KD+1. *> \endverbatim *> *> \param[out] S *> \verbatim *> S is REAL array, dimension (N) *> If INFO = 0, S contains the scale factors for A. *> \endverbatim *> *> \param[out] SCOND *> \verbatim *> SCOND is REAL *> If INFO = 0, S contains the ratio of the smallest S(i) to *> the largest S(i). If SCOND >= 0.1 and AMAX is neither too *> large nor too small, it is not worth scaling by S. *> \endverbatim *> *> \param[out] AMAX *> \verbatim *> AMAX is REAL *> Absolute value of largest matrix element. If AMAX is very *> close to overflow or very close to underflow, the matrix *> should be scaled. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value. *> > 0: if INFO = i, the i-th diagonal element is nonpositive. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup complexOTHERcomputational * * ===================================================================== SUBROUTINE CPBEQU( UPLO, N, KD, AB, LDAB, S, SCOND, AMAX, INFO ) * * -- LAPACK computational routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER UPLO INTEGER INFO, KD, LDAB, N REAL AMAX, SCOND * .. * .. Array Arguments .. REAL S( * ) COMPLEX AB( LDAB, * ) * .. * * ===================================================================== * * .. Parameters .. REAL ZERO, ONE PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) * .. * .. Local Scalars .. LOGICAL UPPER INTEGER I, J REAL SMIN * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX, MIN, REAL, SQRT * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 UPPER = LSAME( UPLO, 'U' ) IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( KD.LT.0 ) THEN INFO = -3 ELSE IF( LDAB.LT.KD+1 ) THEN INFO = -5 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'CPBEQU', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) THEN SCOND = ONE AMAX = ZERO RETURN END IF * IF( UPPER ) THEN J = KD + 1 ELSE J = 1 END IF * * Initialize SMIN and AMAX. * S( 1 ) = REAL( AB( J, 1 ) ) SMIN = S( 1 ) AMAX = S( 1 ) * * Find the minimum and maximum diagonal elements. * DO 10 I = 2, N S( I ) = REAL( AB( J, I ) ) SMIN = MIN( SMIN, S( I ) ) AMAX = MAX( AMAX, S( I ) ) 10 CONTINUE * IF( SMIN.LE.ZERO ) THEN * * Find the first non-positive diagonal element and return. * DO 20 I = 1, N IF( S( I ).LE.ZERO ) THEN INFO = I RETURN END IF 20 CONTINUE ELSE * * Set the scale factors to the reciprocals * of the diagonal elements. * DO 30 I = 1, N S( I ) = ONE / SQRT( S( I ) ) 30 CONTINUE * * Compute SCOND = min(S(I)) / max(S(I)) * SCOND = SQRT( SMIN ) / SQRT( AMAX ) END IF RETURN * * End of CPBEQU * END
bsd-3-clause
hlokavarapu/calypso
src/Fortran_libraries/MHD_src/IO/m_ctl_data_mhd_forces.f90
3
9216
!m_ctl_data_mhd_forces.f90 ! module m_ctl_data_mhd_forces ! ! programmed by H.Matsui on March. 2006 ! ! subroutine deallocate_name_force_ctl ! ! subroutine read_forces_ctl ! subroutine read_gravity_ctl ! subroutine read_coriolis_ctl ! subroutine read_magneto_ctl ! ! begin forces_define !!!!! define of forces !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! available forces ! gravity, Coriolis, Lorentz, Composite_gravity !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! array force_ctl 4 !! force_ctl gravity end !! force_ctl Coriolis end !! force_ctl Lorentz end !! force_ctl Composite_gravity end !! end array !! end forces_define !! !! !!!! gravity_type !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! 0: constant !! 1: constant_radial (constant intensity) !! 2: radial (propotional to radius) !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! begin gravity_define !! gravity_type_ctl radial !! !! !!!! direction of gravity (opposite direction to that of buoyancy) !! array gravity_vec 3 !! gravity_vec x 0.000 end !! gravity_vec y 0.000 end !! gravity_vec z -1.000 end !! end array gravity_vec !! end gravity_define !! !! !!!! direction of rotation vector for Coriolis force !!!!!!!!!!!!! !! !! begin Coriolis_define !! array rotation_vec 3 !! rotation_vec x 0.000 end !! rotation_vec y 0.000 end !! rotation_vec z 1.000 end !! end array rotation_vec !! !! tri_sph_int_file 'rot_int.dat' !! sph_int_file_format 'ascii' !! end Coriolis_define !! !!!!!!!!!! magnetoconvection model!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! array ext_magne_vec: 0...off more than 1...On !! ext_magne_vec: external field (constant) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! begin Magneto_convection_def !! magneto_cv_ctl On !! array ext_magne_vec 3 !! ext_magne_vec x 0.000 end !! ext_magne_vec y 1.000 end !! ext_magne_vec z 0.000 end !! end array ext_magne_vec !! end Magneto_convection_def !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! module m_ctl_data_mhd_forces ! use m_precision ! use m_constants use m_machine_parameter use m_read_control_elements use calypso_mpi use skip_comment_f use t_read_control_arrays ! implicit none ! ! !> Structure for constant force list !!@n force_names_ctl%c_tbl: Name of force type(ctl_array_chara), save :: force_names_ctl ! character(len=kchara) :: gravity_ctl ! !> Structure for constant gravity vector !!@n gravity_vector_ctl%c_tbl: Direction of gravity vector !!@n gravity_vector_ctl%vect: Amplitude of gravity vector type(ctl_array_cr), save :: gravity_vector_ctl ! character (len=kchara) :: sph_cor_file_name_ctl character (len=kchara) :: sph_cor_file_fmt_ctl ! !> Structure for rotation of system !!@n system_rotation_ctl%c_tbl: Direction of rotation vector !!@n system_rotation_ctl%vect: Amplitude of rotation vector type(ctl_array_cr), save :: system_rotation_ctl ! character(len=kchara) :: magneto_cv_ctl ! !> Structure for external magnetic field control !!@n ext_magne_ctl%c_tbl: Direction of external magnetic field !!@n ext_magne_ctl%vect: Amplitude of external magnetic field type(ctl_array_cr), save :: ext_magne_ctl ! ! entry label ! character(len=kchara), parameter & & :: hd_forces_ctl = 'forces_define' integer (kind=kint) :: i_forces_ctl = 0 ! character(len=kchara), parameter & & :: hd_gravity_ctl = 'gravity_define' integer (kind=kint) :: i_gravity_ctl = 0 ! character(len=kchara), parameter & & :: hd_coriolis_ctl = 'Coriolis_define' integer (kind=kint) :: i_coriolis_ctl = 0 ! character(len=kchara), parameter & & :: hd_magneto_ctl = 'Magneto_convection_def' integer (kind=kint) :: i_magneto_ctl = 0 ! ! 4th level for forces ! character(len=kchara), parameter & & :: hd_num_forces = 'force_ctl' ! ! 4th level for time steps ! character(len=kchara), parameter & & :: hd_gravity_type = 'gravity_type_ctl' character(len=kchara), parameter & & :: hd_gravity_vect = 'gravity_vec' integer (kind=kint) :: i_gravity_type = 0 ! ! 4th level for time steps ! character(len=kchara), parameter & & :: hd_rotation_vec = 'rotation_vec' character(len=kchara), parameter & & :: hd_sph_coriolis_file = 'tri_sph_int_file' character(len=kchara), parameter & & :: hd_sph_coriolis_fmt = 'sph_int_file_format' integer (kind=kint) :: i_sph_coriolis_file = 0 integer (kind=kint) :: i_sph_coriolis_fmt = 0 ! ! 4th level for external magnetic field ! character(len=kchara), parameter & & :: hd_magneto_cv = 'magneto_cv_ctl' character(len=kchara), parameter & & :: hd_magne_vect = 'ext_magne_vec' integer (kind=kint) :: i_magneto_cv = 0 ! ! private :: hd_forces_ctl, i_forces_ctl private :: hd_gravity_ctl, hd_coriolis_ctl, hd_magneto_ctl private :: i_gravity_ctl, i_coriolis_ctl, i_magneto_ctl private :: hd_num_forces, hd_sph_coriolis_file private :: hd_sph_coriolis_fmt private :: hd_gravity_type, hd_gravity_vect private :: hd_magneto_cv, hd_magne_vect ! ! -------------------------------------------------------------------- ! contains ! ! -------------------------------------------------------------------- ! subroutine deallocate_name_force_ctl ! call dealloc_control_array_chara(force_names_ctl) ! end subroutine deallocate_name_force_ctl ! ! ----------------------------------------------------------------------- ! ----------------------------------------------------------------------- ! subroutine read_forces_ctl ! ! if(right_begin_flag(hd_forces_ctl) .eq. 0) return if (i_forces_ctl .gt. 0) return do call load_ctl_label_and_line ! call find_control_end_flag(hd_forces_ctl, i_forces_ctl) if(i_forces_ctl .gt. 0) exit ! call read_control_array_c1(hd_num_forces, force_names_ctl) end do ! end subroutine read_forces_ctl ! ! -------------------------------------------------------------------- ! subroutine read_gravity_ctl ! ! if(right_begin_flag(hd_gravity_ctl) .eq. 0) return if (i_gravity_ctl .gt. 0) return do call load_ctl_label_and_line ! call find_control_end_flag(hd_gravity_ctl, i_gravity_ctl) if(i_gravity_ctl .gt. 0) exit ! call read_control_array_c_r & & (hd_gravity_vect, gravity_vector_ctl) ! call read_character_ctl_item(hd_gravity_type, & & i_gravity_type, gravity_ctl) end do ! end subroutine read_gravity_ctl ! ! -------------------------------------------------------------------- ! subroutine read_coriolis_ctl ! ! if(right_begin_flag(hd_coriolis_ctl) .eq. 0) return if (i_coriolis_ctl .gt. 0) return do call load_ctl_label_and_line ! call find_control_end_flag(hd_coriolis_ctl, i_coriolis_ctl) if(i_coriolis_ctl .gt. 0) exit ! ! call read_control_array_c_r & & (hd_rotation_vec, system_rotation_ctl) ! call read_character_ctl_item(hd_sph_coriolis_file, & & i_sph_coriolis_file, sph_cor_file_name_ctl) call read_character_ctl_item(hd_sph_coriolis_fmt, & & i_sph_coriolis_fmt, sph_cor_file_fmt_ctl) end do ! end subroutine read_coriolis_ctl ! ! -------------------------------------------------------------------- ! subroutine read_magneto_ctl ! ! if(right_begin_flag(hd_magneto_ctl) .eq. 0) return if (i_magneto_ctl .gt. 0) return do call load_ctl_label_and_line ! call find_control_end_flag(hd_magneto_ctl, i_magneto_ctl) if(i_magneto_ctl .gt. 0) exit ! call read_control_array_c_r(hd_magne_vect, ext_magne_ctl) ! call read_character_ctl_item(hd_magneto_cv, & & i_magneto_cv, magneto_cv_ctl) end do ! end subroutine read_magneto_ctl ! ! -------------------------------------------------------------------- ! end module m_ctl_data_mhd_forces
gpl-3.0
hlokavarapu/calypso
src/Fortran_libraries/PARALLEL_src/SPH_SHELL_src/m_legendre_work_testlooop.f90
3
7658
!>@file m_legendre_work_testlooop.f90 !!@brief module m_legendre_work_testlooop !! !!@author H. Matsui !!@date Programmed in Aug., 2013 ! !>@brief Work array for forward Legendre transform useing mat multi !>@n data are strored communication buffer !! !!@verbatim !! subroutine alloc_leg_vec_test(nvector, nscalar) !! subroutine dealloc_leg_vec_test !! subroutine dealloc_leg_scl_test !! !! field data for Legendre transform !! original layout: vr_rtm(l_rtm,m_rtm,k_rtm,icomp) !! size: vr_rtm(nidx_rtm(2),nidx_rtm(1)*ncomp,nidx_rtm(3)) !! real(kind = kreal), allocatable :: vr_rtm(:,:,:) !! !! spectr data for Legendre transform !! original layout: sp_rlm(j_rlm,k_rtm,icomp) !! size: sp_rlm(nidx_rlm(2),nidx_rtm(1)*ncomp) !! real(kind = kreal), allocatable :: sp_rlm(:,:) !!@endverbatim !! !!@param ncomp Total number of components for spherical transform !!@param nvector Number of vector for spherical transform !!@param nscalar Number of scalar (including tensor components) !! for spherical transform ! module m_legendre_work_testlooop ! use m_precision use m_constants use calypso_mpi ! use m_machine_parameter use m_spheric_parameter use m_spheric_param_smp use m_schmidt_poly_on_rtm use m_work_4_sph_trans use matmul_for_legendre_trans ! implicit none ! !> Maximum matrix size for spectr data integer(kind = kint) :: nvec_jk !> Maximum matrix size for spectr data integer(kind = kint) :: nscl_jk ! !> Poloidal component with evem (l-m) !!@n real(kind = kreal), allocatable :: pol_e(:,:) !!@n Phi derivative of toroidal component with evem (l-m) !!@n real(kind = kreal), allocatable :: dtordp_e(:,:) !!@n Phi derivative of poloidal component with evem (l-m) !!@n real(kind = kreal), allocatable :: dpoldp_e(:,:) !!@n Scalar with evem (l-m) !!@n real(kind = kreal), allocatable :: scl_e(:,:) !!@n pol_e = Pol_e( 1: nvec_jk,ip) !!@n dtordp_e = Pol_e( nvec_jk+1:2*nvec_jk,ip) !!@n dpoldp_e = Pol_e(2*nvec_jk+1:3*nvec_jk,ip) !!@n scl_e = Pol_e(3*nvec_jk+1:3*nvec_jk+nscl_jk,ip) real(kind = kreal), allocatable :: pol_e(:,:) ! !> Theta derivative of poloidal component with evem (l-m) !!@n real(kind = kreal), allocatable :: dtordt_e(:,:) !!@n Theta derivative of Toroidal component with evem (l-m) !!@n real(kind = kreal), allocatable :: dpoldt_e(:,:) !!@n dtordt_e = tor_e( 1: nvec_jk,ip) !!@n dpoldt_e = tor_e( nvec_jk+1:2*nvec_jk,ip) real(kind = kreal), allocatable :: tor_e(:,:) ! !> Poloidal component with odd (l-m) !!@n real(kind = kreal), allocatable :: pol_o(:,:) !!@n Phi derivative of toroidal component with odd (l-m) !!@n real(kind = kreal), allocatable :: dtordp_o(:,:) !!@n Phi derivative of Poloidal component with odd (l-m) !!@n real(kind = kreal), allocatable :: dpoldp_o(:,:) !!@n Scalar with odd (l-m) !!@n real(kind = kreal), allocatable :: scl_o(:,:) !!@n pol_o = pol_o( 1: nvec_jk,ip) !!@n dtordp_o = pol_o( nvec_jk+1:2*nvec_jk,ip) !!@n dpoldp_o = pol_o(2*nvec_jk+1:3*nvec_jk,ip) !!@n scl_o = pol_o(3*nvec_jk+1:3*nvec_jk+nscl_jk,ip) real(kind = kreal), allocatable :: pol_o(:,:) ! !> Theta derivative of Toroidal component with odd (l-m) !!@n real(kind = kreal), allocatable :: dtordt_o(:,:) !!@n Theta derivative of Poloidal component with odd (l-m) !!@n real(kind = kreal), allocatable :: dpoldt_o(:,:) !!@n dtordt_o = tor_o( 1: nvec_jk,ip) !!@n dpoldt_o = tor_o( nvec_jk+1:2*nvec_jk,ip) real(kind = kreal), allocatable :: tor_o(:,:) ! !> Scalar with evem (l-m) real(kind = kreal), allocatable :: scl_e(:,:) !> Scalar with odd (l-m) real(kind = kreal), allocatable :: scl_o(:,:) ! ! !> Maximum matrix size for field data integer(kind = kint) :: nvec_lk !> Maximum matrix size for field data integer(kind = kint) :: nscl_lk ! !> Symmetric radial component !!@n real(kind = kreal), allocatable :: symp_r(:,:) !!@n Symmetric theta-component with condugate order !!@n real(kind = kreal), allocatable :: symn_t(:,:) !!@n Symmetric phi-component with condugate order !!@n real(kind = kreal), allocatable :: symn_p(:,:) !!@n Symmetric scalar component !!@n real(kind = kreal), allocatable :: symp(:,:) !!@n symp_r = symp_r( 1: nvec_lk,ip) !!@n symn_t = symp_r( nvec_lk+1:2*nvec_lk,ip) !!@n symn_p = symp_r(2*nvec_lk+1:3*nvec_lk,ip) !!@n symp = symp_r(3*nvec_lk+1:3*nvec_lk+nscl_lk,ip) real(kind = kreal), allocatable :: symp_r(:,:) ! !> Anti-symmetric phi-component !!@n real(kind = kreal), allocatable :: asmp_p(:,:) !!@n Anti-symmetric theta-component !!@n real(kind = kreal), allocatable :: asmp_t(:,:) !!@n asmp_p = asmp_p( 1: nvec_lk,ip) !!@n asmp_t = asmp_p( nvec_lk+1:2*nvec_lk,ip) real(kind = kreal), allocatable :: asmp_p(:,:) ! !! Anti-symmetric radial component !!@n real(kind = kreal), allocatable :: asmp_r(:,:) !!@n Anti-symmetric theta-component with condugate order !!@n real(kind = kreal), allocatable :: asmn_t(:,:) !!@n Anti-symmetric phi-component with condugate order !!@n real(kind = kreal), allocatable :: asmn_p(:,:) !!@n Anti-symmetric scalar component !!@n real(kind = kreal), allocatable :: asmp(:,:) !!@n asmp_r = asmp_r( 1: nvec_lk,ip) !!@n asmn_t = asmp_r( nvec_lk+1:2*nvec_lk,ip) !!@n asmn_p = asmp_r(2*nvec_lk+1:3*nvec_lk,ip) !!@n asmp = asmp_r(3*nvec_lk+1:3*nvec_lk+nscl_lk,ip) real(kind = kreal), allocatable :: asmp_r(:,:) ! !> Symmetric phi-component !!@n real(kind = kreal), allocatable :: symp_p(:,:) !!@n Symmetric theta-component !!@n real(kind = kreal), allocatable :: symp_t(:,:) !!@n symp_p = symp_p( 1: nvec_lk,ip) !!@n symp_t = symp_p( nvec_lk+1:2*nvec_lk,ip) real(kind = kreal), allocatable :: symp_p(:,:) ! !> Symmetric scalar component real(kind = kreal), allocatable :: symp(:,:) !> Anti-symmetric scalar component real(kind = kreal), allocatable :: asmp(:,:) ! ! ----------------------------------------------------------------------- ! contains ! ! ----------------------------------------------------------------------- ! subroutine alloc_leg_vec_test(nvector, nscalar) ! integer(kind = kint), intent(in) ::nvector, nscalar ! ! nvec_jk = ((maxdegree_rlm+1)/2) * nidx_rlm(1)*nvector nscl_jk = ((maxdegree_rlm+1)/2) * nidx_rlm(1)*nscalar allocate(pol_e(3*nvec_jk+nscl_jk,np_smp)) allocate(tor_e(2*nvec_jk,np_smp)) allocate(pol_o(3*nvec_jk+nscl_jk,np_smp)) allocate(tor_o(2*nvec_jk,np_smp)) ! nvec_lk = ((maxidx_rtm_smp(2)+1)/2) * nidx_rlm(1)*nvector nscl_lk = ((maxidx_rtm_smp(2)+1)/2) * nidx_rlm(1)*nscalar allocate(symp_r(3*nvec_lk+nscl_lk,np_smp)) allocate(symp_p(2*nvec_lk,np_smp)) allocate(asmp_r(3*nvec_lk+nscl_lk,np_smp)) allocate(asmp_p(2*nvec_lk,np_smp)) ! end subroutine alloc_leg_vec_test ! ! ----------------------------------------------------------------------- ! subroutine dealloc_leg_vec_test ! ! deallocate(pol_e, tor_e, pol_o, tor_o) deallocate(symp_r, symp_p, asmp_r, asmp_p) ! end subroutine dealloc_leg_vec_test ! ! ----------------------------------------------------------------------- ! end module m_legendre_work_testlooop
gpl-3.0
UPenn-RoboCup/OpenBLAS
reference/zpotrff.f
50
5787
SUBROUTINE ZPOTRFF( UPLO, N, A, LDA, INFO ) * * -- LAPACK routine (version 3.0) -- * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., * Courant Institute, Argonne National Lab, and Rice University * September 30, 1994 * * .. Scalar Arguments .. CHARACTER UPLO INTEGER INFO, LDA, N * .. * .. Array Arguments .. COMPLEX*16 A( LDA, * ) * .. * * Purpose * ======= * * ZPOTRF computes the Cholesky factorization of a complex Hermitian * positive definite matrix A. * * The factorization has the form * A = U**H * U, if UPLO = 'U', or * A = L * L**H, if UPLO = 'L', * where U is an upper triangular matrix and L is lower triangular. * * This is the block version of the algorithm, calling Level 3 BLAS. * * Arguments * ========= * * UPLO (input) CHARACTER*1 * = 'U': Upper triangle of A is stored; * = 'L': Lower triangle of A is stored. * * N (input) INTEGER * The order of the matrix A. N >= 0. * * A (input/output) COMPLEX*16 array, dimension (LDA,N) * On entry, the Hermitian matrix A. If UPLO = 'U', the leading * N-by-N upper triangular part of A contains the upper * triangular part of the matrix A, and the strictly lower * triangular part of A is not referenced. If UPLO = 'L', the * leading N-by-N lower triangular part of A contains the lower * triangular part of the matrix A, and the strictly upper * triangular part of A is not referenced. * * On exit, if INFO = 0, the factor U or L from the Cholesky * factorization A = U**H*U or A = L*L**H. * * LDA (input) INTEGER * The leading dimension of the array A. LDA >= max(1,N). * * INFO (output) INTEGER * = 0: successful exit * < 0: if INFO = -i, the i-th argument had an illegal value * > 0: if INFO = i, the leading minor of order i is not * positive definite, and the factorization could not be * completed. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ONE COMPLEX*16 CONE PARAMETER ( ONE = 1.0D+0, CONE = ( 1.0D+0, 0.0D+0 ) ) * .. * .. Local Scalars .. LOGICAL UPPER INTEGER J, JB, NB * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL XERBLA, ZGEMM, ZHERK, ZPOTF2, ZTRSM * .. * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 UPPER = LSAME( UPLO, 'U' ) IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN INFO = -4 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'ZPOTRF', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * * Determine the block size for this environment. * NB = 56 IF( NB.LE.1 .OR. NB.GE.N ) THEN * * Use unblocked code. * CALL ZPOTF2( UPLO, N, A, LDA, INFO ) ELSE * * Use blocked code. * IF( UPPER ) THEN * * Compute the Cholesky factorization A = U'*U. * DO 10 J = 1, N, NB * * Update and factorize the current diagonal block and test * for non-positive-definiteness. * JB = MIN( NB, N-J+1 ) CALL ZHERK( 'Upper', 'Conjugate transpose', JB, J-1, $ -ONE, A( 1, J ), LDA, ONE, A( J, J ), LDA ) CALL ZPOTF2( 'Upper', JB, A( J, J ), LDA, INFO ) IF( INFO.NE.0 ) $ GO TO 30 IF( J+JB.LE.N ) THEN * * Compute the current block row. * CALL ZGEMM( 'Conjugate transpose', 'No transpose', JB, $ N-J-JB+1, J-1, -CONE, A( 1, J ), LDA, $ A( 1, J+JB ), LDA, CONE, A( J, J+JB ), $ LDA ) CALL ZTRSM( 'Left', 'Upper', 'Conjugate transpose', $ 'Non-unit', JB, N-J-JB+1, CONE, A( J, J ), $ LDA, A( J, J+JB ), LDA ) END IF 10 CONTINUE * ELSE * * Compute the Cholesky factorization A = L*L'. * DO 20 J = 1, N, NB * * Update and factorize the current diagonal block and test * for non-positive-definiteness. * JB = MIN( NB, N-J+1 ) CALL ZHERK( 'Lower', 'No transpose', JB, J-1, -ONE, $ A( J, 1 ), LDA, ONE, A( J, J ), LDA ) CALL ZPOTF2( 'Lower', JB, A( J, J ), LDA, INFO ) IF( INFO.NE.0 ) $ GO TO 30 IF( J+JB.LE.N ) THEN * * Compute the current block column. * CALL ZGEMM( 'No transpose', 'Conjugate transpose', $ N-J-JB+1, JB, J-1, -CONE, A( J+JB, 1 ), $ LDA, A( J, 1 ), LDA, CONE, A( J+JB, J ), $ LDA ) CALL ZTRSM( 'Right', 'Lower', 'Conjugate transpose', $ 'Non-unit', N-J-JB+1, JB, CONE, A( J, J ), $ LDA, A( J+JB, J ), LDA ) END IF 20 CONTINUE END IF END IF GO TO 40 * 30 CONTINUE INFO = INFO + J - 1 * 40 CONTINUE RETURN * * End of ZPOTRF * END
bsd-3-clause
hlokavarapu/calypso
src/Fortran_libraries/PARALLEL_src/CONST_SPH_GRID/set_FEM_mesh_4_sph.f90
3
6975
! ! module set_FEM_mesh_4_sph ! ! Written by H. Matsui on March, 2013 ! ! subroutine s_const_FEM_mesh_for_sph(ip_rank, mesh, group) ! module set_FEM_mesh_4_sph ! use m_precision ! implicit none ! private :: const_FEM_geometry_for_sph private :: const_FEM_groups_for_sph private :: const_nod_comm_table_for_sph ! ! ----------------------------------------------------------------------- ! contains ! ! ----------------------------------------------------------------------- ! subroutine s_const_FEM_mesh_for_sph & & (ip_rank, r_global, mesh, group) ! use t_mesh_data use t_comm_table use t_geometry_data use t_group_data use m_spheric_global_ranks use m_sph_mesh_1d_connect ! use coordinate_converter use ordering_sph_mesh_to_rtp ! integer(kind = kint), intent(in) :: ip_rank real(kind= kreal), intent(in) :: r_global(nidx_global_fem(1)) ! type(mesh_geometry), intent(inout) :: mesh type(mesh_groups), intent(inout) :: group ! integer(kind = kint) :: ip_r, ip_t ! ! ip_r = iglobal_rank_rtp(1,ip_rank) + 1 ip_t = iglobal_rank_rtp(2,ip_rank) + 1 ! ! Construct element connectivity call const_FEM_geometry_for_sph(ip_r, ip_t, r_global, & & mesh%node, mesh%ele) ! ! Construct groups call const_FEM_groups_for_sph(ip_r, ip_t, group) ! ! Set communication table call const_nod_comm_table_for_sph(ip_rank, ip_r, ip_t, & & mesh%nod_comm) ! ! Ordering to connect rtp data call s_ordering_sph_mesh_for_rtp(ip_r, ip_t, & & mesh%node, mesh%ele, group%nod_grp, mesh%nod_comm) ! ! Convert spherical coordinate to certesian call position_2_xyz(mesh%node%numnod, & & mesh%node%rr, mesh%node%theta, mesh%node%phi, & & mesh%node%xx(1:mesh%node%numnod,1), & & mesh%node%xx(1:mesh%node%numnod,2), & & mesh%node%xx(1:mesh%node%numnod,3)) ! end subroutine s_const_FEM_mesh_for_sph ! ! ----------------------------------------------------------------------- ! subroutine const_FEM_geometry_for_sph(ip_r, ip_t, r_global, & & node, ele) ! use calypso_mpi use t_geometry_data use m_spheric_parameter use m_spheric_global_ranks use m_sph_mesh_1d_connect ! use set_sph_local_node use set_sph_local_element ! integer(kind = kint), intent(in) :: ip_r, ip_t real(kind= kreal), intent(in) :: r_global(nidx_global_fem(1)) ! type(node_data), intent(inout) :: node type(element_data), intent(inout) :: ele ! ! Construct node geometry call count_numnod_local_sph_mesh & & (iflag_shell_mode, ip_r, ip_t, node) ! call allocate_node_geometry_type(node) call set_local_nodes_sph_mesh & & (iflag_shell_mode, ip_r, ip_t, r_global, node) ! ! Construct element connectivity call count_local_elements_sph_mesh(ip_r, ip_t, ele) ! call allocate_ele_connect_type(ele) call set_local_elements_sph_mesh(ip_r, ip_t, ele) ! end subroutine const_FEM_geometry_for_sph ! ! ----------------------------------------------------------------------- ! ----------------------------------------------------------------------- ! subroutine const_FEM_groups_for_sph(ip_r, ip_t, group) ! use t_mesh_data use t_group_data ! use set_sph_node_group use set_sph_ele_group use set_sph_surf_group use cal_minmax_and_stacks ! integer(kind = kint), intent(in) :: ip_r, ip_t ! type(mesh_groups), intent(inout) :: group ! ! ! Construct node group call count_sph_local_node_group(group%nod_grp) ! call allocate_grp_type_num(group%nod_grp) call count_sph_local_node_grp_item(ip_r, ip_t, group%nod_grp) ! call s_cal_total_and_stacks(group%nod_grp%num_grp, & & group%nod_grp%nitem_grp, izero, group%nod_grp%istack_grp, & & group%nod_grp%num_item) ! call allocate_grp_type_item(group%nod_grp) call set_sph_local_node_grp_item(ip_r, ip_t, group%nod_grp) ! ! Construct element group call allocate_sph_ele_grp_flag call count_sph_local_ele_group(group%ele_grp) ! call allocate_grp_type_num(group%ele_grp) call count_sph_local_ele_grp_item(ip_r, ip_t, group%ele_grp) ! call s_cal_total_and_stacks(group%ele_grp%num_grp, & & group%ele_grp%nitem_grp, izero, group%ele_grp%istack_grp, & & group%ele_grp%num_item) ! call allocate_grp_type_item(group%ele_grp) call set_sph_local_ele_grp_item(ip_r, ip_t, group%ele_grp) ! call deallocate_sph_ele_grp_flag ! ! Construct surf group call count_sph_local_surf_group(group%surf_grp) ! call allocate_sf_grp_type_num(group%surf_grp) call count_sph_local_surf_grp_item(ip_r, ip_t, group%surf_grp) ! call s_cal_total_and_stacks(group%surf_grp%num_grp, & & group%surf_grp%nitem_grp, izero, group%surf_grp%istack_grp, & & group%surf_grp%num_item) ! call allocate_sf_grp_type_item(group%surf_grp) call set_sph_local_surf_grp_item(ip_r, ip_t, group%surf_grp) ! end subroutine const_FEM_groups_for_sph ! ! ----------------------------------------------------------------------- ! subroutine const_nod_comm_table_for_sph(ip_rank, ip_r, ip_t, & & nod_comm) ! use t_comm_table use m_sph_mesh_1d_connect use const_comm_tbl_4_sph_mesh ! integer(kind = kint), intent(in) :: ip_rank, ip_r, ip_t type(communication_table), intent(inout) :: nod_comm ! ! Count subdomain to communicate call count_neib_4_sph_mesh(ip_rank, ip_r, ip_t, nod_comm) call count_neib_4_sph_center_mesh(ip_rank, ip_r, ip_t, nod_comm) ! call allocate_type_comm_tbl_num(nod_comm) ! ! Set subdomain ID to communicate call set_neib_4_sph_mesh(ip_rank, ip_r, ip_t, nod_comm) call set_neib_4_sph_center_mesh(ip_rank, ip_r, ip_t, nod_comm) ! ! Count number of nodes to communicate call count_import_4_sph_mesh(ip_r, ip_t, nod_comm) call count_export_4_sph_mesh(ip_r, ip_t, nod_comm) ! ! call allocate_type_import_item(nod_comm) call allocate_type_export_item(nod_comm) call allocate_1d_comm_tbl_4_sph(nod_comm%ntot_import, & & nod_comm%ntot_export) ! ! set node ID to communicate call set_import_rtp_sph_mesh(ip_r, ip_t, nod_comm) call set_export_rtp_sph_mesh(ip_r, ip_t, nod_comm) ! call deallocate_1d_comm_tbl_4_sph ! end subroutine const_nod_comm_table_for_sph ! ! ----------------------------------------------------------------------- ! end module set_FEM_mesh_4_sph
gpl-3.0
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/slatps.f
24
24381
*> \brief \b SLATPS solves a triangular system of equations with the matrix held in packed storage. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download SLATPS + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slatps.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slatps.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slatps.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE SLATPS( UPLO, TRANS, DIAG, NORMIN, N, AP, X, SCALE, * CNORM, INFO ) * * .. Scalar Arguments .. * CHARACTER DIAG, NORMIN, TRANS, UPLO * INTEGER INFO, N * REAL SCALE * .. * .. Array Arguments .. * REAL AP( * ), CNORM( * ), X( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> SLATPS solves one of the triangular systems *> *> A *x = s*b or A**T*x = s*b *> *> with scaling to prevent overflow, where A is an upper or lower *> triangular matrix stored in packed form. Here A**T denotes the *> transpose of A, x and b are n-element vectors, and s is a scaling *> factor, usually less than or equal to 1, chosen so that the *> components of x will be less than the overflow threshold. If the *> unscaled problem will not cause overflow, the Level 2 BLAS routine *> STPSV is called. If the matrix A is singular (A(j,j) = 0 for some j), *> then s is set to 0 and a non-trivial solution to A*x = 0 is returned. *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> Specifies whether the matrix A is upper or lower triangular. *> = 'U': Upper triangular *> = 'L': Lower triangular *> \endverbatim *> *> \param[in] TRANS *> \verbatim *> TRANS is CHARACTER*1 *> Specifies the operation applied to A. *> = 'N': Solve A * x = s*b (No transpose) *> = 'T': Solve A**T* x = s*b (Transpose) *> = 'C': Solve A**T* x = s*b (Conjugate transpose = Transpose) *> \endverbatim *> *> \param[in] DIAG *> \verbatim *> DIAG is CHARACTER*1 *> Specifies whether or not the matrix A is unit triangular. *> = 'N': Non-unit triangular *> = 'U': Unit triangular *> \endverbatim *> *> \param[in] NORMIN *> \verbatim *> NORMIN is CHARACTER*1 *> Specifies whether CNORM has been set or not. *> = 'Y': CNORM contains the column norms on entry *> = 'N': CNORM is not set on entry. On exit, the norms will *> be computed and stored in CNORM. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the matrix A. N >= 0. *> \endverbatim *> *> \param[in] AP *> \verbatim *> AP is REAL array, dimension (N*(N+1)/2) *> The upper or lower triangular matrix A, packed columnwise in *> a linear array. The j-th column of A is stored in the array *> AP as follows: *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; *> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. *> \endverbatim *> *> \param[in,out] X *> \verbatim *> X is REAL array, dimension (N) *> On entry, the right hand side b of the triangular system. *> On exit, X is overwritten by the solution vector x. *> \endverbatim *> *> \param[out] SCALE *> \verbatim *> SCALE is REAL *> The scaling factor s for the triangular system *> A * x = s*b or A**T* x = s*b. *> If SCALE = 0, the matrix A is singular or badly scaled, and *> the vector x is an exact or approximate solution to A*x = 0. *> \endverbatim *> *> \param[in,out] CNORM *> \verbatim *> CNORM is REAL array, dimension (N) *> *> If NORMIN = 'Y', CNORM is an input argument and CNORM(j) *> contains the norm of the off-diagonal part of the j-th column *> of A. If TRANS = 'N', CNORM(j) must be greater than or equal *> to the infinity-norm, and if TRANS = 'T' or 'C', CNORM(j) *> must be greater than or equal to the 1-norm. *> *> If NORMIN = 'N', CNORM is an output argument and CNORM(j) *> returns the 1-norm of the offdiagonal part of the j-th column *> of A. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -k, the k-th argument had an illegal value *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup realOTHERauxiliary * *> \par Further Details: * ===================== *> *> \verbatim *> *> A rough bound on x is computed; if that is less than overflow, STPSV *> is called, otherwise, specific code is used which checks for possible *> overflow or divide-by-zero at every operation. *> *> A columnwise scheme is used for solving A*x = b. The basic algorithm *> if A is lower triangular is *> *> x[1:n] := b[1:n] *> for j = 1, ..., n *> x(j) := x(j) / A(j,j) *> x[j+1:n] := x[j+1:n] - x(j) * A[j+1:n,j] *> end *> *> Define bounds on the components of x after j iterations of the loop: *> M(j) = bound on x[1:j] *> G(j) = bound on x[j+1:n] *> Initially, let M(0) = 0 and G(0) = max{x(i), i=1,...,n}. *> *> Then for iteration j+1 we have *> M(j+1) <= G(j) / | A(j+1,j+1) | *> G(j+1) <= G(j) + M(j+1) * | A[j+2:n,j+1] | *> <= G(j) ( 1 + CNORM(j+1) / | A(j+1,j+1) | ) *> *> where CNORM(j+1) is greater than or equal to the infinity-norm of *> column j+1 of A, not counting the diagonal. Hence *> *> G(j) <= G(0) product ( 1 + CNORM(i) / | A(i,i) | ) *> 1<=i<=j *> and *> *> |x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + CNORM(i) / |A(i,i)| ) *> 1<=i< j *> *> Since |x(j)| <= M(j), we use the Level 2 BLAS routine STPSV if the *> reciprocal of the largest M(j), j=1,..,n, is larger than *> max(underflow, 1/overflow). *> *> The bound on x(j) is also used to determine when a step in the *> columnwise method can be performed without fear of overflow. If *> the computed bound is greater than a large constant, x is scaled to *> prevent overflow, but if the bound overflows, x is set to 0, x(j) to *> 1, and scale to 0, and a non-trivial solution to A*x = 0 is found. *> *> Similarly, a row-wise scheme is used to solve A**T*x = b. The basic *> algorithm for A upper triangular is *> *> for j = 1, ..., n *> x(j) := ( b(j) - A[1:j-1,j]**T * x[1:j-1] ) / A(j,j) *> end *> *> We simultaneously compute two bounds *> G(j) = bound on ( b(i) - A[1:i-1,i]**T * x[1:i-1] ), 1<=i<=j *> M(j) = bound on x(i), 1<=i<=j *> *> The initial values are G(0) = 0, M(0) = max{b(i), i=1,..,n}, and we *> add the constraint G(j) >= G(j-1) and M(j) >= M(j-1) for j >= 1. *> Then the bound on x(j) is *> *> M(j) <= M(j-1) * ( 1 + CNORM(j) ) / | A(j,j) | *> *> <= M(0) * product ( ( 1 + CNORM(i) ) / |A(i,i)| ) *> 1<=i<=j *> *> and we can safely call STPSV if 1/M(n) and 1/G(n) are both greater *> than max(underflow, 1/overflow). *> \endverbatim *> * ===================================================================== SUBROUTINE SLATPS( UPLO, TRANS, DIAG, NORMIN, N, AP, X, SCALE, $ CNORM, INFO ) * * -- LAPACK auxiliary routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. CHARACTER DIAG, NORMIN, TRANS, UPLO INTEGER INFO, N REAL SCALE * .. * .. Array Arguments .. REAL AP( * ), CNORM( * ), X( * ) * .. * * ===================================================================== * * .. Parameters .. REAL ZERO, HALF, ONE PARAMETER ( ZERO = 0.0E+0, HALF = 0.5E+0, ONE = 1.0E+0 ) * .. * .. Local Scalars .. LOGICAL NOTRAN, NOUNIT, UPPER INTEGER I, IMAX, IP, J, JFIRST, JINC, JLAST, JLEN REAL BIGNUM, GROW, REC, SMLNUM, SUMJ, TJJ, TJJS, $ TMAX, TSCAL, USCAL, XBND, XJ, XMAX * .. * .. External Functions .. LOGICAL LSAME INTEGER ISAMAX REAL SASUM, SDOT, SLAMCH EXTERNAL LSAME, ISAMAX, SASUM, SDOT, SLAMCH * .. * .. External Subroutines .. EXTERNAL SAXPY, SSCAL, STPSV, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC ABS, MAX, MIN * .. * .. Executable Statements .. * INFO = 0 UPPER = LSAME( UPLO, 'U' ) NOTRAN = LSAME( TRANS, 'N' ) NOUNIT = LSAME( DIAG, 'N' ) * * Test the input parameters. * IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN INFO = -1 ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT. $ LSAME( TRANS, 'C' ) ) THEN INFO = -2 ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN INFO = -3 ELSE IF( .NOT.LSAME( NORMIN, 'Y' ) .AND. .NOT. $ LSAME( NORMIN, 'N' ) ) THEN INFO = -4 ELSE IF( N.LT.0 ) THEN INFO = -5 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'SLATPS', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * * Determine machine dependent parameters to control overflow. * SMLNUM = SLAMCH( 'Safe minimum' ) / SLAMCH( 'Precision' ) BIGNUM = ONE / SMLNUM SCALE = ONE * IF( LSAME( NORMIN, 'N' ) ) THEN * * Compute the 1-norm of each column, not including the diagonal. * IF( UPPER ) THEN * * A is upper triangular. * IP = 1 DO 10 J = 1, N CNORM( J ) = SASUM( J-1, AP( IP ), 1 ) IP = IP + J 10 CONTINUE ELSE * * A is lower triangular. * IP = 1 DO 20 J = 1, N - 1 CNORM( J ) = SASUM( N-J, AP( IP+1 ), 1 ) IP = IP + N - J + 1 20 CONTINUE CNORM( N ) = ZERO END IF END IF * * Scale the column norms by TSCAL if the maximum element in CNORM is * greater than BIGNUM. * IMAX = ISAMAX( N, CNORM, 1 ) TMAX = CNORM( IMAX ) IF( TMAX.LE.BIGNUM ) THEN TSCAL = ONE ELSE TSCAL = ONE / ( SMLNUM*TMAX ) CALL SSCAL( N, TSCAL, CNORM, 1 ) END IF * * Compute a bound on the computed solution vector to see if the * Level 2 BLAS routine STPSV can be used. * J = ISAMAX( N, X, 1 ) XMAX = ABS( X( J ) ) XBND = XMAX IF( NOTRAN ) THEN * * Compute the growth in A * x = b. * IF( UPPER ) THEN JFIRST = N JLAST = 1 JINC = -1 ELSE JFIRST = 1 JLAST = N JINC = 1 END IF * IF( TSCAL.NE.ONE ) THEN GROW = ZERO GO TO 50 END IF * IF( NOUNIT ) THEN * * A is non-unit triangular. * * Compute GROW = 1/G(j) and XBND = 1/M(j). * Initially, G(0) = max{x(i), i=1,...,n}. * GROW = ONE / MAX( XBND, SMLNUM ) XBND = GROW IP = JFIRST*( JFIRST+1 ) / 2 JLEN = N DO 30 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 50 * * M(j) = G(j-1) / abs(A(j,j)) * TJJ = ABS( AP( IP ) ) XBND = MIN( XBND, MIN( ONE, TJJ )*GROW ) IF( TJJ+CNORM( J ).GE.SMLNUM ) THEN * * G(j) = G(j-1)*( 1 + CNORM(j) / abs(A(j,j)) ) * GROW = GROW*( TJJ / ( TJJ+CNORM( J ) ) ) ELSE * * G(j) could overflow, set GROW to 0. * GROW = ZERO END IF IP = IP + JINC*JLEN JLEN = JLEN - 1 30 CONTINUE GROW = XBND ELSE * * A is unit triangular. * * Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}. * GROW = MIN( ONE, ONE / MAX( XBND, SMLNUM ) ) DO 40 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 50 * * G(j) = G(j-1)*( 1 + CNORM(j) ) * GROW = GROW*( ONE / ( ONE+CNORM( J ) ) ) 40 CONTINUE END IF 50 CONTINUE * ELSE * * Compute the growth in A**T * x = b. * IF( UPPER ) THEN JFIRST = 1 JLAST = N JINC = 1 ELSE JFIRST = N JLAST = 1 JINC = -1 END IF * IF( TSCAL.NE.ONE ) THEN GROW = ZERO GO TO 80 END IF * IF( NOUNIT ) THEN * * A is non-unit triangular. * * Compute GROW = 1/G(j) and XBND = 1/M(j). * Initially, M(0) = max{x(i), i=1,...,n}. * GROW = ONE / MAX( XBND, SMLNUM ) XBND = GROW IP = JFIRST*( JFIRST+1 ) / 2 JLEN = 1 DO 60 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 80 * * G(j) = max( G(j-1), M(j-1)*( 1 + CNORM(j) ) ) * XJ = ONE + CNORM( J ) GROW = MIN( GROW, XBND / XJ ) * * M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j)) * TJJ = ABS( AP( IP ) ) IF( XJ.GT.TJJ ) $ XBND = XBND*( TJJ / XJ ) JLEN = JLEN + 1 IP = IP + JINC*JLEN 60 CONTINUE GROW = MIN( GROW, XBND ) ELSE * * A is unit triangular. * * Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}. * GROW = MIN( ONE, ONE / MAX( XBND, SMLNUM ) ) DO 70 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 80 * * G(j) = ( 1 + CNORM(j) )*G(j-1) * XJ = ONE + CNORM( J ) GROW = GROW / XJ 70 CONTINUE END IF 80 CONTINUE END IF * IF( ( GROW*TSCAL ).GT.SMLNUM ) THEN * * Use the Level 2 BLAS solve if the reciprocal of the bound on * elements of X is not too small. * CALL STPSV( UPLO, TRANS, DIAG, N, AP, X, 1 ) ELSE * * Use a Level 1 BLAS solve, scaling intermediate results. * IF( XMAX.GT.BIGNUM ) THEN * * Scale X so that its components are less than or equal to * BIGNUM in absolute value. * SCALE = BIGNUM / XMAX CALL SSCAL( N, SCALE, X, 1 ) XMAX = BIGNUM END IF * IF( NOTRAN ) THEN * * Solve A * x = b * IP = JFIRST*( JFIRST+1 ) / 2 DO 100 J = JFIRST, JLAST, JINC * * Compute x(j) = b(j) / A(j,j), scaling x if necessary. * XJ = ABS( X( J ) ) IF( NOUNIT ) THEN TJJS = AP( IP )*TSCAL ELSE TJJS = TSCAL IF( TSCAL.EQ.ONE ) $ GO TO 95 END IF TJJ = ABS( TJJS ) IF( TJJ.GT.SMLNUM ) THEN * * abs(A(j,j)) > SMLNUM: * IF( TJJ.LT.ONE ) THEN IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale x by 1/b(j). * REC = ONE / XJ CALL SSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF END IF X( J ) = X( J ) / TJJS XJ = ABS( X( J ) ) ELSE IF( TJJ.GT.ZERO ) THEN * * 0 < abs(A(j,j)) <= SMLNUM: * IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM * to avoid overflow when dividing by A(j,j). * REC = ( TJJ*BIGNUM ) / XJ IF( CNORM( J ).GT.ONE ) THEN * * Scale by 1/CNORM(j) to avoid overflow when * multiplying x(j) times column j. * REC = REC / CNORM( J ) END IF CALL SSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF X( J ) = X( J ) / TJJS XJ = ABS( X( J ) ) ELSE * * A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and * scale = 0, and compute a solution to A*x = 0. * DO 90 I = 1, N X( I ) = ZERO 90 CONTINUE X( J ) = ONE XJ = ONE SCALE = ZERO XMAX = ZERO END IF 95 CONTINUE * * Scale x if necessary to avoid overflow when adding a * multiple of column j of A. * IF( XJ.GT.ONE ) THEN REC = ONE / XJ IF( CNORM( J ).GT.( BIGNUM-XMAX )*REC ) THEN * * Scale x by 1/(2*abs(x(j))). * REC = REC*HALF CALL SSCAL( N, REC, X, 1 ) SCALE = SCALE*REC END IF ELSE IF( XJ*CNORM( J ).GT.( BIGNUM-XMAX ) ) THEN * * Scale x by 1/2. * CALL SSCAL( N, HALF, X, 1 ) SCALE = SCALE*HALF END IF * IF( UPPER ) THEN IF( J.GT.1 ) THEN * * Compute the update * x(1:j-1) := x(1:j-1) - x(j) * A(1:j-1,j) * CALL SAXPY( J-1, -X( J )*TSCAL, AP( IP-J+1 ), 1, X, $ 1 ) I = ISAMAX( J-1, X, 1 ) XMAX = ABS( X( I ) ) END IF IP = IP - J ELSE IF( J.LT.N ) THEN * * Compute the update * x(j+1:n) := x(j+1:n) - x(j) * A(j+1:n,j) * CALL SAXPY( N-J, -X( J )*TSCAL, AP( IP+1 ), 1, $ X( J+1 ), 1 ) I = J + ISAMAX( N-J, X( J+1 ), 1 ) XMAX = ABS( X( I ) ) END IF IP = IP + N - J + 1 END IF 100 CONTINUE * ELSE * * Solve A**T * x = b * IP = JFIRST*( JFIRST+1 ) / 2 JLEN = 1 DO 140 J = JFIRST, JLAST, JINC * * Compute x(j) = b(j) - sum A(k,j)*x(k). * k<>j * XJ = ABS( X( J ) ) USCAL = TSCAL REC = ONE / MAX( XMAX, ONE ) IF( CNORM( J ).GT.( BIGNUM-XJ )*REC ) THEN * * If x(j) could overflow, scale x by 1/(2*XMAX). * REC = REC*HALF IF( NOUNIT ) THEN TJJS = AP( IP )*TSCAL ELSE TJJS = TSCAL END IF TJJ = ABS( TJJS ) IF( TJJ.GT.ONE ) THEN * * Divide by A(j,j) when scaling x if A(j,j) > 1. * REC = MIN( ONE, REC*TJJ ) USCAL = USCAL / TJJS END IF IF( REC.LT.ONE ) THEN CALL SSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF END IF * SUMJ = ZERO IF( USCAL.EQ.ONE ) THEN * * If the scaling needed for A in the dot product is 1, * call SDOT to perform the dot product. * IF( UPPER ) THEN SUMJ = SDOT( J-1, AP( IP-J+1 ), 1, X, 1 ) ELSE IF( J.LT.N ) THEN SUMJ = SDOT( N-J, AP( IP+1 ), 1, X( J+1 ), 1 ) END IF ELSE * * Otherwise, use in-line code for the dot product. * IF( UPPER ) THEN DO 110 I = 1, J - 1 SUMJ = SUMJ + ( AP( IP-J+I )*USCAL )*X( I ) 110 CONTINUE ELSE IF( J.LT.N ) THEN DO 120 I = 1, N - J SUMJ = SUMJ + ( AP( IP+I )*USCAL )*X( J+I ) 120 CONTINUE END IF END IF * IF( USCAL.EQ.TSCAL ) THEN * * Compute x(j) := ( x(j) - sumj ) / A(j,j) if 1/A(j,j) * was not used to scale the dotproduct. * X( J ) = X( J ) - SUMJ XJ = ABS( X( J ) ) IF( NOUNIT ) THEN * * Compute x(j) = x(j) / A(j,j), scaling if necessary. * TJJS = AP( IP )*TSCAL ELSE TJJS = TSCAL IF( TSCAL.EQ.ONE ) $ GO TO 135 END IF TJJ = ABS( TJJS ) IF( TJJ.GT.SMLNUM ) THEN * * abs(A(j,j)) > SMLNUM: * IF( TJJ.LT.ONE ) THEN IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale X by 1/abs(x(j)). * REC = ONE / XJ CALL SSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF END IF X( J ) = X( J ) / TJJS ELSE IF( TJJ.GT.ZERO ) THEN * * 0 < abs(A(j,j)) <= SMLNUM: * IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. * REC = ( TJJ*BIGNUM ) / XJ CALL SSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF X( J ) = X( J ) / TJJS ELSE * * A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and * scale = 0, and compute a solution to A**T*x = 0. * DO 130 I = 1, N X( I ) = ZERO 130 CONTINUE X( J ) = ONE SCALE = ZERO XMAX = ZERO END IF 135 CONTINUE ELSE * * Compute x(j) := x(j) / A(j,j) - sumj if the dot * product has already been divided by 1/A(j,j). * X( J ) = X( J ) / TJJS - SUMJ END IF XMAX = MAX( XMAX, ABS( X( J ) ) ) JLEN = JLEN + 1 IP = IP + JINC*JLEN 140 CONTINUE END IF SCALE = SCALE / TSCAL END IF * * Scale the column norms by 1/TSCAL for return. * IF( TSCAL.NE.ONE ) THEN CALL SSCAL( N, ONE / TSCAL, CNORM, 1 ) END IF * RETURN * * End of SLATPS * END
bsd-3-clause
nvarini/espresso_iohpc
PW/src/backup/sum_band.f90
1
43010
! ! Copyright (C) 2001-2015 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 sum_band() !---------------------------------------------------------------------------- ! ! ... Calculates the symmetrized charge density and related quantities ! ... Also computes the occupations and the sum of occupied eigenvalues. ! USE kinds, ONLY : DP USE ener, ONLY : eband USE control_flags, ONLY : diago_full_acc, gamma_only, tqr, lxdm USE cell_base, ONLY : at, bg, omega, tpiba USE ions_base, ONLY : nat, ntyp => nsp, ityp USE fft_base, ONLY : dfftp, dffts USE fft_interfaces, ONLY : fwfft, invfft USE gvect, ONLY : ngm, g, nl, nlm USE gvecs, ONLY : nls, nlsm, doublegrid USE klist, ONLY : nks, nkstot, wk, xk, ngk, igk_k USE fixed_occ, ONLY : one_atom_occupations USE ldaU, ONLY : lda_plus_U USE lsda_mod, ONLY : lsda, nspin, current_spin, isk USE scf, ONLY : rho USE symme, ONLY : sym_rho USE io_files, ONLY : iunwfc, nwordwfc USE buffers, ONLY : get_buffer USE uspp, ONLY : nkb, vkb, becsum, nhtol, nhtoj, indv, okvan USE uspp_param, ONLY : upf, nh, nhm USE wavefunctions_module, ONLY : evc, psic, psic_nc USE noncollin_module, ONLY : noncolin, npol, nspin_mag USE spin_orb, ONLY : lspinorb, domag, fcoef USE wvfct, ONLY : nbnd, npwx, wg, et, btype USE mp_pools, ONLY : inter_pool_comm USE mp_bands, ONLY : inter_bgrp_comm, intra_bgrp_comm, set_bgrp_indices, nbgrp USE mp, ONLY : mp_sum USE funct, ONLY : dft_is_meta USE paw_symmetry, ONLY : PAW_symmetrize USE paw_variables, ONLY : okpaw USE becmod, ONLY : allocate_bec_type, deallocate_bec_type, & becp #if defined __HDF5 USE buffers, ONLY : get_buffer_hdf5 USE hdf5_qe, ONLY : evc_hdf5 USE mp_world, ONLY : mpime #endif ! IMPLICIT NONE ! ! ... local variables ! INTEGER :: ir, &! counter on 3D r points is, &! counter on spin polarizations ig, &! counter on g vectors ibnd, & ! counter on bands ik, &! counter on k points ibnd_start, ibnd_end, this_bgrp_nbnd ! first, last and number of band in this bgrp REAL (DP), ALLOCATABLE :: kplusg (:) ! ! CALL start_clock( 'sum_band' ) ! becsum(:,:,:) = 0.D0 rho%of_r(:,:) = 0.D0 rho%of_g(:,:) = (0.D0, 0.D0) if ( dft_is_meta() .OR. lxdm ) then rho%kin_r(:,:) = 0.D0 rho%kin_g(:,:) = (0.D0, 0.D0) end if eband = 0.D0 ! ! ... calculates weights of Kohn-Sham orbitals used in calculation of rho ! CALL weights ( ) ! IF (one_atom_occupations) CALL new_evc() ! IF ( diago_full_acc ) THEN ! ! ... for diagonalization purposes all the bands are considered occupied ! btype(:,:) = 1 ! ELSE ! ! ... for diagonalization purposes a band is considered empty when its ! ... occupation is less than 1.0 % ! btype(:,:) = 1 FORALL( ik = 1:nks, wk(ik) > 0.D0 ) WHERE( wg(:,ik) / wk(ik) < 0.01D0 ) btype(:,ik) = 0 END FORALL ! END IF ! ! ... Needed for LDA+U: compute occupations of Hubbard states ! IF (lda_plus_u) THEN IF(noncolin) THEN CALL new_ns_nc(rho%ns_nc) ELSE CALL new_ns(rho%ns) ENDIF ENDIF ! call set_bgrp_indices ( nbnd, ibnd_start, ibnd_end ) this_bgrp_nbnd = ibnd_end - ibnd_start + 1 ! ! ... Allocate (and later deallocate) arrays needed in specific cases ! IF ( okvan ) CALL allocate_bec_type (nkb,nbnd, becp,intra_bgrp_comm) IF (dft_is_meta() .OR. lxdm) ALLOCATE (kplusg(npwx)) ! ! ... specialized routines are called to sum at Gamma or for each k point ! ... the contribution of the wavefunctions to the charge ! IF ( gamma_only ) THEN ! CALL sum_band_gamma() ! ELSE ! CALL sum_band_k() ! END IF ! IF (dft_is_meta() .OR. lxdm) DEALLOCATE (kplusg) ! IF( okpaw ) THEN rho%bec(:,:,:) = becsum(:,:,:) ! becsum is filled in sum_band_{k|gamma} ! rho%bec has to be recollected and symmetrized, becsum must not, otherwise ! it will break stress routines. CALL mp_sum(rho%bec, inter_pool_comm ) call mp_sum(rho%bec, inter_bgrp_comm ) CALL PAW_symmetrize(rho%bec) ENDIF ! IF ( okvan ) CALL deallocate_bec_type ( becp ) ! ! ... If a double grid is used, interpolate onto the fine grid ! IF ( doublegrid ) THEN ! DO is = 1, nspin ! CALL interpolate( rho%of_r(1,is), rho%of_r(1,is), 1 ) if (dft_is_meta() .OR. lxdm) CALL interpolate(rho%kin_r(1,is),rho%kin_r(1,is),1) ! END DO ! END IF ! ! ... Here we add the Ultrasoft contribution to the charge ! CALL addusdens(rho%of_r(:,:)) ! okvan is checked inside the routine ! IF( okvan ) THEN ! bgrp_parallelization is done here but not in subsequent routines ! (in particular stress routines uses becsum). collect it across bgrp call mp_sum(becsum, inter_bgrp_comm ) ENDIF IF ( noncolin .AND. .NOT. domag ) rho%of_r(:,2:4)=0.D0 ! CALL mp_sum( eband, inter_pool_comm ) CALL mp_sum( eband, inter_bgrp_comm ) ! ! ... reduce charge density across pools ! CALL mp_sum( rho%of_r, inter_pool_comm ) CALL mp_sum( rho%of_r, inter_bgrp_comm ) if (dft_is_meta() .OR. lxdm) CALL mp_sum( rho%kin_r, inter_pool_comm ) if (dft_is_meta() .OR. lxdm) CALL mp_sum( rho%kin_r, inter_bgrp_comm ) ! ! ... bring the (unsymmetrized) rho(r) to G-space (use psic as work array) ! DO is = 1, nspin psic(:) = rho%of_r(:,is) CALL fwfft ('Dense', psic, dfftp) rho%of_g(:,is) = psic(nl(:)) END DO ! ! ... symmetrize rho(G) ! CALL sym_rho ( nspin_mag, rho%of_g ) ! ! ... same for rho_kin(G) ! IF ( dft_is_meta() .OR. lxdm) THEN DO is = 1, nspin psic(:) = rho%kin_r(:,is) CALL fwfft ('Dense', psic, dfftp) rho%kin_g(:,is) = psic(nl(:)) END DO IF (.NOT. gamma_only) CALL sym_rho( nspin, rho%kin_g ) END IF ! ! ... synchronize rho%of_r to the calculated rho%of_g (use psic as work array) ! DO is = 1, nspin_mag ! psic(:) = ( 0.D0, 0.D0 ) psic(nl(:)) = rho%of_g(:,is) IF ( gamma_only ) psic(nlm(:)) = CONJG( rho%of_g(:,is) ) CALL invfft ('Dense', psic, dfftp) rho%of_r(:,is) = psic(:) ! END DO ! ! ... the same for rho%kin_r and rho%kin_g ! IF ( dft_is_meta() .OR. lxdm) THEN DO is = 1, nspin ! psic(:) = ( 0.D0, 0.D0 ) psic(nl(:)) = rho%kin_g(:,is) IF ( gamma_only ) psic(nlm(:)) = CONJG( rho%kin_g(:,is) ) CALL invfft ('Dense', psic, dfftp) rho%kin_r(:,is) = psic(:) ! END DO END IF ! CALL stop_clock( 'sum_band' ) ! RETURN ! CONTAINS ! ! ... internal procedures ! !----------------------------------------------------------------------- SUBROUTINE sum_band_gamma() !----------------------------------------------------------------------- ! ! ... gamma version ! USE becmod, ONLY : becp USE mp_bands, ONLY : me_bgrp USE mp, ONLY : mp_sum, mp_get_comm_null ! IMPLICIT NONE ! ! ... local variables ! REAL(DP) :: w1, w2 ! weights INTEGER :: npw, idx, ioff, incr, v_siz, j COMPLEX(DP), ALLOCATABLE :: tg_psi(:) REAL(DP), ALLOCATABLE :: tg_rho(:) LOGICAL :: use_tg ! ! ! ... here we sum for each k point the contribution ! ... of the wavefunctions to the charge ! use_tg = dffts%have_task_groups dffts%have_task_groups = ( dffts%have_task_groups ) .AND. & ( this_bgrp_nbnd >= dffts%nogrp ) ! incr = 2 ! IF( dffts%have_task_groups ) THEN ! IF( dft_is_meta() .OR. lxdm) & CALL errore( ' sum_band ', ' task groups with meta dft, not yet implemented ', 1 ) ! v_siz = dffts%tg_nnr * dffts%nogrp ! ALLOCATE( tg_psi( v_siz ) ) ALLOCATE( tg_rho( v_siz ) ) ! incr = 2 * dffts%nogrp ! END IF ! k_loop: DO ik = 1, nks ! IF( dffts%have_task_groups ) tg_rho = 0.0_DP IF ( lsda ) current_spin = isk(ik) ! npw = ngk(ik) ! IF ( nks > 1 ) THEN #if defined __HDF5 !CALL get_buffer_hdf5 ( evc_hdf5, evc, ik) CALL get_buffer ( evc, nwordwfc, iunwfc, ik ) #else CALL get_buffer ( evc, nwordwfc, iunwfc, ik ) #endif ENDIF ! IF ( nkb > 0 ) & CALL init_us_2( npw, igk_k(1,ik), xk(1,ik), vkb ) ! ! ... here we compute the band energy: the sum of the eigenvalues ! DO ibnd = ibnd_start, ibnd_end ! ! ... the sum of eband and demet is the integral for ! ... e < ef of e n(e) which reduces for degauss=0 to the sum of ! ... the eigenvalues. ! eband = eband + et(ibnd,ik) * wg(ibnd,ik) ! END DO ! DO ibnd = ibnd_start, ibnd_end, incr ! IF( dffts%have_task_groups ) THEN ! tg_psi(:) = ( 0.D0, 0.D0 ) ioff = 0 ! DO idx = 1, 2*dffts%nogrp, 2 ! ! ... 2*dffts%nogrp ffts at the same time ! IF( idx + ibnd - 1 < ibnd_end ) THEN DO j = 1, npw tg_psi(nls (j)+ioff)= evc(j,idx+ibnd-1)+& (0.0d0,1.d0) * evc(j,idx+ibnd) tg_psi(nlsm(j)+ioff)=CONJG(evc(j,idx+ibnd-1) -& (0.0d0,1.d0) * evc(j,idx+ibnd) ) END DO ELSE IF( idx + ibnd - 1 == ibnd_end ) THEN DO j = 1, npw tg_psi(nls (j)+ioff)= evc(j,idx+ibnd-1) tg_psi(nlsm(j)+ioff)=CONJG( evc(j,idx+ibnd-1) ) END DO END IF ioff = ioff + dffts%tg_nnr END DO ! CALL invfft ('Wave', tg_psi, dffts) ! ! Now the first proc of the group holds the first two bands ! of the 2*dffts%nogrp bands that we are processing at the same time, ! the second proc. holds the third and fourth band ! and so on ! ! Compute the proper factor for each band ! DO idx = 1, dffts%nogrp IF( dffts%nolist( idx ) == me_bgrp ) EXIT END DO ! ! Remember two bands are packed in a single array : ! proc 0 has bands ibnd and ibnd+1 ! proc 1 has bands ibnd+2 and ibnd+3 ! .... ! idx = 2 * idx - 1 ! IF( idx + ibnd - 1 < ibnd_end ) THEN w1 = wg( idx + ibnd - 1, ik) / omega w2 = wg( idx + ibnd , ik) / omega ELSE IF( idx + ibnd - 1 == ibnd_end ) THEN w1 = wg( idx + ibnd - 1, ik) / omega w2 = w1 ELSE w1 = 0.0d0 w2 = w1 END IF ! CALL get_rho_gamma(tg_rho, dffts%tg_npp( me_bgrp + 1 ) * & dffts%nr1x * dffts%nr2x, w1, w2, tg_psi) ! ELSE ! psic(:) = ( 0.D0, 0.D0 ) ! IF ( ibnd < ibnd_end ) THEN ! ! ... two ffts at the same time ! psic(nls(1:npw)) = evc(1:npw,ibnd) + & ( 0.D0, 1.D0 ) * evc(1:npw,ibnd+1) psic(nlsm(1:npw)) = CONJG( evc(1:npw,ibnd) - & ( 0.D0, 1.D0 ) * evc(1:npw,ibnd+1) ) ! ELSE ! psic(nls (1:npw)) = evc(1:npw,ibnd) psic(nlsm(1:npw)) = CONJG( evc(1:npw,ibnd) ) ! END IF ! CALL invfft ('Wave', psic, dffts) ! w1 = wg(ibnd,ik) / omega ! ! ... increment the charge density ... ! IF ( ibnd < ibnd_end ) THEN ! ! ... two ffts at the same time ! w2 = wg(ibnd+1,ik) / omega ! ELSE ! w2 = w1 ! END IF ! CALL get_rho_gamma(rho%of_r(:,current_spin), dffts%nnr, w1, w2, psic) ! END IF ! IF (dft_is_meta() .OR. lxdm) THEN DO j=1,3 psic(:) = ( 0.D0, 0.D0 ) ! kplusg (1:npw) = (xk(j,ik)+g(j,1:npw)) * tpiba IF ( ibnd < ibnd_end ) THEN ! ... two ffts at the same time psic(nls (1:npw))=CMPLX(0d0, kplusg(1:npw),kind=DP) * & ( evc(1:npw,ibnd) + & ( 0.D0, 1.D0 ) * evc(1:npw,ibnd+1) ) psic(nlsm(1:npw)) = CMPLX(0d0, -kplusg(1:npw),kind=DP) * & CONJG( evc(1:npw,ibnd) - & ( 0.D0, 1.D0 ) * evc(1:npw,ibnd+1) ) ELSE psic(nls(1:npw)) = CMPLX(0d0, kplusg(1:npw),kind=DP) * & evc(1:npw,ibnd) psic(nlsm(1:npw)) = CMPLX(0d0, -kplusg(1:npw),kind=DP) * & CONJG( evc(1:npw,ibnd) ) END IF ! CALL invfft ('Wave', psic, dffts) ! ! ... increment the kinetic energy density ... ! DO ir = 1, dffts%nnr rho%kin_r(ir,current_spin) = & rho%kin_r(ir,current_spin) + & w1 * DBLE( psic(ir) )**2 + & w2 * AIMAG( psic(ir) )**2 END DO ! END DO END IF ! ! END DO ! IF( dffts%have_task_groups ) THEN ! ! reduce the group charge ! CALL mp_sum( tg_rho, gid = dffts%ogrp_comm ) ! ioff = 0 DO idx = 1, dffts%nogrp IF( me_bgrp == dffts%nolist( idx ) ) EXIT ioff = ioff + dffts%nr1x * dffts%nr2x * dffts%npp( dffts%nolist( idx ) + 1 ) END DO ! ! copy the charge back to the processor location ! DO ir = 1, dffts%nnr rho%of_r(ir,current_spin) = rho%of_r(ir,current_spin) + tg_rho(ir+ioff) END DO END IF ! ! ... If we have a US pseudopotential we compute here the becsum term ! IF ( okvan ) CALL sum_bec ( ik, current_spin, ibnd_start,ibnd_end,this_bgrp_nbnd ) ! END DO k_loop ! ! ... with distributed <beta|psi>, sum over bands ! IF( okvan .AND. becp%comm /= mp_get_comm_null() ) CALL mp_sum( becsum, becp%comm ) ! IF( dffts%have_task_groups ) THEN DEALLOCATE( tg_psi ) DEALLOCATE( tg_rho ) END IF dffts%have_task_groups = use_tg ! RETURN ! END SUBROUTINE sum_band_gamma ! ! !----------------------------------------------------------------------- SUBROUTINE sum_band_k() !----------------------------------------------------------------------- ! ! ... k-points version ! USE mp_bands, ONLY : me_bgrp USE mp, ONLY : mp_sum USE mp_world, ONLY : mpime ! IMPLICIT NONE ! ! ... local variables ! REAL(DP) :: w1 ! weights INTEGER :: npw, ipol, na, np ! INTEGER :: idx, ioff, incr, v_siz, j COMPLEX(DP), ALLOCATABLE :: tg_psi(:), tg_psi_nc(:,:) REAL(DP), ALLOCATABLE :: tg_rho(:), tg_rho_nc(:,:) LOGICAL :: use_tg ! ! ... here we sum for each k point the contribution ! ... of the wavefunctions to the charge ! use_tg = dffts%have_task_groups dffts%have_task_groups = ( dffts%have_task_groups ) .AND. & ( this_bgrp_nbnd >= dffts%nogrp ) .AND. & ( .NOT. (dft_is_meta() .OR. lxdm) ) ! incr = 1 ! IF( dffts%have_task_groups ) THEN ! v_siz = dffts%tg_nnr * dffts%nogrp ! IF (noncolin) THEN ALLOCATE( tg_psi_nc( v_siz, npol ) ) ALLOCATE( tg_rho_nc( v_siz, nspin_mag ) ) ELSE ALLOCATE( tg_psi( v_siz ) ) ALLOCATE( tg_rho( v_siz ) ) ENDIF ! incr = dffts%nogrp ! END IF ! k_loop: DO ik = 1, nks ! IF( dffts%have_task_groups ) THEN IF (noncolin) THEN tg_rho_nc = 0.0_DP ELSE tg_rho = 0.0_DP ENDIF ENDIF IF ( lsda ) current_spin = isk(ik) npw = ngk (ik) ! IF ( nks > 1 ) THEN #if defined __HDF5 !CALL get_buffer_hdf5 ( evc_hdf5, evc, ik) CALL get_buffer ( evc, nwordwfc, iunwfc, ik ) #else CALL get_buffer ( evc, nwordwfc, iunwfc, ik ) #endif ENDIF ! IF ( nkb > 0 ) & CALL init_us_2( npw, igk_k(1,ik), xk(1,ik), vkb ) ! ! ... here we compute the band energy: the sum of the eigenvalues ! DO ibnd = ibnd_start, ibnd_end, incr ! IF( dffts%have_task_groups ) THEN DO idx = 1, dffts%nogrp IF( idx + ibnd - 1 <= ibnd_end ) eband = eband + et( idx + ibnd - 1, ik ) * wg( idx + ibnd - 1, ik ) END DO ELSE eband = eband + et( ibnd, ik ) * wg( ibnd, ik ) END IF ! ! ... the sum of eband and demet is the integral for e < ef of ! ... e n(e) which reduces for degauss=0 to the sum of the ! ... eigenvalues w1 = wg(ibnd,ik) / omega ! IF (noncolin) THEN IF( dffts%have_task_groups ) THEN ! tg_psi_nc = ( 0.D0, 0.D0 ) ! ioff = 0 ! DO idx = 1, dffts%nogrp ! ! ... dffts%nogrp ffts at the same time ! IF( idx + ibnd - 1 <= ibnd_end ) THEN DO j = 1, npw tg_psi_nc( nls(igk_k(j,ik) ) + ioff, 1 ) = & evc( j, idx+ibnd-1 ) tg_psi_nc( nls(igk_k(j,ik) ) + ioff, 2 ) = & evc( j+npwx, idx+ibnd-1 ) END DO END IF ioff = ioff + dffts%tg_nnr END DO ! CALL invfft ('Wave', tg_psi_nc(:,1), dffts) CALL invfft ('Wave', tg_psi_nc(:,2), dffts) ! ! Now the first proc of the group holds the first band ! of the dffts%nogrp bands that we are processing at the same time, ! the second proc. holds the second and so on ! ! Compute the proper factor for each band ! DO idx = 1, dffts%nogrp IF( dffts%nolist( idx ) == me_bgrp ) EXIT END DO ! ! Remember ! proc 0 has bands ibnd ! proc 1 has bands ibnd+1 ! .... ! IF( idx + ibnd - 1 <= ibnd_end ) THEN w1 = wg( idx + ibnd - 1, ik) / omega ELSE w1 = 0.0d0 END IF ! DO ipol=1,npol CALL get_rho(tg_rho_nc(:,1), dffts%tg_npp( me_bgrp + 1 ) & * dffts%nr1x * dffts%nr2x, w1, tg_psi_nc(:,ipol)) ENDDO ! IF (domag) CALL get_rho_domag(tg_rho_nc(:,:), & dffts%tg_npp( me_bgrp + 1 )*dffts%nr1x*dffts%nr2x, & w1, tg_psi_nc(:,:)) ! ELSE ! ! Noncollinear case without task groups ! psic_nc = (0.D0,0.D0) DO ig = 1, npw psic_nc(nls(igk_k(ig,ik)),1)=evc(ig ,ibnd) psic_nc(nls(igk_k(ig,ik)),2)=evc(ig+npwx,ibnd) END DO CALL invfft ('Wave', psic_nc(:,1), dffts) CALL invfft ('Wave', psic_nc(:,2), dffts) ! ! increment the charge density ... ! DO ipol=1,npol CALL get_rho(rho%of_r(:,1), dffts%nnr, w1, psic_nc(:,ipol)) END DO ! ! In this case, calculate also the three ! components of the magnetization (stored in rho%of_r(ir,2-4)) ! IF (domag) THEN CALL get_rho_domag(rho%of_r(:,:), dffts%nnr, w1, psic_nc(:,:)) ELSE rho%of_r(:,2:4)=0.0_DP END IF ! END IF ! ELSE ! IF( dffts%have_task_groups ) THEN ! !$omp parallel default(shared), private(j,ioff,idx) !$omp do DO j = 1, SIZE( tg_psi ) tg_psi(j) = ( 0.D0, 0.D0 ) END DO !$omp end do ! ioff = 0 ! DO idx = 1, dffts%nogrp ! ! ... dffts%nogrp ffts at the same time ! IF( idx + ibnd - 1 <= ibnd_end ) THEN !$omp do DO j = 1, npw tg_psi( nls(igk_k(j,ik))+ioff ) = evc(j,idx+ibnd-1) END DO !$omp end do END IF ioff = ioff + dffts%tg_nnr END DO !$omp end parallel ! CALL invfft ('Wave', tg_psi, dffts) ! ! Now the first proc of the group holds the first band ! of the dffts%nogrp bands that we are processing at the same time, ! the second proc. holds the second and so on ! ! Compute the proper factor for each band ! DO idx = 1, dffts%nogrp IF( dffts%nolist( idx ) == me_bgrp ) EXIT END DO ! ! Remember ! proc 0 has bands ibnd ! proc 1 has bands ibnd+1 ! .... ! IF( idx + ibnd - 1 <= ibnd_end ) THEN w1 = wg( idx + ibnd - 1, ik) / omega ELSE w1 = 0.0d0 END IF ! CALL get_rho(tg_rho, dffts%tg_npp( me_bgrp + 1 ) * dffts%nr1x * dffts%nr2x, w1, tg_psi) ! ELSE ! psic(:) = ( 0.D0, 0.D0 ) ! psic(nls(igk_k(1:npw,ik))) = evc(1:npw,ibnd) ! CALL invfft ('Wave', psic, dffts) ! ! ... increment the charge density ... ! CALL get_rho(rho%of_r(:,current_spin), dffts%nnr, w1, psic) END IF ! IF (dft_is_meta() .OR. lxdm) THEN DO j=1,3 psic(:) = ( 0.D0, 0.D0 ) ! kplusg (1:npw) = (xk(j,ik)+g(j,igk_k(1:npw,ik))) * tpiba psic(nls(igk_k(1:npw,ik)))=CMPLX(0d0,kplusg(1:npw),kind=DP) * & evc(1:npw,ibnd) ! CALL invfft ('Wave', psic, dffts) ! ! ... increment the kinetic energy density ... ! CALL get_rho(rho%kin_r(:,current_spin), dffts%nnr, w1, psic) END DO END IF ! END IF ! END DO ! IF( dffts%have_task_groups ) THEN ! ! reduce the group charge ! IF (noncolin) THEN CALL mp_sum( tg_rho_nc, gid = dffts%ogrp_comm ) ELSE CALL mp_sum( tg_rho, gid = dffts%ogrp_comm ) ENDIF ! ioff = 0 DO idx = 1, dffts%nogrp IF( me_bgrp == dffts%nolist( idx ) ) EXIT ioff = ioff + dffts%nr1x * dffts%nr2x * dffts%npp( dffts%nolist( idx ) + 1 ) END DO ! ! copy the charge back to the proper processor location ! IF (noncolin) THEN !$omp parallel do DO ir = 1, dffts%nnr rho%of_r(ir,1) = rho%of_r(ir,1) + & tg_rho_nc(ir+ioff,1) END DO !$omp end parallel do IF (domag) THEN !$omp parallel do DO ipol=2,4 DO ir = 1, dffts%nnr rho%of_r(ir,ipol) = rho%of_r(ir,ipol) + & tg_rho_nc(ir+ioff,ipol) END DO END DO !$omp end parallel do ENDIF ELSE !$omp parallel do DO ir = 1, dffts%nnr rho%of_r(ir,current_spin) = rho%of_r(ir,current_spin) + tg_rho(ir+ioff) END DO !$omp end parallel do END IF ! END IF ! ! ... If we have a US pseudopotential we compute here the becsum term ! IF ( okvan ) CALL sum_bec ( ik, current_spin, ibnd_start,ibnd_end,this_bgrp_nbnd ) ! END DO k_loop IF( dffts%have_task_groups ) THEN IF (noncolin) THEN DEALLOCATE( tg_psi_nc ) DEALLOCATE( tg_rho_nc ) ELSE DEALLOCATE( tg_psi ) DEALLOCATE( tg_rho ) END IF END IF dffts%have_task_groups = use_tg ! RETURN ! END SUBROUTINE sum_band_k ! ! SUBROUTINE get_rho(rho_loc, nrxxs_loc, w1_loc, psic_loc) IMPLICIT NONE INTEGER :: nrxxs_loc REAL(DP) :: rho_loc(nrxxs_loc) REAL(DP) :: w1_loc COMPLEX(DP) :: psic_loc(nrxxs_loc) INTEGER :: ir !$omp parallel do DO ir = 1, nrxxs_loc ! rho_loc(ir) = rho_loc(ir) + & w1_loc * ( DBLE( psic_loc(ir) )**2 + & AIMAG( psic_loc(ir) )**2 ) ! END DO !$omp end parallel do END SUBROUTINE get_rho SUBROUTINE get_rho_gamma(rho_loc, nrxxs_loc, w1_loc, w2_loc, psic_loc) IMPLICIT NONE INTEGER :: nrxxs_loc REAL(DP) :: rho_loc(nrxxs_loc) REAL(DP) :: w1_loc, w2_loc COMPLEX(DP) :: psic_loc(nrxxs_loc) INTEGER :: ir !$omp parallel do DO ir = 1, nrxxs_loc ! rho_loc(ir) = rho_loc(ir) + & w1_loc * DBLE( psic_loc(ir) )**2 + & w2_loc * AIMAG( psic_loc(ir) )**2 ! END DO !$omp end parallel do END SUBROUTINE get_rho_gamma SUBROUTINE get_rho_domag(rho_loc, nrxxs_loc, w1_loc, psic_loc) IMPLICIT NONE INTEGER :: nrxxs_loc REAL(DP) :: rho_loc(:, :) REAL(DP) :: w1_loc COMPLEX(DP) :: psic_loc(:, :) INTEGER :: ir !$omp parallel do DO ir = 1, nrxxs_loc ! rho_loc(ir,2) = rho_loc(ir,2) + w1_loc*2.D0* & (DBLE(psic_loc(ir,1))* DBLE(psic_loc(ir,2)) + & AIMAG(psic_loc(ir,1))*AIMAG(psic_loc(ir,2))) rho_loc(ir,3) = rho_loc(ir,3) + w1_loc*2.D0* & (DBLE(psic_loc(ir,1))*AIMAG(psic_loc(ir,2)) - & DBLE(psic_loc(ir,2))*AIMAG(psic_loc(ir,1))) rho_loc(ir,4) = rho_loc(ir,4) + w1_loc* & (DBLE(psic_loc(ir,1))**2+AIMAG(psic_loc(ir,1))**2 & -DBLE(psic_loc(ir,2))**2-AIMAG(psic_loc(ir,2))**2) ! END DO !$omp end parallel do END SUBROUTINE get_rho_domag END SUBROUTINE sum_band !---------------------------------------------------------------------------- SUBROUTINE sum_bec ( ik, current_spin, ibnd_start, ibnd_end, this_bgrp_nbnd ) !---------------------------------------------------------------------------- ! ! This routine computes the sum over bands ! \sum_i <\psi_i|\beta_l>w_i<\beta_m|\psi_i> ! for point "ik" and, for LSDA, spin "current_spin" ! Calls calbec to compute "becp"=<beta_m|psi_i> ! Output is accumulated (unsymmetrized) into "becsum", module "uspp" ! ! Routine used in sum_band (if okvan) and in compute_becsum, called by hinit1 (if okpaw) ! USE kinds, ONLY : DP USE becmod, ONLY : becp, calbec USE control_flags, ONLY : gamma_only USE ions_base, ONLY : nat, ntyp => nsp, ityp USE uspp, ONLY : nkb, vkb, becsum, indv_ijkb0 USE uspp_param, ONLY : upf, nh, nhm USE wvfct, ONLY : nbnd, wg USE klist, ONLY : ngk USE noncollin_module, ONLY : noncolin, npol USE wavefunctions_module, ONLY : evc USE realus, ONLY : real_space, invfft_orbital_gamma, initialisation_level,& fwfft_orbital_gamma, calbec_rs_gamma, s_psir_gamma USE mp_bands, ONLY : nbgrp,inter_bgrp_comm USE mp, ONLY : mp_sum USE funct, ONLY : exx_is_active ! IMPLICIT NONE INTEGER, INTENT(IN) :: ik, current_spin, ibnd_start, ibnd_end, this_bgrp_nbnd ! COMPLEX(DP), ALLOCATABLE :: becsum_nc(:,:,:,:) COMPLEX(dp), ALLOCATABLE :: auxk1(:,:), auxk2(:,:), aux_nc(:,:) REAL(dp), ALLOCATABLE :: auxg(:,:), aux_gk(:,:) INTEGER :: ibnd, ibnd_loc, nbnd_loc ! counters on bands INTEGER :: npw, ikb, jkb, ih, jh, ijh, na, np, is, js ! counters on beta functions, atoms, atom types, spin ! npw = ngk(ik) IF ( .NOT. real_space ) THEN ! calbec computes becp = <vkb_i|psi_j> CALL calbec( npw, vkb, evc, becp ) ELSE do ibnd = ibnd_start, ibnd_end, 2 call invfft_orbital_gamma(evc,ibnd,ibnd_end) call calbec_rs_gamma(ibnd,ibnd_end,becp%r) enddo call mp_sum(becp%r,inter_bgrp_comm) ENDIF ! CALL start_clock( 'sum_band:becsum' ) IF (noncolin) THEN ALLOCATE(becsum_nc(nhm*(nhm+1)/2,nat,npol,npol)) becsum_nc=(0.d0, 0.d0) ENDIF ! DO np = 1, ntyp ! IF ( upf(np)%tvanp ) THEN ! ! allocate work space used to perform GEMM operations ! IF ( gamma_only ) THEN nbnd_loc = becp%nbnd_loc ALLOCATE( auxg( nbnd_loc, nh(np) ) ) ELSE ALLOCATE( auxk1( ibnd_start:ibnd_end, nh(np)*npol ), & auxk2( ibnd_start:ibnd_end, nh(np)*npol ) ) END IF IF ( noncolin ) THEN ALLOCATE ( aux_nc( nh(np)*npol,nh(np)*npol ) ) ELSE ALLOCATE ( aux_gk( nh(np),nh(np) ) ) END IF ! ! In becp=<vkb_i|psi_j> terms corresponding to atom na of type nt ! run from index i=indv_ijkb0(na)+1 to i=indv_ijkb0(na)+nh(nt) ! DO na = 1, nat ! IF (ityp(na)==np) THEN ! ! sum over bands: \sum_i <psi_i|beta_l><beta_m|psi_i> w_i ! copy into aux1, aux2 the needed data to perform a GEMM ! IF ( noncolin ) THEN ! !$omp parallel do default(shared), private(is,ih,ikb,ibnd) DO is = 1, npol DO ih = 1, nh(np) ikb = indv_ijkb0(na) + ih DO ibnd = ibnd_start, ibnd_end auxk1(ibnd,ih+(is-1)*nh(np))= becp%nc(ikb,is,ibnd) auxk2(ibnd,ih+(is-1)*nh(np))= wg(ibnd,ik) * & becp%nc(ikb,is,ibnd) END DO END DO END DO !$omp end parallel do ! CALL ZGEMM ( 'C', 'N', npol*nh(np), npol*nh(np), this_bgrp_nbnd, & (1.0_dp,0.0_dp), auxk1, this_bgrp_nbnd, auxk2, this_bgrp_nbnd, & (0.0_dp,0.0_dp), aux_nc, npol*nh(np) ) ! ELSE IF ( gamma_only ) THEN ! !$omp parallel do default(shared), private(ih,ikb,ibnd,ibnd_loc) DO ih = 1, nh(np) ikb = indv_ijkb0(na) + ih DO ibnd_loc = 1, nbnd_loc ibnd = ibnd_loc + becp%ibnd_begin - 1 auxg(ibnd_loc,ih)= wg(ibnd,ik)*becp%r(ikb,ibnd_loc) END DO END DO !$omp end parallel do ! ! NB: band parallelizazion has not been performed in this case because ! bands were already distributed across R&G processors. ! Contribution to aux_gk is scaled by 1.d0/nbgrp so that the becsum ! summation across bgrps performed outside will gives the right value. ! CALL DGEMM ( 'N', 'N', nh(np), nh(np), nbnd_loc, & 1.0_dp/nbgrp, becp%r(indv_ijkb0(na)+1,1), nkb, & auxg, nbnd_loc, 0.0_dp, aux_gk, nh(np) ) ! ELSE ! !$omp parallel do default(shared), private(ih,ikb,ibnd) DO ih = 1, nh(np) ikb = indv_ijkb0(na) + ih DO ibnd = ibnd_start, ibnd_end auxk1(ibnd,ih) = becp%k(ikb,ibnd) auxk2(ibnd,ih) = wg(ibnd,ik)*becp%k(ikb,ibnd) END DO END DO !$omp end parallel do ! ! only the real part is computed ! CALL DGEMM ( 'C', 'N', nh(np), nh(np), 2*this_bgrp_nbnd, & 1.0_dp, auxk1, 2*this_bgrp_nbnd, auxk2, 2*this_bgrp_nbnd, & 0.0_dp, aux_gk, nh(np) ) ! END IF ! ! copy output from GEMM into desired format ! IF (noncolin .AND. .NOT. upf(np)%has_so) THEN CALL add_becsum_nc (na, np, aux_nc, becsum ) ELSE IF (noncolin .AND. upf(np)%has_so) THEN CALL add_becsum_so (na, np, aux_nc,becsum ) ELSE ijh = 0 DO ih = 1, nh(np) DO jh = ih, nh(np) ijh = ijh + 1 ! ! nondiagonal terms summed and collapsed into a ! single index (matrix is symmetric wrt (ih,jh)) ! IF ( jh == ih ) THEN becsum(ijh,na,current_spin) = & becsum(ijh,na,current_spin) + aux_gk (ih,jh) ELSE becsum(ijh,na,current_spin) = & becsum(ijh,na,current_spin) + aux_gk(ih,jh)*2.0_dp END IF END DO END DO ! END IF END IF ! END DO ! IF ( noncolin ) THEN DEALLOCATE ( aux_nc ) ELSE DEALLOCATE ( aux_gk ) END IF IF ( gamma_only ) THEN DEALLOCATE( auxg ) ELSE DEALLOCATE( auxk2, auxk1 ) END IF ! END IF ! END DO ! IF ( noncolin ) DEALLOCATE ( becsum_nc ) ! CALL stop_clock( 'sum_band:becsum' ) ! END SUBROUTINE sum_bec ! !---------------------------------------------------------------------------- SUBROUTINE add_becsum_nc ( na, np, becsum_nc, becsum ) !---------------------------------------------------------------------------- ! ! This routine multiplies becsum_nc by the identity and the Pauli matrices, ! saves it in becsum for the calculation of augmentation charge and ! magnetization. ! USE kinds, ONLY : DP USE ions_base, ONLY : nat, ntyp => nsp, ityp USE uspp_param, ONLY : nh, nhm USE lsda_mod, ONLY : nspin USE noncollin_module, ONLY : npol, nspin_mag USE spin_orb, ONLY : domag ! IMPLICIT NONE ! INTEGER, INTENT(IN) :: na, np COMPLEX(DP), INTENT(IN) :: becsum_nc(nh(np),npol,nh(np),npol) REAL(DP), INTENT(INOUT) :: becsum(nhm*(nhm+1)/2,nat,nspin_mag) ! ! ... local variables ! INTEGER :: ih, jh, ijh REAL(dp) :: fac ! ijh=0 DO ih = 1, nh(np) DO jh = ih, nh(np) ijh=ijh+1 IF ( ih == jh ) THEN fac = 1.0_dp ELSE fac = 2.0_dp END IF becsum(ijh,na,1)= becsum(ijh,na,1) + fac * & DBLE( becsum_nc(ih,1,jh,1) + becsum_nc(ih,2,jh,2) ) IF (domag) THEN becsum(ijh,na,2)= becsum(ijh,na,2) + fac * & DBLE( becsum_nc(ih,1,jh,2) + becsum_nc(ih,2,jh,1) ) becsum(ijh,na,3)= becsum(ijh,na,3) + fac * DBLE( (0.d0,-1.d0)* & (becsum_nc(ih,1,jh,2) - becsum_nc(ih,2,jh,1)) ) becsum(ijh,na,4)= becsum(ijh,na,4) + fac * & DBLE( becsum_nc(ih,1,jh,1) - becsum_nc(ih,2,jh,2) ) END IF END DO END DO END SUBROUTINE add_becsum_nc ! !---------------------------------------------------------------------------- SUBROUTINE add_becsum_so( na, np, becsum_nc, becsum ) !---------------------------------------------------------------------------- ! ! This routine multiplies becsum_nc by the identity and the Pauli matrices, ! rotates it as appropriate for the spin-orbit case, saves it in becsum ! for the calculation of augmentation charge and magnetization. ! USE kinds, ONLY : DP USE ions_base, ONLY : nat, ntyp => nsp, ityp USE uspp_param, ONLY : nh, nhm USE uspp, ONLY : ijtoh, nhtol, nhtoj, indv USE noncollin_module, ONLY : npol, nspin_mag USE spin_orb, ONLY : fcoef, domag ! IMPLICIT NONE INTEGER, INTENT(IN) :: na, np COMPLEX(DP), INTENT(IN) :: becsum_nc(nh(np),npol,nh(np),npol) REAL(DP), INTENT(INOUT) :: becsum(nhm*(nhm+1)/2,nat,nspin_mag) ! ! ... local variables ! INTEGER :: ih, jh, lh, kh, ijh, is1, is2 COMPLEX(DP) :: fac DO ih = 1, nh(np) DO jh = 1, nh(np) ijh=ijtoh(ih,jh,np) DO kh = 1, nh(np) IF (same_lj(kh,ih,np)) THEN DO lh=1,nh(np) IF (same_lj(lh,jh,np)) THEN DO is1=1,npol DO is2=1,npol fac=becsum_nc(kh,is1,lh,is2) becsum(ijh,na,1)=becsum(ijh,na,1) + fac * & (fcoef(kh,ih,is1,1,np)*fcoef(jh,lh,1,is2,np) + & fcoef(kh,ih,is1,2,np)*fcoef(jh,lh,2,is2,np) ) IF (domag) THEN becsum(ijh,na,2)=becsum(ijh,na,2)+fac * & (fcoef(kh,ih,is1,1,np)*fcoef(jh,lh,2,is2,np) +& fcoef(kh,ih,is1,2,np)*fcoef(jh,lh,1,is2,np) ) becsum(ijh,na,3)=becsum(ijh,na,3)+fac*(0.d0,-1.d0)*& (fcoef(kh,ih,is1,1,np)*fcoef(jh,lh,2,is2,np) - & fcoef(kh,ih,is1,2,np)*fcoef(jh,lh,1,is2,np) ) becsum(ijh,na,4)=becsum(ijh,na,4) + fac * & (fcoef(kh,ih,is1,1,np)*fcoef(jh,lh,1,is2,np) - & fcoef(kh,ih,is1,2,np)*fcoef(jh,lh,2,is2,np) ) END IF END DO END DO END IF END DO END IF END DO END DO END DO ! CONTAINS LOGICAL FUNCTION same_lj(ih,jh,np) INTEGER :: ih, jh, np ! same_lj = ((nhtol(ih,np)==nhtol(jh,np)).AND. & (ABS(nhtoj(ih,np)-nhtoj(jh,np))<1.d8).AND. & (indv(ih,np)==indv(jh,np)) ) ! END FUNCTION same_lj END SUBROUTINE add_becsum_so
gpl-2.0
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/dlasy2.f
24
14556
*> \brief \b DLASY2 solves the Sylvester matrix equation where the matrices are of order 1 or 2. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DLASY2 + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasy2.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasy2.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasy2.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DLASY2( LTRANL, LTRANR, ISGN, N1, N2, TL, LDTL, TR, * LDTR, B, LDB, SCALE, X, LDX, XNORM, INFO ) * * .. Scalar Arguments .. * LOGICAL LTRANL, LTRANR * INTEGER INFO, ISGN, LDB, LDTL, LDTR, LDX, N1, N2 * DOUBLE PRECISION SCALE, XNORM * .. * .. Array Arguments .. * DOUBLE PRECISION B( LDB, * ), TL( LDTL, * ), TR( LDTR, * ), * $ X( LDX, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DLASY2 solves for the N1 by N2 matrix X, 1 <= N1,N2 <= 2, in *> *> op(TL)*X + ISGN*X*op(TR) = SCALE*B, *> *> where TL is N1 by N1, TR is N2 by N2, B is N1 by N2, and ISGN = 1 or *> -1. op(T) = T or T**T, where T**T denotes the transpose of T. *> \endverbatim * * Arguments: * ========== * *> \param[in] LTRANL *> \verbatim *> LTRANL is LOGICAL *> On entry, LTRANL specifies the op(TL): *> = .FALSE., op(TL) = TL, *> = .TRUE., op(TL) = TL**T. *> \endverbatim *> *> \param[in] LTRANR *> \verbatim *> LTRANR is LOGICAL *> On entry, LTRANR specifies the op(TR): *> = .FALSE., op(TR) = TR, *> = .TRUE., op(TR) = TR**T. *> \endverbatim *> *> \param[in] ISGN *> \verbatim *> ISGN is INTEGER *> On entry, ISGN specifies the sign of the equation *> as described before. ISGN may only be 1 or -1. *> \endverbatim *> *> \param[in] N1 *> \verbatim *> N1 is INTEGER *> On entry, N1 specifies the order of matrix TL. *> N1 may only be 0, 1 or 2. *> \endverbatim *> *> \param[in] N2 *> \verbatim *> N2 is INTEGER *> On entry, N2 specifies the order of matrix TR. *> N2 may only be 0, 1 or 2. *> \endverbatim *> *> \param[in] TL *> \verbatim *> TL is DOUBLE PRECISION array, dimension (LDTL,2) *> On entry, TL contains an N1 by N1 matrix. *> \endverbatim *> *> \param[in] LDTL *> \verbatim *> LDTL is INTEGER *> The leading dimension of the matrix TL. LDTL >= max(1,N1). *> \endverbatim *> *> \param[in] TR *> \verbatim *> TR is DOUBLE PRECISION array, dimension (LDTR,2) *> On entry, TR contains an N2 by N2 matrix. *> \endverbatim *> *> \param[in] LDTR *> \verbatim *> LDTR is INTEGER *> The leading dimension of the matrix TR. LDTR >= max(1,N2). *> \endverbatim *> *> \param[in] B *> \verbatim *> B is DOUBLE PRECISION array, dimension (LDB,2) *> On entry, the N1 by N2 matrix B contains the right-hand *> side of the equation. *> \endverbatim *> *> \param[in] LDB *> \verbatim *> LDB is INTEGER *> The leading dimension of the matrix B. LDB >= max(1,N1). *> \endverbatim *> *> \param[out] SCALE *> \verbatim *> SCALE is DOUBLE PRECISION *> On exit, SCALE contains the scale factor. SCALE is chosen *> less than or equal to 1 to prevent the solution overflowing. *> \endverbatim *> *> \param[out] X *> \verbatim *> X is DOUBLE PRECISION array, dimension (LDX,2) *> On exit, X contains the N1 by N2 solution. *> \endverbatim *> *> \param[in] LDX *> \verbatim *> LDX is INTEGER *> The leading dimension of the matrix X. LDX >= max(1,N1). *> \endverbatim *> *> \param[out] XNORM *> \verbatim *> XNORM is DOUBLE PRECISION *> On exit, XNORM is the infinity-norm of the solution. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> On exit, INFO is set to *> 0: successful exit. *> 1: TL and TR have too close eigenvalues, so TL or *> TR is perturbed to get a nonsingular equation. *> NOTE: In the interests of speed, this routine does not *> check the inputs for errors. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup doubleSYauxiliary * * ===================================================================== SUBROUTINE DLASY2( LTRANL, LTRANR, ISGN, N1, N2, TL, LDTL, TR, $ LDTR, B, LDB, SCALE, X, LDX, XNORM, INFO ) * * -- LAPACK auxiliary routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. LOGICAL LTRANL, LTRANR INTEGER INFO, ISGN, LDB, LDTL, LDTR, LDX, N1, N2 DOUBLE PRECISION SCALE, XNORM * .. * .. Array Arguments .. DOUBLE PRECISION B( LDB, * ), TL( LDTL, * ), TR( LDTR, * ), $ X( LDX, * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) DOUBLE PRECISION TWO, HALF, EIGHT PARAMETER ( TWO = 2.0D+0, HALF = 0.5D+0, EIGHT = 8.0D+0 ) * .. * .. Local Scalars .. LOGICAL BSWAP, XSWAP INTEGER I, IP, IPIV, IPSV, J, JP, JPSV, K DOUBLE PRECISION BET, EPS, GAM, L21, SGN, SMIN, SMLNUM, TAU1, $ TEMP, U11, U12, U22, XMAX * .. * .. Local Arrays .. LOGICAL BSWPIV( 4 ), XSWPIV( 4 ) INTEGER JPIV( 4 ), LOCL21( 4 ), LOCU12( 4 ), $ LOCU22( 4 ) DOUBLE PRECISION BTMP( 4 ), T16( 4, 4 ), TMP( 4 ), X2( 2 ) * .. * .. External Functions .. INTEGER IDAMAX DOUBLE PRECISION DLAMCH EXTERNAL IDAMAX, DLAMCH * .. * .. External Subroutines .. EXTERNAL DCOPY, DSWAP * .. * .. Intrinsic Functions .. INTRINSIC ABS, MAX * .. * .. Data statements .. DATA LOCU12 / 3, 4, 1, 2 / , LOCL21 / 2, 1, 4, 3 / , $ LOCU22 / 4, 3, 2, 1 / DATA XSWPIV / .FALSE., .FALSE., .TRUE., .TRUE. / DATA BSWPIV / .FALSE., .TRUE., .FALSE., .TRUE. / * .. * .. Executable Statements .. * * Do not check the input parameters for errors * INFO = 0 * * Quick return if possible * IF( N1.EQ.0 .OR. N2.EQ.0 ) $ RETURN * * Set constants to control overflow * EPS = DLAMCH( 'P' ) SMLNUM = DLAMCH( 'S' ) / EPS SGN = ISGN * K = N1 + N1 + N2 - 2 GO TO ( 10, 20, 30, 50 )K * * 1 by 1: TL11*X + SGN*X*TR11 = B11 * 10 CONTINUE TAU1 = TL( 1, 1 ) + SGN*TR( 1, 1 ) BET = ABS( TAU1 ) IF( BET.LE.SMLNUM ) THEN TAU1 = SMLNUM BET = SMLNUM INFO = 1 END IF * SCALE = ONE GAM = ABS( B( 1, 1 ) ) IF( SMLNUM*GAM.GT.BET ) $ SCALE = ONE / GAM * X( 1, 1 ) = ( B( 1, 1 )*SCALE ) / TAU1 XNORM = ABS( X( 1, 1 ) ) RETURN * * 1 by 2: * TL11*[X11 X12] + ISGN*[X11 X12]*op[TR11 TR12] = [B11 B12] * [TR21 TR22] * 20 CONTINUE * SMIN = MAX( EPS*MAX( ABS( TL( 1, 1 ) ), ABS( TR( 1, 1 ) ), $ ABS( TR( 1, 2 ) ), ABS( TR( 2, 1 ) ), ABS( TR( 2, 2 ) ) ), $ SMLNUM ) TMP( 1 ) = TL( 1, 1 ) + SGN*TR( 1, 1 ) TMP( 4 ) = TL( 1, 1 ) + SGN*TR( 2, 2 ) IF( LTRANR ) THEN TMP( 2 ) = SGN*TR( 2, 1 ) TMP( 3 ) = SGN*TR( 1, 2 ) ELSE TMP( 2 ) = SGN*TR( 1, 2 ) TMP( 3 ) = SGN*TR( 2, 1 ) END IF BTMP( 1 ) = B( 1, 1 ) BTMP( 2 ) = B( 1, 2 ) GO TO 40 * * 2 by 1: * op[TL11 TL12]*[X11] + ISGN* [X11]*TR11 = [B11] * [TL21 TL22] [X21] [X21] [B21] * 30 CONTINUE SMIN = MAX( EPS*MAX( ABS( TR( 1, 1 ) ), ABS( TL( 1, 1 ) ), $ ABS( TL( 1, 2 ) ), ABS( TL( 2, 1 ) ), ABS( TL( 2, 2 ) ) ), $ SMLNUM ) TMP( 1 ) = TL( 1, 1 ) + SGN*TR( 1, 1 ) TMP( 4 ) = TL( 2, 2 ) + SGN*TR( 1, 1 ) IF( LTRANL ) THEN TMP( 2 ) = TL( 1, 2 ) TMP( 3 ) = TL( 2, 1 ) ELSE TMP( 2 ) = TL( 2, 1 ) TMP( 3 ) = TL( 1, 2 ) END IF BTMP( 1 ) = B( 1, 1 ) BTMP( 2 ) = B( 2, 1 ) 40 CONTINUE * * Solve 2 by 2 system using complete pivoting. * Set pivots less than SMIN to SMIN. * IPIV = IDAMAX( 4, TMP, 1 ) U11 = TMP( IPIV ) IF( ABS( U11 ).LE.SMIN ) THEN INFO = 1 U11 = SMIN END IF U12 = TMP( LOCU12( IPIV ) ) L21 = TMP( LOCL21( IPIV ) ) / U11 U22 = TMP( LOCU22( IPIV ) ) - U12*L21 XSWAP = XSWPIV( IPIV ) BSWAP = BSWPIV( IPIV ) IF( ABS( U22 ).LE.SMIN ) THEN INFO = 1 U22 = SMIN END IF IF( BSWAP ) THEN TEMP = BTMP( 2 ) BTMP( 2 ) = BTMP( 1 ) - L21*TEMP BTMP( 1 ) = TEMP ELSE BTMP( 2 ) = BTMP( 2 ) - L21*BTMP( 1 ) END IF SCALE = ONE IF( ( TWO*SMLNUM )*ABS( BTMP( 2 ) ).GT.ABS( U22 ) .OR. $ ( TWO*SMLNUM )*ABS( BTMP( 1 ) ).GT.ABS( U11 ) ) THEN SCALE = HALF / MAX( ABS( BTMP( 1 ) ), ABS( BTMP( 2 ) ) ) BTMP( 1 ) = BTMP( 1 )*SCALE BTMP( 2 ) = BTMP( 2 )*SCALE END IF X2( 2 ) = BTMP( 2 ) / U22 X2( 1 ) = BTMP( 1 ) / U11 - ( U12 / U11 )*X2( 2 ) IF( XSWAP ) THEN TEMP = X2( 2 ) X2( 2 ) = X2( 1 ) X2( 1 ) = TEMP END IF X( 1, 1 ) = X2( 1 ) IF( N1.EQ.1 ) THEN X( 1, 2 ) = X2( 2 ) XNORM = ABS( X( 1, 1 ) ) + ABS( X( 1, 2 ) ) ELSE X( 2, 1 ) = X2( 2 ) XNORM = MAX( ABS( X( 1, 1 ) ), ABS( X( 2, 1 ) ) ) END IF RETURN * * 2 by 2: * op[TL11 TL12]*[X11 X12] +ISGN* [X11 X12]*op[TR11 TR12] = [B11 B12] * [TL21 TL22] [X21 X22] [X21 X22] [TR21 TR22] [B21 B22] * * Solve equivalent 4 by 4 system using complete pivoting. * Set pivots less than SMIN to SMIN. * 50 CONTINUE SMIN = MAX( ABS( TR( 1, 1 ) ), ABS( TR( 1, 2 ) ), $ ABS( TR( 2, 1 ) ), ABS( TR( 2, 2 ) ) ) SMIN = MAX( SMIN, ABS( TL( 1, 1 ) ), ABS( TL( 1, 2 ) ), $ ABS( TL( 2, 1 ) ), ABS( TL( 2, 2 ) ) ) SMIN = MAX( EPS*SMIN, SMLNUM ) BTMP( 1 ) = ZERO CALL DCOPY( 16, BTMP, 0, T16, 1 ) T16( 1, 1 ) = TL( 1, 1 ) + SGN*TR( 1, 1 ) T16( 2, 2 ) = TL( 2, 2 ) + SGN*TR( 1, 1 ) T16( 3, 3 ) = TL( 1, 1 ) + SGN*TR( 2, 2 ) T16( 4, 4 ) = TL( 2, 2 ) + SGN*TR( 2, 2 ) IF( LTRANL ) THEN T16( 1, 2 ) = TL( 2, 1 ) T16( 2, 1 ) = TL( 1, 2 ) T16( 3, 4 ) = TL( 2, 1 ) T16( 4, 3 ) = TL( 1, 2 ) ELSE T16( 1, 2 ) = TL( 1, 2 ) T16( 2, 1 ) = TL( 2, 1 ) T16( 3, 4 ) = TL( 1, 2 ) T16( 4, 3 ) = TL( 2, 1 ) END IF IF( LTRANR ) THEN T16( 1, 3 ) = SGN*TR( 1, 2 ) T16( 2, 4 ) = SGN*TR( 1, 2 ) T16( 3, 1 ) = SGN*TR( 2, 1 ) T16( 4, 2 ) = SGN*TR( 2, 1 ) ELSE T16( 1, 3 ) = SGN*TR( 2, 1 ) T16( 2, 4 ) = SGN*TR( 2, 1 ) T16( 3, 1 ) = SGN*TR( 1, 2 ) T16( 4, 2 ) = SGN*TR( 1, 2 ) END IF BTMP( 1 ) = B( 1, 1 ) BTMP( 2 ) = B( 2, 1 ) BTMP( 3 ) = B( 1, 2 ) BTMP( 4 ) = B( 2, 2 ) * * Perform elimination * DO 100 I = 1, 3 XMAX = ZERO DO 70 IP = I, 4 DO 60 JP = I, 4 IF( ABS( T16( IP, JP ) ).GE.XMAX ) THEN XMAX = ABS( T16( IP, JP ) ) IPSV = IP JPSV = JP END IF 60 CONTINUE 70 CONTINUE IF( IPSV.NE.I ) THEN CALL DSWAP( 4, T16( IPSV, 1 ), 4, T16( I, 1 ), 4 ) TEMP = BTMP( I ) BTMP( I ) = BTMP( IPSV ) BTMP( IPSV ) = TEMP END IF IF( JPSV.NE.I ) $ CALL DSWAP( 4, T16( 1, JPSV ), 1, T16( 1, I ), 1 ) JPIV( I ) = JPSV IF( ABS( T16( I, I ) ).LT.SMIN ) THEN INFO = 1 T16( I, I ) = SMIN END IF DO 90 J = I + 1, 4 T16( J, I ) = T16( J, I ) / T16( I, I ) BTMP( J ) = BTMP( J ) - T16( J, I )*BTMP( I ) DO 80 K = I + 1, 4 T16( J, K ) = T16( J, K ) - T16( J, I )*T16( I, K ) 80 CONTINUE 90 CONTINUE 100 CONTINUE IF( ABS( T16( 4, 4 ) ).LT.SMIN ) $ T16( 4, 4 ) = SMIN SCALE = ONE IF( ( EIGHT*SMLNUM )*ABS( BTMP( 1 ) ).GT.ABS( T16( 1, 1 ) ) .OR. $ ( EIGHT*SMLNUM )*ABS( BTMP( 2 ) ).GT.ABS( T16( 2, 2 ) ) .OR. $ ( EIGHT*SMLNUM )*ABS( BTMP( 3 ) ).GT.ABS( T16( 3, 3 ) ) .OR. $ ( EIGHT*SMLNUM )*ABS( BTMP( 4 ) ).GT.ABS( T16( 4, 4 ) ) ) THEN SCALE = ( ONE / EIGHT ) / MAX( ABS( BTMP( 1 ) ), $ ABS( BTMP( 2 ) ), ABS( BTMP( 3 ) ), ABS( BTMP( 4 ) ) ) BTMP( 1 ) = BTMP( 1 )*SCALE BTMP( 2 ) = BTMP( 2 )*SCALE BTMP( 3 ) = BTMP( 3 )*SCALE BTMP( 4 ) = BTMP( 4 )*SCALE END IF DO 120 I = 1, 4 K = 5 - I TEMP = ONE / T16( K, K ) TMP( K ) = BTMP( K )*TEMP DO 110 J = K + 1, 4 TMP( K ) = TMP( K ) - ( TEMP*T16( K, J ) )*TMP( J ) 110 CONTINUE 120 CONTINUE DO 130 I = 1, 3 IF( JPIV( 4-I ).NE.4-I ) THEN TEMP = TMP( 4-I ) TMP( 4-I ) = TMP( JPIV( 4-I ) ) TMP( JPIV( 4-I ) ) = TEMP END IF 130 CONTINUE X( 1, 1 ) = TMP( 1 ) X( 2, 1 ) = TMP( 2 ) X( 1, 2 ) = TMP( 3 ) X( 2, 2 ) = TMP( 4 ) XNORM = MAX( ABS( TMP( 1 ) )+ABS( TMP( 3 ) ), $ ABS( TMP( 2 ) )+ABS( TMP( 4 ) ) ) RETURN * * End of DLASY2 * END
bsd-3-clause
UPenn-RoboCup/OpenBLAS
lapack-netlib/SRC/claqsp.f
24
5819
*> \brief \b CLAQSP scales a symmetric/Hermitian matrix in packed storage, using scaling factors computed by sppequ. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download CLAQSP + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/claqsp.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/claqsp.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/claqsp.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE CLAQSP( UPLO, N, AP, S, SCOND, AMAX, EQUED ) * * .. Scalar Arguments .. * CHARACTER EQUED, UPLO * INTEGER N * REAL AMAX, SCOND * .. * .. Array Arguments .. * REAL S( * ) * COMPLEX AP( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> CLAQSP equilibrates a symmetric matrix A using the scaling factors *> in the vector S. *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> Specifies whether the upper or lower triangular part of the *> symmetric matrix A is stored. *> = 'U': Upper triangular *> = 'L': Lower triangular *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the matrix A. N >= 0. *> \endverbatim *> *> \param[in,out] AP *> \verbatim *> AP is COMPLEX array, dimension (N*(N+1)/2) *> On entry, the upper or lower triangle of the symmetric matrix *> A, packed columnwise in a linear array. The j-th column of A *> is stored in the array AP as follows: *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; *> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. *> *> On exit, the equilibrated matrix: diag(S) * A * diag(S), in *> the same storage format as A. *> \endverbatim *> *> \param[in] S *> \verbatim *> S is REAL array, dimension (N) *> The scale factors for A. *> \endverbatim *> *> \param[in] SCOND *> \verbatim *> SCOND is REAL *> Ratio of the smallest S(i) to the largest S(i). *> \endverbatim *> *> \param[in] AMAX *> \verbatim *> AMAX is REAL *> Absolute value of largest matrix entry. *> \endverbatim *> *> \param[out] EQUED *> \verbatim *> EQUED is CHARACTER*1 *> Specifies whether or not equilibration was done. *> = 'N': No equilibration. *> = 'Y': Equilibration was done, i.e., A has been replaced by *> diag(S) * A * diag(S). *> \endverbatim * *> \par Internal Parameters: * ========================= *> *> \verbatim *> THRESH is a threshold value used to decide if scaling should be done *> based on the ratio of the scaling factors. If SCOND < THRESH, *> scaling is done. *> *> LARGE and SMALL are threshold values used to decide if scaling should *> be done based on the absolute size of the largest matrix element. *> If AMAX > LARGE or AMAX < SMALL, scaling is done. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup complexOTHERauxiliary * * ===================================================================== SUBROUTINE CLAQSP( UPLO, N, AP, S, SCOND, AMAX, EQUED ) * * -- LAPACK auxiliary routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. CHARACTER EQUED, UPLO INTEGER N REAL AMAX, SCOND * .. * .. Array Arguments .. REAL S( * ) COMPLEX AP( * ) * .. * * ===================================================================== * * .. Parameters .. REAL ONE, THRESH PARAMETER ( ONE = 1.0E+0, THRESH = 0.1E+0 ) * .. * .. Local Scalars .. INTEGER I, J, JC REAL CJ, LARGE, SMALL * .. * .. External Functions .. LOGICAL LSAME REAL SLAMCH EXTERNAL LSAME, SLAMCH * .. * .. Executable Statements .. * * Quick return if possible * IF( N.LE.0 ) THEN EQUED = 'N' RETURN END IF * * Initialize LARGE and SMALL. * SMALL = SLAMCH( 'Safe minimum' ) / SLAMCH( 'Precision' ) LARGE = ONE / SMALL * IF( SCOND.GE.THRESH .AND. AMAX.GE.SMALL .AND. AMAX.LE.LARGE ) THEN * * No equilibration * EQUED = 'N' ELSE * * Replace A by diag(S) * A * diag(S). * IF( LSAME( UPLO, 'U' ) ) THEN * * Upper triangle of A is stored. * JC = 1 DO 20 J = 1, N CJ = S( J ) DO 10 I = 1, J AP( JC+I-1 ) = CJ*S( I )*AP( JC+I-1 ) 10 CONTINUE JC = JC + J 20 CONTINUE ELSE * * Lower triangle of A is stored. * JC = 1 DO 40 J = 1, N CJ = S( J ) DO 30 I = J, N AP( JC+I-J ) = CJ*S( I )*AP( JC+I-J ) 30 CONTINUE JC = JC + N - J + 1 40 CONTINUE END IF EQUED = 'Y' END IF * RETURN * * End of CLAQSP * END
bsd-3-clause
jakevdp/scipy
scipy/integrate/quadpack/dqaws.f
143
8961
subroutine dqaws(f,a,b,alfa,beta,integr,epsabs,epsrel,result, * abserr,neval,ier,limit,lenw,last,iwork,work) c***begin prologue dqaws c***date written 800101 (yymmdd) c***revision date 830518 (yymmdd) c***category no. h2a2a1 c***keywords automatic integrator, special-purpose, c algebraico-logarithmic end-point singularities, c clenshaw-curtis, globally adaptive 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 given c definite integral i = integral of f*w over (a,b), c (where w shows a singular behaviour at the end points c see parameter integr). c hopefully satisfying following claim for accuracy c abs(i-result).le.max(epsabs,epsrel*abs(i)). c***description c c integration of functions having algebraico-logarithmic c end point singularities 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, b.gt.a c if b.le.a, the routine will end with ier = 6. c c alfa - double precision c parameter in the integrand function, alfa.gt.(-1) c if alfa.le.(-1), the routine will end with c ier = 6. c c beta - double precision c parameter in the integrand function, beta.gt.(-1) c if beta.le.(-1), the routine will end with c ier = 6. c c integr - integer c indicates which weight function is to be used c = 1 (x-a)**alfa*(b-x)**beta c = 2 (x-a)**alfa*(b-x)**beta*log(x-a) c = 3 (x-a)**alfa*(b-x)**beta*log(b-x) c = 4 (x-a)**alfa*(b-x)**beta*log(x-a)*log(b-x) c if integr.lt.1 or integr.gt.4, the routine c will end with 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 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 the integral and error c are 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 c subdivisions by increasing the value of c limit (and taking the according dimension c adjustments into account). however, if c this yields no improvement it is advised c to analyze the integrand, in order to c determine the integration difficulties c which prevent the requested tolerance from c being achieved. in case of a jump c discontinuity or a local singularity c of algebraico-logarithmic type at one or c more interior points of the integration c range, one should proceed by splitting up c the interval at these points and calling c the integrator on the subranges. c = 2 the occurrence of roundoff error is c detected, which prevents the requested c tolerance from being achieved. c = 3 extremely bad integrand behaviour occurs c at some points of the integration c interval. c = 6 the input is invalid, because c b.le.a or alfa.le.(-1) or beta.le.(-1) or c or integr.lt.1 or integr.gt.4 or c (epsabs.le.0 and c epsrel.lt.max(50*rel.mach.acc.,0.5d-28)) c or limit.lt.2 or lenw.lt.limit*4. c result, abserr, neval, last are set to c zero. except when lenw or limit is invalid c iwork(1), work(limit*2+1) and c work(limit*3+1) are set to zero, work(1) c is set to a and work(limit+1) to b. c c dimensioning parameters c limit - integer c dimensioning parameter for iwork c limit determines the maximum number of c subintervals in the partition of the given c integration interval (a,b), limit.ge.2. c if limit.lt.2, the routine will end with ier = 6. c c lenw - integer c dimensioning parameter for work c lenw must be at least limit*4. c if lenw.lt.limit*4, the routine will end c with ier = 6. c c last - integer c on return, last equals the number of c subintervals produced in the subdivision process, c which determines the significant number of c elements actually in the work arrays. c c work arrays c iwork - integer c vector of dimension limit, the first k c elements of which contain pointers c to the error estimates over the subintervals, c such that work(limit*3+iwork(1)), ..., c work(limit*3+iwork(k)) form a decreasing c sequence with k = last if last.le.(limit/2+2), c and k = limit+1-last otherwise c c work - double precision c vector of dimension lenw c on return c work(1), ..., work(last) contain the left c end points of the subintervals in the c partition of (a,b), c work(limit+1), ..., work(limit+last) contain c the right end points, c work(limit*2+1), ..., work(limit*2+last) c contain the integral approximations over c the subintervals, c work(limit*3+1), ..., work(limit*3+last) c contain the error estimates. c c***references (none) c***routines called dqawse,xerror c***end prologue dqaws c double precision a,abserr,alfa,b,beta,epsabs,epsrel,f,result,work integer ier,integr,iwork,last,lenw,limit,lvl,l1,l2,l3,neval c dimension iwork(limit),work(lenw) c external f c c check validity of limit and lenw. c c***first executable statement dqaws ier = 6 neval = 0 last = 0 result = 0.0d+00 abserr = 0.0d+00 if(limit.lt.2.or.lenw.lt.limit*4) go to 10 c c prepare call for dqawse. c l1 = limit+1 l2 = limit+l1 l3 = limit+l2 c call dqawse(f,a,b,alfa,beta,integr,epsabs,epsrel,limit,result, * abserr,neval,ier,work(1),work(l1),work(l2),work(l3),iwork,last) c c call error handler if necessary. c lvl = 0 10 if(ier.eq.6) lvl = 1 if(ier.ne.0) call xerror('abnormal return from dqaws',26,ier,lvl) return end
bsd-3-clause
sophAi/ptmd
src/BIMD/BIMD_backup.f
1
3240
*======================================================================== * File Name : BIMD_restore.f * Copyright (C) 2008-2011 Po-Jen Hsu <xanadu8850@pchome.com.tw> * Creation Date : 19-04-2010 * Last Modified : Wed 04 May 2011 10:56:11 AM CST * License : GPL (see bottom) * Encoding : utf-8 * Project : sophAi * Description : * ======================================================================== subroutine BIMD_backup(frame_num) implicit none !Backup point will only be stored above the final loop include "../../include/global_common.h" include "../../include/common.h" include "../../include/file.h" include "../../include/pes.h" include "../../include/simulation.h" include "../../include/BIMD/BIMD.h" include "../../include/BIMD/BIMD_restore.h" include "../../include/cn/cn.h" integer frame_num real*8 org_ufe C if(frame_num.le.dint(last_loop))return file_name= &simulation_restore_file(:index(simulation_restore_file," ")-1) open(21,file=file_name,form="unformatted",access="append") write(21) &time_label,frame_num,simulation_rec_loop C &,init_loop,final_loop &,simulation_delta_time, &temp,delta_temp,q_dim,atom_num,atom_name_a,atom_num_a, &atom_name_b,atom_num_b C write(*,*) "simulation_rec_loop=",simulation_rec_loop write(21) &BIMD_ave_energy,BIMD_ave_energy_square,BIMD_ave_pot, &BIMD_ave_kinetic,BIMD_ave_temper, &cn_name write(21) (ycp(I0),I0=1,q_dim) write(21) (fk0(I0),I0=1,q_dim) write(21) (fk1(I0),I0=1,q_dim) write(21) (fk2(I0),I0=1,q_dim) write(21) (yk0(I0),I0=1,q_dim) write(21) (yk1(I0),I0=1,q_dim) write(21) (yk2(I0),I0=1,q_dim) write(21) (yk3(I0),I0=1,q_dim) do I0=1,atom_num write(21)(BIMD_ave_dist(I0,I1),I1=1,atom_num) enddo do I0=1,atom_num write(21)(BIMD_ave_dist2(I0,I1),I1=1,atom_num) enddo if(wscreen)then if(cn_prev_name.ne.cn_name)then write(*,"(I5,1x,A5,1x,I13,1x,A40,1x,A80)") &myid,"Loop=",frame_num,". Jump to a new local minimum. Backup to", &simulation_restore_file else write(*,"(I5,1x,A5,1x,I13,1x,A10,1x,A80)") &myid,"Loop=",frame_num,",Backup to",simulation_restore_file endif endif 99 close(21) return end * ======================GNU General Public License======================= * 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 2 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * =======================================================================
gpl-2.0
AquaticEcoDynamics/libfvaed2
src/fv_ode.F90
1
7487
!############################################################################### !# # !# fv_ode.F90 # !# # !# Interface for FV (Finite Volume) Model to AED2 modules. # !# # !# This is a support module to managing solution of the BGC ODE set # !# # !# ----------------------------------------------------------------------- # !# # !# Developed by : # !# AquaticEcoDynamics (AED) Group # !# School of Agriculture and Environment # !# (C) The University of Western Australia # !# # !# Copyright by the AED-team @ UWA under the GNU Public License - www.gnu.org # !# # !# ----------------------------------------------------------------------- # !# # !# Created Apr 2015 # !# # !############################################################################### #include "aed2.h" #ifndef DEBUG #define DEBUG 0 #endif !############################################################################### MODULE fv_ode !------------------------------------------------------------------------------- USE aed2_common IMPLICIT NONE PUBLIC init_ode, do_ode !#--------------------------------------------------------------------------# !# Module Data INTEGER :: solution_method AED_REAL,ALLOCATABLE,DIMENSION(:,:) :: flux, flux2, flux3, flux4 AED_REAL,ALLOCATABLE,DIMENSION(:,:) :: cc1 CONTAINS !=============================================================================== !############################################################################### SUBROUTINE init_ode(ode_type, n_vars, nCells) !------------------------------------------------------------------------------- !ARGUMENTS INTEGER,INTENT(in) :: ode_type, n_vars, nCells ! !LOCALS INTEGER :: rc ! !------------------------------------------------------------------------------- !BEGIN solution_method = ode_type SELECT CASE (solution_method) CASE (1) !# euler forward CASE (2) !# runge_kutta_2 ALLOCATE(flux2(n_vars, nCells),stat=rc) ; IF (rc /= 0) STOP 'allocate_memory(): Error allocating (flux2)' ALLOCATE(cc1(n_vars, nCells),stat=rc) ; IF (rc /= 0) STOP 'allocate_memory(): Error allocating (cc1)' CASE (3) !# runge_kutta_4 ALLOCATE(flux2(n_vars, nCells),stat=rc) ; IF (rc /= 0) STOP 'allocate_memory(): Error allocating (flux2)' ALLOCATE(flux3(n_vars, nCells),stat=rc) ; IF (rc /= 0) STOP 'allocate_memory(): Error allocating (flux3)' ALLOCATE(flux4(n_vars, nCells),stat=rc) ; IF (rc /= 0) STOP 'allocate_memory(): Error allocating (flux4)' ALLOCATE(cc1(n_vars, nCells),stat=rc) ; IF (rc /= 0) STOP 'allocate_memory(): Error allocating (cc1)' CASE DEFAULT STOP "no valid solution_method specified!" END SELECT END SUBROUTINE init_ode !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !############################################################################### SUBROUTINE do_ode(col, top, bot) !------------------------------------------------------------------------------- !ARGUMENTS INTEGER,INTENT(in) :: col, top, bot ! !LOCALS INTEGER :: lev, i AED_REAL :: flux_ben(n_vars+n_vars_ben), flux_atm(n_vars+n_vars_ben) TYPE (aed2_column_t) :: column(n_aed2_vars) TYPE (aed2_column_t) :: column2(n_aed2_vars) TYPE (aed2_column_t) :: column3(n_aed2_vars) TYPE (aed2_column_t) :: column4(n_aed2_vars) ! !------------------------------------------------------------------------------- !BEGIN !# Time-integrate one biological time step SELECT CASE (solution_method) CASE (1) !# This is what the euler forward would do .... CALL calculate_fluxes(column, bot-top+1, flux(:,top:bot), flux_atm, flux_ben, h(top:bot)) DO lev = top, bot DO i = 1, n_vars cc(i,lev)=cc(i,lev)+dt*flux(i,lev) #if DEBUG>1 IF ( isnan(cc(i,lev)) ) THEN print*,'Nan at i = ', i, ' lev = ', lev print*,'h(lev) = ', h(lev), ' flux(i,lev) = ', flux(i,lev) print*,'Top of column @ ', top, ' bottom of column @ ', bot call STOPIT('NaN value') ENDIF #endif ENDDO ENDDO CASE (2) !# This is what the runge_kutta_2 would do .... CALL calculate_fluxes(column, bot-top+1, flux(:,top:bot), flux_atm, flux_ben, h(top:bot)) DO lev = top, bot DO i = 1, n_vars cc1(i,lev)=cc(i,lev)+dt*flux(i,lev) ENDDO ENDDO CALL define_column(column2, col, cc1, cc_diag, flux2, flux_atm, flux_ben) CALL calculate_fluxes(column2, bot-top+1, flux2(:,top:bot), flux_atm, flux_ben, h(top:bot)) DO lev = top, bot DO i = 1, n_vars cc(i,lev)=cc(i,lev)+dt*0.5*(flux(i,lev)+flux1(i,lev)) ENDDO ENDDO CASE (3) !# This is what the runge_kutta_4 would do .... CALL calculate_fluxes(column, bot-top+1, flux(:,top:bot), flux_atm, flux_ben, h(top:bot)) DO lev = top, bot DO i = 1, n_vars cc1(i,lev)=cc(i,lev)+dt*flux(i,lev) ENDDO ENDDO CALL define_column(column2, col, cc1, cc_diag, flux2, flux_atm, flux_ben) CALL calculate_fluxes(column2, bot-top+1, flux2(:,top:bot), flux_atm, flux_ben, h(top:bot)) DO lev = top, bot DO i = 1, n_vars cc1(i,lev)=cc(i,lev)+dt*flux1(i,lev) ENDDO ENDDO CALL define_column(column3, col, cc1, cc_diag, flux3, flux_atm, flux_ben) CALL calculate_fluxes(column3, bot-top+1, flux3(:,top:bot), flux_atm, flux_ben, h(top:bot)) DO lev = top, bot DO i = 1, n_vars cc1(i,lev)=cc(i,lev)+dt*flux2(i,lev) ENDDO ENDDO CALL define_column(column4, col, cc1, cc_diag, flux4, flux_atm, flux_ben) CALL calculate_fluxes(column4, bot-top+1, flux4(:,top:bot), flux_atm, flux_ben, h(top:bot)) DO lev = top, bot DO i = 1, n_vars cc(i,lev)=cc(i,lev)+dt*1./3.*(0.5*flux(i,lev)+flux2(i,lev)+flux3(i,lev)+0.5*flux4(i,lev)) ENDDO ENDDO CASE DEFAULT STOP "no valid solution_method specified!" END SELECT END SUBROUTINE do_ode !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !=============================================================================== END MODULE fv_ode
gpl-3.0
hlokavarapu/calypso
src/Fortran_libraries/MHD_src/sph_MHD/m_coef_fdm_free_CMB.f90
3
6573
!>@file m_coef_fdm_free_CMB.f90 !!@brief module m_coef_fdm_free_CMB !! !!@author H. Matsui !!@date Programmed in Jan., 2010 ! !>@brief Matrix to evaluate poloidal velocity and toroidal vorticity !! at CMB with free slip boundary !! !!@verbatim !! subroutine cal_fdm2_CMB_free_vp(r_from_CMB) !! subroutine cal_fdm2_CMB_free_vt(r_from_CMB) !! !! subroutine check_coef_fdm_free_CMB !! !! Matrix to evaluate radial derivative of poloidal velocity !! at CMB with free slip boundary !! dfdr = fdm2_free_vp_CMB(-1,2) * d_rj(CMB-1) !! + fdm2_free_vp_CMB( 0,2) * d_rj(CMB ) !! d2fdr2 = fdm2_free_vp_CMB(-1,3) * d_rj(CMB-1) !! + fdm2_free_vp_CMB( 0,3) * d_rj(CMB ) !! !! Matrix to evaluate radial derivative of toroidal vorticity !! at CMB with free slip boundary !! dfdr = fdm2_free_vt_CMB( 0,2) * d_rj(CMB ) !! d2fdr2 = fdm2_free_vt_CMB(-1,3) * d_rj(CMB-1) !! + fdm2_free_vt_CMB( 0,3) * d_rj(CMB ) !! !! Taylor expansion of free slip boundary at CMB !! dfdr = mat_fdm_2(2,1) * d_rj(CMB ) !! + mat_fdm_2(2,2) !! * (-2*dfdr(CMB) + r(CMB) * d2fdr2(CMB)) !! + mat_fdm_2(2,3) * d_rj(CMB-1) !! d2fdr2 = mat_fdm_2(3,1) * d_rj(CMB ) !! + mat_fdm_2(3,2) !! * (-2*dfdr(CMB) + r(CMB) * d2fdr2(CMB)) !! + mat_fdm_2(3,3) * d_rj(CMB-1) !!@endverbatim !! !!@n @param r_from_CMB(-3:0) radius from next points of CMB ! module m_coef_fdm_free_CMB ! use m_precision ! use m_constants use cal_inverse_small_matrix ! implicit none ! !> Matrix to evaluate radial derivative of poloidal velocity !! at CMB with free slip boundary real(kind = kreal) :: fdm2_free_vp_CMB(-1:1,3) !> Matrix to evaluate radial derivative of toroidal vorticity !! at CMB with free slip boundary real(kind = kreal) :: fdm2_free_vt_CMB(-1:1,3) ! ! !> Work matrix to evaluate fdm2_free_vp_CMB(-1:1,3) !!@verbatim !! dsdr = mat_fdm_CMB_free_vp(2,1) * d_rj(ICB ) !! + mat_fdm_CMB_free_vp(2,3) * d_rj(ICB+1) !! dsfdr2 = mat_fdm_CMB_free_vp(3,1) * d_rj(ICB ) !! + mat_fdm_CMB_free_vp(3,3) * d_rj(ICB+1) !!@endverbatim real(kind = kreal) :: mat_fdm_CMB_free_vp(3,3) ! !> Work matrix to evaluate fdm2_free_vt_CMB(-1:1,3) !!@verbatim !! dtdr = mat_fdm_CMB_free_vt(2,1) * d_rj(ICB ) !! + mat_fdm_CMB_free_vt(2,3) * d_rj(ICB+1) !! dtfdr2 = mat_fdm_CMB_free_vt(3,1) * d_rj(ICB ) !! + mat_fdm_CMB_free_vt(3,3) * d_rj(ICB+1) !!@endverbatim real(kind = kreal) :: mat_fdm_CMB_free_vt(3,3) ! private :: mat_fdm_CMB_free_vp, mat_fdm_CMB_free_vt ! ! ----------------------------------------------------------------------- ! contains ! ! ----------------------------------------------------------------------- ! subroutine cal_fdm2_CMB_free_vp(r_from_CMB) ! real(kind = kreal) :: r_from_CMB(-1:0) ! integer(kind = kint) :: ierr real(kind = kreal) :: mat_taylor_3(3,3) real(kind = kreal) :: dr_n1, r0, r1 ! ! dr_n1 = r_from_CMB(0) - r_from_CMB(-1) r0 = r_from_CMB(0) r1 = r_from_CMB(-1) ! mat_taylor_3(1,1) = one mat_taylor_3(1,2) = zero mat_taylor_3(1,3) = zero ! mat_taylor_3(2,1) = one mat_taylor_3(2,2) = -r0 mat_taylor_3(2,3) = half * r0*r0 ! mat_taylor_3(3,1) = one mat_taylor_3(3,2) =-dr_n1 mat_taylor_3(3,3) = half * dr_n1*dr_n1 ! call cal_inverse_33_matrix(mat_taylor_3, mat_fdm_CMB_free_vp, & & ierr) ! if(ierr .eq. 1) then write(*,*) 'singular matrix free slip CMB mat_vp ', & & r_from_CMB(0) end if ! fdm2_free_vp_CMB(1, 1) = zero fdm2_free_vp_CMB(0, 1) = one fdm2_free_vp_CMB(-1,1) = zero fdm2_free_vp_CMB(1, 2) = zero fdm2_free_vp_CMB(0, 2) = mat_fdm_CMB_free_vp(2,1) fdm2_free_vp_CMB(-1,2) = mat_fdm_CMB_free_vp(2,3) fdm2_free_vp_CMB(1, 3) = zero fdm2_free_vp_CMB(0, 3) = mat_fdm_CMB_free_vp(3,1) fdm2_free_vp_CMB(-1,3) = mat_fdm_CMB_free_vp(3,3) ! end subroutine cal_fdm2_CMB_free_vp ! ! ----------------------------------------------------------------------- ! subroutine cal_fdm2_CMB_free_vt(r_from_CMB) ! real(kind = kreal) :: r_from_CMB(-1:0) ! integer(kind = kint) :: ierr real(kind = kreal) :: mat_taylor_3(3,3) real(kind = kreal) :: dr_n1, r0, r1 ! ! dr_n1 = r_from_CMB(0) - r_from_CMB(-1) r0 = r_from_CMB( 0) r1 = r_from_CMB(-1) ! mat_taylor_3(1,1) = one mat_taylor_3(1,2) = zero mat_taylor_3(1,3) = zero ! mat_taylor_3(2,1) = two mat_taylor_3(2,2) = -r0 mat_taylor_3(2,3) = zero ! mat_taylor_3(3,1) = one mat_taylor_3(3,2) =-dr_n1 mat_taylor_3(3,3) = half * dr_n1*dr_n1 ! call cal_inverse_33_matrix(mat_taylor_3, mat_fdm_CMB_free_vt, & & ierr) ! if(ierr .eq. 1) then write(*,*) 'singular matrix free slip CMB mat_vt ', & & r_from_CMB(0) end if ! fdm2_free_vt_CMB(1, 1) = one fdm2_free_vt_CMB(0, 1) = one fdm2_free_vt_CMB(-1,1) = zero fdm2_free_vt_CMB(1, 2) = one fdm2_free_vt_CMB(0, 2) = mat_fdm_CMB_free_vt(2,1) fdm2_free_vt_CMB(-1,2) = zero fdm2_free_vt_CMB(1, 3) = one fdm2_free_vt_CMB(0, 3) = mat_fdm_CMB_free_vt(3,1) fdm2_free_vt_CMB(-1,3) = mat_fdm_CMB_free_vt(3,3) ! end subroutine cal_fdm2_CMB_free_vt ! ! ----------------------------------------------------------------------- ! subroutine check_coef_fdm_free_CMB ! ! write(50,*) ' fdm2_free_vp_CMB' write(50,*) ' mat_fdm11, mat_fdm12' write(50,'(1p9E25.15e3)') fdm2_free_vp_CMB(-1:0,1) write(50,*) ' mat_fdm21, mat_fdm22' write(50,'(1p9E25.15e3)') fdm2_free_vp_CMB(-1:0,2) write(50,*) ' mat_fdm31, mat_fdm32' write(50,'(1p9E25.15e3)') fdm2_free_vp_CMB(-1:0,3) ! write(50,*) ' fdm2_free_vt_CMB' write(50,*) ' mat_fdm11, mat_fdm12' write(50,'(1p9E25.15e3)') fdm2_free_vt_CMB(-1:0,1) write(50,*) ' mat_fdm21, mat_fdm22' write(50,'(1p9E25.15e3)') fdm2_free_vt_CMB(-1:0,2) write(50,*) ' mat_fdm31, mat_fdm32' write(50,'(1p9E25.15e3)') fdm2_free_vt_CMB(-1:0,3) ! end subroutine check_coef_fdm_free_CMB ! ! ----------------------------------------------------------------------- ! end module m_coef_fdm_free_CMB
gpl-3.0
jwakely/gcc
libgomp/testsuite/libgomp.oacc-fortran/collapse-6.f90
19
1105
! { dg-do run } ! collapse3.f90:test3 program collapse6 integer :: i, j, k, a(1:7, -3:5, 12:19), b(1:7, -3:5, 12:19) integer :: v1, v2, v3, v4, v5, v6, v7, v8, v9 logical :: l, r l = .false. r = .false. a(:, :, :) = 0 b(:, :, :) = 0 v1 = 3 v2 = 6 v3 = -2 v4 = 4 v5 = 13 v6 = 18 v7 = 1 v8 = 1 v9 = 1 !$acc parallel !$acc loop collapse (3) reduction (.or.:l) do i = v1, v2, v7 do j = v3, v4, v8 do k = v5, v6, v9 l = l.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4 l = l.or.k.lt.13.or.k.gt.18 if (.not.l) a(i, j, k) = a(i, j, k) + 1 end do end do end do !$acc end parallel do i = v1, v2, v7 do j = v3, v4, v8 do k = v5, v6, v9 r = r.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4 r = r.or.k.lt.13.or.k.gt.18 if (.not.r) b(i, j, k) = b(i, j, k) + 1 end do end do end do if (l .neqv. r) STOP 1 do i = v1, v2, v7 do j = v3, v4, v8 do k = v5, v6, v9 if (a(i, j, k) .ne. b(i, j, k)) STOP 2 end do end do end do end program collapse6
gpl-2.0
InsightSoftwareConsortium/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/temperton/setdgpfa.f
41
2296
* SUBROUTINE 'SETDGPFA' * SETUP ROUTINE FOR SELF-SORTING IN-PLACE * GENERALIZED PRIME FACTOR (COMPLEX) FFT [DGPFA] * * CALL SETDGPFA(TRIGS,N,NPQR,INFO) * * INPUT : * ----- * N IS THE LENGTH OF THE TRANSFORMS. N MUST BE OF THE FORM: * ----------------------------------- * N = (2**IP) * (3**IQ) * (5**IR) * ----------------------------------- * * OUTPUT: * ------ * TRIGS IS A TABLE OF TWIDDLE FACTORS, * OF LENGTH 2*IPQR (DOUBLE PRECISION) WORDS, WHERE: * -------------------------------------- * IPQR = (2**IP) + (3**IQ) + (5**IR) * -------------------------------------- * NPQR = THREE INTEGERS HOLDING IP, IQ, IR * INFO = SET TO 0 ON SUCCESS AND -1 ON FAILURE * * WRITTEN BY CLIVE TEMPERTON 1990 * *---------------------------------------------------------------------- * SUBROUTINE SETDGPFA(TRIGS,N,NPQR,INFO) * DOUBLE PRECISION TRIGS(*) INTEGER N, NPQR(3), INFO DIMENSION NJ(3) DOUBLE PRECISION DEL DOUBLE PRECISION ANGLE, TWOPI INFO = 0 * * DECOMPOSE N INTO FACTORS 2,3,5 * ------------------------------ NN = N IFAC = 2 * DO 30 LL = 1 , 3 KK = 0 10 CONTINUE IF (MOD(NN,IFAC).NE.0) GO TO 20 KK = KK + 1 NN = NN / IFAC GO TO 10 20 CONTINUE NPQR(LL) = KK IFAC = IFAC + LL 30 CONTINUE * IF (NN.NE.1) THEN * WRITE(6,40) N * 40 FORMAT(' *** WARNING!!!',I10,' IS NOT A LEGAL VALUE OF N ***') INFO = -1 RETURN ENDIF * IP = NPQR(1) IQ = NPQR(2) IR = NPQR(3) * * COMPUTE LIST OF ROTATED TWIDDLE FACTORS * --------------------------------------- NJ(1) = 2**IP NJ(2) = 3**IQ NJ(3) = 5**IR * TWOPI = 4.0 * ASIN(1.0) I = 1 * DO 60 LL = 1 , 3 NI = NJ(LL) IF (NI.EQ.1) GO TO 60 * DEL = TWOPI / DFLOAT(NI) IROT = N / NI KINK = MOD(IROT,NI) KK = 0 * DO 50 K = 1 , NI ANGLE = DFLOAT(KK) * DEL TRIGS(I) = COS(ANGLE) TRIGS(I+1) = SIN(ANGLE) I = I + 2 KK = KK + KINK IF (KK.GT.NI) KK = KK - NI 50 CONTINUE 60 CONTINUE * RETURN END
apache-2.0
embecosm/epiphany-gcc
gcc/testsuite/gfortran.fortran-torture/execute/seq_io.f90
191
1882
! pr 15472 ! sequential access files ! ! this test verifies the most basic sequential unformatted I/O ! write 3 records of various sizes ! then read them back ! and compare with what was written ! implicit none integer size parameter(size=100) logical debug data debug /.FALSE./ ! set debug to true for help in debugging failures. integer m(2) integer n real*4 r(size) integer i m(1) = Z'11111111' m(2) = Z'22222222' n = Z'33333333' do i = 1,size r(i) = i end do write(9)m ! an array of 2 write(9)n ! an integer write(9)r ! an array of reals ! zero all the results so we can compare after they are read back do i = 1,size r(i) = 0 end do m(1) = 0 m(2) = 0 n = 0 rewind(9) read(9)m read(9)n read(9)r ! ! check results if (m(1).ne.Z'11111111') then if (debug) then print '(A,Z8)','m(1) incorrect. m(1) = ',m(1) else call abort endif endif if (m(2).ne.Z'22222222') then if (debug) then print '(A,Z8)','m(2) incorrect. m(2) = ',m(2) else call abort endif endif if (n.ne.Z'33333333') then if (debug) then print '(A,Z8)','n incorrect. n = ',n else call abort endif endif do i = 1,size if (int(r(i)).ne.i) then if (debug) then print*,'element ',i,' was ',r(i),' should be ',i else call abort endif endif end do ! use hexdump to look at the file "fort.9" if (debug) then close(9) else close(9,status='DELETE') endif end
gpl-2.0
Shaswat27/scipy
scipy/fftpack/src/dfftpack/zfftf1.f
116
12031
SUBROUTINE ZFFTF1 (N,C,CH,WA,IFAC) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*) NF = IFAC(2) NA = 0 L1 = 1 IW = 1 DO 116 K1=1,NF IP = IFAC(K1+2) L2 = IP*L1 IDO = N/L2 IDOT = IDO+IDO IDL1 = IDOT*L1 IF (IP .NE. 4) GO TO 103 IX2 = IW+IDOT IX3 = IX2+IDOT IF (NA .NE. 0) GO TO 101 CALL DPASSF4 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3)) GO TO 102 101 CALL DPASSF4 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3)) 102 NA = 1-NA GO TO 115 103 IF (IP .NE. 2) GO TO 106 IF (NA .NE. 0) GO TO 104 CALL DPASSF2 (IDOT,L1,C,CH,WA(IW)) GO TO 105 104 CALL DPASSF2 (IDOT,L1,CH,C,WA(IW)) 105 NA = 1-NA GO TO 115 106 IF (IP .NE. 3) GO TO 109 IX2 = IW+IDOT IF (NA .NE. 0) GO TO 107 CALL DPASSF3 (IDOT,L1,C,CH,WA(IW),WA(IX2)) GO TO 108 107 CALL DPASSF3 (IDOT,L1,CH,C,WA(IW),WA(IX2)) 108 NA = 1-NA GO TO 115 109 IF (IP .NE. 5) GO TO 112 IX2 = IW+IDOT IX3 = IX2+IDOT IX4 = IX3+IDOT IF (NA .NE. 0) GO TO 110 CALL DPASSF5 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4)) GO TO 111 110 CALL DPASSF5 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4)) 111 NA = 1-NA GO TO 115 112 IF (NA .NE. 0) GO TO 113 CALL DPASSF (NAC,IDOT,IP,L1,IDL1,C,C,C,CH,CH,WA(IW)) GO TO 114 113 CALL DPASSF (NAC,IDOT,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW)) 114 IF (NAC .NE. 0) NA = 1-NA 115 L1 = L2 IW = IW+(IP-1)*IDOT 116 CONTINUE IF (NA .EQ. 0) RETURN N2 = N+N DO 117 I=1,N2 C(I) = CH(I) 117 CONTINUE RETURN END SUBROUTINE DPASSF (NAC,IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) , 1 C1(IDO,L1,IP) ,WA(1) ,C2(IDL1,IP), 2 CH2(IDL1,IP) IDOT = IDO/2 NT = IP*IDL1 IPP2 = IP+2 IPPH = (IP+1)/2 IDP = IP*IDO C IF (IDO .LT. L1) GO TO 106 DO 103 J=2,IPPH JC = IPP2-J DO 102 K=1,L1 DO 101 I=1,IDO CH(I,K,J) = CC(I,J,K)+CC(I,JC,K) CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K) 101 CONTINUE 102 CONTINUE 103 CONTINUE DO 105 K=1,L1 DO 104 I=1,IDO CH(I,K,1) = CC(I,1,K) 104 CONTINUE 105 CONTINUE GO TO 112 106 DO 109 J=2,IPPH JC = IPP2-J DO 108 I=1,IDO DO 107 K=1,L1 CH(I,K,J) = CC(I,J,K)+CC(I,JC,K) CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K) 107 CONTINUE 108 CONTINUE 109 CONTINUE DO 111 I=1,IDO DO 110 K=1,L1 CH(I,K,1) = CC(I,1,K) 110 CONTINUE 111 CONTINUE 112 IDL = 2-IDO INC = 0 DO 116 L=2,IPPH LC = IPP2-L IDL = IDL+IDO DO 113 IK=1,IDL1 C2(IK,L) = CH2(IK,1)+WA(IDL-1)*CH2(IK,2) C2(IK,LC) = -WA(IDL)*CH2(IK,IP) 113 CONTINUE IDLJ = IDL INC = INC+IDO DO 115 J=3,IPPH JC = IPP2-J IDLJ = IDLJ+INC IF (IDLJ .GT. IDP) IDLJ = IDLJ-IDP WAR = WA(IDLJ-1) WAI = WA(IDLJ) DO 114 IK=1,IDL1 C2(IK,L) = C2(IK,L)+WAR*CH2(IK,J) C2(IK,LC) = C2(IK,LC)-WAI*CH2(IK,JC) 114 CONTINUE 115 CONTINUE 116 CONTINUE DO 118 J=2,IPPH DO 117 IK=1,IDL1 CH2(IK,1) = CH2(IK,1)+CH2(IK,J) 117 CONTINUE 118 CONTINUE DO 120 J=2,IPPH JC = IPP2-J DO 119 IK=2,IDL1,2 CH2(IK-1,J) = C2(IK-1,J)-C2(IK,JC) CH2(IK-1,JC) = C2(IK-1,J)+C2(IK,JC) CH2(IK,J) = C2(IK,J)+C2(IK-1,JC) CH2(IK,JC) = C2(IK,J)-C2(IK-1,JC) 119 CONTINUE 120 CONTINUE NAC = 1 IF (IDO .EQ. 2) RETURN NAC = 0 DO 121 IK=1,IDL1 C2(IK,1) = CH2(IK,1) 121 CONTINUE DO 123 J=2,IP DO 122 K=1,L1 C1(1,K,J) = CH(1,K,J) C1(2,K,J) = CH(2,K,J) 122 CONTINUE 123 CONTINUE IF (IDOT .GT. L1) GO TO 127 IDIJ = 0 DO 126 J=2,IP IDIJ = IDIJ+2 DO 125 I=4,IDO,2 IDIJ = IDIJ+2 DO 124 K=1,L1 C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)+WA(IDIJ)*CH(I,K,J) C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)-WA(IDIJ)*CH(I-1,K,J) 124 CONTINUE 125 CONTINUE 126 CONTINUE RETURN 127 IDJ = 2-IDO DO 130 J=2,IP IDJ = IDJ+IDO DO 129 K=1,L1 IDIJ = IDJ DO 128 I=4,IDO,2 IDIJ = IDIJ+2 C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)+WA(IDIJ)*CH(I,K,J) C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)-WA(IDIJ)*CH(I-1,K,J) 128 CONTINUE 129 CONTINUE 130 CONTINUE RETURN END SUBROUTINE DPASSF2 (IDO,L1,CC,CH,WA1) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CC(IDO,2,L1) ,CH(IDO,L1,2) , 1 WA1(1) IF (IDO .GT. 2) GO TO 102 DO 101 K=1,L1 CH(1,K,1) = CC(1,1,K)+CC(1,2,K) CH(1,K,2) = CC(1,1,K)-CC(1,2,K) CH(2,K,1) = CC(2,1,K)+CC(2,2,K) CH(2,K,2) = CC(2,1,K)-CC(2,2,K) 101 CONTINUE RETURN 102 DO 104 K=1,L1 DO 103 I=2,IDO,2 CH(I-1,K,1) = CC(I-1,1,K)+CC(I-1,2,K) TR2 = CC(I-1,1,K)-CC(I-1,2,K) CH(I,K,1) = CC(I,1,K)+CC(I,2,K) TI2 = CC(I,1,K)-CC(I,2,K) CH(I,K,2) = WA1(I-1)*TI2-WA1(I)*TR2 CH(I-1,K,2) = WA1(I-1)*TR2+WA1(I)*TI2 103 CONTINUE 104 CONTINUE RETURN END SUBROUTINE DPASSF3 (IDO,L1,CC,CH,WA1,WA2) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CC(IDO,3,L1) ,CH(IDO,L1,3) , 1 WA1(1) ,WA2(1) C *** TAUI IS -SQRT(3)/2 *** DATA TAUR,TAUI /-0.5D0,-0.86602540378443864676D0/ IF (IDO .NE. 2) GO TO 102 DO 101 K=1,L1 TR2 = CC(1,2,K)+CC(1,3,K) CR2 = CC(1,1,K)+TAUR*TR2 CH(1,K,1) = CC(1,1,K)+TR2 TI2 = CC(2,2,K)+CC(2,3,K) CI2 = CC(2,1,K)+TAUR*TI2 CH(2,K,1) = CC(2,1,K)+TI2 CR3 = TAUI*(CC(1,2,K)-CC(1,3,K)) CI3 = TAUI*(CC(2,2,K)-CC(2,3,K)) CH(1,K,2) = CR2-CI3 CH(1,K,3) = CR2+CI3 CH(2,K,2) = CI2+CR3 CH(2,K,3) = CI2-CR3 101 CONTINUE RETURN 102 DO 104 K=1,L1 DO 103 I=2,IDO,2 TR2 = CC(I-1,2,K)+CC(I-1,3,K) CR2 = CC(I-1,1,K)+TAUR*TR2 CH(I-1,K,1) = CC(I-1,1,K)+TR2 TI2 = CC(I,2,K)+CC(I,3,K) CI2 = CC(I,1,K)+TAUR*TI2 CH(I,K,1) = CC(I,1,K)+TI2 CR3 = TAUI*(CC(I-1,2,K)-CC(I-1,3,K)) CI3 = TAUI*(CC(I,2,K)-CC(I,3,K)) DR2 = CR2-CI3 DR3 = CR2+CI3 DI2 = CI2+CR3 DI3 = CI2-CR3 CH(I,K,2) = WA1(I-1)*DI2-WA1(I)*DR2 CH(I-1,K,2) = WA1(I-1)*DR2+WA1(I)*DI2 CH(I,K,3) = WA2(I-1)*DI3-WA2(I)*DR3 CH(I-1,K,3) = WA2(I-1)*DR3+WA2(I)*DI3 103 CONTINUE 104 CONTINUE RETURN END SUBROUTINE DPASSF4 (IDO,L1,CC,CH,WA1,WA2,WA3) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CC(IDO,4,L1) ,CH(IDO,L1,4) , 1 WA1(1) ,WA2(1) ,WA3(1) IF (IDO .NE. 2) GO TO 102 DO 101 K=1,L1 TI1 = CC(2,1,K)-CC(2,3,K) TI2 = CC(2,1,K)+CC(2,3,K) TR4 = CC(2,2,K)-CC(2,4,K) TI3 = CC(2,2,K)+CC(2,4,K) TR1 = CC(1,1,K)-CC(1,3,K) TR2 = CC(1,1,K)+CC(1,3,K) TI4 = CC(1,4,K)-CC(1,2,K) TR3 = CC(1,2,K)+CC(1,4,K) CH(1,K,1) = TR2+TR3 CH(1,K,3) = TR2-TR3 CH(2,K,1) = TI2+TI3 CH(2,K,3) = TI2-TI3 CH(1,K,2) = TR1+TR4 CH(1,K,4) = TR1-TR4 CH(2,K,2) = TI1+TI4 CH(2,K,4) = TI1-TI4 101 CONTINUE RETURN 102 DO 104 K=1,L1 DO 103 I=2,IDO,2 TI1 = CC(I,1,K)-CC(I,3,K) TI2 = CC(I,1,K)+CC(I,3,K) TI3 = CC(I,2,K)+CC(I,4,K) TR4 = CC(I,2,K)-CC(I,4,K) TR1 = CC(I-1,1,K)-CC(I-1,3,K) TR2 = CC(I-1,1,K)+CC(I-1,3,K) TI4 = CC(I-1,4,K)-CC(I-1,2,K) TR3 = CC(I-1,2,K)+CC(I-1,4,K) CH(I-1,K,1) = TR2+TR3 CR3 = TR2-TR3 CH(I,K,1) = TI2+TI3 CI3 = TI2-TI3 CR2 = TR1+TR4 CR4 = TR1-TR4 CI2 = TI1+TI4 CI4 = TI1-TI4 CH(I-1,K,2) = WA1(I-1)*CR2+WA1(I)*CI2 CH(I,K,2) = WA1(I-1)*CI2-WA1(I)*CR2 CH(I-1,K,3) = WA2(I-1)*CR3+WA2(I)*CI3 CH(I,K,3) = WA2(I-1)*CI3-WA2(I)*CR3 CH(I-1,K,4) = WA3(I-1)*CR4+WA3(I)*CI4 CH(I,K,4) = WA3(I-1)*CI4-WA3(I)*CR4 103 CONTINUE 104 CONTINUE RETURN END SUBROUTINE DPASSF5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CC(IDO,5,L1) ,CH(IDO,L1,5) , 1 WA1(1) ,WA2(1) ,WA3(1) ,WA4(1) C *** TR11=COS(2*PI/5), TI11=-SIN(2*PI/5) C *** TR12=-COS(4*PI/5), TI12=-SIN(4*PI/5) DATA TR11,TI11,TR12,TI12 /0.3090169943749474241D0, + -0.95105651629515357212D0, 1 -0.8090169943749474241D0, -0.58778525229247312917D0/ IF (IDO .NE. 2) GO TO 102 DO 101 K=1,L1 TI5 = CC(2,2,K)-CC(2,5,K) TI2 = CC(2,2,K)+CC(2,5,K) TI4 = CC(2,3,K)-CC(2,4,K) TI3 = CC(2,3,K)+CC(2,4,K) TR5 = CC(1,2,K)-CC(1,5,K) TR2 = CC(1,2,K)+CC(1,5,K) TR4 = CC(1,3,K)-CC(1,4,K) TR3 = CC(1,3,K)+CC(1,4,K) CH(1,K,1) = CC(1,1,K)+TR2+TR3 CH(2,K,1) = CC(2,1,K)+TI2+TI3 CR2 = CC(1,1,K)+TR11*TR2+TR12*TR3 CI2 = CC(2,1,K)+TR11*TI2+TR12*TI3 CR3 = CC(1,1,K)+TR12*TR2+TR11*TR3 CI3 = CC(2,1,K)+TR12*TI2+TR11*TI3 CR5 = TI11*TR5+TI12*TR4 CI5 = TI11*TI5+TI12*TI4 CR4 = TI12*TR5-TI11*TR4 CI4 = TI12*TI5-TI11*TI4 CH(1,K,2) = CR2-CI5 CH(1,K,5) = CR2+CI5 CH(2,K,2) = CI2+CR5 CH(2,K,3) = CI3+CR4 CH(1,K,3) = CR3-CI4 CH(1,K,4) = CR3+CI4 CH(2,K,4) = CI3-CR4 CH(2,K,5) = CI2-CR5 101 CONTINUE RETURN 102 DO 104 K=1,L1 DO 103 I=2,IDO,2 TI5 = CC(I,2,K)-CC(I,5,K) TI2 = CC(I,2,K)+CC(I,5,K) TI4 = CC(I,3,K)-CC(I,4,K) TI3 = CC(I,3,K)+CC(I,4,K) TR5 = CC(I-1,2,K)-CC(I-1,5,K) TR2 = CC(I-1,2,K)+CC(I-1,5,K) TR4 = CC(I-1,3,K)-CC(I-1,4,K) TR3 = CC(I-1,3,K)+CC(I-1,4,K) CH(I-1,K,1) = CC(I-1,1,K)+TR2+TR3 CH(I,K,1) = CC(I,1,K)+TI2+TI3 CR2 = CC(I-1,1,K)+TR11*TR2+TR12*TR3 CI2 = CC(I,1,K)+TR11*TI2+TR12*TI3 CR3 = CC(I-1,1,K)+TR12*TR2+TR11*TR3 CI3 = CC(I,1,K)+TR12*TI2+TR11*TI3 CR5 = TI11*TR5+TI12*TR4 CI5 = TI11*TI5+TI12*TI4 CR4 = TI12*TR5-TI11*TR4 CI4 = TI12*TI5-TI11*TI4 DR3 = CR3-CI4 DR4 = CR3+CI4 DI3 = CI3+CR4 DI4 = CI3-CR4 DR5 = CR2+CI5 DR2 = CR2-CI5 DI5 = CI2-CR5 DI2 = CI2+CR5 CH(I-1,K,2) = WA1(I-1)*DR2+WA1(I)*DI2 CH(I,K,2) = WA1(I-1)*DI2-WA1(I)*DR2 CH(I-1,K,3) = WA2(I-1)*DR3+WA2(I)*DI3 CH(I,K,3) = WA2(I-1)*DI3-WA2(I)*DR3 CH(I-1,K,4) = WA3(I-1)*DR4+WA3(I)*DI4 CH(I,K,4) = WA3(I-1)*DI4-WA3(I)*DR4 CH(I-1,K,5) = WA4(I-1)*DR5+WA4(I)*DI5 CH(I,K,5) = WA4(I-1)*DI5-WA4(I)*DR5 103 CONTINUE 104 CONTINUE RETURN END
bsd-3-clause
embecosm/epiphany-gcc
gcc/testsuite/gfortran.dg/maxval_maxloc_conformance_1.f90
193
1816
! { dg-do compile } ! PR 26039: Tests for different ranks for (min|max)loc, (min|max)val, product ! and sum were missing. program main integer, dimension(2) :: a logical, dimension(2,1) :: lo logical, dimension(3) :: lo2 a = (/ 1, 2 /) lo = .true. print *,minloc(a,mask=lo) ! { dg-error "Incompatible ranks" } print *,maxloc(a,mask=lo) ! { dg-error "Incompatible ranks" } print *,minval(a,mask=lo) ! { dg-error "Incompatible ranks" } print *,maxval(a,mask=lo) ! { dg-error "Incompatible ranks" } print *,sum(a,mask=lo) ! { dg-error "Incompatible ranks" } print *,product(a,mask=lo) ! { dg-error "Incompatible ranks" } print *,minloc(a,1,mask=lo) ! { dg-error "Incompatible ranks" } print *,maxloc(a,1,mask=lo) ! { dg-error "Incompatible ranks" } print *,minval(a,1,mask=lo) ! { dg-error "Incompatible ranks" } print *,maxval(a,1,mask=lo) ! { dg-error "Incompatible ranks" } print *,sum(a,1,mask=lo) ! { dg-error "Incompatible ranks" } print *,product(a,1,mask=lo) ! { dg-error "Incompatible ranks" } print *,minloc(a,mask=lo2) ! { dg-error "Different shape" } print *,maxloc(a,mask=lo2) ! { dg-error "Different shape" } print *,minval(a,mask=lo2) ! { dg-error "Different shape" } print *,maxval(a,mask=lo2) ! { dg-error "Different shape" } print *,sum(a,mask=lo2) ! { dg-error "Different shape" } print *,product(a,mask=lo2) ! { dg-error "Different shape" } print *,minloc(a,1,mask=lo2) ! { dg-error "Different shape" } print *,maxloc(a,1,mask=lo2) ! { dg-error "Different shape" } print *,minval(a,1,mask=lo2) ! { dg-error "Different shape" } print *,maxval(a,1,mask=lo2) ! { dg-error "Different shape" } print *,sum(a,1,mask=lo2) ! { dg-error "Different shape" } print *,product(a,1,mask=lo2) ! { dg-error "Different shape" } end program main
gpl-2.0
embecosm/epiphany-gcc
libgfortran/generated/_atan_r10.F90
15
1482
! Copyright 2002, 2007, 2009 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !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_ATANL elemental function _gfortran_specific__atan_r10 (parm) real (kind=10), intent (in) :: parm real (kind=10) :: _gfortran_specific__atan_r10 _gfortran_specific__atan_r10 = atan (parm) end function #endif #endif
gpl-2.0
jwakely/gcc
gcc/testsuite/gfortran.dg/use_only_3.f90
50
1300
! { dg-do compile } ! This tests the patch for PR34975, in which 'n', 'ipol', and 'i' would be ! determined to have 'no IMPLICIT type'. It turned out to be fiendishly ! difficult to write a testcase for this PR because even the smallest changes ! would make the bug disappear. This is the testcase provided in the PR, except ! that all the modules are put in 'use_only_3.inc' in the same order as the ! makefile. Even this has an effect; only 'n' is now determined to be ! improperly typed. All this is due to the richness of the symtree and the ! way in which the renaming inserted new symtree entries. Unless somenody can ! come up with a reduced version, this relatively large file will have to be added ! to the testsuite. Fortunately, it only has to be comiled once:) ! ! Reported by Tobias Burnus <burnus@gcc.gnu.org> ! include 'use_only_3.inc' subroutine dforceb(c0, i, betae, ipol, bec0, ctabin, gqq, gqqm, qmat, dq2, df) use gvecs use gvecw, only: ngw use parameters use electrons_base, only: nx => nbspx, n => nbsp, nspin, f use constants use cvan use ions_base use ions_base, only : nas => nax implicit none integer ipol, i, ctabin complex c0(n), betae, df,& & gqq,gqqm,& & qmat real bec0,& & dq2, gmes end subroutine dforceb
gpl-2.0
InsightSoftwareConsortium/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/eispack/balbak.f
41
2307
subroutine balbak(nm,n,low,igh,scale,m,z) c integer i,j,k,m,n,ii,nm,igh,low double precision scale(n),z(nm,m) double precision s c c this subroutine is a translation of the algol procedure balbak, c num. math. 13, 293-304(1969) by parlett and reinsch. c handbook for auto. comp., vol.ii-linear algebra, 315-326(1971). c c this subroutine forms the eigenvectors of a real general c matrix by back transforming those of the corresponding c balanced matrix determined by balanc. 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 low and igh are integers determined by balanc. c c scale contains information determining the permutations c and scaling factors used by balanc. c c m is the number of columns of z to be back transformed. c c z contains the real and imaginary parts of the eigen- c vectors to be back transformed in its first m columns. c c on output c c z contains the real and imaginary parts of the c transformed eigenvectors in its first m columns. 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 (m .eq. 0) go to 200 if (igh .eq. low) go to 120 c do 110 i = low, igh s = scale(i) c .......... left hand eigenvectors are back transformed c if the foregoing statement is replaced by c s=1.0d0/scale(i). .......... do 100 j = 1, m 100 z(i,j) = z(i,j) * s c 110 continue c ......... for i=low-1 step -1 until 1, c igh+1 step 1 until n do -- .......... 120 do 140 ii = 1, n i = ii if (i .ge. low .and. i .le. igh) go to 140 if (i .lt. low) i = low - ii k = scale(i) if (k .eq. i) go to 140 c do 130 j = 1, m s = z(i,j) z(i,j) = z(k,j) z(k,j) = s 130 continue c 140 continue c 200 return end
apache-2.0
jwakely/gcc
gcc/testsuite/gfortran.dg/gomp/pr35786-1.f90
155
2006
! PR fortran/35786 ! { dg-do compile } ! { dg-options "-fopenmp" } module pr35768 real, parameter :: one = 1.0 contains subroutine fn1 !$omp parallel firstprivate (one) ! { dg-error "is not a variable" } !$omp end parallel end subroutine fn1 subroutine fn2 (doit) external doit !$omp parallel firstprivate (doit) ! { dg-error "is not a variable" } call doit () !$omp end parallel end subroutine fn2 subroutine fn3 interface fn4 subroutine fn4 () end subroutine fn4 end interface !$omp parallel private (fn4) ! { dg-error "is not a variable" } call fn4 () !$omp end parallel end subroutine fn3 subroutine fn5 interface fn6 function fn6 () integer :: fn6 end function fn6 end interface integer :: x !$omp parallel private (fn6, x) ! { dg-error "is not a variable" } x = fn6 () !$omp end parallel end subroutine fn5 function fn7 () result (re7) integer :: re7 !$omp parallel private (fn7) ! { dg-error "is not a variable" } !$omp end parallel end function fn7 function fn8 () result (re8) integer :: re8 call fn9 contains subroutine fn9 !$omp parallel private (fn8) ! { dg-error "is not a variable" } !$omp end parallel end subroutine fn9 end function fn8 function fn10 () result (re10) integer :: re10, re11 entry fn11 () result (re11) !$omp parallel private (fn10) ! { dg-error "is not a variable" } !$omp end parallel !$omp parallel private (fn11) ! { dg-error "is not a variable" } !$omp end parallel end function fn10 function fn12 () result (re12) integer :: re12, re13 entry fn13 () result (re13) call fn14 contains subroutine fn14 !$omp parallel private (fn12) ! { dg-error "is not a variable" } !$omp end parallel !$omp parallel private (fn13) ! { dg-error "is not a variable" } !$omp end parallel end subroutine fn14 end function fn12 end module
gpl-2.0
benchmark-subsetting/cere
examples/NPB3.0-SER/BT/exact_rhs.f
15
13465
c--------------------------------------------------------------------- c--------------------------------------------------------------------- subroutine exact_rhs c--------------------------------------------------------------------- c--------------------------------------------------------------------- c--------------------------------------------------------------------- c compute the right hand side based on exact solution c--------------------------------------------------------------------- include 'header.h' double precision dtemp(5), xi, eta, zeta, dtpp integer m, i, j, k, ip1, im1, jp1, jm1, km1, kp1 c--------------------------------------------------------------------- c initialize c--------------------------------------------------------------------- do k= 0, grid_points(3)-1 do j = 0, grid_points(2)-1 do i = 0, grid_points(1)-1 do m = 1, 5 forcing(m,i,j,k) = 0.0d0 enddo enddo enddo enddo c--------------------------------------------------------------------- c xi-direction flux differences c--------------------------------------------------------------------- do k = 1, grid_points(3)-2 zeta = dble(k) * dnzm1 do j = 1, grid_points(2)-2 eta = dble(j) * dnym1 do i=0, grid_points(1)-1 xi = dble(i) * dnxm1 call exact_solution(xi, eta, zeta, dtemp) do m = 1, 5 ue(i,m) = dtemp(m) enddo dtpp = 1.0d0 / dtemp(1) do m = 2, 5 buf(i,m) = dtpp * dtemp(m) enddo cuf(i) = buf(i,2) * buf(i,2) buf(i,1) = cuf(i) + buf(i,3) * buf(i,3) + > buf(i,4) * buf(i,4) q(i) = 0.5d0*(buf(i,2)*ue(i,2) + buf(i,3)*ue(i,3) + > buf(i,4)*ue(i,4)) enddo do i = 1, grid_points(1)-2 im1 = i-1 ip1 = i+1 forcing(1,i,j,k) = forcing(1,i,j,k) - > tx2*( ue(ip1,2)-ue(im1,2) )+ > dx1tx1*(ue(ip1,1)-2.0d0*ue(i,1)+ue(im1,1)) forcing(2,i,j,k) = forcing(2,i,j,k) - tx2 * ( > (ue(ip1,2)*buf(ip1,2)+c2*(ue(ip1,5)-q(ip1)))- > (ue(im1,2)*buf(im1,2)+c2*(ue(im1,5)-q(im1))))+ > xxcon1*(buf(ip1,2)-2.0d0*buf(i,2)+buf(im1,2))+ > dx2tx1*( ue(ip1,2)-2.0d0* ue(i,2)+ue(im1,2)) forcing(3,i,j,k) = forcing(3,i,j,k) - tx2 * ( > ue(ip1,3)*buf(ip1,2)-ue(im1,3)*buf(im1,2))+ > xxcon2*(buf(ip1,3)-2.0d0*buf(i,3)+buf(im1,3))+ > dx3tx1*( ue(ip1,3)-2.0d0*ue(i,3) +ue(im1,3)) forcing(4,i,j,k) = forcing(4,i,j,k) - tx2*( > ue(ip1,4)*buf(ip1,2)-ue(im1,4)*buf(im1,2))+ > xxcon2*(buf(ip1,4)-2.0d0*buf(i,4)+buf(im1,4))+ > dx4tx1*( ue(ip1,4)-2.0d0* ue(i,4)+ ue(im1,4)) forcing(5,i,j,k) = forcing(5,i,j,k) - tx2*( > buf(ip1,2)*(c1*ue(ip1,5)-c2*q(ip1))- > buf(im1,2)*(c1*ue(im1,5)-c2*q(im1)))+ > 0.5d0*xxcon3*(buf(ip1,1)-2.0d0*buf(i,1)+ > buf(im1,1))+ > xxcon4*(cuf(ip1)-2.0d0*cuf(i)+cuf(im1))+ > xxcon5*(buf(ip1,5)-2.0d0*buf(i,5)+buf(im1,5))+ > dx5tx1*( ue(ip1,5)-2.0d0* ue(i,5)+ ue(im1,5)) enddo c--------------------------------------------------------------------- c Fourth-order dissipation c--------------------------------------------------------------------- do m = 1, 5 i = 1 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (5.0d0*ue(i,m) - 4.0d0*ue(i+1,m) +ue(i+2,m)) i = 2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (-4.0d0*ue(i-1,m) + 6.0d0*ue(i,m) - > 4.0d0*ue(i+1,m) + ue(i+2,m)) enddo do m = 1, 5 do i = 3, grid_points(1)-4 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp* > (ue(i-2,m) - 4.0d0*ue(i-1,m) + > 6.0d0*ue(i,m) - 4.0d0*ue(i+1,m) + ue(i+2,m)) enddo enddo do m = 1, 5 i = grid_points(1)-3 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(i-2,m) - 4.0d0*ue(i-1,m) + > 6.0d0*ue(i,m) - 4.0d0*ue(i+1,m)) i = grid_points(1)-2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(i-2,m) - 4.0d0*ue(i-1,m) + 5.0d0*ue(i,m)) enddo enddo enddo c--------------------------------------------------------------------- c eta-direction flux differences c--------------------------------------------------------------------- do k = 1, grid_points(3)-2 zeta = dble(k) * dnzm1 do i=1, grid_points(1)-2 xi = dble(i) * dnxm1 do j=0, grid_points(2)-1 eta = dble(j) * dnym1 call exact_solution(xi, eta, zeta, dtemp) do m = 1, 5 ue(j,m) = dtemp(m) enddo dtpp = 1.0d0/dtemp(1) do m = 2, 5 buf(j,m) = dtpp * dtemp(m) enddo cuf(j) = buf(j,3) * buf(j,3) buf(j,1) = cuf(j) + buf(j,2) * buf(j,2) + > buf(j,4) * buf(j,4) q(j) = 0.5d0*(buf(j,2)*ue(j,2) + buf(j,3)*ue(j,3) + > buf(j,4)*ue(j,4)) enddo do j = 1, grid_points(2)-2 jm1 = j-1 jp1 = j+1 forcing(1,i,j,k) = forcing(1,i,j,k) - > ty2*( ue(jp1,3)-ue(jm1,3) )+ > dy1ty1*(ue(jp1,1)-2.0d0*ue(j,1)+ue(jm1,1)) forcing(2,i,j,k) = forcing(2,i,j,k) - ty2*( > ue(jp1,2)*buf(jp1,3)-ue(jm1,2)*buf(jm1,3))+ > yycon2*(buf(jp1,2)-2.0d0*buf(j,2)+buf(jm1,2))+ > dy2ty1*( ue(jp1,2)-2.0* ue(j,2)+ ue(jm1,2)) forcing(3,i,j,k) = forcing(3,i,j,k) - ty2*( > (ue(jp1,3)*buf(jp1,3)+c2*(ue(jp1,5)-q(jp1)))- > (ue(jm1,3)*buf(jm1,3)+c2*(ue(jm1,5)-q(jm1))))+ > yycon1*(buf(jp1,3)-2.0d0*buf(j,3)+buf(jm1,3))+ > dy3ty1*( ue(jp1,3)-2.0d0*ue(j,3) +ue(jm1,3)) forcing(4,i,j,k) = forcing(4,i,j,k) - ty2*( > ue(jp1,4)*buf(jp1,3)-ue(jm1,4)*buf(jm1,3))+ > yycon2*(buf(jp1,4)-2.0d0*buf(j,4)+buf(jm1,4))+ > dy4ty1*( ue(jp1,4)-2.0d0*ue(j,4)+ ue(jm1,4)) forcing(5,i,j,k) = forcing(5,i,j,k) - ty2*( > buf(jp1,3)*(c1*ue(jp1,5)-c2*q(jp1))- > buf(jm1,3)*(c1*ue(jm1,5)-c2*q(jm1)))+ > 0.5d0*yycon3*(buf(jp1,1)-2.0d0*buf(j,1)+ > buf(jm1,1))+ > yycon4*(cuf(jp1)-2.0d0*cuf(j)+cuf(jm1))+ > yycon5*(buf(jp1,5)-2.0d0*buf(j,5)+buf(jm1,5))+ > dy5ty1*(ue(jp1,5)-2.0d0*ue(j,5)+ue(jm1,5)) enddo c--------------------------------------------------------------------- c Fourth-order dissipation c--------------------------------------------------------------------- do m = 1, 5 j = 1 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (5.0d0*ue(j,m) - 4.0d0*ue(j+1,m) +ue(j+2,m)) j = 2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (-4.0d0*ue(j-1,m) + 6.0d0*ue(j,m) - > 4.0d0*ue(j+1,m) + ue(j+2,m)) enddo do m = 1, 5 do j = 3, grid_points(2)-4 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp* > (ue(j-2,m) - 4.0d0*ue(j-1,m) + > 6.0d0*ue(j,m) - 4.0d0*ue(j+1,m) + ue(j+2,m)) enddo enddo do m = 1, 5 j = grid_points(2)-3 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(j-2,m) - 4.0d0*ue(j-1,m) + > 6.0d0*ue(j,m) - 4.0d0*ue(j+1,m)) j = grid_points(2)-2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(j-2,m) - 4.0d0*ue(j-1,m) + 5.0d0*ue(j,m)) enddo enddo enddo c--------------------------------------------------------------------- c zeta-direction flux differences c--------------------------------------------------------------------- do j=1, grid_points(2)-2 eta = dble(j) * dnym1 do i = 1, grid_points(1)-2 xi = dble(i) * dnxm1 do k=0, grid_points(3)-1 zeta = dble(k) * dnzm1 call exact_solution(xi, eta, zeta, dtemp) do m = 1, 5 ue(k,m) = dtemp(m) enddo dtpp = 1.0d0/dtemp(1) do m = 2, 5 buf(k,m) = dtpp * dtemp(m) enddo cuf(k) = buf(k,4) * buf(k,4) buf(k,1) = cuf(k) + buf(k,2) * buf(k,2) + > buf(k,3) * buf(k,3) q(k) = 0.5d0*(buf(k,2)*ue(k,2) + buf(k,3)*ue(k,3) + > buf(k,4)*ue(k,4)) enddo do k=1, grid_points(3)-2 km1 = k-1 kp1 = k+1 forcing(1,i,j,k) = forcing(1,i,j,k) - > tz2*( ue(kp1,4)-ue(km1,4) )+ > dz1tz1*(ue(kp1,1)-2.0d0*ue(k,1)+ue(km1,1)) forcing(2,i,j,k) = forcing(2,i,j,k) - tz2 * ( > ue(kp1,2)*buf(kp1,4)-ue(km1,2)*buf(km1,4))+ > zzcon2*(buf(kp1,2)-2.0d0*buf(k,2)+buf(km1,2))+ > dz2tz1*( ue(kp1,2)-2.0d0* ue(k,2)+ ue(km1,2)) forcing(3,i,j,k) = forcing(3,i,j,k) - tz2 * ( > ue(kp1,3)*buf(kp1,4)-ue(km1,3)*buf(km1,4))+ > zzcon2*(buf(kp1,3)-2.0d0*buf(k,3)+buf(km1,3))+ > dz3tz1*(ue(kp1,3)-2.0d0*ue(k,3)+ue(km1,3)) forcing(4,i,j,k) = forcing(4,i,j,k) - tz2 * ( > (ue(kp1,4)*buf(kp1,4)+c2*(ue(kp1,5)-q(kp1)))- > (ue(km1,4)*buf(km1,4)+c2*(ue(km1,5)-q(km1))))+ > zzcon1*(buf(kp1,4)-2.0d0*buf(k,4)+buf(km1,4))+ > dz4tz1*( ue(kp1,4)-2.0d0*ue(k,4) +ue(km1,4)) forcing(5,i,j,k) = forcing(5,i,j,k) - tz2 * ( > buf(kp1,4)*(c1*ue(kp1,5)-c2*q(kp1))- > buf(km1,4)*(c1*ue(km1,5)-c2*q(km1)))+ > 0.5d0*zzcon3*(buf(kp1,1)-2.0d0*buf(k,1) > +buf(km1,1))+ > zzcon4*(cuf(kp1)-2.0d0*cuf(k)+cuf(km1))+ > zzcon5*(buf(kp1,5)-2.0d0*buf(k,5)+buf(km1,5))+ > dz5tz1*( ue(kp1,5)-2.0d0*ue(k,5)+ ue(km1,5)) enddo c--------------------------------------------------------------------- c Fourth-order dissipation c--------------------------------------------------------------------- do m = 1, 5 k = 1 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (5.0d0*ue(k,m) - 4.0d0*ue(k+1,m) +ue(k+2,m)) k = 2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (-4.0d0*ue(k-1,m) + 6.0d0*ue(k,m) - > 4.0d0*ue(k+1,m) + ue(k+2,m)) enddo do m = 1, 5 do k = 3, grid_points(3)-4 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp* > (ue(k-2,m) - 4.0d0*ue(k-1,m) + > 6.0d0*ue(k,m) - 4.0d0*ue(k+1,m) + ue(k+2,m)) enddo enddo do m = 1, 5 k = grid_points(3)-3 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(k-2,m) - 4.0d0*ue(k-1,m) + > 6.0d0*ue(k,m) - 4.0d0*ue(k+1,m)) k = grid_points(3)-2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(k-2,m) - 4.0d0*ue(k-1,m) + 5.0d0*ue(k,m)) enddo enddo enddo c--------------------------------------------------------------------- c now change the sign of the forcing function, c--------------------------------------------------------------------- do k = 1, grid_points(3)-2 do j = 1, grid_points(2)-2 do i = 1, grid_points(1)-2 do m = 1, 5 forcing(m,i,j,k) = -1.d0 * forcing(m,i,j,k) enddo enddo enddo enddo return end
lgpl-3.0
benchmark-subsetting/cere
tests/test_04/exact_rhs.f
15
13465
c--------------------------------------------------------------------- c--------------------------------------------------------------------- subroutine exact_rhs c--------------------------------------------------------------------- c--------------------------------------------------------------------- c--------------------------------------------------------------------- c compute the right hand side based on exact solution c--------------------------------------------------------------------- include 'header.h' double precision dtemp(5), xi, eta, zeta, dtpp integer m, i, j, k, ip1, im1, jp1, jm1, km1, kp1 c--------------------------------------------------------------------- c initialize c--------------------------------------------------------------------- do k= 0, grid_points(3)-1 do j = 0, grid_points(2)-1 do i = 0, grid_points(1)-1 do m = 1, 5 forcing(m,i,j,k) = 0.0d0 enddo enddo enddo enddo c--------------------------------------------------------------------- c xi-direction flux differences c--------------------------------------------------------------------- do k = 1, grid_points(3)-2 zeta = dble(k) * dnzm1 do j = 1, grid_points(2)-2 eta = dble(j) * dnym1 do i=0, grid_points(1)-1 xi = dble(i) * dnxm1 call exact_solution(xi, eta, zeta, dtemp) do m = 1, 5 ue(i,m) = dtemp(m) enddo dtpp = 1.0d0 / dtemp(1) do m = 2, 5 buf(i,m) = dtpp * dtemp(m) enddo cuf(i) = buf(i,2) * buf(i,2) buf(i,1) = cuf(i) + buf(i,3) * buf(i,3) + > buf(i,4) * buf(i,4) q(i) = 0.5d0*(buf(i,2)*ue(i,2) + buf(i,3)*ue(i,3) + > buf(i,4)*ue(i,4)) enddo do i = 1, grid_points(1)-2 im1 = i-1 ip1 = i+1 forcing(1,i,j,k) = forcing(1,i,j,k) - > tx2*( ue(ip1,2)-ue(im1,2) )+ > dx1tx1*(ue(ip1,1)-2.0d0*ue(i,1)+ue(im1,1)) forcing(2,i,j,k) = forcing(2,i,j,k) - tx2 * ( > (ue(ip1,2)*buf(ip1,2)+c2*(ue(ip1,5)-q(ip1)))- > (ue(im1,2)*buf(im1,2)+c2*(ue(im1,5)-q(im1))))+ > xxcon1*(buf(ip1,2)-2.0d0*buf(i,2)+buf(im1,2))+ > dx2tx1*( ue(ip1,2)-2.0d0* ue(i,2)+ue(im1,2)) forcing(3,i,j,k) = forcing(3,i,j,k) - tx2 * ( > ue(ip1,3)*buf(ip1,2)-ue(im1,3)*buf(im1,2))+ > xxcon2*(buf(ip1,3)-2.0d0*buf(i,3)+buf(im1,3))+ > dx3tx1*( ue(ip1,3)-2.0d0*ue(i,3) +ue(im1,3)) forcing(4,i,j,k) = forcing(4,i,j,k) - tx2*( > ue(ip1,4)*buf(ip1,2)-ue(im1,4)*buf(im1,2))+ > xxcon2*(buf(ip1,4)-2.0d0*buf(i,4)+buf(im1,4))+ > dx4tx1*( ue(ip1,4)-2.0d0* ue(i,4)+ ue(im1,4)) forcing(5,i,j,k) = forcing(5,i,j,k) - tx2*( > buf(ip1,2)*(c1*ue(ip1,5)-c2*q(ip1))- > buf(im1,2)*(c1*ue(im1,5)-c2*q(im1)))+ > 0.5d0*xxcon3*(buf(ip1,1)-2.0d0*buf(i,1)+ > buf(im1,1))+ > xxcon4*(cuf(ip1)-2.0d0*cuf(i)+cuf(im1))+ > xxcon5*(buf(ip1,5)-2.0d0*buf(i,5)+buf(im1,5))+ > dx5tx1*( ue(ip1,5)-2.0d0* ue(i,5)+ ue(im1,5)) enddo c--------------------------------------------------------------------- c Fourth-order dissipation c--------------------------------------------------------------------- do m = 1, 5 i = 1 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (5.0d0*ue(i,m) - 4.0d0*ue(i+1,m) +ue(i+2,m)) i = 2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (-4.0d0*ue(i-1,m) + 6.0d0*ue(i,m) - > 4.0d0*ue(i+1,m) + ue(i+2,m)) enddo do m = 1, 5 do i = 3, grid_points(1)-4 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp* > (ue(i-2,m) - 4.0d0*ue(i-1,m) + > 6.0d0*ue(i,m) - 4.0d0*ue(i+1,m) + ue(i+2,m)) enddo enddo do m = 1, 5 i = grid_points(1)-3 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(i-2,m) - 4.0d0*ue(i-1,m) + > 6.0d0*ue(i,m) - 4.0d0*ue(i+1,m)) i = grid_points(1)-2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(i-2,m) - 4.0d0*ue(i-1,m) + 5.0d0*ue(i,m)) enddo enddo enddo c--------------------------------------------------------------------- c eta-direction flux differences c--------------------------------------------------------------------- do k = 1, grid_points(3)-2 zeta = dble(k) * dnzm1 do i=1, grid_points(1)-2 xi = dble(i) * dnxm1 do j=0, grid_points(2)-1 eta = dble(j) * dnym1 call exact_solution(xi, eta, zeta, dtemp) do m = 1, 5 ue(j,m) = dtemp(m) enddo dtpp = 1.0d0/dtemp(1) do m = 2, 5 buf(j,m) = dtpp * dtemp(m) enddo cuf(j) = buf(j,3) * buf(j,3) buf(j,1) = cuf(j) + buf(j,2) * buf(j,2) + > buf(j,4) * buf(j,4) q(j) = 0.5d0*(buf(j,2)*ue(j,2) + buf(j,3)*ue(j,3) + > buf(j,4)*ue(j,4)) enddo do j = 1, grid_points(2)-2 jm1 = j-1 jp1 = j+1 forcing(1,i,j,k) = forcing(1,i,j,k) - > ty2*( ue(jp1,3)-ue(jm1,3) )+ > dy1ty1*(ue(jp1,1)-2.0d0*ue(j,1)+ue(jm1,1)) forcing(2,i,j,k) = forcing(2,i,j,k) - ty2*( > ue(jp1,2)*buf(jp1,3)-ue(jm1,2)*buf(jm1,3))+ > yycon2*(buf(jp1,2)-2.0d0*buf(j,2)+buf(jm1,2))+ > dy2ty1*( ue(jp1,2)-2.0* ue(j,2)+ ue(jm1,2)) forcing(3,i,j,k) = forcing(3,i,j,k) - ty2*( > (ue(jp1,3)*buf(jp1,3)+c2*(ue(jp1,5)-q(jp1)))- > (ue(jm1,3)*buf(jm1,3)+c2*(ue(jm1,5)-q(jm1))))+ > yycon1*(buf(jp1,3)-2.0d0*buf(j,3)+buf(jm1,3))+ > dy3ty1*( ue(jp1,3)-2.0d0*ue(j,3) +ue(jm1,3)) forcing(4,i,j,k) = forcing(4,i,j,k) - ty2*( > ue(jp1,4)*buf(jp1,3)-ue(jm1,4)*buf(jm1,3))+ > yycon2*(buf(jp1,4)-2.0d0*buf(j,4)+buf(jm1,4))+ > dy4ty1*( ue(jp1,4)-2.0d0*ue(j,4)+ ue(jm1,4)) forcing(5,i,j,k) = forcing(5,i,j,k) - ty2*( > buf(jp1,3)*(c1*ue(jp1,5)-c2*q(jp1))- > buf(jm1,3)*(c1*ue(jm1,5)-c2*q(jm1)))+ > 0.5d0*yycon3*(buf(jp1,1)-2.0d0*buf(j,1)+ > buf(jm1,1))+ > yycon4*(cuf(jp1)-2.0d0*cuf(j)+cuf(jm1))+ > yycon5*(buf(jp1,5)-2.0d0*buf(j,5)+buf(jm1,5))+ > dy5ty1*(ue(jp1,5)-2.0d0*ue(j,5)+ue(jm1,5)) enddo c--------------------------------------------------------------------- c Fourth-order dissipation c--------------------------------------------------------------------- do m = 1, 5 j = 1 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (5.0d0*ue(j,m) - 4.0d0*ue(j+1,m) +ue(j+2,m)) j = 2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (-4.0d0*ue(j-1,m) + 6.0d0*ue(j,m) - > 4.0d0*ue(j+1,m) + ue(j+2,m)) enddo do m = 1, 5 do j = 3, grid_points(2)-4 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp* > (ue(j-2,m) - 4.0d0*ue(j-1,m) + > 6.0d0*ue(j,m) - 4.0d0*ue(j+1,m) + ue(j+2,m)) enddo enddo do m = 1, 5 j = grid_points(2)-3 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(j-2,m) - 4.0d0*ue(j-1,m) + > 6.0d0*ue(j,m) - 4.0d0*ue(j+1,m)) j = grid_points(2)-2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(j-2,m) - 4.0d0*ue(j-1,m) + 5.0d0*ue(j,m)) enddo enddo enddo c--------------------------------------------------------------------- c zeta-direction flux differences c--------------------------------------------------------------------- do j=1, grid_points(2)-2 eta = dble(j) * dnym1 do i = 1, grid_points(1)-2 xi = dble(i) * dnxm1 do k=0, grid_points(3)-1 zeta = dble(k) * dnzm1 call exact_solution(xi, eta, zeta, dtemp) do m = 1, 5 ue(k,m) = dtemp(m) enddo dtpp = 1.0d0/dtemp(1) do m = 2, 5 buf(k,m) = dtpp * dtemp(m) enddo cuf(k) = buf(k,4) * buf(k,4) buf(k,1) = cuf(k) + buf(k,2) * buf(k,2) + > buf(k,3) * buf(k,3) q(k) = 0.5d0*(buf(k,2)*ue(k,2) + buf(k,3)*ue(k,3) + > buf(k,4)*ue(k,4)) enddo do k=1, grid_points(3)-2 km1 = k-1 kp1 = k+1 forcing(1,i,j,k) = forcing(1,i,j,k) - > tz2*( ue(kp1,4)-ue(km1,4) )+ > dz1tz1*(ue(kp1,1)-2.0d0*ue(k,1)+ue(km1,1)) forcing(2,i,j,k) = forcing(2,i,j,k) - tz2 * ( > ue(kp1,2)*buf(kp1,4)-ue(km1,2)*buf(km1,4))+ > zzcon2*(buf(kp1,2)-2.0d0*buf(k,2)+buf(km1,2))+ > dz2tz1*( ue(kp1,2)-2.0d0* ue(k,2)+ ue(km1,2)) forcing(3,i,j,k) = forcing(3,i,j,k) - tz2 * ( > ue(kp1,3)*buf(kp1,4)-ue(km1,3)*buf(km1,4))+ > zzcon2*(buf(kp1,3)-2.0d0*buf(k,3)+buf(km1,3))+ > dz3tz1*(ue(kp1,3)-2.0d0*ue(k,3)+ue(km1,3)) forcing(4,i,j,k) = forcing(4,i,j,k) - tz2 * ( > (ue(kp1,4)*buf(kp1,4)+c2*(ue(kp1,5)-q(kp1)))- > (ue(km1,4)*buf(km1,4)+c2*(ue(km1,5)-q(km1))))+ > zzcon1*(buf(kp1,4)-2.0d0*buf(k,4)+buf(km1,4))+ > dz4tz1*( ue(kp1,4)-2.0d0*ue(k,4) +ue(km1,4)) forcing(5,i,j,k) = forcing(5,i,j,k) - tz2 * ( > buf(kp1,4)*(c1*ue(kp1,5)-c2*q(kp1))- > buf(km1,4)*(c1*ue(km1,5)-c2*q(km1)))+ > 0.5d0*zzcon3*(buf(kp1,1)-2.0d0*buf(k,1) > +buf(km1,1))+ > zzcon4*(cuf(kp1)-2.0d0*cuf(k)+cuf(km1))+ > zzcon5*(buf(kp1,5)-2.0d0*buf(k,5)+buf(km1,5))+ > dz5tz1*( ue(kp1,5)-2.0d0*ue(k,5)+ ue(km1,5)) enddo c--------------------------------------------------------------------- c Fourth-order dissipation c--------------------------------------------------------------------- do m = 1, 5 k = 1 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (5.0d0*ue(k,m) - 4.0d0*ue(k+1,m) +ue(k+2,m)) k = 2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (-4.0d0*ue(k-1,m) + 6.0d0*ue(k,m) - > 4.0d0*ue(k+1,m) + ue(k+2,m)) enddo do m = 1, 5 do k = 3, grid_points(3)-4 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp* > (ue(k-2,m) - 4.0d0*ue(k-1,m) + > 6.0d0*ue(k,m) - 4.0d0*ue(k+1,m) + ue(k+2,m)) enddo enddo do m = 1, 5 k = grid_points(3)-3 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(k-2,m) - 4.0d0*ue(k-1,m) + > 6.0d0*ue(k,m) - 4.0d0*ue(k+1,m)) k = grid_points(3)-2 forcing(m,i,j,k) = forcing(m,i,j,k) - dssp * > (ue(k-2,m) - 4.0d0*ue(k-1,m) + 5.0d0*ue(k,m)) enddo enddo enddo c--------------------------------------------------------------------- c now change the sign of the forcing function, c--------------------------------------------------------------------- do k = 1, grid_points(3)-2 do j = 1, grid_points(2)-2 do i = 1, grid_points(1)-2 do m = 1, 5 forcing(m,i,j,k) = -1.d0 * forcing(m,i,j,k) enddo enddo enddo enddo return end
lgpl-3.0
sliem/docker-hep
prospino/on_the_web_10_17_14/Pro2_matrix/Xmatrix_lq_gg.f
2
106892
c -------------------------------------------------------------------- real*8 function LQ_GGB(s,t1,ms1) implicit none real*8 Pi,Nc,Co,Ck,alphas,fac real*8 s,t1,u1,ms1 Pi = 4.D0*atan(1.D0) Nc = 3.D0 Co = 24.D0 Ck = 8.D0/3.D0 alphas = 1.D0 u1 = - s - t1 fac = 1.D0/(64*Pi*(Nc**2-1.D0)**2) LQ_GGB = + + Co*Pi**2*alphas**2 * ( 128*ms1**2*s**(-3) - 64*ms1**2*s**(-1) + *t1**(-1)*u1**(-1) - 128*ms1**4*s**(-2)*t1**(-1)*u1**(-1) + + 64*ms1**4*t1**(-2)*u1**(-2) - 64*s**(-4)*t1*u1 + 32*s**(-2) ) LQ_GGB = LQ_GGB + Ck*Pi**2*alphas**2 *(64*ms1**2*s**(-1)*t1**(-1) + *u1**(-1) - 64*ms1**4*t1**(-2)*u1**(-2) - 32*s**(-2) ) LQ_GGB = fac * LQ_GGB end c -------------------------------------------------------------------- real*8 function LQ_GG1(s,t1,ms1,mu) implicit none real*8 Pi,Nc,Nf,alphas real*8 s,t1,u1,ms1,sca,mu real*8 conalp,consof,LQ_GGB real*8 P1,P2 Pi = 4.D0*atan(1.D0) Nc = 3.D0 Nf = 6.D0 alphas = 1.D0 sca = (mu/ms1)**2 u1 = - s - t1 P1 = -2.D0 * Nc * log(-t1/ms1**2) & + ( 11.D0/3.D0*Nc - 2.D0/3.D0 * (Nf-1.D0) )/2.D0 P2 = -2.D0 * Nc * log(-u1/ms1**2) & + ( 11.D0/3.D0*Nc - 2.D0/3.D0 * (Nf-1.D0) )/2.D0 consof = -alphas/2.D0/Pi * LQ_GGB(s,t1,ms1) & * ( P1 + P2 ) * log(sca) conalp = alphas/2.D0/Pi * LQ_GGB(s,t1,ms1) & * ( 11.D0/3.D0*Nc - 2.D0/3.D0 * (Nf-1.D0)) * log(sca) LQ_GG1 = conalp + consof end c -------------------------------------------------------------------- real*8 function LQ_GG2(s,t1,s4,ms1,del,s4max,mu) implicit none real*8 Pi,Nc,alphas real*8 s,t1,s4,del,s4max,ms1,sca,mu real*8 dldel1,LQ_GGB real*8 P1 Pi=4.D0*atan(1.D0) Nc = 3.D0 alphas = 1.D0 sca = (mu/ms1)**2 dldel1 = log(s4max/ms1**2) & - ( s4max - del )/s4 P1 = 2.D0*Nc*dldel1 LQ_GG2 = -alphas/Pi*LQ_GGB(s,t1,ms1)*P1 * log(sca) end c -------------------------------------------------------------------- real*8 function LQ_GG3(s,t1,s4,ms1,mu) implicit none real*8 Pi,Nc,Co,Ck,alphas,fac real*8 s,t1,u1,s4,ms1,sca,mu real*8 COLO1(9) Pi = 4.D0*atan(1.D0) Nc = 3.D0 Co = Nc*(Nc**2-1.D0) Ck = (Nc**2-1.D0)/Nc alphas = 1.D0 sca = (mu/ms1)**2 u1 = s4 - s - t1 fac = s4 /(s4+ms1**2) /8.D0 /(16*Pi**2)**2 /(Nc**2-1.D0)**2 COLO1(9) = -log(sca) LQ_GG3 = 0.D0 LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( 2048*ms1**2* + s**(-4)*t1**(-2)*u1**2 - 4096*ms1**2*s**(-4)*t1*s4**(-1) + + 2048*ms1**2*s**(-4)*t1**2*u1**(-2) + 4096*ms1**2*s**(-4)* + t1**2*s4**(-2) + 6144*ms1**2*s**(-4) - 4096*ms1**2*s**(-3)* + t1**(-3)*u1**2 - 2048*ms1**2*s**(-3)*t1**(-2)*u1 - 14336* + ms1**2*s**(-3)*t1**(-1) - 2048*ms1**2*s**(-3)*t1*u1**(-2) + + 4096*ms1**2*s**(-3)*t1*s4**(-2) - 4096*ms1**2*s**(-3)*t1**2* + u1**(-3) - 14336*ms1**2*s**(-3)*u1**(-1) + 6144*ms1**2* + s**(-3)*s4**(-1) - 8192*ms1**2*s**(-2)*t1**(-3)*u1 - 4096* + ms1**2*s**(-2)*t1**(-2)*s4*(s+u1)**(-1) + 1024*ms1**2*s**(-2) + *t1**(-2)*s4**2*(s+u1)**(-2) + 6144*ms1**2*s**(-2)*t1**(-1)* + u1**(-1)*s4*(s+t1)**(-1) + 6144*ms1**2*s**(-2)*t1**(-1)* + u1**(-1)*s4*(s+u1)**(-1) - 16384*ms1**2*s**(-2)*t1**(-1)* + u1**(-1) + 8192*ms1**2*s**(-2)*t1**(-1)*s4**(-1) - 8192* + ms1**2*s**(-2)*t1*u1**(-3) - 4096*ms1**2*s**(-2)*u1**(-2)*s4* + (s+t1)**(-1) ) LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-2)*u1**(-2)*s4**2*(s+t1)**(-2) + 8192*ms1**2*s**(-2)* + u1**(-1)*s4**(-1) + 2048*ms1**2*s**(-2)*s4**(-2) - 6144* + ms1**2*s**(-1)*t1**(-3) - 2048*ms1**2*s**(-1)*t1**(-2)* + u1**(-1)*s4**2*(s+u1)**(-2) - 2048*ms1**2*s**(-1)*t1**(-1)* + u1**(-2)*s4**2*(s+t1)**(-2) + 4096*ms1**2*s**(-1)*t1**(-1)* + u1**(-1)*s4**(-1) - 6144*ms1**2*s**(-1)*u1**(-3) - 2048* + ms1**2*t1**(-3)*u1**(-1) - 2048*ms1**2*t1**(-1)*u1**(-3) - + 4096*ms1**4*s**(-3)*t1**(-3)*u1 - 12288*ms1**4*s**(-3)* + t1**(-1)*s4**(-1) - 4096*ms1**4*s**(-3)*t1*u1**(-3) - 12288* + ms1**4*s**(-3)*u1**(-1)*s4**(-1) + 8192*ms1**4*s**(-3)* + s4**(-2) + 4096*ms1**4*s**(-2)*t1**(-4)*u1 + 2048*ms1**4* + s**(-2)*t1**(-3)*s4*(s+u1)**(-1) - 2048*ms1**4*s**(-2)* + t1**(-3) + 8192*ms1**4*s**(-2)*t1**(-2)*u1**(-1)*s4* + (s+u1)**(-1) - 4096*ms1**4*s**(-2)*t1**(-2)*u1**(-1) + 2048* + ms1**4*s**(-2)*t1**(-2)*s4**(-1) ) LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( 8192*ms1**4* + s**(-2)*t1**(-1)*u1**(-2)*s4*(s+t1)**(-1) - 4096*ms1**4* + s**(-2)*t1**(-1)*u1**(-2) - 16384*ms1**4*s**(-2)*t1**(-1)* + u1**(-1)*s4**(-1) + 4096*ms1**4*s**(-2)*t1**(-1)*s4**(-2) + + 4096*ms1**4*s**(-2)*t1*u1**(-4) + 2048*ms1**4*s**(-2)* + u1**(-3)*s4*(s+t1)**(-1) - 2048*ms1**4*s**(-2)*u1**(-3) + + 2048*ms1**4*s**(-2)*u1**(-2)*s4**(-1) + 4096*ms1**4*s**(-2)* + u1**(-1)*s4**(-2) + 8192*ms1**4*s**(-1)*t1**(-4) + 6144* + ms1**4*s**(-1)*t1**(-3)*u1**(-1)*s4*(s+u1)**(-1) - 2048* + ms1**4*s**(-1)*t1**(-3)*u1**(-1)*s4**2*(s+u1)**(-2) - 2048* + ms1**4*s**(-1)*t1**(-3)*u1**(-1) + 4096*ms1**4*s**(-1)* + t1**(-2)*u1**(-2) - 2048*ms1**4*s**(-1)*t1**(-2)*u1**(-1)* + s4**(-1) + 6144*ms1**4*s**(-1)*t1**(-1)*u1**(-3)*s4* + (s+t1)**(-1) - 2048*ms1**4*s**(-1)*t1**(-1)*u1**(-3)*s4**2* + (s+t1)**(-2) - 2048*ms1**4*s**(-1)*t1**(-1)*u1**(-3) - 2048* + ms1**4*s**(-1)*t1**(-1)*u1**(-2)*s4**(-1) ) LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( 8192*ms1**4* + s**(-1)*u1**(-4) + 2048*ms1**4*s*t1**(-4)*u1**(-2) + 2048* + ms1**4*s*t1**(-2)*u1**(-4) + 6144*ms1**4*t1**(-4)*u1**(-1) - + 2048*ms1**4*t1**(-3)*u1**(-2)*s4*(s+u1)**(-1) + 2048*ms1**4* + t1**(-3)*u1**(-2)*s4**2*(s+u1)**(-2) + 2048*ms1**4*t1**(-3)* + u1**(-2) - 2048*ms1**4*t1**(-2)*u1**(-3)*s4*(s+t1)**(-1) + + 2048*ms1**4*t1**(-2)*u1**(-3)*s4**2*(s+t1)**(-2) + 2048* + ms1**4*t1**(-2)*u1**(-3) + 6144*ms1**4*t1**(-1)*u1**(-4) - + 4096*ms1**6*s**(-2)*t1**(-4)*s4*(s+u1)**(-1) + 2048*ms1**6* + s**(-2)*t1**(-4)*s4**2*(s+u1)**(-2) + 6144*ms1**6*s**(-2)* + t1**(-4) + 4096*ms1**6*s**(-2)*t1**(-3)*u1**(-1)*s4* + (s+u1)**(-1) - 4096*ms1**6*s**(-2)*t1**(-3)*u1**(-1) + 4096* + ms1**6*s**(-2)*t1**(-2)*u1**(-2) - 8192*ms1**6*s**(-2)* + t1**(-2)*u1**(-1)*s4**(-1) + 4096*ms1**6*s**(-2)*t1**(-2)* + s4**(-2) + 4096*ms1**6*s**(-2)*t1**(-1)*u1**(-3)*s4* + (s+t1)**(-1) ) LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( -4096*ms1**6 + *s**(-2)*t1**(-1)*u1**(-3) - 8192*ms1**6*s**(-2)*t1**(-1)* + u1**(-2)*s4**(-1) - 4096*ms1**6*s**(-2)*u1**(-4)*s4* + (s+t1)**(-1) + 2048*ms1**6*s**(-2)*u1**(-4)*s4**2* + (s+t1)**(-2) + 6144*ms1**6*s**(-2)*u1**(-4) + 4096*ms1**6* + s**(-2)*u1**(-2)*s4**(-2) + 4096*ms1**6*s**(-1)*t1**(-4)* + u1**(-1) + 4096*ms1**6*s**(-1)*t1**(-3)*u1**(-2)*s4* + (s+u1)**(-1) - 4096*ms1**6*s**(-1)*t1**(-3)*u1**(-2) + 4096* + ms1**6*s**(-1)*t1**(-2)*u1**(-3)*s4*(s+t1)**(-1) - 4096* + ms1**6*s**(-1)*t1**(-2)*u1**(-3) - 4096*ms1**6*s**(-1)* + t1**(-2)*u1**(-2)*s4**(-1) + 4096*ms1**6*s**(-1)*t1**(-1)* + u1**(-4) + 2048*ms1**6*t1**(-4)*u1**(-2) + 2048*ms1**6* + t1**(-2)*u1**(-4) + 2048*s**(-4)*t1**(-2)*u1**3 + 2048* + s**(-4)*t1**(-1)*u1**2 + 2048*s**(-4)*t1 + 2048*s**(-4)*t1**2 + *u1**(-1) + 4096*s**(-4)*t1**2*s4**(-1) + 2048*s**(-4)*t1**3* + u1**(-2) ) LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Co*Pi**4*alphas**3 * (6144*s**(-4)* + u1 + 4096*s**(-3)*t1**(-2)*u1**2 + 4096*s**(-3)*t1*s4**(-1) + + 4096*s**(-3)*t1**2*u1**(-2) + 3072*s**(-2)*t1**(-2)*u1 + + 2048*s**(-2)*t1**(-1)*s4*(s+t1)**(-1) - 1024*s**(-2)*t1**(-1) + *s4*(s+u1)**(-1) + 1024*s**(-2)*t1**(-1)*s4**2*(s+u1)**(-2) + - 1024*s**(-2)*t1**(-1) + 3072*s**(-2)*t1*u1**(-2) - 1024* + s**(-2)*u1**(-1)*s4*(s+t1)**(-1) + 2048*s**(-2)*u1**(-1)*s4* + (s+u1)**(-1) + 1024*s**(-2)*u1**(-1)*s4**2*(s+t1)**(-2) - + 1024*s**(-2)*u1**(-1) + 2048*s**(-2)*s4**(-1) + 1024*s**(-1)* + t1**(-2) + 1024*s**(-1)*u1**(-2) ) LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Ck*Pi**4*alphas**3 * ( 2048*ms1**2* + s**(-2)*t1**(-2)*s4*(s+u1)**(-1) - 1024*ms1**2*s**(-2)* + t1**(-2)*s4**2*(s+u1)**(-2) - 2048*ms1**2*s**(-2)*t1**(-2) + + 4096*ms1**2*s**(-2)*t1**(-1)*u1**(-1) - 4096*ms1**2*s**(-2)* + t1**(-1)*s4**(-1) + 2048*ms1**2*s**(-2)*u1**(-2)*s4* + (s+t1)**(-1) - 1024*ms1**2*s**(-2)*u1**(-2)*s4**2* + (s+t1)**(-2) - 2048*ms1**2*s**(-2)*u1**(-2) - 4096*ms1**2* + s**(-2)*u1**(-1)*s4**(-1) - 2048*ms1**2*s**(-2)*s4**(-2) + + 2048*ms1**2*s**(-1)*t1**(-3) - 2048*ms1**2*s**(-1)*t1**(-2)* + u1**(-1)*s4*(s+u1)**(-1) + 2048*ms1**2*s**(-1)*t1**(-2)* + u1**(-1)*s4**2*(s+u1)**(-2) + 2048*ms1**2*s**(-1)*t1**(-2)* + u1**(-1) - 2048*ms1**2*s**(-1)*t1**(-1)*u1**(-2)*s4* + (s+t1)**(-1) + 2048*ms1**2*s**(-1)*t1**(-1)*u1**(-2)*s4**2* + (s+t1)**(-2) + 2048*ms1**2*s**(-1)*t1**(-1)*u1**(-2) + 2048* + ms1**2*s**(-1)*u1**(-3) + 2048*ms1**2*t1**(-3)*u1**(-1) + + 2048*ms1**2*t1**(-1)*u1**(-3) ) LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Ck*Pi**4*alphas**3 * ( -2048*ms1**4 + *s**(-2)*t1**(-3)*s4*(s+u1)**(-1) + 2048*ms1**4*s**(-2)* + t1**(-3) + 4096*ms1**4*s**(-2)*t1**(-2)*u1**(-1) - 2048* + ms1**4*s**(-2)*t1**(-2)*s4**(-1) + 4096*ms1**4*s**(-2)* + t1**(-1)*u1**(-2) - 4096*ms1**4*s**(-2)*t1**(-1)*s4**(-2) - + 2048*ms1**4*s**(-2)*u1**(-3)*s4*(s+t1)**(-1) + 2048*ms1**4* + s**(-2)*u1**(-3) - 2048*ms1**4*s**(-2)*u1**(-2)*s4**(-1) - + 4096*ms1**4*s**(-2)*u1**(-1)*s4**(-2) - 6144*ms1**4*s**(-1)* + t1**(-3)*u1**(-1)*s4*(s+u1)**(-1) + 2048*ms1**4*s**(-1)* + t1**(-3)*u1**(-1)*s4**2*(s+u1)**(-2) + 6144*ms1**4*s**(-1)* + t1**(-3)*u1**(-1) - 4096*ms1**4*s**(-1)*t1**(-2)*u1**(-2) + + 2048*ms1**4*s**(-1)*t1**(-2)*u1**(-1)*s4**(-1) - 6144*ms1**4* + s**(-1)*t1**(-1)*u1**(-3)*s4*(s+t1)**(-1) + 2048*ms1**4* + s**(-1)*t1**(-1)*u1**(-3)*s4**2*(s+t1)**(-2) + 6144*ms1**4* + s**(-1)*t1**(-1)*u1**(-3) + 2048*ms1**4*s**(-1)*t1**(-1)* + u1**(-2)*s4**(-1) ) LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Ck*Pi**4*alphas**3 * ( -2048*ms1**4 + *s*t1**(-4)*u1**(-2) - 2048*ms1**4*s*t1**(-2)*u1**(-4) - 2048 + *ms1**4*t1**(-4)*u1**(-1) + 2048*ms1**4*t1**(-3)*u1**(-2)*s4* + (s+u1)**(-1) - 2048*ms1**4*t1**(-3)*u1**(-2)*s4**2* + (s+u1)**(-2) - 2048*ms1**4*t1**(-3)*u1**(-2) + 2048*ms1**4* + t1**(-2)*u1**(-3)*s4*(s+t1)**(-1) - 2048*ms1**4*t1**(-2)* + u1**(-3)*s4**2*(s+t1)**(-2) - 2048*ms1**4*t1**(-2)*u1**(-3) + - 2048*ms1**4*t1**(-1)*u1**(-4) + 4096*ms1**6*s**(-2)* + t1**(-4)*s4*(s+u1)**(-1) - 2048*ms1**6*s**(-2)*t1**(-4)*s4**2 + *(s+u1)**(-2) - 2048*ms1**6*s**(-2)*t1**(-4) - 4096*ms1**6* + s**(-2)*t1**(-2)*u1**(-2) + 12288*ms1**6*s**(-2)*t1**(-2)* + u1**(-1)*s4**(-1) - 4096*ms1**6*s**(-2)*t1**(-2)*s4**(-2) + + 12288*ms1**6*s**(-2)*t1**(-1)*u1**(-2)*s4**(-1) - 8192*ms1**6 + *s**(-2)*t1**(-1)*u1**(-1)*s4**(-2) + 4096*ms1**6*s**(-2)* + u1**(-4)*s4*(s+t1)**(-1) - 2048*ms1**6*s**(-2)*u1**(-4)*s4**2 + *(s+t1)**(-2) ) LQ_GG3 = LQ_GG3 + COLO1(9)*Nc*Ck*Pi**4*alphas**3 * ( -2048*ms1**6 + *s**(-2)*u1**(-4) - 4096*ms1**6*s**(-2)*u1**(-2)*s4**(-2) - + 4096*ms1**6*s**(-1)*t1**(-3)*u1**(-2)*s4*(s+u1)**(-1) + 4096* + ms1**6*s**(-1)*t1**(-3)*u1**(-2) - 4096*ms1**6*s**(-1)* + t1**(-2)*u1**(-3)*s4*(s+t1)**(-1) + 4096*ms1**6*s**(-1)* + t1**(-2)*u1**(-3) + 4096*ms1**6*s**(-1)*t1**(-2)*u1**(-2)* + s4**(-1) - 2048*ms1**6*t1**(-4)*u1**(-2) - 2048*ms1**6* + t1**(-2)*u1**(-4) - 1024*s**(-2)*t1**(-2)*u1 + 1024*s**(-2)* + t1**(-1)*s4*(s+u1)**(-1) - 1024*s**(-2)*t1**(-1)*s4**2* + (s+u1)**(-2) - 1024*s**(-2)*t1**(-1) - 1024*s**(-2)*t1* + u1**(-2) + 1024*s**(-2)*u1**(-1)*s4*(s+t1)**(-1) - 1024* + s**(-2)*u1**(-1)*s4**2*(s+t1)**(-2) - 1024*s**(-2)*u1**(-1) + - 2048*s**(-2)*s4**(-1) - 1024*s**(-1)*t1**(-2) - 1024* + s**(-1)*u1**(-2) ) LQ_GG3 = fac * LQ_GG3 end c -------------------------------------------------------------------- real*8 function LQ_GGD(s,t1,s4,ms1,del,s4max) implicit none real*8 Pi,Nc,Co,Ck,Cqed,alphas,fac real*8 s,t1,u1,ms1,s4,del,s4max,t,u real*8 xw,COLO1(9),dldel1,dldel2 real*8 m2(5) Pi=4.D0*atan(1.D0) Nc = 3.D0 Co = Nc*(Nc**2-1.D0) Ck = (Nc**2-1.D0)/Nc Cqed = Nc**2 - 1/Nc**2 alphas = 1.D0 u1 = - s - t1 t = t1 + ms1**2 u = u1 + ms1**2 xw = sqrt(1.D0-4.D0*ms1**2/s) m2(1) = s m2(2) = t1 m2(3) = u1 m2(4) = s4 m2(5) = ms1**2 call LOGAS_LQ(m2,COLO1) dldel1 = log(s4max/ms1**2) & - ( s4max - del )/s4 dldel2 = log(s4max/ms1**2)**2 & - 2.D0* ( s4max - del )/s4 * log(s4/ms1**2) fac = 1.D0/(64*Pi*(Nc**2-1.D0)**2) LQ_GGD = + + Nc*Co*Pi*alphas**3*dldel1 * ( 40*ms1**2*s**(-3)*t**(-1)*t1 - + 40*ms1**2*s**(-3)*u**(-1)*t1 - 180*ms1**2*s**(-3) + 100* + ms1**2*s**(-2)*t**(-1) + 60*ms1**2*s**(-2)*u**(-1) - 130* + ms1**2*s**(-2)*t1**(-1) - 130*ms1**2*s**(-2)*u1**(-1) + 32* + ms1**2*s**(-1)*t**(-1)*t1**(-1) + 32*ms1**2*s**(-1)*u**(-1)* + u1**(-1) - 22*ms1**2*s**(-1)*t1**(-2) - 22*ms1**2*s**(-1)* + u1**(-2) + 34*ms1**4*s**(-3)*t**(-1) + 34*ms1**4*s**(-3)* + u**(-1) - 8*ms1**4*s**(-3)*t1**(-1) - 8*ms1**4*s**(-3)* + u1**(-1) + 98*ms1**4*s**(-2)*t**(-1)*t1**(-1) + 98*ms1**4* + s**(-2)*u**(-1)*u1**(-1) - 96*ms1**4*s**(-2)*t1**(-2) - 96* + ms1**4*s**(-2)*u1**(-2) + 34*ms1**4*s**(-1)*t**(-1)*t1**(-2) + + 34*ms1**4*s**(-1)*u**(-1)*u1**(-2) - 12*ms1**4*s**(-1)* + t1**(-3) - 12*ms1**4*s**(-1)*u1**(-3) + 8*ms1**6*s**(-3)* + t**(-1)*t1**(-1) + 8*ms1**6*s**(-3)*u**(-1)*u1**(-1) + 32* + ms1**6*s**(-2)*t**(-1)*t1**(-2) + 32*ms1**6*s**(-2)*u**(-1)* + u1**(-2) ) LQ_GGD = LQ_GGD + Nc*Co*Pi*alphas**3*dldel1 * (12*ms1**6*s**(-1)* + t**(-1)*t1**(-3) + 12*ms1**6*s**(-1)*u**(-1)*u1**(-3) - 64* + s**(-4)*t1**2 + 14*s**(-3)*t**(-1)*t1**2 + 14*s**(-3)*u**(-1) + *t1**2 - 64*s**(-3)*t1 + 34*s**(-2)*t**(-1)*t1 - 6*s**(-2)* + u**(-1)*t1 - 86*s**(-2) + 10*s**(-1)*t**(-1) - 10*s**(-1)* + u**(-1) - 10*s**(-1)*t1**(-1) - 10*s**(-1)*u1**(-1) ) LQ_GGD = LQ_GGD + Nc*Co*Pi*alphas**3*dldel2 * (256*ms1**2*s**(-3) + + 128*ms1**2*s**(-2)*t1**(-1) + 128*ms1**2*s**(-2)*u1**(-1) + + 128*ms1**4*s**(-2)*t1**(-2) + 128*ms1**4*s**(-2)*u1**(-2) + + 128*s**(-4)*t1**2 + 128*s**(-3)*t1 + 64*s**(-2) ) LQ_GGD = LQ_GGD + Nc*Ck*Pi*alphas**3*dldel1 * (112*ms1**2*s**(-3) + + 88*ms1**2*s**(-2)*t**(-1) + 88*ms1**2*s**(-2)*u**(-1) - 52 + *ms1**2*s**(-2)*t1**(-1) - 52*ms1**2*s**(-2)*u1**(-1) - 64* + ms1**2*s**(-1)*t**(-1)*t1**(-1) - 96*ms1**2*s**(-1)*t**(-1)* + u1**(-1) - 96*ms1**2*s**(-1)*u**(-1)*t1**(-1) - 64*ms1**2* + s**(-1)*u**(-1)*u1**(-1) + 40*ms1**2*s**(-1)*t1**(-2) + 40* + ms1**2*s**(-1)*u1**(-2) + 40*ms1**4*s**(-3)*t**(-1) + 40* + ms1**4*s**(-3)*u**(-1) - 32*ms1**4*s**(-3)*t1**(-1) - 32* + ms1**4*s**(-3)*u1**(-1) + 436*ms1**4*s**(-2)*t**(-1)*t1**(-1) + + 192*ms1**4*s**(-2)*t**(-1)*u1**(-1) + 192*ms1**4*s**(-2)* + u**(-1)*t1**(-1) + 436*ms1**4*s**(-2)*u**(-1)*u1**(-1) - 80* + ms1**4*s**(-2)*t1**(-2) + 32*ms1**4*s**(-2)*t1**(-1)*u1**(-1) + - 80*ms1**4*s**(-2)*u1**(-2) - 56*ms1**4*s**(-1)*t**(-1)* + t1**(-2) - 56*ms1**4*s**(-1)*u**(-1)*u1**(-2) + 16*ms1**4* + s**(-1)*t1**(-3) + 16*ms1**4*s**(-1)*u1**(-3) + 32*ms1**6* + s**(-3)*t**(-1)*t1**(-1) ) LQ_GGD = LQ_GGD + Nc*Ck*Pi*alphas**3*dldel1 * (32*ms1**6*s**(-3)* + u**(-1)*u1**(-1) + 400*ms1**6*s**(-2)*t**(-1)*t1**(-2) + 176* + ms1**6*s**(-2)*t**(-1)*t1**(-1)*u1**(-1) + 176*ms1**6*s**(-2) + *u**(-1)*t1**(-1)*u1**(-1) + 400*ms1**6*s**(-2)*u**(-1)* + u1**(-2) - 128*ms1**6*s**(-2)*t1**(-3) - 64*ms1**6*s**(-2)* + t1**(-2)*u1**(-1) - 64*ms1**6*s**(-2)*t1**(-1)*u1**(-2) - 128 + *ms1**6*s**(-2)*u1**(-3) - 16*ms1**6*s**(-1)*t**(-1)*t1**(-3) + - 16*ms1**6*s**(-1)*u**(-1)*u1**(-3) + 128*ms1**8*s**(-2)* + t**(-1)*t1**(-3) + 64*ms1**8*s**(-2)*t**(-1)*t1**(-2)* + u1**(-1) + 64*ms1**8*s**(-2)*u**(-1)*t1**(-1)*u1**(-2) + 128* + ms1**8*s**(-2)*u**(-1)*u1**(-3) + 64*s**(-4)*t1**2 - 8* + s**(-3)*t**(-1)*t1**2 - 8*s**(-3)*u**(-1)*t1**2 + 64*s**(-3)* + t1 + 4*s**(-2)*t**(-1)*t1 - 20*s**(-2)*u**(-1)*t1 + 80* + s**(-2) - 8*s**(-1)*t**(-1) - 20*s**(-1)*u**(-1) + 40*s**(-1) + *t1**(-1) + 40*s**(-1)*u1**(-1) + 16*t**(-1)*u1**(-1) + 16* + u**(-1)*t1**(-1) ) LQ_GGD = LQ_GGD + Nc*Ck*Pi*alphas**3*dldel2 * ( - 128*ms1**2* + s**(-2)*t1**(-1) - 128*ms1**2*s**(-2)*u1**(-1) - 128*ms1**4* + s**(-2)*t1**(-2) - 256*ms1**4*s**(-2)*t1**(-1)*u1**(-1) - 128 + *ms1**4*s**(-2)*u1**(-2) - 64*s**(-2) ) LQ_GGD = LQ_GGD + Cqed*Pi*alphas**3*dldel1 * ( 24*ms1**2*s**(-2)* + t1**(-1) + 24*ms1**2*s**(-2)*u1**(-1) + 16*ms1**2*s**(-1)* + t**(-1)*t1**(-1) + 48*ms1**2*s**(-1)*t**(-1)*u1**(-1) + 48* + ms1**2*s**(-1)*u**(-1)*t1**(-1) + 16*ms1**2*s**(-1)*u**(-1)* + u1**(-1) - 8*ms1**2*s**(-1)*t1**(-2) - 8*ms1**2*s**(-1)* + u1**(-2) - 160*ms1**4*s**(-2)*t**(-1)*t1**(-1) - 120*ms1**4* + s**(-2)*t**(-1)*u1**(-1) - 120*ms1**4*s**(-2)*u**(-1)* + t1**(-1) - 160*ms1**4*s**(-2)*u**(-1)*u1**(-1) + 48*ms1**4* + s**(-2)*t1**(-2) + 32*ms1**4*s**(-2)*t1**(-1)*u1**(-1) + 48* + ms1**4*s**(-2)*u1**(-2) + 8*ms1**4*s**(-1)*t**(-1)*t1**(-2) + + 8*ms1**4*s**(-1)*u**(-1)*u1**(-2) - 176*ms1**6*s**(-2)* + t**(-1)*t1**(-2) - 144*ms1**6*s**(-2)*t**(-1)*t1**(-1)* + u1**(-1) - 144*ms1**6*s**(-2)*u**(-1)*t1**(-1)*u1**(-1) - 176 + *ms1**6*s**(-2)*u**(-1)*u1**(-2) + 64*ms1**6*s**(-2)*t1**(-3) + + 64*ms1**6*s**(-2)*t1**(-2)*u1**(-1) + 64*ms1**6*s**(-2)* + t1**(-1)*u1**(-2) ) LQ_GGD = LQ_GGD + Cqed*Pi*alphas**3*dldel1 * ( 64*ms1**6*s**(-2)* + u1**(-3) - 64*ms1**8*s**(-2)*t**(-1)*t1**(-3) - 64*ms1**8* + s**(-2)*t**(-1)*t1**(-2)*u1**(-1) - 64*ms1**8*s**(-2)*u**(-1) + *t1**(-1)*u1**(-2) - 64*ms1**8*s**(-2)*u**(-1)*u1**(-3) + 8* + s**(-2)*t**(-1)*t1 - 8*s**(-2)*u**(-1)*t1 - 48*s**(-2) - 8* + s**(-1)*u**(-1) - 16*s**(-1)*t1**(-1) - 16*s**(-1)*u1**(-1) + - 8*t**(-1)*u1**(-1) - 8*u**(-1)*t1**(-1) ) LQ_GGD = LQ_GGD + COLO1(1)*Nc*Ck*Pi*alphas**3*dldel1 * ( - 128* + ms1**2*s**(-5)*t1**2*xw**(-1) - 128*ms1**2*s**(-4)*t1* + xw**(-1) + 64*ms1**2*s**(-3)*xw**(-1) + 64*ms1**2*s**(-2)* + t1**(-1)*xw**(-1) + 64*ms1**2*s**(-2)*u1**(-1)*xw**(-1) - 256 + *ms1**4*s**(-4)*xw**(-1) - 128*ms1**4*s**(-3)*t1**(-1)* + xw**(-1) - 128*ms1**4*s**(-3)*u1**(-1)*xw**(-1) + 64*ms1**4* + s**(-2)*t1**(-2)*xw**(-1) + 64*ms1**4*s**(-2)*u1**(-2)* + xw**(-1) - 128*ms1**6*s**(-3)*t1**(-2)*xw**(-1) - 128*ms1**6* + s**(-3)*u1**(-2)*xw**(-1) + 64*s**(-4)*t1**2*xw**(-1) + 64* + s**(-3)*t1*xw**(-1) + 32*s**(-2)*xw**(-1) ) LQ_GGD = LQ_GGD + COLO1(1)*Cqed*Pi*alphas**3*dldel1 * (64*ms1**2* + s**(-3)*xw**(-1) - 64*ms1**2*s**(-2)*t1**(-1)*xw**(-1) - 64* + ms1**2*s**(-2)*u1**(-1)*xw**(-1) - 128*ms1**4*s**(-3)* + t1**(-1)*xw**(-1) - 128*ms1**4*s**(-3)*u1**(-1)*xw**(-1) - 64 + *ms1**4*s**(-2)*t1**(-2)*xw**(-1) - 384*ms1**4*s**(-2)* + t1**(-1)*u1**(-1)*xw**(-1) - 64*ms1**4*s**(-2)*u1**(-2)* + xw**(-1) + 128*ms1**6*s**(-3)*t1**(-2)*xw**(-1) + 256*ms1**6* + s**(-3)*t1**(-1)*u1**(-1)*xw**(-1) + 128*ms1**6*s**(-3)* + u1**(-2)*xw**(-1) - 32*s**(-2)*xw**(-1) ) LQ_GGD = LQ_GGD + COLO1(3)*Nc*Co*Pi*alphas**3*dldel1 *(128*ms1**2 + *s**(-3) + 64*ms1**2*s**(-2)*t1**(-1) + 64*ms1**2*s**(-2)* + u1**(-1) + 64*ms1**4*s**(-2)*t1**(-2) + 64*ms1**4*s**(-2)* + u1**(-2) + 64*s**(-4)*t1**2 + 64*s**(-3)*t1 + 32*s**(-2) ) LQ_GGD = LQ_GGD + COLO1(4)*Nc*Co*Pi*alphas**3*dldel1 * ( - 128* + ms1**2*s**(-3) - 128*ms1**2*s**(-2)*u1**(-1) - 128*ms1**4* + s**(-2)*u1**(-2) - 64*s**(-4)*t1**2 ) LQ_GGD = LQ_GGD + COLO1(8)*Nc*Co*Pi*alphas**3*dldel1 * ( - 128* + ms1**2*s**(-3) - 128*ms1**2*s**(-2)*t1**(-1) - 128*ms1**4* + s**(-2)*t1**(-2) - 64*s**(-4)*t1**2 - 128*s**(-3)*t1 - 64* + s**(-2) ) LQ_GGD = fac * LQ_GGD end c -------------------------------------------------------------------- real*8 function LQ_GGV(s,t1,ms1,mt) implicit none real*8 Pi,Nc,Co,Ck,Cqed,Nf,Nl,alphas,fac real*8 s,t1,u1,ms1,mt,t,u,ms12 real*8 m2(2,6),softin(4) real*8 SK3B0A(5),SK3B0B(6),SK3B0C(2),SK3B0D(2,2),SK3BP(3) real*8 SK3C0A(8),SK3C0B(4),SK3C0C(5,2),SK3D0(7,2) real*8 SOF1(8) real*8 mur,dec,LQ_GGB Pi=4.D0*atan(1.D0) Nc = 3.D0 Co = Nc*(Nc**2-1.D0) Ck = (Nc**2-1.D0)/Nc Cqed = Nc**2 - 1/Nc**2 alphas = 1.D0 Nf = 6.D0 Nl = 1.D0 u1 = - s - t1 t = t1 + ms1**2 u = u1 + ms1**2 ms12 = ms1**2 fac = 1.D0/(64*Pi*(Nc**2-1.D0)**2) m2(1,1) = s m2(1,2) = t1 + ms1**2 m2(1,3) = u1 + ms1**2 m2(1,4) = t1 m2(1,5) = u1 m2(2,1) = ms1**2 m2(2,2) = 1.D0 m2(2,3) = 1.D0 m2(2,4) = 1.D0 m2(2,5) = mt**2 m2(2,6) = ms1**2 call SCALAR_ARRAY_LQ_B(m2,SK3B0A,SK3B0B,SK3B0C,SK3B0D,SK3BP) call SCALAR_ARRAY_LQ_C(m2,SK3C0A,SK3C0B,SK3C0C,SK3D0) softin(1) = s softin(2) = t1 softin(3) = u1 softin(4) = ms1**2 call SOFT_ARRAY_LQ(softin,SOF1) mur = ms1 dec = 2.D0*alphas/Pi * LQ_GGB(s,t1,ms1)* & ( Nl/24.D0 * log(mur**2/ms1**2) & + 1.D0/6.D0 * log(mur**2/mt**2) ) LQ_GGV = + + Nc*Co*Pi*alphas**3 * ( ms1**2*s**(-3)*t**(-1)*t1 - ms1**2* + s**(-3)*u**(-1)*t1 - 38./3.*ms1**2*s**(-3) + 3*ms1**2*s**(-2) + *t**(-1) + 2*ms1**2*s**(-2)*u**(-1) - 41./3.*ms1**2*s**(-2)* + t1**(-1) - 41./3.*ms1**2*s**(-2)*u1**(-1) + 5*ms1**2*s**(-1)* + t**(-1)*t1**(-1) + 5*ms1**2*s**(-1)*u**(-1)*u1**(-1) - 5* + ms1**2*s**(-1)*t1**(-2) - 5*ms1**2*s**(-1)*u1**(-2) + 5* + ms1**4*s**(-3)*t**(-1) + 5*ms1**4*s**(-3)*u**(-1) - 4*ms1**4* + s**(-3)*t1**(-1) - 4*ms1**4*s**(-3)*u1**(-1) + 3*ms1**4* + s**(-2)*t**(-1)*t1**(-1) + 3*ms1**4*s**(-2)*u**(-1)*u1**(-1) + + 11*ms1**4*s**(-1)*t**(-1)*t1**(-2) + 11*ms1**4*s**(-1)* + u**(-1)*u1**(-2) - 6*ms1**4*s**(-1)*t1**(-3) - 6*ms1**4* + s**(-1)*u1**(-3) + 4*ms1**6*s**(-3)*t**(-1)*t1**(-1) + 4* + ms1**6*s**(-3)*u**(-1)*u1**(-1) + 6*ms1**6*s**(-1)*t**(-1)* + t1**(-3) + 6*ms1**6*s**(-1)*u**(-1)*u1**(-3) ) LQ_GGV = LQ_GGV + Nc*Ck*Pi*alphas**3 * ( - 4*ms1**2*s**(-3)* + t**(-1)*t1 + 4*ms1**2*s**(-3)*u**(-1)*t1 + 8*ms1**2*s**(-3) + + 6*ms1**2*s**(-2)*t**(-1) + 10*ms1**2*s**(-2)*u**(-1) - 34* + ms1**2*s**(-2)*t1**(-1) - 34*ms1**2*s**(-2)*u1**(-1) - 12* + ms1**2*s**(-1)*t**(-1)*t1**(-1) - 16*ms1**2*s**(-1)*t**(-1)* + u1**(-1) - 16*ms1**2*s**(-1)*u**(-1)*t1**(-1) - 12*ms1**2* + s**(-1)*u**(-1)*u1**(-1) + 12*ms1**2*s**(-1)*t1**(-2) + 12* + ms1**2*s**(-1)*u1**(-2) - 20*ms1**4*s**(-3)*t**(-1) - 20* + ms1**4*s**(-3)*u**(-1) + 16*ms1**4*s**(-3)*t1**(-1) + 16* + ms1**4*s**(-3)*u1**(-1) - 18*ms1**4*s**(-2)*t**(-1)*t1**(-1) + + 24*ms1**4*s**(-2)*t**(-1)*u1**(-1) + 24*ms1**4*s**(-2)* + u**(-1)*t1**(-1) - 18*ms1**4*s**(-2)*u**(-1)*u1**(-1) + 40* + ms1**4*s**(-2)*t1**(-2) - 16*ms1**4*s**(-2)*t1**(-1)*u1**(-1) + + 40*ms1**4*s**(-2)*u1**(-2) - 20*ms1**4*s**(-1)*t**(-1)* + t1**(-2) - 20*ms1**4*s**(-1)*u**(-1)*u1**(-2) + 8*ms1**4* + s**(-1)*t1**(-3) ) LQ_GGV = LQ_GGV + Nc*Ck*Pi*alphas**3 * (8*ms1**4*s**(-1)*u1**(-3) + - 16*ms1**6*s**(-3)*t**(-1)*t1**(-1) - 16*ms1**6*s**(-3)* + u**(-1)*u1**(-1) - 104*ms1**6*s**(-2)*t**(-1)*t1**(-2) - 24* + ms1**6*s**(-2)*t**(-1)*t1**(-1)*u1**(-1) - 24*ms1**6*s**(-2)* + u**(-1)*t1**(-1)*u1**(-1) - 104*ms1**6*s**(-2)*u**(-1)* + u1**(-2) + 64*ms1**6*s**(-2)*t1**(-3) + 32*ms1**6*s**(-2)* + t1**(-2)*u1**(-1) + 32*ms1**6*s**(-2)*t1**(-1)*u1**(-2) + 64* + ms1**6*s**(-2)*u1**(-3) - 8*ms1**6*s**(-1)*t**(-1)*t1**(-3) + - 8*ms1**6*s**(-1)*u**(-1)*u1**(-3) - 64*ms1**8*s**(-2)* + t**(-1)*t1**(-3) - 32*ms1**8*s**(-2)*t**(-1)*t1**(-2)* + u1**(-1) - 32*ms1**8*s**(-2)*u**(-1)*t1**(-1)*u1**(-2) - 64* + ms1**8*s**(-2)*u**(-1)*u1**(-3) ) LQ_GGV = LQ_GGV + Co*Pi*alphas**3 * (32./3.*Nf*ms1**2*s**(-3)+8./ + 3.*Nf*ms1**2*s**(-2)*t1**(-1) + 8./3.*Nf*ms1**2*s**(-2)* + u1**(-1) - 16./3.*Nl*ms1**2*s**(-3) - 4./3.*Nl*ms1**2*s**(-2) + *t1**(-1) - 4./3.*Nl*ms1**2*s**(-2)*u1**(-1) ) LQ_GGV = LQ_GGV + Cqed*Pi*alphas**3 *(4*ms1**2*s**(-2)*t**(-1) + + 4*ms1**2*s**(-2)*u**(-1) - 4*ms1**2*s**(-2)*t1**(-1) - 4* + ms1**2*s**(-2)*u1**(-1) + 4*ms1**2*s**(-1)*t**(-1)*t1**(-1) + + 4*ms1**2*s**(-1)*t**(-1)*u1**(-1) + 4*ms1**2*s**(-1)* + u**(-1)*t1**(-1) + 4*ms1**2*s**(-1)*u**(-1)*u1**(-1) - 4* + ms1**2*s**(-1)*t1**(-2) - 4*ms1**2*s**(-1)*u1**(-2) + 40* + ms1**4*s**(-2)*t**(-1)*t1**(-1) + 20*ms1**4*s**(-2)*t**(-1)* + u1**(-1) + 20*ms1**4*s**(-2)*u**(-1)*t1**(-1) + 40*ms1**4* + s**(-2)*u**(-1)*u1**(-1) - 40*ms1**4*s**(-2)*t1**(-2) - 48* + ms1**4*s**(-2)*t1**(-1)*u1**(-1) - 40*ms1**4*s**(-2)*u1**(-2) + + 4*ms1**4*s**(-1)*t**(-1)*t1**(-2) + 4*ms1**4*s**(-1)* + u**(-1)*u1**(-2) + 72*ms1**6*s**(-2)*t**(-1)*t1**(-2) + 56* + ms1**6*s**(-2)*t**(-1)*t1**(-1)*u1**(-1) + 56*ms1**6*s**(-2)* + u**(-1)*t1**(-1)*u1**(-1) + 72*ms1**6*s**(-2)*u**(-1)* + u1**(-2) - 32*ms1**6*s**(-2)*t1**(-3) - 32*ms1**6*s**(-2)* + t1**(-2)*u1**(-1) ) LQ_GGV = LQ_GGV + Cqed*Pi*alphas**3 * ( - 32*ms1**6*s**(-2)* + t1**(-1)*u1**(-2) - 32*ms1**6*s**(-2)*u1**(-3) + 32*ms1**8* + s**(-2)*t**(-1)*t1**(-3) + 32*ms1**8*s**(-2)*t**(-1)*t1**(-2) + *u1**(-1) + 32*ms1**8*s**(-2)*u**(-1)*t1**(-1)*u1**(-2) + 32* + ms1**8*s**(-2)*u**(-1)*u1**(-3) ) LQ_GGV = LQ_GGV + SK3B0A(2)*Co*Pi*alphas**3 * ( -128*mt**2*ms1**2 + *s**(-4) - 128./3.*mt**2*ms1**2*s**(-3)*t1**(-1) - 128./3.* + mt**2*ms1**2*s**(-3)*u1**(-1) - 32./3.*mt**2*ms1**2*s**(-2)* + t1**(-1)*u1**(-1) - 128./3.*ms1**2*s**(-3) - 64./3.*ms1**2* + s**(-2)*t1**(-1) - 64./3.*ms1**2*s**(-2)*u1**(-1) - 64./3.* + ms1**4*s**(-2)*t1**(-2) - 64./3.*ms1**4*s**(-2)*u1**(-2) -64. + /3.*s**(-4)*t1**2 - 64./3.*s**(-3)*t1 - 32./3.*s**(-2) ) LQ_GGV = LQ_GGV + SK3B0A(2)*Ck*Pi*alphas**3 * ( 64./3.*ms1**2* + s**(-2)*t1**(-1) + 64./3.*ms1**2*s**(-2)*u1**(-1) + 64./3.* + ms1**4*s**(-2)*t1**(-2) + 128./3.*ms1**4*s**(-2)*t1**(-1)* + u1**(-1) + 64./3.*ms1**4*s**(-2)*u1**(-2) + 32./3.*s**(-2) ) LQ_GGV = LQ_GGV + SK3B0B(1)*Nc*Co*Pi*alphas**3 * ( - 32* + (s-4*ms12)**(-1)*s**(-3)*t1**2 - 32*(s-4*ms12)**(-1)*s**(-2)* + t1 - 16*(s-4*ms12)**(-1)*s**(-1) - 2*(s-4*ms12)**(-1)* + t1**(-1) - 2*(s-4*ms12)**(-1)*u1**(-1) - 32*ms1**2*s**(-3) - + 8*ms1**2*s**(-2)*t1**(-1) - 8*ms1**2*s**(-2)*u1**(-1) - 32* + s**(-4)*t1**2 - 32*s**(-3)*t1 + 2*s**(-1)*t1**(-1) + 2* + s**(-1)*u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0B(2)*Nc*Ck*Pi*alphas**3 * ( 32* + (s-4*ms12)**(-1)*s**(-3)*t1**2 + 32*(s-4*ms12)**(-1)*s**(-2)* + t1 + 16*(s-4*ms12)**(-1)*s**(-1) + 2*(s-4*ms12)**(-1)* + t1**(-1) + 2*(s-4*ms12)**(-1)*u1**(-1) + 32*ms1**2*s**(-3) + + 8*ms1**2*s**(-2)*t1**(-1) + 8*ms1**2*s**(-2)*u1**(-1) + 32* + s**(-4)*t1**2 + 32*s**(-3)*t1 - 2*s**(-1)*t1**(-1) - 2* + s**(-1)*u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0B(2)*Co*Pi*alphas**3 * ( - 64*Nl*ms1**4* + s**(-4) - 64./3.*Nl*ms1**4*s**(-3)*t1**(-1) - 64./3.*Nl* + ms1**4*s**(-3)*u1**(-1) - 16./3.*Nl*ms1**4*s**(-2)*t1**(-1)* + u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0B(4)*Co*Pi*alphas**3 * ( 128*mt**2*ms1**2* + s**(-4) + 128./3.*mt**2*ms1**2*s**(-3)*t1**(-1) + 128./3.* + mt**2*ms1**2*s**(-3)*u1**(-1) + 32./3.*mt**2*ms1**2*s**(-2)* + t1**(-1)*u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0C(1)*Nc*Co*Pi*alphas**3 * ( 32* + (s-4*ms12)**(-1)*s**(-3)*t1**2 + 32*(s-4*ms12)**(-1)*s**(-2)* + t1 + 16*(s-4*ms12)**(-1)*s**(-1) + 2*(s-4*ms12)**(-1)* + t1**(-1) + 2*(s-4*ms12)**(-1)*u1**(-1) + 96*ms1**2*s**(-3) + + 56*ms1**2*s**(-2)*t1**(-1) + 56*ms1**2*s**(-2)*u1**(-1) + 32* + ms1**4*s**(-3)*t1**(-1) + 32*ms1**4*s**(-3)*u1**(-1) + 96* + ms1**4*s**(-2)*t1**(-2) + 96*ms1**4*s**(-2)*u1**(-2) + 64* + ms1**6*s**(-2)*t1**(-3) + 64*ms1**6*s**(-2)*u1**(-3) + 32* + s**(-4)*t1**2 + 32*s**(-3)*t1 + 16*s**(-2) - 2*s**(-1)* + t1**(-1) - 2*s**(-1)*u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0C(1)*Nc*Ck*Pi*alphas**3 * ( - 32* + (s-4*ms12)**(-1)*s**(-3)*t1**2 - 32*(s-4*ms12)**(-1)*s**(-2)* + t1 - 16*(s-4*ms12)**(-1)*s**(-1) - 2*(s-4*ms12)**(-1)* + t1**(-1) - 2*(s-4*ms12)**(-1)*u1**(-1) - 96*ms1**2*s**(-3) - + 184*ms1**2*s**(-2)*t1**(-1) - 184*ms1**2*s**(-2)*u1**(-1) - + 32*ms1**4*s**(-3)*t1**(-1) - 32*ms1**4*s**(-3)*u1**(-1) - 288 + *ms1**4*s**(-2)*t1**(-2) - 256*ms1**4*s**(-2)*t1**(-1)* + u1**(-1) - 288*ms1**4*s**(-2)*u1**(-2) - 192*ms1**6*s**(-2)* + t1**(-3) - 128*ms1**6*s**(-2)*t1**(-2)*u1**(-1) - 128*ms1**6* + s**(-2)*t1**(-1)*u1**(-2) - 192*ms1**6*s**(-2)*u1**(-3) - 32* + s**(-4)*t1**2 - 32*s**(-3)*t1 - 80*s**(-2) + 2*s**(-1)* + t1**(-1) + 2*s**(-1)*u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0C(1)*Cqed*Pi*alphas**3 *(64*ms1**2*s**(-2) + *t1**(-1) + 64*ms1**2*s**(-2)*u1**(-1) + 96*ms1**4*s**(-2)* + t1**(-2) + 128*ms1**4*s**(-2)*t1**(-1)*u1**(-1) + 96*ms1**4* + s**(-2)*u1**(-2) + 64*ms1**6*s**(-2)*t1**(-3) + 64*ms1**6* + s**(-2)*t1**(-2)*u1**(-1) + 64*ms1**6*s**(-2)*t1**(-1)* + u1**(-2) + 64*ms1**6*s**(-2)*u1**(-3) + 32*s**(-2) ) LQ_GGV = LQ_GGV + SK3B0D(1,1)*Nc*Co*Pi*alphas**3 * ( 19*ms1**2* + s**(-3)*t**(-1)*t1 - 44*ms1**2*s**(-3) + 47*ms1**2*s**(-2)* + t**(-1) - 78*ms1**2*s**(-2)*t1**(-1) + 11*ms1**2*s**(-1)* + t**(-1)*t1**(-1) - 6*ms1**2*s**(-1)*t1**(-2) + 12*ms1**4* + s**(-3)*t**(-1) - 32*ms1**4*s**(-3)*t1**(-1) + 46*ms1**4* + s**(-2)*t**(-1)*t1**(-1) - 112*ms1**4*s**(-2)*t1**(-2) + 6* + ms1**4*s**(-1)*t**(-1)*t1**(-2) + 16*ms1**6*s**(-2)*t**(-1)* + t1**(-2) - 64*ms1**6*s**(-2)*t1**(-3) + 7*s**(-3)*t**(-1)* + t1**2 - 23*s**(-3)*t1 + 17*s**(-2)*t**(-1)*t1 - 33*s**(-2) + + 5*s**(-1)*t**(-1) - 5*s**(-1)*t1**(-1) ) LQ_GGV = LQ_GGV + SK3B0D(1,1)*Nc*Ck*Pi*alphas**3 * ( 4*ms1**2* + s**(-3)*t**(-1)*t1 + 24*ms1**2*s**(-3) + 38*ms1**2*s**(-2)* + t**(-1) + 84*ms1**2*s**(-2)*t1**(-1) + 8*ms1**2*s**(-2)* + u1**(-1) - 20*ms1**2*s**(-1)*t**(-1)*t1**(-1) - 32*ms1**2* + s**(-1)*t**(-1)*u1**(-1) + 8*ms1**2*s**(-1)*t1**(-2) + 40* + ms1**4*s**(-3)*t**(-1) + 236*ms1**4*s**(-2)*t**(-1)*t1**(-1) + + 72*ms1**4*s**(-2)*t**(-1)*u1**(-1) + 112*ms1**4*s**(-2)* + t1**(-2) + 80*ms1**4*s**(-2)*t1**(-1)*u1**(-1) - 8*ms1**4* + s**(-1)*t**(-1)*t1**(-2) + 32*ms1**6*s**(-3)*t**(-1)*t1**(-1) + + 304*ms1**6*s**(-2)*t**(-1)*t1**(-2) + 112*ms1**6*s**(-2)* + t**(-1)*t1**(-1)*u1**(-1) + 64*ms1**6*s**(-2)*t1**(-3) + 64* + ms1**6*s**(-2)*t1**(-2)*u1**(-1) + 128*ms1**8*s**(-2)*t**(-1) + *t1**(-3) + 64*ms1**8*s**(-2)*t**(-1)*t1**(-2)*u1**(-1) - 4* + s**(-3)*t**(-1)*t1**2 + 20*s**(-3)*t1 + 2*s**(-2)*t**(-1)*t1 + + 46*s**(-2) - 4*s**(-1)*t**(-1) + 12*s**(-1)*t1**(-1) + 8* + s**(-1)*u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0D(1,1)*Nc*Ck*Pi*alphas**3 * ( 8*t**(-1)* + u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0D(1,1)*Cqed*Pi*alphas**3 * ( - 4*ms1**2* + s**(-2)*t**(-1) - 24*ms1**2*s**(-2)*t1**(-1) + 4*ms1**2* + s**(-1)*t**(-1)*t1**(-1) + 20*ms1**2*s**(-1)*t**(-1)*u1**(-1) + - 120*ms1**4*s**(-2)*t**(-1)*t1**(-1) - 80*ms1**4*s**(-2)* + t**(-1)*u1**(-1) - 160*ms1**6*s**(-2)*t**(-1)*t1**(-2) - 128* + ms1**6*s**(-2)*t**(-1)*t1**(-1)*u1**(-1) - 64*ms1**8*s**(-2)* + t**(-1)*t1**(-3) - 64*ms1**8*s**(-2)*t**(-1)*t1**(-2)* + u1**(-1) + 4*s**(-2)*t**(-1)*t1 - 20*s**(-2) - 4*s**(-1)* + t1**(-1) - 4*s**(-1)*u1**(-1) - 4*t**(-1)*u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0D(1,2)*Nc*Co*Pi*alphas**3 * ( -19*ms1**2* + s**(-3)*u**(-1)*t1 - 44*ms1**2*s**(-3) + 28*ms1**2*s**(-2)* + u**(-1) - 78*ms1**2*s**(-2)*u1**(-1) + 11*ms1**2*s**(-1)* + u**(-1)*u1**(-1) - 6*ms1**2*s**(-1)*u1**(-2) + 12*ms1**4* + s**(-3)*u**(-1) - 32*ms1**4*s**(-3)*u1**(-1) + 46*ms1**4* + s**(-2)*u**(-1)*u1**(-1) - 112*ms1**4*s**(-2)*u1**(-2) + 6* + ms1**4*s**(-1)*u**(-1)*u1**(-2) + 16*ms1**6*s**(-2)*u**(-1)* + u1**(-2) - 64*ms1**6*s**(-2)*u1**(-3) + 7*s**(-3)*u**(-1)* + t1**2 + 23*s**(-3)*t1 - 3*s**(-2)*u**(-1)*t1 - 10*s**(-2) - 5 + *s**(-1)*u**(-1) - 5*s**(-1)*u1**(-1) ) LQ_GGV = LQ_GGV + SK3B0D(1,2)*Nc*Ck*Pi*alphas**3 * ( - 4*ms1**2* + s**(-3)*u**(-1)*t1 + 24*ms1**2*s**(-3) + 34*ms1**2*s**(-2)* + u**(-1) + 8*ms1**2*s**(-2)*t1**(-1) + 84*ms1**2*s**(-2)* + u1**(-1) - 32*ms1**2*s**(-1)*u**(-1)*t1**(-1) - 20*ms1**2* + s**(-1)*u**(-1)*u1**(-1) + 8*ms1**2*s**(-1)*u1**(-2) + 40* + ms1**4*s**(-3)*u**(-1) + 72*ms1**4*s**(-2)*u**(-1)*t1**(-1) + + 236*ms1**4*s**(-2)*u**(-1)*u1**(-1) + 80*ms1**4*s**(-2)* + t1**(-1)*u1**(-1) + 112*ms1**4*s**(-2)*u1**(-2) - 8*ms1**4* + s**(-1)*u**(-1)*u1**(-2) + 32*ms1**6*s**(-3)*u**(-1)*u1**(-1) + + 112*ms1**6*s**(-2)*u**(-1)*t1**(-1)*u1**(-1) + 304*ms1**6* + s**(-2)*u**(-1)*u1**(-2) + 64*ms1**6*s**(-2)*t1**(-1)* + u1**(-2) + 64*ms1**6*s**(-2)*u1**(-3) + 64*ms1**8*s**(-2)* + u**(-1)*t1**(-1)*u1**(-2) + 128*ms1**8*s**(-2)*u**(-1)* + u1**(-3) - 4*s**(-3)*u**(-1)*t1**2 - 20*s**(-3)*t1 - 10* + s**(-2)*u**(-1)*t1 + 26*s**(-2) - 10*s**(-1)*u**(-1) + 8* + s**(-1)*t1**(-1) ) LQ_GGV = LQ_GGV + SK3B0D(1,2)*Nc*Ck*Pi*alphas**3 * ( 12*s**(-1)* + u1**(-1) + 8*u**(-1)*t1**(-1) ) LQ_GGV = LQ_GGV + SK3B0D(1,2)*Cqed*Pi*alphas**3 * ( - 4*ms1**2* + s**(-2)*u**(-1) - 24*ms1**2*s**(-2)*u1**(-1) + 20*ms1**2* + s**(-1)*u**(-1)*t1**(-1) + 4*ms1**2*s**(-1)*u**(-1)*u1**(-1) + - 80*ms1**4*s**(-2)*u**(-1)*t1**(-1) - 120*ms1**4*s**(-2)* + u**(-1)*u1**(-1) - 128*ms1**6*s**(-2)*u**(-1)*t1**(-1)* + u1**(-1) - 160*ms1**6*s**(-2)*u**(-1)*u1**(-2) - 64*ms1**8* + s**(-2)*u**(-1)*t1**(-1)*u1**(-2) - 64*ms1**8*s**(-2)*u**(-1) + *u1**(-3) - 4*s**(-2)*u**(-1)*t1 - 20*s**(-2) - 4*s**(-1)* + u**(-1) - 4*s**(-1)*t1**(-1) - 4*s**(-1)*u1**(-1) - 4*u**(-1) + *t1**(-1) ) LQ_GGV = LQ_GGV + SK3BP(1)*Nc*Co*Pi*alphas**3 *(64*ms1**2*s**(-4) + *t1**2 + 64*ms1**2*s**(-3)*t1 + 32*ms1**2*s**(-2) + 128* + ms1**4*s**(-3) + 64*ms1**4*s**(-2)*t1**(-1) + 64*ms1**4* + s**(-2)*u1**(-1) + 64*ms1**6*s**(-2)*t1**(-2) + 64*ms1**6* + s**(-2)*u1**(-2) ) LQ_GGV = LQ_GGV + SK3BP(1)*Nc*Ck*Pi*alphas**3 * ( - 64*ms1**2* + s**(-4)*t1**2 - 64*ms1**2*s**(-3)*t1 - 96*ms1**2*s**(-2) - + 128*ms1**4*s**(-3) - 192*ms1**4*s**(-2)*t1**(-1) - 192*ms1**4 + *s**(-2)*u1**(-1) - 192*ms1**6*s**(-2)*t1**(-2) - 256*ms1**6* + s**(-2)*t1**(-1)*u1**(-1) - 192*ms1**6*s**(-2)*u1**(-2) ) LQ_GGV = LQ_GGV + SK3BP(1)*Cqed*Pi*alphas**3 *(32*ms1**2*s**(-2) + + 64*ms1**4*s**(-2)*t1**(-1) + 64*ms1**4*s**(-2)*u1**(-1) + + 64*ms1**6*s**(-2)*t1**(-2) + 128*ms1**6*s**(-2)*t1**(-1)* + u1**(-1) + 64*ms1**6*s**(-2)*u1**(-2) ) LQ_GGV = LQ_GGV + SK3C0A(1)*Nc*Co*Pi*alphas**3 * ( - 32*ms1**2* + s**(-2) - 16*ms1**2*s**(-1)*t1**(-1) - 16*ms1**2*s**(-1)* + u1**(-1) ) LQ_GGV = LQ_GGV + SK3C0A(2)*Nc*Ck*Pi*alphas**3 * ( 32*ms1**2* + s**(-2) - 16*ms1**2*s**(-1)*t1**(-1) - 16*ms1**2*s**(-1)* + u1**(-1) + 40*ms1**4*s**(-2)*t1**(-1) + 40*ms1**4*s**(-2)* + u1**(-1) - 16*s**(-1) ) LQ_GGV = LQ_GGV + SK3C0A(2)*Co*Pi*alphas**3 * ( - 32*Nl*ms1**4* + s**(-3) - 8*Nl*ms1**4*s**(-2)*t1**(-1) - 8*Nl*ms1**4*s**(-2)* + u1**(-1) ) LQ_GGV = LQ_GGV + SK3C0A(2)*Cqed*Pi*alphas**3 *(48*ms1**2*s**(-1) + *t1**(-1) + 48*ms1**2*s**(-1)*u1**(-1) - 80*ms1**4*s**(-2)* + t1**(-1) - 80*ms1**4*s**(-2)*u1**(-1) - 8*t1**(-1) - 8* + u1**(-1) ) LQ_GGV = LQ_GGV + SK3C0A(4)*Co*Pi*alphas**3 * ( 64*mt**2*ms1**2* + s**(-3) + 16*mt**2*ms1**2*s**(-2)*t1**(-1) + 16*mt**2*ms1**2* + s**(-2)*u1**(-1) ) LQ_GGV = LQ_GGV + SK3C0B(1)*Nc*Ck*Pi*alphas**3 * ( - 64*ms1**2* + s**(-4)*t1**2 - 64*ms1**2*s**(-3)*t1 + 96*ms1**2*s**(-2) + 16 + *ms1**2*s**(-1)*t1**(-1) + 16*ms1**2*s**(-1)*u1**(-1) - 192* + ms1**4*s**(-3) - 32*ms1**4*s**(-2)*t1**(-1) - 32*ms1**4* + s**(-2)*u1**(-1) + 32*s**(-3)*t1**2 + 32*s**(-2)*t1 ) LQ_GGV = LQ_GGV + SK3C0B(1)*Cqed*Pi*alphas**3 *(32*ms1**2*s**(-2) + + 32*ms1**2*s**(-1)*t1**(-1) + 32*ms1**2*s**(-1)*u1**(-1) - + 32*ms1**4*s**(-2)*t1**(-1) - 32*ms1**4*s**(-2)*u1**(-1) - 16* + s**(-1) - 8*t1**(-1) - 8*u1**(-1) ) LQ_GGV = LQ_GGV + SK3C0B(2)*Nc*Co*Pi*alphas**3 * ( - 16* + (s-4*ms12)**(-1)*s**(-2)*t1**2 - 16*(s-4*ms12)**(-1)*s**(-1)* + t1 + (s-4*ms12)**(-1)*t1**(-1)*u1 + (s-4*ms12)**(-1)*t1* + u1**(-1) - 6*(s-4*ms12)**(-1) + 32*ms1**2*s**(-2) + 20*ms1**2 + *s**(-1)*t1**(-1) + 20*ms1**2*s**(-1)*u1**(-1) - 16*ms1**4* + s**(-2)*t1**(-1) - 16*ms1**4*s**(-2)*u1**(-1) + 48*s**(-3)* + t1**2 + 48*s**(-2)*t1 + 24*s**(-1) + t1**(-1) + u1**(-1) ) LQ_GGV = LQ_GGV + SK3C0C(1,1)*Nc*Co*Pi*alphas**3 * ( -32*ms1**2* + s**(-3)*t1 - 32*ms1**2*s**(-2) - 32*s**(-3)*t1**2 - 16* + s**(-2)*t1 ) LQ_GGV = LQ_GGV + SK3C0C(1,1)*Nc*Ck*Pi*alphas**3 * ( -32*ms1**2* + s**(-1)*u1**(-1) + 64*ms1**4*s**(-2)*u1**(-1) + 16*s**(-2)*t1 + ) LQ_GGV = LQ_GGV + SK3C0C(1,2)*Nc*Co*Pi*alphas**3 * ( 32*ms1**2* + s**(-3)*t1 - 32*s**(-3)*t1**2 - 48*s**(-2)*t1 - 16*s**(-1) ) LQ_GGV = LQ_GGV + SK3C0C(1,2)*Nc*Ck*Pi*alphas**3 * ( -32*ms1**2* + s**(-1)*t1**(-1) + 64*ms1**4*s**(-2)*t1**(-1) - 16*s**(-2)*t1 + - 16*s**(-1) ) LQ_GGV = LQ_GGV + SK3C0C(3,1)*Nc*Ck*Pi*alphas**3 * ( 32*ms1**2* + s**(-3)*t1 - 32*ms1**2*s**(-2) + 32*ms1**2*s**(-1)*u1**(-1) + + 64*ms1**4*s**(-3) - 32*s**(-2)*t1 ) LQ_GGV = LQ_GGV + SK3C0C(3,1)*Cqed*Pi*alphas**3 * ( - 32*ms1**2* + s**(-2) - 64*ms1**2*s**(-1)*u1**(-1) + 64*ms1**4*s**(-2)* + u1**(-1) + 16*s**(-1) + 16*u1**(-1) ) LQ_GGV = LQ_GGV + SK3C0C(3,2)*Nc*Ck*Pi*alphas**3 * ( -32*ms1**2* + s**(-3)*t1 - 64*ms1**2*s**(-2) + 32*ms1**2*s**(-1)*t1**(-1) + + 64*ms1**4*s**(-3) + 32*s**(-2)*t1 + 32*s**(-1) ) LQ_GGV = LQ_GGV + SK3C0C(3,2)*Cqed*Pi*alphas**3 * ( - 32*ms1**2* + s**(-2) - 64*ms1**2*s**(-1)*t1**(-1) + 64*ms1**4*s**(-2)* + t1**(-1) + 16*s**(-1) + 16*t1**(-1) ) LQ_GGV = LQ_GGV + SK3D0(1,1)*Nc*Co*Pi*alphas**3 * ( - 16*ms1**2* + s**(-2)*t1 - 16*ms1**2*s**(-1) - 32*ms1**4*s**(-1)*t1**(-1) + - 16*s**(-3)*t1**3 - 16*s**(-2)*t1**2 - 8*s**(-1)*t1 ) LQ_GGV = LQ_GGV + SK3D0(1,2)*Nc*Co*Pi*alphas**3 * ( 8 +16*ms1**2* + s**(-2)*t1 - 32*ms1**4*s**(-1)*u1**(-1) + 16*s**(-3)*t1**3 + + 32*s**(-2)*t1**2 + 24*s**(-1)*t1 ) LQ_GGV = LQ_GGV + SK3D0(2,1)*Nc*Ck*Pi*alphas**3 * ( - 32*ms1**2* + s**(-2)*t1 + 16*ms1**2*s**(-1) + 32*ms1**4*s**(-3)*t1 - 32* + ms1**4*s**(-2) + 32*ms1**4*s**(-1)*t1**(-1) - 64*ms1**6* + s**(-2)*t1**(-1) + 8*s**(-1)*t1 ) LQ_GGV = LQ_GGV + SK3D0(2,1)*Cqed*Pi*alphas**3 * ( 32*ms1**2* + s**(-1) + 48*ms1**2*u1**(-1) - 32*ms1**4*s**(-2) - 32*ms1**4* + s**(-1)*t1**(-1) - 96*ms1**4*s**(-1)*u1**(-1) + 64*ms1**6* + s**(-2)*t1**(-1) + 64*ms1**6*s**(-2)*u1**(-1) + 8*t1*u1**(-1) + ) LQ_GGV = LQ_GGV + SK3D0(2,2)*Nc*Ck*Pi*alphas**3 * ( - 8 + 32* + ms1**2*s**(-2)*t1 + 48*ms1**2*s**(-1) - 32*ms1**4*s**(-3)*t1 + - 64*ms1**4*s**(-2) + 32*ms1**4*s**(-1)*u1**(-1) - 64*ms1**6 + *s**(-2)*u1**(-1) - 8*s**(-1)*t1 ) LQ_GGV = LQ_GGV + SK3D0(2,2)*Cqed*Pi*alphas**3 * ( 32*ms1**2* + s**(-1) + 48*ms1**2*t1**(-1) - 32*ms1**4*s**(-2) - 96*ms1**4* + s**(-1)*t1**(-1) - 32*ms1**4*s**(-1)*u1**(-1) + 64*ms1**6* + s**(-2)*t1**(-1) + 64*ms1**6*s**(-2)*u1**(-1) + 8*t1**(-1)*u1 + ) LQ_GGV = LQ_GGV + SK3D0(3,1)*Nc*Ck*Pi*alphas**3 * ( - 16*ms1**2* + s**(-1) - 32*ms1**4*s**(-2) - 32*ms1**4*s**(-1)*t1**(-1) - 32 + *ms1**4*s**(-1)*u1**(-1) - 8*s**(-2)*t1**2 - 8*s**(-1)*t1 ) LQ_GGV = LQ_GGV + SK3D0(3,2)*Nc*Ck*Pi*alphas**3 * ( - 16*ms1**2* + s**(-1) - 32*ms1**4*s**(-2) - 32*ms1**4*s**(-1)*t1**(-1) - 32 + *ms1**4*s**(-1)*u1**(-1) - 8*s**(-2)*t1**2 - 8*s**(-1)*t1 ) LQ_GGV = LQ_GGV + SOF1(1)*Nc*Ck*Pi*alphas**3 *(256*ms1**2*s**(-4) + *t1**2 + 256*ms1**2*s**(-3)*t1 - 128*ms1**2*s**(-2) - 128* + ms1**2*s**(-1)*t1**(-1) - 128*ms1**2*s**(-1)*u1**(-1) + 512* + ms1**4*s**(-3) + 256*ms1**4*s**(-2)*t1**(-1) + 256*ms1**4* + s**(-2)*u1**(-1) - 128*ms1**4*s**(-1)*t1**(-2) - 128*ms1**4* + s**(-1)*u1**(-2) + 256*ms1**6*s**(-2)*t1**(-2) + 256*ms1**6* + s**(-2)*u1**(-2) - 128*s**(-3)*t1**2 - 128*s**(-2)*t1 - 64* + s**(-1) ) LQ_GGV = LQ_GGV + SOF1(1)*Cqed*Pi*alphas**3 * ( - 128*ms1**2* + s**(-2) + 128*ms1**2*s**(-1)*t1**(-1) + 128*ms1**2*s**(-1)* + u1**(-1) - 512*ms1**4*s**(-2)*t1**(-1) - 512*ms1**4*s**(-2)* + u1**(-1) + 128*ms1**4*s**(-1)*t1**(-2) + 128*ms1**4*s**(-1)* + u1**(-2) - 256*ms1**6*s**(-2)*t1**(-2) - 512*ms1**6*s**(-2)* + t1**(-1)*u1**(-1) - 256*ms1**6*s**(-2)*u1**(-2) + 64*s**(-1) + ) LQ_GGV = LQ_GGV + SOF1(2)*Nc*Co*Pi*alphas**3 * ( - 128*ms1**2* + s**(-4)*t1**2 - 128*ms1**2*s**(-3)*t1 - 64*ms1**2*s**(-2) - + 256*ms1**4*s**(-3) - 128*ms1**4*s**(-2)*t1**(-1) - 128*ms1**4 + *s**(-2)*u1**(-1) - 128*ms1**6*s**(-2)*t1**(-2) - 128*ms1**6* + s**(-2)*u1**(-2) ) LQ_GGV = LQ_GGV + SOF1(2)*Nc*Ck*Pi*alphas**3 *(128*ms1**2*s**(-4) + *t1**2 + 128*ms1**2*s**(-3)*t1 + 192*ms1**2*s**(-2) + 256* + ms1**4*s**(-3) + 384*ms1**4*s**(-2)*t1**(-1) + 384*ms1**4* + s**(-2)*u1**(-1) + 384*ms1**6*s**(-2)*t1**(-2) + 512*ms1**6* + s**(-2)*t1**(-1)*u1**(-1) + 384*ms1**6*s**(-2)*u1**(-2) ) LQ_GGV = LQ_GGV + SOF1(2)*Cqed*Pi*alphas**3 * ( - 64*ms1**2* + s**(-2) - 128*ms1**4*s**(-2)*t1**(-1) - 128*ms1**4*s**(-2)* + u1**(-1) - 128*ms1**6*s**(-2)*t1**(-2) - 256*ms1**6*s**(-2)* + t1**(-1)*u1**(-1) - 128*ms1**6*s**(-2)*u1**(-2) ) LQ_GGV = LQ_GGV + SOF1(3)*Nc*Co*Pi*alphas**3 * ( - 128*ms1**2* + s**(-4)*t1**2 - 128*ms1**2*s**(-3)*t1 - 64*ms1**2*s**(-2) - + 256*ms1**4*s**(-3) - 128*ms1**4*s**(-2)*t1**(-1) - 128*ms1**4 + *s**(-2)*u1**(-1) - 128*ms1**6*s**(-2)*t1**(-2) - 128*ms1**6* + s**(-2)*u1**(-2) ) LQ_GGV = LQ_GGV + SOF1(3)*Nc*Ck*Pi*alphas**3 *(128*ms1**2*s**(-4) + *t1**2 + 128*ms1**2*s**(-3)*t1 + 192*ms1**2*s**(-2) + 256* + ms1**4*s**(-3) + 384*ms1**4*s**(-2)*t1**(-1) + 384*ms1**4* + s**(-2)*u1**(-1) + 384*ms1**6*s**(-2)*t1**(-2) + 512*ms1**6* + s**(-2)*t1**(-1)*u1**(-1) + 384*ms1**6*s**(-2)*u1**(-2) ) LQ_GGV = LQ_GGV + SOF1(3)*Cqed*Pi*alphas**3 * ( - 64*ms1**2* + s**(-2) - 128*ms1**4*s**(-2)*t1**(-1) - 128*ms1**4*s**(-2)* + u1**(-1) - 128*ms1**6*s**(-2)*t1**(-2) - 256*ms1**6*s**(-2)* + t1**(-1)*u1**(-1) - 128*ms1**6*s**(-2)*u1**(-2) ) LQ_GGV = LQ_GGV + SOF1(4)*Nc*Co*Pi*alphas**3 * ( - 128*ms1**2* + s**(-3)*t1 + 128*ms1**4*s**(-2)*u1**(-1) - 64*s**(-4)*t1**3 + - 64*s**(-3)*t1**2 ) LQ_GGV = LQ_GGV + SOF1(4)*Nc*Ck*Pi*alphas**3 *(128*ms1**2*s**(-1) + *t1**(-1) - 128*ms1**4*s**(-2)*t1**(-1) - 128*ms1**4*s**(-2)* + u1**(-1) + 128*ms1**4*s**(-1)*t1**(-2) + 64*s**(-2)*t1 + 64* + s**(-1) ) LQ_GGV = LQ_GGV + SOF1(5)*Nc*Co*Pi*alphas**3 *(128*ms1**2*s**(-3) + *t1 + 128*ms1**2*s**(-2) + 128*ms1**4*s**(-2)*t1**(-1) + 64* + s**(-4)*t1**3 + 128*s**(-3)*t1**2 + 64*s**(-2)*t1 ) LQ_GGV = LQ_GGV + SOF1(5)*Nc*Ck*Pi*alphas**3 *(128*ms1**2*s**(-1) + *u1**(-1) - 128*ms1**4*s**(-2)*t1**(-1) - 128*ms1**4*s**(-2)* + u1**(-1) + 128*ms1**4*s**(-1)*u1**(-2) - 64*s**(-2)*t1 ) LQ_GGV = LQ_GGV + SOF1(6)*Nc*Co*Pi*alphas**3 *(128*ms1**2*s**(-3) + *t1 + 128*ms1**2*s**(-2) + 128*ms1**4*s**(-2)*t1**(-1) + 64* + s**(-4)*t1**3 + 128*s**(-3)*t1**2 + 64*s**(-2)*t1 ) LQ_GGV = LQ_GGV + SOF1(6)*Nc*Ck*Pi*alphas**3 *(128*ms1**2*s**(-1) + *u1**(-1) - 128*ms1**4*s**(-2)*t1**(-1) - 128*ms1**4*s**(-2)* + u1**(-1) + 128*ms1**4*s**(-1)*u1**(-2) - 64*s**(-2)*t1 ) LQ_GGV = LQ_GGV + SOF1(7)*Nc*Co*Pi*alphas**3 * ( - 128*ms1**2* + s**(-3)*t1 + 128*ms1**4*s**(-2)*u1**(-1) - 64*s**(-4)*t1**3 + - 64*s**(-3)*t1**2 ) LQ_GGV = LQ_GGV + SOF1(7)*Nc*Ck*Pi*alphas**3 *(128*ms1**2*s**(-1) + *t1**(-1) - 128*ms1**4*s**(-2)*t1**(-1) - 128*ms1**4*s**(-2)* + u1**(-1) + 128*ms1**4*s**(-1)*t1**(-2) + 64*s**(-2)*t1 + 64* + s**(-1) ) LQ_GGV = LQ_GGV + SOF1(8)*Nc*Co*Pi*alphas**3 *(256*ms1**2*s**(-2) + + 128*ms1**2*s**(-1)*t1**(-1) + 128*ms1**2*s**(-1)*u1**(-1) + + 128*ms1**4*s**(-1)*t1**(-2) + 128*ms1**4*s**(-1)*u1**(-2) + + 128*s**(-3)*t1**2 + 128*s**(-2)*t1 + 64*s**(-1) ) LQ_GGV = fac * LQ_GGV + dec end c -------------------------------------------------------------------- real*8 function LQ_GGH(s,t1,s4,ms1) implicit none real*8 Pi,Nc,Co,Ck,Cqed,alphas,fac real*8 s,t1,u1,ms1,s4 real*8 hardin(5) real*8 ANG4(71),COLO1(9) Pi = 4.D0*atan(1.D0) Nc = 3.D0 Co = Nc*(Nc**2-1.D0) Ck = (Nc**2-1.D0)/Nc Cqed = Nc**2 - 1/Nc**2 alphas = 1.D0 u1 = s4 - s - t1 fac = s4 /(s4+ms1**2) /8.D0 /(16*Pi**2)**2 /(Nc**2-1.D0)**2 hardin(1) = s hardin(2) = t1 hardin(3) = u1 hardin(4) = s4 hardin(5) = ms1**2 call LOGAS_LQ(hardin,COLO1) call ANGULAR_ARRAY_LQ(hardin,ANG4) LQ_GGH = + + Nc*Co*Pi**4*alphas**3 * ( 4608*ms1**2*s**(-4)*t1*s4**(-1) - + 2560*ms1**2*s**(-4)*t1*(t1+u1)**(-1) - 2048*ms1**2*s**(-4)* + t1**2*s4**(-2) + 1024*ms1**2*s**(-4)*t1**2*s4**(-1)* + (t1+u1)**(-1) - 1024*ms1**2*s**(-4) - 4096*ms1**2*s**(-3)* + t1**(-3)*u1**2 - 4608*ms1**2*s**(-3)*t1**(-2)*u1 + 512*ms1**2 + *s**(-3)*t1**(-1)*s4*(s+t1)**(-1) - 4096*ms1**2*s**(-3)* + t1**(-1)*s4*(s+u1)**(-1) + 8192*ms1**2*s**(-3)*t1**(-1) - + 4608*ms1**2*s**(-3)*t1*u1**(-2) - 3584*ms1**2*s**(-3)*t1* + s4**(-2) + 5120*ms1**2*s**(-3)*t1*s4**(-1)*(t1+u1)**(-1) - + 4096*ms1**2*s**(-3)*t1**2*u1**(-3) - 1024*ms1**2*s**(-3)* + t1**2*s4**(-2)*(t1+u1)**(-1) - 4096*ms1**2*s**(-3)*u1**(-1)* + s4*(s+t1)**(-1) + 512*ms1**2*s**(-3)*u1**(-1)*s4*(s+u1)**(-1) + + 8704*ms1**2*s**(-3)*u1**(-1) + 2560*ms1**2*s**(-3)* + s4**(-1) - 3584*ms1**2*s**(-3)*(t1+u1)**(-1) - 8192*ms1**2* + s**(-2)*t1**(-3)*u1 + 512*ms1**2*s**(-2)*t1**(-2)*s4* + (s+t1)**(-1) ) LQ_GGH = LQ_GGH + Nc*Co*Pi**4*alphas**3 * ( 5632*ms1**2*s**(-2)* + t1**(-2)*s4*(s+u1)**(-1) - 10240*ms1**2*s**(-2)*t1**(-2) - + 4608*ms1**2*s**(-2)*t1**(-1)*u1**(-1)*s4*(s+t1)**(-1) - 4608* + ms1**2*s**(-2)*t1**(-1)*u1**(-1)*s4*(s+u1)**(-1) + 9216* + ms1**2*s**(-2)*t1**(-1)*u1**(-1) - 9728*ms1**2*s**(-2)* + t1**(-1)*s4**(-1) - 1536*ms1**2*s**(-2)*t1**(-1)* + (t1+u1)**(-1) - 8192*ms1**2*s**(-2)*t1*u1**(-3) - 2560*ms1**2 + *s**(-2)*t1*s4**(-2)*(t1+u1)**(-1) + 5632*ms1**2*s**(-2)* + u1**(-2)*s4*(s+t1)**(-1) + 512*ms1**2*s**(-2)*u1**(-2)*s4* + (s+u1)**(-1) - 10240*ms1**2*s**(-2)*u1**(-2) - 12288*ms1**2* + s**(-2)*u1**(-1)*s4**(-1) - 3072*ms1**2*s**(-2)*s4**(-2) + + 6144*ms1**2*s**(-2)*s4**(-1)*(t1+u1)**(-1) - 1024*ms1**2* + s**(-1)*t1**(-3)*s4*(s+u1)**(-1) - 5120*ms1**2*s**(-1)* + t1**(-3) - 512*ms1**2*s**(-1)*t1**(-2)*u1**(-1)*s4* + (s+t1)**(-1) + 6144*ms1**2*s**(-1)*t1**(-2)*u1**(-1)*s4* + (s+u1)**(-1) ) LQ_GGH = LQ_GGH + Nc*Co*Pi**4*alphas**3 * ( -7680*ms1**2*s**(-1)* + t1**(-2)*u1**(-1) + 512*ms1**2*s**(-1)*t1**(-2)*s4**(-1) + + 6144*ms1**2*s**(-1)*t1**(-1)*u1**(-2)*s4*(s+t1)**(-1) - 512* + ms1**2*s**(-1)*t1**(-1)*u1**(-2)*s4*(s+u1)**(-1) - 7680* + ms1**2*s**(-1)*t1**(-1)*u1**(-2) - 12288*ms1**2*s**(-1)* + t1**(-1)*u1**(-1)*s4**(-1) + 1024*ms1**2*s**(-1)*t1**(-1)* + s4**(-2) + 2560*ms1**2*s**(-1)*t1**(-1)*s4**(-1)* + (t1+u1)**(-1) - 1024*ms1**2*s**(-1)*u1**(-3)*s4*(s+t1)**(-1) + - 5120*ms1**2*s**(-1)*u1**(-3) + 512*ms1**2*s**(-1)*u1**(-2) + *s4**(-1) + 2048*ms1**2*s**(-1)*u1**(-1)*s4**(-2) - 2560* + ms1**2*s**(-1)*s4**(-2)*(t1+u1)**(-1) - 1024*ms1**2*t1**(-3)* + u1**(-1)*s4*(s+u1)**(-1) - 1024*ms1**2*t1**(-3)*u1**(-1) + + 512*ms1**2*t1**(-2)*u1**(-2)*s4*(s+t1)**(-1) + 512*ms1**2* + t1**(-2)*u1**(-2)*s4*(s+u1)**(-1) - 1024*ms1**2*t1**(-2)* + u1**(-2) + 512*ms1**2*t1**(-2)*u1**(-1)*s4**(-1) - 1024* + ms1**2*t1**(-1)*u1**(-3)*s4*(s+t1)**(-1) ) LQ_GGH = LQ_GGH + Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2*t1**(-1) + *u1**(-3) + 512*ms1**2*t1**(-1)*u1**(-2)*s4**(-1) + 2048* + ms1**2*t1**(-1)*u1**(-1)*s4**(-2) - 1024*ms1**2*t1**(-1)* + s4**(-2)*(t1+u1)**(-1) - 4096*ms1**4*s**(-3)*t1**(-3)*u1 - + 4096*ms1**4*s**(-3)*t1*u1**(-3) + 1024*ms1**4*s**(-3)* + u1**(-1)*s4**(-1) - 2048*ms1**4*s**(-3)*s4**(-2) + 4096* + ms1**4*s**(-2)*t1**(-4)*u1 - 1024*ms1**4*s**(-2)*t1**(-2)* + s4**(-1) - 1024*ms1**4*s**(-2)*t1**(-1)*s4**(-2) + 4096* + ms1**4*s**(-2)*t1*u1**(-4) - 1024*ms1**4*s**(-2)*u1**(-2)* + s4**(-1) - 1024*ms1**4*s**(-2)*u1**(-1)*s4**(-2) + 8192* + ms1**4*s**(-1)*t1**(-4) + 2048*ms1**4*s**(-1)*t1**(-3)* + s4**(-1) + 2048*ms1**4*s**(-1)*t1**(-2)*u1**(-1)*s4**(-1) + + 2048*ms1**4*s**(-1)*t1**(-1)*u1**(-2)*s4**(-1) + 8192*ms1**4* + s**(-1)*u1**(-4) + 2048*ms1**4*s**(-1)*u1**(-3)*s4**(-1) + + 2048*ms1**4*s*t1**(-4)*u1**(-2) + 2048*ms1**4*s*t1**(-2)* + u1**(-4) ) LQ_GGH = LQ_GGH + Nc*Co*Pi**4*alphas**3 * ( 6144*ms1**4*t1**(-4)* + u1**(-1) + 2048*ms1**4*t1**(-3)*u1**(-2) + 2048*ms1**4* + t1**(-3)*u1**(-1)*s4**(-1) + 2048*ms1**4*t1**(-2)*u1**(-3) + + 6144*ms1**4*t1**(-1)*u1**(-4) + 2048*ms1**4*t1**(-1)*u1**(-3) + *s4**(-1) + 4096*ms1**6*s**(-2)*t1**(-4) - 1024*ms1**6* + s**(-2)*t1**(-2)*s4**(-2) + 4096*ms1**6*s**(-2)*u1**(-4) - + 1024*ms1**6*s**(-2)*u1**(-2)*s4**(-2) + 4096*ms1**6*s**(-1)* + t1**(-4)*s4**(-1) + 4096*ms1**6*s**(-1)*t1**(-3)*u1**(-1)* + s4**(-1) + 4096*ms1**6*s**(-1)*t1**(-1)*u1**(-3)*s4**(-1) + + 4096*ms1**6*s**(-1)*u1**(-4)*s4**(-1) + 2048*ms1**6*t1**(-4)* + u1**(-2) + 4096*ms1**6*t1**(-4)*u1**(-1)*s4**(-1) + 2048* + ms1**6*t1**(-2)*u1**(-4) + 4096*ms1**6*t1**(-1)*u1**(-4)* + s4**(-1) - 1024*s**(-4)*t1**2*s4**(-1) + 1024*s**(-4)*t1**2* + (t1+u1)**(-1) - 512*s**(-3)*t1**(-2)*u1**2 + 512*s**(-3)* + t1**(-1)*u1*s4*(s+t1)**(-1) + 3328*s**(-3)*t1**(-1)*u1 + 512* + s**(-3)*t1*u1**(-1)*s4*(s+u1)**(-1) ) LQ_GGH = LQ_GGH + Nc*Co*Pi**4*alphas**3 * ( 3584*s**(-3)*t1* + u1**(-1) - 3072*s**(-3)*t1*s4**(-1) + 2560*s**(-3)*t1* + (t1+u1)**(-1) - 512*s**(-3)*t1**2*u1**(-2) - 1024*s**(-3)* + t1**2*s4**(-1)*(t1+u1)**(-1) - 3584*s**(-3)*s4*(s+t1)**(-1) + - 3584*s**(-3)*s4*(s+u1)**(-1) + 7680*s**(-3) + 512*s**(-2)* + t1**(-2)*u1*s4*(s+t1)**(-1) - 512*s**(-2)*t1**(-2)*u1 - 3584* + s**(-2)*t1**(-1)*s4*(s+t1)**(-1) + 1024*s**(-2)*t1**(-1)*s4* + (s+u1)**(-1) + 1792*s**(-2)*t1**(-1) + 512*s**(-2)*t1* + u1**(-2)*s4*(s+u1)**(-1) - 512*s**(-2)*t1*u1**(-2) - 2560* + s**(-2)*t1*s4**(-1)*(t1+u1)**(-1) + 1024*s**(-2)*u1**(-1)*s4* + (s+t1)**(-1) - 3584*s**(-2)*u1**(-1)*s4*(s+u1)**(-1) + 1536* + s**(-2)*u1**(-1) - 2304*s**(-2)*s4**(-1) + 2560*s**(-2)* + (t1+u1)**(-1) - 1024*s**(-1)*t1**(-2)*s4*(s+u1)**(-1) + 1024* + s**(-1)*t1**(-2) + 1024*s**(-1)*t1**(-1)*u1**(-1)*s4* + (s+t1)**(-1) + 1024*s**(-1)*t1**(-1)*u1**(-1)*s4*(s+u1)**(-1) + - 2048*s**(-1)*t1**(-1)*u1**(-1) ) LQ_GGH = LQ_GGH + Nc*Co*Pi**4*alphas**3 *(1024*s**(-1)*t1**(-1)* + s4**(-1) + 1024*s**(-1)*t1**(-1)*(t1+u1)**(-1) - 1024*s**(-1) + *u1**(-2)*s4*(s+t1)**(-1) + 1024*s**(-1)*u1**(-2) + 2304* + s**(-1)*u1**(-1)*s4**(-1) - 2560*s**(-1)*s4**(-1)* + (t1+u1)**(-1) - 1024*t1**(-2)*u1**(-1)*s4*(s+u1)**(-1) + 1024 + *t1**(-2)*u1**(-1) - 1024*t1**(-1)*u1**(-2)*s4*(s+t1)**(-1) + + 1024*t1**(-1)*u1**(-2) + 2048*t1**(-1)*u1**(-1)*s4**(-1) + - 1024*t1**(-1)*s4**(-1)*(t1+u1)**(-1) ) LQ_GGH = LQ_GGH + Nc*Ck*Pi**4*alphas**3 * ( -2048*ms1**2*s**(-4)* + t1*s4**(-1) + 1024*ms1**2*s**(-4)*t1**2*s4**(-2) + 1024* + ms1**2*s**(-4) - 512*ms1**2*s**(-3)*t1**(-1) + 1024*ms1**2* + s**(-3)*t1*s4**(-2) - 1024*ms1**2*s**(-3)*u1**(-1) + 1024* + ms1**2*s**(-3)*s4**(-1) + 1536*ms1**2*s**(-2)*t1**(-2) + 3072 + *ms1**2*s**(-2)*t1**(-1)*u1**(-1) + 1536*ms1**2*s**(-2)* + u1**(-2) + 1024*ms1**2*s**(-2)*u1**(-1)*s4**(-1) + 1536* + ms1**2*s**(-2)*s4**(-2) + 2048*ms1**2*s**(-1)*t1**(-3) + 2048 + *ms1**2*s**(-1)*t1**(-2)*u1**(-1) + 2048*ms1**2*s**(-1)* + t1**(-1)*u1**(-2) + 2048*ms1**2*s**(-1)*u1**(-3) + 2048* + ms1**2*t1**(-3)*u1**(-1) + 2048*ms1**2*t1**(-1)*u1**(-3) - + 1024*ms1**4*s**(-3)*u1**(-1)*s4**(-1) + 2048*ms1**4*s**(-3)* + s4**(-2) + 3072*ms1**4*s**(-2)*t1**(-2)*s4**(-1) + 4096* + ms1**4*s**(-2)*t1**(-1)*u1**(-1)*s4**(-1) + 3072*ms1**4* + s**(-2)*t1**(-1)*s4**(-2) + 3072*ms1**4*s**(-2)*u1**(-2)* + s4**(-1) ) LQ_GGH = LQ_GGH + Nc*Ck*Pi**4*alphas**3 * ( 3072*ms1**4*s**(-2)* + u1**(-1)*s4**(-2) + 4096*ms1**4*s**(-1)*t1**(-3)*u1**(-1) - + 2048*ms1**4*s**(-1)*t1**(-3)*s4**(-1) - 2048*ms1**4*s**(-1)* + t1**(-2)*u1**(-1)*s4**(-1) + 4096*ms1**4*s**(-1)*t1**(-1)* + u1**(-3) - 2048*ms1**4*s**(-1)*t1**(-1)*u1**(-2)*s4**(-1) - + 2048*ms1**4*s**(-1)*u1**(-3)*s4**(-1) - 2048*ms1**4*s* + t1**(-4)*u1**(-2) - 2048*ms1**4*s*t1**(-2)*u1**(-4) - 2048* + ms1**4*t1**(-4)*u1**(-1) - 2048*ms1**4*t1**(-3)*u1**(-2) - + 2048*ms1**4*t1**(-3)*u1**(-1)*s4**(-1) - 2048*ms1**4*t1**(-2) + *u1**(-3) - 2048*ms1**4*t1**(-1)*u1**(-4) - 2048*ms1**4* + t1**(-1)*u1**(-3)*s4**(-1) + 3072*ms1**6*s**(-2)*t1**(-2)* + s4**(-2) + 4096*ms1**6*s**(-2)*t1**(-1)*u1**(-1)*s4**(-2) + + 3072*ms1**6*s**(-2)*u1**(-2)*s4**(-2) - 2048*ms1**6*t1**(-4)* + u1**(-2) - 2048*ms1**6*t1**(-2)*u1**(-4) - 256*s**(-3)* + t1**(-1)*u1 - 512*s**(-3)*t1*u1**(-1) + 512*s**(-3)*t1* + s4**(-1) ) LQ_GGH = LQ_GGH + Nc*Ck*Pi**4*alphas**3 * ( - 512*s**(-3) + 768* + s**(-2)*t1**(-1) + 1024*s**(-2)*u1**(-1) - 256*s**(-2)* + s4**(-1) + 1024*s**(-1)*t1**(-1)*u1**(-1) - 256*s**(-1)* + u1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + Cqed*Pi**4*alphas**3 * ( - 512*ms1**2*s**(-2)* + t1**(-2) - 1536*ms1**2*s**(-2)*t1**(-1)*u1**(-1) - 512*ms1**2 + *s**(-2)*u1**(-2) - 512*ms1**2*s**(-2)*s4**(-2) - 1024*ms1**4 + *s**(-2)*t1**(-2)*s4**(-1) - 2048*ms1**4*s**(-2)*t1**(-1)* + u1**(-1)*s4**(-1) - 1024*ms1**4*s**(-2)*t1**(-1)*s4**(-2) - + 1024*ms1**4*s**(-2)*u1**(-2)*s4**(-1) - 1024*ms1**4*s**(-2)* + u1**(-1)*s4**(-2) - 1024*ms1**6*s**(-2)*t1**(-2)*s4**(-2) - + 2048*ms1**6*s**(-2)*t1**(-1)*u1**(-1)*s4**(-2) - 1024*ms1**6* + s**(-2)*u1**(-2)*s4**(-2) - 512*s**(-2)*t1**(-1) - 512* + s**(-2)*u1**(-1) - 512*s**(-1)*t1**(-1)*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(1)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**6* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(1)*Nc*Ck*Pi**4*alphas**3 * ( 1536*ms1**6* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(1)*Cqed*Pi**4*alphas**3 * ( - 512*ms1**6* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(2)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**4* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(2)*Nc*Ck*Pi**4*alphas**3 * ( 1536*ms1**4* + s**(-2) + 2048*ms1**6*s**(-2)*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(2)*Cqed*Pi**4*alphas**3 * ( - 512*ms1**4* + s**(-2) - 1024*ms1**6*s**(-2)*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(3)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**4* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(3)*Nc*Ck*Pi**4*alphas**3 * ( 1536*ms1**4* + s**(-2) - 2048*ms1**6*s**(-3) ) LQ_GGH = LQ_GGH + ANG4(3)*Cqed*Pi**4*alphas**3 * ( - 512*ms1**4* + s**(-2) + 1024*ms1**6*s**(-3) ) LQ_GGH = LQ_GGH + ANG4(4)*Nc*Co*Pi**4*alphas**3 * ( 512*ms1**2* + s**(-2)*t1*(t1+u1)**(-1) - 512*ms1**2*s**(-2) + 512*ms1**2* + s**(-1)*(t1+u1)**(-1) + 512*ms1**4*s**(-3)*t1*u1**(-1) - 512* + ms1**4*s**(-3)*t1*(t1+u1)**(-1) + 512*ms1**4*s**(-3) + 512* + ms1**4*s**(-2)*u1**(-1) - 512*ms1**4*s**(-2)*(t1+u1)**(-1) + + 512*ms1**4*s**(-1)*u1**(-1)*(t1+u1)**(-1) - 128*s**(-1)*t1* + (t1+u1)**(-1) + 128*s**(-1) ) LQ_GGH = LQ_GGH + ANG4(4)*Nc*Ck*Pi**4*alphas**3 * ( 320*ms1**2* + s**(-2)*t1**(-1)*u1 - 512*ms1**2*s**(-2)*t1*s4**(-1) + 192* + ms1**2*s**(-2)*s4*(s+t1)**(-1) + 320*ms1**2*s**(-2) - 64* + ms1**2*s**(-1)*t1**(-1)*s4*(s+t1)**(-1) - 448*ms1**2*s**(-1)* + t1**(-1) - 256*ms1**2*s**(-1)*u1**(-1)*s4*(s+t1)**(-1) + 256* + ms1**2*s**(-1)*u1**(-1) - 768*ms1**2*s**(-1)*s4**(-1) - 1024* + ms1**4*s**(-3)*t1**(-1)*u1 - 1536*ms1**4*s**(-3)*t1*u1**(-1) + + 512*ms1**4*s**(-3)*t1*s4**(-1) - 2560*ms1**4*s**(-3) + 512 + *ms1**4*s**(-2)*t1**(-1)*s4*(s+t1)**(-1) + 640*ms1**4*s**(-2) + *t1**(-1) - 128*ms1**4*s**(-2)*u1**(-1)*s4*(s+t1)**(-1) + 640 + *ms1**4*s**(-2)*u1**(-1) + 1024*ms1**4*s**(-2)*s4**(-1) - 640 + *ms1**4*s**(-1)*t1**(-1)*u1**(-1)*s4*(s+t1)**(-1) + 128* + ms1**4*s**(-1)*t1**(-1)*u1**(-1) - 512*ms1**4*s**(-1)* + u1**(-2)*s4*(s+t1)**(-1) + 512*ms1**4*s**(-1)*u1**(-2) - 512* + ms1**4*s**(-1)*u1**(-1)*s4**(-1) - 2048*ms1**6*s**(-4) - 1024 + *ms1**6*s**(-3)*t1**(-1) ) LQ_GGH = LQ_GGH + ANG4(4)*Nc*Ck*Pi**4*alphas**3 * ( -1024*ms1**6* + s**(-3)*u1**(-1) + 1024*ms1**6*s**(-2)*u1**(-1)*s4**(-1) - + 128*s**(-1)*t1**(-1)*u1 + 128*s**(-1)*t1*s4**(-1) - 128* + s**(-1)*s4*(s+t1)**(-1) + 128*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(4)*Cqed*Pi**4*alphas**3 * ( - 256*ms1**2* + s**(-2)*t1**(-1)*u1 + 768*ms1**2*s**(-1)*t1**(-1) - 512* + ms1**2*s**(-1)*s4**(-1) - 768*ms1**2*t1**(-1)*s4**(-1) + 512* + ms1**4*s**(-3)*t1**(-1)*u1 + 512*ms1**4*s**(-3)*t1*u1**(-1) + + 1024*ms1**4*s**(-3) - 1024*ms1**4*s**(-2)*t1**(-1) - 512* + ms1**4*s**(-2)*u1**(-1) + 512*ms1**4*s**(-2)*s4**(-1) + 1536* + ms1**4*s**(-1)*t1**(-1)*s4**(-1) + 512*ms1**4*s**(-1)* + u1**(-1)*s4**(-1) + 1024*ms1**6*s**(-4) + 1024*ms1**6*s**(-3) + *t1**(-1) + 1024*ms1**6*s**(-3)*u1**(-1) - 1024*ms1**6* + s**(-2)*t1**(-1)*s4**(-1) - 1024*ms1**6*s**(-2)*u1**(-1)* + s4**(-1) + 128*s**(-1)*t1**(-1)*u1 + 128*s*t1**(-1)*s4**(-1) + - 128*t1**(-1) + 128*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(5)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**6* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(5)*Nc*Ck*Pi**4*alphas**3 * ( 1536*ms1**6* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(5)*Cqed*Pi**4*alphas**3 * ( - 512*ms1**6* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(6)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**4* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(6)*Nc*Ck*Pi**4*alphas**3 * ( 1536*ms1**4* + s**(-2) + 2048*ms1**6*s**(-2)*t1**(-1) ) LQ_GGH = LQ_GGH + ANG4(6)*Cqed*Pi**4*alphas**3 * ( - 512*ms1**4* + s**(-2) - 1024*ms1**6*s**(-2)*t1**(-1) ) LQ_GGH = LQ_GGH + ANG4(7)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**4* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(7)*Nc*Ck*Pi**4*alphas**3 * ( 1536*ms1**4* + s**(-2) - 2048*ms1**6*s**(-3) ) LQ_GGH = LQ_GGH + ANG4(7)*Cqed*Pi**4*alphas**3 * ( - 512*ms1**4* + s**(-2) + 1024*ms1**6*s**(-3) ) LQ_GGH = LQ_GGH + ANG4(8)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-2)*t1*(t1+u1)**(-1) + 512*ms1**2*s**(-1)*(t1+u1)**(-1) + + 512*ms1**4*s**(-3)*t1**(-1)*u1 + 512*ms1**4*s**(-3)*t1* + (t1+u1)**(-1) + 512*ms1**4*s**(-2)*t1**(-1) - 512*ms1**4* + s**(-2)*(t1+u1)**(-1) + 512*ms1**4*s**(-1)*t1**(-1)*u1**(-1) + - 512*ms1**4*s**(-1)*u1**(-1)*(t1+u1)**(-1) + 128*s**(-1)*t1 + *(t1+u1)**(-1) ) LQ_GGH = LQ_GGH + ANG4(8)*Nc*Ck*Pi**4*alphas**3 * ( 256*ms1**2* + s**(-2)*t1*u1**(-1) + 512*ms1**2*s**(-2)*t1*s4**(-1) + 256* + ms1**2*s**(-2)*s4*(s+u1)**(-1) - 256*ms1**2*s**(-2) - 256* + ms1**2*s**(-1)*t1**(-1)*s4*(s+u1)**(-1) + 256*ms1**2*s**(-1)* + t1**(-1) - 512*ms1**2*s**(-1)*u1**(-1) - 256*ms1**2*s**(-1)* + s4**(-1) - 1536*ms1**4*s**(-3)*t1**(-1)*u1 - 1024*ms1**4* + s**(-3)*t1*u1**(-1) - 512*ms1**4*s**(-3)*t1*s4**(-1) - 2048* + ms1**4*s**(-3) + 512*ms1**4*s**(-2)*t1**(-1)*s4*(s+u1)**(-1) + + 512*ms1**4*s**(-2)*u1**(-1)*s4*(s+u1)**(-1) + 512*ms1**4* + s**(-2)*s4**(-1) - 512*ms1**4*s**(-1)*t1**(-2)*s4* + (s+u1)**(-1) + 512*ms1**4*s**(-1)*t1**(-2) - 512*ms1**4* + s**(-1)*t1**(-1)*u1**(-1) - 512*ms1**4*s**(-1)*t1**(-1)* + s4**(-1) - 2048*ms1**6*s**(-4) - 1024*ms1**6*s**(-3)*t1**(-1) + - 1024*ms1**6*s**(-3)*u1**(-1) + 1024*ms1**6*s**(-2)* + t1**(-1)*s4**(-1) - 128*s**(-1)*t1*u1**(-1) - 128*s**(-1)*t1* + s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(8)*Nc*Ck*Pi**4*alphas**3 * ( -128*s**(-1)* + s4*(s+u1)**(-1) + 128*s**(-1) ) LQ_GGH = LQ_GGH + ANG4(8)*Cqed*Pi**4*alphas**3 * ( - 256*ms1**2* + s**(-2)*t1*u1**(-1) + 768*ms1**2*s**(-1)*u1**(-1) - 512* + ms1**2*s**(-1)*s4**(-1) - 768*ms1**2*u1**(-1)*s4**(-1) + 512* + ms1**4*s**(-3)*t1**(-1)*u1 + 512*ms1**4*s**(-3)*t1*u1**(-1) + + 1024*ms1**4*s**(-3) - 512*ms1**4*s**(-2)*t1**(-1) - 1024* + ms1**4*s**(-2)*u1**(-1) + 512*ms1**4*s**(-2)*s4**(-1) + 512* + ms1**4*s**(-1)*t1**(-1)*s4**(-1) + 1536*ms1**4*s**(-1)* + u1**(-1)*s4**(-1) + 1024*ms1**6*s**(-4) + 1024*ms1**6*s**(-3) + *t1**(-1) + 1024*ms1**6*s**(-3)*u1**(-1) - 1024*ms1**6* + s**(-2)*t1**(-1)*s4**(-1) - 1024*ms1**6*s**(-2)*u1**(-1)* + s4**(-1) + 128*s**(-1)*t1*u1**(-1) + 128*s*u1**(-1)*s4**(-1) + - 128*u1**(-1) + 128*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(9)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-4) ) LQ_GGH = LQ_GGH + ANG4(9)*Nc*Ck*Pi**4*alphas**3 * ( 512*ms1**2* + s**(-4) ) LQ_GGH = LQ_GGH + ANG4(10)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-3) ) LQ_GGH = LQ_GGH + ANG4(10)*Nc*Ck*Pi**4*alphas**3 * ( 512*ms1**2* + s**(-3) ) LQ_GGH = LQ_GGH + ANG4(11)*Nc*Co*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-4)*(t1+u1)**(-1) ) LQ_GGH = LQ_GGH + ANG4(12)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + *s**(-4)*t1*(t1+u1)**(-1) + 1024*ms1**2*s**(-4) + 1024*ms1**2 + *s**(-3)*(t1+u1)**(-1) ) LQ_GGH = LQ_GGH + ANG4(12)*Nc*Ck*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-4)*t1*s4**(-1) - 1024*ms1**2*s**(-4) - 256*ms1**2* + s**(-3)*t1**(-1) + 256*ms1**2*s**(-3)*u1**(-1) + 512*ms1**2* + s**(-3)*s4**(-1) + 512*ms1**2*s**(-2)*t1**(-1)*s4**(-1) - 512 + *ms1**2*s**(-2)*u1**(-1)*s4**(-1) - 512*ms1**4*s**(-3)* + t1**(-1)*s4**(-1) + 512*ms1**4*s**(-3)*u1**(-1)*s4**(-1) - + 128*s**(-3)*t1**(-1)*u1 + 128*s**(-3)*t1*u1**(-1) - 512* + s**(-3)*t1*s4**(-1) + 256*s**(-3) + 128*s**(-2)*t1**(-1) - + 128*s**(-2)*u1**(-1) - 256*s**(-2)*s4**(-1) - 128*s**(-1)* + t1**(-1)*s4**(-1) + 128*s**(-1)*u1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(13)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + *s**(-4) ) LQ_GGH = LQ_GGH + ANG4(14)*Nc*Co*Pi**4*alphas**3 * ( -2048*ms1**2 + *s**(-4)*u1 - 1024*ms1**2*s**(-3) ) LQ_GGH = LQ_GGH + ANG4(15)*Nc*Co*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-4)*(t1+u1)**(-1) ) LQ_GGH = LQ_GGH + ANG4(16)*Nc*Co*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-4)*t1*s4**(-1) - 1024*ms1**2*s**(-4)*t1*(t1+u1)**(-1) - + 256*ms1**2*s**(-3)*t1**(-1) + 256*ms1**2*s**(-3)*u1**(-1) + + 512*ms1**2*s**(-3)*s4**(-1) + 1024*ms1**2*s**(-3)* + (t1+u1)**(-1) + 512*ms1**2*s**(-2)*t1**(-1)*s4**(-1) - 512* + ms1**2*s**(-2)*u1**(-1)*s4**(-1) - 512*ms1**4*s**(-3)* + t1**(-1)*s4**(-1) + 512*ms1**4*s**(-3)*u1**(-1)*s4**(-1) - + 128*s**(-3)*t1**(-1)*u1 + 128*s**(-3)*t1*u1**(-1) - 512* + s**(-3)*t1*s4**(-1) + 256*s**(-3) + 128*s**(-2)*t1**(-1) - + 128*s**(-2)*u1**(-1) - 256*s**(-2)*s4**(-1) - 128*s**(-1)* + t1**(-1)*s4**(-1) + 128*s**(-1)*u1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(17)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*t1 + 512*ms1**2*s**(-2)*t1*u1**(-1) - 512*ms1**2* + s**(-2)*t1*(t1+u1)**(-1) - 256*ms1**2*s**(-2)*s4*(s+u1)**(-1) + + 512*ms1**2*s**(-2) + 256*ms1**2*s**(-1)*t1**(-1)*s4* + (s+u1)**(-1) + 256*ms1**2*s**(-1)*t1**(-1) + 1024*ms1**2* + s**(-1)*t1*u1**(-2) + 512*ms1**2*s**(-1)*u1**(-1) + 512* + ms1**2*s**(-1)*(t1+u1)**(-1) + 512*ms1**4*s**(-3)*t1* + (t1+u1)**(-1) - 512*ms1**4*s**(-3) - 512*ms1**4*s**(-2)* + t1**(-1) - 512*ms1**4*s**(-2)*(t1+u1)**(-1) + 512*ms1**4* + s**(-1)*t1**(-2)*s4*(s+u1)**(-1) - 512*ms1**4*s**(-1)* + t1**(-2) - 512*ms1**4*s**(-1)*t1**(-1)*u1**(-1) - 512*ms1**4* + s**(-1)*u1**(-1)*(t1+u1)**(-1) - 384*s**(-3)*t1*u1 - 512* + s**(-3)*t1**2 - 256*s**(-3)*t1**3*u1**(-1) - 128*s**(-3)* + u1**2 - 128*s**(-2)*t1**(-1)*u1**2 - 256*s**(-2)*t1*s4* + (s+u1)**(-1) - 1152*s**(-2)*t1 - 256*s**(-2)*t1**2*u1**(-1)* + s4*(s+u1)**(-1) ) LQ_GGH = LQ_GGH + ANG4(17)*Nc*Co*Pi**4*alphas**3 * ( -768*s**(-2) + *t1**2*u1**(-1) - 768*s**(-2)*u1 - 128*s**(-1)*t1**(-1)*u1 - + 512*s**(-1)*t1*u1**(-1) + 128*s**(-1)*t1*(t1+u1)**(-1) + 128* + s**(-1)*s4*(s+u1)**(-1) - 512*s**(-1) ) LQ_GGH = LQ_GGH + ANG4(18)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*u1 + 512*ms1**2*s**(-2)*t1**(-1)*u1 + 512*ms1**2* + s**(-2)*t1*(t1+u1)**(-1) - 256*ms1**2*s**(-2)*s4*(s+t1)**(-1) + + 1024*ms1**2*s**(-1)*t1**(-2)*u1 + 512*ms1**2*s**(-1)* + t1**(-1) + 256*ms1**2*s**(-1)*u1**(-1)*s4*(s+t1)**(-1) + 256* + ms1**2*s**(-1)*u1**(-1) + 512*ms1**2*s**(-1)*(t1+u1)**(-1) - + 512*ms1**4*s**(-3)*t1*(t1+u1)**(-1) - 512*ms1**4*s**(-2)* + u1**(-1) - 512*ms1**4*s**(-2)*(t1+u1)**(-1) - 1024*ms1**4* + s**(-1)*t1**(-1)*u1**(-1) + 512*ms1**4*s**(-1)*u1**(-2)*s4* + (s+t1)**(-1) - 512*ms1**4*s**(-1)*u1**(-2) + 512*ms1**4* + s**(-1)*u1**(-1)*(t1+u1)**(-1) - 256*s**(-3)*t1**(-1)*u1**3 + - 384*s**(-3)*t1*u1 - 128*s**(-3)*t1**2 - 512*s**(-3)*u1**2 + - 256*s**(-2)*t1**(-1)*u1**2*s4*(s+t1)**(-1) - 768*s**(-2)* + t1**(-1)*u1**2 - 768*s**(-2)*t1 - 128*s**(-2)*t1**2*u1**(-1) + - 256*s**(-2)*u1*s4*(s+t1)**(-1) - 1152*s**(-2)*u1 - 512* + s**(-1)*t1**(-1)*u1 ) LQ_GGH = LQ_GGH + ANG4(18)*Nc*Co*Pi**4*alphas**3 * ( -128*s**(-1) + *t1*u1**(-1) - 128*s**(-1)*t1*(t1+u1)**(-1) + 128*s**(-1)*s4* + (s+t1)**(-1) - 384*s**(-1) ) LQ_GGH = LQ_GGH + ANG4(19)*Nc*Ck*Pi**4*alphas**3 * ( 256*ms1**2* + s**(-2)*t1**(-1)*u1 + 256*ms1**2*s**(-2)*t1*u1**(-1) + 256* + ms1**2*s**(-2)*s4*(s+t1)**(-1) + 256*ms1**2*s**(-2)*s4* + (s+u1)**(-1) + 1024*ms1**2*s**(-2) + 256*ms1**2*s**(-1)* + t1**(-1)*s4*(s+u1)**(-1) + 512*ms1**2*s**(-1)*t1**(-1) + 256* + ms1**2*s**(-1)*u1**(-1)*s4*(s+t1)**(-1) + 512*ms1**2*s**(-1)* + u1**(-1) + 1024*ms1**4*s**(-3)*t1**(-1)*u1 + 1024*ms1**4* + s**(-3)*t1*u1**(-1) + 2048*ms1**4*s**(-3) - 512*ms1**4* + s**(-2)*t1**(-1)*s4*(s+t1)**(-1) + 512*ms1**4*s**(-2)* + t1**(-1)*s4*(s+u1)**(-1) + 1024*ms1**4*s**(-2)*t1**(-1) + 512 + *ms1**4*s**(-2)*u1**(-1)*s4*(s+t1)**(-1) - 512*ms1**4*s**(-2) + *u1**(-1)*s4*(s+u1)**(-1) + 1024*ms1**4*s**(-2)*u1**(-1) + + 512*ms1**4*s**(-1)*t1**(-2)*s4*(s+u1)**(-1) - 512*ms1**4* + s**(-1)*t1**(-2) + 512*ms1**4*s**(-1)*u1**(-2)*s4* + (s+t1)**(-1) - 512*ms1**4*s**(-1)*u1**(-2) + 2048*ms1**6* + s**(-4) ) LQ_GGH = LQ_GGH + ANG4(19)*Nc*Ck*Pi**4*alphas**3 * ( 1024*ms1**6* + s**(-3)*t1**(-1) + 1024*ms1**6*s**(-3)*u1**(-1) + 128*s**(-1) + *t1**(-1)*u1 + 128*s**(-1)*t1*u1**(-1) + 128*s**(-1)*s4* + (s+t1)**(-1) + 128*s**(-1)*s4*(s+u1)**(-1) + 256*s**(-1) + + 128*t1**(-1) + 128*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(19)*Cqed*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2)*t1**(-1)*u1 - 256*ms1**2*s**(-2)*t1*u1**(-1) - 768* + ms1**2*s**(-2) - 1024*ms1**2*s**(-1)*t1**(-1) - 1024*ms1**2* + s**(-1)*u1**(-1) - 768*ms1**2*t1**(-1)*u1**(-1) - 512*ms1**4* + s**(-3)*t1**(-1)*u1 - 512*ms1**4*s**(-3)*t1*u1**(-1) - 1024* + ms1**4*s**(-3) - 1536*ms1**4*s**(-2)*t1**(-1) - 1536*ms1**4* + s**(-2)*u1**(-1) - 1536*ms1**4*s**(-1)*t1**(-1)*u1**(-1) - + 1024*ms1**6*s**(-4) - 1024*ms1**6*s**(-3)*t1**(-1) - 1024* + ms1**6*s**(-3)*u1**(-1) - 1024*ms1**6*s**(-2)*t1**(-1)* + u1**(-1) - 128*s**(-1)*t1**(-1)*u1 - 128*s**(-1)*t1*u1**(-1) + - 256*s**(-1) - 128*s*t1**(-1)*u1**(-1) - 256*t1**(-1) - 256 + *u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(20)*Nc*Ck*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*u1**(-1) - 256*ms1**2*s**(-3)*s4**(-1) + 256*ms1**2* + s**(-2)*t1**(-1)*u1**(-1) + 256*ms1**2*s**(-2)*t1**(-1)* + s4**(-1) - 512*ms1**4*s**(-3)*u1**(-1)*s4**(-1) + 512*ms1**4* + s**(-2)*t1**(-1)*u1**(-1)*s4**(-1) - 128*s**(-3)*t1*u1**(-1) + + 128*s**(-3)*t1*s4**(-1) - 256*s**(-3) + 256*s**(-2)* + t1**(-1) + 128*s**(-1)*t1**(-1)*u1**(-1) - 128*s**(-1)* + t1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(20)*Cqed*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2)*t1**(-1)*u1**(-1) - 256*ms1**2*s**(-2)*t1**(-1)* + s4**(-1) - 512*ms1**4*s**(-2)*t1**(-1)*u1**(-1)*s4**(-1) - + 256*s**(-2)*t1**(-1) - 128*s**(-2)*u1**(-1) + 128*s**(-2)* + s4**(-1) - 128*s**(-1)*t1**(-1)*u1**(-1) + 128*s**(-1)* + t1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(21)*Nc*Ck*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*t1**(-1) - 256*ms1**2*s**(-3)*s4**(-1) + 256*ms1**2* + s**(-2)*t1**(-1)*u1**(-1) + 256*ms1**2*s**(-2)*u1**(-1)* + s4**(-1) - 512*ms1**4*s**(-3)*t1**(-1)*s4**(-1) + 512*ms1**4* + s**(-2)*t1**(-1)*u1**(-1)*s4**(-1) - 128*s**(-3)*t1**(-1)*u1 + - 128*s**(-3)*t1*s4**(-1) - 128*s**(-3) + 256*s**(-2)* + u1**(-1) - 128*s**(-2)*s4**(-1) + 128*s**(-1)*t1**(-1)* + u1**(-1) - 128*s**(-1)*u1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(21)*Cqed*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2)*t1**(-1)*u1**(-1) - 256*ms1**2*s**(-2)*u1**(-1)* + s4**(-1) - 512*ms1**4*s**(-2)*t1**(-1)*u1**(-1)*s4**(-1) - + 128*s**(-2)*t1**(-1) - 256*s**(-2)*u1**(-1) + 128*s**(-2)* + s4**(-1) - 128*s**(-1)*t1**(-1)*u1**(-1) + 128*s**(-1)* + u1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(36)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2) - 1024*ms1**4*s**(-3) ) LQ_GGH = LQ_GGH + ANG4(36)*Nc*Ck*Pi**4*alphas**3 * ( 768*ms1**2* + s**(-2) + 1024*ms1**4*s**(-3) ) LQ_GGH = LQ_GGH + ANG4(36)*Cqed*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2) ) LQ_GGH = LQ_GGH + ANG4(37)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-3)*t1*(t1+u1)**(-1) - 512*ms1**2*s**(-3) + 1024*ms1**2* + s**(-2)*(t1+u1)**(-1) - 1024*ms1**4*s**(-3)*(t1+u1)**(-1) + + 256*s**(-3)*t1 - 512*s**(-3)*t1**2*(t1+u1)**(-1) - 256* + s**(-3)*u1 ) LQ_GGH = LQ_GGH + ANG4(37)*Nc*Ck*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*t1**(-1)*u1 - 256*ms1**2*s**(-3)*t1*u1**(-1) + 512* + ms1**2*s**(-3)*t1*s4**(-1) + 512*ms1**2*s**(-3) + 512*ms1**2* + s**(-2)*t1**(-1) + 768*ms1**2*s**(-2)*u1**(-1) - 2560*ms1**2* + s**(-2)*s4**(-1) - 256*ms1**2*s**(-1)*t1**(-1)*s4**(-1) - 768 + *ms1**2*s**(-1)*u1**(-1)*s4**(-1) - 512*ms1**4*s**(-3)* + t1**(-1) - 512*ms1**4*s**(-3)*u1**(-1) + 4096*ms1**4*s**(-3)* + s4**(-1) + 512*ms1**4*s**(-2)*t1**(-1)*s4**(-1) + 1024*ms1**4 + *s**(-2)*u1**(-1)*s4**(-1) + 128*s**(-2)*t1*u1**(-1) - 256* + s**(-2)*t1*s4**(-1) - 128*s**(-2) - 128*s**(-1)*u1**(-1) + + 256*s**(-1)*s4**(-1) + 128*u1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(37)*Cqed*Pi**4*alphas**3 * ( 256*ms1**2* + s**(-2)*t1**(-1) + 256*ms1**2*s**(-2)*u1**(-1) - 512*ms1**2* + s**(-2)*s4**(-1) - 512*ms1**2*s**(-1)*t1**(-1)*s4**(-1) - 512 + *ms1**2*s**(-1)*u1**(-1)*s4**(-1) + 512*ms1**4*s**(-2)* + t1**(-1)*s4**(-1) + 512*ms1**4*s**(-2)*u1**(-1)*s4**(-1) + + 128*s**(-2)*t1**(-1)*u1 + 128*s**(-2)*t1*u1**(-1) - 128* + s**(-1)*t1**(-1) - 128*s**(-1)*u1**(-1) + 256*s**(-1)* + s4**(-1) + 128*t1**(-1)*s4**(-1) + 128*u1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(38)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + *s**(-4)*u1**2 - 1024*ms1**2*s**(-3)*u1 - 3072*ms1**2*s**(-2) + ) LQ_GGH = LQ_GGH + ANG4(39)*Nc*Co*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-4)*t1 - 1024*ms1**2*s**(-4)*t1**2*s4**(-1) - 1024*ms1**2 + *s**(-4)*u1 + 256*ms1**2*s**(-3)*t1*u1**(-1) - 1024*ms1**2* + s**(-3)*t1*s4**(-1) - 512*ms1**2*s**(-3)*t1*(t1+u1)**(-1) - + 1280*ms1**2*s**(-3) - 256*ms1**2*s**(-2)*u1**(-1) - 1536* + ms1**2*s**(-2)*s4**(-1) + 1024*ms1**2*s**(-2)*(t1+u1)**(-1) + - 512*ms1**2*s**(-1)*t1**(-1)*s4**(-1) - 512*ms1**2*s**(-1)* + u1**(-1)*s4**(-1) - 512*ms1**4*s**(-3)*t1**(-1) + 1024*ms1**4 + *s**(-3)*s4**(-1) - 1024*ms1**4*s**(-3)*(t1+u1)**(-1) + 512* + ms1**4*s**(-2)*t1**(-1)*s4**(-1) + 512*ms1**4*s**(-2)* + u1**(-1)*s4**(-1) + 128*s**(-3)*t1**(-1)*u1**2 + 384*s**(-3)* + t1 + 256*s**(-3)*t1**2*u1**(-1) - 512*s**(-3)*t1**2*s4**(-1) + - 512*s**(-3)*t1**2*(t1+u1)**(-1) - 512*s**(-3)*u1 - 512* + s**(-2)*t1*s4**(-1) + 256*s**(-2) - 256*s**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(40)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2) - 512*ms1**4*s**(-2)*u1**(-1) - 512*ms1**6*s**(-2)* + u1**(-2) ) LQ_GGH = LQ_GGH + ANG4(40)*Nc*Ck*Pi**4*alphas**3 * ( 768*ms1**2* + s**(-2) + 1536*ms1**4*s**(-2)*u1**(-1) + 1536*ms1**6*s**(-2)* + u1**(-2) ) LQ_GGH = LQ_GGH + ANG4(40)*Cqed*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2) - 512*ms1**4*s**(-2)*u1**(-1) - 512*ms1**6*s**(-2)* + u1**(-2) ) LQ_GGH = LQ_GGH + ANG4(41)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-2)*u1**(-1)*s4*(s+t1)**(-1) - 512*ms1**4*s**(-2)* + u1**(-2)*s4*(s+t1)**(-1) - 128*s**(-2)*t1*u1**(-1) - 256* + s**(-2)*s4*(s+t1)**(-1) - 128*s**(-1)*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(41)*Nc*Ck*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*t1*u1**(-1) + 256*ms1**2*s**(-3)*t1*s4**(-1) - 512* + ms1**2*s**(-3) + 512*ms1**2*s**(-2)*t1**(-1) + 512*ms1**2* + s**(-2)*u1**(-1)*s4*(s+t1)**(-1) + 768*ms1**2*s**(-2)* + s4**(-1) + 768*ms1**2*s**(-1)*t1**(-1)*u1**(-1) - 512*ms1**2* + s**(-1)*t1**(-1)*s4**(-1) - 512*ms1**4*s**(-3)*u1**(-1) - 512 + *ms1**4*s**(-3)*s4**(-1) + 512*ms1**4*s**(-2)*t1**(-1)* + u1**(-1) + 1024*ms1**4*s**(-2)*t1**(-1)*s4**(-1) + 512*ms1**4 + *s**(-2)*u1**(-2)*s4*(s+t1)**(-1) + 1024*ms1**4*s**(-2)* + u1**(-2) + 1536*ms1**4*s**(-2)*u1**(-1)*s4**(-1) + 512*ms1**4 + *s**(-1)*t1**(-1)*u1**(-1)*s4**(-1) + 1024*ms1**6*s**(-2)* + t1**(-1)*u1**(-1)*s4**(-1) + 2048*ms1**6*s**(-2)*u1**(-2)* + s4**(-1) - 256*s**(-2)*t1**(-1)*u1 - 256*s**(-2)*t1*s4**(-1) + + 256*s**(-2)*s4*(s+t1)**(-1) + 128*s**(-1)*u1**(-1) - 256* + s**(-1)*s4**(-1) + 128*t1**(-1)*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(41)*Cqed*Pi**4*alphas**3 * ( -1536*ms1**2* + s**(-2)*t1**(-1) - 768*ms1**2*s**(-2)*u1**(-1) + 256*ms1**2* + s**(-2)*s4**(-1) - 1024*ms1**2*s**(-1)*t1**(-1)*u1**(-1) + + 768*ms1**2*s**(-1)*t1**(-1)*s4**(-1) - 1024*ms1**4*s**(-2)* + t1**(-1)*u1**(-1) - 1536*ms1**4*s**(-2)*t1**(-1)*s4**(-1) - + 512*ms1**4*s**(-2)*u1**(-2) - 1024*ms1**4*s**(-2)*u1**(-1)* + s4**(-1) - 512*ms1**4*s**(-1)*t1**(-1)*u1**(-1)*s4**(-1) - + 1024*ms1**6*s**(-2)*t1**(-1)*u1**(-1)*s4**(-1) - 1024*ms1**6* + s**(-2)*u1**(-2)*s4**(-1) - 256*s**(-2)*t1**(-1)*u1 - 128* + s**(-2)*t1*u1**(-1) - 256*s**(-2) - 256*s**(-1)*t1**(-1) - + 384*s**(-1)*u1**(-1) - 128*s**(-1)*s4**(-1) - 256*t1**(-1)* + u1**(-1) - 128*t1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(43)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2) - 512*ms1**4*s**(-2)*t1**(-1) - 512*ms1**6*s**(-2)* + t1**(-2) ) LQ_GGH = LQ_GGH + ANG4(43)*Nc*Ck*Pi**4*alphas**3 * ( 768*ms1**2* + s**(-2) + 1536*ms1**4*s**(-2)*t1**(-1) + 1536*ms1**6*s**(-2)* + t1**(-2) ) LQ_GGH = LQ_GGH + ANG4(43)*Cqed*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2) - 512*ms1**4*s**(-2)*t1**(-1) - 512*ms1**6*s**(-2)* + t1**(-2) ) LQ_GGH = LQ_GGH + ANG4(44)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-2)*t1**(-1)*s4*(s+u1)**(-1) - 512*ms1**4*s**(-2)* + t1**(-2)*s4*(s+u1)**(-1) - 128*s**(-2)*t1**(-1)*u1 - 256* + s**(-2)*s4*(s+u1)**(-1) - 128*s**(-1)*t1**(-1) ) LQ_GGH = LQ_GGH + ANG4(44)*Nc*Ck*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*t1**(-1)*u1 - 256*ms1**2*s**(-3)*t1*s4**(-1) - 256* + ms1**2*s**(-3) + 512*ms1**2*s**(-2)*t1**(-1)*s4*(s+u1)**(-1) + + 512*ms1**2*s**(-2)*u1**(-1) + 512*ms1**2*s**(-2)*s4**(-1) + + 768*ms1**2*s**(-1)*t1**(-1)*u1**(-1) - 512*ms1**2*s**(-1)* + u1**(-1)*s4**(-1) - 512*ms1**4*s**(-3)*t1**(-1) - 512*ms1**4* + s**(-3)*s4**(-1) + 512*ms1**4*s**(-2)*t1**(-2)*s4* + (s+u1)**(-1) + 1024*ms1**4*s**(-2)*t1**(-2) + 512*ms1**4* + s**(-2)*t1**(-1)*u1**(-1) + 1536*ms1**4*s**(-2)*t1**(-1)* + s4**(-1) + 1024*ms1**4*s**(-2)*u1**(-1)*s4**(-1) + 512*ms1**4 + *s**(-1)*t1**(-1)*u1**(-1)*s4**(-1) + 2048*ms1**6*s**(-2)* + t1**(-2)*s4**(-1) + 1024*ms1**6*s**(-2)*t1**(-1)*u1**(-1)* + s4**(-1) - 256*s**(-2)*t1*u1**(-1) + 256*s**(-2)*t1*s4**(-1) + + 256*s**(-2)*s4*(s+u1)**(-1) - 256*s**(-2) + 128*s**(-1)* + t1**(-1) + 128*t1**(-1)*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(44)*Cqed*Pi**4*alphas**3 * ( -768*ms1**2* + s**(-2)*t1**(-1) - 1536*ms1**2*s**(-2)*u1**(-1) + 256*ms1**2* + s**(-2)*s4**(-1) - 1024*ms1**2*s**(-1)*t1**(-1)*u1**(-1) + + 768*ms1**2*s**(-1)*u1**(-1)*s4**(-1) - 512*ms1**4*s**(-2)* + t1**(-2) - 1024*ms1**4*s**(-2)*t1**(-1)*u1**(-1) - 1024* + ms1**4*s**(-2)*t1**(-1)*s4**(-1) - 1536*ms1**4*s**(-2)* + u1**(-1)*s4**(-1) - 512*ms1**4*s**(-1)*t1**(-1)*u1**(-1)* + s4**(-1) - 1024*ms1**6*s**(-2)*t1**(-2)*s4**(-1) - 1024* + ms1**6*s**(-2)*t1**(-1)*u1**(-1)*s4**(-1) - 128*s**(-2)* + t1**(-1)*u1 - 256*s**(-2)*t1*u1**(-1) - 256*s**(-2) - 384* + s**(-1)*t1**(-1) - 256*s**(-1)*u1**(-1) - 128*s**(-1)* + s4**(-1) - 256*t1**(-1)*u1**(-1) - 128*u1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(48)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2)*t1**(-1)*u1 - 256*ms1**2*s**(-2)*t1*u1**(-1) - 256* + ms1**2*s**(-2)*s4*(s+t1)**(-1) - 256*ms1**2*s**(-2)*s4* + (s+u1)**(-1) + 512*ms1**2*s**(-2) - 256*ms1**2*s**(-1)* + t1**(-1)*s4*(s+u1)**(-1) + 256*ms1**2*s**(-1)*t1**(-1) - 256* + ms1**2*s**(-1)*u1**(-1)*s4*(s+t1)**(-1) + 256*ms1**2*s**(-1)* + u1**(-1) - 512*ms1**4*s**(-1)*t1**(-2)*s4*(s+u1)**(-1) + 512* + ms1**4*s**(-1)*t1**(-2) - 512*ms1**4*s**(-1)*u1**(-2)*s4* + (s+t1)**(-1) + 512*ms1**4*s**(-1)*u1**(-2) - 512*s**(-3)* + t1**(-1)*u1**3 - 1536*s**(-3)*t1*u1 - 1024*s**(-3)*t1**2 - + 512*s**(-3)*t1**3*u1**(-1) - 1024*s**(-3)*u1**2 + 256*s**(-2) + *t1**(-1)*u1**2*s4*(s+t1)**(-1) - 768*s**(-2)*t1**(-1)*u1**2 + - 256*s**(-2)*t1*s4*(s+u1)**(-1) - 1536*s**(-2)*t1 + 256* + s**(-2)*t1**2*u1**(-1)*s4*(s+u1)**(-1) - 768*s**(-2)*t1**2* + u1**(-1) - 256*s**(-2)*u1*s4*(s+t1)**(-1) - 1536*s**(-2)*u1 + - 384*s**(-1)*t1**(-1)*u1 ) LQ_GGH = LQ_GGH + ANG4(48)*Nc*Co*Pi**4*alphas**3 * ( -384*s**(-1) + *t1*u1**(-1) - 128*s**(-1)*s4*(s+t1)**(-1) - 128*s**(-1)*s4* + (s+u1)**(-1) - 768*s**(-1) - 128*t1**(-1) - 128*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(49)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*u1 - 256*ms1**2*s**(-2)*t1*(t1+u1)**(-1) - 256*ms1**2 + *s**(-1)*(t1+u1)**(-1) - 512*ms1**4*s**(-3)*t1**(-1)*u1 - 512 + *ms1**4*s**(-3) - 512*ms1**4*s**(-2)*t1**(-1) - 512*ms1**4* + s**(-1)*t1**(-1)*u1**(-1) + 512*ms1**4*s**(-1)*u1**(-1)* + (t1+u1)**(-1) - 128*s**(-3)*t1*u1 + 128*s**(-3)*t1**2 - 256* + s**(-3)*t1**3*(t1+u1)**(-1) - 256*s**(-2)*t1**2*(t1+u1)**(-1) + - 128*s**(-1)*t1*(t1+u1)**(-1) ) LQ_GGH = LQ_GGH + ANG4(49)*Nc*Ck*Pi**4*alphas**3 * ( 256*ms1**2* + s**(-2)*s4*(s+t1)**(-1) - 256*ms1**2*s**(-1)*u1**(-1)*s4* + (s+t1)**(-1) + 512*ms1**2*s**(-1)*u1**(-1) + 512*ms1**4* + s**(-2)*t1**(-1)*s4*(s+t1)**(-1) + 512*ms1**4*s**(-2)* + u1**(-1)*s4*(s+t1)**(-1) + 512*ms1**4*s**(-1)*t1**(-1)* + u1**(-1) - 512*ms1**4*s**(-1)*u1**(-2)*s4*(s+t1)**(-1) + 512* + ms1**4*s**(-1)*u1**(-2) + 128*s**(-2)*t1**2*u1**(-1) + 128* + s**(-2)*u1 + 128*s**(-1)*t1*u1**(-1) - 128*s**(-1)*s4* + (s+t1)**(-1) + 128*s**(-1) ) LQ_GGH = LQ_GGH + ANG4(50)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*t1 + 256*ms1**2*s**(-2)*t1*(t1+u1)**(-1) - 256*ms1**2 + *s**(-2) - 256*ms1**2*s**(-1)*(t1+u1)**(-1) - 512*ms1**4* + s**(-3)*t1*u1**(-1) - 512*ms1**4*s**(-3) - 512*ms1**4*s**(-2) + *u1**(-1) - 512*ms1**4*s**(-1)*u1**(-1)*(t1+u1)**(-1) + 128* + s**(-3)*t1*u1 - 256*s**(-3)*t1**2 + 256*s**(-3)*t1**3* + (t1+u1)**(-1) - 128*s**(-3)*u1**2 + 256*s**(-2)*t1 - 256* + s**(-2)*t1**2*(t1+u1)**(-1) - 256*s**(-2)*u1 + 128*s**(-1)*t1 + *(t1+u1)**(-1) - 128*s**(-1) ) LQ_GGH = LQ_GGH + ANG4(50)*Nc*Ck*Pi**4*alphas**3 * ( 256*ms1**2* + s**(-2)*s4*(s+u1)**(-1) - 256*ms1**2*s**(-1)*t1**(-1)*s4* + (s+u1)**(-1) + 512*ms1**2*s**(-1)*t1**(-1) + 512*ms1**4* + s**(-2)*t1**(-1)*s4*(s+u1)**(-1) + 512*ms1**4*s**(-2)* + u1**(-1)*s4*(s+u1)**(-1) - 512*ms1**4*s**(-1)*t1**(-2)*s4* + (s+u1)**(-1) + 512*ms1**4*s**(-1)*t1**(-2) + 512*ms1**4* + s**(-1)*t1**(-1)*u1**(-1) + 128*s**(-2)*t1**(-1)*u1**2 + 128* + s**(-2)*t1 + 128*s**(-1)*t1**(-1)*u1 - 128*s**(-1)*s4* + (s+u1)**(-1) + 128*s**(-1) ) LQ_GGH = LQ_GGH + ANG4(51)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + ) LQ_GGH = LQ_GGH + ANG4(52)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + *s**(-1) ) LQ_GGH = LQ_GGH + ANG4(53)*Nc*Co*Pi**4*alphas**3 * ( -2048*ms1**2 + *s**(-1)*t1*u1**(-1) - 1024*ms1**2*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(54)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2)*t1**(-1)*u1 - 1024*ms1**2*s**(-2)*t1*u1**(-1) - 256* + ms1**2*s**(-2)*t1*s4**(-1) - 256*ms1**2*s**(-2)*t1* + (t1+u1)**(-1) - 256*ms1**2*s**(-2)*s4*(s+t1)**(-1) - 2304* + ms1**2*s**(-2) - 256*ms1**2*s**(-1)*t1**(-1) - 1024*ms1**2* + s**(-1)*t1*u1**(-2) + 256*ms1**2*s**(-1)*u1**(-1)*s4* + (s+t1)**(-1) - 1792*ms1**2*s**(-1)*u1**(-1) - 256*ms1**2* + s**(-1)*(t1+u1)**(-1) + 512*ms1**4*s**(-1)*t1**(-1)*u1**(-1) + + 512*ms1**4*s**(-1)*u1**(-2)*s4*(s+t1)**(-1) - 512*ms1**4* + s**(-1)*u1**(-2) + 512*ms1**4*s**(-1)*u1**(-1)*s4**(-1) + 512 + *ms1**4*s**(-1)*u1**(-1)*(t1+u1)**(-1) + 512*s**(-3)*t1**(-1) + *u1**3 + 2048*s**(-3)*t1*u1 + 2048*s**(-3)*t1**2 + 1024* + s**(-3)*t1**3*u1**(-1) - 256*s**(-3)*t1**3*s4**(-1) - 256* + s**(-3)*t1**3*(t1+u1)**(-1) + 1536*s**(-3)*u1**2 - 256* + s**(-2)*t1**(-1)*u1**2*s4*(s+t1)**(-1) + 512*s**(-2)*t1**(-1) + *u1**2 ) LQ_GGH = LQ_GGH + ANG4(54)*Nc*Co*Pi**4*alphas**3 * (2048*s**(-2)* + t1 + 1536*s**(-2)*t1**2*u1**(-1) - 512*s**(-2)*t1**2*s4**(-1) + - 256*s**(-2)*t1**2*(t1+u1)**(-1) - 256*s**(-2)*u1*s4* + (s+t1)**(-1) + 1280*s**(-2)*u1 + 128*s**(-1)*t1**(-1)*u1 + + 512*s**(-1)*t1*u1**(-1) - 384*s**(-1)*t1*s4**(-1) - 128* + s**(-1)*t1*(t1+u1)**(-1) + 128*s**(-1)*s4*(s+t1)**(-1) + 384* + s**(-1) - 128*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(55)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + ) LQ_GGH = LQ_GGH + ANG4(56)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + *s**(-1) ) LQ_GGH = LQ_GGH + ANG4(57)*Nc*Co*Pi**4*alphas**3 * ( -2048*ms1**2 + *s**(-1)*t1**(-1)*u1 - 1024*ms1**2*t1**(-1) ) LQ_GGH = LQ_GGH + ANG4(58)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + *s**(-2)*t1**(-1)*u1 - 256*ms1**2*s**(-2)*t1*u1**(-1) + 256* + ms1**2*s**(-2)*t1*s4**(-1) + 256*ms1**2*s**(-2)*t1* + (t1+u1)**(-1) - 256*ms1**2*s**(-2)*s4*(s+u1)**(-1) - 2816* + ms1**2*s**(-2) - 1024*ms1**2*s**(-1)*t1**(-2)*u1 + 256*ms1**2 + *s**(-1)*t1**(-1)*s4*(s+u1)**(-1) - 1792*ms1**2*s**(-1)* + t1**(-1) - 256*ms1**2*s**(-1)*u1**(-1) + 256*ms1**2*s**(-1)* + s4**(-1) - 256*ms1**2*s**(-1)*(t1+u1)**(-1) + 512*ms1**4* + s**(-1)*t1**(-2)*s4*(s+u1)**(-1) - 512*ms1**4*s**(-1)* + t1**(-2) + 1024*ms1**4*s**(-1)*t1**(-1)*u1**(-1) + 512*ms1**4 + *s**(-1)*t1**(-1)*s4**(-1) - 512*ms1**4*s**(-1)*u1**(-1)* + (t1+u1)**(-1) + 1024*s**(-3)*t1**(-1)*u1**3 + 2560*s**(-3)*t1 + *u1 + 1024*s**(-3)*t1**2 + 512*s**(-3)*t1**3*u1**(-1) + 256* + s**(-3)*t1**3*s4**(-1) + 256*s**(-3)*t1**3*(t1+u1)**(-1) + + 1536*s**(-3)*u1**2 + 1536*s**(-2)*t1**(-1)*u1**2 - 256* + s**(-2)*t1*s4*(s+u1)**(-1) ) LQ_GGH = LQ_GGH + ANG4(58)*Nc*Co*Pi**4*alphas**3 * (1536*s**(-2)* + t1 - 256*s**(-2)*t1**2*u1**(-1)*s4*(s+u1)**(-1) + 512*s**(-2) + *t1**2*u1**(-1) + 256*s**(-2)*t1**2*s4**(-1) - 256*s**(-2)* + t1**2*(t1+u1)**(-1) + 1536*s**(-2)*u1 + 512*s**(-1)*t1**(-1)* + u1 + 128*s**(-1)*t1*u1**(-1) + 128*s**(-1)*t1*s4**(-1) + 128* + s**(-1)*t1*(t1+u1)**(-1) + 128*s**(-1)*s4*(s+u1)**(-1) + 128* + s**(-1) ) LQ_GGH = LQ_GGH + ANG4(59)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-2)*t1**2 ) LQ_GGH = LQ_GGH + ANG4(59)*Nc*Ck*Pi**4*alphas**3 * ( 512*ms1**2* + s**(-2)*t1**2 ) LQ_GGH = LQ_GGH + ANG4(60)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-2)*t1 - 1024*ms1**4*s**(-2) ) LQ_GGH = LQ_GGH + ANG4(60)*Nc*Ck*Pi**4*alphas**3 * ( 512*ms1**2* + s**(-2)*t1 + 1024*ms1**4*s**(-2) ) LQ_GGH = LQ_GGH + ANG4(61)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + *s**(-1)*t1*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(61)*Nc*Ck*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-2)*t1**2*u1**(-1) + 1024*ms1**2*s**(-1)*t1*u1**(-1) ) LQ_GGH = LQ_GGH + ANG4(62)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*t1 - 256*ms1**2*s**(-3)*u1 - 512*ms1**2*s**(-2)*t1* + u1**(-1) - 256*ms1**2*s**(-2)*s4*(s+u1)**(-1) - 1024*ms1**2* + s**(-2) - 256*ms1**2*s**(-1)*t1**(-1)*s4*(s+u1)**(-1) + 256* + ms1**2*s**(-1)*t1**(-1) - 1024*ms1**2*s**(-1)*t1*u1**(-2) - + 512*ms1**2*s**(-1)*u1**(-1) + 512*ms1**4*s**(-3)*t1**(-1)*u1 + + 1024*ms1**4*s**(-2)*t1**(-1) - 512*ms1**4*s**(-1)*t1**(-2) + *s4*(s+u1)**(-1) + 512*ms1**4*s**(-1)*t1**(-2) + 1024*ms1**4* + s**(-1)*t1**(-1)*u1**(-1) + 128*s**(-3)*t1*u1 + 256*s**(-3)* + t1**2 + 256*s**(-3)*t1**3*u1**(-1) - 256*s**(-2)*t1*s4* + (s+u1)**(-1) + 640*s**(-2)*t1 + 256*s**(-2)*t1**2*u1**(-1)*s4 + *(s+u1)**(-1) + 768*s**(-2)*t1**2*u1**(-1) + 512*s**(-1)*t1* + u1**(-1) - 128*s**(-1)*s4*(s+u1)**(-1) + 128*s**(-1) ) LQ_GGH = LQ_GGH + ANG4(62)*Nc*Ck*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-2)*t1*u1**(-1) + 256*ms1**2*s**(-2)*s4*(s+t1)**(-1) + + 768*ms1**2*s**(-2) + 256*ms1**2*s**(-1)*u1**(-1)*s4* + (s+t1)**(-1) + 256*ms1**2*s**(-1)*u1**(-1) + 256*ms1**2* + s**(-1)*s4**(-1) - 512*ms1**4*s**(-2)*t1**(-1)*s4* + (s+t1)**(-1) - 512*ms1**4*s**(-2)*t1**(-1) + 512*ms1**4* + s**(-2)*u1**(-1)*s4*(s+t1)**(-1) + 1536*ms1**4*s**(-2)* + u1**(-1) + 512*ms1**4*s**(-2)*s4**(-1) - 1024*ms1**4*s**(-1)* + t1**(-1)*u1**(-1) + 512*ms1**4*s**(-1)*t1**(-1)*s4**(-1) + + 512*ms1**4*s**(-1)*u1**(-2)*s4*(s+t1)**(-1) - 512*ms1**4* + s**(-1)*u1**(-2) + 512*ms1**4*s**(-1)*u1**(-1)*s4**(-1) - 384 + *s**(-2)*t1 - 512*s**(-2)*t1**2*u1**(-1) + 128*s**(-2)*t1**2* + s4**(-1) - 128*s**(-2)*u1 - 512*s**(-1)*t1*u1**(-1) + 128* + s**(-1)*t1*s4**(-1) + 128*s**(-1)*s4*(s+t1)**(-1) - 128* + s**(-1) ) LQ_GGH = LQ_GGH + ANG4(63)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*u1**(-1) - 256*ms1**2*s**(-3)*s4**(-1) - 512*ms1**4* + s**(-3)*u1**(-1)*s4**(-1) - 128*s**(-3)*t1*u1**(-1) + 128* + s**(-3)*t1*s4**(-1) - 256*s**(-3) - 128*s**(-2)*u1**(-1) + + 128*s**(-2)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(63)*Nc*Ck*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2)*t1**(-1)*u1**(-1) - 256*ms1**2*s**(-2)*t1**(-1)* + s4**(-1) - 512*ms1**4*s**(-2)*t1**(-1)*u1**(-1)*s4**(-1) - + 256*s**(-2)*t1**(-1) - 128*s**(-2)*u1**(-1) + 128*s**(-2)* + s4**(-1) - 128*s**(-1)*t1**(-1)*u1**(-1) + 128*s**(-1)* + t1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(64)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-2)*u1**2 ) LQ_GGH = LQ_GGH + ANG4(64)*Nc*Ck*Pi**4*alphas**3 * ( 512*ms1**2* + s**(-2)*u1**2 ) LQ_GGH = LQ_GGH + ANG4(65)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-2)*u1 - 1024*ms1**4*s**(-2) ) LQ_GGH = LQ_GGH + ANG4(65)*Nc*Ck*Pi**4*alphas**3 * ( 512*ms1**2* + s**(-2)*u1 + 1024*ms1**4*s**(-2) ) LQ_GGH = LQ_GGH + ANG4(66)*Nc*Co*Pi**4*alphas**3 * ( -1024*ms1**2 + *s**(-1)*t1**(-1)*u1 ) LQ_GGH = LQ_GGH + ANG4(66)*Nc*Ck*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-2)*t1**(-1)*u1**2 + 1024*ms1**2*s**(-1)*t1**(-1)*u1 ) LQ_GGH = LQ_GGH + ANG4(67)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*t1 - 256*ms1**2*s**(-3)*u1 - 512*ms1**2*s**(-2)* + t1**(-1)*u1 - 256*ms1**2*s**(-2)*s4*(s+t1)**(-1) - 1024* + ms1**2*s**(-2) - 1024*ms1**2*s**(-1)*t1**(-2)*u1 - 512*ms1**2 + *s**(-1)*t1**(-1) - 256*ms1**2*s**(-1)*u1**(-1)*s4* + (s+t1)**(-1) + 256*ms1**2*s**(-1)*u1**(-1) + 512*ms1**4* + s**(-3)*t1*u1**(-1) + 1024*ms1**4*s**(-2)*u1**(-1) + 1024* + ms1**4*s**(-1)*t1**(-1)*u1**(-1) - 512*ms1**4*s**(-1)* + u1**(-2)*s4*(s+t1)**(-1) + 512*ms1**4*s**(-1)*u1**(-2) + 256* + s**(-3)*t1**(-1)*u1**3 + 128*s**(-3)*t1*u1 + 256*s**(-3)* + u1**2 + 256*s**(-2)*t1**(-1)*u1**2*s4*(s+t1)**(-1) + 768* + s**(-2)*t1**(-1)*u1**2 - 256*s**(-2)*u1*s4*(s+t1)**(-1) + 640 + *s**(-2)*u1 + 512*s**(-1)*t1**(-1)*u1 - 128*s**(-1)*s4* + (s+t1)**(-1) + 128*s**(-1) ) LQ_GGH = LQ_GGH + ANG4(67)*Nc*Ck*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-2)*t1**(-1)*u1 + 256*ms1**2*s**(-2)*s4*(s+u1)**(-1) + + 768*ms1**2*s**(-2) + 256*ms1**2*s**(-1)*t1**(-1)*s4* + (s+u1)**(-1) + 256*ms1**2*s**(-1)*t1**(-1) + 256*ms1**2* + s**(-1)*s4**(-1) + 512*ms1**4*s**(-2)*t1**(-1)*s4* + (s+u1)**(-1) + 1536*ms1**4*s**(-2)*t1**(-1) - 512*ms1**4* + s**(-2)*u1**(-1)*s4*(s+u1)**(-1) - 512*ms1**4*s**(-2)* + u1**(-1) + 512*ms1**4*s**(-2)*s4**(-1) + 512*ms1**4*s**(-1)* + t1**(-2)*s4*(s+u1)**(-1) - 512*ms1**4*s**(-1)*t1**(-2) - 1024 + *ms1**4*s**(-1)*t1**(-1)*u1**(-1) + 512*ms1**4*s**(-1)* + t1**(-1)*s4**(-1) + 512*ms1**4*s**(-1)*u1**(-1)*s4**(-1) - + 512*s**(-2)*t1**(-1)*u1**2 - 256*s**(-2)*t1 + 128*s**(-2)* + t1**2*s4**(-1) - 256*s**(-2)*u1 - 512*s**(-1)*t1**(-1)*u1 + + 128*s**(-1)*t1*s4**(-1) + 128*s**(-1)*s4*(s+u1)**(-1) - 128* + s**(-1) ) LQ_GGH = LQ_GGH + ANG4(68)*Nc*Co*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-3)*t1**(-1) - 256*ms1**2*s**(-3)*s4**(-1) - 512*ms1**4* + s**(-3)*t1**(-1)*s4**(-1) - 128*s**(-3)*t1**(-1)*u1 - 128* + s**(-3)*t1*s4**(-1) - 128*s**(-3) - 128*s**(-2)*t1**(-1) ) LQ_GGH = LQ_GGH + ANG4(68)*Nc*Ck*Pi**4*alphas**3 * ( -256*ms1**2* + s**(-2)*t1**(-1)*u1**(-1) - 256*ms1**2*s**(-2)*u1**(-1)* + s4**(-1) - 512*ms1**4*s**(-2)*t1**(-1)*u1**(-1)*s4**(-1) - + 128*s**(-2)*t1**(-1) - 256*s**(-2)*u1**(-1) + 128*s**(-2)* + s4**(-1) - 128*s**(-1)*t1**(-1)*u1**(-1) + 128*s**(-1)* + u1**(-1)*s4**(-1) ) LQ_GGH = LQ_GGH + ANG4(70)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-2)*t1**2*u1**(-2) - 1024*ms1**2*s**(-1)*t1*u1**(-2) - + 512*ms1**2*u1**(-2) ) LQ_GGH = LQ_GGH + ANG4(70)*Nc*Ck*Pi**4*alphas**3 * ( 512*ms1**2* + s**(-2)*t1**2*u1**(-2) + 1024*ms1**2*s**(-1)*t1*u1**(-2) + + 512*ms1**2*u1**(-2) ) LQ_GGH = LQ_GGH + ANG4(71)*Nc*Co*Pi**4*alphas**3 * ( -512*ms1**2* + s**(-2)*t1**(-2)*u1**2 - 1024*ms1**2*s**(-1)*t1**(-2)*u1 - + 512*ms1**2*t1**(-2) ) LQ_GGH = LQ_GGH + ANG4(71)*Nc*Ck*Pi**4*alphas**3 * ( 512*ms1**2* + s**(-2)*t1**(-2)*u1**2 + 1024*ms1**2*s**(-1)*t1**(-2)*u1 + + 512*ms1**2*t1**(-2) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( 2048*ms1**2* + s**(-4)*t1**(-2)*u1**2 - 4096*ms1**2*s**(-4)*t1*s4**(-1) + + 2048*ms1**2*s**(-4)*t1**2*u1**(-2) + 4096*ms1**2*s**(-4)* + t1**2*s4**(-2) + 6144*ms1**2*s**(-4) - 4096*ms1**2*s**(-3)* + t1**(-3)*u1**2 - 2048*ms1**2*s**(-3)*t1**(-2)*u1 - 14336* + ms1**2*s**(-3)*t1**(-1) - 2048*ms1**2*s**(-3)*t1*u1**(-2) + + 4096*ms1**2*s**(-3)*t1*s4**(-2) - 4096*ms1**2*s**(-3)*t1**2* + u1**(-3) - 14336*ms1**2*s**(-3)*u1**(-1) + 6144*ms1**2* + s**(-3)*s4**(-1) - 8192*ms1**2*s**(-2)*t1**(-3)*u1 - 4096* + ms1**2*s**(-2)*t1**(-2)*s4*(s+u1)**(-1) + 1024*ms1**2*s**(-2) + *t1**(-2)*s4**2*(s+u1)**(-2) + 6144*ms1**2*s**(-2)*t1**(-1)* + u1**(-1)*s4*(s+t1)**(-1) + 6144*ms1**2*s**(-2)*t1**(-1)* + u1**(-1)*s4*(s+u1)**(-1) - 16384*ms1**2*s**(-2)*t1**(-1)* + u1**(-1) + 8192*ms1**2*s**(-2)*t1**(-1)*s4**(-1) - 8192* + ms1**2*s**(-2)*t1*u1**(-3) - 4096*ms1**2*s**(-2)*u1**(-2)*s4* + (s+t1)**(-1) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( 1024*ms1**2* + s**(-2)*u1**(-2)*s4**2*(s+t1)**(-2) + 8192*ms1**2*s**(-2)* + u1**(-1)*s4**(-1) + 2048*ms1**2*s**(-2)*s4**(-2) - 6144* + ms1**2*s**(-1)*t1**(-3) - 2048*ms1**2*s**(-1)*t1**(-2)* + u1**(-1)*s4**2*(s+u1)**(-2) - 2048*ms1**2*s**(-1)*t1**(-1)* + u1**(-2)*s4**2*(s+t1)**(-2) + 4096*ms1**2*s**(-1)*t1**(-1)* + u1**(-1)*s4**(-1) - 6144*ms1**2*s**(-1)*u1**(-3) - 2048* + ms1**2*t1**(-3)*u1**(-1) - 2048*ms1**2*t1**(-1)*u1**(-3) - + 4096*ms1**4*s**(-3)*t1**(-3)*u1 - 12288*ms1**4*s**(-3)* + t1**(-1)*s4**(-1) - 4096*ms1**4*s**(-3)*t1*u1**(-3) - 12288* + ms1**4*s**(-3)*u1**(-1)*s4**(-1) + 8192*ms1**4*s**(-3)* + s4**(-2) + 4096*ms1**4*s**(-2)*t1**(-4)*u1 + 2048*ms1**4* + s**(-2)*t1**(-3)*s4*(s+u1)**(-1) - 2048*ms1**4*s**(-2)* + t1**(-3) + 8192*ms1**4*s**(-2)*t1**(-2)*u1**(-1)*s4* + (s+u1)**(-1) - 4096*ms1**4*s**(-2)*t1**(-2)*u1**(-1) + 2048* + ms1**4*s**(-2)*t1**(-2)*s4**(-1) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( 8192*ms1**4* + s**(-2)*t1**(-1)*u1**(-2)*s4*(s+t1)**(-1) - 4096*ms1**4* + s**(-2)*t1**(-1)*u1**(-2) - 16384*ms1**4*s**(-2)*t1**(-1)* + u1**(-1)*s4**(-1) + 4096*ms1**4*s**(-2)*t1**(-1)*s4**(-2) + + 4096*ms1**4*s**(-2)*t1*u1**(-4) + 2048*ms1**4*s**(-2)* + u1**(-3)*s4*(s+t1)**(-1) - 2048*ms1**4*s**(-2)*u1**(-3) + + 2048*ms1**4*s**(-2)*u1**(-2)*s4**(-1) + 4096*ms1**4*s**(-2)* + u1**(-1)*s4**(-2) + 8192*ms1**4*s**(-1)*t1**(-4) + 6144* + ms1**4*s**(-1)*t1**(-3)*u1**(-1)*s4*(s+u1)**(-1) - 2048* + ms1**4*s**(-1)*t1**(-3)*u1**(-1)*s4**2*(s+u1)**(-2) - 2048* + ms1**4*s**(-1)*t1**(-3)*u1**(-1) + 4096*ms1**4*s**(-1)* + t1**(-2)*u1**(-2) - 2048*ms1**4*s**(-1)*t1**(-2)*u1**(-1)* + s4**(-1) + 6144*ms1**4*s**(-1)*t1**(-1)*u1**(-3)*s4* + (s+t1)**(-1) - 2048*ms1**4*s**(-1)*t1**(-1)*u1**(-3)*s4**2* + (s+t1)**(-2) - 2048*ms1**4*s**(-1)*t1**(-1)*u1**(-3) - 2048* + ms1**4*s**(-1)*t1**(-1)*u1**(-2)*s4**(-1) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( 8192*ms1**4* + s**(-1)*u1**(-4) + 2048*ms1**4*s*t1**(-4)*u1**(-2) + 2048* + ms1**4*s*t1**(-2)*u1**(-4) + 6144*ms1**4*t1**(-4)*u1**(-1) - + 2048*ms1**4*t1**(-3)*u1**(-2)*s4*(s+u1)**(-1) + 2048*ms1**4* + t1**(-3)*u1**(-2)*s4**2*(s+u1)**(-2) + 2048*ms1**4*t1**(-3)* + u1**(-2) - 2048*ms1**4*t1**(-2)*u1**(-3)*s4*(s+t1)**(-1) + + 2048*ms1**4*t1**(-2)*u1**(-3)*s4**2*(s+t1)**(-2) + 2048* + ms1**4*t1**(-2)*u1**(-3) + 6144*ms1**4*t1**(-1)*u1**(-4) - + 4096*ms1**6*s**(-2)*t1**(-4)*s4*(s+u1)**(-1) + 2048*ms1**6* + s**(-2)*t1**(-4)*s4**2*(s+u1)**(-2) + 6144*ms1**6*s**(-2)* + t1**(-4) + 4096*ms1**6*s**(-2)*t1**(-3)*u1**(-1)*s4* + (s+u1)**(-1) - 4096*ms1**6*s**(-2)*t1**(-3)*u1**(-1) + 4096* + ms1**6*s**(-2)*t1**(-2)*u1**(-2) - 8192*ms1**6*s**(-2)* + t1**(-2)*u1**(-1)*s4**(-1) + 4096*ms1**6*s**(-2)*t1**(-2)* + s4**(-2) + 4096*ms1**6*s**(-2)*t1**(-1)*u1**(-3)*s4* + (s+t1)**(-1) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Co*Pi**4*alphas**3 * ( -4096*ms1**6 + *s**(-2)*t1**(-1)*u1**(-3) - 8192*ms1**6*s**(-2)*t1**(-1)* + u1**(-2)*s4**(-1) - 4096*ms1**6*s**(-2)*u1**(-4)*s4* + (s+t1)**(-1) + 2048*ms1**6*s**(-2)*u1**(-4)*s4**2* + (s+t1)**(-2) + 6144*ms1**6*s**(-2)*u1**(-4) + 4096*ms1**6* + s**(-2)*u1**(-2)*s4**(-2) + 4096*ms1**6*s**(-1)*t1**(-4)* + u1**(-1) + 4096*ms1**6*s**(-1)*t1**(-3)*u1**(-2)*s4* + (s+u1)**(-1) - 4096*ms1**6*s**(-1)*t1**(-3)*u1**(-2) + 4096* + ms1**6*s**(-1)*t1**(-2)*u1**(-3)*s4*(s+t1)**(-1) - 4096* + ms1**6*s**(-1)*t1**(-2)*u1**(-3) - 4096*ms1**6*s**(-1)* + t1**(-2)*u1**(-2)*s4**(-1) + 4096*ms1**6*s**(-1)*t1**(-1)* + u1**(-4) + 2048*ms1**6*t1**(-4)*u1**(-2) + 2048*ms1**6* + t1**(-2)*u1**(-4) + 2048*s**(-4)*t1**(-2)*u1**3 + 2048* + s**(-4)*t1**(-1)*u1**2 + 2048*s**(-4)*t1 + 2048*s**(-4)*t1**2 + *u1**(-1) + 4096*s**(-4)*t1**2*s4**(-1) + 2048*s**(-4)*t1**3* + u1**(-2) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Co*Pi**4*alphas**3 * (6144*s**(-4)* + u1 + 4096*s**(-3)*t1**(-2)*u1**2 + 4096*s**(-3)*t1*s4**(-1) + + 4096*s**(-3)*t1**2*u1**(-2) + 3072*s**(-2)*t1**(-2)*u1 + + 2048*s**(-2)*t1**(-1)*s4*(s+t1)**(-1) - 1024*s**(-2)*t1**(-1) + *s4*(s+u1)**(-1) + 1024*s**(-2)*t1**(-1)*s4**2*(s+u1)**(-2) + - 1024*s**(-2)*t1**(-1) + 3072*s**(-2)*t1*u1**(-2) - 1024* + s**(-2)*u1**(-1)*s4*(s+t1)**(-1) + 2048*s**(-2)*u1**(-1)*s4* + (s+u1)**(-1) + 1024*s**(-2)*u1**(-1)*s4**2*(s+t1)**(-2) - + 1024*s**(-2)*u1**(-1) + 2048*s**(-2)*s4**(-1) + 1024*s**(-1)* + t1**(-2) + 1024*s**(-1)*u1**(-2) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Ck*Pi**4*alphas**3 * ( 2048*ms1**2* + s**(-2)*t1**(-2)*s4*(s+u1)**(-1) - 1024*ms1**2*s**(-2)* + t1**(-2)*s4**2*(s+u1)**(-2) - 2048*ms1**2*s**(-2)*t1**(-2) + + 4096*ms1**2*s**(-2)*t1**(-1)*u1**(-1) - 4096*ms1**2*s**(-2)* + t1**(-1)*s4**(-1) + 2048*ms1**2*s**(-2)*u1**(-2)*s4* + (s+t1)**(-1) - 1024*ms1**2*s**(-2)*u1**(-2)*s4**2* + (s+t1)**(-2) - 2048*ms1**2*s**(-2)*u1**(-2) - 4096*ms1**2* + s**(-2)*u1**(-1)*s4**(-1) - 2048*ms1**2*s**(-2)*s4**(-2) + + 2048*ms1**2*s**(-1)*t1**(-3) - 2048*ms1**2*s**(-1)*t1**(-2)* + u1**(-1)*s4*(s+u1)**(-1) + 2048*ms1**2*s**(-1)*t1**(-2)* + u1**(-1)*s4**2*(s+u1)**(-2) + 2048*ms1**2*s**(-1)*t1**(-2)* + u1**(-1) - 2048*ms1**2*s**(-1)*t1**(-1)*u1**(-2)*s4* + (s+t1)**(-1) + 2048*ms1**2*s**(-1)*t1**(-1)*u1**(-2)*s4**2* + (s+t1)**(-2) + 2048*ms1**2*s**(-1)*t1**(-1)*u1**(-2) + 2048* + ms1**2*s**(-1)*u1**(-3) + 2048*ms1**2*t1**(-3)*u1**(-1) + + 2048*ms1**2*t1**(-1)*u1**(-3) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Ck*Pi**4*alphas**3 * ( -2048*ms1**4 + *s**(-2)*t1**(-3)*s4*(s+u1)**(-1) + 2048*ms1**4*s**(-2)* + t1**(-3) + 4096*ms1**4*s**(-2)*t1**(-2)*u1**(-1) - 2048* + ms1**4*s**(-2)*t1**(-2)*s4**(-1) + 4096*ms1**4*s**(-2)* + t1**(-1)*u1**(-2) - 4096*ms1**4*s**(-2)*t1**(-1)*s4**(-2) - + 2048*ms1**4*s**(-2)*u1**(-3)*s4*(s+t1)**(-1) + 2048*ms1**4* + s**(-2)*u1**(-3) - 2048*ms1**4*s**(-2)*u1**(-2)*s4**(-1) - + 4096*ms1**4*s**(-2)*u1**(-1)*s4**(-2) - 6144*ms1**4*s**(-1)* + t1**(-3)*u1**(-1)*s4*(s+u1)**(-1) + 2048*ms1**4*s**(-1)* + t1**(-3)*u1**(-1)*s4**2*(s+u1)**(-2) + 6144*ms1**4*s**(-1)* + t1**(-3)*u1**(-1) - 4096*ms1**4*s**(-1)*t1**(-2)*u1**(-2) + + 2048*ms1**4*s**(-1)*t1**(-2)*u1**(-1)*s4**(-1) - 6144*ms1**4* + s**(-1)*t1**(-1)*u1**(-3)*s4*(s+t1)**(-1) + 2048*ms1**4* + s**(-1)*t1**(-1)*u1**(-3)*s4**2*(s+t1)**(-2) + 6144*ms1**4* + s**(-1)*t1**(-1)*u1**(-3) + 2048*ms1**4*s**(-1)*t1**(-1)* + u1**(-2)*s4**(-1) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Ck*Pi**4*alphas**3 * ( -2048*ms1**4 + *s*t1**(-4)*u1**(-2) - 2048*ms1**4*s*t1**(-2)*u1**(-4) - 2048 + *ms1**4*t1**(-4)*u1**(-1) + 2048*ms1**4*t1**(-3)*u1**(-2)*s4* + (s+u1)**(-1) - 2048*ms1**4*t1**(-3)*u1**(-2)*s4**2* + (s+u1)**(-2) - 2048*ms1**4*t1**(-3)*u1**(-2) + 2048*ms1**4* + t1**(-2)*u1**(-3)*s4*(s+t1)**(-1) - 2048*ms1**4*t1**(-2)* + u1**(-3)*s4**2*(s+t1)**(-2) - 2048*ms1**4*t1**(-2)*u1**(-3) + - 2048*ms1**4*t1**(-1)*u1**(-4) + 4096*ms1**6*s**(-2)* + t1**(-4)*s4*(s+u1)**(-1) - 2048*ms1**6*s**(-2)*t1**(-4)*s4**2 + *(s+u1)**(-2) - 2048*ms1**6*s**(-2)*t1**(-4) - 4096*ms1**6* + s**(-2)*t1**(-2)*u1**(-2) + 12288*ms1**6*s**(-2)*t1**(-2)* + u1**(-1)*s4**(-1) - 4096*ms1**6*s**(-2)*t1**(-2)*s4**(-2) + + 12288*ms1**6*s**(-2)*t1**(-1)*u1**(-2)*s4**(-1) - 8192*ms1**6 + *s**(-2)*t1**(-1)*u1**(-1)*s4**(-2) + 4096*ms1**6*s**(-2)* + u1**(-4)*s4*(s+t1)**(-1) - 2048*ms1**6*s**(-2)*u1**(-4)*s4**2 + *(s+t1)**(-2) ) LQ_GGH = LQ_GGH + COLO1(9)*Nc*Ck*Pi**4*alphas**3 * ( -2048*ms1**6 + *s**(-2)*u1**(-4) - 4096*ms1**6*s**(-2)*u1**(-2)*s4**(-2) - + 4096*ms1**6*s**(-1)*t1**(-3)*u1**(-2)*s4*(s+u1)**(-1) + 4096* + ms1**6*s**(-1)*t1**(-3)*u1**(-2) - 4096*ms1**6*s**(-1)* + t1**(-2)*u1**(-3)*s4*(s+t1)**(-1) + 4096*ms1**6*s**(-1)* + t1**(-2)*u1**(-3) + 4096*ms1**6*s**(-1)*t1**(-2)*u1**(-2)* + s4**(-1) - 2048*ms1**6*t1**(-4)*u1**(-2) - 2048*ms1**6* + t1**(-2)*u1**(-4) - 1024*s**(-2)*t1**(-2)*u1 + 1024*s**(-2)* + t1**(-1)*s4*(s+u1)**(-1) - 1024*s**(-2)*t1**(-1)*s4**2* + (s+u1)**(-2) - 1024*s**(-2)*t1**(-1) - 1024*s**(-2)*t1* + u1**(-2) + 1024*s**(-2)*u1**(-1)*s4*(s+t1)**(-1) - 1024* + s**(-2)*u1**(-1)*s4**2*(s+t1)**(-2) - 1024*s**(-2)*u1**(-1) + - 2048*s**(-2)*s4**(-1) - 1024*s**(-1)*t1**(-2) - 1024* + s**(-1)*u1**(-2) ) LQ_GGH = fac * LQ_GGH end
apache-2.0
jwakely/gcc
gcc/testsuite/gfortran.dg/deferred_character_27.f90
16
2402
! { dg-do compile } ! ! Make sure that PR82617 remains fixed. The first attempt at a ! fix for PR70752 cause this to ICE at the point indicated below. ! ! Contributed by Ogmundur Petersson <uberprugelknabe@hotmail.com> ! MODULE test IMPLICIT NONE PRIVATE PUBLIC str_words !> Characters that are considered whitespace. CHARACTER(len=*), PARAMETER :: strwhitespace = & char(32)//& ! space char(10)//& ! new line char(13)//& ! carriage return char( 9)//& ! horizontal tab char(11)//& ! vertical tab char(12) ! form feed (new page) CONTAINS ! ------------------------------------------------------------------- !> Split string into words separated by arbitrary strings of whitespace !> characters (space, tab, newline, return, formfeed). FUNCTION str_words(str,white) RESULT(items) CHARACTER(len=:), DIMENSION(:), ALLOCATABLE :: items CHARACTER(len=*), INTENT(in) :: str !< String to split. CHARACTER(len=*), INTENT(in) :: white ! Whitespace characters. items = strwords_impl(str,white) END FUNCTION str_words ! ------------------------------------------------------------------- !>Implementation of str_words !> characters (space, tab, newline, return, formfeed). FUNCTION strwords_impl(str,white) RESULT(items) CHARACTER(len=:), DIMENSION(:), ALLOCATABLE :: items CHARACTER(len=*), INTENT(in) :: str !< String to split. CHARACTER(len=*), INTENT(in) :: white ! Whitespace characters. INTEGER :: i0,i1,n INTEGER :: l_item,i_item,n_item n = verify(str,white,.TRUE.) IF (n>0) THEN n_item = 0 l_item = 0 i1 = 0 DO i0 = verify(str(i1+1:n),white)+i1 i1 = scan(str(i0+1:n),white) n_item = n_item+1 IF (i1>0) THEN l_item = max(l_item,i1) i1 = i0+i1 ELSE l_item = max(l_item,n-i0+1) EXIT END IF END DO ALLOCATE(CHARACTER(len=l_item)::items(n_item)) i_item = 0 i1 = 0 DO i0 = verify(str(i1+1:n),white)+i1 i1 = scan(str(i0+1:n),white) i_item = i_item+1 IF (i1>0) THEN i1 = i0+i1 items(i_item) = str(i0:i1-1) ELSE items(i_item) = str(i0:n) EXIT END IF END DO ELSE ALLOCATE(CHARACTER(len=0)::items(0)) END IF END FUNCTION strwords_impl END MODULE test
gpl-2.0
zhoupan71234/exciting-plus
utilities/spacegroup/gencrystal.f90
7
2901
subroutine gencrystal use modmain implicit none ! local variables integer is,ia,ip,i,j integer i1,i2,i3 integer id(3),ngen,ngrp real(8) abr,acr,bcr real(8) sab,cab,cac,cbc real(8) v1(3),v2(3) ! space group generator Seitz matrices real(8) srgen(3,3,12),stgen(3,12) ! space group Seitz matrices real(8) srgrp(3,3,192),stgrp(3,192) ! external functions real(8) r3taxi external r3taxi ! convert angles from degrees to radians abr=ab*(pi/180.d0) acr=ac*(pi/180.d0) bcr=bc*(pi/180.d0) ! setup lattice vectors sab=sin(abr) if (abs(sab).lt.epslat) then write(*,*) write(*,'("Error(gencrystal): degenerate lattice vectors")') write(*,*) stop end if cab=cos(abr) cac=cos(acr) cbc=cos(bcr) avec(1,1)=a avec(2,1)=0.d0 avec(3,1)=0.d0 avec(1,2)=b*cab avec(2,2)=b*sab avec(3,2)=0.d0 avec(1,3)=c*cac avec(2,3)=c*(cbc-cab*cac)/sab avec(3,3)=c*sqrt(sab**2-cac**2+2.d0*cab*cac*cbc-cbc**2)/sab do i=1,3 do j=1,3 if (abs(avec(i,j)).lt.epslat) avec(i,j)=0.d0 end do end do ! scale lattice vectors by the number of unit cells do i=1,3 avec(:,i)=avec(:,i)*dble(ncell(i)) end do ! determine the Hall symbol from the Hermann-Mauguin symbol call sgsymb(hrmg,num,schn,hall) ! determine the space group generators call seitzgen(hall,ngen,srgen,stgen) ! compute the space group operations call gengroup(ngen,srgen,stgen,ngrp,srgrp,stgrp) ! compute the equivalent atomic positions do is=1,nspecies natoms(is)=0 do ip=1,nwpos(is) do j=1,ngrp ! apply the space group operation call r3mv(srgrp(:,1,j),wpos(:,ip,is),v1) v1(:)=v1(:)+stgrp(:,j) do i1=0,ncell(1)-1 do i2=0,ncell(2)-1 do i3=0,ncell(3)-1 v2(1)=(v1(1)+dble(i1))/dble(ncell(1)) v2(2)=(v1(2)+dble(i2))/dble(ncell(2)) v2(3)=(v1(3)+dble(i3))/dble(ncell(3)) call r3frac(epslat,v2,id) ! check if new position already exists do ia=1,natoms(is) if (r3taxi(v2,atposl(:,ia,is)).lt.epslat) goto 30 end do ! add new position to list natoms(is)=natoms(is)+1 if (natoms(is).gt.maxatoms) then write(*,*) write(*,'("Error(gencrystal): natoms too large")') write(*,'(" for species ",I4)') is write(*,'("Adjust maxatoms and recompile code")') write(*,*) stop end if atposl(:,natoms(is),is)=v2(:) end do end do end do 30 continue end do end do natmtot=natmtot+natoms(is) end do ! set magnetic fields to zero bfcmt(:,:,:)=0.d0 ! reduce conventional cell to primitive cell if required if (primcell) call findprim ! find the total number of atoms natmtot=0 do is=1,nspecies natmtot=natmtot+natoms(is) end do ! determine the Cartesian atomic coordinates do is=1,nspecies do ia=1,natoms(is) call r3mv(avec,atposl(:,ia,is),atposc(:,ia,is)) end do end do return end subroutine
gpl-3.0
zhoupan71234/exciting-plus
src/rvfcross.f90
5
2354
! Copyright (C) 2007 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl. ! This file is distributed under the terms of the GNU General Public License. ! See the file COPYING for license details. !BOP ! !ROUTINE: rvfcross ! !INTERFACE: subroutine rvfcross(rvfmt1,rvfmt2,rvfir1,rvfir2,rvfmt3,rvfir3) ! !USES: use modmain ! !INPUT/OUTPUT PARAMETERS: ! rvfmt1 : first input muffin-tin field (in,real(lmmaxvr,nrmtmax,natmtot,3)) ! rvfmt2 : second input muffin-tin field (in,real(lmmaxvr,nrmtmax,natmtot,3)) ! rvfir1 : first input interstitial field (in,real(ngrtot,3)) ! rvfir2 : second input interstitial field (in,real(ngrtot,3)) ! rvfmt3 : output muffin-tin field (out,real(lmmaxvr,nrmtmax,natmtot,3)) ! rvfir3 : output interstitial field (out,real(ngrtot,3)) ! !DESCRIPTION: ! Given two real vector fields, ${\bf f}_1$ and ${\bf f}_2$, defined over the ! entire unit cell, this routine computes the local cross product ! $$ {\bf f}_3({\bf r})\equiv{\bf f}_1({\bf r})\times{\bf f}_2({\bf r}). $$ ! ! !REVISION HISTORY: ! Created February 2007 (JKD) !EOP !BOC implicit none ! arguments real(8), intent(in) :: rvfmt1(lmmaxvr,nrmtmax,natmtot,3) real(8), intent(in) :: rvfmt2(lmmaxvr,nrmtmax,natmtot,3) real(8), intent(in) :: rvfir1(ngrtot,3) real(8), intent(in) :: rvfir2(ngrtot,3) real(8), intent(out) :: rvfmt3(lmmaxvr,nrmtmax,natmtot,3) real(8), intent(out) :: rvfir3(ngrtot,3) ! local variables integer is,ia,ias,ir,itp,i real(8) v1(3),v2(3),v3(3) ! automatic arrays real(8) rftp1(lmmaxvr,3),rftp2(lmmaxvr,3) ! muffin-tin region do is=1,nspecies do ia=1,natoms(is) ias=idxas(ia,is) do ir=1,nrmt(is) do i=1,3 call dgemv('N',lmmaxvr,lmmaxvr,1.d0,rbshtvr,lmmaxvr, & rvfmt1(:,ir,ias,i),1,0.d0,rftp1(:,i),1) call dgemv('N',lmmaxvr,lmmaxvr,1.d0,rbshtvr,lmmaxvr, & rvfmt2(:,ir,ias,i),1,0.d0,rftp2(:,i),1) end do do itp=1,lmmaxvr v1(:)=rftp1(itp,:) v2(:)=rftp2(itp,:) call r3cross(v1,v2,v3) rftp1(itp,:)=v3(:) end do do i=1,3 call dgemv('N',lmmaxvr,lmmaxvr,1.d0,rfshtvr,lmmaxvr,rftp1(:,i),1,0.d0, & rvfmt3(:,ir,ias,i),1) end do end do end do end do ! interstitial region do ir=1,ngrtot v1(:)=rvfir1(ir,:) v2(:)=rvfir2(ir,:) call r3cross(v1,v2,v3) rvfir3(ir,:)=v3(:) end do return end subroutine !EOC
gpl-3.0
jwakely/gcc
gcc/testsuite/gfortran.dg/typebound_proc_35.f90
19
1900
! { dg-do run } ! ! PR 78443: [OOP] Incorrect behavior with non_overridable keyword ! ! Contributed by federico <perini@wisc.edu> module types implicit none ! Abstract parent class and its child type type, abstract :: P1 contains procedure :: test => test1 procedure (square_interface), deferred :: square endtype ! Deferred procedure interface abstract interface function square_interface( this, x ) result( y ) import P1 class(P1) :: this real :: x, y end function square_interface end interface type, extends(P1) :: C1 contains procedure, non_overridable :: square => C1_square endtype ! Non-abstract parent class and its child type type :: P2 contains procedure :: test => test2 procedure :: square => P2_square endtype type, extends(P2) :: C2 contains procedure, non_overridable :: square => C2_square endtype contains real function test1( this, x ) class(P1) :: this real :: x test1 = this % square( x ) end function real function test2( this, x ) class(P2) :: this real :: x test2 = this % square( x ) end function function P2_square( this, x ) result( y ) class(P2) :: this real :: x, y y = -100. ! dummy end function function C1_square( this, x ) result( y ) class(C1) :: this real :: x, y y = x**2 end function function C2_square( this, x ) result( y ) class(C2) :: this real :: x, y y = x**2 end function end module program main use types implicit none type(P2) :: t1 type(C2) :: t2 type(C1) :: t3 if ( t1 % test( 2. ) /= -100.) STOP 1 if ( t2 % test( 2. ) /= 4.) STOP 2 if ( t3 % test( 2. ) /= 4.) STOP 3 end program
gpl-2.0
wilseypa/llamaOS
src/tools/blas/strmv.f
6
8777
SUBROUTINE STRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX) * .. Scalar Arguments .. INTEGER INCX,LDA,N CHARACTER DIAG,TRANS,UPLO * .. * .. Array Arguments .. REAL A(LDA,*),X(*) * .. * * Purpose * ======= * * STRMV performs one of the matrix-vector operations * * x := A*x, or x := A**T*x, * * where x is an n element vector and A is an n by n unit, or non-unit, * upper or lower triangular matrix. * * Arguments * ========== * * UPLO - CHARACTER*1. * On entry, UPLO specifies whether the matrix 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. * * TRANS - CHARACTER*1. * On entry, TRANS specifies the operation to be performed as * follows: * * TRANS = 'N' or 'n' x := A*x. * * TRANS = 'T' or 't' x := A**T*x. * * TRANS = 'C' or 'c' x := A**T*x. * * 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. * * N - INTEGER. * On entry, N specifies the order of the matrix A. * N must be at least zero. * Unchanged on exit. * * A - REAL array of DIMENSION ( LDA, n ). * Before entry with UPLO = 'U' or 'u', the leading n by n * 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 n by n * 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. LDA must be at least * max( 1, n ). * Unchanged on exit. * * X - REAL array of dimension at least * ( 1 + ( n - 1 )*abs( INCX ) ). * Before entry, the incremented array X must contain the n * element vector x. On exit, X is overwritten with the * tranformed vector x. * * INCX - INTEGER. * On entry, INCX specifies the increment for the elements of * X. INCX must not be zero. * Unchanged on exit. * * Further Details * =============== * * Level 2 Blas routine. * The vector and matrix arguments are not referenced when N = 0, or M = 0 * * -- Written on 22-October-1986. * Jack Dongarra, Argonne National Lab. * Jeremy Du Croz, Nag Central Office. * Sven Hammarling, Nag Central Office. * Richard Hanson, Sandia National Labs. * * ===================================================================== * * .. Parameters .. REAL ZERO PARAMETER (ZERO=0.0E+0) * .. * .. Local Scalars .. REAL TEMP INTEGER I,INFO,IX,J,JX,KX LOGICAL NOUNIT * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX * .. * * Test the input parameters. * INFO = 0 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN INFO = 1 ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND. + .NOT.LSAME(TRANS,'C')) THEN INFO = 2 ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN INFO = 3 ELSE IF (N.LT.0) THEN INFO = 4 ELSE IF (LDA.LT.MAX(1,N)) THEN INFO = 6 ELSE IF (INCX.EQ.0) THEN INFO = 8 END IF IF (INFO.NE.0) THEN CALL XERBLA('STRMV ',INFO) RETURN END IF * * Quick return if possible. * IF (N.EQ.0) RETURN * NOUNIT = LSAME(DIAG,'N') * * Set up the start point in X if the increment is not unity. This * will be ( N - 1 )*INCX too small for descending loops. * IF (INCX.LE.0) THEN KX = 1 - (N-1)*INCX ELSE IF (INCX.NE.1) THEN KX = 1 END IF * * Start the operations. In this version the elements of A are * accessed sequentially with one pass through A. * IF (LSAME(TRANS,'N')) THEN * * Form x := A*x. * IF (LSAME(UPLO,'U')) THEN IF (INCX.EQ.1) THEN DO 20 J = 1,N IF (X(J).NE.ZERO) THEN TEMP = X(J) DO 10 I = 1,J - 1 X(I) = X(I) + TEMP*A(I,J) 10 CONTINUE IF (NOUNIT) X(J) = X(J)*A(J,J) END IF 20 CONTINUE ELSE JX = KX DO 40 J = 1,N IF (X(JX).NE.ZERO) THEN TEMP = X(JX) IX = KX DO 30 I = 1,J - 1 X(IX) = X(IX) + TEMP*A(I,J) IX = IX + INCX 30 CONTINUE IF (NOUNIT) X(JX) = X(JX)*A(J,J) END IF JX = JX + INCX 40 CONTINUE END IF ELSE IF (INCX.EQ.1) THEN DO 60 J = N,1,-1 IF (X(J).NE.ZERO) THEN TEMP = X(J) DO 50 I = N,J + 1,-1 X(I) = X(I) + TEMP*A(I,J) 50 CONTINUE IF (NOUNIT) X(J) = X(J)*A(J,J) END IF 60 CONTINUE ELSE KX = KX + (N-1)*INCX JX = KX DO 80 J = N,1,-1 IF (X(JX).NE.ZERO) THEN TEMP = X(JX) IX = KX DO 70 I = N,J + 1,-1 X(IX) = X(IX) + TEMP*A(I,J) IX = IX - INCX 70 CONTINUE IF (NOUNIT) X(JX) = X(JX)*A(J,J) END IF JX = JX - INCX 80 CONTINUE END IF END IF ELSE * * Form x := A**T*x. * IF (LSAME(UPLO,'U')) THEN IF (INCX.EQ.1) THEN DO 100 J = N,1,-1 TEMP = X(J) IF (NOUNIT) TEMP = TEMP*A(J,J) DO 90 I = J - 1,1,-1 TEMP = TEMP + A(I,J)*X(I) 90 CONTINUE X(J) = TEMP 100 CONTINUE ELSE JX = KX + (N-1)*INCX DO 120 J = N,1,-1 TEMP = X(JX) IX = JX IF (NOUNIT) TEMP = TEMP*A(J,J) DO 110 I = J - 1,1,-1 IX = IX - INCX TEMP = TEMP + A(I,J)*X(IX) 110 CONTINUE X(JX) = TEMP JX = JX - INCX 120 CONTINUE END IF ELSE IF (INCX.EQ.1) THEN DO 140 J = 1,N TEMP = X(J) IF (NOUNIT) TEMP = TEMP*A(J,J) DO 130 I = J + 1,N TEMP = TEMP + A(I,J)*X(I) 130 CONTINUE X(J) = TEMP 140 CONTINUE ELSE JX = KX DO 160 J = 1,N TEMP = X(JX) IX = JX IF (NOUNIT) TEMP = TEMP*A(J,J) DO 150 I = J + 1,N IX = IX + INCX TEMP = TEMP + A(I,J)*X(IX) 150 CONTINUE X(JX) = TEMP JX = JX + INCX 160 CONTINUE END IF END IF END IF * RETURN * * End of STRMV . * END
bsd-2-clause
jwakely/gcc
gcc/testsuite/gfortran.dg/ieee/large_2.f90
19
3829
! { dg-do run } ! { dg-additional-options "-mfp-rounding-mode=d" { target alpha*-*-* } } use, intrinsic :: ieee_features use, intrinsic :: ieee_arithmetic implicit none ! k1 and k2 will be large real kinds, if supported, and single/double ! otherwise integer, parameter :: k1 = & max(ieee_selected_real_kind(precision(0.d0) + 1), kind(0.)) integer, parameter :: k2 = & max(ieee_selected_real_kind(precision(0._k1) + 1), kind(0.d0)) interface check_equal procedure check_equal1, check_equal2 end interface interface check_not_equal procedure check_not_equal1, check_not_equal2 end interface interface divide procedure divide1, divide2 end interface real(kind=k1) :: x1, x2, x3 real(kind=k2) :: y1, y2, y3 type(ieee_round_type) :: mode if (ieee_support_rounding(ieee_up, x1) .and. & ieee_support_rounding(ieee_down, x1) .and. & ieee_support_rounding(ieee_nearest, x1) .and. & ieee_support_rounding(ieee_to_zero, x1)) then x1 = 1 x2 = 3 x1 = divide(x1, x2, ieee_up) x3 = 1 x2 = 3 x3 = divide(x3, x2, ieee_down) call check_not_equal(x1, x3) call check_equal(x3, nearest(x1, -1._k1)) call check_equal(x1, nearest(x3, 1._k1)) call check_equal(1._k1/3._k1, divide(1._k1, 3._k1, ieee_nearest)) call check_equal(-1._k1/3._k1, divide(-1._k1, 3._k1, ieee_nearest)) call check_equal(divide(3._k1, 7._k1, ieee_to_zero), & divide(3._k1, 7._k1, ieee_down)) call check_equal(divide(-3._k1, 7._k1, ieee_to_zero), & divide(-3._k1, 7._k1, ieee_up)) end if if (ieee_support_rounding(ieee_up, y1) .and. & ieee_support_rounding(ieee_down, y1) .and. & ieee_support_rounding(ieee_nearest, y1) .and. & ieee_support_rounding(ieee_to_zero, y1)) then y1 = 1 y2 = 3 y1 = divide(y1, y2, ieee_up) y3 = 1 y2 = 3 y3 = divide(y3, y2, ieee_down) call check_not_equal(y1, y3) call check_equal(y3, nearest(y1, -1._k2)) call check_equal(y1, nearest(y3, 1._k2)) call check_equal(1._k2/3._k2, divide(1._k2, 3._k2, ieee_nearest)) call check_equal(-1._k2/3._k2, divide(-1._k2, 3._k2, ieee_nearest)) call check_equal(divide(3._k2, 7._k2, ieee_to_zero), & divide(3._k2, 7._k2, ieee_down)) call check_equal(divide(-3._k2, 7._k2, ieee_to_zero), & divide(-3._k2, 7._k2, ieee_up)) end if contains real(kind=k1) function divide1 (x, y, rounding) result(res) use, intrinsic :: ieee_arithmetic real(kind=k1), intent(in) :: x, y type(ieee_round_type), intent(in) :: rounding type(ieee_round_type) :: old call ieee_get_rounding_mode (old) call ieee_set_rounding_mode (rounding) res = x / y call ieee_set_rounding_mode (old) end function real(kind=k2) function divide2 (x, y, rounding) result(res) use, intrinsic :: ieee_arithmetic real(kind=k2), intent(in) :: x, y type(ieee_round_type), intent(in) :: rounding type(ieee_round_type) :: old call ieee_get_rounding_mode (old) call ieee_set_rounding_mode (rounding) res = x / y call ieee_set_rounding_mode (old) end function subroutine check_equal1 (x, y) real(kind=k1), intent(in) :: x, y if (x /= y) then print *, x, y STOP 1 end if end subroutine subroutine check_equal2 (x, y) real(kind=k2), intent(in) :: x, y if (x /= y) then print *, x, y STOP 2 end if end subroutine subroutine check_not_equal1 (x, y) real(kind=k1), intent(in) :: x, y if (x == y) then print *, x, y STOP 3 end if end subroutine subroutine check_not_equal2 (x, y) real(kind=k2), intent(in) :: x, y if (x == y) then print *, x, y STOP 4 end if end subroutine end
gpl-2.0
the-linix-project/linix-kernel-source
gccsrc/gcc-4.7.2/gcc/testsuite/gfortran.dg/string_4.f90
162
1191
! { dg-do compile } ! { dg-options "" } ! (options to disable warnings about statement functions etc.) ! ! PR fortran/44352 ! ! Contributed by Vittorio Zecca ! SUBROUTINE TEST1() implicit real*8 (a-h,o-z) character*32 ddname,stmtfnt1 stmtfnt1(x)= 'h810 e=0.01 ' ddname=stmtfnt1(0.d0) if (ddname /= "h810 e=0.01") call abort() END SUBROUTINE TEST2() implicit none character(2) :: ddname,stmtfnt2 real :: x stmtfnt2(x)= 'x' ddname=stmtfnt2(0.0) if(ddname /= 'x') call abort() END SUBROUTINE TEST3() implicit real*8 (a-h,o-z) character*32 ddname,dname character*2 :: c dname(c) = 'h810 e=0.01 ' ddname=dname("w ") if (ddname /= "h810 e=0.01") call abort() END SUBROUTINE TEST4() implicit real*8 (a-h,o-z) character*32 ddname,dname character*2 :: c dname(c) = 'h810 e=0.01 ' c = 'aa' ddname=dname("w ") if (ddname /= "h810 e=0.01") call abort() if (c /= "aa") call abort() END call test1() call test2() call test3() call test4() end
bsd-2-clause
embecosm/epiphany-gcc
libgomp/testsuite/libgomp.fortran/reduction1.f90
202
4309
! { dg-do run } !$ use omp_lib integer :: i, ia (6), n, cnt real :: r, ra (4) double precision :: d, da (5) complex :: c, ca (3) logical :: v i = 1 ia = 2 r = 3 ra = 4 d = 5.5 da = 6.5 c = cmplx (7.5, 1.5) ca = cmplx (8.5, -3.0) v = .false. cnt = -1 !$omp parallel num_threads (3) private (n) reduction (.or.:v) & !$omp & reduction (+:i, ia, r, ra, d, da, c, ca) !$ if (i .ne. 0 .or. any (ia .ne. 0)) v = .true. !$ if (r .ne. 0 .or. any (ra .ne. 0)) v = .true. !$ if (d .ne. 0 .or. any (da .ne. 0)) v = .true. !$ if (c .ne. cmplx (0) .or. any (ca .ne. cmplx (0))) v = .true. n = omp_get_thread_num () if (n .eq. 0) then cnt = omp_get_num_threads () i = 4 ia(3:5) = -2 r = 5 ra(1:2) = 6.5 d = -2.5 da(2:4) = 8.5 c = cmplx (2.5, -3.5) ca(1) = cmplx (4.5, 5) else if (n .eq. 1) then i = 2 ia(4:6) = 5 r = 1 ra(2:4) = -1.5 d = 8.5 da(1:3) = 2.5 c = cmplx (0.5, -3) ca(2:3) = cmplx (-1, 6) else i = 1 ia = 1 r = -1 ra = -1 d = 1 da = -1 c = 1 ca = cmplx (-1, 0) end if !$omp end parallel if (v) call abort if (cnt .eq. 3) then if (i .ne. 8 .or. any (ia .ne. (/3, 3, 1, 6, 6, 8/))) call abort if (r .ne. 8 .or. any (ra .ne. (/9.5, 8.0, 1.5, 1.5/))) call abort if (d .ne. 12.5 .or. any (da .ne. (/8.0, 16.5, 16.5, 14.0, 5.5/))) call abort if (c .ne. cmplx (11.5, -5)) call abort if (ca(1) .ne. cmplx (12, 2)) call abort if (ca(2) .ne. cmplx (6.5, 3) .or. ca(2) .ne. ca(3)) call abort end if i = 1 ia = 2 r = 3 ra = 4 d = 5.5 da = 6.5 c = cmplx (7.5, 1.5) ca = cmplx (8.5, -3.0) v = .false. cnt = -1 !$omp parallel num_threads (3) private (n) reduction (.or.:v) & !$omp & reduction (-:i, ia, r, ra, d, da, c, ca) !$ if (i .ne. 0 .or. any (ia .ne. 0)) v = .true. !$ if (r .ne. 0 .or. any (ra .ne. 0)) v = .true. !$ if (d .ne. 0 .or. any (da .ne. 0)) v = .true. !$ if (c .ne. cmplx (0) .or. any (ca .ne. cmplx (0))) v = .true. n = omp_get_thread_num () if (n .eq. 0) then cnt = omp_get_num_threads () i = 4 ia(3:5) = -2 r = 5 ra(1:2) = 6.5 d = -2.5 da(2:4) = 8.5 c = cmplx (2.5, -3.5) ca(1) = cmplx (4.5, 5) else if (n .eq. 1) then i = 2 ia(4:6) = 5 r = 1 ra(2:4) = -1.5 d = 8.5 da(1:3) = 2.5 c = cmplx (0.5, -3) ca(2:3) = cmplx (-1, 6) else i = 1 ia = 1 r = -1 ra = -1 d = 1 da = -1 c = 1 ca = cmplx (-1, 0) end if !$omp end parallel if (v) call abort if (cnt .eq. 3) then if (i .ne. 8 .or. any (ia .ne. (/3, 3, 1, 6, 6, 8/))) call abort if (r .ne. 8 .or. any (ra .ne. (/9.5, 8.0, 1.5, 1.5/))) call abort if (d .ne. 12.5 .or. any (da .ne. (/8.0, 16.5, 16.5, 14.0, 5.5/))) call abort if (c .ne. cmplx (11.5, -5)) call abort if (ca(1) .ne. cmplx (12, 2)) call abort if (ca(2) .ne. cmplx (6.5, 3) .or. ca(2) .ne. ca(3)) call abort end if i = 1 ia = 2 r = 4 ra = 8 d = 16 da = 32 c = 2 ca = cmplx (0, 2) v = .false. cnt = -1 !$omp parallel num_threads (3) private (n) reduction (.or.:v) & !$omp & reduction (*:i, ia, r, ra, d, da, c, ca) !$ if (i .ne. 1 .or. any (ia .ne. 1)) v = .true. !$ if (r .ne. 1 .or. any (ra .ne. 1)) v = .true. !$ if (d .ne. 1 .or. any (da .ne. 1)) v = .true. !$ if (c .ne. cmplx (1) .or. any (ca .ne. cmplx (1))) v = .true. n = omp_get_thread_num () if (n .eq. 0) then cnt = omp_get_num_threads () i = 3 ia(3:5) = 2 r = 0.5 ra(1:2) = 2 d = -1 da(2:4) = -2 c = 2.5 ca(1) = cmplx (-5, 0) else if (n .eq. 1) then i = 2 ia(4:6) = -2 r = 8 ra(2:4) = -0.5 da(1:3) = -1 c = -3 ca(2:3) = cmplx (0, -1) else ia = 2 r = 0.5 ra = 0.25 d = 2.5 da = -1 c = cmplx (0, -1) ca = cmplx (-1, 0) end if !$omp end parallel if (v) call abort if (cnt .eq. 3) then if (i .ne. 6 .or. any (ia .ne. (/4, 4, 8, -16, -16, -8/))) call abort if (r .ne. 8 .or. any (ra .ne. (/4., -2., -1., -1./))) call abort if (d .ne. -40 .or. any (da .ne. (/32., -64., -64., 64., -32./))) call abort if (c .ne. cmplx (0, 15)) call abort if (ca(1) .ne. cmplx (0, 10)) call abort if (ca(2) .ne. cmplx (-2, 0) .or. ca(2) .ne. ca(3)) call abort end if end
gpl-2.0
decvalts/wrf
phys/module_bl_temf.F
1
65779
!wrf:model_layer:physics ! ! ! ! module module_bl_temf contains ! !------------------------------------------------------------------- ! subroutine temfpbl(u3d,v3d,th3d,t3d,qv3d,qc3d,qi3d,p3d,p3di,pi3d,rho, & rublten,rvblten,rthblten, & rqvblten,rqcblten,rqiblten,flag_qi, & g,cp,rcp,r_d,r_v,cpv, & z,xlv,psfc, & mut,p_top, & znt,ht,ust,zol,hol,hpbl,psim,psih, & xland,hfx,qfx,tsk,qsfc,gz1oz0,wspd,br, & dt,dtmin,kpbl2d, & svp1,svp2,svp3,svpt0,ep1,ep2,karman,eomeg,stbolt, & kh_temf,km_temf, & u10,v10,t2, & te_temf,shf_temf,qf_temf,uw_temf,vw_temf, & wupd_temf,mf_temf,thup_temf,qtup_temf,qlup_temf, & cf3d_temf,cfm_temf, & hd_temf,lcl_temf,hct_temf, & flhc,flqc,exch_temf, & fCor, & ids,ide, jds,jde, kds,kde, & ims,ime, jms,jme, kms,kme, & its,ite, jts,jte, kts,kte & ) !------------------------------------------------------------------- implicit none !------------------------------------------------------------------- ! New variables for TEMF !-- te_temf Total energy from this scheme !-- shf_temf Sensible heat flux profile from this scheme (kinematic) !-- qf_temf Moisture flux profile from this scheme (kinematic) !-- uw_temf U momentum flux component from this scheme !-- vw_temf V momentum flux component from this scheme !-- kh_temf Exchange coefficient for heat (3D) !-- km_temf Exchange coefficient for momentum (3D) !-- wupd_temf Updraft velocity from TEMF BL scheme !-- mf_temf Mass flux from TEMF BL scheme !-- thup_temf Updraft thetal from TEMF BL scheme !-- qtup_temf Updraft qt from TEMF BL scheme !-- qlup_temf Updraft ql from TEMF BL scheme !-- cf3d_temf 3D cloud fraction from TEMF BL scheme !-- cfm_temf Column cloud fraction from TEMF BL scheme !-- exch_temf Surface exchange coefficient (as for moisture) from TEMF surface layer scheme !-- flhc Surface exchange coefficient for heat (needed by surface scheme) !-- flqc Surface exchange coefficient for moisture (including moisture availablity) !-- fCor Coriolis parameter (from grid%f) ! !-- u3d 3d u-velocity interpolated to theta points (m/s) !-- v3d 3d v-velocity interpolated to theta points (m/s) !-- th3d 3d potential temperature (k) !-- t3d temperature (k) !-- qv3d 3d water vapor mixing ratio (kg/kg) !-- qc3d 3d cloud mixing ratio (kg/kg) !-- qi3d 3d ice mixing ratio (kg/kg) ! (note: if P_QI<PARAM_FIRST_SCALAR this should be zero filled) !-- p3d 3d pressure (pa) !-- p3di 3d pressure (pa) at interface level !-- pi3d 3d exner function (dimensionless) !-- rho 3d dry air density (kg/m^3) !-- rublten u tendency due to ! pbl parameterization (m/s/s) !-- rvblten v tendency due to ! pbl parameterization (m/s/s) !-- rthblten theta tendency due to ! pbl parameterization (K/s) !-- rqvblten qv tendency due to ! pbl parameterization (kg/kg/s) !-- rqcblten qc tendency due to ! pbl parameterization (kg/kg/s) !-- rqiblten qi tendency due to ! pbl parameterization (kg/kg/s) !-- cp heat capacity at constant pressure for dry air (j/kg/k) !-- g acceleration due to gravity (m/s^2) !-- rovcp r/cp !-- r_d gas constant for dry air (j/kg/k) !-- rovg r/g !-- z height above sea level (m) !-- xlv latent heat of vaporization (j/kg) !-- r_v gas constant for water vapor (j/kg/k) !-- psfc pressure at the surface (pa) !-- znt roughness length (m) !-- ht terrain height ASL (m) !-- ust u* in similarity theory (m/s) !-- zol z/l height over monin-obukhov length !-- hol pbl height over monin-obukhov length !-- hpbl pbl height (m) !-- psim similarity stability function for momentum !-- psih similarity stability function for heat !-- xland land mask (1 for land, 2 for water) !-- hfx upward heat flux at the surface (w/m^2) !-- qfx upward moisture flux at the surface (kg/m^2/s) !-- tsk surface temperature (k) !-- qsfc surface specific humidity (kg/kg) !-- gz1oz0 log(z/z0) where z0 is roughness length !-- wspd wind speed at lowest model level (m/s) !-- u10 u-wind speed at 10 m (m/s) !-- v10 v-wind speed at 10 m (m/s) !-- br bulk richardson number in surface layer !-- dt time step (s) !-- dtmin time step (minute) !-- rvovrd r_v divided by r_d (dimensionless) !-- svp1 constant for saturation vapor pressure (kpa) !-- svp2 constant for saturation vapor pressure (dimensionless) !-- svp3 constant for saturation vapor pressure (k) !-- svpt0 constant for saturation vapor pressure (k) !-- ep1 constant for virtual temperature (r_v/r_d - 1) (dimensionless) !-- ep2 constant for specific humidity calculation !-- karman von karman constant !-- eomeg angular velocity of earths rotation (rad/s) !-- stbolt stefan-boltzmann constant (w/m^2/k^4) !-- ids start index for i in domain !-- ide end index for i in domain !-- jds start index for j in domain !-- jde end index for j in domain !-- kds start index for k in domain !-- kde end index for k in domain !-- ims start index for i in memory !-- ime end index for i in memory !-- jms start index for j in memory !-- jme end index for j in memory !-- kms start index for k in memory !-- kme end index for k in memory !-- its start index for i in tile !-- ite end index for i in tile !-- jts start index for j in tile !-- jte end index for j in tile !-- kts start index for k in tile !-- kte end index for k in tile !------------------------------------------------------------------- ! Arguments ! integer, intent(in ) :: ids,ide, jds,jde, kds,kde, & ims,ime, jms,jme, kms,kme, & its,ite, jts,jte, kts,kte ! real, intent(in ) :: dt,dtmin,g,cp,rcp,r_d,r_v,xlv,cpv ! real, intent(in ) :: svp1,svp2,svp3,svpt0 real, intent(in ) :: ep1,ep2,karman,eomeg,stbolt ! real, dimension( ims:ime, kms:kme, jms:jme ) , & intent(in ) :: qv3d, qc3d, qi3d, & p3d, pi3d, th3d, t3d, & z, rho ! real, dimension( ims:ime, kms:kme, jms:jme ) , & intent(inout) :: te_temf real, dimension( ims:ime, kms:kme, jms:jme ) , & intent( out) :: shf_temf, qf_temf, uw_temf, vw_temf , & wupd_temf, mf_temf, thup_temf, qtup_temf, & qlup_temf,cf3d_temf real, dimension( ims:ime, jms:jme ) , & intent(inout) :: flhc, flqc, exch_temf real, dimension( ims:ime, jms:jme ) , & intent(in ) :: fCor real, dimension( ims:ime, jms:jme ) , & intent( out) :: hd_temf, lcl_temf, hct_temf, cfm_temf ! real, dimension( ims:ime, kms:kme, jms:jme ) , & intent(in ) :: p3di ! real, dimension( ims:ime, kms:kme, jms:jme ) , & intent(inout) :: rublten, rvblten, & rthblten, & rqvblten, rqcblten, rqiblten ! real, dimension( ims:ime, kms:kme, jms:jme ) , & intent(inout) :: kh_temf, km_temf real, dimension( ims:ime, jms:jme ) , & intent(inout) :: u10, v10, t2 ! real, dimension( ims:ime, jms:jme ) , & intent(in ) :: xland, & psim, psih, gz1oz0, br, & psfc, tsk, qsfc ! real, dimension( ims:ime, jms:jme ) , & intent(inout) :: hfx, qfx real, dimension( ims:ime, jms:jme ) , & intent(inout) :: hol, ust, hpbl, znt, wspd, zol real, dimension( ims:ime, jms:jme ) , & intent(in ) :: ht ! real, dimension( ims:ime, kms:kme, jms:jme ) , & intent(in ) :: u3d, v3d ! integer, dimension( ims:ime, jms:jme ) , & intent(out ) :: kpbl2d ! logical, intent(in) :: flag_qi ! ! real, dimension( ims:ime, kms:kme, jms:jme ), & ! optional , & ! intent(inout) :: rqiblten ! real, dimension( ims:ime, jms:jme ) , & optional , & intent(in ) :: mut ! real, optional, intent(in ) :: p_top ! !------------------------------------------------------- ! Local variables integer :: j do j = jts,jte call temf2d(J=j,ux=u3d(ims,kms,j),vx=v3d(ims,kms,j) & ,tx=t3d(ims,kms,j),thx=th3d(ims,kms,j) & ,qvx=qv3d(ims,kms,j),qcx=qc3d(ims,kms,j) & ,qix=qi3d(ims,kms,j) & ,p2d=p3d(ims,kms,j),p2di=p3di(ims,kms,j) & ,pi2d=pi3d(ims,kms,j),rho=rho(ims,kms,j) & ,rubltenx=rublten(ims,kms,j),rvbltenx=rvblten(ims,kms,j) & ,rthbltenx=rthblten(ims,kms,j),rqvbltenx=rqvblten(ims,kms,j) & ,rqcbltenx=rqcblten(ims,kms,j),rqibltenx=rqiblten(ims,kms,j) & ,g=g,cp=cp,rcp=rcp,r_d=r_d,r_v=r_v,cpv=cpv & ,z2d=z(ims,kms,j) & ,xlv=xlv & ,psfcpa=psfc(ims,j),znt=znt(ims,j),zsrf=ht(ims,j),ust=ust(ims,j) & ,zol=zol(ims,j),hol=hol(ims,j),hpbl=hpbl(ims,j) & ,psim=psim(ims,j) & ,psih=psih(ims,j),xland=xland(ims,j) & ,hfx=hfx(ims,j),qfx=qfx(ims,j) & ,tsk=tsk(ims,j),qsfc=qsfc(ims,j),gz1oz0=gz1oz0(ims,j) & ,wspd=wspd(ims,j),br=br(ims,j) & ,dt=dt,dtmin=dtmin,kpbl1d=kpbl2d(ims,j) & ,svp1=svp1,svp2=svp2,svp3=svp3,svpt0=svpt0 & ,ep1=ep1,ep2=ep2,karman=karman,eomeg=eomeg & ,stbolt=stbolt & ,kh_temfx=kh_temf(ims,kms,j),km_temfx=km_temf(ims,kms,j) & ,u10=u10(ims,j),v10=v10(ims,j),t2=t2(ims,j) & ,te_temfx=te_temf(ims,kms,j) & ,shf_temfx=shf_temf(ims,kms,j),qf_temfx=qf_temf(ims,kms,j) & ,uw_temfx=uw_temf(ims,kms,j),vw_temfx=vw_temf(ims,kms,j) & ,wupd_temfx=wupd_temf(ims,kms,j),mf_temfx=mf_temf(ims,kms,j) & ,thup_temfx=thup_temf(ims,kms,j),qtup_temfx=qtup_temf(ims,kms,j) & ,qlup_temfx=qlup_temf(ims,kms,j) & ,cf3d_temfx=cf3d_temf(ims,kms,j),cfm_temfx=cfm_temf(ims,j) & ,hd_temfx=hd_temf(ims,j),lcl_temfx=lcl_temf(ims,j) & ,hct_temfx=hct_temf(ims,j),exch_temfx=exch_temf(ims,j) & ,flhc=flhc(ims,j),flqc=flqc(ims,j) & ,fCor=fCor(ims,j) & ,ids=ids,ide=ide, jds=jds,jde=jde, kds=kds,kde=kde & ,ims=ims,ime=ime, jms=jms,jme=jme, kms=kms,kme=kme & ,its=its,ite=ite, jts=jts,jte=jte, kts=kts,kte=kte ) enddo ! end subroutine temfpbl ! !------------------------------------------------------------------- ! subroutine temf2d(j,ux,vx,tx,thx,qvx,qcx,qix,p2d,p2di,pi2d,rho, & rubltenx,rvbltenx,rthbltenx, & rqvbltenx,rqcbltenx,rqibltenx, & g,cp,rcp,r_d,r_v,cpv, & z2d, & xlv,psfcpa, & znt,zsrf,ust,zol,hol,hpbl,psim,psih, & xland,hfx,qfx,tsk,qsfc,gz1oz0,wspd,br, & dt,dtmin,kpbl1d, & svp1,svp2,svp3,svpt0,ep1,ep2,karman,eomeg,stbolt, & kh_temfx,km_temfx, & u10,v10,t2, & te_temfx,shf_temfx,qf_temfx,uw_temfx,vw_temfx, & wupd_temfx,mf_temfx,thup_temfx,qtup_temfx,qlup_temfx, & cf3d_temfx,cfm_temfx, & hd_temfx,lcl_temfx,hct_temfx,exch_temfx, & flhc,flqc, & fCor, & ids,ide, jds,jde, kds,kde, & ims,ime, jms,jme, kms,kme, & its,ite, jts,jte, kts,kte & ) !------------------------------------------------------------------- implicit none !------------------------------------------------------------------- ! ! This is the Total Energy - Mass Flux (TEMF) PBL scheme. ! Initial implementation 2010 by Wayne Angevine, CIRES/NOAA ESRL. ! References: ! Angevine et al., 2010, MWR ! Angevine, 2005, JAM ! Mauritsen et al., 2007, JAS ! !------------------------------------------------------------------- ! integer, intent(in ) :: ids,ide, jds,jde, kds,kde, & ims,ime, jms,jme, kms,kme, & its,ite, jts,jte, kts,kte, j ! real, intent(in ) :: dt,dtmin,g,cp,rcp,r_d,r_v,cpv,xlv ! real, intent(in ) :: svp1,svp2,svp3,svpt0 real, intent(in ) :: ep1,ep2,karman,eomeg,stbolt ! real, dimension( ims:ime, kms:kme ), & intent(in) :: z2d ! real, dimension( ims:ime, kms:kme ) , & intent(in ) :: ux, vx real, dimension( ims:ime, kms:kme ) , & intent(inout) :: te_temfx real, dimension( ims:ime, kms:kme ) , & intent( out) :: shf_temfx, qf_temfx, uw_temfx, vw_temfx , & wupd_temfx, mf_temfx,thup_temfx, & qtup_temfx, qlup_temfx, cf3d_temfx real, dimension( ims:ime ) , & intent( out) :: hd_temfx, lcl_temfx, hct_temfx, cfm_temfx real, dimension( ims:ime ) , & intent(in ) :: fCor real, dimension( ims:ime ) , & intent(inout) :: flhc, flqc, exch_temfx real, dimension( ims:ime, kms:kme ) , & intent(in ) :: tx, thx, qvx, qcx, qix, pi2d, rho real, dimension( ims:ime, kms:kme ) , & intent(in ) :: p2di, p2d ! real, dimension( ims:ime, kms:kme ) , & intent(inout) :: rubltenx, rvbltenx, rthbltenx, & rqvbltenx, rqcbltenx, rqibltenx ! real, dimension( ims:ime ) , & intent(inout) :: hol, ust, hpbl, znt real, dimension( ims:ime ) , & intent(in ) :: xland, zsrf real, dimension( ims:ime ) , & intent(inout) :: hfx, qfx ! real, dimension( ims:ime ), intent(inout) :: wspd real, dimension( ims:ime ), intent(in ) :: br ! real, dimension( ims:ime ), intent(in ) :: psim, psih real, dimension( ims:ime ), intent(in ) :: gz1oz0 ! real, dimension( ims:ime ), intent(in ) :: psfcpa real, dimension( ims:ime ), intent(in ) :: tsk, qsfc real, dimension( ims:ime ), intent(inout) :: zol integer, dimension( ims:ime ), intent(out ) :: kpbl1d real, dimension( ims:ime, kms:kme ) , & intent(inout) :: kh_temfx, km_temfx ! real, dimension( ims:ime ) , & intent(inout) :: u10, v10, t2 ! ! !----------------------------------------------------------- ! Local variables ! ! TE model constants logical, parameter :: MFopt = .true. ! Use mass flux or not real, parameter :: visc_temf = 1.57e-4 ! WA TEST bigger minimum K real, parameter :: conduc_temf = 1.57e-4 / 0.733 real, parameter :: Pr_temf = 0.733 real, parameter :: TEmin = 1e-3 real, parameter :: ftau0 = 0.17 real, parameter :: fth0 = 0.145 real, parameter :: critRi = 0.25 real, parameter :: Cf = 0.185 real, parameter :: CN = 2.0 real, parameter :: Ceps = 0.070 real, parameter :: Cgamma = Ceps real, parameter :: Cphi = Ceps real, parameter :: PrT0 = Cphi/Ceps * ftau0**2 / 2. / fth0**2 ! EDMF constants real, parameter :: CM = 0.03 ! Proportionality constant for subcloud MF real, parameter :: Cdelt = 0.006 ! Prefactor for detrainment rate real, parameter :: Cw = 0.5 ! Prefactor for surface wUPD real, parameter :: Cc = 3.0 ! Prefactor for convective length scale real, parameter :: lasymp = 200.0 ! Asymptotic length scale WA 11/20/09 real, parameter :: hmax = 4000.0 ! Max hd,hct WA 11/20/09 ! integer :: i, k, kt ! Loop variable integer, dimension( its:ite) :: h0idx real, dimension( its:ite) :: h0 real, dimension( its:ite) :: wstr, ang, wm real, dimension( its:ite) :: hd,lcl,hct,ht real, dimension( its:ite) :: convection_TKE_surface_src, sfcFTE real, dimension( its:ite) :: sfcTHVF real, dimension( its:ite) :: z0t integer, dimension( its:ite) :: hdidx,lclidx,hctidx,htidx integer, dimension( its:ite) :: hmax_idx integer, dimension( its:ite) :: tval real, dimension( its:ite, kts:kte) :: thetal, qt real, dimension( its:ite, kts:kte) :: u_temf, v_temf real, dimension( its:ite, kts:kte) :: rv, rl, rt real, dimension( its:ite, kts:kte) :: chi_poisson, gam real, dimension( its:ite, kts:kte) :: dthdz, dqtdz, dudz, dvdz real, dimension( its:ite, kts:kte) :: lepsmin real, dimension( its:ite, kts:kte) :: thetav real, dimension( its:ite, kts:kte) :: MFCth, MFCq, MFCu, MFCv real, dimension( its:ite, kts:kte) :: MFCql, MFCthv, MFCTE real, dimension( its:ite, kts:kte) :: epsmf, deltmf, dMdz real, dimension( its:ite, kts:kte) :: UUPD, VUPD real, dimension( its:ite, kts:kte) :: thetavUPD, qlUPD, TEUPD real, dimension( its:ite, kts:kte) :: thetavUPDmoist, wupd_dry real, dimension( its:ite, kts:kte) :: B, Bmoist real, dimension( its:ite, kts:kte) :: zm, zt, dzm, dzt real, dimension( its:ite, kts:kte) :: dthUPDdz, dqtup_temfxdz, dwUPDdz real, dimension( its:ite, kts:kte) :: dwUPDmoistdz real, dimension( its:ite, kts:kte) :: dUUPDdz, dVUPDdz, dTEUPDdz real, dimension( its:ite, kts:kte) :: TUPD, rstUPD, rUPD, rlUPD, qstUPD real, dimension( its:ite, kts:kte) :: N2, S, Ri, beta, ftau, fth, ratio real, dimension( its:ite, kts:kte) :: TKE, TE2 real, dimension( its:ite, kts:kte) :: ustrtilde, linv, leps real, dimension( its:ite, kts:kte) :: km, kh real, dimension( its:ite, kts:kte) :: Fz, QFK, uwk, vwk real, dimension( its:ite, kts:kte) :: km_conv, kh_conv, lconv real, dimension( its:ite, kts:kte) :: alpha2, beta2 ! For thetav flux calculation real, dimension( its:ite, kts:kte) :: THVF, buoy_src, srcs real, dimension( its:ite, kts:kte) :: u_new, v_new real, dimension( its:ite, kts:kte) :: thx_new, qvx_new, qcx_new real, dimension( its:ite, kts:kte) :: thup_new, qvup_new real, dimension( its:ite, kts:kte) :: beta1 ! For saturation humidity calculations real Cepsmf ! Prefactor for entrainment rate real red_fact ! for reducing MF components logical is_convective ! Vars for cloud fraction calculation real, dimension( its:ite, kts:kte) :: au, sigq, qst, satdef real sigq2, rst !---------------------------------------------------------------------- ! Grid staggering: Matlab version has mass and turbulence levels. ! WRF has full levels (with w) and half levels (u,v,theta,q*). Both ! sets of levels use the same indices (kts:kte). See pbl_driver or ! WRF Physics doc for (a few) details. ! So *mass levels correspond to half levels.* ! WRF full levels are ignored, we define our own turbulence levels ! in order to put the first one below the first half level. ! Another difference is that ! the Matlab version (and the Mauritsen et al. paper) consider the ! first mass level to be at z0 (effectively the surface). WRF considers ! the first half level to be above the effective surface. The first half ! level, at k=1, has nonzero values of u,v for example. Here we convert ! all incoming variables to internal ones with the correct indexing ! in order to make the code consistent with the Matlab version. We ! already had to do this for thetal and qt anyway, so the only additional ! overhead is for u and v. ! I use suffixes m for mass and t for turbulence as in Matlab for things ! like indices. ! Note that zsrf is the terrain height ASL, from Registry variable ht. ! Translations (Matlab to WRF): ! dzt -> calculated below ! dzm -> not supplied, calculated below ! k -> karman ! z0 -> znt ! z0t -> not in WRF, calculated below ! zt -> calculated below ! zm -> (z2d - zsrf) but NOTE zm(1) is now z0 (znt) and zm(2) is ! z2d(1) - zsrf ! ! WA I take the temperature at z0 to be ! TSK. This isn't exactly robust. ! WA 2/16/11 removed calculation of flhc, flqc which are not needed here. ! These should be removed from the calling sequence someday. ! ! Other notes: ! - I have often used 1 instead of kts below, because the scheme demands ! to know where the surface is. It won't work if kts .NE. 1. do i = its,ite ! Main loop ! Get incoming surface theta from TSK (WA for now) thetal(i,1) = tsk(i) / pi2d(i,1) ! WA really should use Exner func. at z0 qt(i,1) = qvx(i,1) rv(i,1) = qt(i,1) / (1.-qt(i,1)) ! Water vapor rl(i,1) = 0. rt(i,1) = rv(i,1) + rl(i,1) ! Total water (without ice) chi_poisson(i,1) = rcp * (1.+rv(i,1)/ep2) / (1.+rv(i,1)*cpv/cp) gam(i,1) = rv(i,1) * r_v / (cp + rv(i,1)*cpv) thetav(i,1) = thetal(i,1) * (1. + 0.608*qt(i,1) - qcx(i,1)) ! WA 4/6/10 allow environment liquid z0t(i) = znt(i) ! Convert incoming theta to thetal and qv,qc to qt ! NOTE this is where the indexing gets changed from WRF to TEMF basis do k = kts+1,kte ! Convert specific humidities to mixing ratios rv(i,k) = qvx(i,k-1) / (1.-qvx(i,k-1)) ! Water vapor rl(i,k) = qcx(i,k-1) / (1.-qcx(i,k-1)) ! Liquid water rt(i,k) = rv(i,k) + rl(i,k) ! Total water (without ice) chi_poisson(i,k) = rcp * (1.+rv(i,k)/ep2) / (1.+rv(i,k)*cpv/cp) gam(i,k) = rt(i,k) * r_v / (cp + rt(i,k)*cpv) thetal(i,k) = thx(i,k-1) * & ((ep2+rv(i,k))/(ep2+rt(i,k)))**chi_poisson(i,k) * & (rv(i,k)/rt(i,k))**(-gam(i,k)) * exp( -xlv*rl(i,k) / & ((cp + rt(i,k)*cpv) * tx(i,k))) qt(i,k) = qvx(i,k-1) + qcx(i,k-1) thetav(i,k) = thetal(i,k) * (1. + 0.608*qt(i,k) - qcx(i,k-1)) ! WA 4/6/10 allow environment liquid end do ! Convert incoming u,v to internal u_temf, v_temf ! NOTE this is where the indexing gets changed from WRF to TEMF basis u_temf(i,1) = 0. ! zero winds at z0 v_temf(i,1) = 0. do k = kts+1,kte u_temf(i,k) = ux(i,k-1) v_temf(i,k) = vx(i,k-1) end do ! Get delta height at half (mass) levels zm(i,1) = znt(i) dzt(i,1) = z2d(i,1) - zsrf(i) - zm(i,1) ! Get height and delta at turbulence levels zt(i,1) = (z2d(i,1) - zsrf(i) - znt(i)) / 2. do kt = kts+1,kte zm(i,kt) = z2d(i,kt-1) - zsrf(i) ! Convert indexing from WRF to TEMF zt(i,kt) = (zm(i,kt) + z2d(i,kt) - zsrf(i)) / 2. dzm(i,kt) = zt(i,kt) - zt(i,kt-1) dzt(i,kt) = z2d(i,kt+1) - z2d(i,kt) end do dzm(i,1) = dzm(i,2) ! WA why? dzt(i,kte) = dzt(i,kte-1) ! WA 12/23/09 ! Gradients at first level dthdz(i,1) = (thetal(i,2)-thetal(i,1)) / (zt(i,1) * log10(zm(i,2)/z0t(i))) dqtdz(i,1) = (qt(i,2)-qt(i,1)) / (zt(i,1) * log10(zm(i,2)/z0t(i))) dudz(i,1) = (u_temf(i,2)-u_temf(i,1)) / (zt(i,1) * log10(zm(i,2)/znt(i))) dvdz(i,1) = (v_temf(i,2)-v_temf(i,1)) / (zt(i,1) * log10(zm(i,2)/znt(i))) ! Surface thetaV flux from Stull p.147 sfcTHVF(i) = hfx(i)/(rho(i,1)*cp) * (1.+0.608*(qvx(i,1)+qcx(i,1))) + 0.608*thetav(i,1)*qf_temfx(i,1) ! WA use hd_temf to calculate w* instead of finding h0 here???? ! Watch initialization! h0idx(i) = 1 h0(i) = zm(i,1) lepsmin(i,kts) = 0. ! WA 2/11/13 find index just above hmax for use below hmax_idx(i) = kte-1 do k = kts+1,kte-1 lepsmin(i,k) = 0. ! Mean gradients dthdz(i,k) = (thetal(i,k+1) - thetal(i,k)) / dzt(i,k) dqtdz(i,k) = (qt(i,k+1) - qt(i,k)) / dzt(i,k) dudz(i,k) = (u_temf(i,k+1) - u_temf(i,k)) / dzt(i,k) dvdz(i,k) = (v_temf(i,k+1) - v_temf(i,k)) / dzt(i,k) ! Find h0 (should eventually be interpolated for smoothness) if (thetav(i,k) > thetav(i,1) .AND. h0idx(i) .EQ. 1) then ! WA 9/28/11 limit h0 as for hd and hct if (zm(i,k) < hmax) then h0idx(i) = k h0(i) = zm(i,k) else h0idx(i) = k h0(i) = hmax end if end if ! WA 2/11/13 find index just above hmax for use below if (zm(i,k) > hmax) then hmax_idx(i) = min(hmax_idx(i),k) end if end do ! Gradients at top level dthdz(i,kte) = dthdz(i,kte-1) dqtdz(i,kte) = dqtdz(i,kte-1) dudz(i,kte) = dudz(i,kte-1) dvdz(i,kte) = dvdz(i,kte-1) if ( hfx(i) > 0.) then ! wstr(i) = (g * h0(i) / thetav(i,2) * shf_temfx(i,1) ) ** (1./3.) wstr(i) = (g * h0(i) / thetav(i,2) * hfx(i)/(rho(i,1)*cp) ) ** (1./3.) else wstr(i) = 0. end if ! Set flag convective or not for use below is_convective = wstr(i) > 0. .AND. MFopt .AND. dthdz(i,1)<0. .AND. dthdz(i,2)<0. ! WA 12/16/09 require two levels of negative (unstable) gradient ! Find stability parameters and length scale (on turbulence levels) do kt = 1,kte-1 N2(i,kt) = 2. * g / (thetav(i,kt) + thetav(i,kt+1))*dthdz(i,kt) S(i,kt) = sqrt(dudz(i,kt)**2. + dvdz(i,kt)**2.) Ri(i,kt) = N2(i,kt) / S(i,kt)**2. if (S(i,kt) < 1e-15) then if (N2(i,kt) >= 0) then Ri(i,kt) = 10. else Ri(i,kt) = -1. end if end if beta(i,kt) = 2. * g / (thetav(i,kt)+thetav(i,kt+1)) if (Ri(i,kt) > 0) then ratio(i,kt) = Ri(i,kt)/(Cphi**2.*ftau0**2./(2.*Ceps**2.*fth0**2.)+3.*Ri(i,kt)) ftau(i,kt) = ftau0 * ((3./4.) / (1.+4.*Ri(i,kt)) + 1./4.) fth(i,kt) = fth0 / (1.+4.*Ri(i,kt)) TE2(i,kt) = 2. * te_temfx(i,kt) * ratio(i,kt) * N2(i,kt) / beta(i,kt)**2. else ratio(i,kt) = Ri(i,kt)/(Cphi**2.*ftau0**2./(-2.*Ceps**2.*fth0**2.)+2.*Ri(i,kt)) ftau(i,kt) = ftau0 fth(i,kt) = fth0 TE2(i,kt) = 0. end if TKE(i,kt) = te_temfx(i,kt) * (1. - ratio(i,kt)) ustrtilde(i,kt) = sqrt(ftau(i,kt) * TKE(i,kt)) if (N2(i,kt) > 0.) then linv(i,kt) = 1./karman / zt(i,kt) + abs(fCor(i)) / & (Cf*ustrtilde(i,kt)) + & sqrt(N2(i,kt))/(CN*ustrtilde(i,kt)) + 1./lasymp else linv(i,kt) = 1./karman / zt(i,kt) + abs(fCor(i)) / & (Cf*ustrtilde(i,kt)) + 1./lasymp end if leps(i,kt) = 1./linv(i,kt) leps(i,kt) = max(leps(i,kt),lepsmin(i,kt)) end do S(i,kte) = 0.0 N2(i,kte) = 0.0 TKE(i,kte) = 0.0 linv(i,kte) = linv(i,kte-1) leps(i,kte) = leps(i,kte-1) ! Find diffusion coefficients ! First use basic formulae for stable and neutral cases, ! then for convective conditions, and finally choose the larger ! WA 12/23/09 use convective form up to hd/2 always ! WA 12/28/09 after restructuring, this block is above MF block, ! so hd is not yet available for this timestep, must use h0, ! or use hd from previous timestep but be careful about initialization. do kt = 1,kte-1 ! WA 12/22/09 ! WA 4/8/10 remove beta term to avoid negative and huge values ! of km due to very small denominator. This is an interim fix ! until we find something better (more theoretically sound). ! km(i,kt) = TKE(i,kt)**1.5 * ftau(i,kt)**2. / (-beta(i,kt) * fth(i,kt) * sqrt(TE2(i,kt)) + Ceps * sqrt(TKE(i,kt)*te_temfx(i,kt)) / leps(i,kt)) km(i,kt) = TKE(i,kt)**1.5 * ftau(i,kt)**2. / (Ceps * sqrt(TKE(i,kt)*te_temfx(i,kt)) / leps(i,kt)) kh(i,kt) = 2. * leps(i,kt) * fth(i,kt)**2. * TKE(i,kt) / sqrt(te_temfx(i,kt)) / Cphi if ( is_convective) then ! WA 2/20/14 trap rare "equality" of h0 and zt (only when h0 = hmax) if (kt <= h0idx(i) .AND. h0(i)-zt(i,kt) > 1e-15) then lconv(i,kt) = 1. / (1. / (karman*zt(i,kt)) + Cc / (karman * (h0(i) - zt(i,kt)))) else lconv(i,kt) = 0. end if ! WA 12/15/09 use appropriate coeffs to match kh_conv and kh at neutral kh_conv(i,kt) = ftau0**2. / Ceps / PrT0 * sqrt(TKE(i,kt)) * lconv(i,kt) if (kh_conv(i,kt) < 0.) then kh_conv(i,kt) = 0. end if km_conv(i,kt) = PrT0 * kh_conv(i,kt) if (zt(i,kt) <= h0(i)/2.) then km(i,kt) = km_conv(i,kt) kh(i,kt) = kh_conv(i,kt) end if if (zt(i,kt) > h0(i)/2. .AND. kt <= h0idx(i)) then km(i,kt) = max(km(i,kt),km_conv(i,kt),visc_temf) kh(i,kt) = max(kh(i,kt),kh_conv(i,kt),conduc_temf) end if end if ! is_convective km(i,kt) = max(km(i,kt),visc_temf) kh(i,kt) = max(kh(i,kt),conduc_temf) Fz(i,kt) = -kh(i,kt) * dthdz(i,kt) ! Diffusive heat flux end do km(i,kte) = km(i,kte-1) kh(i,kte) = kh(i,kte-1) Fz(i,kte) = 0.0 !*** Mass flux block starts here *** if ( is_convective) then Cepsmf = 2. / max(200.,h0(i)) Cepsmf = max(Cepsmf,0.002) do k = kts,kte ! Calculate lateral entrainment fraction for subcloud layer ! epsilon and delta are defined on mass grid (half levels) epsmf(i,k) = Cepsmf end do ! Initialize updraft thup_temfx(i,1) = thetal(i,1) ! No excess qtup_temfx(i,1) = qt(i,1) ! No excess rUPD(i,1) = qtup_temfx(i,1) / (1. - qtup_temfx(i,1)) wupd_temfx(i,1) = Cw * wstr(i) wupd_dry(i,1) = Cw * wstr(i) UUPD(i,1) = u_temf(i,1) VUPD(i,1) = v_temf(i,1) thetavUPD(i,1) = thup_temfx(i,1) * (1. + 0.608*qtup_temfx(i,1)) ! WA Assumes no liquid thetavUPDmoist(i,1) = thup_temfx(i,1) * (1. + 0.608*qtup_temfx(i,1)) ! WA Assumes no liquid TEUPD(i,1) = te_temfx(i,1) + g / thetav(i,1) * sfcTHVF(i) qlUPD(i,1) = qcx(i,1) ! WA allow environment liquid TUPD(i,1) = thup_temfx(i,1) * pi2d(i,1) rstUPD(i,1) = rsat(p2d(i,1),TUPD(i,1),ep2) rlUPD(i,1) = 0. ! Calculate updraft parameters counting up do k = 2,kte ! WA 2/11/13 use hmax index to prevent oddness high up if ( k < hmax_idx(i)) then dthUPDdz(i,k-1) = -epsmf(i,k) * (thup_temfx(i,k-1) - thetal(i,k-1)) thup_temfx(i,k) = thup_temfx(i,k-1) + dthUPDdz(i,k-1) * dzm(i,k-1) dqtup_temfxdz(i,k-1) = -epsmf(i,k) * (qtup_temfx(i,k-1) - qt(i,k-1)) qtup_temfx(i,k) = qtup_temfx(i,k-1) + dqtup_temfxdz(i,k-1) * dzm(i,k-1) thetavUPD(i,k) = thup_temfx(i,k) * (1. + 0.608*qtup_temfx(i,k)) ! WA Assumes no liquid B(i,k-1) = g * (thetavUPD(i,k) - thetav(i,k)) / thetav(i,k) if ( wupd_dry(i,k-1) < 1e-15 ) then wupd_dry(i,k) = 0. else dwUPDdz(i,k-1) = -2. *epsmf(i,k)*wupd_dry(i,k-1) + 0.33*B(i,k-1)/wupd_dry(i,k-1) wupd_dry(i,k) = wupd_dry(i,k-1) + dwUPDdz(i,k-1) * dzm(i,k-1) end if dUUPDdz(i,k-1) = -epsmf(i,k) * (UUPD(i,k-1) - u_temf(i,k-1)) UUPD(i,k) = UUPD(i,k-1) + dUUPDdz(i,k-1) * dzm(i,k-1) dVUPDdz(i,k-1) = -epsmf(i,k) * (VUPD(i,k-1) - v_temf(i,k-1)) VUPD(i,k) = VUPD(i,k-1) + dVUPDdz(i,k-1) * dzm(i,k-1) dTEUPDdz(i,k-1) = -epsmf(i,k) * (TEUPD(i,k-1) - te_temfx(i,k-1)) TEUPD(i,k) = TEUPD(i,k-1) + dTEUPDdz(i,k-1) * dzm(i,k-1) ! Alternative updraft velocity based on moist thetav ! Need thetavUPDmoist, qlUPD rUPD(i,k) = qtup_temfx(i,k) / (1. - qtup_temfx(i,k)) ! WA Updraft temperature assuming no liquid TUPD(i,k) = thup_temfx(i,k) * pi2d(i,k) ! Updraft saturation mixing ratio rstUPD(i,k) = rsat(p2d(i,k-1),TUPD(i,k),ep2) ! Correct to actual temperature (Sommeria & Deardorff 1977) beta1(i,k) = 0.622 * (xlv/(r_d*TUPD(i,k))) * (xlv/(cp*TUPD(i,k))) rstUPD(i,k) = rstUPD(i,k) * (1.0+beta1(i,k)*rUPD(i,k)) / (1.0+beta1(i,k)*rstUPD(i,k)) qstUPD(i,k) = rstUPD(i,k) / (1. + rstUPD(i,k)) if (rUPD(i,k) > rstUPD(i,k)) then rlUPD(i,k) = rUPD(i,k) - rstUPD(i,k) qlUPD(i,k) = rlUPD(i,k) / (1. + rlUPD(i,k)) thetavUPDmoist(i,k) = (thup_temfx(i,k) + ((xlv/cp)*qlUPD(i,k)/pi2d(i,k))) * & (1. + 0.608*qstUPD(i,k) - qlUPD(i,k)) else rlUPD(i,k) = 0. qlUPD(i,k) = qcx(i,k-1) ! WA 4/6/10 allow environment liquid thetavUPDmoist(i,k) = thup_temfx(i,k) * (1. + 0.608*qtup_temfx(i,k)) end if Bmoist(i,k-1) = g * (thetavUPDmoist(i,k) - thetav(i,k)) / thetav(i,k) if ( wupd_temfx(i,k-1) < 1e-15 ) then wupd_temfx(i,k) = 0. else dwUPDmoistdz(i,k-1) = -2. *epsmf(i,k)*wupd_temfx(i,k-1) + 0.33*Bmoist(i,k-1)/wupd_temfx(i,k-1) wupd_temfx(i,k) = wupd_temfx(i,k-1) + dwUPDmoistdz(i,k-1) * dzm(i,k-1) end if else thup_temfx(i,k) = thetal(i,k) qtup_temfx(i,k) = qt(i,k) wupd_dry(i,k) = 0. UUPD(i,k) = u_temf(i,k) VUPD(i,k) = v_temf(i,k) TEUPD(i,k) = te_temfx(i,k) qlUPD(i,k) = qcx(i,k-1) wupd_temfx(i,k) = 0. end if end do ! Find hd based on wUPD if (wupd_dry(i,1) == 0.) then hdidx(i) = 1 else hdidx(i) = kte ! In case wUPD <= 0 not found do k = 2,kte ! if (wupd_dry(i,k) <= 0.) then if (wupd_dry(i,k) <= 0. .OR. zm(i,k) > hmax) then hdidx(i) = k goto 100 ! FORTRAN made me do it! end if end do end if 100 hd(i) = zm(i,hdidx(i)) kpbl1d(i) = hdidx(i) hpbl(i) = hd(i) ! WA 5/11/10 hpbl is height. Should still be replaced by something that works whether convective or not. ! Find LCL, hct, and ht lclidx(i) = kte ! In case LCL not found do k = kts,kte if ( k < hmax_idx(i) .AND. rUPD(i,k) > rstUPD(i,k)) then lclidx(i) = k goto 200 end if end do 200 lcl(i) = zm(i,lclidx(i)) if (hd(i) > lcl(i)) then ! Forced cloud (at least) occurs ! Find hct based on wUPDmoist if (wupd_temfx(i,1) == 0.) then hctidx(i) = 1 else hctidx(i) = kte ! In case wUPD <= 0 not found do k = 2,kte if (wupd_temfx(i,k) <= 0. .OR. zm(i,k) > hmax) then hctidx(i) = k goto 300 ! FORTRAN made me do it! end if end do end if 300 hct(i) = zm(i,hctidx(i)) if (hctidx(i) <= hdidx(i)+1) then ! No active cloud hct(i) = hd(i) hctidx(i) = hdidx(i) else end if else ! No cloud hct(i) = hd(i) hctidx(i) = hdidx(i) end if ht(i) = max(hd(i),hct(i)) htidx(i) = max(hdidx(i),hctidx(i)) ! Now truncate updraft at ht with taper do k = 1,kte if (zm(i,k) < 0.9*ht(i)) then ! Below taper region tval(i) = 1 else if (zm(i,k) >= 0.9*ht(i) .AND. zm(i,k) <= 1.0*ht(i)) then ! Within taper region tval(i) = 1. - ((zm(i,k) - 0.9*ht(i)) / (1.0*ht(i) - 0.9*ht(i))) else ! Above taper region tval(i) = 0. end if thup_temfx(i,k) = tval(i) * thup_temfx(i,k) + (1-tval(i))*thetal(i,k) thetavUPD(i,k) = tval(i) * thetavUPD(i,k) + (1-tval(i))*thetav(i,k) qtup_temfx(i,k) = tval(i) * qtup_temfx(i,k) + (1-tval(i)) * qt(i,k) ! WA 6/21/13 was a subscript error when k=1 if (k > 1) then qlUPD(i,k) = tval(i) * qlUPD(i,k) + (1-tval(i)) * qcx(i,k-1) end if UUPD(i,k) = tval(i) * UUPD(i,k) + (1-tval(i)) * u_temf(i,k) VUPD(i,k) = tval(i) * VUPD(i,k) + (1-tval(i)) * v_temf(i,k) TEUPD(i,k) = tval(i) * TEUPD(i,k) + (1-tval(i)) * te_temfx(i,k) if (zm(i,k) > ht(i)) then ! WA this is just for cleanliness wupd_temfx(i,k) = 0. dwUPDmoistdz(i,k) = 0. wupd_dry(i,k) = 0. dwUPDdz(i,k) = 0. end if end do ! Calculate lateral detrainment rate for cloud layer deltmf(i,1) = Cepsmf do k = 2,kte-1 if (hctidx(i) > hdidx(i)+1) then ! Some cloud deltmf(i,k) = 0.9 * Cepsmf + Cdelt * (atan((zm(i,k)-(lcl(i)+(hct(i)-lcl(i))/1.5))/ & ((hct(i)-lcl(i))/8))+(3.1415926/2))/3.1415926 else if (k < hdidx(i)) then ! No cloud, below hd deltmf(i,k) = Cepsmf + 0.05 * 1. / (hd(i) - zm(i,k)) else if (k >= hdidx(i)) then ! No cloud, above hd deltmf(i,k) = deltmf(i,k-1) end if end do ! Calculate mass flux (defined on turbulence levels) mf_temfx(i,1) = CM * wstr(i) do kt = 2,kte-1 dMdz(i,kt) = (epsmf(i,kt) - deltmf(i,kt)) * mf_temfx(i,kt-1) * dzt(i,kt) mf_temfx(i,kt) = mf_temfx(i,kt-1) + dMdz(i,kt) end do ! WA 12/28/09 If mass flux component > diffusive ! component at second level, ! reduce M to prevent a stable layer MFCth(i,2) = mf_temfx(i,2) * (thup_temfx(i,2)-thetal(i,2) + thup_temfx(i,3)-thetal(i,3)) / 2. if (MFCth(i,2) > Fz(i,2)) then red_fact = Fz(i,2) / MFCth(i,2) do kt = 1,kte mf_temfx(i,kt) = mf_temfx(i,kt) * red_fact end do end if ! Reduce M to prevent stable layer at second level ! Calculate mass flux contributions to fluxes (defined on turb levels) ! Use log interpolation at first level MFCth(i,1) = mf_temfx(i,1) * (thup_temfx(i,1)-thetal(i,1) & + (thup_temfx(i,2)-thetal(i,2) - & (thup_temfx(i,1)-thetal(i,1))) * log(zt(i,1)/znt(i))/log(zm(i,2)/znt(i))) MFCq(i,1) = mf_temfx(i,1) * (qtup_temfx(i,1)-qt(i,1) & + (qtup_temfx(i,2)-qt(i,2) - & (qtup_temfx(i,1)-qt(i,1))) * log(zt(i,1)/znt(i))/log(zm(i,2)/znt(i))) MFCu(i,1) = mf_temfx(i,1) * (UUPD(i,1)-u_temf(i,1) & + (UUPD(i,2)-u_temf(i,2) - & (UUPD(i,1)-u_temf(i,1))) * log(zt(i,1)/znt(i))/log(zm(i,2)/znt(i))) MFCv(i,1) = mf_temfx(i,1) * (VUPD(i,1)-v_temf(i,1) & + (VUPD(i,2)-v_temf(i,2) - & (VUPD(i,1)-v_temf(i,1))) * log(zt(i,1)/znt(i))/log(zm(i,2)/znt(i))) MFCql(i,1) = mf_temfx(i,1) * (qlUPD(i,1)-qcx(i,1) & + (qlUPD(i,2)-qcx(i,2) - & (qlUPD(i,1)-qcx(i,1))) * log(zt(i,1)/znt(i))/log(zm(i,2)/znt(i))) MFCTE(i,1) = mf_temfx(i,1) * (TEUPD(i,1)-te_temfx(i,1) & + (TEUPD(i,2)-te_temfx(i,2) - & (TEUPD(i,1)-te_temfx(i,1))) * log(zt(i,1)/znt(i))/log(zm(i,2)/znt(i))) ! WA Check this do kt = 2,kte-1 MFCth(i,kt) = mf_temfx(i,kt) * (thup_temfx(i,kt)-thetal(i,kt) + thup_temfx(i,kt+1)-thetal(i,kt+1)) / 2. MFCq(i,kt) = mf_temfx(i,kt) * (qtup_temfx(i,kt)-qt(i,kt) + qtup_temfx(i,kt+1)-qt(i,kt+1)) / 2. MFCu(i,kt) = mf_temfx(i,kt) * (UUPD(i,kt)-u_temf(i,kt) + UUPD(i,kt+1)-u_temf(i,kt+1)) / 2. MFCv(i,kt) = mf_temfx(i,kt) * (VUPD(i,kt)-v_temf(i,kt) + VUPD(i,kt+1)-v_temf(i,kt+1)) / 2. MFCql(i,kt) = mf_temfx(i,kt) * (qlUPD(i,kt)-qcx(i,kt-1) + qlUPD(i,kt+1)-qcx(i,kt)) / 2. MFCTE(i,kt) = mf_temfx(i,kt) * (TEUPD(i,kt)-te_temfx(i,kt)) ! TE is on turb levels end do MFCth(i,kte) = 0 MFCq(i,kte) = 0 MFCu(i,kte) = 0 MFCv(i,kte) = 0 MFCql(i,kte) = 0 MFCTE(i,kte) = 0 ! Calculate cloud fraction (on mass levels) cf3d_temfx(i,1) = 0.0 cfm_temfx(i) = 0.0 do k = 2,kte ! if (wupd_temfx(i,k-1) >= 1.0e-15 .AND. wupd_temfx(i,k) >= 1.0e-15 .AND. .NOT. isnan(wupd_temfx(i,k-1)) .AND. .NOT. isnan(wupd_temfx(i,k))) then if (wupd_temfx(i,k-1) >= 1.0e-15 .AND. wupd_temfx(i,k) >= 1.0e-15) then au(i,k) = ((mf_temfx(i,k-1)+mf_temfx(i,k))/2.0) / ((wupd_temfx(i,k-1)+wupd_temfx(i,k))/2.0) ! WA average before divide, is that best? else au(i,k) = 0.0 end if sigq2 = au(i,k) * (qtup_temfx(i,k)-qt(i,k)) if (sigq2 > 0.0) then sigq(i,k) = sqrt(sigq2) else sigq(i,k) = 0.0 end if ! rst = rsat(p2d(i,k),thx(i,k)*pi2d(i,k),ep2) rst = rsat(p2d(i,k-1),thx(i,k-1)*pi2d(i,k-1),ep2) qst(i,k) = rst / (1. + rst) satdef(i,k) = qt(i,k) - qst(i,k) if (satdef(i,k) <= 0.0) then if (sigq(i,k) > 1.0e-15) then cf3d_temfx(i,k) = max(0.5 + 0.36 * atan(1.55*(satdef(i,k)/sigq(i,k))),0.0) else cf3d_temfx(i,k) = 0.0 end if else cf3d_temfx(i,k) = 1.0 end if if (zm(i,k) < lcl(i)) then cf3d_temfx(i,k) = 0.0 end if ! Put max value so far into cfm if (zt(i,k) <= hmax) then cfm_temfx(i) = max(cf3d_temfx(i,k),cfm_temfx(i)) end if end do else ! not is_convective, no MF components do kt = 1,kte MFCth(i,kt) = 0 MFCq(i,kt) = 0 MFCu(i,kt) = 0 MFCv(i,kt) = 0 MFCql(i,kt) = 0 MFCTE(i,kt) = 0 end do lcl(i) = zm(i,kte-1) hct(i) = zm(i,1) hctidx(i) = 1 hd(i) = zm(i,1) hdidx(i) = 1 ht(i) = hd(i) ! Cloud fraction calculations cf3d_temfx(i,1) = 0.0 cfm_temfx(i) = 0.0 do k = 2,kte if (qcx(i,k-1) > 1.0e-15) then cf3d_temfx(i,k) = 1.0 else cf3d_temfx(i,k) = 0.0 end if ! Put max value so far into cfm if (zt(i,k) <= hmax) then cfm_temfx(i) = max(cf3d_temfx(i,k),cfm_temfx(i)) end if end do end if ! MF components or not cf3d_temfx(i,kte) = 0.0 ! Mass flux block ends here ! Flux profiles do kt = 2,kte ! Fz(i,kt) = -kh(i,kt) * dthdz(i,kt) shf_temfx(i,kt) = Fz(i,kt) + MFCth(i,kt) QFK(i,kt) = -kh(i,kt) * dqtdz(i,kt) qf_temfx(i,kt) = QFK(i,kt) + MFCq(i,kt) uwk(i,kt) = -km(i,kt) * dudz(i,kt) uw_temfx(i,kt) = uwk(i,kt) + MFCu(i,kt) vwk(i,kt) = -km(i,kt) * dvdz(i,kt) vw_temfx(i,kt) = vwk(i,kt) + MFCv(i,kt) end do ! Surface momentum fluxes ! WA TEST 11/7/13 use w* as a component of the mean wind inside the ! u* calculation instead of in the velocity scale below (Felix) ! ust(i) = sqrt(ftau(i,1)/ftau0) * sqrt(u_temf(i,2)**2. + v_temf(i,2)**2.) * leps(i,1) / log(zm(i,2)/znt(i)) / zt(i,1) ust(i) = sqrt(ftau(i,1)/ftau0) * sqrt(u_temf(i,2)**2. + v_temf(i,2)**2. + (0.5*wstr(i))**2.) * leps(i,1) / log(zm(i,2)/znt(i)) / zt(i,1) ang(i) = atan2(v_temf(i,2),u_temf(i,2)) uw_temfx(i,1) = -cos(ang(i)) * ust(i)**2. vw_temfx(i,1) = -sin(ang(i)) * ust(i)**2. ! Calculate mixed scaling velocity (Moeng & Sullivan 1994 JAS p.1021) ! Replaces ust everywhere ! WA TEST 11/7/13 back to wm = u* but with "whole" wind in u* above wm(i) = ust(i) ! WA 7/23/10 reduce velocity scale to fix excessive fluxes ! wm(i) = 0.5 * (1./5. * (wstr(i)**3. + 5. * ust(i)**3.)) ** (1./3.) ! Specified flux versions (flux is modified by land surface) ! WA 5/31/13 use whole surface flux to improve heat conservation shf_temfx(i,1) = hfx(i)/(rho(i,1)*cp) qf_temfx(i,1) = qfx(i)/rho(i,1) Fz(i,1) = shf_temfx(i,1) - MFCth(i,1) QFK(i,1) = qf_temfx(i,1) - MFCq(i,1) ! Calculate thetav and its flux ! From Lewellen 2004 eq. 3 ! WA The constants and combinations below should probably be replaced ! by something more consistent with the WRF system, but for now ! I don't want to take the chance of breaking something. do kt = 2,kte-1 alpha2(i,kt) = 0.61 * (thetal(i,kt) + thetal(i,kt+1)) / 2. beta2(i,kt) = (100000. / p2di(i,kt))**0.286 * 2.45e-6 / 1004.67 - 1.61 * (thetal(i,kt) + thetal(i,kt+1)) / 2. end do alpha2(i,1) = 0.61 * (thetal(i,1) + (thetal(i,2)-thetal(i,1)) * (zt(i,2) - znt(i)) / (zm(i,2) - znt(i))) alpha2(i,kte) = 0.61 * thetal(i,kte) beta2(i,1) = (100000. / p2di(i,1))**0.286 * 2.45e-6 / & 1004.67 - 1.61 * (thetal(i,1) + (thetal(i,2) - thetal(i,1)) & * (zt(i,2) - znt(i)) / (zm(i,2) - znt(i))) beta2(i,kte) = (100000. / p2di(i,kte))**0.286 * 2.45e-6 / 1004.67 - 1.61 * thetal(i,kte) if ( is_convective ) then ! Activate EDMF components do kt = 1,kte-1 MFCthv(i,kt) = (1. + 0.61 * (qtup_temfx(i,kt)+qtup_temfx(i,kt+1))) / 2. * MFCth(i,kt) + & alpha2(i,kt) * MFCq(i,kt) + beta2(i,kt) * MFCql(i,kt) end do MFCthv(i,kte) = 0. else ! No MF components do kt = 1,kte MFCthv(i,kt) = 0. end do end if do kt = 1,kte THVF(i,kt) = (1. + 0.61 * qt(i,kt)) * Fz(i,kt) + alpha2(i,kt) * QFK(i,kt) + MFCthv(i,kt) end do ! Update mean variables: ! This is done with implicit solver for diffusion part followed ! by explicit solution for MF terms. ! Note that Coriolis terms that were source terms for u and v ! in Matlab code are now handled by WRF outside this PBL context. u_new(i,:) = u_temf(i,:) call solve_implicit_temf(km(i,kts:kte-1),u_new(i,kts+1:kte), & uw_temfx(i,1),dzm(i,kts:kte-1),dzt(i,kts:kte-1),kts,kte-1,dt,.FALSE.) do k = 2,kte-1 u_new(i,k) = u_new(i,k) + dt * (-(MFCu(i,k)-MFCu(i,k-1))) / dzm(i,k) end do v_new(i,:) = v_temf(i,:) call solve_implicit_temf(km(i,kts:kte-1),v_new(i,kts+1:kte), & vw_temfx(i,1),dzm(i,kts:kte-1),dzt(i,kts:kte-1),kts,kte-1,dt,.FALSE.) do k = 2,kte-1 v_new(i,k) = v_new(i,k) + dt * (-(MFCv(i,k)-MFCv(i,k-1))) / dzm(i,k) end do call solve_implicit_temf(kh(i,kts:kte-1),thetal(i,kts+1:kte),Fz(i,1),dzm(i,kts:kte-1),& dzt(i,kts:kte-1),kts,kte-1,dt,.FALSE.) do k = 2,kte-1 thetal(i,k) = thetal(i,k) + dt * (-(MFCth(i,k)-MFCth(i,k-1))) / dzm(i,k) end do call solve_implicit_temf(kh(i,kts:kte-1),qt(i,kts+1:kte),QFK(i,1),dzm(i,kts:kte-1),& dzt(i,kts:kte-1),kts,kte-1,dt,.FALSE.) do k = 2,kte-1 qt(i,k) = qt(i,k) + dt * (-(MFCq(i,k)-MFCq(i,k-1))) / dzm(i,k) end do ! Stepping TE forward is a bit more complicated te_temfx(i,1) = ust(i)**2. / ftau(i,1) * (1. + ratio(i,1)) if ( is_convective ) then ! WA currently disabled if MFopt=false, is that right? convection_TKE_surface_src(i) = 2. * beta(i,1) * shf_temfx(i,1) else convection_TKE_surface_src(i) = 0. end if te_temfx(i,1) = max(te_temfx(i,1), & (leps(i,1) / Cgamma * (ust(i)**2. * S(i,1) + convection_TKE_surface_src(i)))**(2./3.)) if (te_temfx(i,1) > 20.0) then te_temfx(i,1) = 20.0 ! WA 9/28/11 limit max TE end if sfcFTE(i) = -(km(i,1)+km(i,2)) / 2. * (te_temfx(i,2)-te_temfx(i,1)) / dzm(i,2) do kt = 1,kte if (THVF(i,kt) >= 0) then buoy_src(i,kt) = 2. * g / thetav(i,kt) * THVF(i,kt) else buoy_src(i,kt) = 0. ! Cancel buoyancy term when locally stable end if srcs(i,kt) = -uw_temfx(i,kt) * dudz(i,kt) - vw_temfx(i,kt) * dvdz(i,kt) - & Cgamma * te_temfx(i,kt)**1.5 * linv(i,kt) + buoy_src(i,kt) end do call solve_implicit_temf((km(i,kts:kte-1)+km(i,kts+1:kte))/2.0, & te_temfx(i,kts+1:kte),sfcFTE(i),dzt(i,kts+1:kte),dzt(i,kts:kte-1),kts,kte-1,dt,.false.) do kt = 2,kte-1 te_temfx(i,kt) = te_temfx(i,kt) + dt * srcs(i,kt) te_temfx(i,kt) = te_temfx(i,kt) + dt * (-(MFCTE(i,kt)-MFCTE(i,kt-1))) / dzt(i,kt) if (te_temfx(i,kt) < TEmin) te_temfx(i,kt) = TEmin end do te_temfx(i,kte) = 0.0 do kt = 2,kte-1 if (te_temfx(i,kt) > 20.0) then te_temfx(i,kt) = 20.0 ! WA 9/29/11 reduce limit max TE from 30 end if end do ! Done with updates, now convert internal variables back to WRF vars do k = kts,kte ! Populate kh_temfx, km_temfx from kh, km kh_temfx(i,k) = kh(i,k) km_temfx(i,k) = km(i,k) end do ! Convert thetal, qt back to theta, qv, qc ! See opposite conversion at top of subroutine ! WA this accounts for offset of indexing between ! WRF and TEMF, see notes at top of this routine. call thlqt2thqvqc(thetal(i,kts+1:kte),qt(i,kts+1:kte), & thx_new(i,kts:kte-1),qvx_new(i,kts:kte-1),qcx_new(i,kts:kte-1), & p2d(i,kts:kte-1),pi2d(i,kts:kte-1),kts,kte-1,ep2,xlv,cp) do k = kts,kte-1 ! Calculate tendency terms ! WA this accounts for offset of indexing between ! WRF and TEMF, see notes at top of this routine. rubltenx(i,k) = (u_new(i,k+1) - u_temf(i,k+1)) / dt rvbltenx(i,k) = (v_new(i,k+1) - v_temf(i,k+1)) / dt rthbltenx(i,k) = (thx_new(i,k) - thx(i,k)) / dt rqvbltenx(i,k) = (qvx_new(i,k) - qvx(i,k)) / dt rqcbltenx(i,k) = (qcx_new(i,k) - qcx(i,k)) / dt end do rubltenx(i,kte) = 0. rvbltenx(i,kte) = 0. rthbltenx(i,kte) = 0. rqvbltenx(i,kte) = 0. rqcbltenx(i,kte) = 0. ! Populate surface exchange coefficient variables to go back out ! for next time step of surface scheme ! WA 2/16/11 removed, not needed in BL ! Populate 10 m winds and 2 m temp ! WA Note this only works if first mass level is above 10 m u10(i) = u_new(i,2) * log(10.0/znt(i)) / log(zm(i,2)/znt(i)) v10(i) = v_new(i,2) * log(10.0/znt(i)) / log(zm(i,2)/znt(i)) t2(i) = (tsk(i)/pi2d(i,1) + (thx_new(i,1) - tsk(i)/pi2d(i,1)) * log(2.0/z0t(i)) / log(zm(i,2)/z0t(i))) * pi2d(i,1) ! WA this should also use pi at z0 ! Populate diagnostic variables hd_temfx(i) = hd(i) lcl_temfx(i) = lcl(i) hct_temfx(i) = hct(i) ! Send updraft liquid water back if ( is_convective) then do k = kts,kte-1 qlup_temfx(i,k) = qlUPD(i,k) end do else qlup_temfx(i,1) = qcx(i,1) do k = kts+1,kte-1 qlup_temfx(i,k) = qcx(i,k-1) end do end if qlup_temfx(i,kte) = qcx(i,kte) end do ! Main (i) loop end subroutine temf2d ! !-------------------------------------------------------------------- ! subroutine thlqt2thqvqc(thetal,qt,theta,qv,qc,p,piex,kbot,ktop,ep2,Lv,Cp) ! Calculates theta, qv, qc from thetal, qt. ! Originally from RAMS (subroutine satadjst) by way of Hongli Jiang. implicit none integer, intent(in ) :: kbot, ktop real, dimension( kbot:ktop ), intent(in ) :: thetal, qt real, dimension( kbot:ktop ), intent( out) :: theta, qv, qc real, dimension( kbot:ktop ), intent(in ) :: p, piex real, intent(in ) :: ep2, Lv, Cp ! ! Local variables integer :: k, iterate real :: T1, Tt real, dimension( kbot:ktop) :: rst real, dimension( kbot:ktop) :: Tair, rc, rt, rv ! do k = kbot,ktop T1 = thetal(k) * piex(k) ! First guess T is just thetal converted to T Tair(k) = T1 rt(k) = qt(k) / (1. - qt(k)) do iterate = 1,20 rst(k) = rsat(p(k),Tair(k),ep2) rc(k) = max(rt(k) - rst(k), 0.) Tt = 0.7*Tair(k) + 0.3*T1 * (1.+Lv*rc(k) / (Cp*max(Tair(k),253.))) if ( abs(Tt - Tair(k)) < 0.001) GOTO 100 Tair(k) = Tt end do 100 continue rv(k) = rt(k) - rc(k) qv(k) = rv(k) / (1. + rv(k)) qc(k) = rc(k) / (1. + rc(k)) theta(k) = Tair(k) / piex(k) end do ! k loop return end subroutine thlqt2thqvqc ! !-------------------------------------------------------------------- ! subroutine findhct_te( thetavenv,thetaparin,qpar, & rpar,hdidx,paridx,zm,hct,hctidx,p,piex,ep2,kbot,ktop) ! Calculates the cloud top height (limit of convection) for the ! updraft properties. hct is the level at which a parcel lifted ! at the moist adiabatic rate where it is saturated and at the dry ! adiabatic rate otherwise, first has thetav cooler than the environment. ! Loops start at LCL (paridx). implicit none integer, intent(in) :: kbot, ktop integer, intent(in) :: paridx, hdidx real, intent(in) :: ep2 real, dimension( kbot:ktop), intent(in) :: thetavenv real, dimension( kbot:ktop), intent(in) :: thetaparin real, dimension( kbot:ktop), intent(in) :: qpar, rpar, zm, p, piex real, intent(out) :: hct integer, intent(out) :: hctidx ! Local variables integer k real, dimension( kbot:ktop) :: thetapar, thetavpar, qlpar, Tpar, rsatpar real, dimension( kbot:ktop) :: qsatpar real :: gammas, TparC thetapar(paridx) = thetaparin(paridx) Tpar(paridx) = thetapar(paridx) * piex(paridx) hctidx = ktop ! In case hct not found do k = paridx+1,ktop ! Find saturation mixing ratio at parcel temperature rsatpar(k) = rsat(p(k-1),Tpar(k-1),ep2) qsatpar(k) = rsatpar(k) / (1. + rsatpar(k)) ! When parcel is unsaturated, its temperature changes ! at dry adiabatic rate (in other words, theta is constant). if (rpar(k) <= rsatpar(k)) then thetapar(k) = thetapar(k-1) Tpar(k) = thetapar(k) * piex(k) thetavpar(k) = thetapar(k) * (1.+0.608*qpar(k)) else ! When parcel is saturated, its temperature changes at ! moist adiabatic rate ! Calculate moist adiabatic lapse rate according to Gill A4.12 ! Requires T in deg.C TparC = Tpar(k-1) - 273.15 gammas = 6.4 - 0.12 * TparC + 2.5e-5 * TparC**3. + (-2.4 + 1.e-3 * (TparC-5.)**2.) * (1. - p(k-1)/100000.) Tpar(k) = Tpar(k-1) - gammas/1000. * (zm(k)-zm(k-1)) thetapar(k) = Tpar(k) / piex(k) qlpar(k) = qpar(k) - qsatpar(k) ! Liquid water in parcel thetavpar(k) = thetapar(k) * (1. + 0.608 * qsatpar(k) - qlpar(k)) end if if (thetavenv(k) >= thetavpar(k)) then hctidx = k goto 1000 end if end do 1000 hct = zm(hctidx) return end subroutine findhct_te ! !-------------------------------------------------------------------- ! real function rsat(p,T,ep2) ! Calculates the saturation mixing ratio with respect to liquid water ! Arguments are pressure (Pa) and absolute temperature (K) ! Uses the formula from the ARM intercomparison setup. ! Converted from Matlab by WA 7/28/08 implicit none real p, T, ep2 real temp, x real, parameter :: c0 = 0.6105851e+3 real, parameter :: c1 = 0.4440316e+2 real, parameter :: c2 = 0.1430341e+1 real, parameter :: c3 = 0.2641412e-1 real, parameter :: c4 = 0.2995057e-3 real, parameter :: c5 = 0.2031998e-5 real, parameter :: c6 = 0.6936113e-8 real, parameter :: c7 = 0.2564861e-11 real, parameter :: c8 = -0.3704404e-13 temp = T - 273.15 x =c0+temp*(c1+temp*(c2+temp*(c3+temp*(c4+temp*(c5+temp*(c6+temp*(c7+temp*c8))))))) rsat = ep2*x/(p-x) return end function rsat ! !-------------------------------------------------------------------- ! subroutine solve_implicit_temf(Khlf,psi_n,srf_flux,dzm,dzt,kbot,ktop,dt,print_flag) ! Implicit solution of vertical diffusion for conserved variable ! psi given diffusivity Khlf on turbulence levels, ! and surface flux srf_flux. ! dzm is delta_z of mass levels, dzt is delta_z of turbulence levels. ! dt is timestep (s). implicit none integer :: kbot, ktop logical :: print_flag real :: srf_flux, dt real, dimension( kbot:ktop ), intent(in ) :: Khlf real, dimension( kbot:ktop ), intent(in ) :: dzm, dzt real, dimension( kbot:ktop ), intent(inout) :: psi_n ! ! Local variables integer :: k real, dimension( kbot:ktop ) :: AU, BU, CU, YU ! AU(kbot) = Khlf(kbot) / (dzm(kbot)*dzt(kbot)) BU(kbot) = -1.0/dt - Khlf(kbot+1)/(dzm(kbot+1)*dzt(kbot+1)) CU(kbot) = Khlf(kbot+1)/(dzm(kbot)*dzt(kbot+1)) YU(kbot) = -psi_n(kbot)/dt - srf_flux/dzm(kbot) do k = kbot+1,ktop-1 ! Subdiagonal (A) vector AU(k) = Khlf(k) / (dzm(k) * dzt(k)) ! Main diagonal (B) vector BU(k) = -1.0/dt - (Khlf(k)/dzt(k) + Khlf(k+1)/dzt(k+1)) / dzm(k) ! Superdiagonal (C) vector CU(k) = Khlf(k+1) / (dzm(k)*dzt(k+1)) ! Result vector YU(k) = -psi_n(k)/dt end do ! k loop AU(ktop) = 0. BU(ktop) = -1.0 / dt YU(ktop) = -psi_n(ktop) / dt ! Compute result with tridiagonal routine psi_n = trid(AU,BU,CU,YU,kbot,ktop) return end subroutine solve_implicit_temf ! !-------------------------------------------------------------------- ! function trid(a,b,c,r,kbot,ktop) ! Solves tridiagonal linear system. ! Inputs are subdiagonal vector a, main diagonal b, superdiagonal c, ! result r, column top and bottom indices kbot and ktop. ! Originally from Numerical Recipes section 2.4. implicit none real, dimension( kbot:ktop ) :: trid integer :: kbot, ktop real, dimension( kbot:ktop ), intent(in ) :: a, b, c, r ! ! Local variables integer :: k real :: bet real, dimension( kbot:ktop ) :: gam, u ! bet = b(kbot) u(kbot) = r(kbot) / bet do k = kbot+1,ktop gam(k) = c(k-1) / bet bet = b(k) - a(k)*gam(k) u(k) = (r(k) - a(k)*u(k-1)) / bet end do do k = ktop-1,kbot,-1 u(k) = u(k) - gam(k+1)*u(k+1) end do trid = u return end function trid ! !-------------------------------------------------------------------- ! subroutine temfinit(rublten,rvblten,rthblten,rqvblten, & rqcblten,rqiblten,p_qi,p_first_scalar, & restart, allowed_to_read, & te_temf, cf3d_temf, & ids, ide, jds, jde, kds, kde, & ims, ime, jms, jme, kms, kme, & its, ite, jts, jte, kts, kte ) !------------------------------------------------------------------- implicit none !------------------------------------------------------------------- ! logical , intent(in) :: restart, allowed_to_read integer , intent(in) :: ids, ide, jds, jde, kds, kde, & ims, ime, jms, jme, kms, kme, & its, ite, jts, jte, kts, kte integer , intent(in) :: p_qi,p_first_scalar real , dimension( ims:ime , kms:kme , jms:jme ), intent(out) :: & rublten, & rvblten, & rthblten, & rqvblten, & rqcblten, & rqiblten, & te_temf, & cf3d_temf ! Local variables integer :: i, j, k, itf, jtf, ktf real, parameter :: TEmin = 1e-3 ! jtf = min0(jte,jde-1) ktf = min0(kte,kde-1) itf = min0(ite,ide-1) ! if(.not.restart)then do j = jts,jtf do k = kts,ktf do i = its,itf rublten(i,k,j) = 0. rvblten(i,k,j) = 0. rthblten(i,k,j) = 0. rqvblten(i,k,j) = 0. rqcblten(i,k,j) = 0. te_temf(i,k,j) = TEmin cf3d_temf(i,k,j) = 0. enddo enddo enddo endif ! if (p_qi .ge. p_first_scalar .and. .not.restart) then do j = jts,jtf do k = kts,ktf do i = its,itf rqiblten(i,k,j) = 0. enddo enddo enddo endif ! end subroutine temfinit !------------------------------------------------------------------- end module module_bl_temf
gpl-2.0
decvalts/wrf
external/fftpack/fftpack5/mradb4.F
1
4215
subroutine mradb4 ( m, ido, l1, cc, im1, in1, ch, im2, in2, wa1, wa2, wa3 ) !*****************************************************************************80 ! !! MRADB4 is an FFTPACK5 auxiliary routine. ! ! License: ! ! Licensed under the GNU General Public License (GPL). ! Copyright (C) 1995-2004, Scientific Computing Division, ! University Corporation for Atmospheric Research ! ! Modified: ! ! 27 March 2009 ! ! Author: ! ! Paul Swarztrauber ! Richard Valent ! ! Reference: ! ! Paul Swarztrauber, ! Vectorizing the Fast Fourier Transforms, ! in Parallel Computations, ! edited by G. Rodrigue, ! Academic Press, 1982. ! ! Paul Swarztrauber, ! Fast Fourier Transform Algorithms for Vector Computers, ! Parallel Computing, pages 45-63, 1984. ! ! Parameters: ! implicit none integer ( kind = 4 ) ido integer ( kind = 4 ) in1 integer ( kind = 4 ) in2 integer ( kind = 4 ) l1 real ( kind = 4 ) cc(in1,ido,4,l1) real ( kind = 4 ) ch(in2,ido,l1,4) integer ( kind = 4 ) i integer ( kind = 4 ) ic integer ( kind = 4 ) idp2 integer ( kind = 4 ) im1 integer ( kind = 4 ) im2 integer ( kind = 4 ) k integer ( kind = 4 ) m integer ( kind = 4 ) m1 integer ( kind = 4 ) m1d integer ( kind = 4 ) m2 integer ( kind = 4 ) m2s real ( kind = 4 ) sqrt2 real ( kind = 4 ) wa1(ido) real ( kind = 4 ) wa2(ido) real ( kind = 4 ) wa3(ido) m1d = ( m - 1 ) * im1 + 1 m2s = 1 - im2 sqrt2 = sqrt ( 2.0E+00 ) do k = 1, l1 m2 = m2s do m1 = 1, m1d, im1 m2 = m2 + im2 ch(m2,1,k,3) = (cc(m1,1,1,k)+cc(m1,ido,4,k)) & -(cc(m1,ido,2,k)+cc(m1,ido,2,k)) ch(m2,1,k,1) = (cc(m1,1,1,k)+cc(m1,ido,4,k)) & +(cc(m1,ido,2,k)+cc(m1,ido,2,k)) ch(m2,1,k,4) = (cc(m1,1,1,k)-cc(m1,ido,4,k)) & +(cc(m1,1,3,k)+cc(m1,1,3,k)) ch(m2,1,k,2) = (cc(m1,1,1,k)-cc(m1,ido,4,k)) & -(cc(m1,1,3,k)+cc(m1,1,3,k)) end do end do if ( ido < 2 ) then return end if if ( 2 < ido ) then idp2 = ido + 2 do k = 1, l1 do i = 3, ido, 2 ic = idp2 - i m2 = m2s do m1 = 1, m1d, im1 m2 = m2 + im2 ch(m2,i-1,k,1) = (cc(m1,i-1,1,k)+cc(m1,ic-1,4,k)) & +(cc(m1,i-1,3,k)+cc(m1,ic-1,2,k)) ch(m2,i,k,1) = (cc(m1,i,1,k)-cc(m1,ic,4,k)) & +(cc(m1,i,3,k)-cc(m1,ic,2,k)) ch(m2,i-1,k,2) = wa1(i-2)*((cc(m1,i-1,1,k)-cc(m1,ic-1,4,k)) & -(cc(m1,i,3,k)+cc(m1,ic,2,k)))-wa1(i-1) & *((cc(m1,i,1,k)+cc(m1,ic,4,k))+(cc(m1,i-1,3,k)-cc(m1,ic-1,2,k))) ch(m2,i,k,2) = wa1(i-2)*((cc(m1,i,1,k)+cc(m1,ic,4,k)) & +(cc(m1,i-1,3,k)-cc(m1,ic-1,2,k))) + wa1(i-1) & *((cc(m1,i-1,1,k)-cc(m1,ic-1,4,k))-(cc(m1,i,3,k)+cc(m1,ic,2,k))) ch(m2,i-1,k,3) = wa2(i-2)*((cc(m1,i-1,1,k)+cc(m1,ic-1,4,k)) & -(cc(m1,i-1,3,k)+cc(m1,ic-1,2,k))) - wa2(i-1) & *((cc(m1,i,1,k)-cc(m1,ic,4,k))-(cc(m1,i,3,k)-cc(m1,ic,2,k))) ch(m2,i,k,3) = wa2(i-2)*((cc(m1,i,1,k)-cc(m1,ic,4,k)) & -(cc(m1,i,3,k)-cc(m1,ic,2,k))) + wa2(i-1) & *((cc(m1,i-1,1,k)+cc(m1,ic-1,4,k))-(cc(m1,i-1,3,k) & +cc(m1,ic-1,2,k))) ch(m2,i-1,k,4) = wa3(i-2)*((cc(m1,i-1,1,k)-cc(m1,ic-1,4,k)) & +(cc(m1,i,3,k)+cc(m1,ic,2,k))) - wa3(i-1) & *((cc(m1,i,1,k)+cc(m1,ic,4,k))-(cc(m1,i-1,3,k)-cc(m1,ic-1,2,k))) ch(m2,i,k,4) = wa3(i-2)*((cc(m1,i,1,k)+cc(m1,ic,4,k)) & -(cc(m1,i-1,3,k)-cc(m1,ic-1,2,k))) + wa3(i-1) & *((cc(m1,i-1,1,k)-cc(m1,ic-1,4,k))+(cc(m1,i,3,k)+cc(m1,ic,2,k))) end do end do end do if ( mod ( ido, 2 ) == 1 ) then return end if end if do k = 1, l1 m2 = m2s do m1 = 1, m1d, im1 m2 = m2 + im2 ch(m2,ido,k,1) = (cc(m1,ido,1,k)+cc(m1,ido,3,k)) & +(cc(m1,ido,1,k)+cc(m1,ido,3,k)) ch(m2,ido,k,2) = sqrt2*((cc(m1,ido,1,k)-cc(m1,ido,3,k)) & -(cc(m1,1,2,k)+cc(m1,1,4,k))) ch(m2,ido,k,3) = (cc(m1,1,4,k)-cc(m1,1,2,k)) & +(cc(m1,1,4,k)-cc(m1,1,2,k)) ch(m2,ido,k,4) = -sqrt2*((cc(m1,ido,1,k)-cc(m1,ido,3,k)) & +(cc(m1,1,2,k)+cc(m1,1,4,k))) end do end do return end
gpl-2.0
the-linix-project/linix-kernel-source
gccsrc/gcc-4.7.2/gcc/testsuite/gfortran.dg/g77/19990826-1.f
210
8631
c { dg-do compile } * Date: Tue, 24 Aug 1999 12:25:41 +1200 (NZST) * From: Jonathan Ravens <ravens@whio.gns.cri.nz> * To: gcc-bugs@gcc.gnu.org * Subject: g77 bug report * X-UIDL: a0bf5ecc21487cde48d9104983ab04d6 ! This fortran source will not compile - if the penultimate elseif block is 0 ! included then the message appears : ! ! /usr/src/egcs//gcc-2.95.1/gcc/f/stw.c:308: failed assertion `b->uses_ > 0' ! g77: Internal compiler error: program f771 got fatal signal 6 ! ! The command was : g77 -c <prog.f> ! ! The OS is Red Hat 6, and the output from uname -a is ! Linux grfw1452.gns.cri.nz 2.2.5-15 #1 Mon Apr 19 23:00:46 EDT 1999 i686 unknown ! ! The configure script I used was ! /usr/src/egcs/gcc/gcc-2.95.1/configure --enable-languages=f77 i585-unknown-linux ! ! I was installing 2.95 because under EGCS 2.1.1 none of my code was working ! with optimisation turned on, and there were still bugs with no optimisation ! (all of which code works fine under g77 0.5.21 and Sun/IBM/Dec/HP fortrans). ! ! The version of g77 is : ! !g77 version 2.95.1 19990816 (release) (from FSF-g77 version 0.5.25 19990816 (release)) program main if (i.eq.1) then call abc(1) else if (i.eq. 1) then call abc( 1) else if (i.eq. 2) then call abc( 2) else if (i.eq. 3) then call abc( 3) else if (i.eq. 4) then call abc( 4) else if (i.eq. 5) then call abc( 5) else if (i.eq. 6) then call abc( 6) else if (i.eq. 7) then call abc( 7) else if (i.eq. 8) then call abc( 8) else if (i.eq. 9) then call abc( 9) else if (i.eq. 10) then call abc( 10) else if (i.eq. 11) then call abc( 11) else if (i.eq. 12) then call abc( 12) else if (i.eq. 13) then call abc( 13) else if (i.eq. 14) then call abc( 14) else if (i.eq. 15) then call abc( 15) else if (i.eq. 16) then call abc( 16) else if (i.eq. 17) then call abc( 17) else if (i.eq. 18) then call abc( 18) else if (i.eq. 19) then call abc( 19) else if (i.eq. 20) then call abc( 20) else if (i.eq. 21) then call abc( 21) else if (i.eq. 22) then call abc( 22) else if (i.eq. 23) then call abc( 23) else if (i.eq. 24) then call abc( 24) else if (i.eq. 25) then call abc( 25) else if (i.eq. 26) then call abc( 26) else if (i.eq. 27) then call abc( 27) else if (i.eq. 28) then call abc( 28) else if (i.eq. 29) then call abc( 29) else if (i.eq. 30) then call abc( 30) else if (i.eq. 31) then call abc( 31) else if (i.eq. 32) then call abc( 32) else if (i.eq. 33) then call abc( 33) else if (i.eq. 34) then call abc( 34) else if (i.eq. 35) then call abc( 35) else if (i.eq. 36) then call abc( 36) else if (i.eq. 37) then call abc( 37) else if (i.eq. 38) then call abc( 38) else if (i.eq. 39) then call abc( 39) else if (i.eq. 40) then call abc( 40) else if (i.eq. 41) then call abc( 41) else if (i.eq. 42) then call abc( 42) else if (i.eq. 43) then call abc( 43) else if (i.eq. 44) then call abc( 44) else if (i.eq. 45) then call abc( 45) else if (i.eq. 46) then call abc( 46) else if (i.eq. 47) then call abc( 47) else if (i.eq. 48) then call abc( 48) else if (i.eq. 49) then call abc( 49) else if (i.eq. 50) then call abc( 50) else if (i.eq. 51) then call abc( 51) else if (i.eq. 52) then call abc( 52) else if (i.eq. 53) then call abc( 53) else if (i.eq. 54) then call abc( 54) else if (i.eq. 55) then call abc( 55) else if (i.eq. 56) then call abc( 56) else if (i.eq. 57) then call abc( 57) else if (i.eq. 58) then call abc( 58) else if (i.eq. 59) then call abc( 59) else if (i.eq. 60) then call abc( 60) else if (i.eq. 61) then call abc( 61) else if (i.eq. 62) then call abc( 62) else if (i.eq. 63) then call abc( 63) else if (i.eq. 64) then call abc( 64) else if (i.eq. 65) then call abc( 65) else if (i.eq. 66) then call abc( 66) else if (i.eq. 67) then call abc( 67) else if (i.eq. 68) then call abc( 68) else if (i.eq. 69) then call abc( 69) else if (i.eq. 70) then call abc( 70) else if (i.eq. 71) then call abc( 71) else if (i.eq. 72) then call abc( 72) else if (i.eq. 73) then call abc( 73) else if (i.eq. 74) then call abc( 74) else if (i.eq. 75) then call abc( 75) else if (i.eq. 76) then call abc( 76) else if (i.eq. 77) then call abc( 77) else if (i.eq. 78) then call abc( 78) else if (i.eq. 79) then call abc( 79) else if (i.eq. 80) then call abc( 80) else if (i.eq. 81) then call abc( 81) else if (i.eq. 82) then call abc( 82) else if (i.eq. 83) then call abc( 83) else if (i.eq. 84) then call abc( 84) else if (i.eq. 85) then call abc( 85) else if (i.eq. 86) then call abc( 86) else if (i.eq. 87) then call abc( 87) else if (i.eq. 88) then call abc( 88) else if (i.eq. 89) then call abc( 89) else if (i.eq. 90) then call abc( 90) else if (i.eq. 91) then call abc( 91) else if (i.eq. 92) then call abc( 92) else if (i.eq. 93) then call abc( 93) else if (i.eq. 94) then call abc( 94) else if (i.eq. 95) then call abc( 95) else if (i.eq. 96) then call abc( 96) else if (i.eq. 97) then call abc( 97) else if (i.eq. 98) then call abc( 98) else if (i.eq. 99) then call abc( 99) else if (i.eq. 100) then call abc( 100) else if (i.eq. 101) then call abc( 101) else if (i.eq. 102) then call abc( 102) else if (i.eq. 103) then call abc( 103) else if (i.eq. 104) then call abc( 104) else if (i.eq. 105) then call abc( 105) else if (i.eq. 106) then call abc( 106) else if (i.eq. 107) then call abc( 107) else if (i.eq. 108) then call abc( 108) else if (i.eq. 109) then call abc( 109) else if (i.eq. 110) then call abc( 110) else if (i.eq. 111) then call abc( 111) else if (i.eq. 112) then call abc( 112) else if (i.eq. 113) then call abc( 113) else if (i.eq. 114) then call abc( 114) else if (i.eq. 115) then call abc( 115) else if (i.eq. 116) then call abc( 116) else if (i.eq. 117) then call abc( 117) else if (i.eq. 118) then call abc( 118) else if (i.eq. 119) then call abc( 119) else if (i.eq. 120) then call abc( 120) else if (i.eq. 121) then call abc( 121) else if (i.eq. 122) then call abc( 122) else if (i.eq. 123) then call abc( 123) else if (i.eq. 124) then call abc( 124) else if (i.eq. 125) then !< Miscompiles if present call abc( 125) !< c else if (i.eq. 126) then c call abc( 126) endif end
bsd-2-clause
embecosm/epiphany-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
jwakely/gcc
gcc/testsuite/gfortran.dg/unlimited_polymorphic_18.f90
19
1583
! { dg-do run } ! Testing fix for ! PR fortran/60414 ! module m implicit none Type T real, public :: expectedScalar; contains procedure :: FCheck procedure :: FCheckArr generic :: Check => FCheck, FCheckArr end Type contains subroutine FCheck(this,X) class(T) this class(*) X real :: r select type (X) type is (real) if ( abs (X - this%expectedScalar) > 0.0001 ) then STOP 1 end if class default STOP 2 end select end subroutine FCheck subroutine FCheckArr(this,X) class(T) this class(*) X(:) integer i do i = 1,6 this%expectedScalar = i - 1.0 call this%FCheck(X(i)) end do end subroutine FCheckArr subroutine CheckTextVector(vec, n, scal) integer, intent(in) :: n class(*), intent(in) :: vec(n) class(*), intent(in) :: scal integer j Type(T) :: Tester ! Check full vector call Tester%Check(vec) ! Check a scalar of the same class like the vector Tester%expectedScalar = 5.0 call Tester%Check(scal) ! Check an element of the vector, which is a scalar j=3 Tester%expectedScalar = 2.0 call Tester%Check(vec(j)) end subroutine CheckTextVector end module program test use :: m implicit none real :: vec(1:6) = (/ 0, 1, 2, 3, 4, 5 /) call checktextvector(vec, 6, 5.0) end program test
gpl-2.0
jwakely/gcc
gcc/testsuite/gfortran.dg/direct_io_5.f90
19
1087
! { dg-do run } ! PR27757 Problems with direct access I/O ! This test checks a series of random writes followed by random reads. ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org> program testdirect implicit none integer, dimension(100) :: a integer :: i,j,k,ier real :: x data a / 13, 9, 34, 41, 25, 98, 6, 12, 11, 44, 79, 3,& & 64, 61, 77, 57, 59, 2, 92, 38, 71, 64, 31, 60, 28, 90, 26,& & 97, 47, 26, 48, 96, 95, 82, 100, 90, 45, 71, 71, 67, 72,& & 76, 94, 49, 85, 45, 100, 22, 96, 48, 13, 23, 40, 14, 76, 99,& & 96, 90, 65, 2, 8, 60, 96, 19, 45, 1, 100, 48, 91, 20, 92,& & 72, 81, 59, 24, 37, 43, 21, 54, 68, 31, 19, 79, 63, 41,& & 42, 12, 10, 62, 43, 9, 30, 9, 54, 35, 4, 5, 55, 3, 94 / open(unit=15,file="testdirectio",access="direct",form="unformatted",recl=89) do i=1,100 k = a(i) write(unit=15, rec=k) k enddo do j=1,100 read(unit=15, rec=a(j), iostat=ier) k if (ier.ne.0) then STOP 1 else if (a(j) /= k) STOP 2 endif enddo close(unit=15, status="delete") end program testdirect
gpl-2.0
rgvanwesep/exciting-plus-rgvw-mod
src/phonon.f90
5
4754
! Copyright (C) 2002-2008 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl. ! This file is distributed under the terms of the GNU General Public License. ! See the file COPYING for license details. subroutine phonon use modmain use modqpt implicit none ! local variables integer is,js,ia,ja,ka,jas,kas integer iq,ip,jp,nph,iph,i real(8) dph,a,b,t1 real(8) ftp(3,maxatoms,maxspecies) complex(8) zt1,zt2 complex(8) dyn(3,maxatoms,maxspecies) ! allocatable arrays real(8), allocatable :: veffmtp(:,:,:) real(8), allocatable :: veffirp(:) complex(8), allocatable :: dveffmt(:,:,:) complex(8), allocatable :: dveffir(:) !------------------------! ! initialisation ! !------------------------! ! require forces tforce=.true. ! no primitive cell determination primcell=.false. ! initialise universal variables call init0 ! initialise q-point dependent variables call init2 ! read original effective potential from file and store in global arrays call readstate if (allocated(veffmt0)) deallocate(veffmt0) allocate(veffmt0(lmmaxvr,nrmtmax,natmtot)) if (allocated(veffir0)) deallocate(veffir0) allocate(veffir0(ngrtot)) veffmt0(:,:,:)=veffmt(:,:,:) veffir0(:)=veffir(:) ! allocate local arrays allocate(dveffmt(lmmaxvr,nrcmtmax,natmtot)) allocate(dveffir(ngrtot)) ! switch off automatic determination of muffin-tin radii autormt=.false. ! no shifting of atomic basis allowed tshift=.false. ! determine k-point grid size from radkpt autokpt=.true. ! store original parameters natoms0(1:nspecies)=natoms(1:nspecies) natmtot0=natmtot avec0(:,:)=avec(:,:) ainv0(:,:)=ainv(:,:) atposc0(:,:,:)=0.d0 do is=1,nspecies do ia=1,natoms(is) atposc0(:,ia,is)=atposc(:,ia,is) end do end do ngrid0(:)=ngrid(:) ngrtot0=ngrtot !---------------------------------------! ! compute dynamical matrix rows ! !---------------------------------------! 10 continue natoms(1:nspecies)=natoms0(1:nspecies) ! find a dynamical matrix to calculate call dyntask(80,iq,is,ia,ip) if (iq.eq.0) then call readinput return end if ! phonon dry run if (task.eq.201) then close(80) goto 10 end if ! check to see if mass is considered infinite if (spmass(is).le.0.d0) then do ip=1,3 do js=1,nspecies do ja=1,natoms0(js) do jp=1,3 write(80,'(2G18.10," : is = ",I4,", ia = ",I4,", ip = ",I4)') 0.d0, & 0.d0,js,ja,jp end do end do end do end do close(80) goto 10 end if task=200 nph=1 if ((ivq(1,iq).eq.0).and.(ivq(2,iq).eq.0).and.(ivq(3,iq).eq.0)) nph=0 dyn(:,:,:)=0.d0 dveffmt(:,:,:)=0.d0 dveffir(:)=0.d0 ! loop over phases (cos and sin displacements) do iph=0,nph ! restore input values natoms(1:nspecies)=natoms0(1:nspecies) avec(:,:)=avec0(:,:) atposc(:,:,:)=atposc0(:,:,:) ! generate the supercell call phcell(iph,deltaph,iq,is,ia,ip) ! run the ground-state calculation call gndstate ! store the total force for the first displacement do js=1,nspecies do ja=1,natoms(js) jas=idxas(ja,js) ftp(:,ja,js)=forcetot(:,jas) end do end do ! store the effective potential for the first displacement allocate(veffmtp(lmmaxvr,nrmtmax,natmtot)) allocate(veffirp(ngrtot)) veffmtp(:,:,:)=veffmt(:,:,:) veffirp(:)=veffir(:) ! restore input values natoms(1:nspecies)=natoms0(1:nspecies) avec(:,:)=avec0(:,:) atposc(:,:,:)=atposc0(:,:,:) ! generate the supercell again with twice the displacement dph=deltaph+deltaph call phcell(iph,dph,iq,is,ia,ip) ! run the ground-state calculation again starting from the previous density task=1 call gndstate ! compute the complex perturbing effective potential with implicit q-phase call phdveff(iph,iq,veffmtp,veffirp,dveffmt,dveffir) deallocate(veffmtp,veffirp) ! Fourier transform the force differences to obtain the dynamical matrix zt1=1.d0/(dble(nphcell)*deltaph) ! multiply by i for sin-like displacement if (iph.eq.1) zt1=zt1*zi kas=0 do js=1,nspecies ka=0 do ja=1,natoms0(js) do i=1,nphcell ka=ka+1 kas=kas+1 t1=-dot_product(vqc(:,iq),vphcell(:,i)) zt2=zt1*cmplx(cos(t1),sin(t1),8) do jp=1,3 t1=-(forcetot(jp,kas)-ftp(jp,ka,js)) dyn(jp,ja,js)=dyn(jp,ja,js)+zt2*t1 end do end do end do end do end do ! write dynamical matrix row to file do js=1,nspecies do ja=1,natoms0(js) do jp=1,3 a=dble(dyn(jp,ja,js)) b=aimag(dyn(jp,ja,js)) if (abs(a).lt.1.d-12) a=0.d0 if (abs(b).lt.1.d-12) b=0.d0 write(80,'(2G18.10," : is = ",I4,", ia = ",I4,", ip = ",I4)') a,b,js,ja,jp end do end do end do close(80) ! write the complex perturbing effective potential to file call writedveff(iq,is,ia,ip,dveffmt,dveffir) ! delete the non-essential files call phdelete goto 10 end subroutine
gpl-3.0
rgvanwesep/exciting-plus-rgvw-mod
src/rdmwriteengy.f90
5
1093
! Copyright (C) 2007 J. K. Dewhurst, S. Sharma and E. K. U. Gross. ! This file is distributed under the terms of the GNU General Public License. ! See the file COPYING for license details. !BOP ! !ROUTINE: rdmwriteengy ! !INTERFACE: subroutine rdmwriteengy(fnum) ! !USES: use modrdm use modmain ! !INPUT/OUTPUT PARAMETERS: ! fnum : file number for writing output (in,integer) ! !DESCRIPTION: ! Writes all contributions to the total energy to file. ! ! !REVISION HISTORY: ! Created 2008 (Sharma) !EOP !BOC implicit none ! arguments integer, intent(in) :: fnum write(fnum,*) write(fnum,'("Energies :")') write(fnum,'(" electronic kinetic",T30,": ",G18.10)') engykn write(fnum,'(" core electron kinetic",T30,": ",G18.10)') engykncr write(fnum,'(" Coulomb",T30,": ",G18.10)') engyvcl write(fnum,'(" Madelung",T30,": ",G18.10)') engymad write(fnum,'(" exchange-correlation",T30,": ",G18.10)') engyx if (rdmtemp.gt.0.d0) then write(fnum,'(" entropy",T30,": ",G18.10)') rdmentrpy end if write(fnum,'(" total energy",T30,": ",G18.10)') engytot call flushifc(fnum) return end subroutine !EOC
gpl-3.0
quang-ha/lammps
lib/linalg/dlaed0.f
20
13894
*> \brief \b DLAED0 used by sstedc. Computes all eigenvalues and corresponding eigenvectors of an unreduced symmetric tridiagonal matrix using the divide and conquer method. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DLAED0 + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaed0.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaed0.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaed0.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DLAED0( ICOMPQ, QSIZ, N, D, E, Q, LDQ, QSTORE, LDQS, * WORK, IWORK, INFO ) * * .. Scalar Arguments .. * INTEGER ICOMPQ, INFO, LDQ, LDQS, N, QSIZ * .. * .. Array Arguments .. * INTEGER IWORK( * ) * DOUBLE PRECISION D( * ), E( * ), Q( LDQ, * ), QSTORE( LDQS, * ), * $ WORK( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DLAED0 computes all eigenvalues and corresponding eigenvectors of a *> symmetric tridiagonal matrix using the divide and conquer method. *> \endverbatim * * Arguments: * ========== * *> \param[in] ICOMPQ *> \verbatim *> ICOMPQ is INTEGER *> = 0: Compute eigenvalues only. *> = 1: Compute eigenvectors of original dense symmetric matrix *> also. On entry, Q contains the orthogonal matrix used *> to reduce the original matrix to tridiagonal form. *> = 2: Compute eigenvalues and eigenvectors of tridiagonal *> matrix. *> \endverbatim *> *> \param[in] QSIZ *> \verbatim *> QSIZ is INTEGER *> The dimension of the orthogonal matrix used to reduce *> the full matrix to tridiagonal form. QSIZ >= N if ICOMPQ = 1. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The dimension of the symmetric tridiagonal matrix. N >= 0. *> \endverbatim *> *> \param[in,out] D *> \verbatim *> D is DOUBLE PRECISION array, dimension (N) *> On entry, the main diagonal of the tridiagonal matrix. *> On exit, its eigenvalues. *> \endverbatim *> *> \param[in] E *> \verbatim *> E is DOUBLE PRECISION array, dimension (N-1) *> The off-diagonal elements of the tridiagonal matrix. *> On exit, E has been destroyed. *> \endverbatim *> *> \param[in,out] Q *> \verbatim *> Q is DOUBLE PRECISION array, dimension (LDQ, N) *> On entry, Q must contain an N-by-N orthogonal matrix. *> If ICOMPQ = 0 Q is not referenced. *> If ICOMPQ = 1 On entry, Q is a subset of the columns of the *> orthogonal matrix used to reduce the full *> matrix to tridiagonal form corresponding to *> the subset of the full matrix which is being *> decomposed at this time. *> If ICOMPQ = 2 On entry, Q will be the identity matrix. *> On exit, Q contains the eigenvectors of the *> tridiagonal matrix. *> \endverbatim *> *> \param[in] LDQ *> \verbatim *> LDQ is INTEGER *> The leading dimension of the array Q. If eigenvectors are *> desired, then LDQ >= max(1,N). In any case, LDQ >= 1. *> \endverbatim *> *> \param[out] QSTORE *> \verbatim *> QSTORE is DOUBLE PRECISION array, dimension (LDQS, N) *> Referenced only when ICOMPQ = 1. Used to store parts of *> the eigenvector matrix when the updating matrix multiplies *> take place. *> \endverbatim *> *> \param[in] LDQS *> \verbatim *> LDQS is INTEGER *> The leading dimension of the array QSTORE. If ICOMPQ = 1, *> then LDQS >= max(1,N). In any case, LDQS >= 1. *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is DOUBLE PRECISION array, *> If ICOMPQ = 0 or 1, the dimension of WORK must be at least *> 1 + 3*N + 2*N*lg N + 3*N**2 *> ( lg( N ) = smallest integer k *> such that 2^k >= N ) *> If ICOMPQ = 2, the dimension of WORK must be at least *> 4*N + N**2. *> \endverbatim *> *> \param[out] IWORK *> \verbatim *> IWORK is INTEGER array, *> If ICOMPQ = 0 or 1, the dimension of IWORK must be at least *> 6 + 6*N + 5*N*lg N. *> ( lg( N ) = smallest integer k *> such that 2^k >= N ) *> If ICOMPQ = 2, the dimension of IWORK must be at least *> 3 + 5*N. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit. *> < 0: if INFO = -i, the i-th argument had an illegal value. *> > 0: The algorithm failed to compute an eigenvalue while *> working on the submatrix lying in rows and columns *> INFO/(N+1) through mod(INFO,N+1). *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date December 2016 * *> \ingroup auxOTHERcomputational * *> \par Contributors: * ================== *> *> Jeff Rutter, Computer Science Division, University of California *> at Berkeley, USA * * ===================================================================== SUBROUTINE DLAED0( ICOMPQ, QSIZ, N, D, E, Q, LDQ, QSTORE, LDQS, $ WORK, IWORK, INFO ) * * -- LAPACK computational 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 .. INTEGER ICOMPQ, INFO, LDQ, LDQS, N, QSIZ * .. * .. Array Arguments .. INTEGER IWORK( * ) DOUBLE PRECISION D( * ), E( * ), Q( LDQ, * ), QSTORE( LDQS, * ), $ WORK( * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO, ONE, TWO PARAMETER ( ZERO = 0.D0, ONE = 1.D0, TWO = 2.D0 ) * .. * .. Local Scalars .. INTEGER CURLVL, CURPRB, CURR, I, IGIVCL, IGIVNM, $ IGIVPT, INDXQ, IPERM, IPRMPT, IQ, IQPTR, IWREM, $ J, K, LGN, MATSIZ, MSD2, SMLSIZ, SMM1, SPM1, $ SPM2, SUBMAT, SUBPBS, TLVLS DOUBLE PRECISION TEMP * .. * .. External Subroutines .. EXTERNAL DCOPY, DGEMM, DLACPY, DLAED1, DLAED7, DSTEQR, $ XERBLA * .. * .. External Functions .. INTEGER ILAENV EXTERNAL ILAENV * .. * .. Intrinsic Functions .. INTRINSIC ABS, DBLE, INT, LOG, MAX * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 * IF( ICOMPQ.LT.0 .OR. ICOMPQ.GT.2 ) THEN INFO = -1 ELSE IF( ( ICOMPQ.EQ.1 ) .AND. ( QSIZ.LT.MAX( 0, N ) ) ) THEN INFO = -2 ELSE IF( N.LT.0 ) THEN INFO = -3 ELSE IF( LDQ.LT.MAX( 1, N ) ) THEN INFO = -7 ELSE IF( LDQS.LT.MAX( 1, N ) ) THEN INFO = -9 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'DLAED0', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * SMLSIZ = ILAENV( 9, 'DLAED0', ' ', 0, 0, 0, 0 ) * * Determine the size and placement of the submatrices, and save in * the leading elements of IWORK. * IWORK( 1 ) = N SUBPBS = 1 TLVLS = 0 10 CONTINUE IF( IWORK( SUBPBS ).GT.SMLSIZ ) THEN DO 20 J = SUBPBS, 1, -1 IWORK( 2*J ) = ( IWORK( J )+1 ) / 2 IWORK( 2*J-1 ) = IWORK( J ) / 2 20 CONTINUE TLVLS = TLVLS + 1 SUBPBS = 2*SUBPBS GO TO 10 END IF DO 30 J = 2, SUBPBS IWORK( J ) = IWORK( J ) + IWORK( J-1 ) 30 CONTINUE * * Divide the matrix into SUBPBS submatrices of size at most SMLSIZ+1 * using rank-1 modifications (cuts). * SPM1 = SUBPBS - 1 DO 40 I = 1, SPM1 SUBMAT = IWORK( I ) + 1 SMM1 = SUBMAT - 1 D( SMM1 ) = D( SMM1 ) - ABS( E( SMM1 ) ) D( SUBMAT ) = D( SUBMAT ) - ABS( E( SMM1 ) ) 40 CONTINUE * INDXQ = 4*N + 3 IF( ICOMPQ.NE.2 ) THEN * * Set up workspaces for eigenvalues only/accumulate new vectors * routine * TEMP = LOG( DBLE( N ) ) / LOG( TWO ) LGN = INT( TEMP ) IF( 2**LGN.LT.N ) $ LGN = LGN + 1 IF( 2**LGN.LT.N ) $ LGN = LGN + 1 IPRMPT = INDXQ + N + 1 IPERM = IPRMPT + N*LGN IQPTR = IPERM + N*LGN IGIVPT = IQPTR + N + 2 IGIVCL = IGIVPT + N*LGN * IGIVNM = 1 IQ = IGIVNM + 2*N*LGN IWREM = IQ + N**2 + 1 * * Initialize pointers * DO 50 I = 0, SUBPBS IWORK( IPRMPT+I ) = 1 IWORK( IGIVPT+I ) = 1 50 CONTINUE IWORK( IQPTR ) = 1 END IF * * Solve each submatrix eigenproblem at the bottom of the divide and * conquer tree. * CURR = 0 DO 70 I = 0, SPM1 IF( I.EQ.0 ) THEN SUBMAT = 1 MATSIZ = IWORK( 1 ) ELSE SUBMAT = IWORK( I ) + 1 MATSIZ = IWORK( I+1 ) - IWORK( I ) END IF IF( ICOMPQ.EQ.2 ) THEN CALL DSTEQR( 'I', MATSIZ, D( SUBMAT ), E( SUBMAT ), $ Q( SUBMAT, SUBMAT ), LDQ, WORK, INFO ) IF( INFO.NE.0 ) $ GO TO 130 ELSE CALL DSTEQR( 'I', MATSIZ, D( SUBMAT ), E( SUBMAT ), $ WORK( IQ-1+IWORK( IQPTR+CURR ) ), MATSIZ, WORK, $ INFO ) IF( INFO.NE.0 ) $ GO TO 130 IF( ICOMPQ.EQ.1 ) THEN CALL DGEMM( 'N', 'N', QSIZ, MATSIZ, MATSIZ, ONE, $ Q( 1, SUBMAT ), LDQ, WORK( IQ-1+IWORK( IQPTR+ $ CURR ) ), MATSIZ, ZERO, QSTORE( 1, SUBMAT ), $ LDQS ) END IF IWORK( IQPTR+CURR+1 ) = IWORK( IQPTR+CURR ) + MATSIZ**2 CURR = CURR + 1 END IF K = 1 DO 60 J = SUBMAT, IWORK( I+1 ) IWORK( INDXQ+J ) = K K = K + 1 60 CONTINUE 70 CONTINUE * * Successively merge eigensystems of adjacent submatrices * into eigensystem for the corresponding larger matrix. * * while ( SUBPBS > 1 ) * CURLVL = 1 80 CONTINUE IF( SUBPBS.GT.1 ) THEN SPM2 = SUBPBS - 2 DO 90 I = 0, SPM2, 2 IF( I.EQ.0 ) THEN SUBMAT = 1 MATSIZ = IWORK( 2 ) MSD2 = IWORK( 1 ) CURPRB = 0 ELSE SUBMAT = IWORK( I ) + 1 MATSIZ = IWORK( I+2 ) - IWORK( I ) MSD2 = MATSIZ / 2 CURPRB = CURPRB + 1 END IF * * Merge lower order eigensystems (of size MSD2 and MATSIZ - MSD2) * into an eigensystem of size MATSIZ. * DLAED1 is used only for the full eigensystem of a tridiagonal * matrix. * DLAED7 handles the cases in which eigenvalues only or eigenvalues * and eigenvectors of a full symmetric matrix (which was reduced to * tridiagonal form) are desired. * IF( ICOMPQ.EQ.2 ) THEN CALL DLAED1( MATSIZ, D( SUBMAT ), Q( SUBMAT, SUBMAT ), $ LDQ, IWORK( INDXQ+SUBMAT ), $ E( SUBMAT+MSD2-1 ), MSD2, WORK, $ IWORK( SUBPBS+1 ), INFO ) ELSE CALL DLAED7( ICOMPQ, MATSIZ, QSIZ, TLVLS, CURLVL, CURPRB, $ D( SUBMAT ), QSTORE( 1, SUBMAT ), LDQS, $ IWORK( INDXQ+SUBMAT ), E( SUBMAT+MSD2-1 ), $ MSD2, WORK( IQ ), IWORK( IQPTR ), $ IWORK( IPRMPT ), IWORK( IPERM ), $ IWORK( IGIVPT ), IWORK( IGIVCL ), $ WORK( IGIVNM ), WORK( IWREM ), $ IWORK( SUBPBS+1 ), INFO ) END IF IF( INFO.NE.0 ) $ GO TO 130 IWORK( I / 2+1 ) = IWORK( I+2 ) 90 CONTINUE SUBPBS = SUBPBS / 2 CURLVL = CURLVL + 1 GO TO 80 END IF * * end while * * Re-merge the eigenvalues/vectors which were deflated at the final * merge step. * IF( ICOMPQ.EQ.1 ) THEN DO 100 I = 1, N J = IWORK( INDXQ+I ) WORK( I ) = D( J ) CALL DCOPY( QSIZ, QSTORE( 1, J ), 1, Q( 1, I ), 1 ) 100 CONTINUE CALL DCOPY( N, WORK, 1, D, 1 ) ELSE IF( ICOMPQ.EQ.2 ) THEN DO 110 I = 1, N J = IWORK( INDXQ+I ) WORK( I ) = D( J ) CALL DCOPY( N, Q( 1, J ), 1, WORK( N*I+1 ), 1 ) 110 CONTINUE CALL DCOPY( N, WORK, 1, D, 1 ) CALL DLACPY( 'A', N, N, WORK( N+1 ), N, Q, LDQ ) ELSE DO 120 I = 1, N J = IWORK( INDXQ+I ) WORK( I ) = D( J ) 120 CONTINUE CALL DCOPY( N, WORK, 1, D, 1 ) END IF GO TO 140 * 130 CONTINUE INFO = SUBMAT*( N+1 ) + SUBMAT + MATSIZ - 1 * 140 CONTINUE RETURN * * End of DLAED0 * END
gpl-2.0
embecosm/epiphany-gcc
gcc/testsuite/gfortran.dg/namelist_23.f90
174
1731
!{ dg-do run { target fd_truncate } } ! PR26136 Filling logical variables from namelist read when object list is not ! complete. Test case derived from PR. ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org> program read_logical implicit none logical, dimension(4) :: truely integer, dimension(4) :: truely_a_very_long_variable_name namelist /mynml/ truely namelist /mynml/ truely_a_very_long_variable_name truely = .false. truely_a_very_long_variable_name = 0 open(10, status="scratch") write(10,*) "&mynml" write(10,*) "truely = trouble, traffic .true" write(10,*) "truely_a_very_long_variable_name = 4, 4, 4" write(10,*) "/" rewind(10) read (10, nml=mynml, err = 1000) if (.not.all(truely(1:3))) call abort() if (.not.all(truely_a_very_long_variable_name(1:3).eq.4)) call abort() truely = .false. truely_a_very_long_variable_name = 0 rewind(10) write(10,*) "&mynml" write(10,*) "truely = .true., .true.," write(10,*) "truely_a_very_long_variable_name = 4, 4, 4" write(10,*) "/" rewind(10) read (10, nml=mynml, err = 1000) if (.not.all(truely(1:2))) call abort() if (.not.all(truely_a_very_long_variable_name(1:3).eq.4)) call abort() truely = .true. truely_a_very_long_variable_name = 0 rewind(10) write(10,*) "&mynml" write(10,*) "truely = .false., .false.," write(10,*) "truely_a_very_long_variable_name = 4, 4, 4" write(10,*) "/" rewind(10) read (10, nml=mynml, err = 1000) if (all(truely(1:2))) call abort() if (.not.all(truely_a_very_long_variable_name(1:3).eq.4)) call abort() close(10) stop 1000 call abort() end program read_logical
gpl-2.0
the-linix-project/linix-kernel-source
gccsrc/gcc-4.7.2/gcc/testsuite/gfortran.dg/fmt_cache_1.f
77
1308
! { dg-do run { target fd_truncate } } ! pr40662 segfaults when specific format is invoked twice. ! pr40330 incorrect io. ! test case derived from pr40662, <jvdelisle@gcc.gnu.org> program astap implicit none character(34) :: teststring real(4) :: arlxca = 0.0 open(10) write(10,40) arlxca write(10,40) arlxca 40 format(t4,"arlxca = ",1pg13.6,t27,"arlxcc = ",g13.6,t53, . "atmpca = ",g13.6,t79,"atmpcc = ",g13.6,t105, . "backup = ",g13.6,/, . t4,"csgfac = ",g13.6,t27,"csgmax = ",g13.6,t53, . "csgmin = ",g13.6,t79,"drlxca = ",g13.6,t105, . "drlxcc = ",g13.6,/, . t4,"dtimeh = ",g13.6,t27,"dtimei = ",g13.6,t53, . "dtimel = ",g13.6,t79,"dtimeu = ",g13.6,t105, . "dtmpca = ",g13.6,/, . t4,"dtmpcc = ",g13.6,t27,"ebalna = ",g13.6,t53, . "ebalnc = ",g13.6,t79,"ebalsa = ",g13.6,t105, . "ebalsc = ",g13.6) rewind 10 teststring = "" read(10,'(a)') teststring if (teststring.ne." arlxca = 0.00000 arlxcc =")call abort teststring = "" read(10,'(a)') teststring if (teststring.ne." arlxca = 0.00000 arlxcc =")call abort end program astap
bsd-2-clause
zhoupan71234/exciting-plus
src/sbesseldm.f90
7
3186
! Copyright (C) 2002-2005 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl. ! This file is distributed under the terms of the GNU Lesser General Public ! License. See the file COPYING for license details. !BOP ! !ROUTINE: sbesseldm ! !INTERFACE: subroutine sbesseldm(m,lmax,x,djl) ! !INPUT/OUTPUT PARAMETERS: ! m : order of derivatve (in,integer) ! lmax : maximum order of Bessel function (in,integer) ! x : real argument (in,real) ! djl : array of returned values (out,real(0:lmax)) ! !DESCRIPTION: ! Computes the $m$th derivative of the spherical Bessel function of the first ! kind, $j_l(x)$, for argument $x$ and $l=0,1,\ldots,l_{\rm max}$. For ! $x\ge 1$ this is done by repeatedly using the relations ! \begin{align*} ! \frac{d}{dx}j_l(x)&=\frac{l}{x}j_l(x)-j_{l+1}(x) \\ ! j_{l+1}(x)&=\frac{2l+1}{x}j_l(x)-j_{l-1}(x). ! \end{align*} ! While for $x<1$ the series expansion of the Bessel function is used ! $$ \frac{d^m}{dx^m}j_l(x)=\sum_{i=0}^{\infty} ! \frac{(2i+l)!}{(-2)^ii!(2i+l-m)!(2i+2l+1)!!}x^{2i+l-m}. $$ ! This procedure is numerically stable and accurate to near machine precision ! for $l\le 30$ and $m\le 6$. ! ! !REVISION HISTORY: ! Created March 2003 (JKD) ! Modified to return an array of values, October 2004 (JKD) !EOP !BOC implicit none ! arguments integer, intent(in) :: m integer, intent(in) :: lmax real(8), intent(in) :: x real(8), intent(out) :: djl(0:lmax) ! local variables integer, parameter :: maxm=6 integer, parameter :: maxns=20 integer i,j,l,i0 real(8) t1,sum,x2 integer a(0:maxm+1),a1(0:maxm+1) integer b(0:maxm+1),b1(0:maxm+1) ! automatic arrays real(8) jl(0:lmax+1) ! external functions real(8) factnm,factr external factnm,factr if ((m.lt.0).or.(m.gt.maxm)) then write(*,*) write(*,'("Error(sbesseldm): m out of range : ",I8)') m write(*,*) stop end if if ((lmax.lt.0).or.(lmax.gt.30)) then write(*,*) write(*,'("Error(sbesseldm): lmax out of range : ",I8)') lmax write(*,*) stop end if if ((x.lt.0.d0).or.(x.gt.1.d5)) then write(*,*) write(*,'("Error(sbesseldm): x out of range : ",G18.10)') x write(*,*) stop end if if (m.eq.0) then call sbessel(lmax,x,djl) return end if if (x.gt.1.d0) then call sbessel(lmax+1,x,jl) do l=0,lmax a(1:m+1)=0 a(0)=1 a1(0:m+1)=0 do i=1,m b(0)=0 b1(0)=0 do j=0,i b(j+1)=a(j)*(l-j) b1(j+1)=-a1(j)*(j+l+2) end do do j=0,i b1(j)=b1(j)-a(j) b(j)=b(j)+a1(j) end do a(0:i+1)=b(0:i+1) a1(0:i+1)=b1(0:i+1) end do t1=1.d0 sum=dble(a(0))*jl(l)+dble(a1(0))*jl(l+1) do i=1,m+1 t1=t1*x sum=sum+(dble(a(i))*jl(l)+dble(a1(i))*jl(l+1))/t1 end do djl(l)=sum end do else x2=x**2 do l=0,lmax i0=max((m-l+1)/2,0) j=2*i0+l-m if (j.eq.0) then t1=1.d0 else t1=x**j end if t1=factr(j+m,j)*t1/(factnm(i0,1)*factnm(j+l+m+1,2)*dble((-2)**i0)) sum=t1 do i=i0+1,maxns j=2*i+l t1=-t1*dble((j-1)*j)*x2/dble((j-l)*(j-m-1)*(j-m)*(j+l+1)) if (abs(t1).le.1.d-40) goto 10 sum=sum+t1 end do 10 continue djl(l)=sum end do end if return end subroutine !EOC
gpl-3.0
InsightSoftwareConsortium/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/linpack/dposl.f
41
1848
subroutine dposl(a,lda,n,b) integer lda,n double precision a(lda,1),b(1) c c dposl solves the double precision symmetric positive definite c system a * x = b c using the factors computed by dpoco or dpofa. c c on entry c c a double precision(lda, n) c the output from dpoco or dpofa. c c lda integer c the leading dimension of the array a . c c n integer c the order of the matrix a . c c b double precision(n) c the right hand side vector. c c on return c c b the solution vector x . c c error condition c c a division by zero will occur if the input factor contains c a zero on the diagonal. technically this indicates c singularity but it is usually caused by improper subroutine c arguments. it will not occur if the subroutines are called c correctly and info .eq. 0 . c c to compute inverse(a) * c where c is a matrix c with p columns c call dpoco(a,lda,n,rcond,z,info) c if (rcond is too small .or. info .ne. 0) go to ... c do 10 j = 1, p c call dposl(a,lda,n,c(1,j)) c 10 continue c c linpack. this version dated 08/14/78 . c cleve moler, university of new mexico, argonne national lab. c c subroutines and functions c c blas daxpy,ddot c c internal variables c double precision ddot,t integer k,kb c c solve trans(r)*y = b c do 10 k = 1, n t = ddot(k-1,a(1,k),1,b(1),1) b(k) = (b(k) - t)/a(k,k) 10 continue c c solve r*x = y c do 20 kb = 1, n k = n + 1 - kb b(k) = b(k)/a(k,k) t = -b(k) call daxpy(k-1,t,a(1,k),1,b(1),1) 20 continue return end
apache-2.0
embecosm/epiphany-gcc
libgfortran/generated/_anint_r10.F90
15
1487
! Copyright 2002, 2007, 2009 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !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_ROUNDL elemental function _gfortran_specific__anint_r10 (parm) real (kind=10), intent (in) :: parm real (kind=10) :: _gfortran_specific__anint_r10 _gfortran_specific__anint_r10 = anint (parm) end function #endif #endif
gpl-2.0
bquast/rnnlib
hdf5_snap/fortran/src/H5Dff.f90
11
36109
!****h* ROBODoc/H5D ! ! NAME ! MODULE H5D ! ! FILE ! fortran/src/H5Dff.f90 ! ! PURPOSE ! This file contains Fortran interfaces for H5D functions. It includes ! all the functions that are independent on whether the Fortran 2003 functions ! are enabled or disabled. ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! Copyright by The HDF Group. * ! Copyright by the Board of Trustees of the University of Illinois. * ! All rights reserved. * ! * ! This file is part of HDF5. The full HDF5 copyright notice, including * ! terms governing use, modification, and redistribution, is contained in * ! the files COPYING and Copyright.html. COPYING can be found at the root * ! of the source code distribution tree; Copyright.html can be found at the * ! root level of an installed copy of the electronic HDF5 document set and * ! is linked from the top-level documents page. It can also be found at * ! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * ! access to either file, you may request a copy from help@hdfgroup.org. * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! ! NOTES ! *** IMPORTANT *** ! If you add a new H5D function you must add the function name to the ! Windows dll file 'hdf5_fortrandll.def.in' in the fortran/src directory. ! This is needed for Windows based operating systems. ! !***** MODULE H5D USE H5GLOBAL INTERFACE h5dextend_f MODULE PROCEDURE h5dset_extent_f END INTERFACE INTERFACE h5dread_vl_f MODULE PROCEDURE h5dread_vl_integer MODULE PROCEDURE h5dread_vl_real MODULE PROCEDURE h5dread_vl_string END INTERFACE INTERFACE h5dwrite_vl_f MODULE PROCEDURE h5dwrite_vl_integer MODULE PROCEDURE h5dwrite_vl_real MODULE PROCEDURE h5dwrite_vl_string END INTERFACE CONTAINS ! !****s* H5D/h5dcreate_f ! ! NAME ! h5dcreate_f ! ! PURPOSE ! Creates a dataset at the specified location ! ! INPUTS ! loc_id - file or group identifier ! name - dataset name ! type_id - dataset datatype identifier ! space_id - dataset dataspace identifier ! OUTPUTS ! dset_id - dataset identifier ! hdferr - Returns 0 if successful and -1 if fails ! OPTIONAL PARAMETERS ! creation_prp - Dataset creation property list ! lcpl_id - Link creation property list ! dapl_id - Dataset access property list ! ! AUTHOR ! Elena Pourmal ! August 12, 1999 ! ! HISTORY ! ! - Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). February 28, 2001 ! ! - Added version's 1.8 new optional parameters ! February, 2008 ! ! SOURCE SUBROUTINE h5dcreate_f(loc_id, name, type_id, space_id, dset_id, & hdferr, dcpl_id, lcpl_id, dapl_id) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id ! File or group identifier CHARACTER(LEN=*), INTENT(IN) :: name ! Name of the dataset INTEGER(HID_T), INTENT(IN) :: type_id ! Datatype identifier INTEGER(HID_T), INTENT(IN) :: space_id ! Dataspace identifier INTEGER(HID_T), INTENT(OUT) :: dset_id ! Dataset identifier INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTEGER(HID_T), OPTIONAL, INTENT(IN) :: dcpl_id ! Dataset creation property list INTEGER(HID_T), OPTIONAL, INTENT(IN) :: lcpl_id ! Link creation property list INTEGER(HID_T), OPTIONAL, INTENT(IN) :: dapl_id ! Dataset access property list INTEGER(HID_T) :: lcpl_id_default INTEGER(HID_T) :: dcpl_id_default INTEGER(HID_T) :: dapl_id_default INTEGER :: namelen ! Name length ! MS FORTRAN needs explicit interface for C functions called here. ! INTERFACE INTEGER FUNCTION h5dcreate_c(loc_id, name, namelen, type_id, & space_id, lcpl_id_default, dcpl_id_default, dapl_id_default, dset_id) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DCREATE_C'::h5dcreate_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: name INTEGER(HID_T), INTENT(IN) :: loc_id CHARACTER(LEN=*), INTENT(IN) :: name INTEGER :: namelen INTEGER(HID_T), INTENT(IN) :: type_id INTEGER(HID_T), INTENT(IN) :: space_id INTEGER(HID_T) :: lcpl_id_default INTEGER(HID_T) :: dcpl_id_default INTEGER(HID_T) :: dapl_id_default INTEGER(HID_T), INTENT(OUT) :: dset_id END FUNCTION h5dcreate_c END INTERFACE lcpl_id_default = H5P_DEFAULT_F dcpl_id_default = H5P_DEFAULT_F dapl_id_default = H5P_DEFAULT_F IF(PRESENT(lcpl_id)) lcpl_id_default = lcpl_id IF(PRESENT(dcpl_id)) dcpl_id_default = dcpl_id IF(PRESENT(dapl_id)) dapl_id_default = dapl_id namelen = LEN(name) hdferr = h5dcreate_c(loc_id, name, namelen, type_id, space_id, & lcpl_id_default, dcpl_id_default, dapl_id_default, dset_id) END SUBROUTINE h5dcreate_f ! !****s* H5D/h5dopen_f ! ! NAME ! h5dopen_f ! ! PURPOSE ! Opens an existing dataset. ! ! INPUTS ! loc_id - file or group identifier ! name - dataset name ! OUTPUTS ! dset_id - dataset identifier ! hdferr - Returns 0 if successful and -1 if fails ! OPTIONAL PARAMETERS ! dapl_id - Dataset access property list ! ! AUTHOR ! Elena Pourmal ! August 12, 1999 ! ! HISTORY ! -Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). February 28, 2001 ! ! -Added 1.8 (optional) parameter dapl_id ! February, 2008, M. Scot Breitenfeld ! ! SOURCE SUBROUTINE h5dopen_f(loc_id, name, dset_id, hdferr, dapl_id) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id ! File or group identifier CHARACTER(LEN=*), INTENT(IN) :: name ! Name of the dataset INTEGER(HID_T), INTENT(OUT) :: dset_id ! Dataset identifier INTEGER, INTENT(OUT) :: hdferr ! Error code INTEGER(HID_T), OPTIONAL, INTENT(IN) :: dapl_id ! Dataset access property list !***** INTEGER :: namelen ! Name length INTEGER(HID_T) :: dapl_id_default INTERFACE INTEGER FUNCTION h5dopen_c(loc_id, name, namelen, dapl_id_default, dset_id) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DOPEN_C'::h5dopen_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: name INTEGER(HID_T), INTENT(IN) :: loc_id CHARACTER(LEN=*), INTENT(IN) :: name INTEGER :: namelen INTEGER(HID_T), INTENT(IN) :: dapl_id_default INTEGER(HID_T), INTENT(OUT) :: dset_id END FUNCTION h5dopen_c END INTERFACE dapl_id_default = H5P_DEFAULT_F IF(PRESENT(dapl_id)) dapl_id_default = dapl_id namelen = LEN(name) hdferr = h5dopen_c(loc_id, name, namelen, dapl_id_default, dset_id) END SUBROUTINE h5dopen_f ! !****s* H5D/h5dclose_f ! ! NAME ! h5dclose_f ! ! PURPOSE ! Closes a dataset. ! ! INPUTS ! dset_id - dataset identifier ! OUTPUTS ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR ! Elena Pourmal ! August 12, 1999 ! ! HISTORY ! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). February 28, 2001 ! ! SOURCE SUBROUTINE h5dclose_f(dset_id, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTERFACE INTEGER FUNCTION h5dclose_c(dset_id) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DCLOSE_C'::h5dclose_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dset_id END FUNCTION h5dclose_c END INTERFACE hdferr = h5dclose_c(dset_id) END SUBROUTINE h5dclose_f ! !****s* H5D/h5dget_type_f ! ! NAME ! h5dget_type_f ! ! PURPOSE ! Returns an identifier for a copy of the datatype for a ! dataset. ! ! INPUTS ! dataset_id - dataset identifier ! OUTPUTS ! datatype_id - dataspace identifier ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR ! Elena Pourmal ! August 12, 1999 ! ! HISTORY ! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). February 28, 2001 ! ! NOTES ! ! SOURCE SUBROUTINE h5dget_type_f(dataset_id, datatype_id, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dataset_id ! Dataset identifier INTEGER(HID_T), INTENT(OUT) :: datatype_id ! Datatype identifier INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTERFACE INTEGER FUNCTION h5dget_type_c (dataset_id, datatype_id) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DGET_TYPE_C'::h5dget_type_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dataset_id INTEGER(HID_T), INTENT(OUT) :: datatype_id END FUNCTION h5dget_type_c END INTERFACE hdferr = h5dget_type_c (dataset_id, datatype_id) END SUBROUTINE h5dget_type_f ! !****s* H5D/h5dset_extent ! ! NAME ! h5dset_extent (instead of obsolete name: h5dextend_f) ! ! PURPOSE ! Extends a dataset with unlimited dimension. ! ! INPUTS ! dataset_id - dataset identifier ! size - array containing the new magnitude of ! each dimension ! OUTPUTS ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR ! Elena Pourmal ! August 12, 1999 ! ! HISTORY ! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). February 28, 2001 ! ! Changed name from the now obsolete h5dextend_f ! to h5dset_extent_f. Provided interface to old name ! for backward compatability. -MSB- March 14, 2008 ! ! SOURCE SUBROUTINE h5dset_extent_f(dataset_id, size, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dataset_id ! Dataset identifier INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: size ! Array containing ! dimensions' sizes INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTERFACE INTEGER FUNCTION h5dset_extent_c(dataset_id, size) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DSET_EXTENT_C'::h5dset_extent_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dataset_id INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: size END FUNCTION h5dset_extent_c END INTERFACE hdferr = H5Dset_extent_c(dataset_id, size) END SUBROUTINE h5dset_extent_f !****s* H5D/h5dget_create_plist_f ! ! NAME ! h5dget_create_plist_f ! ! PURPOSE ! Returns an identifier for a copy of the dataset creation ! property list for a dataset. ! ! INPUTS ! dataset_id - dataset identifier ! OUTPUTS ! plist_id - creation property list identifier ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR ! Elena Pourmal ! August 12, 1999 ! ! HISTORY ! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). February 28, 2001 ! SOURCE SUBROUTINE h5dget_create_plist_f(dataset_id, plist_id, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dataset_id ! Dataset identifier INTEGER(HID_T), INTENT(OUT) :: plist_id ! Dataset creation ! property list identifier INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTERFACE INTEGER FUNCTION h5dget_create_plist_c(dataset_id, plist_id) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DGET_CREATE_PLIST_C'::h5dget_create_plist_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dataset_id INTEGER(HID_T), INTENT(OUT) :: plist_id END FUNCTION h5dget_create_plist_c END INTERFACE hdferr = h5dget_create_plist_c(dataset_id, plist_id) END SUBROUTINE h5dget_create_plist_f ! !****s* H5D/h5dget_storage_size_f ! ! NAME ! h5dget_storage_size_f ! ! PURPOSE ! Returns the amount of storage requires by a dataset ! ! INPUTS ! dataset_id - dataset identifier ! OUTPUTS ! size - datastorage size ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR ! Elena Pourmal ! October 15, 2002 ! SOURCE SUBROUTINE h5dget_storage_size_f(dataset_id, size, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dataset_id ! Dataset identifier INTEGER(HSIZE_T), INTENT(OUT) :: size ! Amount of storage ! allocated for dataset INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTERFACE INTEGER FUNCTION h5dget_storage_size_c(dataset_id, size) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DGET_STORAGE_SIZE_C'::h5dget_storage_size_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dataset_id INTEGER(HSIZE_T), INTENT(OUT) :: size END FUNCTION h5dget_storage_size_c END INTERFACE hdferr = h5dget_storage_size_c(dataset_id, size) END SUBROUTINE h5dget_storage_size_f ! !****s* H5D/h5dvlen_get_max_len_f ! ! NAME ! h5dvlen_get_max_len_f ! ! PURPOSE ! Returns maximum length of the VL array elements ! ! INPUTS ! dataset_id - dataset identifier ! type_id - datatype identifier ! space_id - dataspace identifier ! OUTPUTS ! size - buffer size ! hdferr - Returns 0 if successful and -1 if fails ! OPTIONAL PARAMETERS ! NONE ! ! AUTHOR ! Elena Pourmal ! October 15, 2002 ! ! SOURCE SUBROUTINE h5dvlen_get_max_len_f(dataset_id, type_id, space_id, len, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dataset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: type_id ! Datatype identifier INTEGER(HID_T), INTENT(IN) :: space_id ! Dataspace identifier INTEGER(SIZE_T), INTENT(OUT) :: len ! Maximum length of the element INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTERFACE INTEGER FUNCTION h5dvlen_get_max_len_c(dataset_id, type_id, space_id, len) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DVLEN_GET_MAX_LEN_C'::h5dvlen_get_max_len_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dataset_id INTEGER(HID_T), INTENT(IN) :: type_id INTEGER(HID_T), INTENT(IN) :: space_id INTEGER(SIZE_T), INTENT(OUT) :: len END FUNCTION h5dvlen_get_max_len_c END INTERFACE hdferr = h5dvlen_get_max_len_c(dataset_id, type_id, space_id, len) END SUBROUTINE h5dvlen_get_max_len_f ! !****s* H5D/h5dget_space_status_f ! ! NAME ! h5dget_space_status_f ! ! PURPOSE ! Returns the status of data space allocation. ! ! INPUTS ! dset_id - dataset identifier ! OUTPUTS ! flag - status; may have one of the following values: ! H5D_SPACE_STS_ERROR_F ! H5D_SPACE_STS_NOT_ALLOCATED_F ! H5D_SPACE_STS_PART_ALLOCATED_F ! H5D_SPACE_STS_ALLOCATED_F ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR ! Elena Pourmal ! March 12, 2003 ! ! SOURCE SUBROUTINE h5dget_space_status_f(dset_id, flag, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataspace identifier INTEGER, INTENT(OUT) :: flag ! Memory buffer to fill in INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTERFACE INTEGER FUNCTION h5dget_space_status_c(dset_id, flag) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DGET_SPACE_STATUS_C'::h5dget_space_status_c !DEC$ENDIF INTEGER(HID_T) :: dset_id INTEGER :: flag END FUNCTION h5dget_space_status_c END INTERFACE hdferr = h5dget_space_status_c(dset_id, flag) END SUBROUTINE h5dget_space_status_f ! !****s* H5D/h5dcreate_anon_f ! ! NAME ! h5dcreate_anon_f ! ! PURPOSE ! Creates a dataset in a file without linking it into the file structure ! ! INPUTS ! loc_id - Identifier of the file or group within which to create the dataset. ! type_id - Identifier of the datatype to use when creating the dataset. ! space_id - Identifier of the dataspace to use when creating the dataset. ! OUTPUTS ! dset_id - dataset identifier ! hdferr - Returns 0 if successful and -1 if fails ! OPTIONAL PARAMETERS ! dcpl_id - Dataset creation property list identifier. ! dapl_id - Dataset access property list identifier. ! ! AUTHOR ! M. Scot Breitenfeld ! February 11, 2008 ! ! SOURCE SUBROUTINE h5dcreate_anon_f(loc_id, type_id, space_id, dset_id, hdferr, dcpl_id, dapl_id) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id ! File or group identifier. INTEGER(HID_T), INTENT(IN) :: type_id ! Datatype identifier. INTEGER(HID_T), INTENT(IN) :: space_id ! Dataspace identifier. INTEGER(HID_T), INTENT(OUT) :: dset_id ! Dataset identifier. INTEGER, INTENT(OUT) :: hdferr ! Error code. INTEGER(HID_T), OPTIONAL, INTENT(IN) :: dcpl_id ! Dataset creation property list identifier. INTEGER(HID_T), OPTIONAL, INTENT(IN) :: dapl_id ! Dataset access property list identifier. !***** INTEGER(HID_T) :: dcpl_id_default INTEGER(HID_T) :: dapl_id_default ! ! MS FORTRAN needs explicit interface for C functions called here. ! INTERFACE INTEGER FUNCTION h5dcreate_anon_c(loc_id, type_id, space_id, dcpl_id_default, dapl_id_default, dset_id) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DCREATE_ANON_C'::h5dcreate_anon_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: loc_id INTEGER(HID_T), INTENT(IN) :: type_id INTEGER(HID_T), INTENT(IN) :: space_id INTEGER(HID_T) :: dcpl_id_default INTEGER(HID_T) :: dapl_id_default INTEGER(HID_T), INTENT(OUT) :: dset_id END FUNCTION h5dcreate_anon_c END INTERFACE dcpl_id_default = H5P_DEFAULT_F dapl_id_default = H5P_DEFAULT_F IF(PRESENT(dcpl_id)) dcpl_id_default = dcpl_id IF(PRESENT(dapl_id)) dapl_id_default = dapl_id hdferr = h5dcreate_anon_c(loc_id, type_id, space_id, dcpl_id_default, dapl_id_default, dset_id) END SUBROUTINE h5dcreate_anon_f SUBROUTINE h5dwrite_vl_integer(dset_id, mem_type_id, buf, dims, len, & hdferr, & mem_space_id, file_space_id, xfer_prp) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier INTEGER(HSIZE_T), INTENT(IN), DIMENSION(2) :: dims ! MAX len x num_elem INTEGER(SIZE_T), INTENT(IN), DIMENSION(*) :: len ! Array to store ! the length of each ! element INTEGER, INTENT(IN), & DIMENSION(dims(1),dims(2)), TARGET :: buf ! Data buffer INTEGER, INTENT(OUT) :: hdferr ! Error code INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id ! Memory dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id ! File dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp ! Transfer property list identifier INTEGER(HID_T) :: xfer_prp_default INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTERFACE INTEGER FUNCTION h5dwrite_vl_integer_c(dset_id, mem_type_id, & mem_space_id_default, & file_space_id_default, & xfer_prp_default, buf, dims, len) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DWRITE_VL_INTEGER_C'::h5dwrite_vl_integer_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dset_id INTEGER(HID_T), INTENT(IN) :: mem_type_id INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTEGER(HID_T) :: xfer_prp_default INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims INTEGER(SIZE_T), INTENT(IN), DIMENSION(*) :: len INTEGER, INTENT(IN), & DIMENSION(dims(1),dims(2)) :: buf END FUNCTION h5dwrite_vl_integer_c END INTERFACE xfer_prp_default = H5P_DEFAULT_F mem_space_id_default = H5S_ALL_F file_space_id_default = H5S_ALL_F IF (PRESENT(xfer_prp)) xfer_prp_default = xfer_prp IF (PRESENT(mem_space_id)) mem_space_id_default = mem_space_id IF (PRESENT(file_space_id)) file_space_id_default = file_space_id hdferr = h5dwrite_vl_integer_c(dset_id, mem_type_id, mem_space_id_default, & file_space_id_default, xfer_prp_default, & buf, dims, len) END SUBROUTINE h5dwrite_vl_integer SUBROUTINE h5dread_vl_integer(dset_id, mem_type_id, buf, dims, len, & hdferr, & mem_space_id, file_space_id, xfer_prp) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier INTEGER(HSIZE_T), INTENT(IN), DIMENSION(2) :: dims ! MAX len x num_elem INTEGER(SIZE_T), INTENT(INOUT), DIMENSION(*) :: len ! Array to store ! the length of each ! element INTEGER, INTENT(INOUT), & DIMENSION(dims(1),dims(2)), TARGET :: buf ! Data buffer INTEGER, INTENT(OUT) :: hdferr ! Error code ! -1 if failed, 0 otherwise INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id ! Memory dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id ! File dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp ! Transfer property list identifier INTEGER(HID_T) :: xfer_prp_default INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTEGER(HID_T) :: tmp INTEGER :: error INTERFACE INTEGER FUNCTION h5dread_vl_integer_c(dset_id, mem_type_id, & mem_space_id_default, & file_space_id_default, & xfer_prp_default, buf, dims, len) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DREAD_VL_INTEGER_C'::h5dread_vl_integer_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dset_id INTEGER(HID_T), INTENT(IN) :: mem_type_id INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTEGER(HID_T) :: xfer_prp_default INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims INTEGER(SIZE_T), INTENT(INOUT), DIMENSION(*) :: len INTEGER, INTENT(INOUT), & DIMENSION(dims(1),dims(2)) :: buf END FUNCTION h5dread_vl_integer_c END INTERFACE CALL h5dget_space_f(dset_id, tmp, error) xfer_prp_default = H5P_DEFAULT_F mem_space_id_default = tmp file_space_id_default = tmp IF (PRESENT(xfer_prp)) xfer_prp_default = xfer_prp IF (PRESENT(mem_space_id)) mem_space_id_default = mem_space_id IF (PRESENT(file_space_id)) file_space_id_default = file_space_id hdferr = h5dread_vl_integer_c(dset_id, mem_type_id, mem_space_id_default, & file_space_id_default, xfer_prp_default, & buf, dims, len) END SUBROUTINE h5dread_vl_integer SUBROUTINE h5dwrite_vl_real(dset_id, mem_type_id, buf, dims, len, & hdferr, & mem_space_id, file_space_id, xfer_prp) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier INTEGER(HSIZE_T), INTENT(IN), DIMENSION(2) :: dims ! MAX len x num_elem INTEGER(SIZE_T), INTENT(IN), DIMENSION(*) :: len ! Array to store ! the length of each ! element REAL, INTENT(IN), & DIMENSION(dims(1),dims(2)) :: buf ! Data buffer INTEGER, INTENT(OUT) :: hdferr ! Error code INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id ! Memory dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id ! File dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp ! Transfer property list identifier INTEGER(HID_T) :: xfer_prp_default INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTERFACE INTEGER FUNCTION h5dwrite_vl_real_c(dset_id, mem_type_id, & mem_space_id_default, & file_space_id_default, & xfer_prp_default, buf, dims, len) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DWRITE_VL_REAL_C'::h5dwrite_vl_real_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dset_id INTEGER(HID_T), INTENT(IN) :: mem_type_id INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTEGER(HID_T) :: xfer_prp_default INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims INTEGER(SIZE_T), INTENT(IN), DIMENSION(*) :: len REAL, INTENT(IN), & DIMENSION(dims(1),dims(2)) :: buf END FUNCTION h5dwrite_vl_real_c END INTERFACE xfer_prp_default = H5P_DEFAULT_F mem_space_id_default = H5S_ALL_F file_space_id_default = H5S_ALL_F IF (PRESENT(xfer_prp)) xfer_prp_default = xfer_prp IF (PRESENT(mem_space_id)) mem_space_id_default = mem_space_id IF (PRESENT(file_space_id)) file_space_id_default = file_space_id hdferr = h5dwrite_vl_real_c(dset_id, mem_type_id, mem_space_id_default, & file_space_id_default, xfer_prp_default, & buf, dims, len) END SUBROUTINE h5dwrite_vl_real SUBROUTINE h5dread_vl_real(dset_id, mem_type_id, buf, dims, len, & hdferr, & mem_space_id, file_space_id, xfer_prp) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier INTEGER(HSIZE_T), INTENT(IN), DIMENSION(2) :: dims ! MAX len x num_elem INTEGER(SIZE_T), INTENT(INOUT), DIMENSION(*) :: len ! Array to store the length of each element REAL, INTENT(INOUT), & DIMENSION(dims(1),dims(2)) :: buf ! Data buffer INTEGER, INTENT(OUT) :: hdferr ! Error code ! -1 if failed, 0 otherwise INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id ! Memory dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id ! File dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp ! Transfer property list identifier INTEGER(HID_T) :: xfer_prp_default INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTEGER(HID_T) :: tmp INTEGER :: error INTERFACE INTEGER FUNCTION h5dread_vl_real_c(dset_id, mem_type_id, & mem_space_id_default, & file_space_id_default, & xfer_prp_default, buf, dims, len) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DREAD_VL_REAL_C'::h5dread_vl_real_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dset_id INTEGER(HID_T), INTENT(IN) :: mem_type_id INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTEGER(HID_T) :: xfer_prp_default INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims INTEGER(SIZE_T), INTENT(INOUT), DIMENSION(*) :: len REAL, INTENT(INOUT), & DIMENSION(dims(1),dims(2)) :: buf END FUNCTION h5dread_vl_real_c END INTERFACE CALL h5dget_space_f(dset_id, tmp, error) xfer_prp_default = H5P_DEFAULT_F mem_space_id_default = tmp file_space_id_default = tmp IF (PRESENT(xfer_prp)) xfer_prp_default = xfer_prp IF (PRESENT(mem_space_id)) mem_space_id_default = mem_space_id IF (PRESENT(file_space_id)) file_space_id_default = file_space_id hdferr = h5dread_vl_real_c(dset_id, mem_type_id, mem_space_id_default, & file_space_id_default, xfer_prp_default, & buf, dims, len) END SUBROUTINE h5dread_vl_real SUBROUTINE h5dwrite_vl_string(dset_id, mem_type_id, buf, dims, str_len, & hdferr, & mem_space_id, file_space_id, xfer_prp) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier INTEGER(HSIZE_T), INTENT(IN), DIMENSION(2) :: dims ! Number of strings INTEGER(SIZE_T), INTENT(IN), DIMENSION(*) :: str_len ! Array to store the length of each element CHARACTER(LEN=*), INTENT(IN), & DIMENSION(dims(2)) :: buf ! Data buffer INTEGER, INTENT(OUT) :: hdferr ! Error code INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id ! Memory dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id ! File dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp ! Transfer property list identifier INTEGER(HID_T) :: xfer_prp_default INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTERFACE INTEGER FUNCTION h5dwrite_vl_string_c(dset_id, mem_type_id, & mem_space_id_default, & file_space_id_default, & ! xfer_prp_default, tmp_buf, dims, str_len) xfer_prp_default, buf, dims, str_len) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DWRITE_VL_STRING_C'::h5dwrite_vl_string_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: buf INTEGER(HID_T), INTENT(IN) :: dset_id INTEGER(HID_T), INTENT(IN) :: mem_type_id INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTEGER(HID_T) :: xfer_prp_default INTEGER(HSIZE_T), INTENT(IN), DIMENSION(2) :: dims INTEGER(SIZE_T), INTENT(IN), DIMENSION(*) :: str_len CHARACTER(LEN=*), DIMENSION(dims(2)) :: buf END FUNCTION END INTERFACE xfer_prp_default = H5P_DEFAULT_F mem_space_id_default = H5S_ALL_F file_space_id_default = H5S_ALL_F IF (PRESENT(xfer_prp)) xfer_prp_default = xfer_prp IF (PRESENT(mem_space_id)) mem_space_id_default = mem_space_id IF (PRESENT(file_space_id)) file_space_id_default = file_space_id hdferr = h5dwrite_vl_string_c(dset_id, mem_type_id, mem_space_id_default, & file_space_id_default, xfer_prp_default, & buf, dims, str_len) END SUBROUTINE h5dwrite_vl_string SUBROUTINE h5dread_vl_string(dset_id, mem_type_id, buf, dims, str_len, & hdferr, & mem_space_id, file_space_id, xfer_prp) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier INTEGER(HSIZE_T), INTENT(IN), DIMENSION(2) :: dims ! number of strings INTEGER(SIZE_T), INTENT(OUT), DIMENSION(*) :: str_len ! Array to store ! the length of each ! element CHARACTER(LEN=*), INTENT(OUT), & DIMENSION(dims(2)) :: buf ! Data buffer INTEGER, INTENT(OUT) :: hdferr ! Error code INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id ! Memory dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id ! File dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp ! Transfer property list identifier INTEGER(HID_T) :: xfer_prp_default INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTERFACE INTEGER FUNCTION h5dread_vl_string_c(dset_id, mem_type_id, & mem_space_id_default, & file_space_id_default, & xfer_prp_default, buf, dims, str_len) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DREAD_VL_STRING_C'::h5dread_vl_string_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: buf INTEGER(HID_T), INTENT(IN) :: dset_id INTEGER(HID_T), INTENT(IN) :: mem_type_id INTEGER(HID_T) :: mem_space_id_default INTEGER(HID_T) :: file_space_id_default INTEGER(HID_T) :: xfer_prp_default INTEGER(HSIZE_T), INTENT(IN), DIMENSION(2) :: dims INTEGER(SIZE_T), INTENT(OUT), DIMENSION(*) :: str_len CHARACTER(LEN=*), DIMENSION(dims(2)) :: buf END FUNCTION h5dread_vl_string_c END INTERFACE xfer_prp_default = H5P_DEFAULT_F mem_space_id_default = H5S_ALL_F file_space_id_default = H5S_ALL_F IF (PRESENT(xfer_prp)) xfer_prp_default = xfer_prp IF (PRESENT(mem_space_id)) mem_space_id_default = mem_space_id IF (PRESENT(file_space_id)) file_space_id_default = file_space_id hdferr = h5dread_vl_string_c(dset_id, mem_type_id, mem_space_id_default, & file_space_id_default, xfer_prp_default, & buf, dims, str_len) RETURN END SUBROUTINE h5dread_vl_string ! !****s* H5D/h5dget_space_f ! ! NAME ! h5dget_space_f ! ! PURPOSE ! Returns an identifier for a copy of the dataspace for a ! dataset. ! ! INPUTS ! dataset_id - dataset identifier ! OUTPUTS ! dataspace_id - dataspace identifier ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR ! Elena Pourmal ! August 12, 1999 ! ! HISTORY ! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). February 28, 2001 ! ! SOURCE SUBROUTINE h5dget_space_f(dataset_id, dataspace_id, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dataset_id ! Dataset identifier INTEGER(HID_T), INTENT(OUT) :: dataspace_id ! Dataspace identifier INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTERFACE INTEGER FUNCTION h5dget_space_c(dataset_id, dataspace_id) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DGET_SPACE_C'::h5dget_space_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dataset_id INTEGER(HID_T), INTENT(OUT) :: dataspace_id END FUNCTION h5dget_space_c END INTERFACE hdferr = h5dget_space_c(dataset_id, dataspace_id) END SUBROUTINE h5dget_space_f !****s* H5D/h5dget_access_plist_f ! ! NAME ! h5dget_access_plist_f ! ! PURPOSE ! Returns a copy of the dataset creation property list. ! ! INPUTS ! dset_id - Dataset identifier ! ! OUTPUTS ! plist_id - Dataset access property list identifier ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR ! M. Scot Breitenfeld ! April 13, 2009 ! ! SOURCE SUBROUTINE h5dget_access_plist_f(dset_id, plist_id, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id INTEGER(HID_T), INTENT(OUT) :: plist_id INTEGER , INTENT(OUT) :: hdferr !***** INTERFACE INTEGER FUNCTION h5dget_access_plist_c(dset_id, plist_id) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DGET_ACCESS_PLIST_C'::h5dget_access_plist_c !DEC$ENDIF INTEGER(HID_T), INTENT(IN) :: dset_id INTEGER(HID_T), INTENT(OUT) :: plist_id END FUNCTION h5dget_access_plist_c END INTERFACE hdferr = h5dget_access_plist_c(dset_id, plist_id) END SUBROUTINE h5dget_access_plist_f END MODULE H5D
gpl-3.0
jwakely/gcc
gcc/testsuite/gfortran.dg/pr91497.f90
8
2673
! { dg-do compile { target { i?86-*-* x86_64-*-* } } } ! { dg-options "-Wall" } ! Code contributed by Manfred Schwarb <manfred99 at gmx dot ch> ! PR fortran/91497 ! ! Prior to applying the patch for this PR, the following code ! would generate numerous conversion warnings. ! program foo real*4 a,aa real*8 b,bb real*10 c,cc real*16 d integer*2 e,ee integer*4 f,ff integer*8 g,gg PARAMETER(a=3.1415927_4) PARAMETER(b=3.1415927_8) PARAMETER(c=3.1415927_10) PARAMETER(d=3.1415927_16) PARAMETER(e=123_2) PARAMETER(f=123_4) PARAMETER(g=123_8) aa=REAL(b) aa=REAL(c) aa=REAL(d) aa=REAL(e) aa=REAL(f) aa=REAL(g) aa=FLOAT(f) aa=FLOOR(b) aa=FLOOR(c) aa=FLOOR(d) aa=CEILING(b) aa=CEILING(c) aa=CEILING(d) !---unknown but documented type conversions: !!aa=FLOATI(e) !!aa=FLOATJ(f) !!aa=FLOATK(g) !---documentation is wrong for sngl: aa=SNGL(c) aa=SNGL(d) bb=REAL(c, kind=8) bb=REAL(d, kind=8) bb=DBLE(c) bb=DBLE(d) bb=DFLOAT(g) bb=FLOOR(c) bb=FLOOR(d) bb=CEILING(c) bb=CEILING(d) cc=REAL(d, kind=10) cc=FLOOR(d) cc=CEILING(d) aa=AINT(b) aa=ANINT(b) aa=AINT(c) aa=ANINT(c) aa=AINT(d) aa=ANINT(d) bb=DINT(b) bb=DNINT(b) ee=INT(a, kind=2) ee=NINT(a, kind=2) ee=INT(b, kind=2) ee=NINT(b, kind=2) ee=INT(c, kind=2) ee=NINT(c, kind=2) ee=INT(d, kind=2) ee=NINT(d, kind=2) ee=INT(f, kind=2) ee=INT(g, kind=2) ee=IFIX(a) ee=IDINT(b) ee=IDNINT(b) ee=INT2(a) ee=INT2(b) ee=INT2(c) ee=INT2(d) ee=INT2(f) ee=INT2(g) ff=INT(a, kind=4) ff=NINT(a, kind=4) ff=INT(b, kind=4) ff=NINT(b, kind=4) ff=INT(c, kind=4) ff=NINT(c, kind=4) ff=INT(d, kind=4) ff=NINT(d, kind=4) ff=INT(f, kind=4) ff=INT(g, kind=4) ff=IFIX(a) ff=IDINT(b) ff=IDNINT(b) !---LONG not allowed anymore in gfortran 10 (?): !!ff=LONG(a) !!ff=LONG(b) !!ff=LONG(c) !!ff=LONG(d) !!ff=LONG(g) gg=INT(a, kind=8) gg=NINT(a, kind=8) gg=INT(b, kind=8) gg=NINT(b, kind=8) gg=INT(c, kind=8) gg=NINT(c, kind=8) gg=INT(d, kind=8) gg=NINT(d, kind=8) gg=INT(f, kind=8) gg=INT(g, kind=8) gg=IFIX(a) gg=IDINT(b) gg=IDNINT(b) gg=INT8(a) gg=INT8(b) gg=INT8(c) gg=INT8(d) gg=INT8(g) end
gpl-2.0
Shaswat27/scipy
scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/ssaitr.f
103
30696
c----------------------------------------------------------------------- c\BeginDoc c c\Name: ssaitr c c\Description: c Reverse communication interface for applying NP additional steps to c a K step symmetric Arnoldi factorization. c c Input: OP*V_{k} - V_{k}*H = r_{k}*e_{k}^T c c with (V_{k}^T)*B*V_{k} = I, (V_{k}^T)*B*r_{k} = 0. c c Output: OP*V_{k+p} - V_{k+p}*H = r_{k+p}*e_{k+p}^T c c with (V_{k+p}^T)*B*V_{k+p} = I, (V_{k+p}^T)*B*r_{k+p} = 0. c c where OP and B are as in ssaupd. The B-norm of r_{k+p} is also c computed and returned. c c\Usage: c call ssaitr c ( IDO, BMAT, N, K, NP, MODE, RESID, RNORM, V, LDV, H, LDH, c IPNTR, WORKD, INFO ) c c\Arguments c IDO Integer. (INPUT/OUTPUT) c Reverse communication flag. 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 WORK for X, c IPNTR(2) is the pointer into WORK for Y. c This is for the restart phase to force the new c starting vector into the range of OP. c IDO = 1: compute Y = OP * X where c IPNTR(1) is the pointer into WORK for X, c IPNTR(2) is the pointer into WORK for Y, c IPNTR(3) is the pointer into WORK for B * X. c IDO = 2: compute Y = B * X where c IPNTR(1) is the pointer into WORK for X, c IPNTR(2) is the pointer into WORK for Y. c IDO = 99: done c ------------------------------------------------------------- c When the routine is used in the "shift-and-invert" mode, the c vector B * Q is already available and does not need to be c recomputed in forming OP * Q. c c BMAT Character*1. (INPUT) c BMAT specifies the type of matrix B that defines the c semi-inner product for the operator OP. See ssaupd. c B = 'I' -> standard eigenvalue problem A*x = lambda*x c B = 'G' -> generalized eigenvalue problem A*x = lambda*M*x c c N Integer. (INPUT) c Dimension of the eigenproblem. c c K Integer. (INPUT) c Current order of H and the number of columns of V. c c NP Integer. (INPUT) c Number of additional Arnoldi steps to take. c c MODE Integer. (INPUT) c Signifies which form for "OP". If MODE=2 then c a reduction in the number of B matrix vector multiplies c is possible since the B-norm of OP*x is equivalent to c the inv(B)-norm of A*x. c c RESID Real array of length N. (INPUT/OUTPUT) c On INPUT: RESID contains the residual vector r_{k}. c On OUTPUT: RESID contains the residual vector r_{k+p}. c c RNORM Real scalar. (INPUT/OUTPUT) c On INPUT the B-norm of r_{k}. c On OUTPUT the B-norm of the updated residual r_{k+p}. c c V Real N by K+NP array. (INPUT/OUTPUT) c On INPUT: V contains the Arnoldi vectors in the first K c columns. c On OUTPUT: V contains the new NP Arnoldi vectors in the next c NP columns. The first K columns are unchanged. c c LDV Integer. (INPUT) c Leading dimension of V exactly as declared in the calling c program. c c H Real (K+NP) by 2 array. (INPUT/OUTPUT) c H is used to store the generated symmetric tridiagonal matrix c with the subdiagonal in the first column starting at H(2,1) c and the main diagonal in the second column. c c LDH Integer. (INPUT) c Leading dimension of H exactly as declared in the calling c program. c c IPNTR Integer array of length 3. (OUTPUT) c Pointer to mark the starting locations in the WORK for c vectors used by the Arnoldi iteration. c ------------------------------------------------------------- c IPNTR(1): pointer to the current operand vector X. c IPNTR(2): pointer to the current result vector Y. c IPNTR(3): pointer to the vector B * X when used in the c shift-and-invert mode. X is the current operand. c ------------------------------------------------------------- c c WORKD Real work array of length 3*N. (REVERSE COMMUNICATION) c Distributed array to be used in the basic Arnoldi iteration c for reverse communication. The calling program should not c use WORKD as temporary workspace during the iteration !!!!!! c On INPUT, WORKD(1:N) = B*RESID where RESID is associated c with the K step Arnoldi factorization. Used to save some c computation at the first step. c On OUTPUT, WORKD(1:N) = B*RESID where RESID is associated c with the K+NP step Arnoldi factorization. c c INFO Integer. (OUTPUT) c = 0: Normal exit. c > 0: Size of an invariant subspace of OP is found that is c less than K + NP. c c\EndDoc c c----------------------------------------------------------------------- c c\BeginLib c c\Local variables: c xxxxxx real c c\Routines called: c sgetv0 ARPACK routine to generate the initial vector. c ivout ARPACK utility routine that prints integers. c smout ARPACK utility routine that prints matrices. c svout ARPACK utility routine that prints vectors. c wslamch LAPACK routine that determines machine constants. c slascl LAPACK routine for careful scaling of a matrix. c sgemv Level 2 BLAS routine for matrix vector multiplication. c saxpy Level 1 BLAS that computes a vector triad. c sscal Level 1 BLAS that scales a vector. c scopy Level 1 BLAS that copies one vector to another . c wsdot Level 1 BLAS that computes the scalar product of two vectors. c wsnrm2 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\Revision history: c xx/xx/93: Version ' 2.4' c c\SCCS Information: @(#) c FILE: saitr.F SID: 2.6 DATE OF SID: 8/28/96 RELEASE: 2 c c\Remarks c The algorithm implemented is: c c restart = .false. c Given V_{k} = [v_{1}, ..., v_{k}], r_{k}; c r_{k} contains the initial residual vector even for k = 0; c Also assume that rnorm = || B*r_{k} || and B*r_{k} are already c computed by the calling program. c c betaj = rnorm ; p_{k+1} = B*r_{k} ; c For j = k+1, ..., k+np Do c 1) if ( betaj < tol ) stop or restart depending on j. c if ( restart ) generate a new starting vector. c 2) v_{j} = r(j-1)/betaj; V_{j} = [V_{j-1}, v_{j}]; c p_{j} = p_{j}/betaj c 3) r_{j} = OP*v_{j} where OP is defined as in ssaupd c For shift-invert mode p_{j} = B*v_{j} is already available. c wnorm = || OP*v_{j} || c 4) Compute the j-th step residual vector. c w_{j} = V_{j}^T * B * OP * v_{j} c r_{j} = OP*v_{j} - V_{j} * w_{j} c alphaj <- j-th component of w_{j} c rnorm = || r_{j} || c betaj+1 = rnorm c If (rnorm > 0.717*wnorm) accept step and go back to 1) c 5) Re-orthogonalization step: c s = V_{j}'*B*r_{j} c r_{j} = r_{j} - V_{j}*s; rnorm1 = || r_{j} || c alphaj = alphaj + s_{j}; c 6) Iterative refinement step: c If (rnorm1 > 0.717*rnorm) then c rnorm = rnorm1 c accept step and go back to 1) c Else c rnorm = rnorm1 c If this is the first time in step 6), go to 5) c Else r_{j} lies in the span of V_{j} numerically. c Set r_{j} = 0 and rnorm = 0; go to 1) c EndIf c End Do c c\EndLib c c----------------------------------------------------------------------- c subroutine ssaitr & (ido, bmat, n, k, np, mode, resid, rnorm, v, ldv, h, ldh, & ipntr, workd, info) 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 integer ido, info, k, ldh, ldv, n, mode, np Real & rnorm c c %-----------------% c | Array Arguments | c %-----------------% c integer ipntr(3) Real & h(ldh,2), resid(n), v(ldv,k+np), workd(3*n) c c %------------% c | Parameters | c %------------% c Real & one, zero parameter (one = 1.0E+0, zero = 0.0E+0) c c %---------------% c | Local Scalars | c %---------------% c logical first, orth1, orth2, rstart, step3, step4 integer i, ierr, ipj, irj, ivj, iter, itry, j, msglvl, & infol, jj Real & rnorm1, wnorm, safmin, temp1 save orth1, orth2, rstart, step3, step4, & ierr, ipj, irj, ivj, iter, itry, j, msglvl, & rnorm1, safmin, wnorm c c %-----------------------% c | Local Array Arguments | c %-----------------------% c Real & xtemp(2) c c %----------------------% c | External Subroutines | c %----------------------% c external saxpy, scopy, sscal, sgemv, sgetv0, svout, smout, & slascl, ivout, arscnd c c %--------------------% c | External Functions | c %--------------------% c Real & wsdot, wsnrm2, wslamch external wsdot, wsnrm2, wslamch c c %-----------------% c | Data statements | c %-----------------% c data first / .true. / c c %-----------------------% c | Executable Statements | c %-----------------------% c if (first) then first = .false. c c %--------------------------------% c | safmin = safe minimum is such | c | that 1/sfmin does not overflow | c %--------------------------------% c safmin = wslamch('safmin') end if c if (ido .eq. 0) then c c %-------------------------------% c | Initialize timing statistics | c | & message level for debugging | c %-------------------------------% c call arscnd (t0) msglvl = msaitr c c %------------------------------% c | Initial call to this routine | c %------------------------------% c info = 0 step3 = .false. step4 = .false. rstart = .false. orth1 = .false. orth2 = .false. c c %--------------------------------% c | Pointer to the current step of | c | the factorization to build | c %--------------------------------% c j = k + 1 c c %------------------------------------------% c | Pointers used for reverse communication | c | when using WORKD. | c %------------------------------------------% c ipj = 1 irj = ipj + n ivj = irj + n end if c c %-------------------------------------------------% c | When in reverse communication mode one of: | c | STEP3, STEP4, ORTH1, ORTH2, RSTART | c | will be .true. | c | STEP3: return from computing OP*v_{j}. | c | STEP4: return from computing B-norm of OP*v_{j} | c | ORTH1: return from computing B-norm of r_{j+1} | c | ORTH2: return from computing B-norm of | c | correction to the residual vector. | c | RSTART: return from OP computations needed by | c | sgetv0. | c %-------------------------------------------------% c if (step3) go to 50 if (step4) go to 60 if (orth1) go to 70 if (orth2) go to 90 if (rstart) go to 30 c c %------------------------------% c | Else this is the first step. | c %------------------------------% c c %--------------------------------------------------------------% c | | c | A R N O L D I I T E R A T I O N L O O P | c | | c | Note: B*r_{j-1} is already in WORKD(1:N)=WORKD(IPJ:IPJ+N-1) | c %--------------------------------------------------------------% c 1000 continue c if (msglvl .gt. 2) then call ivout (logfil, 1, j, ndigit, & '_saitr: generating Arnoldi vector no.') call svout (logfil, 1, rnorm, ndigit, & '_saitr: B-norm of the current residual =') end if c c %---------------------------------------------------------% c | Check for exact zero. Equivalent to determing whether a | c | j-step Arnoldi factorization is present. | c %---------------------------------------------------------% c if (rnorm .gt. zero) go to 40 c c %---------------------------------------------------% c | Invariant subspace found, generate a new starting | c | vector which is orthogonal to the current Arnoldi | c | basis and continue the iteration. | c %---------------------------------------------------% c if (msglvl .gt. 0) then call ivout (logfil, 1, j, ndigit, & '_saitr: ****** restart at step ******') end if c c %---------------------------------------------% c | ITRY is the loop variable that controls the | c | maximum amount of times that a restart is | c | attempted. NRSTRT is used by stat.h | c %---------------------------------------------% c nrstrt = nrstrt + 1 itry = 1 20 continue rstart = .true. ido = 0 30 continue c c %--------------------------------------% c | If in reverse communication mode and | c | RSTART = .true. flow returns here. | c %--------------------------------------% c call sgetv0 (ido, bmat, itry, .false., n, j, v, ldv, & resid, rnorm, ipntr, workd, ierr) if (ido .ne. 99) go to 9000 if (ierr .lt. 0) then itry = itry + 1 if (itry .le. 3) go to 20 c c %------------------------------------------------% c | Give up after several restart attempts. | c | Set INFO to the size of the invariant subspace | c | which spans OP and exit. | c %------------------------------------------------% c info = j - 1 call arscnd (t1) tsaitr = tsaitr + (t1 - t0) ido = 99 go to 9000 end if c 40 continue c c %---------------------------------------------------------% c | STEP 2: v_{j} = r_{j-1}/rnorm and p_{j} = p_{j}/rnorm | c | Note that p_{j} = B*r_{j-1}. In order to avoid overflow | c | when reciprocating a small RNORM, test against lower | c | machine bound. | c %---------------------------------------------------------% c call scopy (n, resid, 1, v(1,j), 1) if (rnorm .ge. safmin) then temp1 = one / rnorm call sscal (n, temp1, v(1,j), 1) call sscal (n, temp1, workd(ipj), 1) else c c %-----------------------------------------% c | To scale both v_{j} and p_{j} carefully | c | use LAPACK routine SLASCL | c %-----------------------------------------% c call slascl ('General', i, i, rnorm, one, n, 1, & v(1,j), n, infol) call slascl ('General', i, i, rnorm, one, n, 1, & workd(ipj), n, infol) end if c c %------------------------------------------------------% c | STEP 3: r_{j} = OP*v_{j}; Note that p_{j} = B*v_{j} | c | Note that this is not quite yet r_{j}. See STEP 4 | c %------------------------------------------------------% c step3 = .true. nopx = nopx + 1 call arscnd (t2) call scopy (n, v(1,j), 1, workd(ivj), 1) ipntr(1) = ivj ipntr(2) = irj ipntr(3) = ipj ido = 1 c c %-----------------------------------% c | Exit in order to compute OP*v_{j} | c %-----------------------------------% c go to 9000 50 continue c c %-----------------------------------% c | Back from reverse communication; | c | WORKD(IRJ:IRJ+N-1) := OP*v_{j}. | c %-----------------------------------% c call arscnd (t3) tmvopx = tmvopx + (t3 - t2) c step3 = .false. c c %------------------------------------------% c | Put another copy of OP*v_{j} into RESID. | c %------------------------------------------% c call scopy (n, workd(irj), 1, resid, 1) c c %-------------------------------------------% c | STEP 4: Finish extending the symmetric | c | Arnoldi to length j. If MODE = 2 | c | then B*OP = B*inv(B)*A = A and | c | we don't need to compute B*OP. | c | NOTE: If MODE = 2 WORKD(IVJ:IVJ+N-1) is | c | assumed to have A*v_{j}. | c %-------------------------------------------% c if (mode .eq. 2) go to 65 call arscnd (t2) if (bmat .eq. 'G') then nbx = nbx + 1 step4 = .true. ipntr(1) = irj ipntr(2) = ipj ido = 2 c c %-------------------------------------% c | Exit in order to compute B*OP*v_{j} | c %-------------------------------------% c go to 9000 else if (bmat .eq. 'I') then call scopy(n, resid, 1 , workd(ipj), 1) end if 60 continue c c %-----------------------------------% c | Back from reverse communication; | c | WORKD(IPJ:IPJ+N-1) := B*OP*v_{j}. | c %-----------------------------------% c if (bmat .eq. 'G') then call arscnd (t3) tmvbx = tmvbx + (t3 - t2) end if c step4 = .false. c c %-------------------------------------% c | The following is needed for STEP 5. | c | Compute the B-norm of OP*v_{j}. | c %-------------------------------------% c 65 continue if (mode .eq. 2) then c c %----------------------------------% c | Note that the B-norm of OP*v_{j} | c | is the inv(B)-norm of A*v_{j}. | c %----------------------------------% c wnorm = wsdot (n, resid, 1, workd(ivj), 1) wnorm = sqrt(abs(wnorm)) else if (bmat .eq. 'G') then wnorm = wsdot (n, resid, 1, workd(ipj), 1) wnorm = sqrt(abs(wnorm)) else if (bmat .eq. 'I') then wnorm = wsnrm2(n, resid, 1) end if c c %-----------------------------------------% c | Compute the j-th residual corresponding | c | to the j step factorization. | c | Use Classical Gram Schmidt and compute: | c | w_{j} <- V_{j}^T * B * OP * v_{j} | c | r_{j} <- OP*v_{j} - V_{j} * w_{j} | c %-----------------------------------------% c c c %------------------------------------------% c | Compute the j Fourier coefficients w_{j} | c | WORKD(IPJ:IPJ+N-1) contains B*OP*v_{j}. | c %------------------------------------------% c if (mode .ne. 2 ) then call sgemv('T', n, j, one, v, ldv, workd(ipj), 1, zero, & workd(irj), 1) else if (mode .eq. 2) then call sgemv('T', n, j, one, v, ldv, workd(ivj), 1, zero, & workd(irj), 1) end if c c %--------------------------------------% c | Orthgonalize r_{j} against V_{j}. | c | RESID contains OP*v_{j}. See STEP 3. | c %--------------------------------------% c call sgemv('N', n, j, -one, v, ldv, workd(irj), 1, one, & resid, 1) c c %--------------------------------------% c | Extend H to have j rows and columns. | c %--------------------------------------% c h(j,2) = workd(irj + j - 1) if (j .eq. 1 .or. rstart) then h(j,1) = zero else h(j,1) = rnorm end if call arscnd (t4) c orth1 = .true. iter = 0 c call arscnd (t2) if (bmat .eq. 'G') then nbx = nbx + 1 call scopy (n, resid, 1, workd(irj), 1) ipntr(1) = irj ipntr(2) = ipj ido = 2 c c %----------------------------------% c | Exit in order to compute B*r_{j} | c %----------------------------------% c go to 9000 else if (bmat .eq. 'I') then call scopy (n, resid, 1, workd(ipj), 1) end if 70 continue c c %---------------------------------------------------% c | Back from reverse communication if ORTH1 = .true. | c | WORKD(IPJ:IPJ+N-1) := B*r_{j}. | c %---------------------------------------------------% c if (bmat .eq. 'G') then call arscnd (t3) tmvbx = tmvbx + (t3 - t2) end if c orth1 = .false. c c %------------------------------% c | Compute the B-norm of r_{j}. | c %------------------------------% c if (bmat .eq. 'G') then rnorm = wsdot (n, resid, 1, workd(ipj), 1) rnorm = sqrt(abs(rnorm)) else if (bmat .eq. 'I') then rnorm = wsnrm2(n, resid, 1) end if c c %-----------------------------------------------------------% c | STEP 5: Re-orthogonalization / Iterative refinement phase | c | Maximum NITER_ITREF tries. | c | | c | s = V_{j}^T * B * r_{j} | c | r_{j} = r_{j} - V_{j}*s | c | alphaj = alphaj + s_{j} | c | | c | The stopping criteria used for iterative refinement is | c | discussed in Parlett's book SEP, page 107 and in Gragg & | c | Reichel ACM TOMS paper; Algorithm 686, Dec. 1990. | c | Determine if we need to correct the residual. The goal is | c | to enforce ||v(:,1:j)^T * r_{j}|| .le. eps * || r_{j} || | c %-----------------------------------------------------------% c if (rnorm .gt. 0.717*wnorm) go to 100 nrorth = nrorth + 1 c c %---------------------------------------------------% c | Enter the Iterative refinement phase. If further | c | refinement is necessary, loop back here. The loop | c | variable is ITER. Perform a step of Classical | c | Gram-Schmidt using all the Arnoldi vectors V_{j} | c %---------------------------------------------------% c 80 continue c if (msglvl .gt. 2) then xtemp(1) = wnorm xtemp(2) = rnorm call svout (logfil, 2, xtemp, ndigit, & '_saitr: re-orthonalization ; wnorm and rnorm are') end if c c %----------------------------------------------------% c | Compute V_{j}^T * B * r_{j}. | c | WORKD(IRJ:IRJ+J-1) = v(:,1:J)'*WORKD(IPJ:IPJ+N-1). | c %----------------------------------------------------% c call sgemv ('T', n, j, one, v, ldv, workd(ipj), 1, & zero, workd(irj), 1) c c %----------------------------------------------% c | Compute the correction to the residual: | c | r_{j} = r_{j} - V_{j} * WORKD(IRJ:IRJ+J-1). | c | The correction to H is v(:,1:J)*H(1:J,1:J) + | c | v(:,1:J)*WORKD(IRJ:IRJ+J-1)*e'_j, but only | c | H(j,j) is updated. | c %----------------------------------------------% c call sgemv ('N', n, j, -one, v, ldv, workd(irj), 1, & one, resid, 1) c if (j .eq. 1 .or. rstart) h(j,1) = zero h(j,2) = h(j,2) + workd(irj + j - 1) c orth2 = .true. call arscnd (t2) if (bmat .eq. 'G') then nbx = nbx + 1 call scopy (n, resid, 1, workd(irj), 1) ipntr(1) = irj ipntr(2) = ipj ido = 2 c c %-----------------------------------% c | Exit in order to compute B*r_{j}. | c | r_{j} is the corrected residual. | c %-----------------------------------% c go to 9000 else if (bmat .eq. 'I') then call scopy (n, resid, 1, workd(ipj), 1) end if 90 continue c c %---------------------------------------------------% c | Back from reverse communication if ORTH2 = .true. | c %---------------------------------------------------% c if (bmat .eq. 'G') then call arscnd (t3) tmvbx = tmvbx + (t3 - t2) end if c c %-----------------------------------------------------% c | Compute the B-norm of the corrected residual r_{j}. | c %-----------------------------------------------------% c if (bmat .eq. 'G') then rnorm1 = wsdot (n, resid, 1, workd(ipj), 1) rnorm1 = sqrt(abs(rnorm1)) else if (bmat .eq. 'I') then rnorm1 = wsnrm2(n, resid, 1) end if c if (msglvl .gt. 0 .and. iter .gt. 0) then call ivout (logfil, 1, j, ndigit, & '_saitr: Iterative refinement for Arnoldi residual') if (msglvl .gt. 2) then xtemp(1) = rnorm xtemp(2) = rnorm1 call svout (logfil, 2, xtemp, ndigit, & '_saitr: iterative refinement ; rnorm and rnorm1 are') end if end if c c %-----------------------------------------% c | Determine if we need to perform another | c | step of re-orthogonalization. | c %-----------------------------------------% c if (rnorm1 .gt. 0.717*rnorm) then c c %--------------------------------% c | No need for further refinement | c %--------------------------------% c rnorm = rnorm1 c else c c %-------------------------------------------% c | Another step of iterative refinement step | c | is required. NITREF is used by stat.h | c %-------------------------------------------% c nitref = nitref + 1 rnorm = rnorm1 iter = iter + 1 if (iter .le. 1) go to 80 c c %-------------------------------------------------% c | Otherwise RESID is numerically in the span of V | c %-------------------------------------------------% c do 95 jj = 1, n resid(jj) = zero 95 continue rnorm = zero end if c c %----------------------------------------------% c | Branch here directly if iterative refinement | c | wasn't necessary or after at most NITER_REF | c | steps of iterative refinement. | c %----------------------------------------------% c 100 continue c rstart = .false. orth2 = .false. c call arscnd (t5) titref = titref + (t5 - t4) c c %----------------------------------------------------------% c | Make sure the last off-diagonal element is non negative | c | If not perform a similarity transformation on H(1:j,1:j) | c | and scale v(:,j) by -1. | c %----------------------------------------------------------% c if (h(j,1) .lt. zero) then h(j,1) = -h(j,1) if ( j .lt. k+np) then call sscal(n, -one, v(1,j+1), 1) else call sscal(n, -one, resid, 1) end if end if c c %------------------------------------% c | STEP 6: Update j = j+1; Continue | c %------------------------------------% c j = j + 1 if (j .gt. k+np) then call arscnd (t1) tsaitr = tsaitr + (t1 - t0) ido = 99 c if (msglvl .gt. 1) then call svout (logfil, k+np, h(1,2), ndigit, & '_saitr: main diagonal of matrix H of step K+NP.') if (k+np .gt. 1) then call svout (logfil, k+np-1, h(2,1), ndigit, & '_saitr: sub diagonal of matrix H of step K+NP.') end if end if c go to 9000 end if c c %--------------------------------------------------------% c | Loop back to extend the factorization by another step. | c %--------------------------------------------------------% c go to 1000 c c %---------------------------------------------------------------% c | | c | E N D O F M A I N I T E R A T I O N L O O P | c | | c %---------------------------------------------------------------% c 9000 continue return c c %---------------% c | End of ssaitr | c %---------------% c end
bsd-3-clause
mkumatag/origin
vendor/github.com/gonum/lapack/internal/testdata/netlib/xerbla.f
91
2161
*> \brief \b XERBLA * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE XERBLA( SRNAME, INFO ) * * .. Scalar Arguments .. * CHARACTER*(*) SRNAME * INTEGER INFO * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> XERBLA is an error handler for the LAPACK routines. *> It is called by an LAPACK routine if an input parameter has an *> invalid value. A message is printed and execution stops. *> *> Installers may consider modifying the STOP statement in order to *> call system-specific exception-handling facilities. *> \endverbatim * * Arguments: * ========== * *> \param[in] SRNAME *> \verbatim *> SRNAME is CHARACTER*(*) *> The name of the routine which called XERBLA. *> \endverbatim *> *> \param[in] INFO *> \verbatim *> INFO is INTEGER *> The position of the invalid parameter in the parameter list *> of the calling routine. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup aux_blas * * ===================================================================== SUBROUTINE XERBLA( SRNAME, INFO ) * * -- Reference BLAS level1 routine (version 3.4.0) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER*(*) SRNAME INTEGER INFO * .. * * ===================================================================== * * .. Intrinsic Functions .. INTRINSIC LEN_TRIM * .. * .. Executable Statements .. * WRITE( *, FMT = 9999 )SRNAME( 1:LEN_TRIM( SRNAME ) ), INFO * STOP * 9999 FORMAT( ' ** On entry to ', A, ' parameter number ', I2, ' had ', $ 'an illegal value' ) * * End of XERBLA * END
apache-2.0
mkumatag/origin
vendor/gonum.org/v1/gonum/lapack/internal/testdata/netlib/xerbla.f
91
2161
*> \brief \b XERBLA * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE XERBLA( SRNAME, INFO ) * * .. Scalar Arguments .. * CHARACTER*(*) SRNAME * INTEGER INFO * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> XERBLA is an error handler for the LAPACK routines. *> It is called by an LAPACK routine if an input parameter has an *> invalid value. A message is printed and execution stops. *> *> Installers may consider modifying the STOP statement in order to *> call system-specific exception-handling facilities. *> \endverbatim * * Arguments: * ========== * *> \param[in] SRNAME *> \verbatim *> SRNAME is CHARACTER*(*) *> The name of the routine which called XERBLA. *> \endverbatim *> *> \param[in] INFO *> \verbatim *> INFO is INTEGER *> The position of the invalid parameter in the parameter list *> of the calling routine. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup aux_blas * * ===================================================================== SUBROUTINE XERBLA( SRNAME, INFO ) * * -- Reference BLAS level1 routine (version 3.4.0) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER*(*) SRNAME INTEGER INFO * .. * * ===================================================================== * * .. Intrinsic Functions .. INTRINSIC LEN_TRIM * .. * .. Executable Statements .. * WRITE( *, FMT = 9999 )SRNAME( 1:LEN_TRIM( SRNAME ) ), INFO * STOP * 9999 FORMAT( ' ** On entry to ', A, ' parameter number ', I2, ' had ', $ 'an illegal value' ) * * End of XERBLA * END
apache-2.0
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/SRC/cposvx.f
28
16696
*> \brief <b> CPOSVX computes the solution to system of linear equations A * X = B for PO matrices</b> * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download CPOSVX + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cposvx.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cposvx.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cposvx.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE CPOSVX( FACT, UPLO, N, NRHS, A, LDA, AF, LDAF, EQUED, * S, B, LDB, X, LDX, RCOND, FERR, BERR, WORK, * RWORK, INFO ) * * .. Scalar Arguments .. * CHARACTER EQUED, FACT, UPLO * INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS * REAL RCOND * .. * .. Array Arguments .. * REAL BERR( * ), FERR( * ), RWORK( * ), S( * ) * COMPLEX A( LDA, * ), AF( LDAF, * ), B( LDB, * ), * $ WORK( * ), X( LDX, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> CPOSVX uses the Cholesky factorization A = U**H*U or A = L*L**H to *> compute the solution to a complex system of linear equations *> A * X = B, *> where A is an N-by-N Hermitian positive definite matrix and X and B *> are N-by-NRHS matrices. *> *> Error bounds on the solution and a condition estimate are also *> provided. *> \endverbatim * *> \par Description: * ================= *> *> \verbatim *> *> The following steps are performed: *> *> 1. If FACT = 'E', real scaling factors are computed to equilibrate *> the system: *> diag(S) * A * diag(S) * inv(diag(S)) * X = diag(S) * B *> Whether or not the system will be equilibrated depends on the *> scaling of the matrix A, but if equilibration is used, A is *> overwritten by diag(S)*A*diag(S) and B by diag(S)*B. *> *> 2. If FACT = 'N' or 'E', the Cholesky decomposition is used to *> factor the matrix A (after equilibration if FACT = 'E') as *> A = U**H* U, if UPLO = 'U', or *> A = L * L**H, if UPLO = 'L', *> where U is an upper triangular matrix and L is a lower triangular *> matrix. *> *> 3. If the leading i-by-i principal minor is not positive definite, *> then the routine returns with INFO = i. Otherwise, the factored *> form of A is used to estimate the condition number of the matrix *> A. If the reciprocal of the condition number is less than machine *> precision, INFO = N+1 is returned as a warning, but the routine *> still goes on to solve for X and compute error bounds as *> described below. *> *> 4. The system of equations is solved for X using the factored form *> of A. *> *> 5. Iterative refinement is applied to improve the computed solution *> matrix and calculate error bounds and backward error estimates *> for it. *> *> 6. If equilibration was used, the matrix X is premultiplied by *> diag(S) so that it solves the original system before *> equilibration. *> \endverbatim * * Arguments: * ========== * *> \param[in] FACT *> \verbatim *> FACT is CHARACTER*1 *> Specifies whether or not the factored form of the matrix A is *> supplied on entry, and if not, whether the matrix A should be *> equilibrated before it is factored. *> = 'F': On entry, AF contains the factored form of A. *> If EQUED = 'Y', the matrix A has been equilibrated *> with scaling factors given by S. A and AF will not *> be modified. *> = 'N': The matrix A will be copied to AF and factored. *> = 'E': The matrix A will be equilibrated if necessary, then *> copied to AF and factored. *> \endverbatim *> *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> = 'U': Upper triangle of A is stored; *> = 'L': Lower triangle of A is stored. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of linear equations, i.e., the order of the *> matrix A. N >= 0. *> \endverbatim *> *> \param[in] NRHS *> \verbatim *> NRHS is INTEGER *> The number of right hand sides, i.e., the number of columns *> of the matrices B and X. NRHS >= 0. *> \endverbatim *> *> \param[in,out] A *> \verbatim *> A is COMPLEX array, dimension (LDA,N) *> On entry, the Hermitian matrix A, except if FACT = 'F' and *> EQUED = 'Y', then A must contain the equilibrated matrix *> diag(S)*A*diag(S). If UPLO = 'U', the leading *> N-by-N upper triangular part of A contains the upper *> triangular part of the matrix A, and the strictly lower *> triangular part of A is not referenced. If UPLO = 'L', the *> leading N-by-N lower triangular part of A contains the lower *> triangular part of the matrix A, and the strictly upper *> triangular part of A is not referenced. A is not modified if *> FACT = 'F' or 'N', or if FACT = 'E' and EQUED = 'N' on exit. *> *> On exit, if FACT = 'E' and EQUED = 'Y', A is overwritten by *> diag(S)*A*diag(S). *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. LDA >= max(1,N). *> \endverbatim *> *> \param[in,out] AF *> \verbatim *> AF is COMPLEX array, dimension (LDAF,N) *> If FACT = 'F', then AF is an input argument and on entry *> contains the triangular factor U or L from the Cholesky *> factorization A = U**H*U or A = L*L**H, in the same storage *> format as A. If EQUED .ne. 'N', then AF is the factored form *> of the equilibrated matrix diag(S)*A*diag(S). *> *> If FACT = 'N', then AF is an output argument and on exit *> returns the triangular factor U or L from the Cholesky *> factorization A = U**H*U or A = L*L**H of the original *> matrix A. *> *> If FACT = 'E', then AF is an output argument and on exit *> returns the triangular factor U or L from the Cholesky *> factorization A = U**H*U or A = L*L**H of the equilibrated *> matrix A (see the description of A for the form of the *> equilibrated matrix). *> \endverbatim *> *> \param[in] LDAF *> \verbatim *> LDAF is INTEGER *> The leading dimension of the array AF. LDAF >= max(1,N). *> \endverbatim *> *> \param[in,out] EQUED *> \verbatim *> EQUED is CHARACTER*1 *> Specifies the form of equilibration that was done. *> = 'N': No equilibration (always true if FACT = 'N'). *> = 'Y': Equilibration was done, i.e., A has been replaced by *> diag(S) * A * diag(S). *> EQUED is an input argument if FACT = 'F'; otherwise, it is an *> output argument. *> \endverbatim *> *> \param[in,out] S *> \verbatim *> S is REAL array, dimension (N) *> The scale factors for A; not accessed if EQUED = 'N'. S is *> an input argument if FACT = 'F'; otherwise, S is an output *> argument. If FACT = 'F' and EQUED = 'Y', each element of S *> must be positive. *> \endverbatim *> *> \param[in,out] B *> \verbatim *> B is COMPLEX array, dimension (LDB,NRHS) *> On entry, the N-by-NRHS righthand side matrix B. *> On exit, if EQUED = 'N', B is not modified; if EQUED = 'Y', *> B is overwritten by diag(S) * B. *> \endverbatim *> *> \param[in] LDB *> \verbatim *> LDB is INTEGER *> The leading dimension of the array B. LDB >= max(1,N). *> \endverbatim *> *> \param[out] X *> \verbatim *> X is COMPLEX array, dimension (LDX,NRHS) *> If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X to *> the original system of equations. Note that if EQUED = 'Y', *> A and B are modified on exit, and the solution to the *> equilibrated system is inv(diag(S))*X. *> \endverbatim *> *> \param[in] LDX *> \verbatim *> LDX is INTEGER *> The leading dimension of the array X. LDX >= max(1,N). *> \endverbatim *> *> \param[out] RCOND *> \verbatim *> RCOND is REAL *> The estimate of the reciprocal condition number of the matrix *> A after equilibration (if done). If RCOND is less than the *> machine precision (in particular, if RCOND = 0), the matrix *> is singular to working precision. This condition is *> indicated by a return code of INFO > 0. *> \endverbatim *> *> \param[out] FERR *> \verbatim *> FERR is REAL array, dimension (NRHS) *> The estimated forward error bound for each solution vector *> X(j) (the j-th column of the solution matrix X). *> If XTRUE is the true solution corresponding to X(j), FERR(j) *> is an estimated upper bound for the magnitude of the largest *> element in (X(j) - XTRUE) divided by the magnitude of the *> largest element in X(j). The estimate is as reliable as *> the estimate for RCOND, and is almost always a slight *> overestimate of the true error. *> \endverbatim *> *> \param[out] BERR *> \verbatim *> BERR is REAL array, dimension (NRHS) *> The componentwise relative backward error of each solution *> vector X(j) (i.e., the smallest relative change in *> any element of A or B that makes X(j) an exact solution). *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is COMPLEX array, dimension (2*N) *> \endverbatim *> *> \param[out] RWORK *> \verbatim *> RWORK is REAL array, dimension (N) *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> > 0: if INFO = i, and i is *> <= N: the leading minor of order i of A is *> not positive definite, so the factorization *> could not be completed, and the solution has not *> been computed. RCOND = 0 is returned. *> = N+1: U is nonsingular, but RCOND is less than machine *> precision, meaning that the matrix is singular *> to working precision. Nevertheless, the *> solution and error bounds are computed because *> there are a number of situations where the *> computed solution can be more accurate than the *> value of RCOND would suggest. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date April 2012 * *> \ingroup complexPOsolve * * ===================================================================== SUBROUTINE CPOSVX( FACT, UPLO, N, NRHS, A, LDA, AF, LDAF, EQUED, $ S, B, LDB, X, LDX, RCOND, FERR, BERR, WORK, $ RWORK, INFO ) * * -- LAPACK driver routine (version 3.4.1) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * April 2012 * * .. Scalar Arguments .. CHARACTER EQUED, FACT, UPLO INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS REAL RCOND * .. * .. Array Arguments .. REAL BERR( * ), FERR( * ), RWORK( * ), S( * ) COMPLEX A( LDA, * ), AF( LDAF, * ), B( LDB, * ), $ WORK( * ), X( LDX, * ) * .. * * ===================================================================== * * .. Parameters .. REAL ZERO, ONE PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) * .. * .. Local Scalars .. LOGICAL EQUIL, NOFACT, RCEQU INTEGER I, INFEQU, J REAL AMAX, ANORM, BIGNUM, SCOND, SMAX, SMIN, SMLNUM * .. * .. External Functions .. LOGICAL LSAME REAL CLANHE, SLAMCH EXTERNAL LSAME, CLANHE, SLAMCH * .. * .. External Subroutines .. EXTERNAL CLACPY, CLAQHE, CPOCON, CPOEQU, CPORFS, CPOTRF, $ CPOTRS, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. * .. Executable Statements .. * INFO = 0 NOFACT = LSAME( FACT, 'N' ) EQUIL = LSAME( FACT, 'E' ) IF( NOFACT .OR. EQUIL ) THEN EQUED = 'N' RCEQU = .FALSE. ELSE RCEQU = LSAME( EQUED, 'Y' ) SMLNUM = SLAMCH( 'Safe minimum' ) BIGNUM = ONE / SMLNUM END IF * * Test the input parameters. * IF( .NOT.NOFACT .AND. .NOT.EQUIL .AND. .NOT.LSAME( FACT, 'F' ) ) $ THEN INFO = -1 ELSE IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) $ THEN INFO = -2 ELSE IF( N.LT.0 ) THEN INFO = -3 ELSE IF( NRHS.LT.0 ) THEN INFO = -4 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN INFO = -6 ELSE IF( LDAF.LT.MAX( 1, N ) ) THEN INFO = -8 ELSE IF( LSAME( FACT, 'F' ) .AND. .NOT. $ ( RCEQU .OR. LSAME( EQUED, 'N' ) ) ) THEN INFO = -9 ELSE IF( RCEQU ) THEN SMIN = BIGNUM SMAX = ZERO DO 10 J = 1, N SMIN = MIN( SMIN, S( J ) ) SMAX = MAX( SMAX, S( J ) ) 10 CONTINUE IF( SMIN.LE.ZERO ) THEN INFO = -10 ELSE IF( N.GT.0 ) THEN SCOND = MAX( SMIN, SMLNUM ) / MIN( SMAX, BIGNUM ) ELSE SCOND = ONE END IF END IF IF( INFO.EQ.0 ) THEN IF( LDB.LT.MAX( 1, N ) ) THEN INFO = -12 ELSE IF( LDX.LT.MAX( 1, N ) ) THEN INFO = -14 END IF END IF END IF * IF( INFO.NE.0 ) THEN CALL XERBLA( 'CPOSVX', -INFO ) RETURN END IF * IF( EQUIL ) THEN * * Compute row and column scalings to equilibrate the matrix A. * CALL CPOEQU( N, A, LDA, S, SCOND, AMAX, INFEQU ) IF( INFEQU.EQ.0 ) THEN * * Equilibrate the matrix. * CALL CLAQHE( UPLO, N, A, LDA, S, SCOND, AMAX, EQUED ) RCEQU = LSAME( EQUED, 'Y' ) END IF END IF * * Scale the right hand side. * IF( RCEQU ) THEN DO 30 J = 1, NRHS DO 20 I = 1, N B( I, J ) = S( I )*B( I, J ) 20 CONTINUE 30 CONTINUE END IF * IF( NOFACT .OR. EQUIL ) THEN * * Compute the Cholesky factorization A = U**H *U or A = L*L**H. * CALL CLACPY( UPLO, N, N, A, LDA, AF, LDAF ) CALL CPOTRF( UPLO, N, AF, LDAF, INFO ) * * Return if INFO is non-zero. * IF( INFO.GT.0 )THEN RCOND = ZERO RETURN END IF END IF * * Compute the norm of the matrix A. * ANORM = CLANHE( '1', UPLO, N, A, LDA, RWORK ) * * Compute the reciprocal of the condition number of A. * CALL CPOCON( UPLO, N, AF, LDAF, ANORM, RCOND, WORK, RWORK, INFO ) * * Compute the solution matrix X. * CALL CLACPY( 'Full', N, NRHS, B, LDB, X, LDX ) CALL CPOTRS( UPLO, N, NRHS, AF, LDAF, X, LDX, INFO ) * * Use iterative refinement to improve the computed solution and * compute error bounds and backward error estimates for it. * CALL CPORFS( UPLO, N, NRHS, A, LDA, AF, LDAF, B, LDB, X, LDX, $ FERR, BERR, WORK, RWORK, INFO ) * * Transform the solution matrix X to a solution of the original * system. * IF( RCEQU ) THEN DO 50 J = 1, NRHS DO 40 I = 1, N X( I, J ) = S( I )*X( I, J ) 40 CONTINUE 50 CONTINUE DO 60 J = 1, NRHS FERR( J ) = FERR( J ) / SCOND 60 CONTINUE END IF * * Set INFO = N+1 if the matrix is singular to working precision. * IF( RCOND.LT.SLAMCH( 'Epsilon' ) ) $ INFO = N + 1 * RETURN * * End of CPOSVX * END
bsd-3-clause
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/SRC/ssbgvd.f
5
11830
*> \brief \b SSBGVD * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download SSBGVD + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssbgvd.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssbgvd.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssbgvd.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE SSBGVD( JOBZ, UPLO, N, KA, KB, AB, LDAB, BB, LDBB, W, * Z, LDZ, WORK, LWORK, IWORK, LIWORK, INFO ) * * .. Scalar Arguments .. * CHARACTER JOBZ, UPLO * INTEGER INFO, KA, KB, LDAB, LDBB, LDZ, LIWORK, LWORK, N * .. * .. Array Arguments .. * INTEGER IWORK( * ) * REAL AB( LDAB, * ), BB( LDBB, * ), W( * ), * $ WORK( * ), Z( LDZ, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> SSBGVD computes all the eigenvalues, and optionally, the eigenvectors *> of a real generalized symmetric-definite banded eigenproblem, of the *> form A*x=(lambda)*B*x. Here A and B are assumed to be symmetric and *> banded, and B is also positive definite. If eigenvectors are *> desired, it uses a divide and conquer algorithm. *> *> The divide and conquer algorithm makes very mild assumptions about *> floating point arithmetic. It will work on machines with a guard *> digit in add/subtract, or on those binary machines without guard *> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or *> Cray-2. It could conceivably fail on hexadecimal or decimal machines *> without guard digits, but we know of none. *> \endverbatim * * Arguments: * ========== * *> \param[in] JOBZ *> \verbatim *> JOBZ is CHARACTER*1 *> = 'N': Compute eigenvalues only; *> = 'V': Compute eigenvalues and eigenvectors. *> \endverbatim *> *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> = 'U': Upper triangles of A and B are stored; *> = 'L': Lower triangles of A and B are stored. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the matrices A and B. N >= 0. *> \endverbatim *> *> \param[in] KA *> \verbatim *> KA is INTEGER *> The number of superdiagonals of the matrix A if UPLO = 'U', *> or the number of subdiagonals if UPLO = 'L'. KA >= 0. *> \endverbatim *> *> \param[in] KB *> \verbatim *> KB is INTEGER *> The number of superdiagonals of the matrix B if UPLO = 'U', *> or the number of subdiagonals if UPLO = 'L'. KB >= 0. *> \endverbatim *> *> \param[in,out] AB *> \verbatim *> AB is REAL array, dimension (LDAB, N) *> On entry, the upper or lower triangle of the symmetric band *> matrix A, stored in the first ka+1 rows of the array. The *> j-th column of A is stored in the j-th column of the array AB *> as follows: *> if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j; *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+ka). *> *> On exit, the contents of AB are destroyed. *> \endverbatim *> *> \param[in] LDAB *> \verbatim *> LDAB is INTEGER *> The leading dimension of the array AB. LDAB >= KA+1. *> \endverbatim *> *> \param[in,out] BB *> \verbatim *> BB is REAL array, dimension (LDBB, N) *> On entry, the upper or lower triangle of the symmetric band *> matrix B, stored in the first kb+1 rows of the array. The *> j-th column of B is stored in the j-th column of the array BB *> as follows: *> if UPLO = 'U', BB(ka+1+i-j,j) = B(i,j) for max(1,j-kb)<=i<=j; *> if UPLO = 'L', BB(1+i-j,j) = B(i,j) for j<=i<=min(n,j+kb). *> *> On exit, the factor S from the split Cholesky factorization *> B = S**T*S, as returned by SPBSTF. *> \endverbatim *> *> \param[in] LDBB *> \verbatim *> LDBB is INTEGER *> The leading dimension of the array BB. LDBB >= KB+1. *> \endverbatim *> *> \param[out] W *> \verbatim *> W is REAL array, dimension (N) *> If INFO = 0, the eigenvalues in ascending order. *> \endverbatim *> *> \param[out] Z *> \verbatim *> Z is REAL array, dimension (LDZ, N) *> If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of *> eigenvectors, with the i-th column of Z holding the *> eigenvector associated with W(i). The eigenvectors are *> normalized so Z**T*B*Z = I. *> If JOBZ = 'N', then Z is not referenced. *> \endverbatim *> *> \param[in] LDZ *> \verbatim *> LDZ is INTEGER *> The leading dimension of the array Z. LDZ >= 1, and if *> JOBZ = 'V', LDZ >= max(1,N). *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is REAL array, dimension (MAX(1,LWORK)) *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. *> \endverbatim *> *> \param[in] LWORK *> \verbatim *> LWORK is INTEGER *> The dimension of the array WORK. *> If N <= 1, LWORK >= 1. *> If JOBZ = 'N' and N > 1, LWORK >= 3*N. *> If JOBZ = 'V' and N > 1, LWORK >= 1 + 5*N + 2*N**2. *> *> If LWORK = -1, then a workspace query is assumed; the routine *> only calculates the optimal sizes of the WORK and IWORK *> arrays, returns these values as the first entries of the WORK *> and IWORK arrays, and no error message related to LWORK or *> LIWORK is issued by XERBLA. *> \endverbatim *> *> \param[out] IWORK *> \verbatim *> IWORK is INTEGER array, dimension (MAX(1,LIWORK)) *> On exit, if LIWORK > 0, IWORK(1) returns the optimal LIWORK. *> \endverbatim *> *> \param[in] LIWORK *> \verbatim *> LIWORK is INTEGER *> The dimension of the array IWORK. *> If JOBZ = 'N' or N <= 1, LIWORK >= 1. *> If JOBZ = 'V' and N > 1, LIWORK >= 3 + 5*N. *> *> If LIWORK = -1, then a workspace query is assumed; the *> routine only calculates the optimal sizes of the WORK and *> IWORK arrays, returns these values as the first entries of *> the WORK and IWORK arrays, and no error message related to *> LWORK or LIWORK is issued by XERBLA. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> > 0: if INFO = i, and i is: *> <= N: the algorithm failed to converge: *> i off-diagonal elements of an intermediate *> tridiagonal form did not converge to zero; *> > N: if INFO = N + i, for 1 <= i <= N, then SPBSTF *> returned INFO = i: B is not positive definite. *> The factorization of B could not be completed and *> no eigenvalues or eigenvectors were computed. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2015 * *> \ingroup realOTHEReigen * *> \par Contributors: * ================== *> *> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA * * ===================================================================== SUBROUTINE SSBGVD( JOBZ, UPLO, N, KA, KB, AB, LDAB, BB, LDBB, W, $ Z, LDZ, WORK, LWORK, IWORK, LIWORK, INFO ) * * -- LAPACK driver routine (version 3.6.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2015 * * .. Scalar Arguments .. CHARACTER JOBZ, UPLO INTEGER INFO, KA, KB, LDAB, LDBB, LDZ, LIWORK, LWORK, N * .. * .. Array Arguments .. INTEGER IWORK( * ) REAL AB( LDAB, * ), BB( LDBB, * ), W( * ), $ WORK( * ), Z( LDZ, * ) * .. * * ===================================================================== * * .. Parameters .. REAL ONE, ZERO PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) * .. * .. Local Scalars .. LOGICAL LQUERY, UPPER, WANTZ CHARACTER VECT INTEGER IINFO, INDE, INDWK2, INDWRK, LIWMIN, LLWRK2, $ LWMIN * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL SGEMM, SLACPY, SPBSTF, SSBGST, SSBTRD, SSTEDC, $ SSTERF, XERBLA * .. * .. Executable Statements .. * * Test the input parameters. * WANTZ = LSAME( JOBZ, 'V' ) UPPER = LSAME( UPLO, 'U' ) LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 ) * INFO = 0 IF( N.LE.1 ) THEN LIWMIN = 1 LWMIN = 1 ELSE IF( WANTZ ) THEN LIWMIN = 3 + 5*N LWMIN = 1 + 5*N + 2*N**2 ELSE LIWMIN = 1 LWMIN = 2*N END IF * IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN INFO = -1 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN INFO = -2 ELSE IF( N.LT.0 ) THEN INFO = -3 ELSE IF( KA.LT.0 ) THEN INFO = -4 ELSE IF( KB.LT.0 .OR. KB.GT.KA ) THEN INFO = -5 ELSE IF( LDAB.LT.KA+1 ) THEN INFO = -7 ELSE IF( LDBB.LT.KB+1 ) THEN INFO = -9 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN INFO = -12 END IF * IF( INFO.EQ.0 ) THEN WORK( 1 ) = LWMIN IWORK( 1 ) = LIWMIN * IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN INFO = -14 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN INFO = -16 END IF END IF * IF( INFO.NE.0 ) THEN CALL XERBLA( 'SSBGVD', -INFO ) RETURN ELSE IF( LQUERY ) THEN RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * * Form a split Cholesky factorization of B. * CALL SPBSTF( UPLO, N, KB, BB, LDBB, INFO ) IF( INFO.NE.0 ) THEN INFO = N + INFO RETURN END IF * * Transform problem to standard eigenvalue problem. * INDE = 1 INDWRK = INDE + N INDWK2 = INDWRK + N*N LLWRK2 = LWORK - INDWK2 + 1 CALL SSBGST( JOBZ, UPLO, N, KA, KB, AB, LDAB, BB, LDBB, Z, LDZ, $ WORK( INDWRK ), IINFO ) * * Reduce to tridiagonal form. * IF( WANTZ ) THEN VECT = 'U' ELSE VECT = 'N' END IF CALL SSBTRD( VECT, UPLO, N, KA, AB, LDAB, W, WORK( INDE ), Z, LDZ, $ WORK( INDWRK ), IINFO ) * * For eigenvalues only, call SSTERF. For eigenvectors, call SSTEDC. * IF( .NOT.WANTZ ) THEN CALL SSTERF( N, W, WORK( INDE ), INFO ) ELSE CALL SSTEDC( 'I', N, W, WORK( INDE ), WORK( INDWRK ), N, $ WORK( INDWK2 ), LLWRK2, IWORK, LIWORK, INFO ) CALL SGEMM( 'N', 'N', N, N, N, ONE, Z, LDZ, WORK( INDWRK ), N, $ ZERO, WORK( INDWK2 ), N ) CALL SLACPY( 'A', N, N, WORK( INDWK2 ), N, Z, LDZ ) END IF * WORK( 1 ) = LWMIN IWORK( 1 ) = LIWMIN * RETURN * * End of SSBGVD * END
bsd-3-clause
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/TESTING/LIN/zchkqrt.f
31
5397
*> \brief \b ZCHKQRT * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE ZCHKQRT( THRESH, TSTERR, NM, MVAL, NN, NVAL, NNB, * NBVAL, NOUT ) * .. Scalar Arguments .. * LOGICAL TSTERR * INTEGER NM, NN, NNB, NOUT * DOUBLE PRECISION THRESH * .. * .. Array Arguments .. * INTEGER MVAL( * ), NBVAL( * ), NVAL( * ) * *> \par Purpose: * ============= *> *> \verbatim *> *> ZCHKQRT tests ZGEQRT and ZGEMQRT. *> \endverbatim * * Arguments: * ========== * *> \param[in] THRESH *> \verbatim *> THRESH is DOUBLE PRECISION *> The threshold value for the test ratios. A result is *> included in the output file if RESULT >= THRESH. To have *> every test ratio printed, use THRESH = 0. *> \endverbatim *> *> \param[in] TSTERR *> \verbatim *> TSTERR is LOGICAL *> Flag that indicates whether error exits are to be tested. *> \endverbatim *> *> \param[in] NM *> \verbatim *> NM is INTEGER *> The number of values of M contained in the vector MVAL. *> \endverbatim *> *> \param[in] MVAL *> \verbatim *> MVAL is INTEGER array, dimension (NM) *> The values of the matrix row dimension M. *> \endverbatim *> *> \param[in] NN *> \verbatim *> NN is INTEGER *> The number of values of N contained in the vector NVAL. *> \endverbatim *> *> \param[in] NVAL *> \verbatim *> NVAL is INTEGER array, dimension (NN) *> The values of the matrix column dimension N. *> \endverbatim *> *> \param[in] NNB *> \verbatim *> NNB is INTEGER *> The number of values of NB contained in the vector NBVAL. *> \endverbatim *> *> \param[in] NBVAL *> \verbatim *> NBVAL is INTEGER array, dimension (NBVAL) *> The values of the blocksize NB. *> \endverbatim *> *> \param[in] NOUT *> \verbatim *> NOUT is INTEGER *> The unit number for output. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup complex16_lin * * ===================================================================== SUBROUTINE ZCHKQRT( THRESH, TSTERR, NM, MVAL, NN, NVAL, NNB, $ NBVAL, NOUT ) IMPLICIT NONE * * -- LAPACK test routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. LOGICAL TSTERR INTEGER NM, NN, NNB, NOUT DOUBLE PRECISION THRESH * .. * .. Array Arguments .. INTEGER MVAL( * ), NBVAL( * ), NVAL( * ) * .. * * ===================================================================== * * .. Parameters .. INTEGER NTESTS PARAMETER ( NTESTS = 6 ) * .. * .. Local Scalars .. CHARACTER*3 PATH INTEGER I, J, K, T, M, N, NB, NFAIL, NERRS, NRUN, $ MINMN * .. * .. Local Arrays .. DOUBLE PRECISION RESULT( NTESTS ) * .. * .. External Subroutines .. EXTERNAL ALAERH, ALAHD, ALASUM, ZERRQRT, ZQRT04 * .. * .. Scalars in Common .. LOGICAL LERR, OK CHARACTER*32 SRNAMT INTEGER INFOT, NUNIT * .. * .. Common blocks .. COMMON / INFOC / INFOT, NUNIT, OK, LERR COMMON / SRNAMC / SRNAMT * .. * .. Executable Statements .. * * Initialize constants * PATH( 1: 1 ) = 'Z' PATH( 2: 3 ) = 'QT' NRUN = 0 NFAIL = 0 NERRS = 0 * * Test the error exits * IF( TSTERR ) CALL ZERRQRT( PATH, NOUT ) INFOT = 0 * * Do for each value of M in MVAL. * DO I = 1, NM M = MVAL( I ) * * Do for each value of N in NVAL. * DO J = 1, NN N = NVAL( J ) * * Do for each possible value of NB * MINMN = MIN( M, N ) DO K = 1, NNB NB = NBVAL( K ) * * Test ZGEQRT and ZGEMQRT * IF( (NB.LE.MINMN).AND.(NB.GT.0) ) THEN CALL ZQRT04( M, N, NB, RESULT ) * * Print information about the tests that did not * pass the threshold. * DO T = 1, NTESTS IF( RESULT( T ).GE.THRESH ) THEN IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) $ CALL ALAHD( NOUT, PATH ) WRITE( NOUT, FMT = 9999 )M, N, NB, $ T, RESULT( T ) NFAIL = NFAIL + 1 END IF END DO NRUN = NRUN + NTESTS END IF END DO END DO END DO * * Print a summary of the results. * CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS ) * 9999 FORMAT( ' M=', I5, ', N=', I5, ', NB=', I4, $ ' test(', I2, ')=', G12.5 ) RETURN * * End of ZCHKQRT * END
bsd-3-clause
indashnet/InDashNet.Open.UN2000
android/external/eigen/blas/testing/sblat2.f
204
111315
PROGRAM SBLAT2 * * Test program for the REAL Level 2 Blas. * * The program must be driven by a short data file. The first 18 records * of the file are read using list-directed input, the last 16 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 34 lines: * 'SBLAT2.SUMM' NAME OF SUMMARY OUTPUT FILE * 6 UNIT NUMBER OF SUMMARY FILE * 'SBLAT2.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 * 4 NUMBER OF VALUES OF K * 0 1 2 4 VALUES OF K * 4 NUMBER OF VALUES OF INCX AND INCY * 1 2 -1 -2 VALUES OF INCX AND INCY * 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 0.9 VALUES OF BETA * SGEMV T PUT F FOR NO TEST. SAME COLUMNS. * SGBMV T PUT F FOR NO TEST. SAME COLUMNS. * SSYMV T PUT F FOR NO TEST. SAME COLUMNS. * SSBMV T PUT F FOR NO TEST. SAME COLUMNS. * SSPMV T PUT F FOR NO TEST. SAME COLUMNS. * STRMV T PUT F FOR NO TEST. SAME COLUMNS. * STBMV T PUT F FOR NO TEST. SAME COLUMNS. * STPMV T PUT F FOR NO TEST. SAME COLUMNS. * STRSV T PUT F FOR NO TEST. SAME COLUMNS. * STBSV T PUT F FOR NO TEST. SAME COLUMNS. * STPSV T PUT F FOR NO TEST. SAME COLUMNS. * SGER T PUT F FOR NO TEST. SAME COLUMNS. * SSYR T PUT F FOR NO TEST. SAME COLUMNS. * SSPR T PUT F FOR NO TEST. SAME COLUMNS. * SSYR2 T PUT F FOR NO TEST. SAME COLUMNS. * SSPR2 T PUT F FOR NO TEST. SAME COLUMNS. * * See: * * Dongarra J. J., Du Croz J. J., Hammarling S. and Hanson R. J.. * An extended set of Fortran Basic Linear Algebra Subprograms. * * Technical Memoranda Nos. 41 (revision 3) and 81, Mathematics * and Computer Science Division, Argonne National Laboratory, * 9700 South Cass Avenue, Argonne, Illinois 60439, US. * * Or * * NAG Technical Reports TR3/87 and TR4/87, Numerical Algorithms * Group Ltd., NAG Central Office, 256 Banbury Road, Oxford * OX2 7DE, UK, and Numerical Algorithms Group Inc., 1101 31st * Street, Suite 100, Downers Grove, Illinois 60515-1263, USA. * * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Parameters .. INTEGER NIN PARAMETER ( NIN = 5 ) INTEGER NSUBS PARAMETER ( NSUBS = 16 ) REAL ZERO, HALF, ONE PARAMETER ( ZERO = 0.0, HALF = 0.5, ONE = 1.0 ) INTEGER NMAX, INCMAX PARAMETER ( NMAX = 65, INCMAX = 2 ) INTEGER NINMAX, NIDMAX, NKBMAX, NALMAX, NBEMAX PARAMETER ( NINMAX = 7, NIDMAX = 9, NKBMAX = 7, $ NALMAX = 7, NBEMAX = 7 ) * .. Local Scalars .. REAL EPS, ERR, THRESH INTEGER I, ISNUM, J, N, NALF, NBET, NIDIM, NINC, NKB, $ NOUT, NTRA LOGICAL FATAL, LTESTT, REWI, SAME, SFATAL, TRACE, $ TSTERR CHARACTER*1 TRANS CHARACTER*6 SNAMET CHARACTER*32 SNAPS, SUMMRY * .. Local Arrays .. REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), $ ALF( NALMAX ), AS( NMAX*NMAX ), BET( NBEMAX ), $ G( NMAX ), X( NMAX ), XS( NMAX*INCMAX ), $ XX( NMAX*INCMAX ), Y( NMAX ), $ YS( NMAX*INCMAX ), YT( NMAX ), $ YY( NMAX*INCMAX ), Z( 2*NMAX ) INTEGER IDIM( NIDMAX ), INC( NINMAX ), KB( NKBMAX ) LOGICAL LTEST( NSUBS ) CHARACTER*6 SNAMES( NSUBS ) * .. External Functions .. REAL SDIFF LOGICAL LSE EXTERNAL SDIFF, LSE * .. External Subroutines .. EXTERNAL SCHK1, SCHK2, SCHK3, SCHK4, SCHK5, SCHK6, $ SCHKE, SMVCH * .. Intrinsic Functions .. INTRINSIC ABS, 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/'SGEMV ', 'SGBMV ', 'SSYMV ', 'SSBMV ', $ 'SSPMV ', 'STRMV ', 'STBMV ', 'STPMV ', $ 'STRSV ', 'STBSV ', 'STPSV ', 'SGER ', $ 'SSYR ', 'SSPR ', 'SSYR2 ', 'SSPR2 '/ * .. 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 230 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 230 END IF 10 CONTINUE * Values of K READ( NIN, FMT = * )NKB IF( NKB.LT.1.OR.NKB.GT.NKBMAX )THEN WRITE( NOUT, FMT = 9997 )'K', NKBMAX GO TO 230 END IF READ( NIN, FMT = * )( KB( I ), I = 1, NKB ) DO 20 I = 1, NKB IF( KB( I ).LT.0 )THEN WRITE( NOUT, FMT = 9995 ) GO TO 230 END IF 20 CONTINUE * Values of INCX and INCY READ( NIN, FMT = * )NINC IF( NINC.LT.1.OR.NINC.GT.NINMAX )THEN WRITE( NOUT, FMT = 9997 )'INCX AND INCY', NINMAX GO TO 230 END IF READ( NIN, FMT = * )( INC( I ), I = 1, NINC ) DO 30 I = 1, NINC IF( INC( I ).EQ.0.OR.ABS( INC( I ) ).GT.INCMAX )THEN WRITE( NOUT, FMT = 9994 )INCMAX GO TO 230 END IF 30 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 230 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 230 END IF READ( NIN, FMT = * )( BET( I ), I = 1, NBET ) * * Report values of parameters. * WRITE( NOUT, FMT = 9993 ) WRITE( NOUT, FMT = 9992 )( IDIM( I ), I = 1, NIDIM ) WRITE( NOUT, FMT = 9991 )( KB( I ), I = 1, NKB ) WRITE( NOUT, FMT = 9990 )( INC( I ), I = 1, NINC ) WRITE( NOUT, FMT = 9989 )( ALF( I ), I = 1, NALF ) WRITE( NOUT, FMT = 9988 )( BET( I ), I = 1, NBET ) IF( .NOT.TSTERR )THEN WRITE( NOUT, FMT = * ) WRITE( NOUT, FMT = 9980 ) 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 40 I = 1, NSUBS LTEST( I ) = .FALSE. 40 CONTINUE 50 READ( NIN, FMT = 9984, END = 80 )SNAMET, LTESTT DO 60 I = 1, NSUBS IF( SNAMET.EQ.SNAMES( I ) ) $ GO TO 70 60 CONTINUE WRITE( NOUT, FMT = 9986 )SNAMET STOP 70 LTEST( I ) = LTESTT GO TO 50 * 80 CONTINUE CLOSE ( NIN ) * * Compute EPS (the machine precision). * EPS = ONE 90 CONTINUE IF( SDIFF( ONE + EPS, ONE ).EQ.ZERO ) $ GO TO 100 EPS = HALF*EPS GO TO 90 100 CONTINUE EPS = EPS + EPS WRITE( NOUT, FMT = 9998 )EPS * * Check the reliability of SMVCH using exact data. * N = MIN( 32, NMAX ) DO 120 J = 1, N DO 110 I = 1, N A( I, J ) = MAX( I - J + 1, 0 ) 110 CONTINUE X( J ) = J Y( J ) = ZERO 120 CONTINUE DO 130 J = 1, N YY( J ) = J*( ( J + 1 )*J )/2 - ( ( J + 1 )*J*( J - 1 ) )/3 130 CONTINUE * YY holds the exact result. On exit from SMVCH YT holds * the result computed by SMVCH. TRANS = 'N' CALL SMVCH( TRANS, N, N, ONE, A, NMAX, X, 1, ZERO, Y, 1, YT, G, $ YY, EPS, ERR, FATAL, NOUT, .TRUE. ) SAME = LSE( YY, YT, N ) IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN WRITE( NOUT, FMT = 9985 )TRANS, SAME, ERR STOP END IF TRANS = 'T' CALL SMVCH( TRANS, N, N, ONE, A, NMAX, X, -1, ZERO, Y, -1, YT, G, $ YY, EPS, ERR, FATAL, NOUT, .TRUE. ) SAME = LSE( YY, YT, N ) IF( .NOT.SAME.OR.ERR.NE.ZERO )THEN WRITE( NOUT, FMT = 9985 )TRANS, SAME, ERR STOP END IF * * Test each subroutine in turn. * DO 210 ISNUM = 1, NSUBS WRITE( NOUT, FMT = * ) IF( .NOT.LTEST( ISNUM ) )THEN * Subprogram is not to be tested. WRITE( NOUT, FMT = 9983 )SNAMES( ISNUM ) ELSE SRNAMT = SNAMES( ISNUM ) * Test error exits. IF( TSTERR )THEN CALL SCHKE( ISNUM, SNAMES( ISNUM ), NOUT ) WRITE( NOUT, FMT = * ) END IF * Test computations. INFOT = 0 OK = .TRUE. FATAL = .FALSE. GO TO ( 140, 140, 150, 150, 150, 160, 160, $ 160, 160, 160, 160, 170, 180, 180, $ 190, 190 )ISNUM * Test SGEMV, 01, and SGBMV, 02. 140 CALL SCHK1( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NKB, KB, NALF, ALF, $ NBET, BET, NINC, INC, NMAX, INCMAX, A, AA, AS, $ X, XX, XS, Y, YY, YS, YT, G ) GO TO 200 * Test SSYMV, 03, SSBMV, 04, and SSPMV, 05. 150 CALL SCHK2( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NKB, KB, NALF, ALF, $ NBET, BET, NINC, INC, NMAX, INCMAX, A, AA, AS, $ X, XX, XS, Y, YY, YS, YT, G ) GO TO 200 * Test STRMV, 06, STBMV, 07, STPMV, 08, * STRSV, 09, STBSV, 10, and STPSV, 11. 160 CALL SCHK3( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NKB, KB, NINC, INC, $ NMAX, INCMAX, A, AA, AS, Y, YY, YS, YT, G, Z ) GO TO 200 * Test SGER, 12. 170 CALL SCHK4( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NALF, ALF, NINC, INC, $ NMAX, INCMAX, A, AA, AS, X, XX, XS, Y, YY, YS, $ YT, G, Z ) GO TO 200 * Test SSYR, 13, and SSPR, 14. 180 CALL SCHK5( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NALF, ALF, NINC, INC, $ NMAX, INCMAX, A, AA, AS, X, XX, XS, Y, YY, YS, $ YT, G, Z ) GO TO 200 * Test SSYR2, 15, and SSPR2, 16. 190 CALL SCHK6( SNAMES( ISNUM ), EPS, THRESH, NOUT, NTRA, TRACE, $ REWI, FATAL, NIDIM, IDIM, NALF, ALF, NINC, INC, $ NMAX, INCMAX, A, AA, AS, X, XX, XS, Y, YY, YS, $ YT, G, Z ) * 200 IF( FATAL.AND.SFATAL ) $ GO TO 220 END IF 210 CONTINUE WRITE( NOUT, FMT = 9982 ) GO TO 240 * 220 CONTINUE WRITE( NOUT, FMT = 9981 ) GO TO 240 * 230 CONTINUE WRITE( NOUT, FMT = 9987 ) * 240 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, E9.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( ' VALUE OF K IS LESS THAN 0' ) 9994 FORMAT( ' ABSOLUTE VALUE OF INCX OR INCY IS 0 OR GREATER THAN ', $ I2 ) 9993 FORMAT( ' TESTS OF THE REAL LEVEL 2 BLAS', //' THE F', $ 'OLLOWING PARAMETER VALUES WILL BE USED:' ) 9992 FORMAT( ' FOR N ', 9I6 ) 9991 FORMAT( ' FOR K ', 7I6 ) 9990 FORMAT( ' FOR INCX AND INCY ', 7I6 ) 9989 FORMAT( ' FOR ALPHA ', 7F6.1 ) 9988 FORMAT( ' FOR BETA ', 7F6.1 ) 9987 FORMAT( ' AMEND DATA FILE OR INCREASE ARRAY SIZES IN PROGRAM', $ /' ******* TESTS ABANDONED *******' ) 9986 FORMAT( ' SUBPROGRAM NAME ', A6, ' NOT RECOGNIZED', /' ******* T', $ 'ESTS ABANDONED *******' ) 9985 FORMAT( ' ERROR IN SMVCH - IN-LINE DOT PRODUCTS ARE BEING EVALU', $ 'ATED WRONGLY.', /' SMVCH WAS CALLED WITH TRANS = ', A1, $ ' AND RETURNED SAME = ', L1, ' AND ERR = ', F12.3, '.', / $ ' THIS MAY BE DUE TO FAULTS IN THE ARITHMETIC OR THE COMPILER.' $ , /' ******* TESTS ABANDONED *******' ) 9984 FORMAT( A6, L2 ) 9983 FORMAT( 1X, A6, ' WAS NOT TESTED' ) 9982 FORMAT( /' END OF TESTS' ) 9981 FORMAT( /' ******* FATAL ERROR - TESTS ABANDONED *******' ) 9980 FORMAT( ' ERROR-EXITS WILL NOT BE TESTED' ) * * End of SBLAT2. * END SUBROUTINE SCHK1( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NKB, KB, NALF, ALF, NBET, $ BET, NINC, INC, NMAX, INCMAX, A, AA, AS, X, XX, $ XS, Y, YY, YS, YT, G ) * * Tests SGEMV and SGBMV. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Parameters .. REAL ZERO, HALF PARAMETER ( ZERO = 0.0, HALF = 0.5 ) * .. Scalar Arguments .. REAL EPS, THRESH INTEGER INCMAX, NALF, NBET, NIDIM, NINC, NKB, NMAX, $ NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ), $ AS( NMAX*NMAX ), BET( NBET ), G( NMAX ), $ X( NMAX ), XS( NMAX*INCMAX ), $ XX( NMAX*INCMAX ), Y( NMAX ), $ YS( NMAX*INCMAX ), YT( NMAX ), $ YY( NMAX*INCMAX ) INTEGER IDIM( NIDIM ), INC( NINC ), KB( NKB ) * .. Local Scalars .. REAL ALPHA, ALS, BETA, BLS, ERR, ERRMAX, TRANSL INTEGER I, IA, IB, IC, IKU, IM, IN, INCX, INCXS, INCY, $ INCYS, IX, IY, KL, KLS, KU, KUS, LAA, LDA, $ LDAS, LX, LY, M, ML, MS, N, NARGS, NC, ND, NK, $ NL, NS LOGICAL BANDED, FULL, NULL, RESET, SAME, TRAN CHARACTER*1 TRANS, TRANSS CHARACTER*3 ICH * .. Local Arrays .. LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LSE, LSERES EXTERNAL LSE, LSERES * .. External Subroutines .. EXTERNAL SGBMV, SGEMV, SMAKE, SMVCH * .. Intrinsic Functions .. INTRINSIC ABS, MAX, MIN * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Data statements .. DATA ICH/'NTC'/ * .. Executable Statements .. FULL = SNAME( 3: 3 ).EQ.'E' BANDED = SNAME( 3: 3 ).EQ.'B' * Define the number of arguments. IF( FULL )THEN NARGS = 11 ELSE IF( BANDED )THEN NARGS = 13 END IF * NC = 0 RESET = .TRUE. ERRMAX = ZERO * DO 120 IN = 1, NIDIM N = IDIM( IN ) ND = N/2 + 1 * DO 110 IM = 1, 2 IF( IM.EQ.1 ) $ M = MAX( N - ND, 0 ) IF( IM.EQ.2 ) $ M = MIN( N + ND, NMAX ) * IF( BANDED )THEN NK = NKB ELSE NK = 1 END IF DO 100 IKU = 1, NK IF( BANDED )THEN KU = KB( IKU ) KL = MAX( KU - 1, 0 ) ELSE KU = N - 1 KL = M - 1 END IF * Set LDA to 1 more than minimum value if room. IF( BANDED )THEN LDA = KL + KU + 1 ELSE LDA = M END IF IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 100 LAA = LDA*N NULL = N.LE.0.OR.M.LE.0 * * Generate the matrix A. * TRANSL = ZERO CALL SMAKE( SNAME( 2: 3 ), ' ', ' ', M, N, A, NMAX, AA, $ LDA, KL, KU, RESET, TRANSL ) * DO 90 IC = 1, 3 TRANS = ICH( IC: IC ) TRAN = TRANS.EQ.'T'.OR.TRANS.EQ.'C' * IF( TRAN )THEN ML = N NL = M ELSE ML = M NL = N END IF * DO 80 IX = 1, NINC INCX = INC( IX ) LX = ABS( INCX )*NL * * Generate the vector X. * TRANSL = HALF CALL SMAKE( 'GE', ' ', ' ', 1, NL, X, 1, XX, $ ABS( INCX ), 0, NL - 1, RESET, TRANSL ) IF( NL.GT.1 )THEN X( NL/2 ) = ZERO XX( 1 + ABS( INCX )*( NL/2 - 1 ) ) = ZERO END IF * DO 70 IY = 1, NINC INCY = INC( IY ) LY = ABS( INCY )*ML * DO 60 IA = 1, NALF ALPHA = ALF( IA ) * DO 50 IB = 1, NBET BETA = BET( IB ) * * Generate the vector Y. * TRANSL = ZERO CALL SMAKE( 'GE', ' ', ' ', 1, ML, Y, 1, $ YY, ABS( INCY ), 0, ML - 1, $ RESET, TRANSL ) * NC = NC + 1 * * Save every datum before calling the * subroutine. * TRANSS = TRANS MS = M NS = N KLS = KL KUS = KU ALS = ALPHA DO 10 I = 1, LAA AS( I ) = AA( I ) 10 CONTINUE LDAS = LDA DO 20 I = 1, LX XS( I ) = XX( I ) 20 CONTINUE INCXS = INCX BLS = BETA DO 30 I = 1, LY YS( I ) = YY( I ) 30 CONTINUE INCYS = INCY * * Call the subroutine. * IF( FULL )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9994 )NC, SNAME, $ TRANS, M, N, ALPHA, LDA, INCX, BETA, $ INCY IF( REWI ) $ REWIND NTRA CALL SGEMV( TRANS, M, N, ALPHA, AA, $ LDA, XX, INCX, BETA, YY, $ INCY ) ELSE IF( BANDED )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9995 )NC, SNAME, $ TRANS, M, N, KL, KU, ALPHA, LDA, $ INCX, BETA, INCY IF( REWI ) $ REWIND NTRA CALL SGBMV( TRANS, M, N, KL, KU, ALPHA, $ AA, LDA, XX, INCX, BETA, $ YY, INCY ) END IF * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9993 ) FATAL = .TRUE. GO TO 130 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = TRANS.EQ.TRANSS ISAME( 2 ) = MS.EQ.M ISAME( 3 ) = NS.EQ.N IF( FULL )THEN ISAME( 4 ) = ALS.EQ.ALPHA ISAME( 5 ) = LSE( AS, AA, LAA ) ISAME( 6 ) = LDAS.EQ.LDA ISAME( 7 ) = LSE( XS, XX, LX ) ISAME( 8 ) = INCXS.EQ.INCX ISAME( 9 ) = BLS.EQ.BETA IF( NULL )THEN ISAME( 10 ) = LSE( YS, YY, LY ) ELSE ISAME( 10 ) = LSERES( 'GE', ' ', 1, $ ML, YS, YY, $ ABS( INCY ) ) END IF ISAME( 11 ) = INCYS.EQ.INCY ELSE IF( BANDED )THEN ISAME( 4 ) = KLS.EQ.KL ISAME( 5 ) = KUS.EQ.KU ISAME( 6 ) = ALS.EQ.ALPHA ISAME( 7 ) = LSE( AS, AA, LAA ) ISAME( 8 ) = LDAS.EQ.LDA ISAME( 9 ) = LSE( XS, XX, LX ) ISAME( 10 ) = INCXS.EQ.INCX ISAME( 11 ) = BLS.EQ.BETA IF( NULL )THEN ISAME( 12 ) = LSE( YS, YY, LY ) ELSE ISAME( 12 ) = LSERES( 'GE', ' ', 1, $ ML, YS, YY, $ ABS( INCY ) ) END IF ISAME( 13 ) = INCYS.EQ.INCY END IF * * 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 130 END IF * IF( .NOT.NULL )THEN * * Check the result. * CALL SMVCH( TRANS, M, N, ALPHA, A, $ NMAX, X, INCX, BETA, Y, $ INCY, YT, G, YY, EPS, ERR, $ FATAL, NOUT, .TRUE. ) ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and * return. IF( FATAL ) $ GO TO 130 ELSE * Avoid repeating tests with M.le.0 or * N.le.0. GO TO 110 END IF * 50 CONTINUE * 60 CONTINUE * 70 CONTINUE * 80 CONTINUE * 90 CONTINUE * 100 CONTINUE * 110 CONTINUE * 120 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 140 * 130 CONTINUE WRITE( NOUT, FMT = 9996 )SNAME IF( FULL )THEN WRITE( NOUT, FMT = 9994 )NC, SNAME, TRANS, M, N, ALPHA, LDA, $ INCX, BETA, INCY ELSE IF( BANDED )THEN WRITE( NOUT, FMT = 9995 )NC, SNAME, TRANS, M, N, KL, KU, $ ALPHA, LDA, INCX, BETA, INCY END IF * 140 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, ''',', 4( I3, ',' ), F4.1, $ ', A,', I3, ', X,', I2, ',', F4.1, ', Y,', I2, ') .' ) 9994 FORMAT( 1X, I6, ': ', A6, '(''', A1, ''',', 2( I3, ',' ), F4.1, $ ', A,', I3, ', X,', I2, ',', F4.1, ', Y,', I2, $ ') .' ) 9993 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of SCHK1. * END SUBROUTINE SCHK2( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NKB, KB, NALF, ALF, NBET, $ BET, NINC, INC, NMAX, INCMAX, A, AA, AS, X, XX, $ XS, Y, YY, YS, YT, G ) * * Tests SSYMV, SSBMV and SSPMV. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Parameters .. REAL ZERO, HALF PARAMETER ( ZERO = 0.0, HALF = 0.5 ) * .. Scalar Arguments .. REAL EPS, THRESH INTEGER INCMAX, NALF, NBET, NIDIM, NINC, NKB, NMAX, $ NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ), $ AS( NMAX*NMAX ), BET( NBET ), G( NMAX ), $ X( NMAX ), XS( NMAX*INCMAX ), $ XX( NMAX*INCMAX ), Y( NMAX ), $ YS( NMAX*INCMAX ), YT( NMAX ), $ YY( NMAX*INCMAX ) INTEGER IDIM( NIDIM ), INC( NINC ), KB( NKB ) * .. Local Scalars .. REAL ALPHA, ALS, BETA, BLS, ERR, ERRMAX, TRANSL INTEGER I, IA, IB, IC, IK, IN, INCX, INCXS, INCY, $ INCYS, IX, IY, K, KS, LAA, LDA, LDAS, LX, LY, $ N, NARGS, NC, NK, NS LOGICAL BANDED, FULL, NULL, PACKED, RESET, SAME CHARACTER*1 UPLO, UPLOS CHARACTER*2 ICH * .. Local Arrays .. LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LSE, LSERES EXTERNAL LSE, LSERES * .. External Subroutines .. EXTERNAL SMAKE, SMVCH, SSBMV, SSPMV, SSYMV * .. Intrinsic Functions .. INTRINSIC ABS, MAX * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Data statements .. DATA ICH/'UL'/ * .. Executable Statements .. FULL = SNAME( 3: 3 ).EQ.'Y' BANDED = SNAME( 3: 3 ).EQ.'B' PACKED = SNAME( 3: 3 ).EQ.'P' * Define the number of arguments. IF( FULL )THEN NARGS = 10 ELSE IF( BANDED )THEN NARGS = 11 ELSE IF( PACKED )THEN NARGS = 9 END IF * NC = 0 RESET = .TRUE. ERRMAX = ZERO * DO 110 IN = 1, NIDIM N = IDIM( IN ) * IF( BANDED )THEN NK = NKB ELSE NK = 1 END IF DO 100 IK = 1, NK IF( BANDED )THEN K = KB( IK ) ELSE K = N - 1 END IF * Set LDA to 1 more than minimum value if room. IF( BANDED )THEN LDA = K + 1 ELSE LDA = N END IF IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 100 IF( PACKED )THEN LAA = ( N*( N + 1 ) )/2 ELSE LAA = LDA*N END IF NULL = N.LE.0 * DO 90 IC = 1, 2 UPLO = ICH( IC: IC ) * * Generate the matrix A. * TRANSL = ZERO CALL SMAKE( SNAME( 2: 3 ), UPLO, ' ', N, N, A, NMAX, AA, $ LDA, K, K, RESET, TRANSL ) * DO 80 IX = 1, NINC INCX = INC( IX ) LX = ABS( INCX )*N * * Generate the vector X. * TRANSL = HALF CALL SMAKE( 'GE', ' ', ' ', 1, N, X, 1, XX, $ ABS( INCX ), 0, N - 1, RESET, TRANSL ) IF( N.GT.1 )THEN X( N/2 ) = ZERO XX( 1 + ABS( INCX )*( N/2 - 1 ) ) = ZERO END IF * DO 70 IY = 1, NINC INCY = INC( IY ) LY = ABS( INCY )*N * DO 60 IA = 1, NALF ALPHA = ALF( IA ) * DO 50 IB = 1, NBET BETA = BET( IB ) * * Generate the vector Y. * TRANSL = ZERO CALL SMAKE( 'GE', ' ', ' ', 1, N, Y, 1, YY, $ ABS( INCY ), 0, N - 1, RESET, $ TRANSL ) * NC = NC + 1 * * Save every datum before calling the * subroutine. * UPLOS = UPLO NS = N KS = K ALS = ALPHA DO 10 I = 1, LAA AS( I ) = AA( I ) 10 CONTINUE LDAS = LDA DO 20 I = 1, LX XS( I ) = XX( I ) 20 CONTINUE INCXS = INCX BLS = BETA DO 30 I = 1, LY YS( I ) = YY( I ) 30 CONTINUE INCYS = INCY * * Call the subroutine. * IF( FULL )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9993 )NC, SNAME, $ UPLO, N, ALPHA, LDA, INCX, BETA, INCY IF( REWI ) $ REWIND NTRA CALL SSYMV( UPLO, N, ALPHA, AA, LDA, XX, $ INCX, BETA, YY, INCY ) ELSE IF( BANDED )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9994 )NC, SNAME, $ UPLO, N, K, ALPHA, LDA, INCX, BETA, $ INCY IF( REWI ) $ REWIND NTRA CALL SSBMV( UPLO, N, K, ALPHA, AA, LDA, $ XX, INCX, BETA, YY, INCY ) ELSE IF( PACKED )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9995 )NC, SNAME, $ UPLO, N, ALPHA, INCX, BETA, INCY IF( REWI ) $ REWIND NTRA CALL SSPMV( UPLO, N, ALPHA, AA, XX, INCX, $ BETA, YY, INCY ) END IF * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9992 ) FATAL = .TRUE. GO TO 120 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = UPLO.EQ.UPLOS ISAME( 2 ) = NS.EQ.N IF( FULL )THEN ISAME( 3 ) = ALS.EQ.ALPHA ISAME( 4 ) = LSE( AS, AA, LAA ) ISAME( 5 ) = LDAS.EQ.LDA ISAME( 6 ) = LSE( XS, XX, LX ) ISAME( 7 ) = INCXS.EQ.INCX ISAME( 8 ) = BLS.EQ.BETA IF( NULL )THEN ISAME( 9 ) = LSE( YS, YY, LY ) ELSE ISAME( 9 ) = LSERES( 'GE', ' ', 1, N, $ YS, YY, ABS( INCY ) ) END IF ISAME( 10 ) = INCYS.EQ.INCY ELSE IF( BANDED )THEN ISAME( 3 ) = KS.EQ.K ISAME( 4 ) = ALS.EQ.ALPHA ISAME( 5 ) = LSE( AS, AA, LAA ) ISAME( 6 ) = LDAS.EQ.LDA ISAME( 7 ) = LSE( XS, XX, LX ) ISAME( 8 ) = INCXS.EQ.INCX ISAME( 9 ) = BLS.EQ.BETA IF( NULL )THEN ISAME( 10 ) = LSE( YS, YY, LY ) ELSE ISAME( 10 ) = LSERES( 'GE', ' ', 1, N, $ YS, YY, ABS( INCY ) ) END IF ISAME( 11 ) = INCYS.EQ.INCY ELSE IF( PACKED )THEN ISAME( 3 ) = ALS.EQ.ALPHA ISAME( 4 ) = LSE( AS, AA, LAA ) ISAME( 5 ) = LSE( XS, XX, LX ) ISAME( 6 ) = INCXS.EQ.INCX ISAME( 7 ) = BLS.EQ.BETA IF( NULL )THEN ISAME( 8 ) = LSE( YS, YY, LY ) ELSE ISAME( 8 ) = LSERES( 'GE', ' ', 1, N, $ YS, YY, ABS( INCY ) ) END IF ISAME( 9 ) = INCYS.EQ.INCY END IF * * 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 SMVCH( 'N', N, N, ALPHA, A, NMAX, X, $ INCX, BETA, Y, INCY, YT, G, $ YY, EPS, ERR, FATAL, NOUT, $ .TRUE. ) ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and * return. IF( FATAL ) $ GO TO 120 ELSE * Avoid repeating tests with N.le.0 GO TO 110 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 IF( FULL )THEN WRITE( NOUT, FMT = 9993 )NC, SNAME, UPLO, N, ALPHA, LDA, INCX, $ BETA, INCY ELSE IF( BANDED )THEN WRITE( NOUT, FMT = 9994 )NC, SNAME, UPLO, N, K, ALPHA, LDA, $ INCX, BETA, INCY ELSE IF( PACKED )THEN WRITE( NOUT, FMT = 9995 )NC, SNAME, UPLO, N, ALPHA, INCX, $ BETA, INCY END IF * 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, ''',', I3, ',', F4.1, ', AP', $ ', X,', I2, ',', F4.1, ', Y,', I2, ') .' ) 9994 FORMAT( 1X, I6, ': ', A6, '(''', A1, ''',', 2( I3, ',' ), F4.1, $ ', A,', I3, ', X,', I2, ',', F4.1, ', Y,', I2, $ ') .' ) 9993 FORMAT( 1X, I6, ': ', A6, '(''', A1, ''',', I3, ',', F4.1, ', A,', $ I3, ', X,', I2, ',', F4.1, ', Y,', I2, ') .' ) 9992 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of SCHK2. * END SUBROUTINE SCHK3( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NKB, KB, NINC, INC, NMAX, $ INCMAX, A, AA, AS, X, XX, XS, XT, G, Z ) * * Tests STRMV, STBMV, STPMV, STRSV, STBSV and STPSV. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Parameters .. REAL ZERO, HALF, ONE PARAMETER ( ZERO = 0.0, HALF = 0.5, ONE = 1.0 ) * .. Scalar Arguments .. REAL EPS, THRESH INTEGER INCMAX, NIDIM, NINC, NKB, NMAX, NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), $ AS( NMAX*NMAX ), G( NMAX ), X( NMAX ), $ XS( NMAX*INCMAX ), XT( NMAX ), $ XX( NMAX*INCMAX ), Z( NMAX ) INTEGER IDIM( NIDIM ), INC( NINC ), KB( NKB ) * .. Local Scalars .. REAL ERR, ERRMAX, TRANSL INTEGER I, ICD, ICT, ICU, IK, IN, INCX, INCXS, IX, K, $ KS, LAA, LDA, LDAS, LX, N, NARGS, NC, NK, NS LOGICAL BANDED, FULL, NULL, PACKED, RESET, SAME CHARACTER*1 DIAG, DIAGS, TRANS, TRANSS, UPLO, UPLOS CHARACTER*2 ICHD, ICHU CHARACTER*3 ICHT * .. Local Arrays .. LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LSE, LSERES EXTERNAL LSE, LSERES * .. External Subroutines .. EXTERNAL SMAKE, SMVCH, STBMV, STBSV, STPMV, STPSV, $ STRMV, STRSV * .. Intrinsic Functions .. INTRINSIC ABS, 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'/ * .. Executable Statements .. FULL = SNAME( 3: 3 ).EQ.'R' BANDED = SNAME( 3: 3 ).EQ.'B' PACKED = SNAME( 3: 3 ).EQ.'P' * Define the number of arguments. IF( FULL )THEN NARGS = 8 ELSE IF( BANDED )THEN NARGS = 9 ELSE IF( PACKED )THEN NARGS = 7 END IF * NC = 0 RESET = .TRUE. ERRMAX = ZERO * Set up zero vector for SMVCH. DO 10 I = 1, NMAX Z( I ) = ZERO 10 CONTINUE * DO 110 IN = 1, NIDIM N = IDIM( IN ) * IF( BANDED )THEN NK = NKB ELSE NK = 1 END IF DO 100 IK = 1, NK IF( BANDED )THEN K = KB( IK ) ELSE K = N - 1 END IF * Set LDA to 1 more than minimum value if room. IF( BANDED )THEN LDA = K + 1 ELSE LDA = N END IF IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 100 IF( PACKED )THEN LAA = ( N*( N + 1 ) )/2 ELSE LAA = LDA*N END IF NULL = N.LE.0 * DO 90 ICU = 1, 2 UPLO = ICHU( ICU: ICU ) * DO 80 ICT = 1, 3 TRANS = ICHT( ICT: ICT ) * DO 70 ICD = 1, 2 DIAG = ICHD( ICD: ICD ) * * Generate the matrix A. * TRANSL = ZERO CALL SMAKE( SNAME( 2: 3 ), UPLO, DIAG, N, N, A, $ NMAX, AA, LDA, K, K, RESET, TRANSL ) * DO 60 IX = 1, NINC INCX = INC( IX ) LX = ABS( INCX )*N * * Generate the vector X. * TRANSL = HALF CALL SMAKE( 'GE', ' ', ' ', 1, N, X, 1, XX, $ ABS( INCX ), 0, N - 1, RESET, $ TRANSL ) IF( N.GT.1 )THEN X( N/2 ) = ZERO XX( 1 + ABS( INCX )*( N/2 - 1 ) ) = ZERO END IF * NC = NC + 1 * * Save every datum before calling the subroutine. * UPLOS = UPLO TRANSS = TRANS DIAGS = DIAG NS = N KS = K DO 20 I = 1, LAA AS( I ) = AA( I ) 20 CONTINUE LDAS = LDA DO 30 I = 1, LX XS( I ) = XX( I ) 30 CONTINUE INCXS = INCX * * Call the subroutine. * IF( SNAME( 4: 5 ).EQ.'MV' )THEN IF( FULL )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9993 )NC, SNAME, $ UPLO, TRANS, DIAG, N, LDA, INCX IF( REWI ) $ REWIND NTRA CALL STRMV( UPLO, TRANS, DIAG, N, AA, LDA, $ XX, INCX ) ELSE IF( BANDED )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9994 )NC, SNAME, $ UPLO, TRANS, DIAG, N, K, LDA, INCX IF( REWI ) $ REWIND NTRA CALL STBMV( UPLO, TRANS, DIAG, N, K, AA, $ LDA, XX, INCX ) ELSE IF( PACKED )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9995 )NC, SNAME, $ UPLO, TRANS, DIAG, N, INCX IF( REWI ) $ REWIND NTRA CALL STPMV( UPLO, TRANS, DIAG, N, AA, XX, $ INCX ) END IF ELSE IF( SNAME( 4: 5 ).EQ.'SV' )THEN IF( FULL )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9993 )NC, SNAME, $ UPLO, TRANS, DIAG, N, LDA, INCX IF( REWI ) $ REWIND NTRA CALL STRSV( UPLO, TRANS, DIAG, N, AA, LDA, $ XX, INCX ) ELSE IF( BANDED )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9994 )NC, SNAME, $ UPLO, TRANS, DIAG, N, K, LDA, INCX IF( REWI ) $ REWIND NTRA CALL STBSV( UPLO, TRANS, DIAG, N, K, AA, $ LDA, XX, INCX ) ELSE IF( PACKED )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9995 )NC, SNAME, $ UPLO, TRANS, DIAG, N, INCX IF( REWI ) $ REWIND NTRA CALL STPSV( UPLO, TRANS, DIAG, N, AA, XX, $ INCX ) END IF END IF * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9992 ) FATAL = .TRUE. GO TO 120 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = UPLO.EQ.UPLOS ISAME( 2 ) = TRANS.EQ.TRANSS ISAME( 3 ) = DIAG.EQ.DIAGS ISAME( 4 ) = NS.EQ.N IF( FULL )THEN ISAME( 5 ) = LSE( AS, AA, LAA ) ISAME( 6 ) = LDAS.EQ.LDA IF( NULL )THEN ISAME( 7 ) = LSE( XS, XX, LX ) ELSE ISAME( 7 ) = LSERES( 'GE', ' ', 1, N, XS, $ XX, ABS( INCX ) ) END IF ISAME( 8 ) = INCXS.EQ.INCX ELSE IF( BANDED )THEN ISAME( 5 ) = KS.EQ.K ISAME( 6 ) = LSE( AS, AA, LAA ) ISAME( 7 ) = LDAS.EQ.LDA IF( NULL )THEN ISAME( 8 ) = LSE( XS, XX, LX ) ELSE ISAME( 8 ) = LSERES( 'GE', ' ', 1, N, XS, $ XX, ABS( INCX ) ) END IF ISAME( 9 ) = INCXS.EQ.INCX ELSE IF( PACKED )THEN ISAME( 5 ) = LSE( AS, AA, LAA ) IF( NULL )THEN ISAME( 6 ) = LSE( XS, XX, LX ) ELSE ISAME( 6 ) = LSERES( 'GE', ' ', 1, N, XS, $ XX, ABS( INCX ) ) END IF ISAME( 7 ) = INCXS.EQ.INCX END IF * * 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 IF( SNAME( 4: 5 ).EQ.'MV' )THEN * * Check the result. * CALL SMVCH( TRANS, N, N, ONE, A, NMAX, X, $ INCX, ZERO, Z, INCX, XT, G, $ XX, EPS, ERR, FATAL, NOUT, $ .TRUE. ) ELSE IF( SNAME( 4: 5 ).EQ.'SV' )THEN * * Compute approximation to original vector. * DO 50 I = 1, N Z( I ) = XX( 1 + ( I - 1 )* $ ABS( INCX ) ) XX( 1 + ( I - 1 )*ABS( INCX ) ) $ = X( I ) 50 CONTINUE CALL SMVCH( TRANS, N, N, ONE, A, NMAX, Z, $ INCX, ZERO, X, INCX, XT, G, $ XX, EPS, ERR, FATAL, NOUT, $ .FALSE. ) END IF ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and return. IF( FATAL ) $ GO TO 120 ELSE * Avoid repeating tests with N.le.0. GO TO 110 END IF * 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 IF( FULL )THEN WRITE( NOUT, FMT = 9993 )NC, SNAME, UPLO, TRANS, DIAG, N, LDA, $ INCX ELSE IF( BANDED )THEN WRITE( NOUT, FMT = 9994 )NC, SNAME, UPLO, TRANS, DIAG, N, K, $ LDA, INCX ELSE IF( PACKED )THEN WRITE( NOUT, FMT = 9995 )NC, SNAME, UPLO, TRANS, DIAG, N, INCX END IF * 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, '(', 3( '''', A1, ''',' ), I3, ', AP, ', $ 'X,', I2, ') .' ) 9994 FORMAT( 1X, I6, ': ', A6, '(', 3( '''', A1, ''',' ), 2( I3, ',' ), $ ' A,', I3, ', X,', I2, ') .' ) 9993 FORMAT( 1X, I6, ': ', A6, '(', 3( '''', A1, ''',' ), I3, ', A,', $ I3, ', X,', I2, ') .' ) 9992 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of SCHK3. * END SUBROUTINE SCHK4( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NALF, ALF, NINC, INC, NMAX, $ INCMAX, A, AA, AS, X, XX, XS, Y, YY, YS, YT, G, $ Z ) * * Tests SGER. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Parameters .. REAL ZERO, HALF, ONE PARAMETER ( ZERO = 0.0, HALF = 0.5, ONE = 1.0 ) * .. Scalar Arguments .. REAL EPS, THRESH INTEGER INCMAX, NALF, NIDIM, NINC, NMAX, NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ), $ AS( NMAX*NMAX ), G( NMAX ), X( NMAX ), $ XS( NMAX*INCMAX ), XX( NMAX*INCMAX ), $ Y( NMAX ), YS( NMAX*INCMAX ), YT( NMAX ), $ YY( NMAX*INCMAX ), Z( NMAX ) INTEGER IDIM( NIDIM ), INC( NINC ) * .. Local Scalars .. REAL ALPHA, ALS, ERR, ERRMAX, TRANSL INTEGER I, IA, IM, IN, INCX, INCXS, INCY, INCYS, IX, $ IY, J, LAA, LDA, LDAS, LX, LY, M, MS, N, NARGS, $ NC, ND, NS LOGICAL NULL, RESET, SAME * .. Local Arrays .. REAL W( 1 ) LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LSE, LSERES EXTERNAL LSE, LSERES * .. External Subroutines .. EXTERNAL SGER, SMAKE, SMVCH * .. Intrinsic Functions .. INTRINSIC ABS, MAX, MIN * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Executable Statements .. * Define the number of arguments. NARGS = 9 * NC = 0 RESET = .TRUE. ERRMAX = ZERO * DO 120 IN = 1, NIDIM N = IDIM( IN ) ND = N/2 + 1 * DO 110 IM = 1, 2 IF( IM.EQ.1 ) $ M = MAX( N - ND, 0 ) IF( IM.EQ.2 ) $ M = MIN( N + ND, NMAX ) * * Set LDA to 1 more than minimum value if room. LDA = M IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 110 LAA = LDA*N NULL = N.LE.0.OR.M.LE.0 * DO 100 IX = 1, NINC INCX = INC( IX ) LX = ABS( INCX )*M * * Generate the vector X. * TRANSL = HALF CALL SMAKE( 'GE', ' ', ' ', 1, M, X, 1, XX, ABS( INCX ), $ 0, M - 1, RESET, TRANSL ) IF( M.GT.1 )THEN X( M/2 ) = ZERO XX( 1 + ABS( INCX )*( M/2 - 1 ) ) = ZERO END IF * DO 90 IY = 1, NINC INCY = INC( IY ) LY = ABS( INCY )*N * * Generate the vector Y. * TRANSL = ZERO CALL SMAKE( 'GE', ' ', ' ', 1, N, Y, 1, YY, $ ABS( INCY ), 0, N - 1, RESET, TRANSL ) IF( N.GT.1 )THEN Y( N/2 ) = ZERO YY( 1 + ABS( INCY )*( N/2 - 1 ) ) = ZERO END IF * DO 80 IA = 1, NALF ALPHA = ALF( IA ) * * Generate the matrix A. * TRANSL = ZERO CALL SMAKE( SNAME( 2: 3 ), ' ', ' ', M, N, A, NMAX, $ AA, LDA, M - 1, N - 1, RESET, TRANSL ) * NC = NC + 1 * * Save every datum before calling the subroutine. * MS = M NS = N ALS = ALPHA DO 10 I = 1, LAA AS( I ) = AA( I ) 10 CONTINUE LDAS = LDA DO 20 I = 1, LX XS( I ) = XX( I ) 20 CONTINUE INCXS = INCX DO 30 I = 1, LY YS( I ) = YY( I ) 30 CONTINUE INCYS = INCY * * Call the subroutine. * IF( TRACE ) $ WRITE( NTRA, FMT = 9994 )NC, SNAME, M, N, $ ALPHA, INCX, INCY, LDA IF( REWI ) $ REWIND NTRA CALL SGER( M, N, ALPHA, XX, INCX, YY, INCY, AA, $ LDA ) * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9993 ) FATAL = .TRUE. GO TO 140 END IF * * See what data changed inside subroutine. * ISAME( 1 ) = MS.EQ.M ISAME( 2 ) = NS.EQ.N ISAME( 3 ) = ALS.EQ.ALPHA ISAME( 4 ) = LSE( XS, XX, LX ) ISAME( 5 ) = INCXS.EQ.INCX ISAME( 6 ) = LSE( YS, YY, LY ) ISAME( 7 ) = INCYS.EQ.INCY IF( NULL )THEN ISAME( 8 ) = LSE( AS, AA, LAA ) ELSE ISAME( 8 ) = LSERES( 'GE', ' ', M, N, AS, AA, $ LDA ) END IF ISAME( 9 ) = LDAS.EQ.LDA * * 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 140 END IF * IF( .NOT.NULL )THEN * * Check the result column by column. * IF( INCX.GT.0 )THEN DO 50 I = 1, M Z( I ) = X( I ) 50 CONTINUE ELSE DO 60 I = 1, M Z( I ) = X( M - I + 1 ) 60 CONTINUE END IF DO 70 J = 1, N IF( INCY.GT.0 )THEN W( 1 ) = Y( J ) ELSE W( 1 ) = Y( N - J + 1 ) END IF CALL SMVCH( 'N', M, 1, ALPHA, Z, NMAX, W, 1, $ ONE, A( 1, J ), 1, YT, G, $ AA( 1 + ( J - 1 )*LDA ), EPS, $ ERR, FATAL, NOUT, .TRUE. ) ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and return. IF( FATAL ) $ GO TO 130 70 CONTINUE ELSE * Avoid repeating tests with M.le.0 or N.le.0. GO TO 110 END IF * 80 CONTINUE * 90 CONTINUE * 100 CONTINUE * 110 CONTINUE * 120 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 150 * 130 CONTINUE WRITE( NOUT, FMT = 9995 )J * 140 CONTINUE WRITE( NOUT, FMT = 9996 )SNAME WRITE( NOUT, FMT = 9994 )NC, SNAME, M, N, ALPHA, INCX, INCY, LDA * 150 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( I3, ',' ), F4.1, ', X,', I2, $ ', Y,', I2, ', A,', I3, ') .' ) 9993 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of SCHK4. * END SUBROUTINE SCHK5( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NALF, ALF, NINC, INC, NMAX, $ INCMAX, A, AA, AS, X, XX, XS, Y, YY, YS, YT, G, $ Z ) * * Tests SSYR and SSPR. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Parameters .. REAL ZERO, HALF, ONE PARAMETER ( ZERO = 0.0, HALF = 0.5, ONE = 1.0 ) * .. Scalar Arguments .. REAL EPS, THRESH INTEGER INCMAX, NALF, NIDIM, NINC, NMAX, NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ), $ AS( NMAX*NMAX ), G( NMAX ), X( NMAX ), $ XS( NMAX*INCMAX ), XX( NMAX*INCMAX ), $ Y( NMAX ), YS( NMAX*INCMAX ), YT( NMAX ), $ YY( NMAX*INCMAX ), Z( NMAX ) INTEGER IDIM( NIDIM ), INC( NINC ) * .. Local Scalars .. REAL ALPHA, ALS, ERR, ERRMAX, TRANSL INTEGER I, IA, IC, IN, INCX, INCXS, IX, J, JA, JJ, LAA, $ LDA, LDAS, LJ, LX, N, NARGS, NC, NS LOGICAL FULL, NULL, PACKED, RESET, SAME, UPPER CHARACTER*1 UPLO, UPLOS CHARACTER*2 ICH * .. Local Arrays .. REAL W( 1 ) LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LSE, LSERES EXTERNAL LSE, LSERES * .. External Subroutines .. EXTERNAL SMAKE, SMVCH, SSPR, SSYR * .. Intrinsic Functions .. INTRINSIC ABS, MAX * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Data statements .. DATA ICH/'UL'/ * .. Executable Statements .. FULL = SNAME( 3: 3 ).EQ.'Y' PACKED = SNAME( 3: 3 ).EQ.'P' * Define the number of arguments. IF( FULL )THEN NARGS = 7 ELSE IF( PACKED )THEN NARGS = 6 END IF * NC = 0 RESET = .TRUE. ERRMAX = ZERO * DO 100 IN = 1, NIDIM N = IDIM( IN ) * Set LDA to 1 more than minimum value if room. LDA = N IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 100 IF( PACKED )THEN LAA = ( N*( N + 1 ) )/2 ELSE LAA = LDA*N END IF * DO 90 IC = 1, 2 UPLO = ICH( IC: IC ) UPPER = UPLO.EQ.'U' * DO 80 IX = 1, NINC INCX = INC( IX ) LX = ABS( INCX )*N * * Generate the vector X. * TRANSL = HALF CALL SMAKE( 'GE', ' ', ' ', 1, N, X, 1, XX, ABS( INCX ), $ 0, N - 1, RESET, TRANSL ) IF( N.GT.1 )THEN X( N/2 ) = ZERO XX( 1 + ABS( INCX )*( N/2 - 1 ) ) = ZERO END IF * DO 70 IA = 1, NALF ALPHA = ALF( IA ) NULL = N.LE.0.OR.ALPHA.EQ.ZERO * * Generate the matrix A. * TRANSL = ZERO CALL SMAKE( SNAME( 2: 3 ), UPLO, ' ', N, N, A, NMAX, $ AA, LDA, N - 1, N - 1, RESET, TRANSL ) * NC = NC + 1 * * Save every datum before calling the subroutine. * UPLOS = UPLO NS = N ALS = ALPHA DO 10 I = 1, LAA AS( I ) = AA( I ) 10 CONTINUE LDAS = LDA DO 20 I = 1, LX XS( I ) = XX( I ) 20 CONTINUE INCXS = INCX * * Call the subroutine. * IF( FULL )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9993 )NC, SNAME, UPLO, N, $ ALPHA, INCX, LDA IF( REWI ) $ REWIND NTRA CALL SSYR( UPLO, N, ALPHA, XX, INCX, AA, LDA ) ELSE IF( PACKED )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9994 )NC, SNAME, UPLO, N, $ ALPHA, INCX IF( REWI ) $ REWIND NTRA CALL SSPR( UPLO, N, ALPHA, XX, INCX, AA ) END IF * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9992 ) FATAL = .TRUE. GO TO 120 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = UPLO.EQ.UPLOS ISAME( 2 ) = NS.EQ.N ISAME( 3 ) = ALS.EQ.ALPHA ISAME( 4 ) = LSE( XS, XX, LX ) ISAME( 5 ) = INCXS.EQ.INCX IF( NULL )THEN ISAME( 6 ) = LSE( AS, AA, LAA ) ELSE ISAME( 6 ) = LSERES( SNAME( 2: 3 ), UPLO, N, N, AS, $ AA, LDA ) END IF IF( .NOT.PACKED )THEN ISAME( 7 ) = LDAS.EQ.LDA END IF * * 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. * IF( INCX.GT.0 )THEN DO 40 I = 1, N Z( I ) = X( I ) 40 CONTINUE ELSE DO 50 I = 1, N Z( I ) = X( N - I + 1 ) 50 CONTINUE END IF JA = 1 DO 60 J = 1, N W( 1 ) = Z( J ) IF( UPPER )THEN JJ = 1 LJ = J ELSE JJ = J LJ = N - J + 1 END IF CALL SMVCH( 'N', LJ, 1, ALPHA, Z( JJ ), LJ, W, $ 1, ONE, A( JJ, J ), 1, YT, G, $ AA( JA ), EPS, ERR, FATAL, NOUT, $ .TRUE. ) IF( FULL )THEN IF( UPPER )THEN JA = JA + LDA ELSE JA = JA + LDA + 1 END IF ELSE JA = JA + LJ END IF ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and return. IF( FATAL ) $ GO TO 110 60 CONTINUE ELSE * Avoid repeating tests if N.le.0. IF( N.LE.0 ) $ GO TO 100 END IF * 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 WRITE( NOUT, FMT = 9995 )J * 120 CONTINUE WRITE( NOUT, FMT = 9996 )SNAME IF( FULL )THEN WRITE( NOUT, FMT = 9993 )NC, SNAME, UPLO, N, ALPHA, INCX, LDA ELSE IF( PACKED )THEN WRITE( NOUT, FMT = 9994 )NC, SNAME, UPLO, N, ALPHA, INCX END IF * 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, '(''', A1, ''',', I3, ',', F4.1, ', X,', $ I2, ', AP) .' ) 9993 FORMAT( 1X, I6, ': ', A6, '(''', A1, ''',', I3, ',', F4.1, ', X,', $ I2, ', A,', I3, ') .' ) 9992 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of SCHK5. * END SUBROUTINE SCHK6( SNAME, EPS, THRESH, NOUT, NTRA, TRACE, REWI, $ FATAL, NIDIM, IDIM, NALF, ALF, NINC, INC, NMAX, $ INCMAX, A, AA, AS, X, XX, XS, Y, YY, YS, YT, G, $ Z ) * * Tests SSYR2 and SSPR2. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Parameters .. REAL ZERO, HALF, ONE PARAMETER ( ZERO = 0.0, HALF = 0.5, ONE = 1.0 ) * .. Scalar Arguments .. REAL EPS, THRESH INTEGER INCMAX, NALF, NIDIM, NINC, NMAX, NOUT, NTRA LOGICAL FATAL, REWI, TRACE CHARACTER*6 SNAME * .. Array Arguments .. REAL A( NMAX, NMAX ), AA( NMAX*NMAX ), ALF( NALF ), $ AS( NMAX*NMAX ), G( NMAX ), X( NMAX ), $ XS( NMAX*INCMAX ), XX( NMAX*INCMAX ), $ Y( NMAX ), YS( NMAX*INCMAX ), YT( NMAX ), $ YY( NMAX*INCMAX ), Z( NMAX, 2 ) INTEGER IDIM( NIDIM ), INC( NINC ) * .. Local Scalars .. REAL ALPHA, ALS, ERR, ERRMAX, TRANSL INTEGER I, IA, IC, IN, INCX, INCXS, INCY, INCYS, IX, $ IY, J, JA, JJ, LAA, LDA, LDAS, LJ, LX, LY, N, $ NARGS, NC, NS LOGICAL FULL, NULL, PACKED, RESET, SAME, UPPER CHARACTER*1 UPLO, UPLOS CHARACTER*2 ICH * .. Local Arrays .. REAL W( 2 ) LOGICAL ISAME( 13 ) * .. External Functions .. LOGICAL LSE, LSERES EXTERNAL LSE, LSERES * .. External Subroutines .. EXTERNAL SMAKE, SMVCH, SSPR2, SSYR2 * .. Intrinsic Functions .. INTRINSIC ABS, MAX * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Common blocks .. COMMON /INFOC/INFOT, NOUTC, OK, LERR * .. Data statements .. DATA ICH/'UL'/ * .. Executable Statements .. FULL = SNAME( 3: 3 ).EQ.'Y' PACKED = SNAME( 3: 3 ).EQ.'P' * Define the number of arguments. IF( FULL )THEN NARGS = 9 ELSE IF( PACKED )THEN NARGS = 8 END IF * NC = 0 RESET = .TRUE. ERRMAX = ZERO * DO 140 IN = 1, NIDIM N = IDIM( IN ) * Set LDA to 1 more than minimum value if room. LDA = N IF( LDA.LT.NMAX ) $ LDA = LDA + 1 * Skip tests if not enough room. IF( LDA.GT.NMAX ) $ GO TO 140 IF( PACKED )THEN LAA = ( N*( N + 1 ) )/2 ELSE LAA = LDA*N END IF * DO 130 IC = 1, 2 UPLO = ICH( IC: IC ) UPPER = UPLO.EQ.'U' * DO 120 IX = 1, NINC INCX = INC( IX ) LX = ABS( INCX )*N * * Generate the vector X. * TRANSL = HALF CALL SMAKE( 'GE', ' ', ' ', 1, N, X, 1, XX, ABS( INCX ), $ 0, N - 1, RESET, TRANSL ) IF( N.GT.1 )THEN X( N/2 ) = ZERO XX( 1 + ABS( INCX )*( N/2 - 1 ) ) = ZERO END IF * DO 110 IY = 1, NINC INCY = INC( IY ) LY = ABS( INCY )*N * * Generate the vector Y. * TRANSL = ZERO CALL SMAKE( 'GE', ' ', ' ', 1, N, Y, 1, YY, $ ABS( INCY ), 0, N - 1, RESET, TRANSL ) IF( N.GT.1 )THEN Y( N/2 ) = ZERO YY( 1 + ABS( INCY )*( N/2 - 1 ) ) = ZERO END IF * DO 100 IA = 1, NALF ALPHA = ALF( IA ) NULL = N.LE.0.OR.ALPHA.EQ.ZERO * * Generate the matrix A. * TRANSL = ZERO CALL SMAKE( SNAME( 2: 3 ), UPLO, ' ', N, N, A, $ NMAX, AA, LDA, N - 1, N - 1, RESET, $ TRANSL ) * NC = NC + 1 * * Save every datum before calling the subroutine. * UPLOS = UPLO NS = N ALS = ALPHA DO 10 I = 1, LAA AS( I ) = AA( I ) 10 CONTINUE LDAS = LDA DO 20 I = 1, LX XS( I ) = XX( I ) 20 CONTINUE INCXS = INCX DO 30 I = 1, LY YS( I ) = YY( I ) 30 CONTINUE INCYS = INCY * * Call the subroutine. * IF( FULL )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9993 )NC, SNAME, UPLO, N, $ ALPHA, INCX, INCY, LDA IF( REWI ) $ REWIND NTRA CALL SSYR2( UPLO, N, ALPHA, XX, INCX, YY, INCY, $ AA, LDA ) ELSE IF( PACKED )THEN IF( TRACE ) $ WRITE( NTRA, FMT = 9994 )NC, SNAME, UPLO, N, $ ALPHA, INCX, INCY IF( REWI ) $ REWIND NTRA CALL SSPR2( UPLO, N, ALPHA, XX, INCX, YY, INCY, $ AA ) END IF * * Check if error-exit was taken incorrectly. * IF( .NOT.OK )THEN WRITE( NOUT, FMT = 9992 ) FATAL = .TRUE. GO TO 160 END IF * * See what data changed inside subroutines. * ISAME( 1 ) = UPLO.EQ.UPLOS ISAME( 2 ) = NS.EQ.N ISAME( 3 ) = ALS.EQ.ALPHA ISAME( 4 ) = LSE( XS, XX, LX ) ISAME( 5 ) = INCXS.EQ.INCX ISAME( 6 ) = LSE( YS, YY, LY ) ISAME( 7 ) = INCYS.EQ.INCY IF( NULL )THEN ISAME( 8 ) = LSE( AS, AA, LAA ) ELSE ISAME( 8 ) = LSERES( SNAME( 2: 3 ), UPLO, N, N, $ AS, AA, LDA ) END IF IF( .NOT.PACKED )THEN ISAME( 9 ) = LDAS.EQ.LDA END IF * * 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 160 END IF * IF( .NOT.NULL )THEN * * Check the result column by column. * IF( INCX.GT.0 )THEN DO 50 I = 1, N Z( I, 1 ) = X( I ) 50 CONTINUE ELSE DO 60 I = 1, N Z( I, 1 ) = X( N - I + 1 ) 60 CONTINUE END IF IF( INCY.GT.0 )THEN DO 70 I = 1, N Z( I, 2 ) = Y( I ) 70 CONTINUE ELSE DO 80 I = 1, N Z( I, 2 ) = Y( N - I + 1 ) 80 CONTINUE END IF JA = 1 DO 90 J = 1, N W( 1 ) = Z( J, 2 ) W( 2 ) = Z( J, 1 ) IF( UPPER )THEN JJ = 1 LJ = J ELSE JJ = J LJ = N - J + 1 END IF CALL SMVCH( 'N', LJ, 2, ALPHA, Z( JJ, 1 ), $ NMAX, W, 1, ONE, A( JJ, J ), 1, $ YT, G, AA( JA ), EPS, ERR, FATAL, $ NOUT, .TRUE. ) IF( FULL )THEN IF( UPPER )THEN JA = JA + LDA ELSE JA = JA + LDA + 1 END IF ELSE JA = JA + LJ END IF ERRMAX = MAX( ERRMAX, ERR ) * If got really bad answer, report and return. IF( FATAL ) $ GO TO 150 90 CONTINUE ELSE * Avoid repeating tests with N.le.0. IF( N.LE.0 ) $ GO TO 140 END IF * 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 170 * 150 CONTINUE WRITE( NOUT, FMT = 9995 )J * 160 CONTINUE WRITE( NOUT, FMT = 9996 )SNAME IF( FULL )THEN WRITE( NOUT, FMT = 9993 )NC, SNAME, UPLO, N, ALPHA, INCX, $ INCY, LDA ELSE IF( PACKED )THEN WRITE( NOUT, FMT = 9994 )NC, SNAME, UPLO, N, ALPHA, INCX, INCY END IF * 170 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, '(''', A1, ''',', I3, ',', F4.1, ', X,', $ I2, ', Y,', I2, ', AP) .' ) 9993 FORMAT( 1X, I6, ': ', A6, '(''', A1, ''',', I3, ',', F4.1, ', X,', $ I2, ', Y,', I2, ', A,', I3, ') .' ) 9992 FORMAT( ' ******* FATAL ERROR - ERROR-EXIT TAKEN ON VALID CALL *', $ '******' ) * * End of SCHK6. * END SUBROUTINE SCHKE( ISNUM, SRNAMT, NOUT ) * * Tests the error exits from the Level 2 Blas. * Requires a special version of the error-handling routine XERBLA. * ALPHA, BETA, A, X and Y should not need to be defined. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Scalar Arguments .. INTEGER ISNUM, NOUT CHARACTER*6 SRNAMT * .. Scalars in Common .. INTEGER INFOT, NOUTC LOGICAL LERR, OK * .. Local Scalars .. REAL ALPHA, BETA * .. Local Arrays .. REAL A( 1, 1 ), X( 1 ), Y( 1 ) * .. External Subroutines .. EXTERNAL CHKXER, SGBMV, SGEMV, SGER, SSBMV, SSPMV, SSPR, $ SSPR2, SSYMV, SSYR, SSYR2, STBMV, STBSV, STPMV, $ STPSV, STRMV, STRSV * .. 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, 70, 80, $ 90, 100, 110, 120, 130, 140, 150, $ 160 )ISNUM 10 INFOT = 1 CALL SGEMV( '/', 0, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SGEMV( 'N', -1, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL SGEMV( 'N', 0, -1, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL SGEMV( 'N', 2, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 8 CALL SGEMV( 'N', 0, 0, ALPHA, A, 1, X, 0, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL SGEMV( 'N', 0, 0, ALPHA, A, 1, X, 1, BETA, Y, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 20 INFOT = 1 CALL SGBMV( '/', 0, 0, 0, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SGBMV( 'N', -1, 0, 0, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL SGBMV( 'N', 0, -1, 0, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL SGBMV( 'N', 0, 0, -1, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL SGBMV( 'N', 2, 0, 0, -1, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 8 CALL SGBMV( 'N', 0, 0, 1, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL SGBMV( 'N', 0, 0, 0, 0, ALPHA, A, 1, X, 0, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 13 CALL SGBMV( 'N', 0, 0, 0, 0, ALPHA, A, 1, X, 1, BETA, Y, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 30 INFOT = 1 CALL SSYMV( '/', 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SSYMV( 'U', -1, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL SSYMV( 'U', 2, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL SSYMV( 'U', 0, ALPHA, A, 1, X, 0, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 10 CALL SSYMV( 'U', 0, ALPHA, A, 1, X, 1, BETA, Y, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 40 INFOT = 1 CALL SSBMV( '/', 0, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SSBMV( 'U', -1, 0, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL SSBMV( 'U', 0, -1, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL SSBMV( 'U', 0, 1, ALPHA, A, 1, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 8 CALL SSBMV( 'U', 0, 0, ALPHA, A, 1, X, 0, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 11 CALL SSBMV( 'U', 0, 0, ALPHA, A, 1, X, 1, BETA, Y, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 50 INFOT = 1 CALL SSPMV( '/', 0, ALPHA, A, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SSPMV( 'U', -1, ALPHA, A, X, 1, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL SSPMV( 'U', 0, ALPHA, A, X, 0, BETA, Y, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL SSPMV( 'U', 0, ALPHA, A, X, 1, BETA, Y, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 60 INFOT = 1 CALL STRMV( '/', 'N', 'N', 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL STRMV( 'U', '/', 'N', 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL STRMV( 'U', 'N', '/', 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL STRMV( 'U', 'N', 'N', -1, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL STRMV( 'U', 'N', 'N', 2, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 8 CALL STRMV( 'U', 'N', 'N', 0, A, 1, X, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 70 INFOT = 1 CALL STBMV( '/', 'N', 'N', 0, 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL STBMV( 'U', '/', 'N', 0, 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL STBMV( 'U', 'N', '/', 0, 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL STBMV( 'U', 'N', 'N', -1, 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL STBMV( 'U', 'N', 'N', 0, -1, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL STBMV( 'U', 'N', 'N', 0, 1, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL STBMV( 'U', 'N', 'N', 0, 0, A, 1, X, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 80 INFOT = 1 CALL STPMV( '/', 'N', 'N', 0, A, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL STPMV( 'U', '/', 'N', 0, A, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL STPMV( 'U', 'N', '/', 0, A, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL STPMV( 'U', 'N', 'N', -1, A, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL STPMV( 'U', 'N', 'N', 0, A, X, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 90 INFOT = 1 CALL STRSV( '/', 'N', 'N', 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL STRSV( 'U', '/', 'N', 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL STRSV( 'U', 'N', '/', 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL STRSV( 'U', 'N', 'N', -1, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 6 CALL STRSV( 'U', 'N', 'N', 2, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 8 CALL STRSV( 'U', 'N', 'N', 0, A, 1, X, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 100 INFOT = 1 CALL STBSV( '/', 'N', 'N', 0, 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL STBSV( 'U', '/', 'N', 0, 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL STBSV( 'U', 'N', '/', 0, 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL STBSV( 'U', 'N', 'N', -1, 0, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL STBSV( 'U', 'N', 'N', 0, -1, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL STBSV( 'U', 'N', 'N', 0, 1, A, 1, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL STBSV( 'U', 'N', 'N', 0, 0, A, 1, X, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 110 INFOT = 1 CALL STPSV( '/', 'N', 'N', 0, A, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL STPSV( 'U', '/', 'N', 0, A, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 3 CALL STPSV( 'U', 'N', '/', 0, A, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 4 CALL STPSV( 'U', 'N', 'N', -1, A, X, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL STPSV( 'U', 'N', 'N', 0, A, X, 0 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 120 INFOT = 1 CALL SGER( -1, 0, ALPHA, X, 1, Y, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SGER( 0, -1, ALPHA, X, 1, Y, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL SGER( 0, 0, ALPHA, X, 0, Y, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL SGER( 0, 0, ALPHA, X, 1, Y, 0, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL SGER( 2, 0, ALPHA, X, 1, Y, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 130 INFOT = 1 CALL SSYR( '/', 0, ALPHA, X, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SSYR( 'U', -1, ALPHA, X, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL SSYR( 'U', 0, ALPHA, X, 0, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL SSYR( 'U', 2, ALPHA, X, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 140 INFOT = 1 CALL SSPR( '/', 0, ALPHA, X, 1, A ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SSPR( 'U', -1, ALPHA, X, 1, A ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL SSPR( 'U', 0, ALPHA, X, 0, A ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 150 INFOT = 1 CALL SSYR2( '/', 0, ALPHA, X, 1, Y, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SSYR2( 'U', -1, ALPHA, X, 1, Y, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL SSYR2( 'U', 0, ALPHA, X, 0, Y, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL SSYR2( 'U', 0, ALPHA, X, 1, Y, 0, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 9 CALL SSYR2( 'U', 2, ALPHA, X, 1, Y, 1, A, 1 ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) GO TO 170 160 INFOT = 1 CALL SSPR2( '/', 0, ALPHA, X, 1, Y, 1, A ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 2 CALL SSPR2( 'U', -1, ALPHA, X, 1, Y, 1, A ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 5 CALL SSPR2( 'U', 0, ALPHA, X, 0, Y, 1, A ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) INFOT = 7 CALL SSPR2( 'U', 0, ALPHA, X, 1, Y, 0, A ) CALL CHKXER( SRNAMT, INFOT, NOUT, LERR, OK ) * 170 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 SCHKE. * END SUBROUTINE SMAKE( TYPE, UPLO, DIAG, M, N, A, NMAX, AA, LDA, KL, $ KU, RESET, TRANSL ) * * Generates values for an M by N matrix A within the bandwidth * defined by KL and KU. * 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', 'GB', 'SY', 'SB', 'SP', 'TR', 'TB' OR 'TP'. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Parameters .. REAL ZERO, ONE PARAMETER ( ZERO = 0.0, ONE = 1.0 ) REAL ROGUE PARAMETER ( ROGUE = -1.0E10 ) * .. Scalar Arguments .. REAL TRANSL INTEGER KL, KU, LDA, M, N, NMAX LOGICAL RESET CHARACTER*1 DIAG, UPLO CHARACTER*2 TYPE * .. Array Arguments .. REAL A( NMAX, * ), AA( * ) * .. Local Scalars .. INTEGER I, I1, I2, I3, IBEG, IEND, IOFF, J, KK LOGICAL GEN, LOWER, SYM, TRI, UNIT, UPPER * .. External Functions .. REAL SBEG EXTERNAL SBEG * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. Executable Statements .. GEN = TYPE( 1: 1 ).EQ.'G' SYM = TYPE( 1: 1 ).EQ.'S' TRI = TYPE( 1: 1 ).EQ.'T' 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 IF( ( I.LE.J.AND.J - I.LE.KU ).OR. $ ( I.GE.J.AND.I - J.LE.KL ) )THEN A( I, J ) = SBEG( RESET ) + TRANSL ELSE A( I, J ) = ZERO END IF IF( I.NE.J )THEN 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.'GB' )THEN DO 90 J = 1, N DO 60 I1 = 1, KU + 1 - J AA( I1 + ( J - 1 )*LDA ) = ROGUE 60 CONTINUE DO 70 I2 = I1, MIN( KL + KU + 1, KU + 1 + M - J ) AA( I2 + ( J - 1 )*LDA ) = A( I2 + J - KU - 1, J ) 70 CONTINUE DO 80 I3 = I2, LDA AA( I3 + ( J - 1 )*LDA ) = ROGUE 80 CONTINUE 90 CONTINUE ELSE IF( TYPE.EQ.'SY'.OR.TYPE.EQ.'TR' )THEN DO 130 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 100 I = 1, IBEG - 1 AA( I + ( J - 1 )*LDA ) = ROGUE 100 CONTINUE DO 110 I = IBEG, IEND AA( I + ( J - 1 )*LDA ) = A( I, J ) 110 CONTINUE DO 120 I = IEND + 1, LDA AA( I + ( J - 1 )*LDA ) = ROGUE 120 CONTINUE 130 CONTINUE ELSE IF( TYPE.EQ.'SB'.OR.TYPE.EQ.'TB' )THEN DO 170 J = 1, N IF( UPPER )THEN KK = KL + 1 IBEG = MAX( 1, KL + 2 - J ) IF( UNIT )THEN IEND = KL ELSE IEND = KL + 1 END IF ELSE KK = 1 IF( UNIT )THEN IBEG = 2 ELSE IBEG = 1 END IF IEND = MIN( KL + 1, 1 + M - J ) END IF DO 140 I = 1, IBEG - 1 AA( I + ( J - 1 )*LDA ) = ROGUE 140 CONTINUE DO 150 I = IBEG, IEND AA( I + ( J - 1 )*LDA ) = A( I + J - KK, J ) 150 CONTINUE DO 160 I = IEND + 1, LDA AA( I + ( J - 1 )*LDA ) = ROGUE 160 CONTINUE 170 CONTINUE ELSE IF( TYPE.EQ.'SP'.OR.TYPE.EQ.'TP' )THEN IOFF = 0 DO 190 J = 1, N IF( UPPER )THEN IBEG = 1 IEND = J ELSE IBEG = J IEND = N END IF DO 180 I = IBEG, IEND IOFF = IOFF + 1 AA( IOFF ) = A( I, J ) IF( I.EQ.J )THEN IF( UNIT ) $ AA( IOFF ) = ROGUE END IF 180 CONTINUE 190 CONTINUE END IF RETURN * * End of SMAKE. * END SUBROUTINE SMVCH( TRANS, M, N, ALPHA, A, NMAX, X, INCX, BETA, Y, $ INCY, YT, G, YY, EPS, ERR, FATAL, NOUT, MV ) * * Checks the results of the computational tests. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Parameters .. REAL ZERO, ONE PARAMETER ( ZERO = 0.0, ONE = 1.0 ) * .. Scalar Arguments .. REAL ALPHA, BETA, EPS, ERR INTEGER INCX, INCY, M, N, NMAX, NOUT LOGICAL FATAL, MV CHARACTER*1 TRANS * .. Array Arguments .. REAL A( NMAX, * ), G( * ), X( * ), Y( * ), YT( * ), $ YY( * ) * .. Local Scalars .. REAL ERRI INTEGER I, INCXL, INCYL, IY, J, JX, KX, KY, ML, NL LOGICAL TRAN * .. Intrinsic Functions .. INTRINSIC ABS, MAX, SQRT * .. Executable Statements .. TRAN = TRANS.EQ.'T'.OR.TRANS.EQ.'C' IF( TRAN )THEN ML = N NL = M ELSE ML = M NL = N END IF IF( INCX.LT.0 )THEN KX = NL INCXL = -1 ELSE KX = 1 INCXL = 1 END IF IF( INCY.LT.0 )THEN KY = ML INCYL = -1 ELSE KY = 1 INCYL = 1 END IF * * Compute expected result in YT using data in A, X and Y. * Compute gauges in G. * IY = KY DO 30 I = 1, ML YT( IY ) = ZERO G( IY ) = ZERO JX = KX IF( TRAN )THEN DO 10 J = 1, NL YT( IY ) = YT( IY ) + A( J, I )*X( JX ) G( IY ) = G( IY ) + ABS( A( J, I )*X( JX ) ) JX = JX + INCXL 10 CONTINUE ELSE DO 20 J = 1, NL YT( IY ) = YT( IY ) + A( I, J )*X( JX ) G( IY ) = G( IY ) + ABS( A( I, J )*X( JX ) ) JX = JX + INCXL 20 CONTINUE END IF YT( IY ) = ALPHA*YT( IY ) + BETA*Y( IY ) G( IY ) = ABS( ALPHA )*G( IY ) + ABS( BETA*Y( IY ) ) IY = IY + INCYL 30 CONTINUE * * Compute the error ratio for this result. * ERR = ZERO DO 40 I = 1, ML ERRI = ABS( YT( I ) - YY( 1 + ( I - 1 )*ABS( INCY ) ) )/EPS IF( G( I ).NE.ZERO ) $ ERRI = ERRI/G( I ) ERR = MAX( ERR, ERRI ) IF( ERR*SQRT( EPS ).GE.ONE ) $ GO TO 50 40 CONTINUE * If the loop completes, all results are at least half accurate. GO TO 70 * * Report fatal error. * 50 FATAL = .TRUE. WRITE( NOUT, FMT = 9999 ) DO 60 I = 1, ML IF( MV )THEN WRITE( NOUT, FMT = 9998 )I, YT( I ), $ YY( 1 + ( I - 1 )*ABS( INCY ) ) ELSE WRITE( NOUT, FMT = 9998 )I, $ YY( 1 + ( I - 1 )*ABS( INCY ) ), YT(I) END IF 60 CONTINUE * 70 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 ) * * End of SMVCH. * END LOGICAL FUNCTION LSE( RI, RJ, LR ) * * Tests if two arrays are identical. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Scalar Arguments .. INTEGER LR * .. Array Arguments .. REAL RI( * ), RJ( * ) * .. Local Scalars .. INTEGER I * .. Executable Statements .. DO 10 I = 1, LR IF( RI( I ).NE.RJ( I ) ) $ GO TO 20 10 CONTINUE LSE = .TRUE. GO TO 30 20 CONTINUE LSE = .FALSE. 30 RETURN * * End of LSE. * END LOGICAL FUNCTION LSERES( TYPE, UPLO, M, N, AA, AS, LDA ) * * Tests if selected elements in two arrays are equal. * * TYPE is 'GE', 'SY' or 'SP'. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Scalar Arguments .. INTEGER LDA, M, N CHARACTER*1 UPLO CHARACTER*2 TYPE * .. Array Arguments .. REAL 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 LSERES = .TRUE. GO TO 80 70 CONTINUE LSERES = .FALSE. 80 RETURN * * End of LSERES. * END REAL FUNCTION SBEG( RESET ) * * Generates random numbers uniformly distributed between -0.5 and 0.5. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. Scalar Arguments .. LOGICAL RESET * .. Local Scalars .. INTEGER I, IC, MI * .. Save statement .. SAVE I, IC, MI * .. Intrinsic Functions .. INTRINSIC REAL * .. 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 SBEG = REAL( I - 500 )/1001.0 RETURN * * End of SBEG. * END REAL FUNCTION SDIFF( X, Y ) * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * * .. Scalar Arguments .. REAL X, Y * .. Executable Statements .. SDIFF = X - Y RETURN * * End of SDIFF. * 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 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. 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 2 BLAS * routines. * * XERBLA is an error handler for the Level 2 BLAS routines. * * It is called by the Level 2 BLAS routines if an input parameter is * invalid. * * Auxiliary routine for test program for Level 2 Blas. * * -- Written on 10-August-1987. * Richard Hanson, Sandia National Labs. * Jeremy Du Croz, NAG Central Office. * * .. 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
apache-2.0
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/TESTING/LIN/spot03.f
32
5949
*> \brief \b SPOT03 * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE SPOT03( UPLO, N, A, LDA, AINV, LDAINV, WORK, LDWORK, * RWORK, RCOND, RESID ) * * .. Scalar Arguments .. * CHARACTER UPLO * INTEGER LDA, LDAINV, LDWORK, N * REAL RCOND, RESID * .. * .. Array Arguments .. * REAL A( LDA, * ), AINV( LDAINV, * ), RWORK( * ), * $ WORK( LDWORK, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> SPOT03 computes the residual for a symmetric matrix times its *> inverse: *> norm( I - A*AINV ) / ( N * norm(A) * norm(AINV) * EPS ), *> where EPS is the machine epsilon. *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> Specifies whether the upper or lower triangular part of the *> symmetric matrix A is stored: *> = 'U': Upper triangular *> = 'L': Lower triangular *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of rows and columns of the matrix A. N >= 0. *> \endverbatim *> *> \param[in] A *> \verbatim *> A is REAL array, dimension (LDA,N) *> The original symmetric matrix A. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. LDA >= max(1,N) *> \endverbatim *> *> \param[in,out] AINV *> \verbatim *> AINV is REAL array, dimension (LDAINV,N) *> On entry, the inverse of the matrix A, stored as a symmetric *> matrix in the same format as A. *> In this version, AINV is expanded into a full matrix and *> multiplied by A, so the opposing triangle of AINV will be *> changed; i.e., if the upper triangular part of AINV is *> stored, the lower triangular part will be used as work space. *> \endverbatim *> *> \param[in] LDAINV *> \verbatim *> LDAINV is INTEGER *> The leading dimension of the array AINV. LDAINV >= max(1,N). *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is REAL array, dimension (LDWORK,N) *> \endverbatim *> *> \param[in] LDWORK *> \verbatim *> LDWORK is INTEGER *> The leading dimension of the array WORK. LDWORK >= max(1,N). *> \endverbatim *> *> \param[out] RWORK *> \verbatim *> RWORK is REAL array, dimension (N) *> \endverbatim *> *> \param[out] RCOND *> \verbatim *> RCOND is REAL *> The reciprocal of the condition number of A, computed as *> ( 1/norm(A) ) / norm(AINV). *> \endverbatim *> *> \param[out] RESID *> \verbatim *> RESID is REAL *> norm(I - A*AINV) / ( N * norm(A) * norm(AINV) * EPS ) *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup single_lin * * ===================================================================== SUBROUTINE SPOT03( UPLO, N, A, LDA, AINV, LDAINV, WORK, LDWORK, $ RWORK, RCOND, RESID ) * * -- LAPACK test routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER UPLO INTEGER LDA, LDAINV, LDWORK, N REAL RCOND, RESID * .. * .. Array Arguments .. REAL A( LDA, * ), AINV( LDAINV, * ), RWORK( * ), $ WORK( LDWORK, * ) * .. * * ===================================================================== * * .. Parameters .. REAL ZERO, ONE PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) * .. * .. Local Scalars .. INTEGER I, J REAL AINVNM, ANORM, EPS * .. * .. External Functions .. LOGICAL LSAME REAL SLAMCH, SLANGE, SLANSY EXTERNAL LSAME, SLAMCH, SLANGE, SLANSY * .. * .. External Subroutines .. EXTERNAL SSYMM * .. * .. Intrinsic Functions .. INTRINSIC REAL * .. * .. Executable Statements .. * * Quick exit if N = 0. * IF( N.LE.0 ) THEN RCOND = ONE RESID = ZERO RETURN END IF * * Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0. * EPS = SLAMCH( 'Epsilon' ) ANORM = SLANSY( '1', UPLO, N, A, LDA, RWORK ) AINVNM = SLANSY( '1', UPLO, N, AINV, LDAINV, RWORK ) IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN RCOND = ZERO RESID = ONE / EPS RETURN END IF RCOND = ( ONE / ANORM ) / AINVNM * * Expand AINV into a full matrix and call SSYMM to multiply * AINV on the left by A. * IF( LSAME( UPLO, 'U' ) ) THEN DO 20 J = 1, N DO 10 I = 1, J - 1 AINV( J, I ) = AINV( I, J ) 10 CONTINUE 20 CONTINUE ELSE DO 40 J = 1, N DO 30 I = J + 1, N AINV( J, I ) = AINV( I, J ) 30 CONTINUE 40 CONTINUE END IF CALL SSYMM( 'Left', UPLO, N, N, -ONE, A, LDA, AINV, LDAINV, ZERO, $ WORK, LDWORK ) * * Add the identity matrix to WORK . * DO 50 I = 1, N WORK( I, I ) = WORK( I, I ) + ONE 50 CONTINUE * * Compute norm(I - A*AINV) / (N * norm(A) * norm(AINV) * EPS) * RESID = SLANGE( '1', N, N, WORK, LDWORK, RWORK ) * RESID = ( ( RESID*RCOND ) / EPS ) / REAL( N ) * RETURN * * End of SPOT03 * END
bsd-3-clause
nicjhan/MOM5
src/ocean_shared/generic_tracers/generic_miniBLING.F90
9
216944
!---------------------------------------------------------------- ! <CONTACT EMAIL="Eric.Galbraith@mcgill.ca"> Eric D. Galbraith ! </CONTACT> ! ! <CONTACT EMAIL="GFDL.Climate.Model.Info@noaa.gov"> John P. Dunne ! </CONTACT> ! ! <CONTACT EMAIL="GFDL.Climate.Model.Info@noaa.gov"> Anand Gnanandesikan ! </CONTACT> ! ! <CONTACT EMAIL="GFDL.Climate.Model.Info@noaa.gov"> Niki Zadeh ! </CONTACT> ! ! <REVIEWER EMAIL="GFDL.Climate.Model.Info@noaa.gov"> Rick Slater ! </REVIEWER> ! ! <OVERVIEW> ! This module contains the generic version of miniBLING. ! It is designed so that both GFDL Ocean models, GOLD and MOM, can use it. ! ! WARNING: although the core components of the model (PO4, Fed, DOP, O2) ! have been reasonably well tested, the other components should be viewed as ! developmental at this point. There may still be some bugs. ! ! Also, the growth parameters have been tuned to produce a reasonable simulation ! of PO4 and chl in a 3-degree CORE-forced version of MOM4p1. It is unlikely that ! these parameter choices will produce satisfactory simulations in other physical ! model configurations, and may need to be adjusted. ! </OVERVIEW> ! !<DESCRIPTION> ! Biogeochemistry with Light, Iron, Nutrient and Gas version zero (BLINGv0) ! includes an implicit ecological model of growth limitation by light, ! temperature, phosphate and iron, along with dissolved organic ! phosphorus and O2 pools. ! Food web processing in the euphotic zone and remineralization/ ! dissolution through the ocean interior are handled as in Dunne et al. ! (2005). O2 equilibria and gas exchange follow OCMIP2 protocols. ! Additional functionality comes from an optional carbon cycle that is ! non-interactive, i.e. does not change the core miniBLING behaviour, as ! well as tracers for radiocarbon (14c), a decomposition of carbon ! components by gas exchange and remineralization (carbon_pre), a ! decomposition of oxygen as preformed and total (o2_pre), saturation and ! consumed, and a decomposition of phosphate as preformed and remineralized ! (po4_pre). !</DESCRIPTION> ! ! <INFO> ! <REFERENCE> ! This model is available for public use. ! The current version is BLINGv0. The version number refers to the core ! model behaviour; additional tracers exist in different iterations of the ! module. In publications it should be referenced as: ! Galbraith, E.D., Gnanadesikan, A., Dunne, J. and Hiscock, M. 2010. ! Regional impacts of iron-light colimitation in a global ! biogeochemical model. Biogeosciences , 7, 1043-1064. ! ! All parameter values are as described in this paper. ! Note that this reference is only for the core model components, and ! does not include any of the additional functionalities, which remain ! undocumented. Please contact Eric Galbraith (eric.galbraith@mcgill.ca) ! for more information. ! </REFERENCE> ! ! <DEVELOPER_NOTES> ! This code was originally developed based on the template of Perth generic TOPAZ code. ! </DEVELOPER_NOTES> ! </INFO> ! !<NAMELIST NAME="generic_miniBLING_nml"> ! ! <DATA NAME="do_14c" TYPE="logical"> ! If true, then simulate radiocarbon. Includes 2 prognostic tracers, DI14C ! and DO14C. Requires that do_carbon = .true. ! </DATA> ! ! <DATA NAME="do_carbon" TYPE="logical"> ! If true, then simulate the carbon cycle based on strict stoichiometry ! of C:P. Includes 1 prognostic tracer, DIC. ! </DATA> ! !</NAMELIST> ! !---------------------------------------------------------------- #include <fms_platform.h> module generic_miniBLING_mod use coupler_types_mod, only: coupler_2d_bc_type use field_manager_mod, only: fm_string_len, fm_path_name_len, fm_field_name_len use mpp_mod, only: mpp_error, NOTE, FATAL use mpp_mod, only: stdout use time_manager_mod, only: time_type use diag_manager_mod, only: register_diag_field, send_data use constants_mod, only: WTMCO2, WTMO2 use data_override_mod, only: data_override use g_tracer_utils, only : g_tracer_type,g_tracer_start_param_list,g_tracer_end_param_list use g_tracer_utils, only : g_tracer_add,g_tracer_add_param, g_tracer_set_files use g_tracer_utils, only : g_tracer_set_values,g_tracer_get_pointer use g_tracer_utils, only : g_tracer_get_common use g_tracer_utils, only : g_tracer_coupler_set,g_tracer_coupler_get use g_tracer_utils, only : g_tracer_get_values, g_tracer_column_int, g_tracer_flux_at_depth use FMS_ocmip2_co2calc_mod, only : FMS_ocmip2_co2calc, CO2_dope_vector implicit none ; private character(len=fm_string_len), parameter :: mod_name = 'generic_miniBLING' character(len=fm_string_len), parameter :: package_name = 'generic_minibling' public do_generic_miniBLING public generic_miniBLING_register public generic_miniBLING_init public generic_miniBLING_register_diag public generic_miniBLING_update_from_coupler public generic_miniBLING_diag public generic_miniBLING_update_from_source public generic_miniBLING_update_from_bottom public generic_miniBLING_set_boundary_values public generic_miniBLING_end !The following logical for using this module is overwritten ! generic_tracer_nml namelist logical, save :: do_generic_miniBLING = .false. logical, save :: module_is_initialized = .false. real, parameter :: sperd = 24.0 * 3600.0 real, parameter :: spery = 365.25 * sperd real, parameter :: epsln=1.0e-30 ! !The following two types contain all the parameters and arrays used in this module. type generic_miniBLING_type character(len=fm_string_len) :: name = '_' character(len=fm_field_name_len) :: suffix = ' ' character(len=fm_field_name_len) :: long_suffix = ' ' logical :: prevent_neg_o2 = .true. ! Turn on additional complexity. Most relevant diagnostic variables and all ! tracers are not activated unless the appropriate switch is set to true. logical :: do_14c = .true. ! Requires do_carbon = .true. logical :: do_carbon = .true. real :: min_frac_pop = 0.0 ! Set to 1 to turn off recycling character(len=fm_string_len) :: alk_scheme = 'normal' ! Specify the scheme to use for calculating alkalinity character(len=fm_string_len) :: biomass_type = 'single' ! Specify the scheme to use for calculating biomass real :: alk_slope = 32.0e-06 ! Slope of alk:salt equation real :: alk_intercept = 1200.0e-06 ! Intercept of alk:salt equation real :: alpha_photo ! Quantum yield under low light real :: c_2_p ! Carbon to Phosphorus ratio real :: chl_min ! Minimum chl concentration allowed (for numerical stability) logical :: fe_is_prognostic = .false. ! Set whether Fed is prognostic or diagnostic logical :: fe_is_diagnostic = .false. ! Set whether Fed is diagnostic or data real :: fe_restoring = 10.0 ! Restoring time scale, in days, if Fed is diagnostic real :: fe_coastal = 2.0e-09 ! Coastal iron concentration, in mol/kg, if Fed is diagnostic real :: fe_coastal_depth = 200.0 ! Coastal depth, in meters, if Fed is diagnostic real :: fe_2_p_max ! Iron to Phosphate uptake ratio scaling real :: def_fe_min = 0.0 ! Minimum for iron deficiency real :: fe_2_p_sed ! Iron to Phosphorus ratio in sediments real :: felig_bkg ! Iron ligand concentration real :: gamma_biomass ! Biomass adjustment timescale real :: gamma_irr_mem ! Photoadaptation timescale real :: gamma_pop ! Patriculate Organic Phosphorus decay real :: half_life_14c ! Radiocarbon half-life real :: k_fe_2_p ! Fe:P half-saturation constant real :: k_fe_uptake ! Iron half-saturation concentration real :: k_o2 ! Oxygen half-saturation concentration real :: k_po4 ! Phosphate half-saturation concentration real :: k_po4_recycle ! Phosphate half-saturation concentration real :: kappa_eppley ! Temperature dependence real :: kappa_remin ! Temperature dependence for particle fractionation real :: kfe_inorg ! Iron scavenging, 2nd order real :: kfe_eq_lig_max ! Maximum light-dependent iron ligand stability constant real :: kfe_eq_lig_min ! Minimum light-dependent iron ligand stability constant real :: kfe_eq_lig_irr ! Irradiance scaling for iron ligand stability constant real :: kfe_eq_lig_femin ! Low-iron threshold for ligand stability constant real :: kfe_org ! Iron scavenging, 1st order real :: lambda0 ! Total mortality rate constant real :: lambda_14c ! Radiocarbon decay rate real :: mass_2_p ! Organic matter mass to Phosphorus ratio real :: o2_2_p ! Oxygen to Phosphorus ratio real :: o2_min ! Anaerobic respiration threshold real :: P_star ! Pivotal phytoplankton concentration real :: pc_0 ! Maximum carbon-specific growth rate real :: phi_lg ! Fraction of small phytoplankton converted to detritus real :: phi_sm ! Fraction of large phytoplankton converted to detritus real :: po4_min ! Minimum PO4 concentration real :: remin_min ! Minimum remineralization under low O2 real :: thetamax_hi ! Maximum Chl:C ratio when iron-replete real :: thetamax_lo ! Maximum Chl:C ratio when iron-limited real :: wsink_acc ! Sinking rate acceleration with depth real :: wsink0 ! Sinking rate at surface real :: wsink0_z ! Depth to which sinking rate remains constant real :: htotal_scale_lo real :: htotal_scale_hi real :: htotal_in real :: Rho_0 real :: a_0 real :: a_1 real :: a_2 real :: a_3 real :: a_4 real :: a_5 real :: b_0 real :: b_1 real :: b_2 real :: b_3 real :: c_0 real :: a1_co2 real :: a2_co2 real :: a3_co2 real :: a4_co2 real :: a1_o2 real :: a2_o2 real :: a3_o2 real :: a4_o2 ! ! the following arrays are used for calculation diagnostic integrals and fluxes at depth ! real, dimension(:,:,:), _ALLOCATABLE :: wrk_3d _NULL real, dimension(:,:), _ALLOCATABLE :: wrk_2d _NULL integer, dimension(:,:), _ALLOCATABLE :: k_lev _NULL real, dimension(:,:), _ALLOCATABLE :: integral _NULL real, dimension(:,:), _ALLOCATABLE :: flux _NULL ! The prefix nomenclature is as follows: ! "f_t" = a "field", generally a working array for the concentration of tracer t ! "jt_process" = a source/sink term for tracer t due to a biogeochemical process. ! * Note, j terms are in units of mol kg-1 in the code, but are saved to the diagnostic ! file as layer integrals (i.e. multiplied by the layer thickness/density) ! "b_t" = the flux of tracer t out of the ocean bottom ! "p_t" = a pointer, generally to the concentration of a tracer t real, dimension(:,:,:), _ALLOCATABLE :: biomass_p_ts _NULL real, dimension(:,:,:), _ALLOCATABLE :: def_fe _NULL real, dimension(:,:,:), _ALLOCATABLE :: expkT _NULL real, dimension(:,:,:), pointer :: p_biomass_p => NULL() real, dimension(:,:,:), _ALLOCATABLE :: f_chl _NULL real, dimension(:,:,:), _ALLOCATABLE :: f_fed _NULL real, dimension(:,:,:), _ALLOCATABLE :: f_fed_data _NULL real, dimension(:,:,:), pointer :: p_phyto_lg => NULL() real, dimension(:,:,:), pointer :: p_phyto_sm => NULL() real, dimension(:,:,:), pointer :: p_htotal => NULL() real, dimension(:,:,:), pointer :: p_irr_mem => NULL() real, dimension(:,:,:), _ALLOCATABLE :: f_o2 _NULL real, dimension(:,:,:), _ALLOCATABLE :: f_po4 _NULL real, dimension(:,:,:), _ALLOCATABLE :: fe_2_p_uptake _NULL real, dimension(:,:,:), _ALLOCATABLE :: feprime _NULL real, dimension(:,:,:), _ALLOCATABLE :: fpofe _NULL real, dimension(:,:,:), _ALLOCATABLE :: fpop _NULL real, dimension(:,:,:), _ALLOCATABLE :: frac_lg _NULL real, dimension(:,:,:), _ALLOCATABLE :: frac_pop _NULL real, dimension(:,:,:), _ALLOCATABLE :: irr_inst _NULL real, dimension(:,:,:), _ALLOCATABLE :: irr_mix _NULL real, dimension(:,:,:), _ALLOCATABLE :: irrk _NULL real, dimension(:,:,:), _ALLOCATABLE :: jfe_ads_inorg _NULL real, dimension(:,:,:), _ALLOCATABLE :: jfe_ads_org _NULL real, dimension(:,:,:), _ALLOCATABLE :: jfe_recycle _NULL real, dimension(:,:,:), _ALLOCATABLE :: jfe_reminp _NULL real, dimension(:,:,:), _ALLOCATABLE :: jfe_uptake _NULL real, dimension(:,:,:), _ALLOCATABLE :: jo2 _NULL real, dimension(:,:,:), _ALLOCATABLE :: jp_recycle _NULL real, dimension(:,:,:), _ALLOCATABLE :: jp_reminp _NULL real, dimension(:,:,:), _ALLOCATABLE :: jp_uptake _NULL real, dimension(:,:,:), _ALLOCATABLE :: jpo4 _NULL real, dimension(:,:,:), _ALLOCATABLE :: jfeop _NULL real, dimension(:,:,:), _ALLOCATABLE :: jpop _NULL real, dimension(:,:,:), _ALLOCATABLE :: kfe_eq_lig _NULL real, dimension(:,:,:), _ALLOCATABLE :: mu _NULL real, dimension(:,:,:), _ALLOCATABLE :: pc_m _NULL real, dimension(:,:,:), _ALLOCATABLE :: theta _NULL real, dimension(:,:,:), _ALLOCATABLE :: thetamax_fe _NULL real, dimension(:,:,:), _ALLOCATABLE :: wsink _NULL real, dimension(:,:,:), _ALLOCATABLE :: zremin _NULL real, dimension(:,:,:), _ALLOCATABLE :: zbot _NULL real, dimension(:,:), _ALLOCATABLE :: b_fed _NULL real, dimension(:,:), _ALLOCATABLE :: b_o2 _NULL real, dimension(:,:), _ALLOCATABLE :: b_po4 _NULL real, dimension(:,:), _ALLOCATABLE :: fe_burial _NULL real, dimension(:,:), _ALLOCATABLE :: ffe_sed _NULL real, dimension(:,:), _ALLOCATABLE :: o2_saturation _NULL real, dimension(:,:), _ALLOCATABLE :: b_dic _NULL real, dimension(:,:), _ALLOCATABLE :: co2_alpha _NULL real, dimension(:,:), _ALLOCATABLE :: co2_csurf _NULL real, dimension(:,:), _ALLOCATABLE :: htotallo _NULL real, dimension(:,:), _ALLOCATABLE :: htotalhi _NULL real, dimension(:,:), _ALLOCATABLE :: pco2_surf _NULL real, dimension(:,:), _ALLOCATABLE :: surf_temp _NULL real, dimension(:,:), _ALLOCATABLE :: surf_salt _NULL real, dimension(:,:), _ALLOCATABLE :: surf_alk _NULL real, dimension(:,:), _ALLOCATABLE :: surf_po4 _NULL real, dimension(:,:), _ALLOCATABLE :: surf_sio4 _NULL real, dimension(:,:), _ALLOCATABLE :: surf_dic _NULL real, dimension(:,:,:), _ALLOCATABLE :: c14_2_p _NULL real, dimension(:,:,:), _ALLOCATABLE :: fpo14c _NULL real, dimension(:,:,:), _ALLOCATABLE :: j14c_decay_dic _NULL real, dimension(:,:,:), _ALLOCATABLE :: j14c_reminp _NULL real, dimension(:,:,:), _ALLOCATABLE :: jdi14c _NULL real, dimension(:,:), _ALLOCATABLE :: b_di14c _NULL real, dimension(:,:), _ALLOCATABLE :: c14o2_alpha _NULL real, dimension(:,:), _ALLOCATABLE :: c14o2_csurf _NULL real, dimension(:,:,:,:), pointer :: p_fed => NULL() real, dimension(:,:,:), pointer :: p_fed_diag => NULL() real, dimension(:,:,:,:), pointer :: p_o2 => NULL() real, dimension(:,:,:,:), pointer :: p_po4 => NULL() real, dimension(:,:,:,:), pointer :: p_di14c => NULL() real, dimension(:,:,:,:), pointer :: p_dic => NULL() character(len=fm_string_len) :: ice_restart_file character(len=fm_string_len) :: ocean_restart_file character(len=fm_string_len) :: IC_file real :: diag_depth = 100.0 ! Depth over which to integrate and at which to get flux ! for diagnostics character(len=16) :: diag_depth_str = ' ' ! String to hold diag depth integer :: id_b_dic = -1 ! Bottom flux of DIC integer :: id_b_di14c = -1 ! Bottom flux of DI14C integer :: id_b_fed = -1 ! Bottom flux of Fe integer :: id_b_o2 = -1 ! Bottom flux of O2 integer :: id_b_po4 = -1 ! Bottom flux of PO4 integer :: id_biomass_p_ts = -1 ! Instantaneous P concentration in biomass integer :: id_c14_2_p = -1 ! DI14C to PO4 uptake ratio integer :: id_c14o2_csurf = -1 ! Surface water 14CO2* integer :: id_c14o2_alpha = -1 ! Surface water 14CO2* solubility integer :: id_co2_csurf = -1 ! Surface water CO2* integer :: id_co2_alpha = -1 ! Surface water CO2* solubility integer :: id_def_fe = -1 ! Iron deficiency term integer :: id_expkT = -1 ! Temperature dependence integer :: id_fe_2_p_uptake = -1 ! Fed:PO4 of instantaneous uptake integer :: id_feprime = -1 ! Free (unbound) iron concentration integer :: id_fe_burial = -1 ! Flux of iron to sediment as particulate integer :: id_ffe_sed = -1 ! Sediment iron efflux integer :: id_fpofe = -1 ! POFe sinking flux integer :: id_fpo14c = -1 ! PO14C sinking flux integer :: id_fpop = -1 ! POP sinking flux integer :: id_fpop_depth = -1 ! POP sinking flux at depth integer :: id_frac_lg = -1 ! Fraction of production by large phytoplankton integer :: id_frac_pop = -1 ! Fraction of uptake converted to particulate integer :: id_irr_inst = -1 ! Instantaneous irradiance integer :: id_irr_mix = -1 ! Mixed layer irradiance integer :: id_irrk = -1 ! Effective susceptibility to light limitation integer :: id_j14c_decay_dic = -1 ! Radioactive decay of DI14C integer :: id_j14c_reminp = -1 ! 14C particle remineralization layer integral integer :: id_jdi14c = -1 ! DI14C source layer integral integer :: id_jfe_ads_inorg = -1 ! Iron adsorption (2nd order) layer integral integer :: id_jfe_ads_org = -1 ! Iron adsorption to fpop layer integral integer :: id_jfe_recycle = -1 ! Iron fast recycling layer integral integer :: id_jfe_reminp = -1 ! Iron particle remineralization layer integral integer :: id_jfe_uptake = -1 ! Iron uptake layer integral integer :: id_jo2 = -1 ! O2 source layer integral integer :: id_jo2_depth = -1 ! Depth integral of O2 source integer :: id_jp_recycle = -1 ! Phosphorus fast recycling layer integral integer :: id_jp_recycle_depth = -1 ! Depth integral of Phosphorus fast recycling integer :: id_jp_reminp = -1 ! Phosphorus particle remineralization layer integral integer :: id_jp_reminp_depth = -1 ! Depth integral of Phosphorus particle remineralization integer :: id_jp_uptake = -1 ! Phosphorus uptake layer integral integer :: id_jp_uptake_depth = -1 ! Depth integral of Phosphorus uptake integer :: id_jpo4 = -1 ! PO4 source layer integral integer :: id_jpo4_depth = -1 ! Depth integral of PO4 source layer integral integer :: id_jfeop = -1 ! Particulate organic iron source layer integral integer :: id_jpop = -1 ! Particulate organic phosphorus source layer integral integer :: id_kfe_eq_lig = -1 ! Iron-ligand stability constant integer :: id_mu = -1 ! Growth rate after respiratory loss(carbon specific) integer :: id_o2_saturation = -1 ! Surface water O2 saturation integer :: id_pc_m = -1 ! Light-saturated maximum photosynthesis rate (carbon specific) integer :: id_pco2_surf = -1 ! Surface water pCO2 integer :: id_temp_co2calc = -1 ! Surface temp for co2calc integer :: id_salt_co2calc = -1 ! Surface salt for co2calc integer :: id_alk_co2calc = -1 ! Surface temp for co2calc integer :: id_po4_co2calc = -1 ! Surface temp for co2calc integer :: id_sio4_co2calc = -1 ! Surface temp for co2calc integer :: id_dic_co2calc = -1 ! Surface temp for co2calc integer :: id_theta = -1 ! Chl:C ratio integer :: id_thetamax_fe = -1 ! Iron-limited maximum Chl:C ratio integer :: id_wsink = -1 ! Sinking rate integer :: id_zremin = -1 ! Remineralization length scale integer :: id_fed_data = -1 ! Dissolved Iron data integer :: id_di14c_surf = -1 ! Surface dissolved inorganic radiocarbon Prognostic tracer integer :: id_dic_surf = -1 ! Surface dissolved inorganic carbon Prognostic tracer integer :: id_fed_surf = -1 ! Surface dissolved Iron Prognostic tracer integer :: id_o2_surf = -1 ! Surface oxygen Prognostic tracer integer :: id_po4_surf = -1 ! Surface phosphate Prognostic tracer integer :: id_di14c_depth = -1 ! Depth integral of dissolved inorganic radiocarbon Prognostic tracer integer :: id_dic_depth = -1 ! Depth integral of dissolved inorganic carbon Prognostic tracer integer :: id_fed_depth = -1 ! Depth integral of dissolved Iron Prognostic tracer integer :: id_o2_depth = -1 ! Depth integral of oxygen Prognostic tracer integer :: id_po4_depth = -1 ! Depth integral of phosphate Prognostic tracer integer :: id_fed_data_surf = -1 ! Surface dissolved Iron data integer :: id_htotal_surf = -1 ! Surface hydrogen ion Diagnostic tracer integer :: id_chl_surf = -1 ! Surface chlorophyll Diagnostic tracer integer :: id_biomass_p_surf = -1 ! Surface biomass Diagnostic tracer integer :: id_phyto_lg_surf = -1 ! Surface large phytoplankton integer :: id_phyto_sm_surf = -1 ! Surface small phytoplankton integer :: id_irr_mem_surf = -1 ! Surface irradiance Memory Diagnostic tracer integer :: id_fed_data_depth = -1 ! Depth integral of dissolved Iron data integer :: id_chl_depth = -1 ! Depth integral of chlorophyll Diagnostic tracer integer :: id_biomass_p_depth = -1 ! Depth integral of biomass Diagnostic tracer integer :: id_phyto_lg_depth = -1 ! Depth integral of large phytoplankton integer :: id_phyto_sm_depth = -1 ! Depth integral of small phytoplankton integer :: id_irr_mem_depth = -1 ! Depth integral of irradiance Memory Diagnostic tracer logical :: override_surf_temp = .true. ! True if overriding surface properties logical :: override_surf_salt = .true. ! Must be true for first try, and will then logical :: override_surf_alk = .true. ! be set accordingly by data_override logical :: override_surf_po4 = .true. logical :: override_surf_sio4 = .true. logical :: override_surf_dic = .true. end type generic_miniBLING_type !An auxiliary type for storing varible names and descriptions type, public :: vardesc character(len=fm_string_len) :: name ! The variable name in a NetCDF file. character(len=fm_string_len) :: longname ! The long name of that variable. character(len=1) :: hor_grid ! The hor. grid: u, v, h, q, or 1. character(len=1) :: z_grid ! The vert. grid: L, i, or 1. character(len=1) :: t_grid ! The time description: s, a, m, or 1. character(len=fm_string_len) :: units ! The dimensions of the variable. character(len=1) :: mem_size ! The size in memory: d or f. end type vardesc type(generic_miniBLING_type), save :: bling integer, parameter :: num_instances = 1 !type(generic_miniBLING_type), dimension(:), pointer :: bling !integer :: num_instances type(CO2_dope_vector) :: CO2_dope_vec contains !####################################################################### subroutine generic_miniBLING_register(tracer_list) type(g_tracer_type), pointer, intent(inout) :: tracer_list !----------------------------------------------------------------------- ! local parameters !----------------------------------------------------------------------- ! character(len=fm_string_len), parameter :: sub_name = 'generic_miniBLING_register' character(len=256), parameter :: error_header = & '==>Error from ' // trim(mod_name) // '(' // trim(sub_name) // '): ' character(len=256), parameter :: warn_header = & '==>Warning from ' // trim(mod_name) // '(' // trim(sub_name) // '): ' character(len=256), parameter :: note_header = & '==>Note from ' // trim(mod_name) // '(' // trim(sub_name) // '): ' integer :: n integer :: stdout_unit stdout_unit = stdout() !Add here only the parameters that are required at the time of registeration !(to make flux exchanging Ocean tracers known for all PE's) ! call g_tracer_start_param_list(package_name) call g_tracer_add_param('name', bling%name, '_') ! Turn on additional complexity. Most relevant diagnostic variables and all ! tracers are not activated unless the appropriate switch is set to true. call g_tracer_add_param('do_14c', bling%do_14c, .true.) call g_tracer_add_param('do_carbon', bling%do_carbon, .true.) call g_tracer_add_param('ice_restart_file' , bling%ice_restart_file , 'ice_minibling.res.nc') call g_tracer_add_param('ocean_restart_file', bling%ocean_restart_file, 'ocean_minibling.res.nc') call g_tracer_add_param('IC_file' , bling%IC_file , '') call g_tracer_end_param_list(package_name) !----------------------------------------------------------------------- ! Set the suffixes for this instance if (bling%name(1:1) .eq. '_') then bling%suffix = ' ' bling%long_suffix = ' ' else !}{ bling%suffix = '_' // bling%name bling%long_suffix = ' (' // trim(bling%name) // ')' endif !} ! Check for some possible fatal problems in the namelist variables. if ((bling%do_14c) .and. (bling%do_carbon)) then write (stdout_unit,*) trim(note_header), 'Simulating radiocarbon for instance ' // trim(bling%name) else if ((bling%do_14c) .and. .not. (bling%do_carbon)) then call mpp_error(FATAL, trim(error_header) // & ' Do_14c requires do_carbon for instance ' // trim(bling%name)) endif ! Set Restart files call g_tracer_set_files(ice_restart_file = bling%ice_restart_file,& ocean_restart_file = bling%ocean_restart_file ) do n = 1, num_instances !All tracer fields shall be registered for diag output. !===================================================== !Specify all prognostic tracers of this modules. !===================================================== !User adds one call for each prognostic tracer below! !User should specify if fluxes must be extracted from boundary !by passing one or more of the following methods as .true. !and provide the corresponding parameters array !methods: flux_gas,flux_runoff,flux_wetdep,flux_drydep ! !Pass an init_value arg if the tracers should be initialized to a nonzero value everywhere !otherwise they will be initialized to zero. ! !=========================================================== !Prognostic Tracers !=========================================================== ! ! Dissolved Fe ! if (bling%fe_is_prognostic) then call g_tracer_add(tracer_list, package_name, & name = 'fed' // bling%suffix, & longname = 'Dissolved Iron' // bling%long_suffix, & units = 'mol/kg', & prog = .true., & flux_runoff = .false., & flux_wetdep = .true., & flux_drydep = .true., & flux_param = (/ 55.847e-03 /), & flux_bottom = .true. ) elseif (bling%fe_is_diagnostic) then call g_tracer_add(tracer_list, package_name, & name = 'fed' // bling%suffix, & longname = 'Dissolved Iron' // bling%long_suffix, & units = 'mol/kg', & prog = .false.) else call mpp_error(NOTE, trim(note_header) // ' Fe is data overridden for instance ' // trim(bling%name)) endif ! O2 ! call g_tracer_add(tracer_list, package_name, & name = 'o2' // bling%suffix, & longname = 'Oxygen' // bling%long_suffix, & units = 'mol/kg', & prog = .true., & flux_gas = .true., & flux_gas_type = 'air_sea_gas_flux_generic', & flux_gas_name = 'o2_flux' // trim(bling%suffix), & flux_gas_molwt = WTMO2, & flux_gas_param = (/ 9.36e-07, 9.7561e-06 /), & flux_bottom = .true., & flux_gas_restart_file = 'ocean_minibling_airsea_flux.res.nc' ) ! PO4 ! call g_tracer_add(tracer_list, package_name, & name = 'po4' // bling%suffix, & longname = 'Phosphate' // bling%long_suffix, & units = 'mol/kg', & prog = .true., & flux_bottom = .true. ) !=========================================================== !Diagnostic Tracers !=========================================================== ! Chl (Chlorophyll) ! call g_tracer_add(tracer_list, package_name, & name = 'chl' // bling%suffix, & longname = 'Chlorophyll' // bling%long_suffix, & units = 'ug kg-1', & prog = .false., & init_value = 0.08 ) ! Irr_mem (Irradiance Memory) ! call g_tracer_add(tracer_list, package_name, & name = 'irr_mem' // bling%suffix, & longname = 'Irradiance memory' // bling%long_suffix, & units = 'Watts/m^2', & prog = .false.) if (bling%biomass_type .eq. 'single') then ! Biomass ! call g_tracer_add(tracer_list, package_name, & name = 'biomass_p' // bling%suffix, & longname = 'Biomass in P units' // bling%long_suffix, & units = 'mol P kg-1', & prog = .false.) elseif (bling%biomass_type .eq. 'lg_sm_phyto') then ! Large phytoplankton biomass ! call g_tracer_add(tracer_list, package_name, & name = 'phyto_lg' // bling%suffix, & longname = 'Large phytoplankton biomass in P units' // bling%long_suffix, & units = 'mol P kg-1', & prog = .false., & init_value = 4.e-07 ) ! Small phytoplankton biomass ! call g_tracer_add(tracer_list, package_name, & name = 'phyto_sm' // bling%suffix, & longname = 'Small phytoplankton biomass in P units' // bling%long_suffix, & units = 'mol P kg-1', & prog = .false., & init_value = 4.e-07 ) else call mpp_error(FATAL, trim(error_header) // ' Unknown biomass type "' // trim(bling%biomass_type) // '"') endif if (bling%do_carbon) then !<<CARBON CYCLE ! DIC (Dissolved inorganic carbon) ! call g_tracer_add(tracer_list, package_name, & name = 'dic' // bling%suffix, & longname = 'Dissolved Inorganic Carbon' // bling%long_suffix, & units = 'mol/kg', & prog = .true., & flux_gas = .true., & flux_gas_type = 'air_sea_gas_flux_generic', & flux_gas_name = 'co2_flux' // trim(bling%suffix), & flux_gas_molwt = WTMCO2, & flux_gas_param = (/ 9.36e-07, 9.7561e-06 /), & flux_gas_restart_file = 'ocean_minibling_airsea_flux.res.nc', & flux_runoff = .false., & flux_param = (/ 12.011e-03 /), & flux_bottom = .true., & init_value = 0.001) !Diagnostic Tracers: ! Htotal (H+ ion concentration) ! call g_tracer_add(tracer_list, package_name, & name = 'htotal' // bling%suffix, & longname = 'H+ ion concentration' // bling%long_suffix, & units = 'mol/kg', & prog = .false., & init_value = bling%htotal_in) if (bling%do_14c) then !<<RADIOCARBON ! DI14C (Dissolved inorganic radiocarbon) ! call g_tracer_add(tracer_list, package_name, & name = 'di14c' // bling%suffix, & longname = 'Dissolved Inorganic Radiocarbon' // bling%long_suffix, & units = 'mol/kg', & prog = .true., & flux_gas = .true., & flux_gas_type = 'air_sea_gas_flux_generic', & flux_gas_name = 'c14o2_flux' // trim(bling%suffix), & flux_gas_molwt = WTMCO2, & flux_gas_param = (/ 9.36e-07, 9.7561e-06 /), & flux_gas_restart_file = 'ocean_minibling_airsea_flux.res.nc', & flux_param = (/ 14.e-03 /), & flux_bottom = .true., & init_value = 0.001) endif !} !RADIOCARBON>> endif !} !CARBON CYCLE>> enddo !} n end subroutine generic_miniBLING_register !####################################################################### ! <SUBROUTINE NAME="generic_miniBLING_init"> ! <OVERVIEW> ! Initialize the generic miniBLING module ! </OVERVIEW> ! <DESCRIPTION> ! This subroutine: ! Adds all the miniBLING Tracers to the list of generic Tracers passed ! to it via utility subroutine g_tracer_add(). Adds all the parameters ! used by this module via utility subroutine g_tracer_add_param(). ! Allocates all work arrays used in the module. ! </DESCRIPTION> ! <TEMPLATE> ! call generic_miniBLING_init ! </TEMPLATE> ! </SUBROUTINE> subroutine generic_miniBLING_init(tracer_list) type(g_tracer_type), pointer :: tracer_list !----------------------------------------------------------------------- ! local parameters !----------------------------------------------------------------------- ! character(len=64), parameter :: sub_name = 'generic_miniBLING_init' character(len=256) :: caller_str character(len=256) :: error_header character(len=256) :: warn_header character(len=256) :: note_header integer :: n character(len=fm_field_name_len) :: name integer :: nn character(len=fm_field_name_len), pointer, dimension(:) :: names => NULL() integer :: stdout_unit character(len=fm_string_len) :: string integer :: package_index stdout_unit = stdout() ! Set up the field input caller_str = trim(mod_name) // '(' // trim(sub_name) // ')[]' error_header = '==>Error from ' // trim(caller_str) // ':' warn_header = '==>Warning from ' // trim(caller_str) // ':' note_header = '==>Note from ' // trim(caller_str) // ':' write (stdout_unit,*) write (stdout_unit,*) trim(note_header), ' Processing generic tracer package miniBLING' do n = 1, num_instances !Specify all parameters used in this modules. !============================================================== !User adds one call for each parameter below! !User also adds the definition of each parameter in generic_miniBLING_params type !============================================================== !Add the known experimental parameters used for calculations in this module. !All the g_tracer_add_param calls must happen between !g_tracer_start_param_list and g_tracer_end_param_list calls. !This implementation enables runtime overwrite via field_table. call g_tracer_start_param_list(package_name) ! Rho_0 is used in the Boussinesq ! approximation to calculations of pressure and ! pressure gradients, in units of kg m-3. call g_tracer_add_param('RHO_0', bling%Rho_0, 1035.0) !----------------------------------------------------------------------- ! Gas exchange !----------------------------------------------------------------------- ! coefficients for O2 saturation !----------------------------------------------------------------------- call g_tracer_add_param('a_0', bling%a_0, 2.00907) call g_tracer_add_param('a_1', bling%a_1, 3.22014) call g_tracer_add_param('a_2', bling%a_2, 4.05010) call g_tracer_add_param('a_3', bling%a_3, 4.94457) call g_tracer_add_param('a_4', bling%a_4, -2.56847e-01) call g_tracer_add_param('a_5', bling%a_5, 3.88767) call g_tracer_add_param('b_0', bling%b_0, -6.24523e-03) call g_tracer_add_param('b_1', bling%b_1, -7.37614e-03) call g_tracer_add_param('b_2', bling%b_2, -1.03410e-02 ) call g_tracer_add_param('b_3', bling%b_3, -8.17083e-03) call g_tracer_add_param('c_0', bling%c_0, -4.88682e-07) !----------------------------------------------------------------------- ! Schmidt number coefficients !----------------------------------------------------------------------- ! Compute the Schmidt number of CO2 in seawater using the ! formulation presented by Wanninkhof (1992, J. Geophys. Res., 97, ! 7373-7382). !----------------------------------------------------------------------- !New Wanninkhof numbers call g_tracer_add_param('a1_co2', bling%a1_co2, 2068.9) call g_tracer_add_param('a2_co2', bling%a2_co2, -118.63) call g_tracer_add_param('a3_co2', bling%a3_co2, 2.9311) call g_tracer_add_param('a4_co2', bling%a4_co2, -0.027) !--------------------------------------------------------------------- ! Compute the Schmidt number of O2 in seawater using the ! formulation proposed by Keeling et al. (1998, Global Biogeochem. ! Cycles, 12, 141-163). !--------------------------------------------------------------------- !New Wanninkhof numbers call g_tracer_add_param('a1_o2', bling%a1_o2, 1929.7) call g_tracer_add_param('a2_o2', bling%a2_o2, -117.46) call g_tracer_add_param('a3_o2', bling%a3_o2, 3.116) call g_tracer_add_param('a4_o2', bling%a4_o2, -0.0306) call g_tracer_add_param('htotal_scale_lo', bling%htotal_scale_lo, 0.01) call g_tracer_add_param('htotal_scale_hi', bling%htotal_scale_hi, 100.0) !----------------------------------------------------------------------- ! Uptake !----------------------------------------------------------------------- ! ! Phytoplankton growth altered from Geider et al (1997) ! and Moore et al (2002). ! The factor of 6.022e17 is to convert ! from umol to quanta and 2.77e18 to convert from quanta/sec ! to Watts given the average energy spectrum for underwater ! PAR from the Seabird sensor. ! call g_tracer_add_param('alk_scheme', bling%alk_scheme, 'normal') call g_tracer_add_param('alk_slope', bling%alk_slope, 32.0e-06) call g_tracer_add_param('alk_intercept', bling%alk_intercept, 1200.0e-06) call g_tracer_add_param('biomass_type', bling%biomass_type, 'single') call g_tracer_add_param('alpha_photo', bling%alpha_photo, 1.e-5 * 2.77e+18 / 6.022e+17) ! g C g Chl-1 m2 W-1 s-1 call g_tracer_add_param('kappa_eppley', bling%kappa_eppley, 0.063) ! deg C-1 call g_tracer_add_param('pc_0', bling%pc_0, 1.0e-5) ! s-1 call g_tracer_add_param('thetamax_hi', bling%thetamax_hi, 0.040) ! g Chl g C-1 call g_tracer_add_param('thetamax_lo', bling%thetamax_lo, 0.010) ! g Chl g C-1 ! ! Chl:C response rate constant for phytoplankton calibrated to 1 d-1 ! after Owens et al (1980, Diel Periodicity in cellular Chlorophyll ! content of marine diatoms, Mar. Biol, 59, 71-77). ! call g_tracer_add_param('gamma_irr_mem', bling%gamma_irr_mem, 1.0 / sperd) ! s-1 ! Introduce a minimum chlorophyll concentration for numerical stability. ! Value is an order of magnitude less than the minimum produced in topaz. ! call g_tracer_add_param('chl_min', bling%chl_min, 1.e-5) ! ug kg-1 ! ! The biomass reponds to changes in growth rate with an arbitrary 2 day lag. ! call g_tracer_add_param('gamma_biomass', bling%gamma_biomass, 0.5 / sperd) ! s-1 !----------------------------------------------------------------------- ! Monod half saturation coefficient for phosphate. Value of Aumont (JGR, 2002) ! used for large phytoplankton. call g_tracer_add_param('k_po4', bling%k_po4, 1.0e-7) ! mol PO4 kg-1 call g_tracer_add_param('po4_min', bling%po4_min, 1.0e-8) ! mol PO4 kg-1 !----------------------------------------------------------------------- ! Fe uptake and limitation. ! The uptake ratio of Fe:P is determined from a Monod constant and a ! scaling factor. ! The k_Fe_uptake is high, to provide luxury uptake of iron as a ! relatively linear function of iron concentrations under open-ocean ! conditions, consistent with the results of Sunda and Huntsman (Fig 1, ! Nature, 1997). call g_tracer_add_param('k_fe_uptake', bling%k_fe_uptake, 0.8e-9) ! mol Fe kg-1 ! This Monod term, which is nearly linear with [Fe], is multiplied by a ! scaling term to provide the actual Fe:P uptake ratio such that, at ! [Fe] = k_fe_uptake, Fe:P = fe_2_p_max / 2. ! This maximum value was set in accordance with the range of ! open-ocean Fe:C ratios summarized by Boyd et al. (Science, 2007) and ! converted to a Fe:P ratio. ! As a tuning parameter, it affects the amount of Fe that cycles via the ! organic matter pathway, and its ratio to k_fe_2_p determines the ! degree of iron limitation (the larger this ratio, the less iron ! limitation there will be). call g_tracer_add_param('fe_2_p_max', bling%fe_2_p_max, 28.e-6 * 106.) ! mol Fed mol PO4-1 ! ! New paramter to help with non-prognostic iron ! call g_tracer_add_param('def_fe_min', bling%def_fe_min, 0.0) ! ? ! ! If fe_is_prognostic is true, then Fed will be a prognostic variable, otherwise ! if fe_is_diagnostic is true, then it will be diagnostic, restoring to a 3-d field with ! a time-scale of fe_restoring (in days), otherwise fed will be data driven ! with any coastal increase. ! call g_tracer_add_param('fe_is_prognostic', bling%fe_is_prognostic, .false.) call g_tracer_add_param('fe_is_diagnostic', bling%fe_is_diagnostic, .false.) call g_tracer_add_param('fe_restoring', bling%fe_restoring, 10.0) ! days call g_tracer_add_param('fe_coastal', bling%fe_coastal, 2.0e-09) ! mol/kg call g_tracer_add_param('fe_coastal_depth', bling%fe_coastal_depth, 200.0) ! m ! The k_fe_2_p is the Fe:P at which the iron-limitation term has a ! value of 0.5, chosen according to Sunda and Huntsman (Fig. 2, ! Nature, 1997). Converted from Fe:C ratio. call g_tracer_add_param('k_fe_2_p', bling%k_fe_2_p, 7.e-6 * 106.) ! mol Fe mol P-1 !----------------------------------------------------------------------- ! Mortality & Remineralization !----------------------------------------------------------------------- ! ! T=0 phytoplankton specific total-mortality rate from the global ! synthesis of Dunne et al. (2005) ! call g_tracer_add_param('lambda0', bling%lambda0, 0.19 / sperd) ! s-1 ! ! Pivot phytoplankton concentration for grazing-based ! variation in ecosystem structure from the global ! synthesis of Dunne et al. (2005). Converted from mol C m-3. ! call g_tracer_add_param('P_star', bling%P_star, 1.9e-3 / 1028. / 106.0) ! mol P kg-1 ! ! Temperature-dependence of fractional detritus production ! from the global synthesis of Dunne et al. (2005) ! call g_tracer_add_param('kappa_remin', bling%kappa_remin, -0.032) ! deg C-1 ! Phytoplankton fractional detritus production by size class, ! from the global synthesis of Dunne et al. (2005) call g_tracer_add_param('phi_lg', bling%phi_lg, 1.0) ! unitless call g_tracer_add_param('phi_sm', bling%phi_sm, 0.18) ! unitless ! Half saturation constant for fast recycling of P, very low to act only in nutrient-poor waters call g_tracer_add_param('k_po4_recycle', bling%k_po4_recycle, 2.0e-8) ! mol PO4 kg-1 !----------------------------------------------------------------------- ! Remineralization !----------------------------------------------------------------------- ! ! Stoichiometric ratios taken from Anderson (1995) as discussed in ! Sarmiento and Gruber (2008), and Sarmiento et al. (2002) for Ca:P. ! call g_tracer_add_param('c_2_p', bling%c_2_p, 106.0 ) ! mol C mol P-1 call g_tracer_add_param('o2_2_p', bling%o2_2_p, 150.0 ) ! mol O2 mol P-1 ! Convert from mol P m-3 to mg C l-1 call g_tracer_add_param('mass_2_p', bling%mass_2_p, 106. * 12.001 ) ! g C mol P-1 ! Radiocarbon call g_tracer_add_param('half_life_14c', bling%half_life_14c, 5730.0 ) ! a ! !----------------------------------------------------------------------- ! Remineralization length scales ! ! Values of parameters to approximate upper e-folding of the globally-tuned ! "Martin curve" used in the OCMIP-II Biotic configuration of (z/75)^-0.9 ! that gives a value of exp(-1) at 228 m from 75 m for an e-folding scale ! of 188 m. ! Here these are given as a linear function of depth, ! wsink = wsink0 + wsink_acc * (z - wsink0_z) call g_tracer_add_param('wsink_acc', bling%wsink_acc, 0.05 / sperd) ! s-1 call g_tracer_add_param('wsink0', bling%wsink0, 16.0 / sperd) ! m s-1 call g_tracer_add_param('wsink0_z', bling%wsink0_z, 80. ) ! m call g_tracer_add_param('gamma_pop', bling%gamma_pop, 0.12 / sperd ) ! s-1 ! Half saturation oxygen concentration for oxic remineralization rate. ! call g_tracer_add_param('k_o2', bling%k_o2, 20.0e-6) ! mol O2 kg-1 ! ! Remineralization rate under suboxic/anoxic conditions, as a fraction of the rate under ! fully oxidized conditions. As this code is currently intended for short, high-resolution runs, ! this value is set to zero to cause a cessation of remineralization under suboxia/anoxia. ! This will allow P to sink past the OMZ, which lead lead to a downward expansion of the OMZ, ! but it hopefully won't be a huge problem on the timescale of 100-200 years. ! call g_tracer_add_param('remin_min', bling%remin_min, 0.0) ! dimensionless ! ! Minimum oxygen concentration for oxic remineralization. ! At O2 less than this, anaerobic remineralization occurs at remin_min rate. ! call g_tracer_add_param('o2_min', bling%o2_min, 1.0e-06) ! mol O2 kg-1 ! ! Prevent oxygen from becoming negative. Setting to false allows negative ! oxygen in anoxic zones, which can be thought of as equivalent to ! denitrification plus H2S production. ! call g_tracer_add_param('prevent_neg_o2', bling%prevent_neg_o2, .true. ) !----------------------------------------------------------------------- ! Iron Cycling ! ! Global uniform iron ligand concentration. ! Taken from Parekh, P., M. J. Follows and E. A. Boyle (2005) Decoupling of iron ! and phosphate in the global ocean. Glob. Biogeochem. Cycles, 19, ! doi: 10.1029/2004GB002280. ! call g_tracer_add_param('felig_bkg', bling%felig_bkg, 1.0e-9) ! mol ligand kg-1 ! ! Ratio of iron efflux from bottom sediment boundaries to the sedimenting phosphorus flux. ! From Elrod et al. (2004), 0.68 mmol Fe mol C-1, after Moore et al (2008): ! call g_tracer_add_param('fe_2_p_sed', bling%fe_2_p_sed, 1.e-4 * 106.0 ) ! mol Fe mol P-1 ! ! 1.5-order iron scavenging in order to prevent high iron ! accumulations in high deposition regions (like the tropical ! Atlantic). This also helps prevent Fe accumulating in oligotrophic gyres and in ! the abyssal ocean, where organic fluxes are low. ! call g_tracer_add_param('kfe_inorg', bling%kfe_inorg, 1.e3/sperd) ! mol.5 Fe-.5 kg s-1 ! ! Equilibrium constant for (free and inorganically bound) iron binding with organic ! ligands taken from range similar to Parekh, P., M. J. Follows and E. A. Boyle ! (2005) Decoupling of iron and phosphate in the global ocean. Glob. Biogeochem. ! Cycles, 19, doi: 10.1029/2004GB002280. ! call g_tracer_add_param('kfe_eq_lig_max', bling%kfe_eq_lig_max, 8.e10) ! mol lig-1 kg ! ! Minimum ligand strength under high light, to represent photodissociation of ! ligand-Fe complexes. ! call g_tracer_add_param('kfe_eq_lig_min', bling%kfe_eq_lig_min, 0.8e10) ! mol lig-1 kg ! ! Photodecay irradiance scaling. ! call g_tracer_add_param('kfe_eq_lig_irr', bling%kfe_eq_lig_irr, 0.1) ! W m-2 ! ! Iron concentration near which photodecay is compensated by enhanced siderophore ! production. ! call g_tracer_add_param('kfe_eq_lig_femin', bling%kfe_eq_lig_femin, 0.05e-9) ! W m-2 ! ! Adsorption rate coefficient for detrital organic material. ! call g_tracer_add_param('kfe_org', bling%kfe_org, 0.5/sperd) ! g org-1 m3 s-1 ! ! Mimimum fraction of POP (for turning off recycling set to 1.0) ! call g_tracer_add_param('min_frac_pop', bling%min_frac_pop, 0.0) ! ! Depth for integral and flux diagnostics ! !----------------------------------------------------------------------- ! Miscellaneous !----------------------------------------------------------------------- ! call g_tracer_add_param('diag_depth', bling%diag_depth, 100.0) ! use nearest integer ! call g_tracer_end_param_list(package_name) ! ! Check the diag depth and set a string for that depth ! if (bling%diag_depth .gt. 0.0) then bling%diag_depth = nint(bling%diag_depth) write (bling%diag_depth_str, '(f10.0)') bling%diag_depth bling%diag_depth_str = adjustl(bling%diag_depth_str) bling%diag_depth_str = bling%diag_depth_str(1:len_trim(bling%diag_depth_str)-1) ! remove trailing decimal point else call mpp_error(FATAL, trim(error_header) // ' diag_depth <= 0 for instance ' // trim(bling%name)) endif enddo !} n ! Allocate all the private work arrays used by this module. call user_allocate_arrays end subroutine generic_miniBLING_init !####################################################################### ! Register diagnostic fields to be used in this module. ! Note that the tracer fields are automatically registered in user_add_tracers ! User adds only diagnostics for fields that are not a member of g_tracer_type ! subroutine generic_miniBLING_register_diag real, parameter :: missing_value1 = -1.0e+10 type(vardesc) :: vardesc_temp integer :: isc integer :: iec integer :: jsc integer :: jec integer :: isd integer :: ied integer :: jsd integer :: jed integer :: nk integer :: ntau integer :: n integer :: axes(3) type(time_type) :: init_time call g_tracer_get_common(isc, iec, jsc, jec, isd, ied, jsd, jed, nk, ntau, axes = axes, init_time = init_time) ! The following vardesc types contain a package of metadata about each tracer, ! including, in order, the following elements: name; longname; horizontal ! staggering ('h') for collocation with thickness points ; vertical staggering ! ('L') for a layer variable ; temporal staggering ('s' for snapshot) ; units ; ! and precision in non-restart output files ('f' for 32-bit float or 'd' for ! 64-bit doubles). For most tracers, only the name, longname and units should ! be changed. ! ! Register Diagnostics !=========================================================== ! ! Core diagnostics do n = 1, num_instances if (bling%fe_is_prognostic) then vardesc_temp = vardesc& ("b_fed","Bottom flux of Fe into sediment",'h','1','s','mol m-2 s-1','f') bling%id_b_fed = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif vardesc_temp = vardesc& ("b_o2","Bottom flux of O2 into sediment",'h','1','s','mol m-2 s-1','f') bling%id_b_o2 = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("b_po4","Bottom flux of PO4 into sediment",'h','1','s','mol m-2 s-1','f') bling%id_b_po4 = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) if (bling%biomass_type .eq. 'single') then vardesc_temp = vardesc& ("biomass_p_ts","Instantaneous P concentration in biomass",'h','L','s','mol kg-1','f') bling%id_biomass_p_ts = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif vardesc_temp = vardesc& ("def_Fe","Iron deficiency term",'h','L','s','unitless','f') bling%id_def_fe = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("expkT","Temperature dependence",'h','L','s','unitless','f') bling%id_expkT = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("fe_2_p_uptake","Uptake ratio of Fed:PO4",'h','L','s','mol Fe mol P-1','f') bling%id_fe_2_p_uptake = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) if (bling%fe_is_prognostic) then vardesc_temp = vardesc& ("fe_burial","Sedimenting iron flux",'h','1','s','mol m-2 s-1','f') bling%id_fe_burial = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("feprime","Concentration of free, unbound iron",'h','L','s','mol kg-1','f') bling%id_feprime = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("ffe_sed","Sediment iron efflux",'h','1','s','mol m-2 s-1','f') bling%id_ffe_sed = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("fpofe","POFe sinking flux at layer bottom",'h','L','s','mol m-2 s-1','f') bling%id_fpofe = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif vardesc_temp = vardesc& ("fpop_" // trim(bling%diag_depth_str),"POP sinking flux at " // trim(bling%diag_depth_str) // " m", & 'h','L','s','mol m-2 s-1','f') bling%id_fpop_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("fpop","POP sinking flux at layer bottom",'h','L','s','mol m-2 s-1','f') bling%id_fpop = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("frac_lg","Fraction of production by large phytoplankton",'h','L','s','unitless','f') bling%id_frac_lg = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("frac_pop","Particulate fraction of total uptake",'h','L','s','unitless','f') bling%id_frac_pop = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("irr_inst","Instantaneous light",'h','L','s','W m-2','f') bling%id_irr_inst = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("irr_mix","Mixed layer light",'h','L','s','W m-2','f') bling%id_irr_mix = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("irrk","Tendency to light limitation",'h','L','s','W m-2','f') bling%id_irrk = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) if (bling%fe_is_prognostic) then vardesc_temp = vardesc& ("jfe_ads_inorg","Iron adsorption (2nd order) layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jfe_ads_inorg = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jfe_ads_org","Iron adsorption to FPOP layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jfe_ads_org = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jfe_recycle","Fast recycling of iron layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jfe_recycle = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif if (bling%fe_is_prognostic .or. bling%fe_is_diagnostic) then vardesc_temp = vardesc& ("jfe_reminp","Sinking particulate Fe decay layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jfe_reminp = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif vardesc_temp = vardesc& ("jfe_uptake","Iron production layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jfe_uptake = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jo2_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral of o2 source", & 'h','L','s','mol m-2 s-1','f') bling%id_jo2_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jo2","O2 source layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jo2 = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jp_recycle_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral of fast recycling of PO4", & 'h','L','s','mol m-2 s-1','f') bling%id_jp_recycle_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jp_recycle","Fast recycling of PO4 layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jp_recycle = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jp_reminp_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral of sinking particulate P decay", & 'h','L','s','mol m-2 s-1','f') bling%id_jp_reminp_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jp_reminp","Sinking particulate P decay layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jp_reminp = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jp_uptake_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral of pO4 uptake", & 'h','L','s','mol m-2 s-1','f') bling%id_jp_uptake_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jp_uptake","PO4 uptake layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jp_uptake = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jpo4_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral of PO4 source", & 'h','L','s','mol m-2 s-1','f') bling%id_jpo4_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jpo4","PO4 source layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jpo4 = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jpop","Particulate P source layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jpop = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) if (bling%fe_is_prognostic) then vardesc_temp = vardesc& ("jfeop","Particulate Fe source layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jfeop = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("kfe_eq_lig","Iron ligand stability constant",'h','L','s','mol-1 kg','f') bling%id_kfe_eq_lig = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif vardesc_temp = vardesc& ("mu","Net growth rate after respiratory loss",'h','L','s','s-1','f') bling%id_mu = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("o2_saturation","Saturation O2 concentration",'h','1','s','mol kg-1','f') bling%id_o2_saturation = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("pc_m","Light-saturated photosynthesis rate (carbon specific)",'h','L','s','s-1','f') bling%id_pc_m = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("theta","Chl:C ratio",'h','L','s','g Chl g C-1','f') bling%id_theta = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("thetamax_fe","Fe-limited max Chl:C",'h','L','s','g Chl g C-1','f') bling%id_thetamax_fe = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("wsink","Sinking rate",'h','L','s','m s-1','f') bling%id_wsink = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("zremin","Remineralization lengthscale",'h','L','s','m','f') bling%id_zremin = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("o2_surf","Surface O2 concentration",'h','1','s','mol kg-1','f') bling%id_o2_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("o2_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral O2", & 'h','1','s','mol m-2','f') bling%id_o2_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("fed_surf","Surface Fed concentration",'h','1','s','mol kg-1','f') bling%id_fed_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("fed_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral Fed", & 'h','1','s','mol m-2','f') bling%id_fed_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) if (.not. bling%fe_is_prognostic) then vardesc_temp = vardesc& ("fed_data_surf","Surface Fed data concentration",'h','1','s','mol kg-1','f') bling%id_fed_data_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("fed_data_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral Fedconcentration", & 'h','1','s','mol m-2','f') bling%id_fed_data_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif vardesc_temp = vardesc& ("po4_surf","Surface PO4 concentration",'h','1','s','mol kg-1','f') bling%id_po4_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("po4_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral PO4", & 'h','1','s','mol m-2','f') bling%id_po4_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("htotal_surf","Surface H+ concentration",'h','1','s','mol kg-1','f') bling%id_htotal_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) if (bling%biomass_type .eq. 'single') then vardesc_temp = vardesc& ("biomass_p_surf","Surface Biomass-P concentration",'h','1','s','mol kg-1','f') bling%id_biomass_p_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("biomass_p_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral BiomasP concentration", & 'h','1','s','mol m-2','f') bling%id_biomass_p_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) elseif (bling%biomass_type .eq. 'lg_sm_phyto') then vardesc_temp = vardesc& ("phyto_lg_surf","Surface large phytoplankton concentration",'h','1','s','mol kg-1','f') bling%id_phyto_lg_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("phyto_lg_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral largeconcentration", & 'h','1','s','mol m-2','f') bling%id_phyto_lg_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("phyto_sm_surf","Surface small phytoplankton concentration",'h','1','s','mol kg-1','f') bling%id_phyto_sm_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("phyto_sm_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral smallconcentration", & 'h','1','s','mol m-2','f') bling%id_phyto_sm_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif vardesc_temp = vardesc& ("chl_surf","Surface Chl concentration",'h','1','s','mol kg-1','f') bling%id_chl_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("chl_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral Chl", & 'h','1','s','mol m-2','f') bling%id_chl_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("irr_mem_surf","Surface IRR_mem concentration",'h','1','s','mol kg-1','f') bling%id_irr_mem_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("irr_mem_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral IRR_mem", & 'h','1','s','mol m-2','f') bling%id_irr_mem_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) if (.not. bling%fe_is_prognostic) then vardesc_temp = vardesc& ("fed_data","Fed data concentration",'h','1','s','mol kg-1','f') bling%id_fed_data = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif if (bling%do_carbon) then !<<CARBON CYCLE vardesc_temp = vardesc& ("dic_surf","Surface DIC concentration",'h','1','s','mol kg-1','f') bling%id_dic_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("dic_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral DIC", & 'h','1','s','mol m-2','f') bling%id_dic_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("b_dic","Bottom flux of DIC into sediment",'h','1','s','mol m-2 s-1','f') bling%id_b_dic = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("co2_alpha","Saturation surface CO2* per uatm",'h','1','s','mol kg-1 atm-1','f') bling%id_co2_alpha = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("co2_csurf","CO2* concentration at surface",'h','1','s','mol kg-1','f') bling%id_co2_csurf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("pco2_surf","Seawater pCO2 in surface layer",'h','1','s','uatm','f') bling%id_pco2_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("temp_co2calc","Surface temperature used for co2calc",'h','1','s','deg C','f') bling%id_temp_co2calc = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("salt_co2calc","Surface salinity used for co2calc",'h','1','s','PSU','f') bling%id_salt_co2calc = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("alk_co2calc","Surface alkalinity used for co2calc",'h','1','s','eq kg-1','f') bling%id_alk_co2calc = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("po4_co2calc","Surface phosphate used for co2calc",'h','1','s','mol kg -1','f') bling%id_po4_co2calc = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("sio4_co2calc","Surface silicate used for co2calc",'h','1','s','mol kg -1','f') bling%id_sio4_co2calc = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("dic_co2calc","Surface DIC used for co2calc",'h','1','s','mol kg -1','f') bling%id_dic_co2calc = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) if (bling%do_14c) then !<<RADIOCARBON vardesc_temp = vardesc& ("di14c_surf","Surface DI14C concentration",'h','1','s','mol kg-1','f') bling%id_di14c_surf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("di14c_" // trim(bling%diag_depth_str),trim(bling%diag_depth_str) // " m integral DI14C", & 'h','1','s','mol m-2','f') bling%id_di14c_depth = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("b_di14c","Bottom flux of DI14C into sediment",'h','1','s','mol m-2 s-1','f') bling%id_b_di14c = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("c14_2_p","Ratio of DI14C to PO4",'h','L','s','mol kg-1','f') bling%id_c14_2_p = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("c14o2_alpha","Saturation surface 14CO2* per uatm",'h','1','s','mol kg-1 atm-1','f') bling%id_c14o2_alpha = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("c14o2_csurf","14CO2* concentration at surface",'h','1','s','mol kg-1','f') bling%id_c14o2_csurf = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:2), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("fpo14c","PO14C sinking flux at layer bottom",'h','L','s','mol m-2 s-1','f') bling%id_fpo14c = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("j14c_decay_dic","DI14C radioactive decay layer integral",'h','L','s','mol m-2 s-1','f') bling%id_j14c_decay_dic = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("j14c_reminp","Sinking PO14C remineralization layer integral",'h','L','s','mol m-2 s-1','f') bling%id_j14c_reminp = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) vardesc_temp = vardesc& ("jdi14c","DI14C source layer integral",'h','L','s','mol m-2 s-1','f') bling%id_jdi14c = register_diag_field(package_name, trim(vardesc_temp%name) // bling%suffix, & axes(1:3), init_time, trim(vardesc_temp%longname) // bling%long_suffix, & vardesc_temp%units, missing_value = missing_value1) endif !} !RADIOCARBON>> endif !} !CARBON CYCLE>> enddo !} n end subroutine generic_miniBLING_register_diag !####################################################################### ! <SUBROUTINE NAME="generic_miniBLING_update_from_coupler"> ! <OVERVIEW> ! Modify the values obtained from the coupler if necessary. ! </OVERVIEW> ! <DESCRIPTION> ! Some tracer fields could be modified after values are obtained from the ! coupler. This subroutine is the place for specific tracer manipulations. ! miniBLING currently does not use this. ! </DESCRIPTION> ! <TEMPLATE> ! call generic_miniBLING_update_from_coupler(tracer_list) ! </TEMPLATE> ! <IN NAME="tracer_list" TYPE="type(g_tracer_type), pointer"> ! Pointer to the head of generic tracer list. ! </IN> ! </SUBROUTINE> subroutine generic_miniBLING_update_from_coupler(tracer_list) type(g_tracer_type), pointer, intent(inout) :: tracer_list character(len=fm_string_len), parameter :: sub_name = 'generic_miniBLING_update_from_coupler' end subroutine generic_miniBLING_update_from_coupler !####################################################################### ! <SUBROUTINE NAME="generic_miniBLING_update_from_bottom"> ! <OVERVIEW> ! Set values of bottom fluxes and reservoirs ! </OVERVIEW> ! <DESCRIPTION> ! Some tracers could have bottom fluxes and reservoirs. ! This subroutine is the place for specific tracer manipulations. ! miniBLING currently does not use this. ! </DESCRIPTION> ! <TEMPLATE> ! call generic_miniBLING_update_from_bottom(tracer_list,dt, tau) ! </TEMPLATE> ! <IN NAME="tracer_list" TYPE="type(g_tracer_type), pointer"> ! Pointer to the head of generic tracer list. ! </IN> ! <IN NAME="dt" TYPE="real"> ! Time step increment ! </IN> ! <IN NAME="tau" TYPE="integer"> ! Time step index to be used for %field ! </IN> ! </SUBROUTINE> subroutine generic_miniBLING_update_from_bottom(tracer_list, dt, tau) type(g_tracer_type), pointer, intent(inout) :: tracer_list real, intent(in) :: dt integer, intent(in) :: tau end subroutine generic_miniBLING_update_from_bottom !####################################################################### ! <SUBROUTINE NAME="generic_miniBLING_diag"> ! <OVERVIEW> ! Do things which must be done after tronsports and sources have been applied ! </OVERVIEW> ! <DESCRIPTION> ! This subroutine saves out surface diagnostic firlds for prognostic tracers ! after vertical transport has been calculated ! </DESCRIPTION> ! <TEMPLATE> ! call generic_miniBLING_diag(tracer_list,tau,model_time) ! </TEMPLATE> ! <IN NAME="tracer_list" TYPE="type(g_tracer_type), pointer"> ! Pointer to the head of generic tracer list. ! </IN> ! <IN NAME="tau" TYPE="integer"> ! Time step index of %field ! </IN> ! <IN NAME="model_time" TYPE="time_type"> ! Model time ! </IN> ! </SUBROUTINE> subroutine generic_miniBLING_diag(tracer_list, ilb, jlb, tau, model_time, dzt, rho_dzt, caller) type(g_tracer_type), pointer, intent(inout) :: tracer_list integer, intent(in) :: ilb integer, intent(in) :: jlb integer, intent(in) :: tau type(time_type), intent(in) :: model_time real, dimension(ilb:,jlb:,:), intent(in) :: dzt real, dimension(ilb:,jlb:,:), intent(in) :: rho_dzt character(len=*), intent(in), optional :: caller !----------------------------------------------------------------------- ! local parameters character(len=fm_string_len), parameter :: sub_name = 'generic_miniBLING_diag' character(len=256) :: caller_str character(len=256) :: error_header character(len=256) :: warn_header character(len=256) :: note_header integer :: isc integer :: iec integer :: jsc integer :: jec integer :: isd integer :: ied integer :: jsd integer :: jed integer :: nk integer :: ntau integer :: i integer :: j integer :: k integer :: n real, dimension(:,:,:), pointer :: grid_tmask logical :: used integer :: k_int logical :: diag_initialized ! Set up the headers for stdout messages. if (present(caller)) then caller_str = trim(mod_name) // '(' // trim(sub_name) // ')[' // trim(caller) // ']' else caller_str = trim(mod_name) // '(' // trim(sub_name) // ')[]' endif error_header = '==> Error from ' // trim(caller_str) // ':' warn_header = '==> Warning from ' // trim(caller_str) // ':' note_header = '==> Note from ' // trim(caller_str) // ':' ! Set up the module if not already done call g_tracer_get_common(isc, iec, jsc, jec, isd, ied, jsd, jed, nk, ntau, & grid_tmask = grid_tmask) ! !----------------------------------------------------------------------- ! Save depth integrals and fluxes !----------------------------------------------------------------------- ! k_int = 0 diag_initialized = .false. do n = 1, num_instances if (bling%id_po4_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_po4(:,:,:,tau), dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_po4_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_o2_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_o2(:,:,:,tau), dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_o2_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_dic_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_dic(:,:,:,tau), dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_dic_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_di14c_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_di14c(:,:,:,tau), dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_di14c_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%fe_is_prognostic) then if (bling%id_fed_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_fed(:,:,:,tau), dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_fed_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} elseif (bling%fe_is_diagnostic) then if (bling%id_fed_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_fed_diag, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_fed_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} else if (bling%id_fed_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%f_fed, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_fed_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} endif if (.not. bling%fe_is_prognostic) then if (bling%id_fed_data_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%f_fed_data, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_fed_data_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} endif !} if (bling%id_chl_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%f_chl, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_chl_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_biomass_p_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_biomass_p, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_biomass_p_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_phyto_lg_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_phyto_lg, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_phyto_lg_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_phyto_sm_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_phyto_sm, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_phyto_sm_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_irr_mem_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%p_irr_mem, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_irr_mem_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_jp_uptake_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%jp_uptake, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_jp_uptake_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_jp_recycle_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%jp_recycle, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_jp_recycle_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_jp_reminp_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%jp_reminp, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_jp_reminp_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_jpo4_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%jpo4, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_jpo4_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_jo2_depth .gt. 0) then call g_tracer_column_int(bling%diag_depth, isd, jsd, bling%jo2, dzt, rho_dzt, & bling%wrk_3d, k_int, bling%integral) used = send_data(bling%id_jo2_depth, bling%integral, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} if (bling%id_fpop_depth .gt. 0) then call g_tracer_flux_at_depth(bling%diag_depth, isd, jsd, bling%fpop, dzt, & bling%k_lev, bling%wrk_2d, diag_initialized, bling%flux) used = send_data(bling%id_fpop_depth, bling%flux, & model_time, rmask = grid_tmask(:,:,1), is_in=isc, js_in=jsc, ie_in=iec, je_in=jec) endif !} enddo ! !----------------------------------------------------------------------- ! Save surface prognostic variables for diagnostics, after vertical diffusion !----------------------------------------------------------------------- ! do n = 1, num_instances if (bling%id_po4_surf .gt. 0) & used = send_data(bling%id_po4_surf, bling%p_po4(:,:,1,tau), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_o2_surf .gt. 0) & used = send_data(bling%id_o2_surf, bling%p_o2(:,:,1,tau), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_dic_surf .gt. 0) & used = send_data(bling%id_dic_surf, bling%p_dic(:,:,1,tau), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_di14c_surf .gt. 0) & used = send_data(bling%id_di14c_surf, bling%p_di14c(:,:,1,tau), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%fe_is_prognostic) then if (bling%id_fed_surf .gt. 0) & used = send_data(bling%id_fed_surf, bling%p_fed(:,:,1,tau), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) elseif (bling%fe_is_diagnostic) then if (bling%id_fed_surf .gt. 0) & used = send_data(bling%id_fed_surf, bling%p_fed_diag(:,:,1), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) else if (bling%id_fed_surf .gt. 0) & used = send_data(bling%id_fed_surf, bling%f_fed(:,:,1), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) endif enddo return end subroutine generic_miniBLING_diag !####################################################################### ! <SUBROUTINE NAME="generic_miniBLING_update_from_source"> ! <OVERVIEW> ! Update tracer concentration fields due to the source/sink contributions. ! </OVERVIEW> ! <DESCRIPTION> ! This subroutine contains most of the biogeochemistry for calculating the ! interaction of the core set of tracers with each other and with outside forcings. ! Additional tracers (e.g. carbon, isotopes) are calculated in other subroutines. ! </DESCRIPTION> ! <TEMPLATE> ! call generic_miniBLING_update_from_source(tracer_list,Temp,Salt,dzt,hblt_depth,& ! ilb,jlb,tau,dtts, grid_dat,sw_pen,opacity) ! </TEMPLATE> ! <IN NAME="tracer_list" TYPE="type(g_tracer_type), pointer"> ! Pointer to the head of generic tracer list. ! </IN> ! <IN NAME="ilb,jlb" TYPE="integer"> ! Lower bounds of x and y extents of input arrays on data domain ! </IN> ! <IN NAME="Temp" TYPE="real, dimension(ilb:,jlb:,:)"> ! Ocean temperature ! </IN> ! <IN NAME="Salt" TYPE="real, dimension(ilb:,jlb:,:)"> ! Ocean salinity ! </IN> ! <IN NAME="dzt" TYPE="real, dimension(ilb:,jlb:,:)"> ! Ocean layer thickness (meters) ! </IN> ! <IN NAME="opacity" TYPE="real, dimension(ilb:,jlb:,:)"> ! Ocean opacity ! </IN> ! <IN NAME="sw_pen" TYPE="real, dimension(ilb:,jlb:)"> ! Shortwave peneteration ! </IN> ! <IN NAME="hblt_depth" TYPE="real, dimension(ilb:,jlb:)"> ! ! </IN> ! <IN NAME="grid_dat" TYPE="real, dimension(ilb:,jlb:)"> ! Grid area ! </IN> ! <IN NAME="tau" TYPE="integer"> ! Time step index of %field ! </IN> ! <IN NAME="dtts" TYPE="real"> ! Time step increment ! </IN> ! </SUBROUTINE> subroutine generic_miniBLING_update_from_source(tracer_list, Temp, Salt, & rho_dzt, dzt, hblt_depth, ilb, jlb, tau, dtts, grid_dat, model_time, nbands, & max_wavelength_band, sw_pen_band, opacity_band, grid_ht) type(g_tracer_type), pointer, intent(inout) :: tracer_list real, dimension(ilb:,jlb:,:), intent(in) :: Temp real, dimension(ilb:,jlb:,:), intent(in) :: Salt real, dimension(ilb:,jlb:,:), intent(in) :: rho_dzt real, dimension(ilb:,jlb:,:), intent(in) :: dzt real, dimension(ilb:,jlb:), intent(in) :: hblt_depth real, dimension(ilb:,jlb:), intent(in) :: grid_ht integer, intent(in) :: ilb integer, intent(in) :: jlb integer, intent(in) :: tau real, intent(in) :: dtts real, dimension(ilb:,jlb:), intent(in) :: grid_dat type(time_type), intent(in) :: model_time integer, intent(in) :: nbands real, dimension(:), intent(in) :: max_wavelength_band real, dimension(:,ilb:,jlb:), intent(in) :: sw_pen_band real, dimension(:,ilb:,jlb:,:), intent(in) :: opacity_band !----------------------------------------------------------------------- ! local parameters character(len=fm_string_len), parameter :: sub_name = 'generic_miniBLING_update_from_source' character(len=256) :: caller_str character(len=256) :: error_header character(len=256) :: warn_header character(len=256) :: note_header integer :: isc integer :: iec integer :: jsc integer :: jec integer :: isd integer :: ied integer :: jsd integer :: jed integer :: nk integer :: ntau integer :: i integer :: j integer :: k integer :: kblt integer :: n real, dimension(:,:,:), pointer :: grid_tmask integer, dimension(:,:), pointer :: grid_kmt logical :: used integer :: nb real :: tmp_hblt real :: tmp_Irrad real :: tmp_irrad_ML real :: tmp_phyto_lg_ML real :: tmp_phyto_sm_ML real :: tmp_opacity real, dimension(:), Allocatable :: tmp_irr_band real :: s_over_p ! Set up the headers for stdout messages. caller_str = trim(mod_name) // '(' // trim(sub_name) // ')[]' error_header = '==>Error from ' // trim(caller_str) // ':' warn_header = '==>Warning from ' // trim(caller_str) // ':' note_header = '==>Note from ' // trim(caller_str) // ':' ! Set up the module if not already done call g_tracer_get_common(isc, iec, jsc, jec, isd, ied, jsd, jed, nk, ntau, & grid_tmask = grid_tmask, grid_kmt = grid_kmt) ! SURFACE GAS FLUXES ! ! This subroutine coordinates the calculation of gas concentrations and solubilities ! in the surface layer. The concentration of a gas is written as csurf, while the ! solubility (in mol kg-1 atm-1 or mol m-3 atm-1) is written as alpha. These two ! quantities are passed to the coupler, which multiplies their difference by the ! gas exchange piston velocity over the mixed layer depth to provide the gas ! exchange flux, ! Flux = Kw/dz * (alpha - csurf) ! ! For CO2 and 14CO2, the carbon solubility and speciation are calculated by the ! subroutine co2calc, following the OCMIP2 protocol. These calculations are both made ! using total CO2, following which the surface CO2 concentration (CO2*, also known as ! H2CO3*) is scaled by the DI14C/DIC ratio to give the surface 14CO2 concentration. ! The speciation calculation uses in situ temperature, salinity, and PO4. ! ! ! Oxygen solubility is calculated here, using in situ temperature and salinity. !--------------------------------------------------------------------- ! Get positive tracer concentrations for carbon calculation !--------------------------------------------------------------------- allocate(tmp_irr_band(nbands)) do n = 1, num_instances bling%zbot = 0.0 s_over_p = 0.0 !--------------------------------------------------------------------- ! Get positive concentrations for prognostic tracers !--------------------------------------------------------------------- call g_tracer_get_values(tracer_list, 'po4' // bling%suffix, 'field', bling%f_po4, isd, jsd, & ntau = tau, positive = .true.) if (bling%fe_is_prognostic) then call g_tracer_get_values(tracer_list, 'fed' // bling%suffix, 'field', bling%f_fed, isd, jsd, & ntau = tau, positive = .true.) else call data_override('OCN', 'fed_data' // trim(bling%suffix), bling%f_fed_data, model_time) do k = 1, nk do j = jsc, jec do i = isc, iec bling%f_fed_data(i,j,k) = & max(bling%f_fed_data(i,j,k), & bling%fe_coastal * (1.0 - grid_ht(i,j)/bling%fe_coastal_depth)) * grid_tmask(i,j,k) enddo !} i enddo !} j enddo !} k if (bling%fe_is_diagnostic) then call g_tracer_get_values(tracer_list, 'fed' // bling%suffix, 'field', bling%f_fed, isd, jsd, & positive = .true.) else do k = 1, nk do j = jsc, jec do i = isc, iec bling%f_fed(i,j,k) = bling%f_fed_data(i,j,k) enddo !} i enddo !} j enddo !} k endif endif call g_tracer_get_values(tracer_list, 'o2' // bling%suffix, 'field', bling%f_o2, isd, jsd, & ntau = tau, positive = .true.) !--------------------------------------------------------------------- ! Assign pointers for diagnostic tracers !--------------------------------------------------------------------- if (bling%biomass_type .eq. 'single') then call g_tracer_get_pointer(tracer_list,'biomass_p' // bling%suffix,'field',bling%p_biomass_p) elseif (bling%biomass_type .eq. 'lg_sm_phyto') then call g_tracer_get_pointer(tracer_list,'phyto_lg'// bling%suffix,'field',bling%p_phyto_lg) call g_tracer_get_pointer(tracer_list,'phyto_sm'// bling%suffix,'field',bling%p_phyto_sm) endif call g_tracer_get_pointer(tracer_list,'irr_mem' // bling%suffix,'field',bling%p_irr_mem) if (bling%do_carbon) then !<<CARBON CYCLE call g_tracer_get_pointer(tracer_list, 'htotal' // bling%suffix, 'field', bling%p_htotal) call g_tracer_get_pointer(tracer_list, 'dic' // bling%suffix, 'field', bling%p_dic) !--------------------------------------------------------------------- ! Calculate co2 fluxes csurf and alpha for the next round of exchange ! Note a scaled value of the PO4, rather than SiOH3, is used for all ! calculations since there is no prognostic silica cycle. ! Alkalinity is calculated from salinity, since there is no prognostic ! alkalinity cycle. !--------------------------------------------------------------------- k=1 do j = jsc, jec do i = isc, iec bling%htotallo(i,j) = bling%htotal_scale_lo * bling%p_htotal(i,j,k) bling%htotalhi(i,j) = bling%htotal_scale_hi * bling%p_htotal(i,j,k) enddo !} i enddo !} j do j = jsc, jec !{ do i = isc, iec !{ bling%surf_temp(i,j) = Temp(i,j,k) bling%surf_salt(i,j) = Salt(i,j,k) bling%surf_po4(i,j) = bling%f_po4(i,j,k) bling%surf_sio4(i,j) = bling%f_po4(i,j,k) bling%surf_dic(i,j) = bling%p_dic(i,j,k,tau) enddo !} i enddo !} j ! Optionally override surface values used in the gas exchange calculations ! Note that the data_override routine wants the array to be over the computational grid, ! so we need to pass only that part of the array (the arrays must be dimensioned on the data ! domain, as that is what is needed for the co2calc routine). Also note that we only call the ! data_override routine if we are actually overriding to avoid the implicit array copies implied ! by passing a sub-array into and out of the subroutine. ! ! There could be a problem with this scheme if the halo region values are actually used, as these may ! be inconsistent with the overridden values on adjacent processors. I do not believe that this is ! problem, however. -- Richard Slater (2012-02-07) if (bling%override_surf_temp) then call data_override('OCN', 'temp_co2_flux' // trim(bling%suffix),bling%surf_temp(isc:iec,jsc:jec),& model_time, override = bling%override_surf_temp) endif if (bling%override_surf_salt) then call data_override('OCN', 'salt_co2_flux' // trim(bling%suffix),bling%surf_salt(isc:iec,jsc:jec),& model_time, override = bling%override_surf_salt) endif if (bling%override_surf_alk) then call data_override('OCN', 'alk_co2_flux' // trim(bling%suffix),bling%surf_alk(isc:iec,jsc:jec), & model_time, override = bling%override_surf_alk) endif if (bling%override_surf_po4) then call data_override('OCN', 'po4_co2_flux' // trim(bling%suffix),bling%surf_po4(isc:iec,jsc:jec), & model_time, override = bling%override_surf_po4) endif if (bling%override_surf_sio4) then call data_override('OCN', 'sio4_co2_flux' // trim(bling%suffix),bling%surf_sio4(isc:iec,jsc:jec),& model_time, override = bling%override_surf_sio4) endif if (bling%override_surf_dic) then call data_override('OCN', 'dic_co2_flux' // trim(bling%suffix),bling%surf_dic(isc:iec,jsc:jec), & model_time, override = bling%override_surf_dic) endif if (.not. bling%override_surf_alk) then ! ! Calculate the surface alkalinity if not overridden above ! if (bling%alk_scheme .eq. 'normal') then do j = jsc, jec !{ do i = isc, iec !{ ! This is an ad hoc regression, eyeballed from GLODAP vs WOA in ferret, to give ALK from salinity. ! Intercept is large, to keep the Southern Ocean alkalinity close to obs. Note this makes ! the gyres low alkalinity, which will lead to outgassing there. ! Would probably be better to use an ALK/salinity map instead. bling%surf_alk(i,j) = Salt(i,j,1) * bling%alk_slope + bling%alk_intercept enddo !} i enddo !} j elseif (bling%alk_scheme .eq. 'ratios') then call data_override('OCN', 'surf_alk' // trim(bling%suffix), bling%surf_alk(isc:iec,jsc:jec), model_time) do j = jsc, jec !{ do i = isc, iec !{ ! Use a map of the ratios of alkalinity to salinity and a constant intercept ! For this method, we use the data_override value for surf_alk to set the slopes bling%surf_alk(i,j) = Salt(i,j,1) * bling%surf_alk(i,j) + bling%alk_intercept enddo !} i enddo !} j elseif (bling%alk_scheme .eq. 'intercepts') then call data_override('OCN', 'surf_alk' // trim(bling%suffix), bling%surf_alk(isc:iec,jsc:jec), model_time) do j = jsc, jec !{ do i = isc, iec !{ ! Use a map of the intercepts of alkalinity to salinity and a constant slope ! For this method, we use the data_override value for surf_alk to set the intercepts bling%surf_alk(i,j) = Salt(i,j,1) * bling%alk_slope + bling%surf_alk(i,j) enddo !} i enddo !} j else call mpp_error(FATAL, trim(error_header) // & ' Illegal alk_scheme (' // trim(bling%alk_scheme) // ') for instance ' // trim(bling%name)) endif endif call FMS_ocmip2_co2calc(CO2_dope_vec, grid_tmask(:,:,k), & bling%surf_temp(:,:), bling%surf_salt(:,:), & bling%surf_dic(:,:), & bling%surf_po4(:,:), & bling%surf_sio4(:,:), & bling%surf_alk(:,:), & bling%htotallo, bling%htotalhi, & !InOut bling%p_htotal(:,:,k), & !OUT co2star=bling%co2_csurf(:,:), & alpha=bling%co2_alpha(:,:), & pCO2surf=bling%pco2_surf(:,:)) call g_tracer_set_values(tracer_list,'dic' // bling%suffix,'alpha',bling%co2_alpha ,isd,jsd) call g_tracer_set_values(tracer_list,'dic' // bling%suffix,'csurf',bling%co2_csurf ,isd,jsd) if (bling%do_14c) then !<<RADIOCARBON call g_tracer_get_pointer(tracer_list,'di14c' // bling%suffix ,'field', bling%p_di14c) do j = jsc, jec do i = isc, iec ! The surface p14CO2* concentration is calculated by scaling the total CO2* by the ! surface water 14C/12C. bling%c14o2_csurf(i,j) = bling%co2_csurf(i,j) * & bling%p_di14c(i,j,1,tau) / (bling%p_dic(i,j,1,tau) + epsln) ! Alpha is here the same as co2. The air-sea flux depends on the atmospheric ! p14CO2 given in the data table entry (which may vary over time, reflecting ! both changes in atmospheric pCO2 and D14CO2). bling%c14o2_alpha(i,j) = bling%co2_alpha(i,j) enddo !} i enddo !} j call g_tracer_set_values(tracer_list,'di14c' // bling%suffix,'alpha',bling%c14o2_alpha ,isd,jsd) call g_tracer_set_values(tracer_list,'di14c' // bling%suffix,'csurf',bling%c14o2_csurf ,isd,jsd) endif !RADIOCARBON>> endif !CARBON CYCLE>> !-------------------------------------------------------------------------- ! NUTRIENT UPTAKE !-------------------------------------------------------------------------- ! Available light calculation !----------------------------------------------------------------------- ! There are multiple types of light. ! irr_inst is the instantaneous irradiance field. ! irr_mix is the same, but with the irr_inst averaged throughout the ! mixed layer as defined in the KPP routine plus one more vertical box ! to account for mixing directly below the boundary layer. This quantity ! is intended to represent the light to which phytoplankton subject to ! turbulent transport in the mixed-layer would be exposed. ! irr_mem is a temporally smoothed field carried between timesteps, to ! represent photoadaptation. !----------------------------------------------------------------------- if (bling%biomass_type .eq. 'single') then do j = jsc, jec do i = isc, iec do nb = 1,nbands if (max_wavelength_band(nb) .lt. 710) then tmp_irr_band(nb) = max(0.0,sw_pen_band(nb,i,j)) else tmp_irr_band(nb) = 0.0 endif enddo !} nbands kblt = 0 tmp_irrad_ML = 0.0 tmp_hblt = 0.0 do k = 1, nk tmp_Irrad = 0.0 do nb = 1,nbands tmp_opacity = opacity_band(nb,i,j,k) tmp_Irrad = tmp_Irrad + tmp_irr_band(nb) * exp(-tmp_opacity * dzt(i,j,k) * 0.5) ! Change tmp_irr_band from being the value atop layer k to the value at the bottom of layer k. tmp_irr_band(nb) = tmp_irr_band(nb) * exp(-tmp_opacity * dzt(i,j,k)) enddo !} nbands bling%irr_inst(i,j,k) = tmp_Irrad * grid_tmask(i,j,k) bling%irr_mix(i,j,k) = tmp_Irrad * grid_tmask(i,j,k) if ((k == 1) .or. (tmp_hblt .lt. hblt_depth(i,j))) then kblt = kblt+1 tmp_irrad_ML = tmp_irrad_ML + bling%irr_mix(i,j,k) * dzt(i,j,k) tmp_hblt = tmp_hblt + dzt(i,j,k) endif enddo !} k bling%irr_mix(i,j,1:kblt) = tmp_irrad_ML / max(1.0e-6,tmp_hblt) enddo !} i enddo !} j elseif (bling%biomass_type .eq. 'lg_sm_phyto') then do j = jsc, jec do i = isc, iec do nb = 1,nbands if (max_wavelength_band(nb) .lt. 710) then tmp_irr_band(nb) = max(0.0,sw_pen_band(nb,i,j)) else tmp_irr_band(nb) = 0.0 endif enddo !} nbands kblt = 0 tmp_irrad_ML = 0.0 tmp_phyto_lg_ML = 0.0 tmp_phyto_sm_ML = 0.0 tmp_hblt = 0.0 do k = 1, nk tmp_Irrad = 0.0 do nb = 1,nbands tmp_opacity = opacity_band(nb,i,j,k) tmp_Irrad = tmp_Irrad + tmp_irr_band(nb) * exp(-tmp_opacity * dzt(i,j,k) * 0.5) ! Change tmp_irr_band from being the value atop layer k to the value at the bottom of layer k. tmp_irr_band(nb) = tmp_irr_band(nb) * exp(-tmp_opacity * dzt(i,j,k)) enddo !} nbands bling%irr_inst(i,j,k) = tmp_Irrad * grid_tmask(i,j,k) bling%irr_mix(i,j,k) = tmp_Irrad * grid_tmask(i,j,k) if ((k == 1) .or. (tmp_hblt .lt. hblt_depth(i,j))) then kblt = kblt+1 tmp_irrad_ML = tmp_irrad_ML + bling%irr_mix(i,j,k) * dzt(i,j,k) tmp_phyto_lg_ML = tmp_phyto_lg_ML + bling%p_phyto_lg(i,j,k) * dzt(i,j,k) tmp_phyto_sm_ML = tmp_phyto_sm_ML + bling%p_phyto_sm(i,j,k) * dzt(i,j,k) tmp_hblt = tmp_hblt + dzt(i,j,k) endif enddo !} k bling%irr_mix(i,j,1:kblt) = tmp_irrad_ML / max(1.0e-6,tmp_hblt) bling%p_phyto_lg(i,j,1:kblt) = tmp_phyto_lg_ML / max(1.0e-6,tmp_hblt) bling%p_phyto_lg(i,j,1:kblt) = tmp_phyto_sm_ML / max(1.0e-6,tmp_hblt) enddo !} i enddo !} j endif do k = 1, nk do j = jsc, jec do i = isc, iec !-------------------------------------------------------------------- ! Phytoplankton photoadaptation. This represents the fact that phytoplankton cells are ! adapted to the averaged light field to which they've been exposed over their lifetimes, ! rather than the instantaneous light. The timescale is set by gamma_irr_mem. bling%p_irr_mem(i,j,k) = (bling%p_irr_mem(i,j,k) + & (bling%irr_mix(i,j,k) - bling%p_irr_mem(i,j,k)) * min( 1.0 , & bling%gamma_irr_mem * dtts)) * grid_tmask(i,j,k) !-------------------------------------------------------------------- ! Temperature functionality of growth and grazing ! NB The temperature effect of Eppley (1972) is used instead ! of that in Geider et al (1997) for both simplicity and ! to incorporate combined effects on uptake, incorporation ! into organic matter and photorespiration. Values of PCmax ! are normalized to 0C rather than 20C in Geider et al. (1997) bling%expkT(i,j,k) = exp(bling%kappa_eppley * Temp(i,j,k)) enddo !} i enddo !} j enddo !} k !----------------------------------------------------------------------- ! Phytoplankton are assumed to grow according to the general properties ! described in Geider (1997). This formulation gives a biomass-specific ! growthrate as a function of light, nutrient limitation, and ! temperature. We modify this relationship slightly here, as described ! below, and also use the assumption of steady state growth vs. loss to ! derive a simple relationship between growth rate, biomass and uptake. ! !----------------------------------------------------------------------- ! First, we calculate the limitation terms for PO4 and Fe, and the ! Fe-limited Chl:C maximum. ! The light-saturated maximal photosynthesis rate term (pc_m) is simply ! the product of a prescribed maximal photosynthesis rate (pc_0), the ! Eppley temperature dependence, and a Liebig limitation (the minimum ! of Michaelis-Menton PO4-limitation, or iron-limitation). The iron ! limitation term is scaled by (k_fe_2_p + fe_2_p_max) / fe_2_p_max ! so that it approaches 1 as fed approaches infinity. Thus, ! it's of comparable magnitude to the PO4 limitation term. ! ! Fe limitation acts by reducing the maximum achievable Chl:C ratio ! (theta) below a prescribed, Fe-replete maximum value (thetamax), to ! approach a prescribed minimum Chl:C (thetamin) under extreme ! Fe-limitation. !----------------------------------------------------------------------- do k = 1, nk do j = jsc, jec do i = isc, iec bling%fe_2_p_uptake(i,j,k) = bling%fe_2_p_max * & bling%f_fed(i,j,k) / (bling%k_fe_uptake + bling%f_fed(i,j,k)) bling%def_fe(i,j,k) = max(bling%def_fe_min, & (bling%fe_2_p_uptake(i,j,k) / & (bling%k_fe_2_p + bling%fe_2_p_uptake(i,j,k)) * & (bling%k_fe_2_p + bling%fe_2_p_max) / bling%fe_2_p_max)) bling%pc_m(i,j,k) = bling%pc_0 * bling%expkT(i,j,k) * min( & max(0.,((bling%f_po4(i,j,k) - bling%po4_min) / & (bling%k_po4 + bling%f_po4(i,j,k) - bling%po4_min))) , & bling%def_fe(i,j,k)) bling%thetamax_fe(i,j,k) = bling%thetamax_lo + & (bling%thetamax_hi - bling%thetamax_lo) * bling%def_fe(i,j,k) !----------------------------------------------------------------------- ! Next, the nutrient-limited efficiency of algal photosystems, Irrk, is ! calculated. This requires a prescribed quantum yield, alpha. ! The iron deficiency term is included here as a multiplier of the ! thetamax_fe to represent the importance of Fe in forming chlorophyll ! accessory antennae, which do not affect the Chl:C but still affect the ! phytoplankton ability to use light (eg Stzrepek & Harrison Nature ! 2004). bling%irrk(i,j,k) = (bling%pc_m(i,j,k) / ( epsln + & bling%alpha_photo * bling%thetamax_fe(i,j,k) )) + & bling%p_irr_mem(i,j,k) * 0.5 !----------------------------------------------------------------------- ! We also calculate the Chl:C ratio here, although it does not enter ! into the uptake calculation and is only used for the diagnostic ! chlorophyll concentration, below. bling%theta(i,j,k) = bling%thetamax_fe(i,j,k) / (1. + & bling%thetamax_fe(i,j,k) * bling%alpha_photo * & bling%p_irr_mem(i,j,k) / (epsln + 2. * bling%pc_m(i,j,k))) !----------------------------------------------------------------------- ! Now we can calculate the carbon-specific photosynthesis rate, mu. bling%mu(i,j,k) = bling%pc_m(i,j,k) * & (1. - exp(-bling%irr_mix(i,j,k) / (epsln + bling%irrk(i,j,k)))) enddo !} i enddo !} j enddo !} k !----------------------------------------------------------------------- ! We now must convert this net carbon-specific growth rate to nutrient ! uptake rates, the quantities we are interested in. Since we have no ! explicit biomass tracer, we use the result of Dunne et al. (GBC, 2005) ! to calculate an implicit biomass from the uptake rate through the ! application of a simple idealized grazing law. This has the effect of ! reducing uptake in low growth-rate regimes and increasing uptake in ! high growth-rate regimes - essentially a non-linear amplification of ! the growth rate variability. The result is: if (bling%biomass_type .eq. 'single') then do k = 1, nk do j = jsc, jec do i = isc, iec bling%biomass_p_ts(i,j,k) = & ((bling%mu(i,j,k)/(bling%lambda0 * bling%expkT(i,j,k)))**3 & + (bling%mu(i,j,k)/(bling%lambda0 * bling%expkT(i,j,k)))) & * bling%p_star bling%p_biomass_p(i,j,k) = bling%p_biomass_p(i,j,k) + & (bling%biomass_p_ts(i,j,k) - bling%p_biomass_p(i,j,k)) * & min(1.0, bling%gamma_biomass * dtts) * grid_tmask(i,j,k) bling%jp_uptake(i,j,k) = bling%p_biomass_p(i,j,k) * & bling%mu(i,j,k) ! We can now use the diagnostic biomass to calculate the chlorophyll ! concentration: bling%f_chl(i,j,k) = max(bling%chl_min, bling%p_biomass_p(i,j,k) & * bling%c_2_p * 12.011e6 * bling%theta(i,j,k)) * & grid_tmask(i,j,k) ! As a helpful diagnostic, the implied fraction of production by large ! phytoplankton is calculated, also following Dunne et al. 2005. This ! could be done more simply, but is done here in a complicated way as ! a sanity check. Note the calculation is made in P units, rather than C. s_over_p = ( -1. + ( 1. + 4. * bling%jp_uptake(i,j,k) / & (bling%expkT(i,j,k) * bling%lambda0 * bling%p_star))**0.5) * .5 bling%frac_lg(i,j,k) = s_over_p / (1 + s_over_p) enddo !} i enddo !} j enddo !} k elseif (bling%biomass_type .eq. 'lg_sm_phyto') then do k = 1, nk do j = jsc, jec do i = isc, iec bling%jp_uptake(i,j,k) = bling%mu(i,j,k) * & (bling%p_phyto_lg(i,j,k) + bling%p_phyto_sm(i,j,k)) enddo !} i enddo !} j enddo !} k endif !----------------------------------------------------------------------- ! Iron is then taken up as a function of PO4 uptake and iron limitation, ! with a maximum Fe:P uptake ratio of fe2p_max: do k = 1, nk do j = jsc, jec do i = isc, iec bling%jfe_uptake(i,j,k) = bling%jp_uptake(i,j,k) * & bling%fe_2_p_uptake(i,j,k) enddo !} i enddo !} j enddo !} k !------------------------------------------------------------------------- ! PARTITIONING BETWEEN ORGANIC POOLS !------------------------------------------------------------------------- ! The uptake of nutrients is assumed to contribute to the growth of ! phytoplankton, which subsequently die and are consumed by heterotrophs. ! This can involve the transfer of nutrient elements between many ! organic pools, both particulate and dissolved, with complex histories. ! We take a simple approach here, partitioning the total uptake into two ! fractions - sinking and non-sinking - as a function of temperature, ! following Dunne et al. (2005). ! The non-sinking fraction is recycled instantaneously to the inorganic ! nutrient pool, ! representing the fast turnover of labile dissolved organic matter via ! the microbial loop, and the remainder is converted to semi-labile ! dissolved organic matter. Iron and phosphorus are treated identically ! for the first step, but all iron is recycled instantaneously in the ! second step (i.e. there is no dissolved organic iron pool). !------------------------------------------------------------------------- do k = 1, nk do j = jsc, jec do i = isc, iec bling%frac_pop(i,j,k) = max((bling%phi_sm + bling%phi_lg * & (bling%mu(i,j,k)/(bling%lambda0*bling%expkT(i,j,k)))**2.)/ & (1. + (bling%mu(i,j,k)/(bling%lambda0*bling%expkT(i,j,k)))**2.)* & exp(bling%kappa_remin * Temp(i,j,k)) * & ! Experimental! Reduce frac_pop under strong PO4 limitation bling%f_po4(i,j,k) / (bling%k_po4_recycle + bling%f_po4(i,j,k)), & bling%min_frac_pop) bling%jpop(i,j,k) = bling%frac_pop(i,j,k) * bling%jp_uptake(i,j,k) ! Whatever isn't converted to sinking particulate is recycled to the dissolved pool. bling%jp_recycle(i,j,k) = bling%jp_uptake(i,j,k) - & bling%jpop(i,j,k) enddo !] i enddo !} j enddo !} k if (bling%biomass_type .eq. 'lg_sm_phyto') then do k = 1, nk do j = jsc, jec do i = isc, iec ! Finally, update the biomass of total phytoplankton, and of diazotrophs. ! Use this to solve the Dunne et al. 2005 mortality term, with alpha=1/3 (eq. 5b). ! Then, add this to the pre-exisiting phytoplankton biomass and the total uptake to give bling%p_phyto_lg(i,j,k) = bling%p_phyto_lg(i,j,k) + & bling%p_phyto_lg(i,j,k) * (bling%mu(i,j,k) - & bling%lambda0 * bling%expkT(i,j,k) * & (bling%p_phyto_lg(i,j,k) / bling%p_star)**(1./3.) ) * dtts * grid_tmask(i,j,k) bling%p_phyto_sm(i,j,k) = bling%p_phyto_sm(i,j,k) + & bling%p_phyto_sm(i,j,k) * (bling%mu(i,j,k) - & bling%lambda0 * bling%expkT(i,j,k) * & (bling%p_phyto_sm(i,j,k) / bling%p_star) ) * dtts * grid_tmask(i,j,k) bling%frac_lg(i,j,k) = bling%p_phyto_lg(i,j,k) / & (epsln + bling%p_phyto_lg(i,j,k)+bling%p_phyto_sm(i,j,k)) ! Calculate the chlorophyll concentration: bling%f_chl(i,j,k) = max(bling%chl_min, & bling%c_2_p * 12.011e6 * bling%theta(i,j,k) * & (bling%p_phyto_lg(i,j,k) + bling%p_phyto_sm(i,j,k))) * grid_tmask(i,j,k) enddo !] i enddo !} j enddo !} k endif ! ! perform recycling, as above, for the prognostic Fed tracer ! if (bling%fe_is_prognostic) then do k = 1, nk do j = jsc, jec do i = isc, iec bling%jfeop(i,j,k) = bling%frac_pop(i,j,k)*bling%jfe_uptake(i,j,k) bling%jfe_recycle(i,j,k) = bling%jfe_uptake(i,j,k) - & bling%jfeop(i,j,k) enddo !] i enddo !} j enddo !} k endif !------------------------------------------------------------------------- ! SINKING AND REMINERALIZATION !------------------------------------------------------------------------- ! Calculate the depth of each grid cell (needs to be 3d for use with ! isopycnal co-ordinate model). do j = jsc, jec do i = isc, iec bling%zbot(i,j,1) = dzt(i,j,1) enddo !} i enddo !} j do k = 2, nk do j = jsc, jec do i = isc, iec bling%zbot(i,j,k) = bling%zbot(i,j,k-1) + dzt(i,j,k) enddo !} i enddo !} j enddo !} k !----------------------------------------------------------------------- ! Calculate the remineralization lengthscale matrix, zremin, a function ! of z. Sinking rate (wsink) is constant over the upper wsink0_z metres, ! then increases linearly with depth. ! The remineralization rate is a function of oxygen concentrations, ! to slow remineralization under suboxia/anoxia. The remineralization rate ! approaches the remin_min as O2 approaches O2 min. do k = 1, nk do j = jsc, jec do i = isc, iec if (bling%zbot(i,j,k) .lt. bling%wsink0_z) then bling%wsink(i,j,k) = bling%wsink0 else bling%wsink(i,j,k) = (bling%wsink_acc * (bling%zbot(i,j,k) - & bling%wsink0_z) + bling%wsink0) endif bling%zremin(i,j,k) = bling%gamma_pop * (bling%f_o2(i,j,k) / & (bling%k_o2 + bling%f_o2(i,j,k)) * (1. - bling%remin_min)+ & bling%remin_min) / (bling%wsink(i,j,k) + epsln) enddo !} i enddo !} j enddo !} k if (bling%do_carbon) then !<<CARBON CYCLE if (bling%do_14c) then !<<RADIOCARBON ! Sinking particulate 14C is generated in the local ratio of 14C/12C ! to sinking 12C, which itself is strictly tied to P through a fixed ! C:P. Therefore, jpop can be used to calculate fpo14c. do j = jsc, jec do i = isc, iec bling%c14_2_p(i,j,1) = bling%c_2_p * & bling%p_di14c(i,j,1,tau) / (epsln + bling%p_dic(i,j,1,tau)) bling%fpo14c(i,j,1) = bling%jpop(i,j,1) * bling%c14_2_p(i,j,1) * & rho_dzt(i,j,1) / (1.0 + dzt(i,j,1) * bling%zremin(i,j,1)) bling%j14c_reminp(i,j,1) = (bling%jpop(i,j,1) * & bling%c14_2_p(i,j,1) * rho_dzt(i,j,1) - bling%fpo14c(i,j,1)) / & (epsln + rho_dzt(i,j,1)) enddo !} i enddo !} j do k = 2, nk do j = jsc, jec do i = isc, iec bling%fpo14c(i,j,k) = (bling%fpo14c(i,j,k-1) + & bling%jpop(i,j,k) * bling%c14_2_p(i,j,k) * rho_dzt(i,j,k)) / & (1.0 + dzt(i,j,k) * bling%zremin(i,j,k)) bling%j14c_reminp(i,j,k) = (bling%fpo14c(i,j,k-1) + & bling%jpop(i,j,k) * bling%c14_2_p(i,j,k) * rho_dzt(i,j,k) - & bling%fpo14c(i,j,k)) / (epsln + rho_dzt(i,j,k)) enddo !} i enddo !} j enddo !} k ! Decay the radiocarbon in DIC bling%lambda_14c = log(2.0) / (bling%half_life_14c * spery) do k = 1, nk do j = jsc, jec do i = isc, iec bling%j14c_decay_dic(i,j,k) = bling%p_di14c(i,j,k,tau) * & bling%lambda_14c enddo !} i enddo !} j enddo !} k endif !RADIOCARBON>> endif !CARBON CYCLE>> if (bling%fe_is_prognostic) then do k = 1, nk do j = jsc, jec do i = isc, iec !--------------------------------------------------------------------- ! Calculate free and inorganically associated iron concentration for ! scavenging. ! We assume that there is a ! spectrum of iron ligands present in seawater, with varying binding ! strengths and whose composition varies with light and iron ! concentrations. For example, photodissocation of ligand complexes ! occurs under bright light, weakening the binding strength ! (e.g. Barbeau et al., Nature 2001), while at very low iron ! concentrations (order kfe_eq_lig_femin), siderophores are thought ! to be produced as a response to extreme iron stress. ! In anoxic waters, iron should be reduced, and therefore mostly ! immune to scavenging. Easiest way to do this is to skip the feprime ! calculation if oxygen is less than 0. if (bling%f_o2(i,j,k) .gt. bling%o2_min) then bling%kfe_eq_lig(i,j,k) = bling%kfe_eq_lig_max - & (bling%kfe_eq_lig_max - bling%kfe_eq_lig_min) * & (bling%irr_inst(i,j,k)**2. / (bling%irr_inst(i,j,k)**2. + & bling%kfe_eq_lig_irr **2.)) * max(0., min(1., (bling%f_fed(i,j,k) - & bling%kfe_eq_lig_femin) / (epsln + bling%f_fed(i,j,k)) * 1.2)) bling%feprime(i,j,k) = 1.0 + bling%kfe_eq_lig(i,j,k) * & (bling%felig_bkg - bling%f_fed(i,j,k)) bling%feprime(i,j,k) = (-bling%feprime(i,j,k) +(bling%feprime(i,j,k)* & bling%feprime(i,j,k) + 4.0 * bling%kfe_eq_lig(i,j,k) * & bling%f_fed(i,j,k))**(0.5)) /(2.0 * bling%kfe_eq_lig(i,j,k)) else !}{ bling%feprime(i,j,k) = 0. endif !} bling%jfe_ads_inorg(i,j,k) = min(0.5/dtts, bling%kfe_inorg * & bling%feprime(i,j,k) ** 0.5) * bling%feprime(i,j,k) enddo !} i enddo !} j enddo !} k endif !--------------------------------------------------------------------- ! In general, the flux at the bottom of a grid cell should equal ! Fb = (Ft + Prod*dz) / (1 + zremin*dz) ! where Ft is the flux at the top, and prod*dz is the integrated ! production of new sinking particles within the layer. ! Since Ft=0 in the first layer, do j = jsc, jec do i = isc, iec bling%fpop(i,j,1) = bling%jpop(i,j,1) * rho_dzt(i,j,1) / & (1.0 + dzt(i,j,1) * bling%zremin(i,j,1)) !----------------------------------------------------------------------- ! Calculate remineralization terms bling%jp_reminp(i,j,1) = & (bling%jpop(i,j,1) * rho_dzt(i,j,1) - bling%fpop(i,j,1)) / & (epsln + rho_dzt(i,j,1)) enddo !} i enddo !} j !----------------------------------------------------------------------- ! Then, for the rest of water column, include flux from above: do k = 2, nk do j = jsc, jec do i = isc, iec bling%fpop(i,j,k) = (bling%fpop(i,j,k-1) + & bling%jpop(i,j,k) * rho_dzt(i,j,k)) / & (1.0 + dzt(i,j,k) * bling%zremin(i,j,k)) !--------------------------------------------------------------------- ! Calculate remineralization terms bling%jp_reminp(i,j,k) = (bling%fpop(i,j,k-1) + & bling%jpop(i,j,k) * rho_dzt(i,j,k) - bling%fpop(i,j,k)) / & (epsln + rho_dzt(i,j,k)) enddo !} i enddo !} j enddo !} k !--------------------------------------------------------------------- ! BOTTOM LAYER ! Account for remineralization in bottom box, and bottom fluxes do j = jsc, jec do i = isc, iec k = grid_kmt(i,j) if (k .gt. 0) then !--------------------------------------------------------------------- ! Calculate external bottom fluxes for tracer_vertdiff. Positive fluxes ! are from the water column into the seafloor. For P, the bottom flux ! puts the sinking flux reaching the bottom cell into the water column ! through diffusion. ! For oxygen, the consumption of oxidant required to respire ! the settling flux of organic matter (in support of the ! PO4 bottom flux) diffuses from the bottom water into the sediment. bling%b_po4(i,j) = - bling%fpop(i,j,k) if (bling%f_o2(i,j,k) .gt. bling%o2_min) then bling%b_o2(i,j) = bling%o2_2_p * bling%fpop(i,j,k) else bling%b_o2(i,j) = 0.0 endif endif enddo !} i enddo !} j if (bling%fe_is_prognostic) then do j = jsc, jec do i = isc, iec !----------------------------------------------------------------------- ! Now, calculate the Fe adsorption using this fpop: ! The absolute first order rate constant is calculated from the ! concentration of organic particles, after Parekh et al. (2005). Never ! allowed to be greater than 1/2dt for numerical stability. bling%jfe_ads_org(i,j,1) = min (0.5/dtts, & bling%kfe_org * (bling%fpop(i,j,1) / (epsln + bling%wsink(i,j,1)) * & bling%mass_2_p) ** 0.58) * bling%feprime(i,j,1) bling%fpofe(i,j,1) = (bling%jfeop(i,j,1) +bling%jfe_ads_inorg(i,j,1) & + bling%jfe_ads_org(i,j,1)) * rho_dzt(i,j,1) / & (1.0 + dzt(i,j,1) * bling%zremin(i,j,1)) !----------------------------------------------------------------------- ! Calculate remineralization terms bling%jfe_reminp(i,j,1) = & ((bling%jfeop(i,j,1) + bling%jfe_ads_org(i,j,1) + & bling%jfe_ads_inorg(i,j,1)) * rho_dzt(i,j,1) - & bling%fpofe(i,j,1)) / (epsln + rho_dzt(i,j,1)) enddo !} i enddo !} j !----------------------------------------------------------------------- ! Then, for the rest of water column, include flux from above: do k = 2, nk do j = jsc, jec do i = isc, iec !----------------------------------------------------------------------- ! Again, calculate the Fe adsorption using this fpop: bling%jfe_ads_org(i,j,k) = min (0.5/dtts, bling%kfe_org * & (bling%fpop(i,j,k) / (epsln + bling%wsink(i,j,k)) * & bling%mass_2_p) ** 0.58) * bling%feprime(i,j,k) bling%fpofe(i,j,k) = (bling%fpofe(i,j,k-1) + & (bling%jfe_ads_org(i,j,k) + bling%jfe_ads_inorg(i,j,k) + & bling%jfeop(i,j,k)) *rho_dzt(i,j,k)) / & (1.0 + dzt(i,j,k) * bling%zremin(i,j,k)) !--------------------------------------------------------------------- ! Calculate remineralization terms bling%jfe_reminp(i,j,k) = (bling%fpofe(i,j,k-1) + & (bling%jfe_ads_org(i,j,k) + bling%jfe_ads_inorg(i,j,k) + & bling%jfeop(i,j,k)) * rho_dzt(i,j,k) - & bling%fpofe(i,j,k)) / (epsln + rho_dzt(i,j,k)) enddo !} i enddo !} j enddo !} k !--------------------------------------------------------------------- ! BOTTOM LAYER ! Account for remineralization in bottom box, and bottom fluxes do j = jsc, jec do i = isc, iec k = grid_kmt(i,j) if (k .gt. 0) then !--------------------------------------------------------------------- ! Calculate iron addition from sediments as a function of organic ! matter supply. bling%ffe_sed(i,j) = bling%fe_2_p_sed * bling%fpop(i,j,k) ! Added the burial flux of sinking particulate iron here as a ! diagnostic, needed to calculate mass balance of iron. bling%fe_burial(i,j) = bling%fpofe(i,j,k) !--------------------------------------------------------------------- ! Calculate external bottom fluxes for tracer_vertdiff. Positive fluxes ! are from the water column into the seafloor. For iron, the sinking flux disappears into the ! sediments if bottom waters are oxic (assumed adsorbed as oxides), ! while an efflux of dissolved iron occurs dependent on the supply of ! reducing organic matter (scaled by the org-P sedimentation rate). ! If bottom waters are anoxic, the sinking flux of Fe is returned to ! the water column. Note this is not appropriate for very long runs ! with an anoxic ocean (iron will keep accumulating forever). if (bling%f_o2(i,j,k) .gt. bling%o2_min) then bling%b_fed(i,j) = - bling%ffe_sed(i,j) else bling%b_fed(i,j) = - bling%ffe_sed(i,j) - bling%fpofe(i,j,k) endif endif enddo !} i enddo !} j endif if (bling%fe_is_prognostic) then call g_tracer_set_values(tracer_list,'fed' // bling%suffix, 'btf', bling%b_fed ,isd,jsd) endif call g_tracer_set_values(tracer_list,'po4' // bling%suffix, 'btf', bling%b_po4 ,isd,jsd) call g_tracer_set_values(tracer_list,'o2' // bling%suffix, 'btf', bling%b_o2 ,isd,jsd) if (bling%do_carbon) then !<<CARBON CYCLE ! Do bottom box calcs for carbon cycle do j = jsc, jec do i = isc, iec k = grid_kmt(i,j) if (k .gt. 0) then ! Do not bury any C-org - all goes back to water column bling%b_dic(i,j) = - bling%fpop(i,j,k) * bling%c_2_p endif !} enddo !} i enddo !} j call g_tracer_set_values(tracer_list,'dic' // bling%suffix, 'btf', bling%b_dic ,isd,jsd) if (bling%do_14c) then !<<RADIOCARBON do j = jsc, jec do i = isc, iec k = grid_kmt(i,j) if (k .gt. 0) then bling%b_di14c(i,j) = - bling%fpo14c(i,j,k) endif !} enddo !} i enddo !} j call g_tracer_set_values(tracer_list,'di14c' // bling%suffix,'btf',bling%b_di14c,isd,jsd) endif !} !RADIOCARBON>> endif !} !CARBON CYCLE>> !------------------------------------------------------------------------- ! CALCULATE SOURCE/SINK TERMS FOR EACH TRACER !------------------------------------------------------------------------- !Update the prognostics tracer fields via their pointers. if (bling%fe_is_prognostic) then call g_tracer_get_pointer(tracer_list, 'fed' // bling%suffix, 'field', bling%p_fed) elseif (bling%fe_is_diagnostic) then call g_tracer_get_pointer(tracer_list, 'fed' // bling%suffix, 'field', bling%p_fed_diag) endif call g_tracer_get_pointer(tracer_list,'o2' // bling%suffix ,'field',bling%p_o2 ) call g_tracer_get_pointer(tracer_list,'po4' // bling%suffix ,'field',bling%p_po4 ) if (bling%do_carbon) then call g_tracer_get_pointer(tracer_list,'dic' // bling%suffix,'field',bling%p_dic) if (bling%do_14c) then call g_tracer_get_pointer(tracer_list,'di14c' // bling%suffix,'field',bling%p_di14c) endif !} endif !} do k = 1, nk do j = jsc, jec do i = isc, iec ! ! PO4 ! Sum of fast recycling and decay of sinking POP, less uptake. ! bling%jpo4(i,j,k) = bling%jp_recycle(i,j,k) + & bling%jp_reminp(i,j,k) - bling%jp_uptake(i,j,k) bling%p_po4(i,j,k,tau) = bling%p_po4(i,j,k,tau) + & bling%jpo4(i,j,k) * dtts * grid_tmask(i,j,k) !----------------------------------------------------------------------- ! O2 ! Assuming constant P:O ratio. ! Optional prevention of negative oxygen (does not conserve ocean ! redox potential) or alternatively it can be allowed to go negative, ! keeping track of an implicit nitrate deficit ! plus sulfate reduction. !----------------------------------------------------------------------- if ( (bling%prevent_neg_o2) .and. & (bling%f_o2(i,j,k) .lt. bling%o2_min) ) then bling%jo2(i,j,k) = 0. * grid_tmask(i,j,k) else bling%jo2(i,j,k) = - bling%o2_2_p * bling%jpo4(i,j,k) & * grid_tmask(i,j,k) endif !} bling%p_o2(i,j,k,tau) = bling%p_o2(i,j,k,tau) + bling%jo2(i,j,k) * & dtts * grid_tmask(i,j,k) enddo !} i enddo !} j enddo !} k ! ! Fed ! if (bling%fe_is_prognostic) then do k = 1, nk do j = jsc, jec do i = isc, iec bling%p_fed(i,j,k,tau) = bling%p_fed(i,j,k,tau) + & (bling%jfe_recycle(i,j,k) + bling%jfe_reminp(i,j,k) - & bling%jfe_uptake(i,j,k) - bling%jfe_ads_org(i,j,k) - & bling%jfe_ads_inorg(i,j,k) ) * dtts * grid_tmask(i,j,k) enddo !} i enddo !} j enddo !} k elseif (bling%fe_is_diagnostic) then do k = 1, nk do j = jsc, jec do i = isc, iec bling%p_fed_diag(i,j,k) = bling%p_fed_diag(i,j,k) - & bling%jfe_uptake(i,j,k) * dtts * grid_tmask(i,j,k) bling%jfe_reminp(i,j,k) = (bling%f_fed_data(i,j,k) - bling%p_fed_diag(i,j,k)) * & (1.0 / (bling%fe_restoring * 86400.0)) * grid_tmask(i,j,k) bling%p_fed_diag(i,j,k) = bling%p_fed_diag(i,j,k) + & bling%jfe_reminp(i,j,k) * dtts enddo !} i enddo !} j enddo !} k endif if (bling%do_carbon) then !<<CARBON CYCLE do k = 1, nk do j = jsc, jec do i = isc, iec bling%p_dic(i,j,k,tau) = bling%p_dic(i,j,k,tau) + & (bling%jpo4(i,j,k) * bling%c_2_p) * dtts * grid_tmask(i,j,k) if (bling%do_14c) then !<<RADIOCARBON bling%jdi14c(i,j,k) = (bling%jp_recycle(i,j,k) - & bling%jp_uptake(i,j,k)) * bling%c14_2_p(i,j,k) + & bling%j14c_reminp(i,j,k) bling%p_di14c(i,j,k,tau) = bling%p_di14c(i,j,k,tau) + & (bling%jdi14c(i,j,k) - bling%j14c_decay_dic(i,j,k)) * dtts & * grid_tmask(i,j,k) endif !} !RADIOCARBON>> enddo !} i enddo !} j enddo !} k endif !CARBON CYCLE>> ! !Set the diagnostics tracer fields. ! call g_tracer_set_values(tracer_list,'chl' // bling%suffix,'field',bling%f_chl,isd,jsd, & ntau=1) !----------------------------------------------------------------------- ! Save variables for diagnostics !----------------------------------------------------------------------- ! if (.not. bling%fe_is_prognostic) then if (bling%id_fed_data_surf .gt. 0) & used = send_data(bling%id_fed_data_surf, bling%f_fed_data(:,:,1), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) endif if (bling%id_htotal_surf .gt. 0) & used = send_data(bling%id_htotal_surf, bling%p_htotal(:,:,1), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_chl_surf .gt. 0) & used = send_data(bling%id_chl_surf, bling%f_chl(:,:,1), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%biomass_type .eq. 'single') then if (bling%id_biomass_p_surf .gt. 0) & used = send_data(bling%id_biomass_p_surf, bling%p_biomass_p(:,:,1), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) elseif (bling%biomass_type .eq. 'lg_sm_phyto') then if (bling%id_phyto_lg_surf .gt. 0) & used = send_data(bling%id_phyto_lg_surf, bling%p_phyto_lg(:,:,1), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_phyto_sm_surf .gt. 0) & used = send_data(bling%id_phyto_sm_surf, bling%p_phyto_sm(:,:,1), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) endif if (bling%id_irr_mem_surf .gt. 0) & used = send_data(bling%id_irr_mem_surf, bling%p_irr_mem(:,:,1), & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_pco2_surf .gt. 0) & used = send_data(bling%id_pco2_surf, bling%pco2_surf, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_temp_co2calc .gt. 0) & used = send_data(bling%id_temp_co2calc, bling%surf_temp, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_salt_co2calc .gt. 0) & used = send_data(bling%id_salt_co2calc, bling%surf_salt, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_po4_co2calc .gt. 0) & used = send_data(bling%id_po4_co2calc, bling%surf_po4, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_alk_co2calc .gt. 0) & used = send_data(bling%id_alk_co2calc, bling%surf_alk, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_sio4_co2calc .gt. 0) & used = send_data(bling%id_sio4_co2calc, bling%surf_sio4, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_dic_co2calc .gt. 0) & used = send_data(bling%id_dic_co2calc, bling%surf_dic, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%fe_is_prognostic) then if (bling%id_b_fed .gt. 0) & used = send_data(bling%id_b_fed, bling%b_fed, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) endif if (bling%id_b_o2 .gt. 0) & used = send_data(bling%id_b_o2, bling%b_o2, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_b_po4 .gt. 0) & used = send_data(bling%id_b_po4, bling%b_po4, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%biomass_type .eq. 'single') then if (bling%id_biomass_p_ts .gt. 0) & used = send_data(bling%id_biomass_p_ts, bling%biomass_p_ts, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) endif if (bling%id_def_fe .gt. 0) & used = send_data(bling%id_def_fe, bling%def_fe, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_expkT .gt. 0) & used = send_data(bling%id_expkT, bling%expkT, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_fe_2_p_uptake .gt. 0) & used = send_data(bling%id_fe_2_p_uptake, bling%fe_2_p_uptake, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%fe_is_prognostic) then if (bling%id_feprime .gt. 0) & used = send_data(bling%id_feprime, bling%feprime, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_fe_burial .gt. 0) & used = send_data(bling%id_fe_burial, bling%fe_burial, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_ffe_sed .gt. 0) & used = send_data(bling%id_ffe_sed, bling%ffe_sed, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_fpofe .gt. 0) & used = send_data(bling%id_fpofe, bling%fpofe, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) endif if (bling%id_fpop .gt. 0) & used = send_data(bling%id_fpop, bling%fpop, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_frac_lg .gt. 0) & used = send_data(bling%id_frac_lg, bling%frac_lg, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_frac_pop .gt. 0) & used = send_data(bling%id_frac_pop, bling%frac_pop, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_irr_inst .gt. 0) & used = send_data(bling%id_irr_inst, bling%irr_inst, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_irr_mix .gt. 0) & used = send_data(bling%id_irr_mix, bling%irr_mix, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_irrk .gt. 0) & used = send_data(bling%id_irrk, bling%irrk, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%fe_is_prognostic) then if (bling%id_jfe_ads_inorg .gt. 0) & used = send_data(bling%id_jfe_ads_inorg, bling%jfe_ads_inorg*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_jfe_ads_org .gt. 0) & used = send_data(bling%id_jfe_ads_org, bling%jfe_ads_org*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_jfe_recycle .gt. 0) & used = send_data(bling%id_jfe_recycle, bling%jfe_recycle*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) endif if (bling%fe_is_prognostic .or. bling%fe_is_diagnostic) then if (bling%id_jfe_reminp .gt. 0) & used = send_data(bling%id_jfe_reminp, bling%jfe_reminp*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) endif if (bling%id_jfe_uptake .gt. 0) & used = send_data(bling%id_jfe_uptake, bling%jfe_uptake*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_jo2 .gt. 0) & used = send_data(bling%id_jo2, bling%jo2*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_jp_recycle .gt. 0) & used = send_data(bling%id_jp_recycle, bling%jp_recycle*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_jp_reminp .gt. 0) & used = send_data(bling%id_jp_reminp, bling%jp_reminp*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_jp_uptake .gt. 0) & used = send_data(bling%id_jp_uptake, bling%jp_uptake*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_jpo4 .gt. 0) & used = send_data(bling%id_jpo4, bling%jpo4*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_jpop .gt. 0) & used = send_data(bling%id_jpop, bling%jpop*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%fe_is_prognostic) then if (bling%id_jfeop .gt. 0) & used = send_data(bling%id_jfeop, bling%jfeop*rho_dzt, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_kfe_eq_lig .gt. 0) & used = send_data(bling%id_kfe_eq_lig, bling%kfe_eq_lig, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) endif if (bling%id_pc_m .gt. 0) & used = send_data(bling%id_pc_m, bling%pc_m, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_mu .gt. 0) & used = send_data(bling%id_mu, bling%mu, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_o2_saturation .gt. 0) & used = send_data(bling%id_o2_saturation, bling%o2_saturation, & model_time, rmask = grid_tmask(:,:,1), & is_in=isc, js_in=jsc,ie_in=iec, je_in=jec) if (bling%id_theta .gt. 0) & used = send_data(bling%id_theta, bling%theta, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_thetamax_fe .gt. 0) & used = send_data(bling%id_thetamax_fe, bling%thetamax_fe, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_wsink .gt. 0) & used = send_data(bling%id_wsink, bling%wsink, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (bling%id_zremin .gt. 0) & used = send_data(bling%id_zremin, bling%zremin, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) if (.not. bling%fe_is_prognostic) then if (bling%id_fed_data .gt. 0) & used = send_data(bling%id_fed_data, bling%f_fed_data, & model_time, rmask = grid_tmask, & is_in=isc, js_in=jsc, ks_in=1,ie_in=iec, je_in=jec, ke_in=nk) endif enddo !} n deallocate(tmp_irr_band) return end subroutine generic_miniBLING_update_from_source !####################################################################### ! <SUBROUTINE NAME="generic_miniBLING_set_boundary_values"> ! <DESCRIPTION> ! Calculate and set coupler values at the surface / bottom of the ocean. ! </DESCRIPTION> ! <TEMPLATE> ! call generic_miniBLING_set_boundary_values(tracer_list,SST,SSS,rho,ilb,jlb,tau) ! </TEMPLATE> ! <IN NAME="tracer_list" TYPE="type(g_tracer_type), pointer"> ! Pointer to the head of generic tracer list. ! </IN> ! <IN NAME="ilb,jlb" TYPE="integer"> ! Lower bounds of x and y extents of input arrays on data domain ! </IN> ! <IN NAME="SST" TYPE="real, dimension(ilb:,jlb:)"> ! Sea Surface Temperature ! </IN> ! <IN NAME="SSS" TYPE="real, dimension(ilb:,jlb:)"> ! Sea Surface Salinity ! </IN> ! <IN NAME="rho" TYPE="real, dimension(ilb:,jlb:,:,:)"> ! Ocean density ! </IN> ! <IN NAME="tau" TYPE="integer"> ! Time step index of %field ! </IN> ! </SUBROUTINE> !User must provide the calculations for these boundary values. subroutine generic_miniBLING_set_boundary_values(tracer_list, SST, SSS, rho, ilb, jlb, tau) type(g_tracer_type), pointer, intent(inout) :: tracer_list real, dimension(ilb:,jlb:), intent(in) :: SST real, dimension(ilb:,jlb:), intent(in) :: SSS real, dimension(ilb:,jlb:,:,:), intent(in) :: rho integer, intent(in) :: ilb integer, intent(in) :: jlb integer, intent(in) :: tau integer :: isc integer :: iec integer :: jsc integer :: jec integer :: isd integer :: ied integer :: jsd integer :: jed integer :: nk integer :: ntau integer :: i integer :: j integer :: n real :: sal real :: ST real :: sc_co2 real :: sc_o2 !real :: sc_no_term real :: o2_saturation real :: tt real :: tk real :: ts real :: ts2 real :: ts3 real :: ts4 real :: ts5 real, dimension(:,:,:), pointer :: grid_tmask real, dimension(:,:,:,:), pointer :: o2_field real, dimension(:,:), pointer :: co2_alpha real, dimension(:,:), pointer :: co2_csurf real, dimension(:,:), pointer :: co2_schmidt real, dimension(:,:), pointer :: o2_alpha real, dimension(:,:), pointer :: o2_csurf real, dimension(:,:), pointer :: o2_schmidt real, dimension(:,:), pointer :: co2_sat_rate real, dimension(:,:), pointer :: c14o2_alpha real, dimension(:,:), pointer :: c14o2_csurf real, dimension(:,:), pointer :: c14o2_schmidt real :: surface_rho character(len=fm_string_len), parameter :: sub_name = 'generic_miniBLING_set_boundary_values' ! SURFACE GAS FLUXES ! ! This subroutine coordinates the calculation of gas concentrations and solubilities ! in the surface layer. The concentration of a gas is written as csurf, while the ! solubility (in mol kg-1 atm-1 or mol m-3 atm-1) is written as alpha. These two ! quantities are passed to the coupler, which multiplies their difference by the ! gas exchange piston velocity over the mixed layer depth to provide the gas ! exchange flux, ! Flux = Kw/dz * (alpha - csurf) ! In order to simplify code flow, the Schmidt number parameters, which are part of ! the piston velocity, are calculated here and applied to each of csurf and alpha ! before being sent to the coupler. ! ! For CO2 and 14CO2, the carbon solubility and speciation are calculated by the ! subroutine co2calc, following the OCMIP2 protocol. These calculations are both made ! using total CO2, following which the surface CO2 concentration (CO2*, also known as ! H2CO3*) is scaled by the DI14C/DIC ratio to give the surface 14CO2 concentration. ! The speciation calculation uses in situ temperature, salinity, ALK, PO4 and SiO4. ! ! Oxygen solubility is calculated here, using in situ temperature and salinity. !Get the necessary properties call g_tracer_get_common(isc, iec, jsc, jec, isd, ied, jsd, jed, nk, ntau, grid_tmask = grid_tmask) do n = 1, num_instances call g_tracer_get_pointer(tracer_list, 'o2' // bling%suffix ,'field', o2_field) call g_tracer_get_pointer(tracer_list, 'o2' // bling%suffix, 'alpha', o2_alpha) call g_tracer_get_pointer(tracer_list, 'o2' // bling%suffix, 'csurf', o2_csurf) call g_tracer_get_pointer(tracer_list, 'o2' // bling%suffix, 'sc_no', o2_schmidt) do j = jsc, jec do i = isc, iec sal = SSS(i,j) ST = SST(i,j) surface_rho = bling%Rho_0 !--------------------------------------------------------------------- ! O2 !--------------------------------------------------------------------- ! Compute the oxygen saturation concentration at 1 atm total pressure in mol/kg ! given the temperature (T, in deg C) and the salinity (S, in permil). ! ! From Garcia and Gordon (1992), Limnology and Oceonography (page 1310, eq (8)). ! *** Note: the "a3*ts^2" term was erroneous, and not included here. *** ! Defined between T(freezing) <= T <= 40 deg C and 0 <= S <= 42 permil. ! ! check value: T = 10 deg C, S = 35 permil, o2_saturation = 0.282015 mol m-3 !--------------------------------------------------------------------- tt = 298.15 - ST tk = 273.15 + ST ts = log(tt / tk) ts2 = ts * ts ts3 = ts2 * ts ts4 = ts3 * ts ts5 = ts4 * ts o2_saturation = (1000.0/22391.6) * grid_tmask(i,j,1) * & !convert from ml/l to mol m-3 exp(bling%a_0 + bling%a_1*ts + bling%a_2*ts2 + bling%a_3*ts3 + & bling%a_4*ts4 + bling%a_5*ts5 + (bling%b_0 + bling%b_1*ts + & bling%b_2*ts2 + bling%b_3*ts3 + bling%c_0 * sal) * sal) !--------------------------------------------------------------------- ! Compute the Schmidt number of O2 in seawater using the formulation proposed ! by Keeling et al. (1998, Global Biogeochem. Cycles, 12, 141-163). !--------------------------------------------------------------------- sc_o2 = bling%a1_o2 + ST * (bling%a2_o2 + ST * (bling%a3_o2 + & ST * bling%a4_o2 )) * grid_tmask(i,j,1) o2_alpha(i,j) = o2_saturation bling%o2_saturation(i,j) = o2_saturation / surface_rho o2_csurf(i,j) = o2_field(i,j,1,tau) * surface_rho o2_schmidt(i,j) = sc_o2 enddo !} i enddo !} j if (bling%do_carbon) then !<<CARBON CYCLE call g_tracer_get_pointer(tracer_list, 'dic' // bling%suffix, 'alpha', co2_alpha) call g_tracer_get_pointer(tracer_list, 'dic' // bling%suffix, 'csurf', co2_csurf) call g_tracer_get_pointer(tracer_list, 'dic' // bling%suffix, 'sc_no', co2_schmidt) do j = jsc, jec do i = isc, iec ST = SST(i,j) surface_rho = bling%Rho_0 !--------------------------------------------------------------------- ! CO2 !--------------------------------------------------------------------- !--------------------------------------------------------------------- ! Compute the Schmidt number of CO2 in seawater using the formulation ! presented by Wanninkhof (1992, J. Geophys. Res., 97, 7373-7382). !--------------------------------------------------------------------- sc_co2 = bling%a1_co2 + ST * (bling%a2_co2 + ST * & (bling%a3_co2 + ST * bling%a4_co2)) * grid_tmask(i,j,1) co2_alpha(i,j) = co2_alpha(i,j) * surface_rho co2_csurf(i,j) = co2_csurf(i,j) * surface_rho co2_schmidt(i,j) = sc_co2 enddo !} i enddo !} j if (bling%do_14c) then call g_tracer_get_pointer(tracer_list, 'di14c' // bling%suffix, 'alpha', c14o2_alpha) call g_tracer_get_pointer(tracer_list, 'di14c' // bling%suffix, 'csurf', c14o2_csurf) call g_tracer_get_pointer(tracer_list, 'di14c' // bling%suffix, 'sc_no', c14o2_schmidt) do j = jsc, jec do i = isc, iec ST = SST(i,j) surface_rho = bling%Rho_0 sc_co2 = bling%a1_co2 + ST * (bling%a2_co2 + ST * (bling%a3_co2 + & ST * bling%a4_co2)) * grid_tmask(i,j,1) c14o2_alpha(i,j) = c14o2_alpha(i,j) * surface_rho c14o2_csurf(i,j) = c14o2_csurf(i,j) * surface_rho c14o2_schmidt(i,j) = sc_co2 enddo enddo endif endif !CARBON CYCLE>> enddo return end subroutine generic_miniBLING_set_boundary_values !####################################################################### ! <SUBROUTINE NAME="generic_miniBLING_end"> ! <DESCRIPTION> ! End the module. Deallocate all work arrays. ! </DESCRIPTION> ! </SUBROUTINE> subroutine generic_miniBLING_end character(len=fm_string_len), parameter :: sub_name = 'generic_miniBLING_end' character(len=256), parameter :: error_header = & '==>Error from ' // trim(mod_name) // '(' // trim(sub_name) // '): ' character(len=256), parameter :: warn_header = & '==>Warning from ' // trim(mod_name) // '(' // trim(sub_name) // '): ' character(len=256), parameter :: note_header = & '==>Note from ' // trim(mod_name) // '(' // trim(sub_name) // '): ' integer :: stdout_unit stdout_unit = stdout() call user_deallocate_arrays return end subroutine generic_miniBLING_end !####################################################################### ! ! This is an internal sub, not a public interface. ! Allocate all the work arrays to be used in this module. ! subroutine user_allocate_arrays integer :: isc integer :: iec integer :: jsc integer :: jec integer :: isd integer :: ied integer :: jsd integer :: jed integer :: nk integer :: ntau integer :: n call g_tracer_get_common(isc,iec,jsc,jec,isd,ied,jsd,jed,nk,ntau) !Used in ocmip2_co2calc CO2_dope_vec%isc = isc CO2_dope_vec%iec = iec CO2_dope_vec%jsc = jsc CO2_dope_vec%jec = jec CO2_dope_vec%isd = isd CO2_dope_vec%ied = ied CO2_dope_vec%jsd = jsd CO2_dope_vec%jed = jed do n = 1, num_instances allocate(bling%wrk_3d (isd:ied, jsd:jed, 1:nk)); bling%wrk_3d=0.0 allocate(bling%wrk_2d (isd:ied, jsd:jed) ); bling%wrk_2d=0.0 allocate(bling%flux (isd:ied, jsd:jed) ); bling%flux=0.0 allocate(bling%integral (isd:ied, jsd:jed) ); bling%integral=0.0 allocate(bling%k_lev (isd:ied, jsd:jed) ); bling%k_lev=0.0 if (bling%biomass_type .eq. 'single') then allocate(bling%biomass_p_ts (isd:ied, jsd:jed, 1:nk)); bling%biomass_p_ts=0.0 endif allocate(bling%def_fe (isd:ied, jsd:jed, 1:nk)); bling%def_fe=0.0 allocate(bling%expkT (isd:ied, jsd:jed, 1:nk)); bling%expkT=0.0 allocate(bling%f_chl (isd:ied, jsd:jed, 1:nk)); bling%f_chl=0.0 allocate(bling%f_fed (isd:ied, jsd:jed, 1:nk)); bling%f_fed=0.0 if (.not. bling%fe_is_prognostic) then allocate(bling%f_fed_data (isc:iec, jsc:jec, 1:nk)); bling%f_fed_data=0.0 endif allocate(bling%f_o2 (isd:ied, jsd:jed, 1:nk)); bling%f_o2=0.0 allocate(bling%f_po4 (isd:ied, jsd:jed, 1:nk)); bling%f_po4=0.0 allocate(bling%fe_2_p_uptake (isd:ied, jsd:jed, 1:nk)); bling%fe_2_p_uptake=0.0 if (bling%fe_is_prognostic) then allocate(bling%feprime (isd:ied, jsd:jed, 1:nk)); bling%feprime=0.0 allocate(bling%fpofe (isd:ied, jsd:jed, 1:nk)); bling%fpofe=0.0 endif allocate(bling%fpop (isd:ied, jsd:jed, 1:nk)); bling%fpop=0.0 allocate(bling%frac_lg (isd:ied, jsd:jed, 1:nk)); bling%frac_lg=0.0 allocate(bling%frac_pop (isd:ied, jsd:jed, 1:nk)); bling%frac_pop=0.0 allocate(bling%irr_inst (isd:ied, jsd:jed, 1:nk)); bling%irr_inst=0.0 allocate(bling%irr_mix (isd:ied, jsd:jed, 1:nk)); bling%irr_mix=0.0 allocate(bling%irrk (isd:ied, jsd:jed, 1:nk)); bling%irrk=0.0 if (bling%fe_is_prognostic) then allocate(bling%jfe_ads_inorg (isd:ied, jsd:jed, 1:nk)); bling%jfe_ads_inorg=0.0 allocate(bling%jfe_ads_org (isd:ied, jsd:jed, 1:nk)); bling%jfe_ads_org=0.0 allocate(bling%jfe_recycle (isd:ied, jsd:jed, 1:nk)); bling%jfe_recycle=0.0 endif if (bling%fe_is_prognostic .or. bling%fe_is_diagnostic) then allocate(bling%jfe_reminp (isd:ied, jsd:jed, 1:nk)); bling%jfe_reminp=0.0 endif allocate(bling%jfe_uptake (isd:ied, jsd:jed, 1:nk)); bling%jfe_uptake=0.0 allocate(bling%jo2 (isd:ied, jsd:jed, 1:nk)); bling%jo2=0.0 allocate(bling%jp_recycle (isd:ied, jsd:jed, 1:nk)); bling%jp_recycle=0.0 allocate(bling%jp_reminp (isd:ied, jsd:jed, 1:nk)); bling%jp_reminp=0.0 allocate(bling%jp_uptake (isd:ied, jsd:jed, 1:nk)); bling%jp_uptake=0.0 allocate(bling%jpo4 (isd:ied, jsd:jed, 1:nk)); bling%jpo4=0.0 allocate(bling%jpop (isd:ied, jsd:jed, 1:nk)); bling%jpop=0.0 if (bling%fe_is_prognostic) then allocate(bling%jfeop (isd:ied, jsd:jed, 1:nk)); bling%jfeop=0.0 allocate(bling%kfe_eq_lig (isd:ied, jsd:jed, 1:nk)); bling%kfe_eq_lig=0.0 endif allocate(bling%mu (isd:ied, jsd:jed, 1:nk)); bling%mu=0.0 allocate(bling%pc_m (isd:ied, jsd:jed, 1:nk)); bling%pc_m=0.0 allocate(bling%theta (isd:ied, jsd:jed, 1:nk)); bling%theta=0.0 allocate(bling%thetamax_fe (isd:ied, jsd:jed, 1:nk)); bling%thetamax_fe=0.0 allocate(bling%wsink (isd:ied, jsd:jed, 1:nk)); bling%wsink=0.0 allocate(bling%zremin (isd:ied, jsd:jed, 1:nk)); bling%zremin=0.0 allocate(bling%zbot (isd:ied, jsd:jed, 1:nk)); bling%zbot=0.0 allocate(bling%b_o2 (isd:ied, jsd:jed)); bling%b_o2=0.0 allocate(bling%b_po4 (isd:ied, jsd:jed)); bling%b_po4=0.0 if (bling%fe_is_prognostic) then allocate(bling%b_fed (isd:ied, jsd:jed)); bling%b_fed=0.0 allocate(bling%fe_burial (isd:ied, jsd:jed)); bling%fe_burial=0.0 allocate(bling%ffe_sed (isd:ied, jsd:jed)); bling%ffe_sed=0.0 endif allocate(bling%o2_saturation (isd:ied, jsd:jed)); bling%o2_saturation=0.0 if (bling%do_carbon) then !<<CARBON CYCLE allocate(bling%b_dic (isd:ied, jsd:jed)); bling%b_dic=0.0 allocate(bling%co2_alpha (isd:ied, jsd:jed)); bling%co2_alpha=0.0 allocate(bling%co2_csurf (isd:ied, jsd:jed)); bling%co2_csurf=0.0 allocate(bling%htotallo (isd:ied, jsd:jed)) allocate(bling%htotalhi (isd:ied, jsd:jed)) allocate(bling%pco2_surf (isd:ied, jsd:jed)); bling%pco2_surf=0.0 allocate(bling%surf_temp (isd:ied, jsd:jed)); bling%surf_temp=0.0 allocate(bling%surf_salt (isd:ied, jsd:jed)); bling%surf_salt=0.0 allocate(bling%surf_alk (isd:ied, jsd:jed)); bling%surf_alk=0.0 allocate(bling%surf_po4 (isd:ied, jsd:jed)); bling%surf_po4=0.0 allocate(bling%surf_sio4 (isd:ied, jsd:jed)); bling%surf_sio4=0.0 allocate(bling%surf_dic (isd:ied, jsd:jed)); bling%surf_dic=0.0 if (bling%do_14c) then !<<RADIOCARBON allocate(bling%c14_2_p (isd:ied, jsd:jed, 1:nk)); bling%c14_2_p=0.0 allocate(bling%fpo14c (isd:ied, jsd:jed, 1:nk)); bling%fpo14c=0.0 allocate(bling%j14c_decay_dic (isd:ied, jsd:jed, 1:nk)); bling%j14c_decay_dic=0.0 allocate(bling%j14c_reminp (isd:ied, jsd:jed, 1:nk)); bling%j14c_reminp=0.0 allocate(bling%jdi14c (isd:ied, jsd:jed, 1:nk)); bling%jdi14c=0.0 allocate(bling%b_di14c (isd:ied, jsd:jed)); bling%b_di14c=0.0 allocate(bling%c14o2_alpha (isd:ied, jsd:jed)); bling%c14o2_alpha=0.0 allocate(bling%c14o2_csurf (isd:ied, jsd:jed)); bling%c14o2_csurf=0.0 endif !RADIOCARBON>> endif !CARBON CYCLE>> enddo return end subroutine user_allocate_arrays !####################################################################### ! ! This is an internal sub, not a public interface. ! Deallocate all the work arrays allocated by user_allocate_arrays. ! subroutine user_deallocate_arrays integer :: n do n = 1, num_instances deallocate(bling%wrk_3d) deallocate(bling%wrk_2d) deallocate(bling%flux) deallocate(bling%integral) deallocate(bling%k_lev) deallocate(bling%o2_saturation) if (bling%biomass_type .eq. 'single') then deallocate(bling%biomass_p_ts) endif deallocate(bling%def_fe) deallocate(bling%expkT) deallocate(bling%f_chl) deallocate(bling%f_fed) if (.not. bling%fe_is_prognostic) then deallocate(bling%f_fed_data) endif deallocate(bling%f_o2) deallocate(bling%f_po4) deallocate(bling%fe_2_p_uptake) if (bling%fe_is_prognostic) then deallocate(bling%feprime) deallocate(bling%fpofe) endif deallocate(bling%fpop) deallocate(bling%frac_lg) deallocate(bling%frac_pop) deallocate(bling%irr_inst) deallocate(bling%irr_mix) deallocate(bling%irrk) if (bling%fe_is_prognostic) then deallocate(bling%jfe_ads_inorg) deallocate(bling%jfe_ads_org) deallocate(bling%jfe_recycle) endif if (bling%fe_is_prognostic .or. bling%fe_is_diagnostic) then deallocate(bling%jfe_reminp) endif deallocate(bling%jfe_uptake) deallocate(bling%jo2) deallocate(bling%jp_recycle) deallocate(bling%jp_reminp) deallocate(bling%jp_uptake) deallocate(bling%jpo4) deallocate(bling%jpop) if (bling%fe_is_prognostic) then deallocate(bling%jfeop) deallocate(bling%kfe_eq_lig) endif deallocate(bling%pc_m) deallocate(bling%mu) deallocate(bling%theta) deallocate(bling%thetamax_fe) deallocate(bling%wsink) deallocate(bling%zremin) deallocate(bling%zbot) if (bling%fe_is_prognostic) then deallocate(bling%fe_burial) deallocate(bling%ffe_sed) deallocate(bling%b_fed) endif deallocate(bling%b_o2) deallocate(bling%b_po4) if (bling%do_carbon) then !<<CARBON CYCLE deallocate(bling%surf_temp) deallocate(bling%surf_salt) deallocate(bling%surf_alk) deallocate(bling%surf_po4) deallocate(bling%surf_sio4) deallocate(bling%surf_dic) deallocate(bling%co2_csurf) deallocate(bling%pco2_surf) deallocate(bling%co2_alpha) deallocate(bling%htotallo) deallocate(bling%htotalhi) deallocate(bling%b_dic) if (bling%do_14c) then !<<RADIOCARBON deallocate(bling%c14_2_p) deallocate(bling%fpo14c) deallocate(bling%j14c_decay_dic) deallocate(bling%j14c_reminp) deallocate(bling%jdi14c) deallocate(bling%c14o2_alpha) deallocate(bling%c14o2_csurf) deallocate(bling%b_di14c) endif !} !RADIOCARBON>> endif !} !CARBON CYCLE>> enddo !} n return end subroutine user_deallocate_arrays end module generic_miniBLING_mod
gpl-2.0
kargakis/origin
vendor/github.com/gonum/lapack/internal/testdata/netlib/xerbla.f
91
2161
*> \brief \b XERBLA * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE XERBLA( SRNAME, INFO ) * * .. Scalar Arguments .. * CHARACTER*(*) SRNAME * INTEGER INFO * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> XERBLA is an error handler for the LAPACK routines. *> It is called by an LAPACK routine if an input parameter has an *> invalid value. A message is printed and execution stops. *> *> Installers may consider modifying the STOP statement in order to *> call system-specific exception-handling facilities. *> \endverbatim * * Arguments: * ========== * *> \param[in] SRNAME *> \verbatim *> SRNAME is CHARACTER*(*) *> The name of the routine which called XERBLA. *> \endverbatim *> *> \param[in] INFO *> \verbatim *> INFO is INTEGER *> The position of the invalid parameter in the parameter list *> of the calling routine. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup aux_blas * * ===================================================================== SUBROUTINE XERBLA( SRNAME, INFO ) * * -- Reference BLAS level1 routine (version 3.4.0) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER*(*) SRNAME INTEGER INFO * .. * * ===================================================================== * * .. Intrinsic Functions .. INTRINSIC LEN_TRIM * .. * .. Executable Statements .. * WRITE( *, FMT = 9999 )SRNAME( 1:LEN_TRIM( SRNAME ) ), INFO * STOP * 9999 FORMAT( ' ** On entry to ', A, ' parameter number ', I2, ' had ', $ 'an illegal value' ) * * End of XERBLA * END
apache-2.0
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/TESTING/LIN/schkqr.f
3
13898
*> \brief \b SCHKQR * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE SCHKQR( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL, * NRHS, THRESH, TSTERR, NMAX, A, AF, AQ, AR, AC, * B, X, XACT, TAU, WORK, RWORK, IWORK, NOUT ) * * .. Scalar Arguments .. * LOGICAL TSTERR * INTEGER NM, NMAX, NN, NNB, NOUT, NRHS * REAL THRESH * .. * .. Array Arguments .. * LOGICAL DOTYPE( * ) * INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NVAL( * ), * $ NXVAL( * ) * REAL A( * ), AC( * ), AF( * ), AQ( * ), AR( * ), * $ B( * ), RWORK( * ), TAU( * ), WORK( * ), * $ X( * ), XACT( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> SCHKQR tests SGEQRF, SORGQR and SORMQR. *> \endverbatim * * Arguments: * ========== * *> \param[in] DOTYPE *> \verbatim *> DOTYPE is LOGICAL array, dimension (NTYPES) *> The matrix types to be used for testing. Matrices of type j *> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = *> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. *> \endverbatim *> *> \param[in] NM *> \verbatim *> NM is INTEGER *> The number of values of M contained in the vector MVAL. *> \endverbatim *> *> \param[in] MVAL *> \verbatim *> MVAL is INTEGER array, dimension (NM) *> The values of the matrix row dimension M. *> \endverbatim *> *> \param[in] NN *> \verbatim *> NN is INTEGER *> The number of values of N contained in the vector NVAL. *> \endverbatim *> *> \param[in] NVAL *> \verbatim *> NVAL is INTEGER array, dimension (NN) *> The values of the matrix column dimension N. *> \endverbatim *> *> \param[in] NNB *> \verbatim *> NNB is INTEGER *> The number of values of NB and NX contained in the *> vectors NBVAL and NXVAL. The blocking parameters are used *> in pairs (NB,NX). *> \endverbatim *> *> \param[in] NBVAL *> \verbatim *> NBVAL is INTEGER array, dimension (NNB) *> The values of the blocksize NB. *> \endverbatim *> *> \param[in] NXVAL *> \verbatim *> NXVAL is INTEGER array, dimension (NNB) *> The values of the crossover point NX. *> \endverbatim *> *> \param[in] NRHS *> \verbatim *> NRHS is INTEGER *> The number of right hand side vectors to be generated for *> each linear system. *> \endverbatim *> *> \param[in] THRESH *> \verbatim *> THRESH is REAL *> The threshold value for the test ratios. A result is *> included in the output file if RESULT >= THRESH. To have *> every test ratio printed, use THRESH = 0. *> \endverbatim *> *> \param[in] TSTERR *> \verbatim *> TSTERR is LOGICAL *> Flag that indicates whether error exits are to be tested. *> \endverbatim *> *> \param[in] NMAX *> \verbatim *> NMAX is INTEGER *> The maximum value permitted for M or N, used in dimensioning *> the work arrays. *> \endverbatim *> *> \param[out] A *> \verbatim *> A is REAL array, dimension (NMAX*NMAX) *> \endverbatim *> *> \param[out] AF *> \verbatim *> AF is REAL array, dimension (NMAX*NMAX) *> \endverbatim *> *> \param[out] AQ *> \verbatim *> AQ is REAL array, dimension (NMAX*NMAX) *> \endverbatim *> *> \param[out] AR *> \verbatim *> AR is REAL array, dimension (NMAX*NMAX) *> \endverbatim *> *> \param[out] AC *> \verbatim *> AC is REAL array, dimension (NMAX*NMAX) *> \endverbatim *> *> \param[out] B *> \verbatim *> B is REAL array, dimension (NMAX*NRHS) *> \endverbatim *> *> \param[out] X *> \verbatim *> X is REAL array, dimension (NMAX*NRHS) *> \endverbatim *> *> \param[out] XACT *> \verbatim *> XACT is REAL array, dimension (NMAX*NRHS) *> \endverbatim *> *> \param[out] TAU *> \verbatim *> TAU is REAL array, dimension (NMAX) *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is REAL array, dimension (NMAX*NMAX) *> \endverbatim *> *> \param[out] RWORK *> \verbatim *> RWORK is REAL array, dimension (NMAX) *> \endverbatim *> *> \param[out] IWORK *> \verbatim *> IWORK is INTEGER array, dimension (NMAX) *> \endverbatim *> *> \param[in] NOUT *> \verbatim *> NOUT is INTEGER *> The unit number for output. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2015 * *> \ingroup single_lin * * ===================================================================== SUBROUTINE SCHKQR( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL, $ NRHS, THRESH, TSTERR, NMAX, A, AF, AQ, AR, AC, $ B, X, XACT, TAU, WORK, RWORK, IWORK, NOUT ) * * -- LAPACK test routine (version 3.6.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2015 * * .. Scalar Arguments .. LOGICAL TSTERR INTEGER NM, NMAX, NN, NNB, NOUT, NRHS REAL THRESH * .. * .. Array Arguments .. LOGICAL DOTYPE( * ) INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NVAL( * ), $ NXVAL( * ) REAL A( * ), AC( * ), AF( * ), AQ( * ), AR( * ), $ B( * ), RWORK( * ), TAU( * ), WORK( * ), $ X( * ), XACT( * ) * .. * * ===================================================================== * * .. Parameters .. INTEGER NTESTS PARAMETER ( NTESTS = 9 ) INTEGER NTYPES PARAMETER ( NTYPES = 8 ) REAL ZERO PARAMETER ( ZERO = 0.0E0 ) * .. * .. Local Scalars .. CHARACTER DIST, TYPE CHARACTER*3 PATH INTEGER I, IK, IM, IMAT, IN, INB, INFO, K, KL, KU, LDA, $ LWORK, M, MINMN, MODE, N, NB, NERRS, NFAIL, NK, $ NRUN, NT, NX REAL ANORM, CNDNUM * .. * .. Local Arrays .. INTEGER ISEED( 4 ), ISEEDY( 4 ), KVAL( 4 ) REAL RESULT( NTESTS ) * .. * .. External Functions .. LOGICAL SGENND EXTERNAL SGENND * .. * .. External Subroutines .. EXTERNAL ALAERH, ALAHD, ALASUM, SERRQR, SGEQRS, SGET02, $ SLACPY, SLARHS, SLATB4, SLATMS, SQRT01, $ SQRT01P, SQRT02, SQRT03, XLAENV * .. * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. * .. Scalars in Common .. LOGICAL LERR, OK CHARACTER*32 SRNAMT INTEGER INFOT, NUNIT * .. * .. Common blocks .. COMMON / INFOC / INFOT, NUNIT, OK, LERR COMMON / SRNAMC / SRNAMT * .. * .. Data statements .. DATA ISEEDY / 1988, 1989, 1990, 1991 / * .. * .. Executable Statements .. * * Initialize constants and the random number seed. * PATH( 1: 1 ) = 'Single precision' PATH( 2: 3 ) = 'QR' NRUN = 0 NFAIL = 0 NERRS = 0 DO 10 I = 1, 4 ISEED( I ) = ISEEDY( I ) 10 CONTINUE * * Test the error exits * IF( TSTERR ) $ CALL SERRQR( PATH, NOUT ) INFOT = 0 CALL XLAENV( 2, 2 ) * LDA = NMAX LWORK = NMAX*MAX( NMAX, NRHS ) * * Do for each value of M in MVAL. * DO 70 IM = 1, NM M = MVAL( IM ) * * Do for each value of N in NVAL. * DO 60 IN = 1, NN N = NVAL( IN ) MINMN = MIN( M, N ) DO 50 IMAT = 1, NTYPES * * Do the tests only if DOTYPE( IMAT ) is true. * IF( .NOT.DOTYPE( IMAT ) ) $ GO TO 50 * * Set up parameters with SLATB4 and generate a test matrix * with SLATMS. * CALL SLATB4( PATH, IMAT, M, N, TYPE, KL, KU, ANORM, MODE, $ CNDNUM, DIST ) * SRNAMT = 'SLATMS' CALL SLATMS( M, N, DIST, ISEED, TYPE, RWORK, MODE, $ CNDNUM, ANORM, KL, KU, 'No packing', A, LDA, $ WORK, INFO ) * * Check error code from SLATMS. * IF( INFO.NE.0 ) THEN CALL ALAERH( PATH, 'SLATMS', INFO, 0, ' ', M, N, -1, $ -1, -1, IMAT, NFAIL, NERRS, NOUT ) GO TO 50 END IF * * Set some values for K: the first value must be MINMN, * corresponding to the call of SQRT01; other values are * used in the calls of SQRT02, and must not exceed MINMN. * KVAL( 1 ) = MINMN KVAL( 2 ) = 0 KVAL( 3 ) = 1 KVAL( 4 ) = MINMN / 2 IF( MINMN.EQ.0 ) THEN NK = 1 ELSE IF( MINMN.EQ.1 ) THEN NK = 2 ELSE IF( MINMN.LE.3 ) THEN NK = 3 ELSE NK = 4 END IF * * Do for each value of K in KVAL * DO 40 IK = 1, NK K = KVAL( IK ) * * Do for each pair of values (NB,NX) in NBVAL and NXVAL. * DO 30 INB = 1, NNB NB = NBVAL( INB ) CALL XLAENV( 1, NB ) NX = NXVAL( INB ) CALL XLAENV( 3, NX ) DO I = 1, NTESTS RESULT( I ) = ZERO END DO NT = 2 IF( IK.EQ.1 ) THEN * * Test SGEQRF * CALL SQRT01( M, N, A, AF, AQ, AR, LDA, TAU, $ WORK, LWORK, RWORK, RESULT( 1 ) ) * * Test SGEQRFP * CALL SQRT01P( M, N, A, AF, AQ, AR, LDA, TAU, $ WORK, LWORK, RWORK, RESULT( 8 ) ) IF( .NOT. SGENND( M, N, AF, LDA ) ) $ RESULT( 9 ) = 2*THRESH NT = NT + 1 ELSE IF( M.GE.N ) THEN * * Test SORGQR, using factorization * returned by SQRT01 * CALL SQRT02( M, N, K, A, AF, AQ, AR, LDA, TAU, $ WORK, LWORK, RWORK, RESULT( 1 ) ) END IF IF( M.GE.K ) THEN * * Test SORMQR, using factorization returned * by SQRT01 * CALL SQRT03( M, N, K, AF, AC, AR, AQ, LDA, TAU, $ WORK, LWORK, RWORK, RESULT( 3 ) ) NT = NT + 4 * * If M>=N and K=N, call SGEQRS to solve a system * with NRHS right hand sides and compute the * residual. * IF( K.EQ.N .AND. INB.EQ.1 ) THEN * * Generate a solution and set the right * hand side. * SRNAMT = 'SLARHS' CALL SLARHS( PATH, 'New', 'Full', $ 'No transpose', M, N, 0, 0, $ NRHS, A, LDA, XACT, LDA, B, LDA, $ ISEED, INFO ) * CALL SLACPY( 'Full', M, NRHS, B, LDA, X, $ LDA ) SRNAMT = 'SGEQRS' CALL SGEQRS( M, N, NRHS, AF, LDA, TAU, X, $ LDA, WORK, LWORK, INFO ) * * Check error code from SGEQRS. * IF( INFO.NE.0 ) $ CALL ALAERH( PATH, 'SGEQRS', INFO, 0, ' ', $ M, N, NRHS, -1, NB, IMAT, $ NFAIL, NERRS, NOUT ) * CALL SGET02( 'No transpose', M, N, NRHS, A, $ LDA, X, LDA, B, LDA, RWORK, $ RESULT( 7 ) ) NT = NT + 1 END IF END IF * * Print information about the tests that did not * pass the threshold. * DO 20 I = 1, NTESTS IF( RESULT( I ).GE.THRESH ) THEN IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 ) $ CALL ALAHD( NOUT, PATH ) WRITE( NOUT, FMT = 9999 )M, N, K, NB, NX, $ IMAT, I, RESULT( I ) NFAIL = NFAIL + 1 END IF 20 CONTINUE NRUN = NRUN + NTESTS 30 CONTINUE 40 CONTINUE 50 CONTINUE 60 CONTINUE 70 CONTINUE * * Print a summary of the results. * CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS ) * 9999 FORMAT( ' M=', I5, ', N=', I5, ', K=', I5, ', NB=', I4, ', NX=', $ I5, ', type ', I2, ', test(', I2, ')=', G12.5 ) RETURN * * End of SCHKQR * END
bsd-3-clause
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/TESTING/EIG/dstt21.f
32
6540
*> \brief \b DSTT21 * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE DSTT21( N, KBAND, AD, AE, SD, SE, U, LDU, WORK, * RESULT ) * * .. Scalar Arguments .. * INTEGER KBAND, LDU, N * .. * .. Array Arguments .. * DOUBLE PRECISION AD( * ), AE( * ), RESULT( 2 ), SD( * ), * $ SE( * ), U( LDU, * ), WORK( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DSTT21 checks a decomposition of the form *> *> A = U S U' *> *> where ' means transpose, A is symmetric tridiagonal, U is orthogonal, *> and S is diagonal (if KBAND=0) or symmetric tridiagonal (if KBAND=1). *> Two tests are performed: *> *> RESULT(1) = | A - U S U' | / ( |A| n ulp ) *> *> RESULT(2) = | I - UU' | / ( n ulp ) *> \endverbatim * * Arguments: * ========== * *> \param[in] N *> \verbatim *> N is INTEGER *> The size of the matrix. If it is zero, DSTT21 does nothing. *> It must be at least zero. *> \endverbatim *> *> \param[in] KBAND *> \verbatim *> KBAND is INTEGER *> The bandwidth of the matrix S. It may only be zero or one. *> If zero, then S is diagonal, and SE is not referenced. If *> one, then S is symmetric tri-diagonal. *> \endverbatim *> *> \param[in] AD *> \verbatim *> AD is DOUBLE PRECISION array, dimension (N) *> The diagonal of the original (unfactored) matrix A. A is *> assumed to be symmetric tridiagonal. *> \endverbatim *> *> \param[in] AE *> \verbatim *> AE is DOUBLE PRECISION array, dimension (N-1) *> The off-diagonal of the original (unfactored) matrix A. A *> is assumed to be symmetric tridiagonal. AE(1) is the (1,2) *> and (2,1) element, AE(2) is the (2,3) and (3,2) element, etc. *> \endverbatim *> *> \param[in] SD *> \verbatim *> SD is DOUBLE PRECISION array, dimension (N) *> The diagonal of the (symmetric tri-) diagonal matrix S. *> \endverbatim *> *> \param[in] SE *> \verbatim *> SE is DOUBLE PRECISION array, dimension (N-1) *> The off-diagonal of the (symmetric tri-) diagonal matrix S. *> Not referenced if KBSND=0. If KBAND=1, then AE(1) is the *> (1,2) and (2,1) element, SE(2) is the (2,3) and (3,2) *> element, etc. *> \endverbatim *> *> \param[in] U *> \verbatim *> U is DOUBLE PRECISION array, dimension (LDU, N) *> The orthogonal matrix in the decomposition. *> \endverbatim *> *> \param[in] LDU *> \verbatim *> LDU is INTEGER *> The leading dimension of U. LDU must be at least N. *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is DOUBLE PRECISION array, dimension (N*(N+1)) *> \endverbatim *> *> \param[out] RESULT *> \verbatim *> RESULT is DOUBLE PRECISION array, dimension (2) *> The values computed by the two tests described above. The *> values are currently limited to 1/ulp, to avoid overflow. *> RESULT(1) is always modified. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup double_eig * * ===================================================================== SUBROUTINE DSTT21( N, KBAND, AD, AE, SD, SE, U, LDU, WORK, $ RESULT ) * * -- LAPACK test routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER KBAND, LDU, N * .. * .. Array Arguments .. DOUBLE PRECISION AD( * ), AE( * ), RESULT( 2 ), SD( * ), $ SE( * ), U( LDU, * ), WORK( * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 ) * .. * .. Local Scalars .. INTEGER J DOUBLE PRECISION ANORM, TEMP1, TEMP2, ULP, UNFL, WNORM * .. * .. External Functions .. DOUBLE PRECISION DLAMCH, DLANGE, DLANSY EXTERNAL DLAMCH, DLANGE, DLANSY * .. * .. External Subroutines .. EXTERNAL DGEMM, DLASET, DSYR, DSYR2 * .. * .. Intrinsic Functions .. INTRINSIC ABS, DBLE, MAX, MIN * .. * .. Executable Statements .. * * 1) Constants * RESULT( 1 ) = ZERO RESULT( 2 ) = ZERO IF( N.LE.0 ) $ RETURN * UNFL = DLAMCH( 'Safe minimum' ) ULP = DLAMCH( 'Precision' ) * * Do Test 1 * * Copy A & Compute its 1-Norm: * CALL DLASET( 'Full', N, N, ZERO, ZERO, WORK, N ) * ANORM = ZERO TEMP1 = ZERO * DO 10 J = 1, N - 1 WORK( ( N+1 )*( J-1 )+1 ) = AD( J ) WORK( ( N+1 )*( J-1 )+2 ) = AE( J ) TEMP2 = ABS( AE( J ) ) ANORM = MAX( ANORM, ABS( AD( J ) )+TEMP1+TEMP2 ) TEMP1 = TEMP2 10 CONTINUE * WORK( N**2 ) = AD( N ) ANORM = MAX( ANORM, ABS( AD( N ) )+TEMP1, UNFL ) * * Norm of A - USU' * DO 20 J = 1, N CALL DSYR( 'L', N, -SD( J ), U( 1, J ), 1, WORK, N ) 20 CONTINUE * IF( N.GT.1 .AND. KBAND.EQ.1 ) THEN DO 30 J = 1, N - 1 CALL DSYR2( 'L', N, -SE( J ), U( 1, J ), 1, U( 1, J+1 ), 1, $ WORK, N ) 30 CONTINUE END IF * WNORM = DLANSY( '1', 'L', N, WORK, N, WORK( N**2+1 ) ) * IF( ANORM.GT.WNORM ) THEN RESULT( 1 ) = ( WNORM / ANORM ) / ( N*ULP ) ELSE IF( ANORM.LT.ONE ) THEN RESULT( 1 ) = ( MIN( WNORM, N*ANORM ) / ANORM ) / ( N*ULP ) ELSE RESULT( 1 ) = MIN( WNORM / ANORM, DBLE( N ) ) / ( N*ULP ) END IF END IF * * Do Test 2 * * Compute UU' - I * CALL DGEMM( 'N', 'C', N, N, N, ONE, U, LDU, U, LDU, ZERO, WORK, $ N ) * DO 40 J = 1, N WORK( ( N+1 )*( J-1 )+1 ) = WORK( ( N+1 )*( J-1 )+1 ) - ONE 40 CONTINUE * RESULT( 2 ) = MIN( DBLE( N ), DLANGE( '1', N, N, WORK, N, $ WORK( N**2+1 ) ) ) / ( N*ULP ) * RETURN * * End of DSTT21 * END
bsd-3-clause
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/SRC/dpttrs.f
25
4877
*> \brief \b DPTTRS * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DPTTRS + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dpttrs.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dpttrs.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dpttrs.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DPTTRS( N, NRHS, D, E, B, LDB, INFO ) * * .. Scalar Arguments .. * INTEGER INFO, LDB, N, NRHS * .. * .. Array Arguments .. * DOUBLE PRECISION B( LDB, * ), D( * ), E( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DPTTRS solves a tridiagonal system of the form *> A * X = B *> using the L*D*L**T factorization of A computed by DPTTRF. D is a *> diagonal matrix specified in the vector D, L is a unit bidiagonal *> matrix whose subdiagonal is specified in the vector E, and X and B *> are N by NRHS matrices. *> \endverbatim * * Arguments: * ========== * *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the tridiagonal matrix A. N >= 0. *> \endverbatim *> *> \param[in] NRHS *> \verbatim *> NRHS is INTEGER *> The number of right hand sides, i.e., the number of columns *> of the matrix B. NRHS >= 0. *> \endverbatim *> *> \param[in] D *> \verbatim *> D is DOUBLE PRECISION array, dimension (N) *> The n diagonal elements of the diagonal matrix D from the *> L*D*L**T factorization of A. *> \endverbatim *> *> \param[in] E *> \verbatim *> E is DOUBLE PRECISION array, dimension (N-1) *> The (n-1) subdiagonal elements of the unit bidiagonal factor *> L from the L*D*L**T factorization of A. E can also be regarded *> as the superdiagonal of the unit bidiagonal factor U from the *> factorization A = U**T*D*U. *> \endverbatim *> *> \param[in,out] B *> \verbatim *> B is DOUBLE PRECISION array, dimension (LDB,NRHS) *> On entry, the right hand side vectors B for the system of *> linear equations. *> On exit, the solution vectors, X. *> \endverbatim *> *> \param[in] LDB *> \verbatim *> LDB is INTEGER *> The leading dimension of the array B. LDB >= max(1,N). *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -k, the k-th argument had an illegal value *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup doublePTcomputational * * ===================================================================== SUBROUTINE DPTTRS( N, NRHS, D, E, B, LDB, INFO ) * * -- LAPACK computational routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. INTEGER INFO, LDB, N, NRHS * .. * .. Array Arguments .. DOUBLE PRECISION B( LDB, * ), D( * ), E( * ) * .. * * ===================================================================== * * .. Local Scalars .. INTEGER J, JB, NB * .. * .. External Functions .. INTEGER ILAENV EXTERNAL ILAENV * .. * .. External Subroutines .. EXTERNAL DPTTS2, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. * .. Executable Statements .. * * Test the input arguments. * INFO = 0 IF( N.LT.0 ) THEN INFO = -1 ELSE IF( NRHS.LT.0 ) THEN INFO = -2 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN INFO = -6 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'DPTTRS', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 .OR. NRHS.EQ.0 ) $ RETURN * * Determine the number of right-hand sides to solve at a time. * IF( NRHS.EQ.1 ) THEN NB = 1 ELSE NB = MAX( 1, ILAENV( 1, 'DPTTRS', ' ', N, NRHS, -1, -1 ) ) END IF * IF( NB.GE.NRHS ) THEN CALL DPTTS2( N, NRHS, D, E, B, LDB ) ELSE DO 10 J = 1, NRHS, NB JB = MIN( NRHS-J+1, NB ) CALL DPTTS2( N, JB, D, E, B( 1, J ), LDB ) 10 CONTINUE END IF * RETURN * * End of DPTTRS * END
bsd-3-clause
shanzhenren/PLE
Model/eigen-3.2.5/lapack/dlarf.f
273
6167
*> \brief \b DLARF * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DLARF + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarf.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarf.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarf.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) * * .. Scalar Arguments .. * CHARACTER SIDE * INTEGER INCV, LDC, M, N * DOUBLE PRECISION TAU * .. * .. Array Arguments .. * DOUBLE PRECISION C( LDC, * ), V( * ), WORK( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DLARF applies a real elementary reflector H to a real m by n matrix *> C, from either the left or the right. H is represented in the form *> *> H = I - tau * v * v**T *> *> where tau is a real scalar and v is a real vector. *> *> If tau = 0, then H is taken to be the unit matrix. *> \endverbatim * * Arguments: * ========== * *> \param[in] SIDE *> \verbatim *> SIDE is CHARACTER*1 *> = 'L': form H * C *> = 'R': form C * H *> \endverbatim *> *> \param[in] M *> \verbatim *> M is INTEGER *> The number of rows of the matrix C. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of columns of the matrix C. *> \endverbatim *> *> \param[in] V *> \verbatim *> V is DOUBLE PRECISION array, dimension *> (1 + (M-1)*abs(INCV)) if SIDE = 'L' *> or (1 + (N-1)*abs(INCV)) if SIDE = 'R' *> The vector v in the representation of H. V is not used if *> TAU = 0. *> \endverbatim *> *> \param[in] INCV *> \verbatim *> INCV is INTEGER *> The increment between elements of v. INCV <> 0. *> \endverbatim *> *> \param[in] TAU *> \verbatim *> TAU is DOUBLE PRECISION *> The value tau in the representation of H. *> \endverbatim *> *> \param[in,out] C *> \verbatim *> C is DOUBLE PRECISION array, dimension (LDC,N) *> On entry, the m by n matrix C. *> On exit, C is overwritten by the matrix H * C if SIDE = 'L', *> or C * H if SIDE = 'R'. *> \endverbatim *> *> \param[in] LDC *> \verbatim *> LDC is INTEGER *> The leading dimension of the array C. LDC >= max(1,M). *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is DOUBLE PRECISION array, dimension *> (N) if SIDE = 'L' *> or (M) if SIDE = 'R' *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup doubleOTHERauxiliary * * ===================================================================== SUBROUTINE DLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) * * -- LAPACK auxiliary routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER SIDE INTEGER INCV, LDC, M, N DOUBLE PRECISION TAU * .. * .. Array Arguments .. DOUBLE PRECISION C( LDC, * ), V( * ), WORK( * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ONE, ZERO PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 ) * .. * .. Local Scalars .. LOGICAL APPLYLEFT INTEGER I, LASTV, LASTC * .. * .. External Subroutines .. EXTERNAL DGEMV, DGER * .. * .. External Functions .. LOGICAL LSAME INTEGER ILADLR, ILADLC EXTERNAL LSAME, ILADLR, ILADLC * .. * .. Executable Statements .. * APPLYLEFT = LSAME( SIDE, 'L' ) LASTV = 0 LASTC = 0 IF( TAU.NE.ZERO ) THEN ! Set up variables for scanning V. LASTV begins pointing to the end ! of V. IF( APPLYLEFT ) THEN LASTV = M ELSE LASTV = N END IF IF( INCV.GT.0 ) THEN I = 1 + (LASTV-1) * INCV ELSE I = 1 END IF ! Look for the last non-zero row in V. DO WHILE( LASTV.GT.0 .AND. V( I ).EQ.ZERO ) LASTV = LASTV - 1 I = I - INCV END DO IF( APPLYLEFT ) THEN ! Scan for the last non-zero column in C(1:lastv,:). LASTC = ILADLC(LASTV, N, C, LDC) ELSE ! Scan for the last non-zero row in C(:,1:lastv). LASTC = ILADLR(M, LASTV, C, LDC) END IF END IF ! Note that lastc.eq.0 renders the BLAS operations null; no special ! case is needed at this level. IF( APPLYLEFT ) THEN * * Form H * C * IF( LASTV.GT.0 ) THEN * * w(1:lastc,1) := C(1:lastv,1:lastc)**T * v(1:lastv,1) * CALL DGEMV( 'Transpose', LASTV, LASTC, ONE, C, LDC, V, INCV, $ ZERO, WORK, 1 ) * * C(1:lastv,1:lastc) := C(...) - v(1:lastv,1) * w(1:lastc,1)**T * CALL DGER( LASTV, LASTC, -TAU, V, INCV, WORK, 1, C, LDC ) END IF ELSE * * Form C * H * IF( LASTV.GT.0 ) THEN * * w(1:lastc,1) := C(1:lastc,1:lastv) * v(1:lastv,1) * CALL DGEMV( 'No transpose', LASTC, LASTV, ONE, C, LDC, $ V, INCV, ZERO, WORK, 1 ) * * C(1:lastc,1:lastv) := C(...) - w(1:lastc,1) * v(1:lastv,1)**T * CALL DGER( LASTC, LASTV, -TAU, WORK, 1, V, INCV, C, LDC ) END IF END IF RETURN * * End of DLARF * END
gpl-3.0
zakki/lsd_slam_windows
thirdparty/eigen-3.2.5/lapack/dlarf.f
273
6167
*> \brief \b DLARF * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DLARF + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarf.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarf.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarf.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) * * .. Scalar Arguments .. * CHARACTER SIDE * INTEGER INCV, LDC, M, N * DOUBLE PRECISION TAU * .. * .. Array Arguments .. * DOUBLE PRECISION C( LDC, * ), V( * ), WORK( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DLARF applies a real elementary reflector H to a real m by n matrix *> C, from either the left or the right. H is represented in the form *> *> H = I - tau * v * v**T *> *> where tau is a real scalar and v is a real vector. *> *> If tau = 0, then H is taken to be the unit matrix. *> \endverbatim * * Arguments: * ========== * *> \param[in] SIDE *> \verbatim *> SIDE is CHARACTER*1 *> = 'L': form H * C *> = 'R': form C * H *> \endverbatim *> *> \param[in] M *> \verbatim *> M is INTEGER *> The number of rows of the matrix C. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of columns of the matrix C. *> \endverbatim *> *> \param[in] V *> \verbatim *> V is DOUBLE PRECISION array, dimension *> (1 + (M-1)*abs(INCV)) if SIDE = 'L' *> or (1 + (N-1)*abs(INCV)) if SIDE = 'R' *> The vector v in the representation of H. V is not used if *> TAU = 0. *> \endverbatim *> *> \param[in] INCV *> \verbatim *> INCV is INTEGER *> The increment between elements of v. INCV <> 0. *> \endverbatim *> *> \param[in] TAU *> \verbatim *> TAU is DOUBLE PRECISION *> The value tau in the representation of H. *> \endverbatim *> *> \param[in,out] C *> \verbatim *> C is DOUBLE PRECISION array, dimension (LDC,N) *> On entry, the m by n matrix C. *> On exit, C is overwritten by the matrix H * C if SIDE = 'L', *> or C * H if SIDE = 'R'. *> \endverbatim *> *> \param[in] LDC *> \verbatim *> LDC is INTEGER *> The leading dimension of the array C. LDC >= max(1,M). *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is DOUBLE PRECISION array, dimension *> (N) if SIDE = 'L' *> or (M) if SIDE = 'R' *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup doubleOTHERauxiliary * * ===================================================================== SUBROUTINE DLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) * * -- LAPACK auxiliary routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER SIDE INTEGER INCV, LDC, M, N DOUBLE PRECISION TAU * .. * .. Array Arguments .. DOUBLE PRECISION C( LDC, * ), V( * ), WORK( * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ONE, ZERO PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 ) * .. * .. Local Scalars .. LOGICAL APPLYLEFT INTEGER I, LASTV, LASTC * .. * .. External Subroutines .. EXTERNAL DGEMV, DGER * .. * .. External Functions .. LOGICAL LSAME INTEGER ILADLR, ILADLC EXTERNAL LSAME, ILADLR, ILADLC * .. * .. Executable Statements .. * APPLYLEFT = LSAME( SIDE, 'L' ) LASTV = 0 LASTC = 0 IF( TAU.NE.ZERO ) THEN ! Set up variables for scanning V. LASTV begins pointing to the end ! of V. IF( APPLYLEFT ) THEN LASTV = M ELSE LASTV = N END IF IF( INCV.GT.0 ) THEN I = 1 + (LASTV-1) * INCV ELSE I = 1 END IF ! Look for the last non-zero row in V. DO WHILE( LASTV.GT.0 .AND. V( I ).EQ.ZERO ) LASTV = LASTV - 1 I = I - INCV END DO IF( APPLYLEFT ) THEN ! Scan for the last non-zero column in C(1:lastv,:). LASTC = ILADLC(LASTV, N, C, LDC) ELSE ! Scan for the last non-zero row in C(:,1:lastv). LASTC = ILADLR(M, LASTV, C, LDC) END IF END IF ! Note that lastc.eq.0 renders the BLAS operations null; no special ! case is needed at this level. IF( APPLYLEFT ) THEN * * Form H * C * IF( LASTV.GT.0 ) THEN * * w(1:lastc,1) := C(1:lastv,1:lastc)**T * v(1:lastv,1) * CALL DGEMV( 'Transpose', LASTV, LASTC, ONE, C, LDC, V, INCV, $ ZERO, WORK, 1 ) * * C(1:lastv,1:lastc) := C(...) - v(1:lastv,1) * w(1:lastc,1)**T * CALL DGER( LASTV, LASTC, -TAU, V, INCV, WORK, 1, C, LDC ) END IF ELSE * * Form C * H * IF( LASTV.GT.0 ) THEN * * w(1:lastc,1) := C(1:lastc,1:lastv) * v(1:lastv,1) * CALL DGEMV( 'No transpose', LASTC, LASTV, ONE, C, LDC, $ V, INCV, ZERO, WORK, 1 ) * * C(1:lastc,1:lastv) := C(...) - w(1:lastc,1) * v(1:lastv,1)**T * CALL DGER( LASTC, LASTV, -TAU, WORK, 1, V, INCV, C, LDC ) END IF END IF RETURN * * End of DLARF * END
gpl-3.0
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/SRC/stgsna.f
26
24172
*> \brief \b STGSNA * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download STGSNA + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/stgsna.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/stgsna.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/stgsna.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE STGSNA( JOB, HOWMNY, SELECT, N, A, LDA, B, LDB, VL, * LDVL, VR, LDVR, S, DIF, MM, M, WORK, LWORK, * IWORK, INFO ) * * .. Scalar Arguments .. * CHARACTER HOWMNY, JOB * INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, M, MM, N * .. * .. Array Arguments .. * LOGICAL SELECT( * ) * INTEGER IWORK( * ) * REAL A( LDA, * ), B( LDB, * ), DIF( * ), S( * ), * $ VL( LDVL, * ), VR( LDVR, * ), WORK( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> STGSNA estimates reciprocal condition numbers for specified *> eigenvalues and/or eigenvectors of a matrix pair (A, B) in *> generalized real Schur canonical form (or of any matrix pair *> (Q*A*Z**T, Q*B*Z**T) with orthogonal matrices Q and Z, where *> Z**T denotes the transpose of Z. *> *> (A, B) must be in generalized real Schur form (as returned by SGGES), *> i.e. A is block upper triangular with 1-by-1 and 2-by-2 diagonal *> blocks. B is upper triangular. *> *> \endverbatim * * Arguments: * ========== * *> \param[in] JOB *> \verbatim *> JOB is CHARACTER*1 *> Specifies whether condition numbers are required for *> eigenvalues (S) or eigenvectors (DIF): *> = 'E': for eigenvalues only (S); *> = 'V': for eigenvectors only (DIF); *> = 'B': for both eigenvalues and eigenvectors (S and DIF). *> \endverbatim *> *> \param[in] HOWMNY *> \verbatim *> HOWMNY is CHARACTER*1 *> = 'A': compute condition numbers for all eigenpairs; *> = 'S': compute condition numbers for selected eigenpairs *> specified by the array SELECT. *> \endverbatim *> *> \param[in] SELECT *> \verbatim *> SELECT is LOGICAL array, dimension (N) *> If HOWMNY = 'S', SELECT specifies the eigenpairs for which *> condition numbers are required. To select condition numbers *> for the eigenpair corresponding to a real eigenvalue w(j), *> SELECT(j) must be set to .TRUE.. To select condition numbers *> corresponding to a complex conjugate pair of eigenvalues w(j) *> and w(j+1), either SELECT(j) or SELECT(j+1) or both, must be *> set to .TRUE.. *> If HOWMNY = 'A', SELECT is not referenced. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the square matrix pair (A, B). N >= 0. *> \endverbatim *> *> \param[in] A *> \verbatim *> A is REAL array, dimension (LDA,N) *> The upper quasi-triangular matrix A in the pair (A,B). *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. LDA >= max(1,N). *> \endverbatim *> *> \param[in] B *> \verbatim *> B is REAL array, dimension (LDB,N) *> The upper triangular matrix B in the pair (A,B). *> \endverbatim *> *> \param[in] LDB *> \verbatim *> LDB is INTEGER *> The leading dimension of the array B. LDB >= max(1,N). *> \endverbatim *> *> \param[in] VL *> \verbatim *> VL is REAL array, dimension (LDVL,M) *> If JOB = 'E' or 'B', VL must contain left eigenvectors of *> (A, B), corresponding to the eigenpairs specified by HOWMNY *> and SELECT. The eigenvectors must be stored in consecutive *> columns of VL, as returned by STGEVC. *> If JOB = 'V', VL is not referenced. *> \endverbatim *> *> \param[in] LDVL *> \verbatim *> LDVL is INTEGER *> The leading dimension of the array VL. LDVL >= 1. *> If JOB = 'E' or 'B', LDVL >= N. *> \endverbatim *> *> \param[in] VR *> \verbatim *> VR is REAL array, dimension (LDVR,M) *> If JOB = 'E' or 'B', VR must contain right eigenvectors of *> (A, B), corresponding to the eigenpairs specified by HOWMNY *> and SELECT. The eigenvectors must be stored in consecutive *> columns ov VR, as returned by STGEVC. *> If JOB = 'V', VR is not referenced. *> \endverbatim *> *> \param[in] LDVR *> \verbatim *> LDVR is INTEGER *> The leading dimension of the array VR. LDVR >= 1. *> If JOB = 'E' or 'B', LDVR >= N. *> \endverbatim *> *> \param[out] S *> \verbatim *> S is REAL array, dimension (MM) *> If JOB = 'E' or 'B', the reciprocal condition numbers of the *> selected eigenvalues, stored in consecutive elements of the *> array. For a complex conjugate pair of eigenvalues two *> consecutive elements of S are set to the same value. Thus *> S(j), DIF(j), and the j-th columns of VL and VR all *> correspond to the same eigenpair (but not in general the *> j-th eigenpair, unless all eigenpairs are selected). *> If JOB = 'V', S is not referenced. *> \endverbatim *> *> \param[out] DIF *> \verbatim *> DIF is REAL array, dimension (MM) *> If JOB = 'V' or 'B', the estimated reciprocal condition *> numbers of the selected eigenvectors, stored in consecutive *> elements of the array. For a complex eigenvector two *> consecutive elements of DIF are set to the same value. If *> the eigenvalues cannot be reordered to compute DIF(j), DIF(j) *> is set to 0; this can only occur when the true value would be *> very small anyway. *> If JOB = 'E', DIF is not referenced. *> \endverbatim *> *> \param[in] MM *> \verbatim *> MM is INTEGER *> The number of elements in the arrays S and DIF. MM >= M. *> \endverbatim *> *> \param[out] M *> \verbatim *> M is INTEGER *> The number of elements of the arrays S and DIF used to store *> the specified condition numbers; for each selected real *> eigenvalue one element is used, and for each selected complex *> conjugate pair of eigenvalues, two elements are used. *> If HOWMNY = 'A', M is set to N. *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is REAL array, dimension (MAX(1,LWORK)) *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. *> \endverbatim *> *> \param[in] LWORK *> \verbatim *> LWORK is INTEGER *> The dimension of the array WORK. LWORK >= max(1,N). *> If JOB = 'V' or 'B' LWORK >= 2*N*(N+2)+16. *> *> If LWORK = -1, then a workspace query is assumed; the routine *> only calculates the optimal size of the WORK array, returns *> this value as the first entry of the WORK array, and no error *> message related to LWORK is issued by XERBLA. *> \endverbatim *> *> \param[out] IWORK *> \verbatim *> IWORK is INTEGER array, dimension (N + 6) *> If JOB = 'E', IWORK is not referenced. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> =0: Successful exit *> <0: If INFO = -i, the i-th argument had an illegal value *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup realOTHERcomputational * *> \par Further Details: * ===================== *> *> \verbatim *> *> The reciprocal of the condition number of a generalized eigenvalue *> w = (a, b) is defined as *> *> S(w) = (|u**TAv|**2 + |u**TBv|**2)**(1/2) / (norm(u)*norm(v)) *> *> where u and v are the left and right eigenvectors of (A, B) *> corresponding to w; |z| denotes the absolute value of the complex *> number, and norm(u) denotes the 2-norm of the vector u. *> The pair (a, b) corresponds to an eigenvalue w = a/b (= u**TAv/u**TBv) *> of the matrix pair (A, B). If both a and b equal zero, then (A B) is *> singular and S(I) = -1 is returned. *> *> An approximate error bound on the chordal distance between the i-th *> computed generalized eigenvalue w and the corresponding exact *> eigenvalue lambda is *> *> chord(w, lambda) <= EPS * norm(A, B) / S(I) *> *> where EPS is the machine precision. *> *> The reciprocal of the condition number DIF(i) of right eigenvector u *> and left eigenvector v corresponding to the generalized eigenvalue w *> is defined as follows: *> *> a) If the i-th eigenvalue w = (a,b) is real *> *> Suppose U and V are orthogonal transformations such that *> *> U**T*(A, B)*V = (S, T) = ( a * ) ( b * ) 1 *> ( 0 S22 ),( 0 T22 ) n-1 *> 1 n-1 1 n-1 *> *> Then the reciprocal condition number DIF(i) is *> *> Difl((a, b), (S22, T22)) = sigma-min( Zl ), *> *> where sigma-min(Zl) denotes the smallest singular value of the *> 2(n-1)-by-2(n-1) matrix *> *> Zl = [ kron(a, In-1) -kron(1, S22) ] *> [ kron(b, In-1) -kron(1, T22) ] . *> *> Here In-1 is the identity matrix of size n-1. kron(X, Y) is the *> Kronecker product between the matrices X and Y. *> *> Note that if the default method for computing DIF(i) is wanted *> (see SLATDF), then the parameter DIFDRI (see below) should be *> changed from 3 to 4 (routine SLATDF(IJOB = 2 will be used)). *> See STGSYL for more details. *> *> b) If the i-th and (i+1)-th eigenvalues are complex conjugate pair, *> *> Suppose U and V are orthogonal transformations such that *> *> U**T*(A, B)*V = (S, T) = ( S11 * ) ( T11 * ) 2 *> ( 0 S22 ),( 0 T22) n-2 *> 2 n-2 2 n-2 *> *> and (S11, T11) corresponds to the complex conjugate eigenvalue *> pair (w, conjg(w)). There exist unitary matrices U1 and V1 such *> that *> *> U1**T*S11*V1 = ( s11 s12 ) and U1**T*T11*V1 = ( t11 t12 ) *> ( 0 s22 ) ( 0 t22 ) *> *> where the generalized eigenvalues w = s11/t11 and *> conjg(w) = s22/t22. *> *> Then the reciprocal condition number DIF(i) is bounded by *> *> min( d1, max( 1, |real(s11)/real(s22)| )*d2 ) *> *> where, d1 = Difl((s11, t11), (s22, t22)) = sigma-min(Z1), where *> Z1 is the complex 2-by-2 matrix *> *> Z1 = [ s11 -s22 ] *> [ t11 -t22 ], *> *> This is done by computing (using real arithmetic) the *> roots of the characteristical polynomial det(Z1**T * Z1 - lambda I), *> where Z1**T denotes the transpose of Z1 and det(X) denotes *> the determinant of X. *> *> and d2 is an upper bound on Difl((S11, T11), (S22, T22)), i.e. an *> upper bound on sigma-min(Z2), where Z2 is (2n-2)-by-(2n-2) *> *> Z2 = [ kron(S11**T, In-2) -kron(I2, S22) ] *> [ kron(T11**T, In-2) -kron(I2, T22) ] *> *> Note that if the default method for computing DIF is wanted (see *> SLATDF), then the parameter DIFDRI (see below) should be changed *> from 3 to 4 (routine SLATDF(IJOB = 2 will be used)). See STGSYL *> for more details. *> *> For each eigenvalue/vector specified by SELECT, DIF stores a *> Frobenius norm-based estimate of Difl. *> *> An approximate error bound for the i-th computed eigenvector VL(i) or *> VR(i) is given by *> *> EPS * norm(A, B) / DIF(i). *> *> See ref. [2-3] for more details and further references. *> \endverbatim * *> \par Contributors: * ================== *> *> Bo Kagstrom and Peter Poromaa, Department of Computing Science, *> Umea University, S-901 87 Umea, Sweden. * *> \par References: * ================ *> *> \verbatim *> *> [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the *> Generalized Real Schur Form of a Regular Matrix Pair (A, B), in *> M.S. Moonen et al (eds), Linear Algebra for Large Scale and *> Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218. *> *> [2] B. Kagstrom and P. Poromaa; Computing Eigenspaces with Specified *> Eigenvalues of a Regular Matrix Pair (A, B) and Condition *> Estimation: Theory, Algorithms and Software, *> Report UMINF - 94.04, Department of Computing Science, Umea *> University, S-901 87 Umea, Sweden, 1994. Also as LAPACK Working *> Note 87. To appear in Numerical Algorithms, 1996. *> *> [3] B. Kagstrom and P. Poromaa, LAPACK-Style Algorithms and Software *> for Solving the Generalized Sylvester Equation and Estimating the *> Separation between Regular Matrix Pairs, Report UMINF - 93.23, *> Department of Computing Science, Umea University, S-901 87 Umea, *> Sweden, December 1993, Revised April 1994, Also as LAPACK Working *> Note 75. To appear in ACM Trans. on Math. Software, Vol 22, *> No 1, 1996. *> \endverbatim *> * ===================================================================== SUBROUTINE STGSNA( JOB, HOWMNY, SELECT, N, A, LDA, B, LDB, VL, $ LDVL, VR, LDVR, S, DIF, MM, M, WORK, LWORK, $ IWORK, INFO ) * * -- LAPACK computational routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER HOWMNY, JOB INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, M, MM, N * .. * .. Array Arguments .. LOGICAL SELECT( * ) INTEGER IWORK( * ) REAL A( LDA, * ), B( LDB, * ), DIF( * ), S( * ), $ VL( LDVL, * ), VR( LDVR, * ), WORK( * ) * .. * * ===================================================================== * * .. Parameters .. INTEGER DIFDRI PARAMETER ( DIFDRI = 3 ) REAL ZERO, ONE, TWO, FOUR PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0, $ FOUR = 4.0E+0 ) * .. * .. Local Scalars .. LOGICAL LQUERY, PAIR, SOMCON, WANTBH, WANTDF, WANTS INTEGER I, IERR, IFST, ILST, IZ, K, KS, LWMIN, N1, N2 REAL ALPHAI, ALPHAR, ALPRQT, BETA, C1, C2, COND, $ EPS, LNRM, RNRM, ROOT1, ROOT2, SCALE, SMLNUM, $ TMPII, TMPIR, TMPRI, TMPRR, UHAV, UHAVI, UHBV, $ UHBVI * .. * .. Local Arrays .. REAL DUMMY( 1 ), DUMMY1( 1 ) * .. * .. External Functions .. LOGICAL LSAME REAL SDOT, SLAMCH, SLAPY2, SNRM2 EXTERNAL LSAME, SDOT, SLAMCH, SLAPY2, SNRM2 * .. * .. External Subroutines .. EXTERNAL SGEMV, SLACPY, SLAG2, STGEXC, STGSYL, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX, MIN, SQRT * .. * .. Executable Statements .. * * Decode and test the input parameters * WANTBH = LSAME( JOB, 'B' ) WANTS = LSAME( JOB, 'E' ) .OR. WANTBH WANTDF = LSAME( JOB, 'V' ) .OR. WANTBH * SOMCON = LSAME( HOWMNY, 'S' ) * INFO = 0 LQUERY = ( LWORK.EQ.-1 ) * IF( .NOT.WANTS .AND. .NOT.WANTDF ) THEN INFO = -1 ELSE IF( .NOT.LSAME( HOWMNY, 'A' ) .AND. .NOT.SOMCON ) THEN INFO = -2 ELSE IF( N.LT.0 ) THEN INFO = -4 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN INFO = -6 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN INFO = -8 ELSE IF( WANTS .AND. LDVL.LT.N ) THEN INFO = -10 ELSE IF( WANTS .AND. LDVR.LT.N ) THEN INFO = -12 ELSE * * Set M to the number of eigenpairs for which condition numbers * are required, and test MM. * IF( SOMCON ) THEN M = 0 PAIR = .FALSE. DO 10 K = 1, N IF( PAIR ) THEN PAIR = .FALSE. ELSE IF( K.LT.N ) THEN IF( A( K+1, K ).EQ.ZERO ) THEN IF( SELECT( K ) ) $ M = M + 1 ELSE PAIR = .TRUE. IF( SELECT( K ) .OR. SELECT( K+1 ) ) $ M = M + 2 END IF ELSE IF( SELECT( N ) ) $ M = M + 1 END IF END IF 10 CONTINUE ELSE M = N END IF * IF( N.EQ.0 ) THEN LWMIN = 1 ELSE IF( LSAME( JOB, 'V' ) .OR. LSAME( JOB, 'B' ) ) THEN LWMIN = 2*N*( N + 2 ) + 16 ELSE LWMIN = N END IF WORK( 1 ) = LWMIN * IF( MM.LT.M ) THEN INFO = -15 ELSE IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN INFO = -18 END IF END IF * IF( INFO.NE.0 ) THEN CALL XERBLA( 'STGSNA', -INFO ) RETURN ELSE IF( LQUERY ) THEN RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * * Get machine constants * EPS = SLAMCH( 'P' ) SMLNUM = SLAMCH( 'S' ) / EPS KS = 0 PAIR = .FALSE. * DO 20 K = 1, N * * Determine whether A(k,k) begins a 1-by-1 or 2-by-2 block. * IF( PAIR ) THEN PAIR = .FALSE. GO TO 20 ELSE IF( K.LT.N ) $ PAIR = A( K+1, K ).NE.ZERO END IF * * Determine whether condition numbers are required for the k-th * eigenpair. * IF( SOMCON ) THEN IF( PAIR ) THEN IF( .NOT.SELECT( K ) .AND. .NOT.SELECT( K+1 ) ) $ GO TO 20 ELSE IF( .NOT.SELECT( K ) ) $ GO TO 20 END IF END IF * KS = KS + 1 * IF( WANTS ) THEN * * Compute the reciprocal condition number of the k-th * eigenvalue. * IF( PAIR ) THEN * * Complex eigenvalue pair. * RNRM = SLAPY2( SNRM2( N, VR( 1, KS ), 1 ), $ SNRM2( N, VR( 1, KS+1 ), 1 ) ) LNRM = SLAPY2( SNRM2( N, VL( 1, KS ), 1 ), $ SNRM2( N, VL( 1, KS+1 ), 1 ) ) CALL SGEMV( 'N', N, N, ONE, A, LDA, VR( 1, KS ), 1, ZERO, $ WORK, 1 ) TMPRR = SDOT( N, WORK, 1, VL( 1, KS ), 1 ) TMPRI = SDOT( N, WORK, 1, VL( 1, KS+1 ), 1 ) CALL SGEMV( 'N', N, N, ONE, A, LDA, VR( 1, KS+1 ), 1, $ ZERO, WORK, 1 ) TMPII = SDOT( N, WORK, 1, VL( 1, KS+1 ), 1 ) TMPIR = SDOT( N, WORK, 1, VL( 1, KS ), 1 ) UHAV = TMPRR + TMPII UHAVI = TMPIR - TMPRI CALL SGEMV( 'N', N, N, ONE, B, LDB, VR( 1, KS ), 1, ZERO, $ WORK, 1 ) TMPRR = SDOT( N, WORK, 1, VL( 1, KS ), 1 ) TMPRI = SDOT( N, WORK, 1, VL( 1, KS+1 ), 1 ) CALL SGEMV( 'N', N, N, ONE, B, LDB, VR( 1, KS+1 ), 1, $ ZERO, WORK, 1 ) TMPII = SDOT( N, WORK, 1, VL( 1, KS+1 ), 1 ) TMPIR = SDOT( N, WORK, 1, VL( 1, KS ), 1 ) UHBV = TMPRR + TMPII UHBVI = TMPIR - TMPRI UHAV = SLAPY2( UHAV, UHAVI ) UHBV = SLAPY2( UHBV, UHBVI ) COND = SLAPY2( UHAV, UHBV ) S( KS ) = COND / ( RNRM*LNRM ) S( KS+1 ) = S( KS ) * ELSE * * Real eigenvalue. * RNRM = SNRM2( N, VR( 1, KS ), 1 ) LNRM = SNRM2( N, VL( 1, KS ), 1 ) CALL SGEMV( 'N', N, N, ONE, A, LDA, VR( 1, KS ), 1, ZERO, $ WORK, 1 ) UHAV = SDOT( N, WORK, 1, VL( 1, KS ), 1 ) CALL SGEMV( 'N', N, N, ONE, B, LDB, VR( 1, KS ), 1, ZERO, $ WORK, 1 ) UHBV = SDOT( N, WORK, 1, VL( 1, KS ), 1 ) COND = SLAPY2( UHAV, UHBV ) IF( COND.EQ.ZERO ) THEN S( KS ) = -ONE ELSE S( KS ) = COND / ( RNRM*LNRM ) END IF END IF END IF * IF( WANTDF ) THEN IF( N.EQ.1 ) THEN DIF( KS ) = SLAPY2( A( 1, 1 ), B( 1, 1 ) ) GO TO 20 END IF * * Estimate the reciprocal condition number of the k-th * eigenvectors. IF( PAIR ) THEN * * Copy the 2-by 2 pencil beginning at (A(k,k), B(k, k)). * Compute the eigenvalue(s) at position K. * WORK( 1 ) = A( K, K ) WORK( 2 ) = A( K+1, K ) WORK( 3 ) = A( K, K+1 ) WORK( 4 ) = A( K+1, K+1 ) WORK( 5 ) = B( K, K ) WORK( 6 ) = B( K+1, K ) WORK( 7 ) = B( K, K+1 ) WORK( 8 ) = B( K+1, K+1 ) CALL SLAG2( WORK, 2, WORK( 5 ), 2, SMLNUM*EPS, BETA, $ DUMMY1( 1 ), ALPHAR, DUMMY( 1 ), ALPHAI ) ALPRQT = ONE C1 = TWO*( ALPHAR*ALPHAR+ALPHAI*ALPHAI+BETA*BETA ) C2 = FOUR*BETA*BETA*ALPHAI*ALPHAI ROOT1 = C1 + SQRT( C1*C1-4.0*C2 ) ROOT2 = C2 / ROOT1 ROOT1 = ROOT1 / TWO COND = MIN( SQRT( ROOT1 ), SQRT( ROOT2 ) ) END IF * * Copy the matrix (A, B) to the array WORK and swap the * diagonal block beginning at A(k,k) to the (1,1) position. * CALL SLACPY( 'Full', N, N, A, LDA, WORK, N ) CALL SLACPY( 'Full', N, N, B, LDB, WORK( N*N+1 ), N ) IFST = K ILST = 1 * CALL STGEXC( .FALSE., .FALSE., N, WORK, N, WORK( N*N+1 ), N, $ DUMMY, 1, DUMMY1, 1, IFST, ILST, $ WORK( N*N*2+1 ), LWORK-2*N*N, IERR ) * IF( IERR.GT.0 ) THEN * * Ill-conditioned problem - swap rejected. * DIF( KS ) = ZERO ELSE * * Reordering successful, solve generalized Sylvester * equation for R and L, * A22 * R - L * A11 = A12 * B22 * R - L * B11 = B12, * and compute estimate of Difl((A11,B11), (A22, B22)). * N1 = 1 IF( WORK( 2 ).NE.ZERO ) $ N1 = 2 N2 = N - N1 IF( N2.EQ.0 ) THEN DIF( KS ) = COND ELSE I = N*N + 1 IZ = 2*N*N + 1 CALL STGSYL( 'N', DIFDRI, N2, N1, WORK( N*N1+N1+1 ), $ N, WORK, N, WORK( N1+1 ), N, $ WORK( N*N1+N1+I ), N, WORK( I ), N, $ WORK( N1+I ), N, SCALE, DIF( KS ), $ WORK( IZ+1 ), LWORK-2*N*N, IWORK, IERR ) * IF( PAIR ) $ DIF( KS ) = MIN( MAX( ONE, ALPRQT )*DIF( KS ), $ COND ) END IF END IF IF( PAIR ) $ DIF( KS+1 ) = DIF( KS ) END IF IF( PAIR ) $ KS = KS + 1 * 20 CONTINUE WORK( 1 ) = LWMIN RETURN * * End of STGSNA * END
bsd-3-clause
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/reference/zsbmvf.f
50
9642
SUBROUTINE ZSBMVF(UPLO, N, K, ALPHA, A, LDA, X, INCX, BETA, Y, $ INCY ) * * -- LAPACK auxiliary routine (version 3.1) -- * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. * November 2006 * * .. Scalar Arguments .. CHARACTER UPLO INTEGER INCX, INCY, K, LDA, N COMPLEX*16 ALPHA, BETA * .. * .. Array Arguments .. COMPLEX*16 A( LDA, * ), X( * ), Y( * ) * .. * * Purpose * ======= * * ZSBMV performs the matrix-vector operation * * y := alpha*A*x + beta*y, * * where alpha and beta are scalars, x and y are n element vectors and * A is an n by n symmetric band matrix, with k super-diagonals. * * Arguments * ========== * * UPLO - CHARACTER*1 * On entry, UPLO specifies whether the upper or lower * triangular part of the band matrix A is being supplied as * follows: * * UPLO = 'U' or 'u' The upper triangular part of A is * being supplied. * * UPLO = 'L' or 'l' The lower triangular part of A is * being supplied. * * Unchanged on exit. * * N - INTEGER * On entry, N specifies the order of the matrix A. * N must be at least zero. * Unchanged on exit. * * K - INTEGER * On entry, K specifies the number of super-diagonals of the * matrix A. K must satisfy 0 .le. K. * Unchanged on exit. * * ALPHA - COMPLEX*16 * On entry, ALPHA specifies the scalar alpha. * Unchanged on exit. * * A - COMPLEX*16 array, dimension( LDA, N ) * Before entry with UPLO = 'U' or 'u', the leading ( k + 1 ) * by n part of the array A must contain the upper triangular * band part of the symmetric matrix, supplied column by * column, with the leading diagonal of the matrix in row * ( k + 1 ) of the array, the first super-diagonal starting at * position 2 in row k, and so on. The top left k by k triangle * of the array A is not referenced. * The following program segment will transfer the upper * triangular part of a symmetric band matrix from conventional * full matrix storage to band storage: * * DO 20, J = 1, N * M = K + 1 - J * DO 10, I = MAX( 1, J - K ), J * A( M + I, J ) = matrix( I, J ) * 10 CONTINUE * 20 CONTINUE * * Before entry with UPLO = 'L' or 'l', the leading ( k + 1 ) * by n part of the array A must contain the lower triangular * band part of the symmetric matrix, supplied column by * column, with the leading diagonal of the matrix in row 1 of * the array, the first sub-diagonal starting at position 1 in * row 2, and so on. The bottom right k by k triangle of the * array A is not referenced. * The following program segment will transfer the lower * triangular part of a symmetric band matrix from conventional * full matrix storage to band storage: * * DO 20, J = 1, N * M = 1 - J * DO 10, I = J, MIN( N, J + K ) * A( M + I, J ) = matrix( I, J ) * 10 CONTINUE * 20 CONTINUE * * Unchanged on exit. * * LDA - INTEGER * On entry, LDA specifies the first dimension of A as declared * in the calling (sub) program. LDA must be at least * ( k + 1 ). * Unchanged on exit. * * X - COMPLEX*16 array, dimension at least * ( 1 + ( N - 1 )*abs( INCX ) ). * Before entry, the incremented array X must contain the * vector x. * Unchanged on exit. * * INCX - INTEGER * On entry, INCX specifies the increment for the elements of * X. INCX must not be zero. * Unchanged on exit. * * BETA - COMPLEX*16 * On entry, BETA specifies the scalar beta. * Unchanged on exit. * * Y - COMPLEX*16 array, dimension at least * ( 1 + ( N - 1 )*abs( INCY ) ). * Before entry, the incremented array Y must contain the * vector y. On exit, Y is overwritten by the updated vector y. * * INCY - INTEGER * On entry, INCY specifies the increment for the elements of * Y. INCY must not be zero. * Unchanged on exit. * * ===================================================================== * * .. Parameters .. COMPLEX*16 ONE PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) ) COMPLEX*16 ZERO PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) ) * .. * .. Local Scalars .. INTEGER I, INFO, IX, IY, J, JX, JY, KPLUS1, KX, KY, L COMPLEX*16 TEMP1, TEMP2 * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN INFO = 1 ELSE IF( N.LT.0 ) THEN INFO = 2 ELSE IF( K.LT.0 ) THEN INFO = 3 ELSE IF( LDA.LT.( K+1 ) ) THEN INFO = 6 ELSE IF( INCX.EQ.0 ) THEN INFO = 8 ELSE IF( INCY.EQ.0 ) THEN INFO = 11 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'ZSBMV ', INFO ) RETURN END IF * * Quick return if possible. * IF( ( N.EQ.0 ) .OR. ( ( ALPHA.EQ.ZERO ) .AND. ( BETA.EQ.ONE ) ) ) $ RETURN * * Set up the start points in X and Y. * IF( INCX.GT.0 ) THEN KX = 1 ELSE KX = 1 - ( N-1 )*INCX END IF IF( INCY.GT.0 ) THEN KY = 1 ELSE KY = 1 - ( N-1 )*INCY END IF * * Start the operations. In this version the elements of the array A * are accessed sequentially with one pass through A. * * First form y := beta*y. * IF( BETA.NE.ONE ) THEN IF( INCY.EQ.1 ) THEN IF( BETA.EQ.ZERO ) THEN DO 10 I = 1, N Y( I ) = ZERO 10 CONTINUE ELSE DO 20 I = 1, N Y( I ) = BETA*Y( I ) 20 CONTINUE END IF ELSE IY = KY IF( BETA.EQ.ZERO ) THEN DO 30 I = 1, N Y( IY ) = ZERO IY = IY + INCY 30 CONTINUE ELSE DO 40 I = 1, N Y( IY ) = BETA*Y( IY ) IY = IY + INCY 40 CONTINUE END IF END IF END IF IF( ALPHA.EQ.ZERO ) $ RETURN IF( LSAME( UPLO, 'U' ) ) THEN * * Form y when upper triangle of A is stored. * KPLUS1 = K + 1 IF( ( INCX.EQ.1 ) .AND. ( INCY.EQ.1 ) ) THEN DO 60 J = 1, N TEMP1 = ALPHA*X( J ) TEMP2 = ZERO L = KPLUS1 - J DO 50 I = MAX( 1, J-K ), J - 1 Y( I ) = Y( I ) + TEMP1*A( L+I, J ) TEMP2 = TEMP2 + A( L+I, J )*X( I ) 50 CONTINUE Y( J ) = Y( J ) + TEMP1*A( KPLUS1, J ) + ALPHA*TEMP2 60 CONTINUE ELSE JX = KX JY = KY DO 80 J = 1, N TEMP1 = ALPHA*X( JX ) TEMP2 = ZERO IX = KX IY = KY L = KPLUS1 - J DO 70 I = MAX( 1, J-K ), J - 1 Y( IY ) = Y( IY ) + TEMP1*A( L+I, J ) TEMP2 = TEMP2 + A( L+I, J )*X( IX ) IX = IX + INCX IY = IY + INCY 70 CONTINUE Y( JY ) = Y( JY ) + TEMP1*A( KPLUS1, J ) + ALPHA*TEMP2 JX = JX + INCX JY = JY + INCY IF( J.GT.K ) THEN KX = KX + INCX KY = KY + INCY END IF 80 CONTINUE END IF ELSE * * Form y when lower triangle of A is stored. * IF( ( INCX.EQ.1 ) .AND. ( INCY.EQ.1 ) ) THEN DO 100 J = 1, N TEMP1 = ALPHA*X( J ) TEMP2 = ZERO Y( J ) = Y( J ) + TEMP1*A( 1, J ) L = 1 - J DO 90 I = J + 1, MIN( N, J+K ) Y( I ) = Y( I ) + TEMP1*A( L+I, J ) TEMP2 = TEMP2 + A( L+I, J )*X( I ) 90 CONTINUE Y( J ) = Y( J ) + ALPHA*TEMP2 100 CONTINUE ELSE JX = KX JY = KY DO 120 J = 1, N TEMP1 = ALPHA*X( JX ) TEMP2 = ZERO Y( JY ) = Y( JY ) + TEMP1*A( 1, J ) L = 1 - J IX = JX IY = JY DO 110 I = J + 1, MIN( N, J+K ) IX = IX + INCX IY = IY + INCY Y( IY ) = Y( IY ) + TEMP1*A( L+I, J ) TEMP2 = TEMP2 + A( L+I, J )*X( IX ) 110 CONTINUE Y( JY ) = Y( JY ) + ALPHA*TEMP2 JX = JX + INCX JY = JY + INCY 120 CONTINUE END IF END IF * RETURN * * End of ZSBMV * END
bsd-3-clause
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/SRC/DEPRECATED/dtzrqf.f
24
6691
*> \brief \b DTZRQF * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DTZRQF + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtzrqf.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtzrqf.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtzrqf.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DTZRQF( M, N, A, LDA, TAU, INFO ) * * .. Scalar Arguments .. * INTEGER INFO, LDA, M, N * .. * .. Array Arguments .. * DOUBLE PRECISION A( LDA, * ), TAU( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> This routine is deprecated and has been replaced by routine DTZRZF. *> *> DTZRQF reduces the M-by-N ( M<=N ) real upper trapezoidal matrix A *> to upper triangular form by means of orthogonal transformations. *> *> The upper trapezoidal matrix A is factored as *> *> A = ( R 0 ) * Z, *> *> where Z is an N-by-N orthogonal matrix and R is an M-by-M upper *> triangular matrix. *> \endverbatim * * Arguments: * ========== * *> \param[in] M *> \verbatim *> M is INTEGER *> The number of rows of the matrix A. M >= 0. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of columns of the matrix A. N >= M. *> \endverbatim *> *> \param[in,out] A *> \verbatim *> A is DOUBLE PRECISION array, dimension (LDA,N) *> On entry, the leading M-by-N upper trapezoidal part of the *> array A must contain the matrix to be factorized. *> On exit, the leading M-by-M upper triangular part of A *> contains the upper triangular matrix R, and elements M+1 to *> N of the first M rows of A, with the array TAU, represent the *> orthogonal matrix Z as a product of M elementary reflectors. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. LDA >= max(1,M). *> \endverbatim *> *> \param[out] TAU *> \verbatim *> TAU is DOUBLE PRECISION array, dimension (M) *> The scalar factors of the elementary reflectors. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup doubleOTHERcomputational * *> \par Further Details: * ===================== *> *> \verbatim *> *> The factorization is obtained by Householder's method. The kth *> transformation matrix, Z( k ), which is used to introduce zeros into *> the ( m - k + 1 )th row of A, is given in the form *> *> Z( k ) = ( I 0 ), *> ( 0 T( k ) ) *> *> where *> *> T( k ) = I - tau*u( k )*u( k )**T, u( k ) = ( 1 ), *> ( 0 ) *> ( z( k ) ) *> *> tau is a scalar and z( k ) is an ( n - m ) element vector. *> tau and z( k ) are chosen to annihilate the elements of the kth row *> of X. *> *> The scalar tau is returned in the kth element of TAU and the vector *> u( k ) in the kth row of A, such that the elements of z( k ) are *> in a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in *> the upper triangular part of A. *> *> Z is given by *> *> Z = Z( 1 ) * Z( 2 ) * ... * Z( m ). *> \endverbatim *> * ===================================================================== SUBROUTINE DTZRQF( M, N, A, LDA, TAU, INFO ) * * -- LAPACK computational routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER INFO, LDA, M, N * .. * .. Array Arguments .. DOUBLE PRECISION A( LDA, * ), TAU( * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ONE, ZERO PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 ) * .. * .. Local Scalars .. INTEGER I, K, M1 * .. * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. * .. External Subroutines .. EXTERNAL DAXPY, DCOPY, DGEMV, DGER, DLARFG, XERBLA * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 IF( M.LT.0 ) THEN INFO = -1 ELSE IF( N.LT.M ) THEN INFO = -2 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN INFO = -4 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'DTZRQF', -INFO ) RETURN END IF * * Perform the factorization. * IF( M.EQ.0 ) $ RETURN IF( M.EQ.N ) THEN DO 10 I = 1, N TAU( I ) = ZERO 10 CONTINUE ELSE M1 = MIN( M+1, N ) DO 20 K = M, 1, -1 * * Use a Householder reflection to zero the kth row of A. * First set up the reflection. * CALL DLARFG( N-M+1, A( K, K ), A( K, M1 ), LDA, TAU( K ) ) * IF( ( TAU( K ).NE.ZERO ) .AND. ( K.GT.1 ) ) THEN * * We now perform the operation A := A*P( k ). * * Use the first ( k - 1 ) elements of TAU to store a( k ), * where a( k ) consists of the first ( k - 1 ) elements of * the kth column of A. Also let B denote the first * ( k - 1 ) rows of the last ( n - m ) columns of A. * CALL DCOPY( K-1, A( 1, K ), 1, TAU, 1 ) * * Form w = a( k ) + B*z( k ) in TAU. * CALL DGEMV( 'No transpose', K-1, N-M, ONE, A( 1, M1 ), $ LDA, A( K, M1 ), LDA, ONE, TAU, 1 ) * * Now form a( k ) := a( k ) - tau*w * and B := B - tau*w*z( k )**T. * CALL DAXPY( K-1, -TAU( K ), TAU, 1, A( 1, K ), 1 ) CALL DGER( K-1, N-M, -TAU( K ), TAU, 1, A( K, M1 ), LDA, $ A( 1, M1 ), LDA ) END IF 20 CONTINUE END IF * RETURN * * End of DTZRQF * END
bsd-3-clause
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/SRC/zla_gbrcond_c.f
25
9861
*> \brief \b ZLA_GBRCOND_C computes the infinity norm condition number of op(A)*inv(diag(c)) for general banded matrices. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download ZLA_GBRCOND_C + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zla_gbrcond_c.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zla_gbrcond_c.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zla_gbrcond_c.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * DOUBLE PRECISION FUNCTION ZLA_GBRCOND_C( TRANS, N, KL, KU, AB, * LDAB, AFB, LDAFB, IPIV, * C, CAPPLY, INFO, WORK, * RWORK ) * * .. Scalar Arguments .. * CHARACTER TRANS * LOGICAL CAPPLY * INTEGER N, KL, KU, KD, KE, LDAB, LDAFB, INFO * .. * .. Array Arguments .. * INTEGER IPIV( * ) * COMPLEX*16 AB( LDAB, * ), AFB( LDAFB, * ), WORK( * ) * DOUBLE PRECISION C( * ), RWORK( * ) * * * *> \par Purpose: * ============= *> *> \verbatim *> *> ZLA_GBRCOND_C Computes the infinity norm condition number of *> op(A) * inv(diag(C)) where C is a DOUBLE PRECISION vector. *> \endverbatim * * Arguments: * ========== * *> \param[in] TRANS *> \verbatim *> TRANS is CHARACTER*1 *> Specifies the form of the system of equations: *> = 'N': A * X = B (No transpose) *> = 'T': A**T * X = B (Transpose) *> = 'C': A**H * X = B (Conjugate Transpose = Transpose) *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of linear equations, i.e., the order of the *> matrix A. N >= 0. *> \endverbatim *> *> \param[in] KL *> \verbatim *> KL is INTEGER *> The number of subdiagonals within the band of A. KL >= 0. *> \endverbatim *> *> \param[in] KU *> \verbatim *> KU is INTEGER *> The number of superdiagonals within the band of A. KU >= 0. *> \endverbatim *> *> \param[in] AB *> \verbatim *> AB is COMPLEX*16 array, dimension (LDAB,N) *> On entry, the matrix A in band storage, in rows 1 to KL+KU+1. *> The j-th column of A is stored in the j-th column of the *> array AB as follows: *> AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) *> \endverbatim *> *> \param[in] LDAB *> \verbatim *> LDAB is INTEGER *> The leading dimension of the array AB. LDAB >= KL+KU+1. *> \endverbatim *> *> \param[in] AFB *> \verbatim *> AFB is COMPLEX*16 array, dimension (LDAFB,N) *> Details of the LU factorization of the band matrix A, as *> computed by ZGBTRF. U is stored as an upper triangular *> band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, *> and the multipliers used during the factorization are stored *> in rows KL+KU+2 to 2*KL+KU+1. *> \endverbatim *> *> \param[in] LDAFB *> \verbatim *> LDAFB is INTEGER *> The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1. *> \endverbatim *> *> \param[in] IPIV *> \verbatim *> IPIV is INTEGER array, dimension (N) *> The pivot indices from the factorization A = P*L*U *> as computed by ZGBTRF; row i of the matrix was interchanged *> with row IPIV(i). *> \endverbatim *> *> \param[in] C *> \verbatim *> C is DOUBLE PRECISION array, dimension (N) *> The vector C in the formula op(A) * inv(diag(C)). *> \endverbatim *> *> \param[in] CAPPLY *> \verbatim *> CAPPLY is LOGICAL *> If .TRUE. then access the vector C in the formula above. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: Successful exit. *> i > 0: The ith argument is invalid. *> \endverbatim *> *> \param[in] WORK *> \verbatim *> WORK is COMPLEX*16 array, dimension (2*N). *> Workspace. *> \endverbatim *> *> \param[in] RWORK *> \verbatim *> RWORK is DOUBLE PRECISION array, dimension (N). *> Workspace. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup complex16GBcomputational * * ===================================================================== DOUBLE PRECISION FUNCTION ZLA_GBRCOND_C( TRANS, N, KL, KU, AB, $ LDAB, AFB, LDAFB, IPIV, $ C, CAPPLY, INFO, WORK, $ RWORK ) * * -- LAPACK computational routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. CHARACTER TRANS LOGICAL CAPPLY INTEGER N, KL, KU, KD, KE, LDAB, LDAFB, INFO * .. * .. Array Arguments .. INTEGER IPIV( * ) COMPLEX*16 AB( LDAB, * ), AFB( LDAFB, * ), WORK( * ) DOUBLE PRECISION C( * ), RWORK( * ) * * * ===================================================================== * * .. Local Scalars .. LOGICAL NOTRANS INTEGER KASE, I, J DOUBLE PRECISION AINVNM, ANORM, TMP COMPLEX*16 ZDUM * .. * .. Local Arrays .. INTEGER ISAVE( 3 ) * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL ZLACN2, ZGBTRS, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC ABS, MAX * .. * .. Statement Functions .. DOUBLE PRECISION CABS1 * .. * .. Statement Function Definitions .. CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) ) * .. * .. Executable Statements .. ZLA_GBRCOND_C = 0.0D+0 * INFO = 0 NOTRANS = LSAME( TRANS, 'N' ) IF ( .NOT. NOTRANS .AND. .NOT. LSAME( TRANS, 'T' ) .AND. .NOT. $ LSAME( TRANS, 'C' ) ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( KL.LT.0 .OR. KL.GT.N-1 ) THEN INFO = -3 ELSE IF( KU.LT.0 .OR. KU.GT.N-1 ) THEN INFO = -4 ELSE IF( LDAB.LT.KL+KU+1 ) THEN INFO = -6 ELSE IF( LDAFB.LT.2*KL+KU+1 ) THEN INFO = -8 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'ZLA_GBRCOND_C', -INFO ) RETURN END IF * * Compute norm of op(A)*op2(C). * ANORM = 0.0D+0 KD = KU + 1 KE = KL + 1 IF ( NOTRANS ) THEN DO I = 1, N TMP = 0.0D+0 IF ( CAPPLY ) THEN DO J = MAX( I-KL, 1 ), MIN( I+KU, N ) TMP = TMP + CABS1( AB( KD+I-J, J ) ) / C( J ) END DO ELSE DO J = MAX( I-KL, 1 ), MIN( I+KU, N ) TMP = TMP + CABS1( AB( KD+I-J, J ) ) END DO END IF RWORK( I ) = TMP ANORM = MAX( ANORM, TMP ) END DO ELSE DO I = 1, N TMP = 0.0D+0 IF ( CAPPLY ) THEN DO J = MAX( I-KL, 1 ), MIN( I+KU, N ) TMP = TMP + CABS1( AB( KE-I+J, I ) ) / C( J ) END DO ELSE DO J = MAX( I-KL, 1 ), MIN( I+KU, N ) TMP = TMP + CABS1( AB( KE-I+J, I ) ) END DO END IF RWORK( I ) = TMP ANORM = MAX( ANORM, TMP ) END DO END IF * * Quick return if possible. * IF( N.EQ.0 ) THEN ZLA_GBRCOND_C = 1.0D+0 RETURN ELSE IF( ANORM .EQ. 0.0D+0 ) THEN RETURN END IF * * Estimate the norm of inv(op(A)). * AINVNM = 0.0D+0 * KASE = 0 10 CONTINUE CALL ZLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE ) IF( KASE.NE.0 ) THEN IF( KASE.EQ.2 ) THEN * * Multiply by R. * DO I = 1, N WORK( I ) = WORK( I ) * RWORK( I ) END DO * IF ( NOTRANS ) THEN CALL ZGBTRS( 'No transpose', N, KL, KU, 1, AFB, LDAFB, $ IPIV, WORK, N, INFO ) ELSE CALL ZGBTRS( 'Conjugate transpose', N, KL, KU, 1, AFB, $ LDAFB, IPIV, WORK, N, INFO ) ENDIF * * Multiply by inv(C). * IF ( CAPPLY ) THEN DO I = 1, N WORK( I ) = WORK( I ) * C( I ) END DO END IF ELSE * * Multiply by inv(C**H). * IF ( CAPPLY ) THEN DO I = 1, N WORK( I ) = WORK( I ) * C( I ) END DO END IF * IF ( NOTRANS ) THEN CALL ZGBTRS( 'Conjugate transpose', N, KL, KU, 1, AFB, $ LDAFB, IPIV, WORK, N, INFO ) ELSE CALL ZGBTRS( 'No transpose', N, KL, KU, 1, AFB, LDAFB, $ IPIV, WORK, N, INFO ) END IF * * Multiply by R. * DO I = 1, N WORK( I ) = WORK( I ) * RWORK( I ) END DO END IF GO TO 10 END IF * * Compute the estimate of the reciprocal condition number. * IF( AINVNM .NE. 0.0D+0 ) $ ZLA_GBRCOND_C = 1.0D+0 / AINVNM * RETURN * END
bsd-3-clause
nicjhan/MOM5
src/mom5/ocean_tracers/ocean_residency.F90
10
51866
module ocean_residency_mod !{ ! !<CONTACT EMAIL="GFDL.Climate.Model.Info@noaa.gov"> Richard D. Slater !</CONTACT> ! !<REVIEWER EMAIL="GFDL.Climate.Model.Info@noaa.gov"> Stephen M. Griffies !</REVIEWER> ! !<OVERVIEW> ! Ocean residency module !</OVERVIEW> ! !<DESCRIPTION> ! ! This module is a superset of the ocean age tracer module. It may ! be used to reproduce the age tracer, but it can also do much ! more. Unlike the ocean age tracer module, here you may specify ! a 3-d field by specifying a series of "rectangular prisms". ! The grid cells which occupy this field may vary with time due ! to the variations in the thickness of the surface layer. ! ! You may also specify a 3-d field by choosing one of three mixed-layers ! (KPP, density-derived or buoyancy-derived). You may also specify a ! region based on a a range of a prognostic or diagnostic ocean ! tracer (such as all points with a temperature of 10-20 degrees). ! ! You may specify either the mixed-layer method or the tracer range along ! with the geographic specification. If multiple methods are used, then ! the resultant field is the intersection of the two methods. In fact, the ! geographic method is always in use, and defaults to the whole ocean. ! ! There is an option of using the inverse of any method. This is sometimes ! easier to use than explicitly specifying the inverse. For instance, ! to get the temperatures outside of the range 10-20 degrees, one could ! specify the 10-20 degree range and set <swap> to true, or, specify two ! different regions, one less than 10 degrees and one greater than 20 degrees. ! ! By default, the values inside the specified region are set to a ! specified value each time-step (default is 0), and outside of this region ! the field is integrated over time in units of years (integrand is ! 1/(365.25*86400) by default, but this value can be changed. The inner region ! can be forced to be 0 (or the user-specified inner value) at each time-step ! (the default), or it can be restored to this value at a user-specified ! rate (given in days), or, it can be left alone (not integrated or set to ! any value). ! ! Finally, since we are just integrating a specified field by a constant value ! (by default), it is simple to make that field a simple function of another ! tracer. This is the final option. You may specify a prognostic or diagnostic ! variable to be the integrand, and have it scaled by a constant. One case ! which has been done is to integrate irradiance in the mixed-layer. ! ! This module is split into several different modules. This particular module ! is the only one called from outside, and it makes appropriate calls to ! the other modules to implement its features. This was done so that it would ! be easier to expand the features of the ocean residency, without cluttering ! the code too much. Ideally, this could all be done with classes, but there ! is currently no support for classes in Fortran (pre-F2003). The current ! modules are: ! ! ocean_residency.F90 This module, the control center, and also does the ! integrations and resetting in the inner regions. ! ocean_residency_meta.F90 Has specifications of the ocean_residency type ! and other utility routines. This is separate ! to stop circular references ! ocean_residency_ml.F90 Handles setting mixed-layer masks ! ocean_residency_range.F90 Handles setting the masks for the tracer ranges ! ocean_residency_integrand.F90 Handles setting the integrand to a non-constant ! value ! ! field_table namelist inputs: ! ! The following 6 arrays specify the bounds of boxes, the intersection of which ! will define the region where the integrand is set to restore_region_value. ALl arrays ! must have the same number of elements. If none are specified, then no region will ! be used, unless swap is true, which is a quick way of selecting the entire ocean. ! This may be useful when one really wants to use one of the other methods of selecting, ! such as mixed layer depth, or tracer range. ! ! Longitudes will be shifted to lie in the range 0-360 degrees. If the eastern side is ! greater than the western, then the selected region will consist of those grid cells from ! the eastern value to 360, and 0 to the western value. If the northern value is less than ! the southern value, or if the top depth is greater than the bottom depth, then ! an error occurs, and the model stops. ! ! Three special cases exist for the depth (which currently must be in meters). ! If the bottom value is less than or equal to zero, then the top box is selected. ! If the top value is greater than the maximum depth, then the bottom box is selected. ! If the top value is negative, then grid cells within "the absolute value of the top value" ! from the bottom are selected. ! ! Note that the geographic specification is used for all residency tracers, so either ! values for these 6 arrays must be given so as to select a region, or else swap must ! be set to true and no arrays given. ! ! east_bnd: array of boundary points of the eastern side of the box, ! in degrees longitude (default: NULL) ! north_bnd: array of boundary points of the northern side of the box, ! in degrees latitude (default: NULL) ! south_bnd: array of boundary points of the southern side of the box, ! in degrees latitude (default: NULL) ! west_bnd: array of boundary points of the western side of the box, ! in degrees longitude (default: NULL) ! top_bnd: array of boundary points of the top side of the box, ! in meters (default: NULL) ! bottom_bnd: array of boundary points of the bottom side of the box, ! in meters (default: NULL) ! ! swap: if true, then select the inverse of the specified geographic region, ! otherwise, just use the specified region (default: false) ! restore: restoring value for values in the defined regions ! negative => do nothing, 0 => force to integrate_region_value, ! positive => time scale in days to force to integrate_region_value ! (default: 0.0) ! restore_region_value: value to set the mask to for grid cells within ! the specified region (default: 0.0) ! integrate_region_value: value to set the mask to for grid cells outside ! the specified region (default: secs_in_year_r) ! swap_module: if true, then select the inverse of the region from the specified module, ! otherwise, just use the specified region (default: false) ! module_name: if set, then it will be used to select the alternate ! method of selecting the region (default: ' ' -- only geographic ! selection is used) ! ! For the following arrays, see the different extra modules for required and ! possible values for the module selected. ! ! params: an array of real parameters which may be used for the method ! being used for selection (default: NULL) ! flags: an array of real parameters which may be used for the method ! being used for selection (default: NULL) ! strings: an array of real parameters which may be used for the method ! being used for selection (default: NULL) ! ! For the following arrays, see the different extra modules for required and ! possible values for the module selected to specify the integrand. ! int_module_name: if set, then the name of the module used to set ! the integrand (default: ' ' -- integrate time, in years) ! int_params: an array of real parameters which may be used for the integrand ! (default: NULL) ! int_flags: an array of real parameters which may be used for the integrand ! (default: NULL) ! int_strings: an array of real parameters which may be used for the integrand ! (default: NULL) ! !---------------------------------------------------------------------------------------- ! ! Sample field table entries: ! --------------------------- ! ! "tracer_packages","ocean_mod","ocean_residency" ! names = age_surface, age_bottom_inv, kppbl_nil, kppbl_14d, kppbl_frc, kppbl_irr_14d, temp_15_20 ! horizontal-advection-scheme = mdppm ! vertical-advection-scheme = mdppm ! units = yr ! min_tracer_limit=0.0 ! / ! ! This is the same as the old age tracer with all surface ! values forced to zero ! ! "namelists","ocean_mod","ocean_residency/age_surface" ! south_bnd = -90.0 ! north_bnd = 90.0 ! west_bnd = 0.0 ! east_bnd = 360.0 ! top_bnd = 0.0 ! bottom_bnd = 0.0 ! / ! ! This integrates the age in the bottom box and forces to ! zero everywhere else (note that swap is true) ! ! "namelists","ocean_mod","ocean_residency/age_bottom_inv" ! south_bnd = -90.0 ! north_bnd = 90.0 ! west_bnd = 0.0 ! east_bnd = 360.0 ! top_bnd = 10000.0 ! bottom_bnd = 10000.0 ! swap = t ! / ! ! This integrates the age of the water in the KPP ! boundary layer, but lets the age outside of this region ! keep its value until it again mixes with the boundary layer. ! The module_name is set, and strings is set to pick the ! type of mixed layer desired ! (note that the global geographic area is explicitly specified, ! and that the restoring time scale is negative) ! ! "namelists","ocean_mod","ocean_residency/kppbl_nil" ! south_bnd = -90.0 ! north_bnd = 90.0 ! west_bnd = 0.0 ! east_bnd = 360.0 ! top_bnd = 0.0 ! bottom_bnd = 10000.0 ! restore = -1.0 ! module_name = ocean_residency_ml ! strings = kpp_bl ! swap_module = t ! / ! ! This is the same as above, but forces the age outside ! the boundary layer to 0 with a 14 day time scale ! (note that the global geographic region is specified by ! setting swap to true, also note the value of restore) ! ! "namelists","ocean_mod","ocean_residency/kppbl_14d" ! swap = t ! restore = 14.0 ! module_name = ocean_residency_ml ! strings = kpp_bl ! swap_module = t ! / ! ! This is the same as above, but forces age to zero outside ! the boundary layer (note that restore did not need to ! be explicitly specified, as the default is zero) ! ! "namelists","ocean_mod","ocean_residency/kppbl_frc" ! swap = t ! restore = 0.0 ! module_name = ocean_residency_ml ! strings = kpp_bl ! swap_module = t ! / ! ! The following integrates irradiance in the boundary ! layer (note that the units needed to be changed for ! netCDF output purposes) ! ! "prog_tracers","ocean_mod","residency_kppbl_irr_14d" ! units = W-yr/m^2 ! / ! ! "namelists","ocean_mod","ocean_residency/kppbl_irr_14d" ! swap = t ! restore = 14.0 ! module_name = ocean_residency_ml ! strings = kpp_bl ! swap_module = t ! int_module_name = ocean_residency_integrand ! int_strings = irr ! / ! ! This specifies the region as the area with ! a temperature range of between 15 and 20 degrees ! (note that the params holds the variable ! range) ! ! "namelists","ocean_mod","ocean_residency/temp_15_20" ! swap = t ! module_name = ocean_residency_range ! strings = tracer_range, temp ! params = 15.0, 20.0 ! / ! !</DESCRIPTION> ! ! $Id: ocean_residency.F90,v 20.0 2013/12/14 00:17:04 fms Exp $ ! ! ! modules ! use time_manager_mod, only: time_type use field_manager_mod, only: fm_string_len, fm_path_name_len, fm_field_name_len use field_manager_mod, only: fm_get_length, fm_get_value, fm_new_value use mpp_mod, only: stdout, mpp_error, FATAL, mpp_pe, mpp_root_pe use diag_manager_mod, only: register_diag_field, send_data use ocean_tpm_util_mod, only: otpm_set_tracer_package, otpm_set_prog_tracer, otpm_set_diag_tracer use fm_util_mod, only: fm_util_set_value use fm_util_mod, only: fm_util_start_namelist, fm_util_end_namelist use fm_util_mod, only: fm_util_get_string, fm_util_get_string_array use fm_util_mod, only: fm_util_get_logical, fm_util_get_logical_array use fm_util_mod, only: fm_util_get_integer, fm_util_get_real, fm_util_get_real_array use fm_util_mod, only: fm_util_check_for_bad_fields use ocean_types_mod, only: ocean_prog_tracer_type, ocean_diag_tracer_type use ocean_types_mod, only: ocean_thickness_type, ocean_time_type, ocean_density_type use ocean_residency_meta_mod, only: ocean_residency_set_region_geog use ocean_residency_meta_mod, only: instance, num_instances, secs_in_year_r, sec_per_day use ocean_residency_ml_mod, only: do_ocean_residency_ml use ocean_residency_ml_mod, only: ocean_residency_ml_start, ocean_residency_ml_source use ocean_residency_range_mod, only: do_ocean_residency_range use ocean_residency_range_mod, only: ocean_residency_range_start, ocean_residency_range_source use ocean_residency_integrand_mod, only: do_ocean_residency_integrand use ocean_residency_integrand_mod, only: ocean_residency_integrand_start, ocean_residency_integrand_source ! ! force all variables to be "typed" ! implicit none ! ! Set all variables to be private by default private ! ! Public routines ! public :: ocean_residency_init public :: ocean_residency_source public :: ocean_residency_start public :: ocean_residency_tracer ! ! Private routines ! ! ! Public parameters ! ! ! Private parameters ! character(len=fm_field_name_len), parameter :: package_name = 'ocean_residency' character(len=48), parameter :: mod_name = 'ocean_residency_mod' character(len=48), parameter :: diag_name = 'ocean_residency' character(len=fm_string_len), parameter :: default_restart_file = 'ocean_residency.res.nc' ! ! Public variables ! logical, public :: do_ocean_residency ! ! Public types ! ! ! Private variables ! integer :: package_index contains !####################################################################### ! <SUBROUTINE NAME="ocean_residency_init"> ! ! <DESCRIPTION> ! Set up any extra fields needed by the tracer packages ! </DESCRIPTION> ! subroutine ocean_residency_init !{ implicit none ! !----------------------------------------------------------------------- ! Arguments !----------------------------------------------------------------------- ! ! ! local parameters ! character(len=64), parameter :: sub_name = 'ocean_residency_init' character(len=256), parameter :: error_header = & '==>Error from ' // trim(mod_name) // '(' // trim(sub_name) // '):' character(len=256), parameter :: note_header = & '==>Note from ' // trim(mod_name) // '(' // trim(sub_name) // '):' ! !----------------------------------------------------------------------- ! local variables !----------------------------------------------------------------------- ! integer :: n integer :: nn integer :: num_regions character(len=fm_field_name_len) :: name character(len=fm_path_name_len) :: path_to_names character(len=fm_field_name_len+1) :: suffix character(len=fm_field_name_len+3) :: long_suffix character(len=256) :: caller_str character(len=fm_string_len), pointer, dimension(:) :: good_list integer :: stdoutunit stdoutunit=stdout() ! ! Initialize the ocean residency package ! package_index = otpm_set_tracer_package(package_name, & units = 'yr', flux_units = 'm', & min_tracer_limit = 0.0, max_tracer_limit = 1.0e+20, & restart_file = default_restart_file, & caller = trim(mod_name) // '(' // trim(sub_name) // ')') ! ! Check whether to use this package ! path_to_names = '/ocean_mod/tracer_packages/' // trim(package_name) // '/names' num_instances = fm_get_length(path_to_names) if (num_instances .lt. 0) then !{ call mpp_error(FATAL, trim(error_header) // ' Could not get number of instances') endif !} ! ! Check some things ! write (stdoutunit,*) if (num_instances .eq. 0) then !{ write (stdoutunit,*) & trim(note_header), ' No instances' do_ocean_residency = .false. else !}{ write (stdoutunit,*) trim(note_header), ' ', num_instances, ' instances' do_ocean_residency = .true. endif !} ! ! Return if we don't want to use this package ! if (.not. do_ocean_residency) then !{ return endif !} ! ! allocate the instance array ! allocate ( instance(num_instances) ) ! ! loop over the names, saving them into the instance array ! do n = 1, num_instances !{ if (fm_get_value(path_to_names, name, index = n)) then !{ instance(n)%name = name else !}{ write (name,*) n call mpp_error(FATAL, trim(error_header) // & ' Bad field name for index ' // trim(name)) endif !} enddo !} n do n = 1, num_instances !{ ! ! determine the tracer name for this instance ! name = instance(n)%name if (name(1:1) .eq. '_') then !{ suffix = ' ' long_suffix = ' ' else !}{ suffix = '_' // name long_suffix = ' (' // trim(name) // ')' endif !} instance(n)%tracer_index = otpm_set_prog_tracer('residency' // trim(suffix), package_name, & longname = 'Residency' // trim(long_suffix), units = 'yr', & caller = trim(mod_name) // '(' // trim(sub_name) // ')') enddo !} n ! ! set up the density diagnostic tracers ! n = otpm_set_diag_tracer('rho_in_situ', longname = 'In situ density', units = 'kg/m^3', & caller = trim(mod_name) // '(' // trim(sub_name) // ')') n = otpm_set_diag_tracer('rho_neutral', longname = 'Neutral density', units = 'kg/m^3', & caller = trim(mod_name) // '(' // trim(sub_name) // ')') n = otpm_set_diag_tracer('rho_pot_0', longname = 'Potential density-0', units = 'kg/m^3', & caller = trim(mod_name) // '(' // trim(sub_name) // ')') n = otpm_set_diag_tracer('rho_pot_1', longname = 'Potential density-1', units = 'kg/m^3', & caller = trim(mod_name) // '(' // trim(sub_name) // ')') n = otpm_set_diag_tracer('rho_pot_2', longname = 'Potential density-2', units = 'kg/m^3', & caller = trim(mod_name) // '(' // trim(sub_name) // ')') n = otpm_set_diag_tracer('rho_pot_3', longname = 'Potential density-3', units = 'kg/m^3', & caller = trim(mod_name) // '(' // trim(sub_name) // ')') n = otpm_set_diag_tracer('rho_pot_4', longname = 'Potential density-4', units = 'kg/m^3', & caller = trim(mod_name) // '(' // trim(sub_name) // ')') ! !----------------------------------------------------------------------- ! Set up the instance residency namelists !----------------------------------------------------------------------- ! ! ! Add the package name to the list of good namelists, to be used ! later for a consistency check ! if (fm_new_value('/ocean_mod/GOOD/good_namelists', package_name, append = .true.) .le. 0) then !{ call mpp_error(FATAL, trim(error_header) // & ' Could not add ' // trim(package_name) // ' to "good_namelists" list') endif !} caller_str = trim(mod_name) // '(' // trim(sub_name) // ')' do n = 1, num_instances !{ ! ! create the instance namelist ! call fm_util_start_namelist(package_name, instance(n)%name, caller = caller_str, no_overwrite = .true., & check = .true.) call fm_util_set_value('num_regions', 1) call fm_util_set_value('integrate_region_value', secs_in_year_r) call fm_util_set_value('union', .true.) call fm_util_set_value('int_module_name', ' ') call fm_util_set_value('int_params', 0.0, index = 0) call fm_util_set_value('int_flags', .false., index = 0) call fm_util_set_value('int_strings', ' ', index = 0) ! ! get the number of regions so that we may set up the extra namelists ! num_regions = fm_util_get_integer('num_regions', scalar = .true.) ! ! create namelists for each region ! if (num_regions .le. 0) then call mpp_error(FATAL,trim(error_header) // ' num_regions is non-positive for instance ' // & trim(instance(n)%name) // ' in package ' // trim(package_name)) endif do nn = 1, num_regions !{ if (num_regions .eq. 1) then suffix = ' ' else write (long_suffix,*) nn suffix = '_' // long_suffix(scan(long_suffix,'0123456789'):) endif call fm_util_set_value('restore' // suffix, 0.0) call fm_util_set_value('restore_region_value' // suffix, 0.0) call fm_util_set_value('swap' // suffix, .false.) call fm_util_set_value('swap_module' // suffix, .false.) call fm_util_set_value('west_bnd' // suffix, 0.0, index = 0) call fm_util_set_value('east_bnd' // suffix, 0.0, index = 0) call fm_util_set_value('south_bnd' // suffix, 0.0, index = 0) call fm_util_set_value('north_bnd' // suffix, 0.0, index = 0) call fm_util_set_value('top_bnd' // suffix, 0.0, index = 0) call fm_util_set_value('bottom_bnd' // suffix, 0.0, index = 0) call fm_util_set_value('module_name' // suffix, ' ') call fm_util_set_value('params' // suffix, 0.0, index = 0) call fm_util_set_value('flags' // suffix, .false., index = 0) call fm_util_set_value('strings' // suffix, ' ', index = 0) enddo !} nn call fm_util_end_namelist(package_name, instance(n)%name, check = .true., caller = caller_str) enddo !} n ! ! Check for any errors in the number of fields in the namelists for this package ! good_list => fm_util_get_string_array('/ocean_mod/GOOD/namelists/' // trim(package_name) // '/good_values', & caller = trim(mod_name) // '(' // trim(sub_name) // ')') if (associated(good_list)) then !{ call fm_util_check_for_bad_fields('/ocean_mod/namelists/' // trim(package_name), good_list, & caller = trim(mod_name) // '(' // trim(sub_name) // ')') deallocate(good_list) else !}{ call mpp_error(FATAL,trim(error_header) // ' Empty "' // trim(package_name) // '" list') endif !} return end subroutine ocean_residency_init !} ! </SUBROUTINE> NAME="ocean_residency_init" !####################################################################### ! <SUBROUTINE NAME="ocean_residency_source"> ! ! <DESCRIPTION> ! Calculate the source arrays for the tracer packages ! </DESCRIPTION> ! subroutine ocean_residency_source(isc, iec, jsc, jec, isd, ied, jsd, jed, nk, & T_prog, T_diag, Time, Thickness, Dens, grid_xt, grid_yt, grid_zw, & grid_tmask, grid_kmt, hblt_depth) ! ! modules ! implicit none ! !----------------------------------------------------------------------- ! Arguments !----------------------------------------------------------------------- ! integer, intent(in) :: isc integer, intent(in) :: iec integer, intent(in) :: jsc integer, intent(in) :: jec integer, intent(in) :: isd integer, intent(in) :: ied integer, intent(in) :: jsd integer, intent(in) :: jed integer, intent(in) :: nk type(ocean_prog_tracer_type), dimension(:), intent(inout) :: T_prog type(ocean_diag_tracer_type), dimension(:), intent(inout) :: T_diag type(ocean_time_type), intent(in) :: Time type(ocean_thickness_type), intent(in) :: Thickness type(ocean_density_type), intent(in) :: Dens real, dimension(isd:,jsd:), intent(in) :: grid_xt real, dimension(isd:,jsd:), intent(in) :: grid_yt real, dimension(:), intent(in) :: grid_zw real, dimension(isd:,jsd:,:), intent(in) :: grid_tmask integer, dimension(isd:,jsd:), intent(in) :: grid_kmt real, intent(in), dimension(isd:,jsd:) :: hblt_depth ! ! local parameters ! character(len=64), parameter :: sub_name = 'ocean_residency_source' character(len=256), parameter :: error_header = & '==>Error from ' // trim(mod_name) // '(' // trim(sub_name) // '):' ! ! local variables ! integer :: i integer :: ind integer :: j integer :: k integer :: n integer :: nn logical :: used logical :: good integer :: stdoutunit stdoutunit=stdout() ! ! set the source values for the residency tracers ! do n = 1, num_instances !{ ! ! set the values via the input values ! do nn = 1, instance(n)%num_regions !{ call ocean_residency_set_region_geog(isd, ied, jsd, jed, nk, instance(n)%region(nn)%mask, & grid_xt, grid_yt, grid_zw(nk), Thickness%depth_zt, Thickness%depth_zwt, & instance(n)%region(nn)%num_geog_regions, & instance(n)%region(nn)%west_bnd, instance(n)%region(nn)%east_bnd, & instance(n)%region(nn)%south_bnd, instance(n)%region(nn)%north_bnd, & instance(n)%region(nn)%top_bnd, instance(n)%region(nn)%bottom_bnd, & grid_kmt, t_prog(instance(n)%tracer_index)%name, & restore_region_value = 1.0, integrate_region_value = 0.0, & swap = instance(n)%region(nn)%swap, & initialize = .true.) enddo !} nn enddo !} n ! ! set the source values for the residency tracers which need to be set in other ! modules ! if (do_ocean_residency_ml) then !{ call ocean_residency_ml_source(isd, ied, jsd, jed, nk, & t_prog, time, thickness, dens, Thickness%depth_zwt, hblt_depth) endif !} if (do_ocean_residency_range) then !{ call ocean_residency_range_source(isd, ied, jsd, jed, nk, Time%taum1, t_prog, t_diag, grid_kmt) endif !} ! ! save out the mask fields for each region ! do n = 1, num_instances !{ do nn = 1, instance(n)%num_regions !{ do k = 1, nk do j = jsd, jed do i = isd, ied instance(n)%region(nn)%mask(i,j,k) = instance(n)%region(nn)%mask(i,j,k) * grid_tmask(i,j,k) enddo enddo enddo if (instance(n)%region(nn)%id_restore_region .gt. 0) then !{ used = send_data(instance(n)%region(nn)%id_restore_region, & instance(n)%region(nn)%mask(:,:,:), & Time%model_time, rmask = grid_tmask(:,:,:), & is_in=isc, js_in=jsc, ks_in=1, ie_in=iec, je_in=jec, ke_in=nk) endif !} enddo !} nn enddo !} n ! ! merge the mask fields into one field ! do n = 1, num_instances !{ if (instance(n)%num_regions .eq. 1) then !{ do k = 1, nk !{ do j = jsd, jed !{ do i = isd, ied !{ if (grid_tmask(i,j,k) .lt. 0.5) then !{ instance(n)%mask(i,j,k) = 0.0 instance(n)%index(i,j,k) = -1 elseif (instance(n)%region(1)%mask(i,j,k) .eq. 1.0) then !}{ instance(n)%mask(i,j,k) = instance(n)%region(1)%restore_region_value instance(n)%index(i,j,k) = 1 else !}{ instance(n)%mask(i,j,k) = instance(n)%integrate_region_value instance(n)%index(i,j,k) = 0 endif !} enddo !} i enddo !} j enddo !} k else !}{ do k = 1, nk !{ do j = jsd, jed !{ do i = isd, ied !{ if (grid_tmask(i,j,k) .gt. 0.5) then !{ ! ! we're looking to set the restore_region_value for any point that has at least ! one region set ! if (instance(n)%union) then !{ ! ! find the first region with a value set ! ind = 0 do nn = 1, instance(n)%num_regions !{ if (instance(n)%region(nn)%mask(i,j,k) .eq. 1.0) then !{ ind = nn exit endif !} enddo !} nn ! ! if ind == 0, then this point is out of all regions ! if (ind .ne. 0) then !{ ! ! Quit with an error if a ! region with a different restore_region_value also has a value set ! do nn = ind + 1, instance(n)%num_regions !{ if (instance(n)%region(nn)%mask(i,j,k) .eq. 1.0) then !{ if (instance(n)%region(nn)%restore_region_value .ne. & instance(n)%region(ind)%restore_region_value) then !{ write (stdoutunit,*) trim(error_header), ' Grid point ', i, ', ', j, ', ',k, & ' in two regions for "', trim(instance(n)%name), '"' call mpp_error(FATAL,trim(error_header) // ' Grid point in two regions for "' // & trim(instance(n)%name) // '"') elseif (instance(n)%region(nn)%restore .ne. instance(n)%region(ind)%restore) then !}{ write (stdoutunit,*) trim(error_header), ' Grid point ', i, ', ', j, ', ',k, & ' has different restore values for "', trim(instance(n)%name), '"' call mpp_error(FATAL,trim(error_header) // ' Grid point has different restore values for "' // & trim(instance(n)%name) // '"') endif !} endif !} enddo !} nn endif !} else !}{ ! not a union, therefore an intersection ! ! Find the first region with a value set ! ind = 0 do nn = 1, instance(n)%num_regions !{ if (instance(n)%region(nn)%mask(i,j,k) .eq. 1.0) then !{ ind = nn exit endif !} enddo !} nn ! ! If ind == 0, then this point is out of all regions ! if (ind .gt. 0) then !{ ! ! Otherwise, check whether this value is set for all regions with ! the same restore_region_value. If so, use that value, otherwise ! use the integrate_region_value. Also, quit with an error if a ! region with a different restore_region_value also has a value set ! good = .true. do nn = ind + 1, instance(n)%num_regions !{ if (instance(n)%region(nn)%mask(i,j,k) .eq. 1.0) then !{ if (instance(n)%region(nn)%restore_region_value .ne. & instance(n)%region(ind)%restore_region_value) then !{ write (stdoutunit,*) trim(error_header), ' Grid point ', i, ', ', j, ', ',k, & ' in two regions for "', trim(instance(n)%name), '"' call mpp_error(FATAL,trim(error_header) // ' Grid point in two regions for "' // & trim(instance(n)%name) // '"') elseif (instance(n)%region(nn)%restore_region_value .ne. & instance(n)%region(ind)%restore_region_value) then !}{ write (stdoutunit,*) trim(error_header), ' Grid point ', i, ', ', j, ', ',k, & ' has different restore values for "', trim(instance(n)%name), '"' call mpp_error(FATAL,trim(error_header) // ' Grid point has different restore values for "' // & trim(instance(n)%name) // '"') else !}{ good = good .and. instance(n)%region(nn)%mask(i,j,k) .eq. 1.0 endif !} endif !} enddo !} nn if (.not. good) then !{ ind = 0 endif !} endif !} endif !} instance(n)%index(i,j,k) = ind if (ind .gt. 0) then instance(n)%mask(i,j,k) = instance(n)%region(ind)%restore_region_value else instance(n)%mask(i,j,k) = instance(n)%integrate_region_value endif else !}{ instance(n)%index(i,j,k) = -1 instance(n)%mask(i,j,k) = 0.0 endif !} enddo !} i enddo !} j enddo !} k endif !} enddo !} n ! ! set the integrate_region value if something other than time is to be integrated ! if (do_ocean_residency_integrand) then !{ call ocean_residency_integrand_source(isd, ied, jsd, jed, nk, Time%taum1, t_prog, t_diag, grid_tmask) endif !} do n = 1, num_instances !{ do k = 1, nk !{ do j = jsd, jed !{ do i = isd, ied !{ t_prog(instance(n)%tracer_index)%source(i,j,k) = t_prog(instance(n)%tracer_index)%source(i,j,k) + & instance(n)%mask(i,j,k) enddo !} i enddo !} j enddo !} k ! ! Save the diagnostic for the merged mask array ! if (instance(n)%id_restore_region .gt. 0) then !{ used = send_data(instance(n)%id_restore_region, & instance(n)%mask(:,:,:), & Time%model_time, rmask = grid_tmask(:,:,:), & is_in=isc, js_in=jsc, ks_in=1, ie_in=iec, je_in=jec, ke_in=nk) endif !} enddo !} n ! ! Restore to the restore_region values ! do n = 1, num_instances !{ if (instance(n)%some_restore) then !{ do k = 1, nk do j = jsd, jed !{ do i = isd, ied !{ ind = instance(n)%index(i,j,k) !if (instance(n)%region(ind)%mask(i,j,k) .eq. 1.0) then !{} if (ind .gt. 0) then !{ if (instance(n)%region(ind)%restore .gt. 0.0) then !{ instance(n)%mask(i,j,k) = & (instance(n)%region(ind)%restore_region_value - & t_prog(instance(n)%tracer_index)%field(i,j,k,Time%tau)) / & (instance(n)%region(ind)%restore * sec_per_day) * grid_tmask(i,j,k) t_prog(instance(n)%tracer_index)%source(i,j,k) = & t_prog(instance(n)%tracer_index)%source(i,j,k) + instance(n)%mask(i,j,k) endif !} endif !} enddo !}i enddo !} j enddo !} k endif !} enddo !} n return end subroutine ocean_residency_source ! </SUBROUTINE> NAME="ocean_residency_source" !####################################################################### ! <SUBROUTINE NAME="ocean_residency_start"> ! ! <DESCRIPTION> ! Start the ocean residency package ! ! Residency surface area specification ! ! west_bnd : western longitude of residency region ! east_bnd : eastern longitude of residency region ! south_bnd : southern latitude of residency region ! north_bnd : northern latitude of residency region ! top_bnd : top depth of residency region ! bottom_bnd : bottom depth of residency region ! ! To set the volumes, a number of namelists are read, ! each containing the above values. You may specify up to ! num_geog_region rectangular cubes bounded by ! (west_bnd, east_bnd, north_bnd, south_bnd, top_bnd, bottom_bnd). ! Any grid box whose center is in one of these volumes will ! be considered to be part of the volume where the ! residency is reset to zero every time-step. ! ! north_bnd may not equal south_bnd, and west_bnd may not equal east_bnd ! ! top_depth may equal bottom_depth. In that case, then whatever vertical ! box contains that depth will define the vertical range for the box ! ! If south_bnd > north_bnd, then nothing will be done for that rectangle ! ! The initial surface area is empty, with the default rectangle ! setting the surface area to be empty ! ! More than num_geog_regions rectanglar volumes may be used to specify ! the volume by using more than one namelist ! </DESCRIPTION> ! subroutine ocean_residency_start(isd, ied, jsd, jed, nk, model_time, grid_tracer_axes) !{ ! ! modules ! implicit none ! !----------------------------------------------------------------------- ! Arguments !----------------------------------------------------------------------- ! integer, intent(in) :: isd integer, intent(in) :: ied integer, intent(in) :: jsd integer, intent(in) :: jed integer, intent(in) :: nk type(time_type), intent(in) :: model_time integer, dimension(:), intent(in) :: grid_tracer_axes ! ! local parameters ! character(len=64), parameter :: sub_name = 'ocean_residency_start' character(len=256), parameter :: error_header = & '==>Error from ' // trim(mod_name) // '(' // trim(sub_name) // '):' character(len=256), parameter :: note_header = & '==>Note from ' // trim(mod_name) // '(' // trim(sub_name) // '):' ! ! local variables ! integer :: i integer :: j integer :: k integer :: n integer :: nn character(len=256) :: caller_str integer :: len_w integer :: len_e integer :: len_s integer :: len_n integer :: len_t integer :: len_b character(len=fm_field_name_len+3) :: long_suffix character(len=fm_field_name_len+1) :: suffix character(len=24) :: num_suffix character(len=24) :: num_long_suffix character(len=24) :: number_str logical :: found_error integer :: stdoutunit stdoutunit=stdout() ! !----------------------------------------------------------------------- ! save the instance namelist values !----------------------------------------------------------------------- ! caller_str = trim(mod_name) // '(' // trim(sub_name) // ')' do n = 1, num_instances !{ call fm_util_start_namelist(package_name, instance(n)%name, caller = caller_str) instance(n)%num_regions = fm_util_get_integer ('num_regions', scalar = .true.) instance(n)%integrate_region_value = fm_util_get_real ('integrate_region_value', scalar = .true.) instance(n)%union = fm_util_get_logical ('union', scalar = .true.) instance(n)%int_module_name = fm_util_get_string ('int_module_name', scalar = .true.) instance(n)%int_params => fm_util_get_real_array ('int_params') instance(n)%int_flags => fm_util_get_logical_array('int_flags') instance(n)%int_strings => fm_util_get_string_array ('int_strings') ! ! create namelists for each region ! if (instance(n)%num_regions .le. 0) then call mpp_error(FATAL,trim(error_header) // ' num_regions is non-positive for instance ' // & trim(instance(n)%name) // ' in package ' // trim(package_name)) endif ! ! allocate storage for this instance and ! set all of the values to the default ! allocate( instance(n)%region(instance(n)%num_regions) ) do nn = 1, instance(n)%num_regions !{ allocate( instance(n)%region(nn)%mask(isd:ied,jsd:jed,nk) ) do k = 1, nk do j = jsd, jed do i = isd, ied instance(n)%region(nn)%mask(i,j,k) = 0.0 enddo enddo enddo enddo !} nn allocate( instance(n)%mask(isd:ied,jsd:jed,nk) ) do k = 1, nk do j = jsd, jed do i = isd, ied instance(n)%mask(i,j,k) = 0.0 enddo enddo enddo allocate( instance(n)%index(isd:ied,jsd:jed,nk) ) do k = 1, nk do j = jsd, jed do i = isd, ied instance(n)%index(i,j,k) = 0 enddo enddo enddo !instance(n)%mask => instance(n)%region(1)%mask instance(n)%some_restore = .false. instance(n)%some_fix = .false. do nn = 1, instance(n)%num_regions !{ if (instance(n)%num_regions .eq. 1) then suffix = ' ' else write (long_suffix,*) nn suffix = '_' // long_suffix(scan(long_suffix,'0123456789'):) endif instance(n)%region(nn)%restore = fm_util_get_real ('restore' // suffix, scalar = .true.) instance(n)%region(nn)%restore_region_value = fm_util_get_real ('restore_region_value' // suffix, scalar = .true.) instance(n)%region(nn)%swap = fm_util_get_logical ('swap' // suffix, scalar = .true.) instance(n)%region(nn)%swap_module = fm_util_get_logical ('swap_module' // suffix, scalar = .true.) instance(n)%region(nn)%west_bnd => fm_util_get_real_array ('west_bnd' // suffix) instance(n)%region(nn)%east_bnd => fm_util_get_real_array ('east_bnd' // suffix) instance(n)%region(nn)%south_bnd => fm_util_get_real_array ('south_bnd' // suffix) instance(n)%region(nn)%north_bnd => fm_util_get_real_array ('north_bnd' // suffix) instance(n)%region(nn)%top_bnd => fm_util_get_real_array ('top_bnd' // suffix) instance(n)%region(nn)%bottom_bnd => fm_util_get_real_array ('bottom_bnd' // suffix) instance(n)%region(nn)%module_name = fm_util_get_string ('module_name' // suffix, scalar = .true.) instance(n)%region(nn)%params => fm_util_get_real_array ('params' // suffix) instance(n)%region(nn)%flags => fm_util_get_logical_array('flags' // suffix) instance(n)%region(nn)%strings => fm_util_get_string_array ('strings' // suffix) instance(n)%some_restore = instance(n)%some_restore .or. instance(n)%region(nn)%restore .gt. 0.0 instance(n)%some_fix = instance(n)%some_fix .or. instance(n)%region(nn)%restore .eq. 0.0 enddo !} nn call fm_util_end_namelist(package_name, instance(n)%name, caller = caller_str) ! ! Check some things ! do nn = 1, instance(n)%num_regions !{ if (.not. associated(instance(n)%region(nn)%west_bnd) .and. & .not. associated(instance(n)%region(nn)%east_bnd) .and. & .not. associated(instance(n)%region(nn)%south_bnd) .and. & .not. associated(instance(n)%region(nn)%north_bnd) .and. & .not. associated(instance(n)%region(nn)%top_bnd) .and. & .not. associated(instance(n)%region(nn)%bottom_bnd)) then !{ write (stdoutunit,*) trim(note_header), & ' No region specified, assuming it will be specified externally: ', trim(instance(n)%name), ' region: ', nn instance(n)%region(nn)%num_geog_regions = 0 elseif (.not. associated(instance(n)%region(nn)%west_bnd) .or. & .not. associated(instance(n)%region(nn)%east_bnd) .or. & .not. associated(instance(n)%region(nn)%south_bnd) .or. & .not. associated(instance(n)%region(nn)%north_bnd) .or. & .not. associated(instance(n)%region(nn)%top_bnd) .or. & .not. associated(instance(n)%region(nn)%bottom_bnd)) then !}{ call mpp_error(FATAL, trim(error_header) // ' Some regions not specified: ' // trim(instance(n)%name)) else !}{ len_w = size(instance(n)%region(nn)%west_bnd) len_e = size(instance(n)%region(nn)%east_bnd) len_s = size(instance(n)%region(nn)%south_bnd) len_n = size(instance(n)%region(nn)%north_bnd) len_t = size(instance(n)%region(nn)%top_bnd) len_b = size(instance(n)%region(nn)%bottom_bnd) if (len_e .ne. len_w .or. len_e .ne. len_s .or. len_e .ne. len_n .or. & len_e .ne. len_t .or. len_e .ne. len_b) then !{ call mpp_error(FATAL, trim(error_header) // ' Region sizes are not equal: ' // trim(instance(n)%name)) endif !} instance(n)%region(nn)%num_geog_regions = len_w endif !} enddo !} nn ! ! register the fields ! if (instance(n)%name(1:1) .eq. '_') then !{ suffix = ' ' long_suffix = ' ' else !}{ suffix = '_' // instance(n)%name long_suffix = ' (' // trim(instance(n)%name) // ')' endif !} instance(n)%id_change = register_diag_field(trim(diag_name), & 'residency_change' // trim(suffix), grid_tracer_axes(1:3), & model_time, 'Residency change' // trim(long_suffix), ' ', & missing_value = -1.0e+10) instance(n)%id_restore_region = register_diag_field(trim(diag_name), & 'residency_in_merged_regions' // trim(suffix), grid_tracer_axes(1:3), & model_time, 'Residency in merged regions' // trim(long_suffix), ' ', & missing_value = -1.0e+10) do nn = 1, instance(n)%num_regions !{ if (instance(n)%num_regions .eq. 1) then num_suffix = ' ' else write (number_str,*) nn num_suffix = '_' // number_str(scan(number_str,'0123456789'):) num_long_suffix = ' ' // number_str(scan(number_str,'0123456789'):) endif instance(n)%region(nn)%id_restore_region = register_diag_field(trim(diag_name), & 'residency_restore_region' // trim(num_suffix) // trim(suffix), grid_tracer_axes(1:3), & model_time, 'Residency in region' // trim(num_long_suffix) // trim(long_suffix), ' ', & missing_value = -1.0e+10) enddo !} nn enddo !} n ! ! call the start routines for instances controlled by external modules ! call ocean_residency_ml_start call ocean_residency_range_start call ocean_residency_integrand_start ! ! check that the external tracers are all accounted for ! found_error = .false. do n = 1, num_instances !{ if (instance(n)%int_module_name .ne. ' ' .and. .not. instance(n)%int_found) then !}{ found_error = .true. write (stdoutunit,*) trim(error_header), ' Instance "', trim(instance(n)%name), & '" not found with integrand module name "', trim(instance(n)%int_module_name), '"' endif !} do nn = 1, instance(n)%num_regions !{ if (instance(n)%region(nn)%module_name .ne. ' ' .and. .not. instance(n)%region(nn)%found) then !{ found_error = .true. write (stdoutunit,*) trim(error_header), ' Instance "', trim(instance(n)%name), & '" not found with module name "', trim(instance(n)%region(nn)%module_name), '"' endif !} enddo !} nn enddo !} n if (found_error) then !{ call mpp_error(FATAL, trim(error_header) // ' Some external instances not found') endif !} return end subroutine ocean_residency_start !} ! </SUBROUTINE> NAME="ocean_residency_start" !####################################################################### ! <SUBROUTINE NAME="ocean_residency_tracer"> ! ! <DESCRIPTION> ! Subroutine to do calculations needed every time-step after ! the continuity equation has been integrated ! </DESCRIPTION> ! subroutine ocean_residency_tracer(isc, iec, jsc, jec, & isd, ied, jsd, jed, nk, T_prog, grid_tmask, taup1, model_time, dtts) !{ implicit none ! !----------------------------------------------------------------------- ! Arguments !----------------------------------------------------------------------- ! type(ocean_prog_tracer_type), dimension(:), intent(inout) :: T_prog integer, intent(in) :: isc integer, intent(in) :: iec integer, intent(in) :: jsc integer, intent(in) :: jec integer, intent(in) :: isd integer, intent(in) :: ied integer, intent(in) :: jsd integer, intent(in) :: jed integer, intent(in) :: nk integer, intent(in) :: taup1 type(time_type), intent(in) :: model_time real, dimension(isd:,jsd:,:), intent(in) :: grid_tmask real, intent(in) :: dtts ! ! local parameters ! ! ! local variables ! integer :: i integer :: j integer :: k integer :: n integer :: ind logical :: used ! ! fix the restore_region values ! do n = 1, num_instances !{ if (instance(n)%some_fix) then !{ do k = 1, nk do j = jsd, jed !{ do i = isd, ied !{ ind = instance(n)%index(i,j,k) !if (instance(n)%region(ind)%mask(i,j,k) .eq. 1.0) then !{} if (ind .gt. 0) then !{ if (instance(n)%region(ind)%restore .eq. 0.0) then !{ instance(n)%mask(i,j,k) = & (instance(n)%region(ind)%restore_region_value - & t_prog(instance(n)%tracer_index)%field(i,j,k,taup1)) / & dtts * grid_tmask(i,j,k) t_prog(instance(n)%tracer_index)%field(i,j,k,taup1) = instance(n)%region(ind)%restore_region_value endif !} endif !} enddo !}i enddo !} j enddo !} k endif !} if (instance(n)%id_change .gt. 0) then used = send_data(instance(n)%id_change, & instance(n)%mask(:,:,:), & model_time, rmask = grid_tmask(:,:,:), & is_in=isc, js_in=jsc, ks_in=1, ie_in=iec, je_in=jec, ke_in=nk) endif enddo !} n return end subroutine ocean_residency_tracer !} ! </SUBROUTINE> NAME="ocean_residency_tracer" end module ocean_residency_mod !}
gpl-2.0
ryanrhymes/openblas
lib/OpenBLAS-0.2.19/lapack-netlib/BLAS/SRC/srotm.f
26
5263
*> \brief \b SROTM * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE SROTM(N,SX,INCX,SY,INCY,SPARAM) * * .. Scalar Arguments .. * INTEGER INCX,INCY,N * .. * .. Array Arguments .. * REAL SPARAM(5),SX(*),SY(*) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> APPLY THE MODIFIED GIVENS TRANSFORMATION, H, TO THE 2 BY N MATRIX *> *> (SX**T) , WHERE **T INDICATES TRANSPOSE. THE ELEMENTS OF SX ARE IN *> (SX**T) *> *> SX(LX+I*INCX), I = 0 TO N-1, WHERE LX = 1 IF INCX .GE. 0, ELSE *> LX = (-INCX)*N, AND SIMILARLY FOR SY USING USING LY AND INCY. *> WITH SPARAM(1)=SFLAG, H HAS ONE OF THE FOLLOWING FORMS.. *> *> SFLAG=-1.E0 SFLAG=0.E0 SFLAG=1.E0 SFLAG=-2.E0 *> *> (SH11 SH12) (1.E0 SH12) (SH11 1.E0) (1.E0 0.E0) *> H=( ) ( ) ( ) ( ) *> (SH21 SH22), (SH21 1.E0), (-1.E0 SH22), (0.E0 1.E0). *> SEE SROTMG FOR A DESCRIPTION OF DATA STORAGE IN SPARAM. *> *> \endverbatim * * Arguments: * ========== * *> \param[in] N *> \verbatim *> N is INTEGER *> number of elements in input vector(s) *> \endverbatim *> *> \param[in,out] SX *> \verbatim *> SX is REAL array, dimension N *> double precision vector with N elements *> \endverbatim *> *> \param[in] INCX *> \verbatim *> INCX is INTEGER *> storage spacing between elements of SX *> \endverbatim *> *> \param[in,out] SY *> \verbatim *> SY is REAL array, dimension N *> double precision vector with N elements *> \endverbatim *> *> \param[in] INCY *> \verbatim *> INCY is INTEGER *> storage spacing between elements of SY *> \endverbatim *> *> \param[in,out] SPARAM *> \verbatim *> SPARAM is REAL array, dimension 5 *> SPARAM(1)=SFLAG *> SPARAM(2)=SH11 *> SPARAM(3)=SH21 *> SPARAM(4)=SH12 *> SPARAM(5)=SH22 *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup single_blas_level1 * * ===================================================================== SUBROUTINE SROTM(N,SX,INCX,SY,INCY,SPARAM) * * -- Reference BLAS level1 routine (version 3.4.0) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER INCX,INCY,N * .. * .. Array Arguments .. REAL SPARAM(5),SX(*),SY(*) * .. * * ===================================================================== * * .. Local Scalars .. REAL SFLAG,SH11,SH12,SH21,SH22,TWO,W,Z,ZERO INTEGER I,KX,KY,NSTEPS * .. * .. Data statements .. DATA ZERO,TWO/0.E0,2.E0/ * .. * SFLAG = SPARAM(1) IF (N.LE.0 .OR. (SFLAG+TWO.EQ.ZERO)) RETURN IF (INCX.EQ.INCY.AND.INCX.GT.0) THEN * NSTEPS = N*INCX IF (SFLAG.LT.ZERO) THEN SH11 = SPARAM(2) SH12 = SPARAM(4) SH21 = SPARAM(3) SH22 = SPARAM(5) DO I = 1,NSTEPS,INCX W = SX(I) Z = SY(I) SX(I) = W*SH11 + Z*SH12 SY(I) = W*SH21 + Z*SH22 END DO ELSE IF (SFLAG.EQ.ZERO) THEN SH12 = SPARAM(4) SH21 = SPARAM(3) DO I = 1,NSTEPS,INCX W = SX(I) Z = SY(I) SX(I) = W + Z*SH12 SY(I) = W*SH21 + Z END DO ELSE SH11 = SPARAM(2) SH22 = SPARAM(5) DO I = 1,NSTEPS,INCX W = SX(I) Z = SY(I) SX(I) = W*SH11 + Z SY(I) = -W + SH22*Z END DO END IF ELSE KX = 1 KY = 1 IF (INCX.LT.0) KX = 1 + (1-N)*INCX IF (INCY.LT.0) KY = 1 + (1-N)*INCY * IF (SFLAG.LT.ZERO) THEN SH11 = SPARAM(2) SH12 = SPARAM(4) SH21 = SPARAM(3) SH22 = SPARAM(5) DO I = 1,N W = SX(KX) Z = SY(KY) SX(KX) = W*SH11 + Z*SH12 SY(KY) = W*SH21 + Z*SH22 KX = KX + INCX KY = KY + INCY END DO ELSE IF (SFLAG.EQ.ZERO) THEN SH12 = SPARAM(4) SH21 = SPARAM(3) DO I = 1,N W = SX(KX) Z = SY(KY) SX(KX) = W + Z*SH12 SY(KY) = W*SH21 + Z KX = KX + INCX KY = KY + INCY END DO ELSE SH11 = SPARAM(2) SH22 = SPARAM(5) DO I = 1,N W = SX(KX) Z = SY(KY) SX(KX) = W*SH11 + Z SY(KY) = -W + SH22*Z KX = KX + INCX KY = KY + INCY END DO END IF END IF RETURN END
bsd-3-clause
nicjhan/MOM5
src/atmos_shared/tracer_driver/tropchem/mo_exp_slv.F90
10
13359
module MO_EXP_SOL_MOD implicit none ! save private public :: exp_slv_init, exp_sol integer, parameter :: inst = 1, avrg = 2 integer :: o3s_ndx, o3inert_ndx integer :: oh_ndx, ho2_ndx, c2h4_ndx, c3h6_ndx, isop_ndx, & mvk_ndx, macr_ndx, c10h16_ndx, no2_ndx, n2o5_ndx, & no3_ndx, ox_ndx integer :: jo1d_ndx, ox_l1_ndx, o1d_n2_ndx, o1d_o2_ndx, ox_l2_ndx, & ox_l3_ndx, ox_l4_ndx, ox_l5_ndx, ox_l6_ndx, ox_l7_ndx, & ox_l8_ndx, ox_l9_ndx, usr4_ndx, usr16_ndx, usr17_ndx logical :: o3s_loss logical :: class_hist_prod = .false. logical :: class_hist_loss = .false. character(len=128), parameter :: version = '$Id: mo_exp_slv.F90,v 19.0 2012/01/06 20:33:52 fms Exp $' character(len=128), parameter :: tagname = '$Name: tikal $' logical :: module_is_initialized = .false. CONTAINS subroutine exp_slv_init !----------------------------------------------------------------------- ! ... Initialize the explicit solver !----------------------------------------------------------------------- use CHEM_MODS_MOD, only : clscnt1, explicit use mo_chem_utls_mod, only : get_spc_ndx, get_rxt_ndx implicit none !----------------------------------------------------------------------- ! ... Local variables !----------------------------------------------------------------------- o3s_ndx = get_spc_ndx( 'O3S' ) o3inert_ndx = get_spc_ndx( 'O3INERT' ) ox_ndx = get_spc_ndx( 'OX' ) oh_ndx = get_spc_ndx( 'OH' ) ho2_ndx = get_spc_ndx( 'HO2' ) c2h4_ndx = get_spc_ndx( 'C2H4' ) c3h6_ndx = get_spc_ndx( 'C3H6' ) isop_ndx = get_spc_ndx( 'ISOP' ) mvk_ndx = get_spc_ndx( 'MVK' ) macr_ndx = get_spc_ndx( 'MACR' ) c10h16_ndx = get_spc_ndx( 'C10H16' ) no2_ndx = get_spc_ndx( 'NO2' ) n2o5_ndx = get_spc_ndx( 'N2O5' ) no3_ndx = get_spc_ndx( 'NO3' ) jo1d_ndx = get_rxt_ndx( 'jo1d' ) ox_l1_ndx = get_rxt_ndx( 'ox_l1' ) ox_l2_ndx = get_rxt_ndx( 'ox_l2' ) ox_l3_ndx = get_rxt_ndx( 'ox_l3' ) ox_l4_ndx = get_rxt_ndx( 'ox_l4' ) ox_l5_ndx = get_rxt_ndx( 'ox_l5' ) ox_l6_ndx = get_rxt_ndx( 'ox_l6' ) ox_l7_ndx = get_rxt_ndx( 'ox_l7' ) ox_l8_ndx = get_rxt_ndx( 'ox_l8' ) ox_l9_ndx = get_rxt_ndx( 'ox_l9' ) o1d_n2_ndx = get_rxt_ndx( 'o1d_n2' ) o1d_o2_ndx = get_rxt_ndx( 'o1d_o2' ) usr4_ndx = get_rxt_ndx( 'usr4' ) usr16_ndx = get_rxt_ndx( 'usr16' ) usr17_ndx = get_rxt_ndx( 'usr17' ) !----------------------------------------------------------------------- ! ... Scan for class production to history file(s) !----------------------------------------------------------------------- ! do file = 1,moz_file_cnt ! do timetype = inst,avrg ! if( hfile(file)%histout_cnt(14,timetype) > 0 ) then ! il = hfile(file)%histout_ind(14,timetype) ! iu = il + hfile(file)%histout_cnt(14,timetype) - 1 ! if( timetype == inst ) then ! if( ANY( hfile(file)%inst_map(il:iu)/1000 == 1 ) ) then ! class_hist_prod = .true. ! exit ! end if ! else if( timetype == avrg ) then ! if( ANY( hfile(file)%timav_map(il:iu)/1000 == 1 ) ) then ! class_hist_prod = .true. ! exit ! end if ! end if ! end if ! end do ! if( class_hist_prod ) then ! exit ! end if ! end do !----------------------------------------------------------------------- ! ... Scan for class loss to history file(s) !----------------------------------------------------------------------- ! do file = 1,moz_file_cnt ! do timetype = inst,avrg ! if( hfile(file)%histout_cnt(15,timetype) > 0 ) then ! il = hfile(file)%histout_ind(15,timetype) ! iu = il + hfile(file)%histout_cnt(15,timetype) - 1 ! if( timetype == inst ) then ! if( ANY( hfile(file)%inst_map(il:iu)/1000 == 1 ) ) then ! class_hist_loss = .true. ! exit ! end if ! else if( timetype == avrg ) then ! if( ANY( hfile(file)%timav_map(il:iu)/1000 == 1 ) ) then ! class_hist_loss = .true. ! exit ! end if ! end if ! end if ! end do ! if( class_hist_loss ) then ! exit ! end if ! end do end subroutine EXP_SLV_INIT subroutine EXP_SOL( base_sol, reaction_rates, & het_rates, extfrc, & nstep, delt, & prod_out, loss_out,& plonl, plnplv ) !----------------------------------------------------------------------- ! ... Exp_sol advances the volumetric mixing ratio ! forward one time step via the fully explicit ! Euler scheme ! Note : This code has o3inert and o3s as the last ! two class members; neither has production ! or loss - some dimensionality below has been ! altered to acount for this !----------------------------------------------------------------------- use chem_mods_mod, only : clscnt1, explicit, extcnt, hetcnt, rxntot use MO_INDPRD_MOD, only : INDPRD use MO_EXP_PROD_LOSS_MOD, only : EXP_PROD_LOSS use mo_grid_mod, only : pcnstm1 implicit none !----------------------------------------------------------------------- ! ... Dummy arguments !----------------------------------------------------------------------- integer, intent(in) :: nstep ! time step index integer, intent(in) :: plonl ! lon tile dim integer, intent(in) :: plnplv ! plonl*plev real, intent(in) :: delt ! time step in seconds real, intent(in) :: reaction_rates(plnplv,max(1,rxntot)) real, intent(in) :: het_rates(plnplv,max(1,hetcnt)), & extfrc(plnplv,max(1,extcnt)) real, intent(inout) :: base_sol(plnplv,pcnstm1) real, intent(out), optional :: prod_out(plnplv,pcnstm1),loss_out(plnplv,pcnstm1) !----------------------------------------------------------------------- ! ... Local variables !----------------------------------------------------------------------- integer :: k, l, m real, dimension(plnplv,max(1,clscnt1)) :: & prod, & loss, & ind_prd if( explicit%indprd_cnt /= 0 ) then !----------------------------------------------------------------------- ! ... Put "independent" production in the forcing !----------------------------------------------------------------------- call indprd( 1, ind_prd, base_sol, extfrc, reaction_rates ) else do m = 1,max(1,clscnt1) ind_prd(:,m) = 0. end do end if !----------------------------------------------------------------------- ! ... Form F(y) !----------------------------------------------------------------------- call exp_prod_loss( prod, loss, base_sol, reaction_rates, het_rates ) !----------------------------------------------------------------------- ! ... Solve for the mixing ratio at t(n+1) !----------------------------------------------------------------------- do m = 1,clscnt1 l = explicit%clsmap(m) if( l /= o3s_ndx .and. l /= o3inert_ndx ) then base_sol(:,l) = base_sol(:,l) + delt * (prod(:,m) + ind_prd(:,m) - loss(:,m)) !++van : o3s is assigned in mo_chemdr.F90 so commenting these lines here ! else if( l == o3s_ndx ) then !----------------------------------------------------------------------- ! ... special code for o3s ! NB: The coefficients for O3S loss from rxn with ISOP, MVK, MACR, and C10H16 ! are unity. For the OX loss rate (in IMP_SOL) they are adjusted (downward) ! to account for the regeneration of OX by these rxns. But here, we ! consider this regenerated OX to be "tropospheric." -- lwh 2/01 ! Also include O3S loss from NO2+OH, N2O5+aerosol, NO3+aerosol !----------------------------------------------------------------------- ! do k = 1,plnplv ! loss(k,m) = & ! reaction_rates(k,jo1d_ndx)*reaction_rates(k,ox_l1_ndx) & ! /(reaction_rates(k,o1d_n2_ndx) + reaction_rates(k,o1d_o2_ndx) & ! + reaction_rates(k,ox_l1_ndx)) & ! + reaction_rates(k,ox_l2_ndx)*base_sol(k,oh_ndx) & ! + reaction_rates(k,ox_l3_ndx)*base_sol(k,ho2_ndx) & ! + reaction_rates(k,ox_l6_ndx)*base_sol(k,c2h4_ndx) & ! + reaction_rates(k,ox_l4_ndx)*base_sol(k,c3h6_ndx) & ! + reaction_rates(k,ox_l5_ndx)*base_sol(k,isop_ndx) & ! + reaction_rates(k,ox_l7_ndx)*base_sol(k,mvk_ndx) & ! + reaction_rates(k,ox_l8_ndx)*base_sol(k,macr_ndx) & ! + reaction_rates(k,ox_l9_ndx)*base_sol(k,c10h16_ndx) & ! + ((reaction_rates(k,usr4_ndx)*base_sol(k,no2_ndx)*base_sol(k,oh_ndx) & ! + 3.*reaction_rates(k,usr16_ndx)*base_sol(k,n2o5_ndx) & ! + 2.*reaction_rates(k,usr17_ndx)*base_sol(k,no3_ndx)) & ! / max( base_sol(k,ox_ndx), 1.e-20 )) ! base_sol(k,l) = base_sol(k,l)*exp( -delt*loss(k,m) ) ! loss(k,m) = loss(k,m) * base_sol(k,l) ! end do end if if( PRESENT( prod_out ) ) then prod_out(:,l) = prod(:,m) + ind_prd(:,m) end if if( PRESENT( loss_out ) ) then loss_out(:,l) = loss(:,m) end if end do !----------------------------------------------------------------------- ! ... Check for explicit species production and loss output ! First check instantaneous then time averaged !----------------------------------------------------------------------- ! if( class_hist_prod ) then ! do file = 1,moz_file_cnt ! if( hfile(file)%wrhstts .and. hfile(file)%histout_cnt(14,1) > 0 ) then ! do n = 1,hfile(file)%histout_cnt(14,1) ! class = hfile(file)%inst_map(hfile(file)%histout_ind(14,1)+n-1)/1000 ! if( class == 1 ) then ! cls_ndx = mod( hfile(file)%inst_map(hfile(file)%histout_ind(14,1)+n-1),1000 ) ! fldname = hfile(file)%hist_inst(hfile(file)%histout_ind(14,1)+n-1) ! wrk(:) = (prod(:,cls_ndx) + ind_prd(:,cls_ndx)) * hnm(:) ! call outfld( fldname, wrk, plonl, ip, lat, file ) ! end if ! end do ! end if ! if( hfile(file)%histout_cnt(14,2) > 0 ) then ! do n = 1,hfile(file)%histout_cnt(14,2) ! class = hfile(file)%timav_map(hfile(file)%histout_ind(14,2)+n-1)/1000 ! if( class == 1 ) then ! cls_ndx = mod( hfile(file)%timav_map(hfile(file)%histout_ind(14,2)+n-1),1000 ) ! fldname = hfile(file)%hist_timav(hfile(file)%histout_ind(14,2)+n-1) ! wrk(:) = (prod(:,cls_ndx) + ind_prd(:,cls_ndx)) * hnm(:) ! call outfld( fldname, wrk, plonl, ip, lat, file ) ! end if ! end do ! end if ! end do ! end if ! if( class_hist_loss ) then ! do file = 1,moz_file_cnt ! if( hfile(file)%wrhstts .and. hfile(file)%histout_cnt(15,1) > 0 ) then ! do n = 1,hfile(file)%histout_cnt(15,1) ! class = hfile(file)%inst_map(hfile(file)%histout_ind(15,1)+n-1)/1000 ! if( class == 1 ) then ! cls_ndx = mod( hfile(file)%inst_map(hfile(file)%histout_ind(15,1)+n-1),1000 ) ! fldname = hfile(file)%hist_inst(hfile(file)%histout_ind(15,1)+n-1) ! l = explicit%clsmap(cls_ndx) ! wrk(:) = loss(:,cls_ndx) * hnm(:) ! call outfld( fldname, wrk, plonl, ip, lat, file ) ! end if ! end do ! end if ! if( hfile(file)%histout_cnt(15,2) > 0 ) then ! do n = 1,hfile(file)%histout_cnt(15,2) ! class = hfile(file)%timav_map(hfile(file)%histout_ind(15,2)+n-1)/1000 ! if( class == 1 ) then ! cls_ndx = mod( hfile(file)%timav_map(hfile(file)%histout_ind(15,2)+n-1),1000 ) ! fldname = hfile(file)%hist_timav(hfile(file)%histout_ind(15,2)+n-1) ! l = explicit%clsmap(cls_ndx) ! wrk(:) = loss(:,cls_ndx) * hnm(:) ! call outfld( fldname, wrk, plonl, ip, lat, file ) ! end if ! end do ! end if ! end do ! end if end subroutine EXP_SOL end module MO_EXP_SOL_MOD
gpl-2.0
shanzhenren/PLE
Model/eigen-3.2.5/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
gpl-3.0
lofar-astron/PyBDSF
src/port3/d7dog.f
2
7534
SUBROUTINE D7DOG(DIG, LV, N, NWTSTP, STEP, V) C C *** COMPUTE DOUBLE DOGLEG STEP *** C C *** PARAMETER DECLARATIONS *** C INTEGER LV, N REAL DIG(N), NWTSTP(N), STEP(N), V(LV) C C *** PURPOSE *** C C THIS SUBROUTINE COMPUTES A CANDIDATE STEP (FOR _USE_ IN AN UNCON- C STRAINED MINIMIZATION CODE) BY THE DOUBLE DOGLEG ALGORITHM OF C DENNIS AND MEI (REF. 1), WHICH IS A VARIATION ON POWELL*S DOGLEG C SCHEME (REF. 2, P. 95). C C-------------------------- PARAMETER USAGE -------------------------- C C DIG (INPUT) DIAG(D)**-2 * G -- SEE ALGORITHM NOTES. C G (INPUT) THE CURRENT GRADIENT VECTOR. C LV (INPUT) LENGTH OF V. C N (INPUT) NUMBER OF COMPONENTS IN DIG, G, NWTSTP, AND STEP. C NWTSTP (INPUT) NEGATIVE NEWTON STEP -- SEE ALGORITHM NOTES. C STEP (OUTPUT) THE COMPUTED STEP. C V (I/O) VALUES ARRAY, THE FOLLOWING COMPONENTS OF WHICH ARE C USED HERE... C V(BIAS) (INPUT) BIAS FOR RELAXED NEWTON STEP, WHICH IS V(BIAS) OF C THE WAY FROM THE FULL NEWTON TO THE FULLY RELAXED NEWTON C STEP. RECOMMENDED VALUE = 0.8 . C V(DGNORM) (INPUT) 2-NORM OF DIAG(D)**-1 * G -- SEE ALGORITHM NOTES. C V(DSTNRM) (OUTPUT) 2-NORM OF DIAG(D) * STEP, WHICH IS V(RADIUS) C UNLESS V(STPPAR) = 0 -- SEE ALGORITHM NOTES. C V(DST0) (INPUT) 2-NORM OF DIAG(D) * NWTSTP -- SEE ALGORITHM NOTES. C V(GRDFAC) (OUTPUT) THE COEFFICIENT OF DIG IN THE STEP RETURNED -- C STEP(I) = V(GRDFAC)*DIG(I) + V(NWTFAC)*NWTSTP(I). C V(GTHG) (INPUT) SQUARE-ROOT OF (DIG**T) * (HESSIAN) * DIG -- SEE C ALGORITHM NOTES. C V(GTSTEP) (OUTPUT) INNER PRODUCT BETWEEN G AND STEP. C V(NREDUC) (OUTPUT) FUNCTION REDUCTION PREDICTED FOR THE FULL NEWTON C STEP. C V(NWTFAC) (OUTPUT) THE COEFFICIENT OF NWTSTP IN THE STEP RETURNED -- C SEE V(GRDFAC) ABOVE. C V(PREDUC) (OUTPUT) FUNCTION REDUCTION PREDICTED FOR THE STEP RETURNED. C V(RADIUS) (INPUT) THE TRUST REGION RADIUS. D TIMES THE STEP RETURNED C HAS 2-NORM V(RADIUS) UNLESS V(STPPAR) = 0. C V(STPPAR) (OUTPUT) CODE TELLING HOW STEP WAS COMPUTED... 0 MEANS A C FULL NEWTON STEP. BETWEEN 0 AND 1 MEANS V(STPPAR) OF THE C WAY FROM THE NEWTON TO THE RELAXED NEWTON STEP. BETWEEN C 1 AND 2 MEANS A TRUE DOUBLE DOGLEG STEP, V(STPPAR) - 1 OF C THE WAY FROM THE RELAXED NEWTON TO THE CAUCHY STEP. C GREATER THAN 2 MEANS 1 / (V(STPPAR) - 1) TIMES THE CAUCHY C STEP. C C------------------------------- NOTES ------------------------------- C C *** ALGORITHM NOTES *** C C LET G AND H BE THE CURRENT GRADIENT AND HESSIAN APPROXIMA- C TION RESPECTIVELY AND LET D BE THE CURRENT SCALE VECTOR. THIS C ROUTINE ASSUMES DIG = DIAG(D)**-2 * G AND NWTSTP = H**-1 * G. C THE STEP COMPUTED IS THE SAME ONE WOULD GET BY REPLACING G AND H C BY DIAG(D)**-1 * G AND DIAG(D)**-1 * H * DIAG(D)**-1, C COMPUTING STEP, AND TRANSLATING STEP BACK TO THE ORIGINAL C VARIABLES, I.E., PREMULTIPLYING IT BY DIAG(D)**-1. C C *** REFERENCES *** C C 1. DENNIS, J.E., AND MEI, H.H.W. (1979), TWO NEW UNCONSTRAINED OPTI- C MIZATION ALGORITHMS WHICH _USE_ FUNCTION AND GRADIENT C VALUES, J. OPTIM. THEORY APPLIC. 28, PP. 453-482. C 2. POWELL, M.J.D. (1970), A HYBRID METHOD FOR NON-LINEAR EQUATIONS, C IN NUMERICAL METHODS FOR NON-LINEAR EQUATIONS, EDITED BY C P. RABINOWITZ, GORDON AND BREACH, LONDON. C C *** GENERAL *** C C CODED BY DAVID M. GAY. C THIS SUBROUTINE WAS WRITTEN IN CONNECTION WITH RESEARCH SUPPORTED C BY THE NATIONAL SCIENCE FOUNDATION UNDER GRANTS MCS-7600324 AND C MCS-7906671. C C------------------------ EXTERNAL QUANTITIES ------------------------ C C *** INTRINSIC FUNCTIONS *** C/+ REAL SQRT C/ C-------------------------- LOCAL VARIABLES -------------------------- C INTEGER I REAL CFACT, CNORM, CTRNWT, GHINVG, FEMNSQ, GNORM, 1 NWTNRM, RELAX, RLAMBD, T, T1, T2 REAL HALF, ONE, TWO, ZERO C C *** V SUBSCRIPTS *** C INTEGER BIAS, DGNORM, DSTNRM, DST0, GRDFAC, GTHG, GTSTEP, 1 NREDUC, NWTFAC, PREDUC, RADIUS, STPPAR C C *** DATA INITIALIZATIONS *** C C/6 C DATA HALF/0.5E+0/, ONE/1.E+0/, TWO/2.E+0/, ZERO/0.E+0/ C/7 PARAMETER (HALF=0.5E+0, ONE=1.E+0, TWO=2.E+0, ZERO=0.E+0) C/ C C/6 C DATA BIAS/43/, DGNORM/1/, DSTNRM/2/, DST0/3/, GRDFAC/45/, C 1 GTHG/44/, GTSTEP/4/, NREDUC/6/, NWTFAC/46/, PREDUC/7/, C 2 RADIUS/8/, STPPAR/5/ C/7 PARAMETER (BIAS=43, DGNORM=1, DSTNRM=2, DST0=3, GRDFAC=45, 1 GTHG=44, GTSTEP=4, NREDUC=6, NWTFAC=46, PREDUC=7, 2 RADIUS=8, STPPAR=5) C/ C C+++++++++++++++++++++++++++++++ BODY ++++++++++++++++++++++++++++++++ C NWTNRM = V(DST0) RLAMBD = ONE IF (NWTNRM .GT. ZERO) RLAMBD = V(RADIUS) / NWTNRM GNORM = V(DGNORM) GHINVG = TWO * V(NREDUC) V(GRDFAC) = ZERO V(NWTFAC) = ZERO IF (RLAMBD .LT. ONE) GO TO 30 C C *** THE NEWTON STEP IS INSIDE THE TRUST REGION *** C V(STPPAR) = ZERO V(DSTNRM) = NWTNRM V(GTSTEP) = -GHINVG V(PREDUC) = V(NREDUC) V(NWTFAC) = -ONE DO 20 I = 1, N 20 STEP(I) = -NWTSTP(I) GO TO 999 C 30 V(DSTNRM) = V(RADIUS) CFACT = (GNORM / V(GTHG))**2 C *** CAUCHY STEP = -CFACT * G. CNORM = GNORM * CFACT RELAX = ONE - V(BIAS) * (ONE - GNORM*CNORM/GHINVG) IF (RLAMBD .LT. RELAX) GO TO 50 C C *** STEP IS BETWEEN RELAXED NEWTON AND FULL NEWTON STEPS *** C V(STPPAR) = ONE - (RLAMBD - RELAX) / (ONE - RELAX) T = -RLAMBD V(GTSTEP) = T * GHINVG V(PREDUC) = RLAMBD * (ONE - HALF*RLAMBD) * GHINVG V(NWTFAC) = T DO 40 I = 1, N 40 STEP(I) = T * NWTSTP(I) GO TO 999 C 50 IF (CNORM .LT. V(RADIUS)) GO TO 70 C C *** THE CAUCHY STEP LIES OUTSIDE THE TRUST REGION -- C *** STEP = SCALED CAUCHY STEP *** C T = -V(RADIUS) / GNORM V(GRDFAC) = T V(STPPAR) = ONE + CNORM / V(RADIUS) V(GTSTEP) = -V(RADIUS) * GNORM V(PREDUC) = V(RADIUS)*(GNORM - HALF*V(RADIUS)*(V(GTHG)/GNORM)**2) DO 60 I = 1, N 60 STEP(I) = T * DIG(I) GO TO 999 C C *** COMPUTE DOGLEG STEP BETWEEN CAUCHY AND RELAXED NEWTON *** C *** FEMUR = RELAXED NEWTON STEP MINUS CAUCHY STEP *** C 70 CTRNWT = CFACT * RELAX * GHINVG / GNORM C *** CTRNWT = INNER PROD. OF CAUCHY AND RELAXED NEWTON STEPS, C *** SCALED BY GNORM**-1. T1 = CTRNWT - GNORM*CFACT**2 C *** T1 = INNER PROD. OF FEMUR AND CAUCHY STEP, SCALED BY C *** GNORM**-1. T2 = V(RADIUS)*(V(RADIUS)/GNORM) - GNORM*CFACT**2 T = RELAX * NWTNRM FEMNSQ = (T/GNORM)*T - CTRNWT - T1 C *** FEMNSQ = SQUARE OF 2-NORM OF FEMUR, SCALED BY GNORM**-1. T = T2 / (T1 + SQRT(T1**2 + FEMNSQ*T2)) C *** DOGLEG STEP = CAUCHY STEP + T * FEMUR. T1 = (T - ONE) * CFACT V(GRDFAC) = T1 T2 = -T * RELAX V(NWTFAC) = T2 V(STPPAR) = TWO - T V(GTSTEP) = T1*GNORM**2 + T2*GHINVG V(PREDUC) = -T1*GNORM * ((T2 + ONE)*GNORM) 1 - T2 * (ONE + HALF*T2)*GHINVG 2 - HALF * (V(GTHG)*T1)**2 DO 80 I = 1, N 80 STEP(I) = T1*DIG(I) + T2*NWTSTP(I) C 999 RETURN C *** LAST LINE OF D7DOG FOLLOWS *** END
gpl-3.0