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 |
---|---|---|---|---|---|
tuxillo/aarch64-dragonfly-gcc | gcc/testsuite/gfortran.dg/continuation_3.f90 | 193 | 1932 | ! { dg-do compile }
! { dg-options -std=f95 }
! PR 19262 Test limit on line continuations. Test case derived form case in PR
! by Steve Kargl. Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>
print *, &
"1" // & ! 1
"2" // & ! 2
"3" // & ! 3
"4" // & ! 4
"5" // & ! 5
"6" // & ! 6
"7" // & ! 7
"8" // & ! 8
"9" // & ! 9
"0" // & ! 10
"1" // & ! 11
"2" // & ! 12
"3" // & ! 13
"4" // & ! 14
"5" // & ! 15
"6" // & ! 16
"7" // & ! 17
"8" // & ! 18
"9" // & ! 19
"0" // & ! 20
"1" // & ! 21
"2" // & ! 22
"3" // & ! 23
"4" // & ! 24
"5" // & ! 25
"6" // & ! 26
"7" // & ! 27
"8" // & ! 28
"9" // & ! 29
"0" // & ! 30
"1" // & ! 31
"2" // & ! 32
"3" // & ! 33
"4" // & ! 34
"5" // & ! 35
"6" // & ! 36
"7" // & ! 37
"8" // & ! 38
"9"
print *, &
"1" // & ! 1
"2" // & ! 2
"3" // & ! 3
"4" // & ! 4
"5" // & ! 5
"6" // & ! 6
"7" // & ! 7
"8" // & ! 8
"9" // & ! 9
"0" // & ! 10
"1" // & ! 11
"2" // & ! 12
"3" // & ! 13
"4" // & ! 14
"5" // & ! 15
"6" // & ! 16
"7" // & ! 17
"8" // & ! 18
"9" // & ! 19
"0" // & ! 20
"1" // & ! 21
"2" // & ! 22
"3" // & ! 23
"4" // & ! 24
"5" // & ! 25
"6" // & ! 26
"7" // & ! 27
"8" // & ! 28
"9" // & ! 29
!
!
"0" // & ! 30
"1" // & ! 31
!
!
"2" // & ! 32
"3" // & ! 33
"4" // & ! 34
"5" // & ! 35
"6" // & ! 36
"7" // & ! 37
"8" // & ! 38
"9" // & ! 39
"0" ! { dg-warning "Limit of 39 continuations exceeded" }
end | gpl-2.0 |
Hellybean/SaberMod_ROM_Toolchain | gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_mmval.f90 | 190 | 1175 | ! Program to test the MINVAL and MAXVAL intrinsics
program testmmval
implicit none
integer, dimension (3, 3) :: a
integer, dimension (3) :: b
logical, dimension (3, 3) :: m, tr
integer i
character (len=9) line
a = reshape ((/1, 2, 3, 5, 4, 6, 9, 8, 7/), (/3, 3/));
tr = .true.
b = minval (a, 1)
if (any(b .ne. (/1, 4, 7/))) call abort
write (line, 9000) minval (a, 1)
if (line .ne. ' 1 4 7') call abort
m = .true.
m(1, 1) = .false.
m(1, 2) = .false.
b = minval (a, 1, m)
if (any(b .ne. (/2, 4, 7/))) call abort
b = minval (a, 1, m .and. tr)
if (any(b .ne. (/2, 4, 7/))) call abort
write (line, 9000) minval(a, 1, m)
if (line .ne. ' 2 4 7') call abort
b = maxval (a, 1)
if (any(b .ne. (/3, 6, 9/))) call abort
write (line, 9000) maxval (a, 1)
if (line .ne. ' 3 6 9') call abort
m = .true.
m(1, 2) = .false.
m(1, 3) = .false.
b = maxval (a, 1, m)
if (any(b .ne. (/3, 6, 8/))) call abort
b = maxval (a, 1, m .and. tr)
if (any(b .ne. (/3, 6, 8/))) call abort
write (line, 9000) maxval(a, 1, m)
if (line .ne. ' 3 6 8') call abort
9000 format(3I3)
end program
| gpl-2.0 |
rvanharen/netcdf2littler | tests/netcdf2littler_tests.f90 | 1 | 14347 | module netcdf2littler_tests
! minimal unit testing framework for write_littler
use readncdf
use write_littler
use logging
implicit none
private
public :: main
integer, parameter :: stdout = 6
contains
logical function assert(condition, test_name)
! asserts if the condition is true/false and returns the status of the tests
logical, intent(in) :: condition
character(len=*), intent(in) :: test_name
character(len=60) :: output_test_name
assert = condition
output_test_name = test_name ! report only first 60 characters of test_name
if (assert) then
write(unit=stdout, fmt='(A)')'test '//output_test_name//': '//&
char(27)//'[32mPASS'//char(27)//'[0m'
else
write(unit=stdout, fmt='(A)')'test '//output_test_name//': '//&
char(27)//'[31mFAIL'//char(27)//'[0m'
end if
end function assert
subroutine initialize_tests(tests, ntests)
! allocate logical array with test results
! write output header to stdout
logical, dimension(:), allocatable, intent(inout) :: tests
integer, intent(in) :: ntests
! allocate logical array with test results
if (allocated(tests)) deallocate(tests)
allocate(tests(ntests))
! write header of test results
write(unit=stdout, fmt='(A)')
write(unit=stdout, fmt='(71("-"))')
write(unit=stdout, fmt='(T6, A,T66,A)') 'test name', 'result'
write(unit=stdout, fmt='(71("-"))')
end subroutine initialize_tests
subroutine report_tests(tests)
! reports the total number of tests and the number of passes/fails
logical, dimension(:), intent(in) :: tests
integer :: n, nsuccess, nfailure
! set initial number of passes/fails to 0
nsuccess = 0
nfailure = 0
! loop over all tests and update passes/fails
do n = 1, size(tests)
if (tests(n)) then
nsuccess = nsuccess + 1
else
nfailure = nfailure + 1
end if
end do
! write the result to the screen
write(unit=stdout, fmt='(71("-"))')
write(unit=stdout, fmt='(A,I3,A)')'Ran a total of ', size(tests),' tests.'
write(unit=stdout, fmt='(I3,A,I3,A)')nsuccess,' tests PASSED, ',nfailure,' tests FAILED.'
write(unit=stdout, fmt='(A)')
if (nfailure /= 0) then
call exit(1)
end if
end subroutine report_tests
subroutine main
! main routine that runs all the tests
logical,dimension(:),allocatable :: tests ! logical array with test results
INTEGER :: ntests ! total number of tests
INTEGER :: n = 1 ! test counter
ntests = 49 ! modify if adding new tests
call define_logfile('write_littler_tests.log')
call initialize_tests(tests,ntests)
call test_dateint(tests, n)
call test_get_default_littler(tests, n)
call test_readtimedim(tests, n)
call test_readstepnc_single(tests, n)
call test_readstepnc(tests, n)
call test_read_variables(tests, n)
call test_concat(tests, n)
n = n-1
call report_tests(tests)
! remove this statement later, used for keeping track of ntests
if ( n/=ntests ) then
print *, 'WARNING'
print *, 'Total number of actual tests performed was: ', n
print *, 'Total number of tests set (ntests) was: ', ntests
end if
end subroutine main
subroutine test_dateint(tests, n)
! test if dateint returns a character string with YYYYMMDDHHMMSS
integer, intent(inout) :: n
logical, dimension(*), intent(inout) :: tests
tests(n) = assert(dateint(2010,01,02,23,30,59)=='20100102233059', 'dateint')
n = n+1
end subroutine test_dateint
subroutine test_get_default_littler(tests, n)
! description
integer, intent(inout) :: n
logical, dimension(*), intent(inout) :: tests
integer, parameter :: kx=1
real, dimension(kx) :: dpressure, dheight, dtemperature, ddew_point
real, dimension(kx) :: dspeed, ddirection, du, dv, drh, dthickness
real, dimension(kx) :: dpsfc, drefpres
integer, dimension(kx) :: dpressure_qc, dheight_qc, dtemperature_qc
integer, dimension(kx) :: ddew_point_qc, dspeed_qc, ddirection_qc, du_qc
integer, dimension(kx) :: dv_qc, drh_qc, dthickness_qc
call get_default_littler(dpressure, dheight, dtemperature, ddew_point, &
dspeed, ddirection, du, dv, drh, dthickness, dpsfc, drefpres, dpressure_qc, &
dheight_qc, dtemperature_qc, ddew_point_qc, dspeed_qc, ddirection_qc, du_qc, &
dv_qc, drh_qc, dthickness_qc, kx)
! default values
tests(n) = assert(dpressure(1)==-888888., 'get_default_littler: default pressure')
n=n+1
tests(n) = assert(dheight(1)==-888888., 'get_default_littler: default height')
n=n+1
tests(n) = assert(dtemperature(1)==-888888., 'get_default_littler: default temperature')
n=n+1
tests(n) = assert(ddew_point(1)==-888888., 'get_default_littler: default dew_point')
n=n+1
tests(n) = assert(dspeed(1)==-888888., 'get_default_littler: default speed')
n=n+1
tests(n) = assert(ddirection(1)==-888888., 'get_default_littler: default direction')
n=n+1
tests(n) = assert(du(1)==-888888., 'get_default_littler: default u velocity')
n=n+1
tests(n) = assert(dv(1)==-888888., 'get_default_littler: default v velocity')
n=n+1
tests(n) = assert(drh(1)==-888888., 'get_default_littler: default relative humidity')
n=n+1
tests(n) = assert(dthickness(1)==-888888., 'get_default_littler: default thickness')
n=n+1
tests(n) = assert(dpsfc(1)==-888888., 'get_default_littler: default surface pressure')
n=n+1
tests(n) = assert(drefpres(1)==-888888., 'get_default_littler: reference pressure')
n=n+1
! default qc values
tests(n) = assert(dpressure_qc(1)==0, 'get_default_littler: default pressure_qc')
n=n+1
tests(n) = assert(dheight_qc(1)==0, 'get_default_littler: default height_qc')
n=n+1
tests(n) = assert(dtemperature_qc(1)==0, 'get_default_littler: default temperature_qc')
n=n+1
tests(n) = assert(ddew_point_qc(1)==0, 'get_default_littler: default dew_point_qc')
n=n+1
tests(n) = assert(dspeed_qc(1)==0, 'get_default_littler: default speed_qc')
n=n+1
tests(n) = assert(ddirection_qc(1)==0, 'get_default_littler: default direction_qc')
n=n+1
tests(n) = assert(du_qc(1)==0, 'get_default_littler: default u velocity_qc')
n=n+1
tests(n) = assert(dv_qc(1)==0, 'get_default_littler: default v velocity_qc')
n=n+1
tests(n) = assert(drh_qc(1)==0, 'get_default_littler: default relative humidity_qc')
n=n+1
tests(n) = assert(dthickness_qc(1)==0, 'get_default_littler: default thickness_qc')
n=n+1
end subroutine test_get_default_littler
subroutine test_readtimedim(tests, n)
! unit test for readtimedim subroutine
integer, intent(inout) :: n
logical, dimension(*), intent(inout) :: tests
real,dimension(:), allocatable :: time
character(len=100) :: timeunits
call readtimedim('../test_data/test_1d.nc', time, timeunits)
tests(n) = assert(time(5)==138750896., 'readtimedim: time (1d) - 1')
n=n+1
tests(n) = assert((time(9)-time(1))==2400., 'readtimedim: time (1d) - 2')
n=n+1
tests(n) = assert(timeunits=='seconds since 2010-01-01 00:00', &
'readtimedim: timeunits (1d)')
n=n+1
call readtimedim('../test_data/test_2d.nc', time, timeunits)
tests(n) = assert(time(5)==138750896., 'readtimedim: time (2d) - 1')
n=n+1
tests(n) = assert((time(9)-time(1))==2400., 'readtimedim: time (2d) - 2')
n=n+1
tests(n) = assert(timeunits=='seconds since 2010-01-01 00:00', &
'readtimedim: timeunits (2d)')
n=n+1
end subroutine test_readtimedim
subroutine test_readstepnc_single(tests, n)
! unit test for readstepnc_single subroutine
integer, intent(inout) :: n
logical, dimension(*), intent(inout) :: tests
real, dimension(10) :: ff
real :: lon, lat, elevation, fill_value
integer :: startindex = 1
integer :: countnum = 10
call readstepnc_single('../test_data/test_1d.nc', 'temperature', ff, &
fill_value, lon, lat, elevation, startindex, countnum)
tests(n) = assert(lon==4.88883305, 'readstepnc_single: longitude')
n=n+1
tests(n) = assert(lat==52.3687325, 'readstepnc_single: latitude')
n=n+1
tests(n) = assert(elevation==1.8, 'readstepnc_single: elevation')
n=n+1
tests(n) = assert(ff(3)==20.5000000, 'readstepnc_single: array value')
n=n+1
tests(n) = assert((ff(1)-ff(10))==1.50000000, 'readstepnc_single: array value difference')
n=n+1
end subroutine test_readstepnc_single
subroutine test_readstepnc(tests, n)
! unit test for readstepnc subroutine
integer, intent(inout) :: n
logical, dimension(*), intent(inout) :: tests
real, dimension(10) :: ff
real :: lon, lat, elevation, fill_value
integer :: startindex = 1
integer :: countnum = 10
integer :: device = 2
call readstepnc('../test_data/test_2d.nc','temperature', ff, &
fill_value, lon, lat, elevation, device, startindex, countnum)
tests(n) = assert(lon==4.88883305, 'readstepnc: longitude')
n=n+1
tests(n) = assert(lat==52.3687325, 'readstepnc: latitude')
n=n+1
tests(n) = assert(elevation==24.2, 'readstepnc: elevation')
n=n+1
tests(n) = assert(ff(3)==20.5000000, 'readstepnc: array value')
n=n+1
tests(n) = assert((ff(1)-ff(10))==1.50000000, 'readstepnc: array value difference')
n=n+1
end subroutine test_readstepnc
subroutine test_read_variables(tests, n)
! unit test for readstepnc subroutine
integer, intent(inout) :: n
logical, dimension(*), intent(inout) :: tests
character(len=99):: filename, outfile
real :: lon, lat, elevation, fill_value
integer :: startindex = 1
integer :: countnum = 10
integer :: device = 1
integer :: dimensions = 1
integer :: idx = 1
real, dimension(:), allocatable :: humidity, height, speed
real, dimension(:), allocatable :: temperature, dew_point
real, dimension(:), allocatable :: pressure, direction, thickness
real,dimension(:), allocatable :: uwind, vwind, refpres
character(len=30), dimension(2):: variable_name
character(len=30), dimension(2):: variable_mapping
integer, parameter :: kx=1
integer,dimension(kx) :: p_qc,z_qc,t_qc,td_qc,spd_qc
integer, dimension(kx) :: dir_qc,u_qc,v_qc,rh_qc,thick_qc
real, dimension(kx) :: dpressure, dheight, dtemperature, ddew_point
real, dimension(kx) :: dspeed, ddirection, du, dv, drh, dthickness
real, dimension(kx) :: dpsfc, drefpres
integer, dimension(kx) :: dpressure_qc, dheight_qc, dtemperature_qc
integer, dimension(kx) :: ddew_point_qc, dspeed_qc, ddirection_qc, du_qc
integer, dimension(kx) :: dv_qc, drh_qc, dthickness_qc
character(len=14), dimension(:), allocatable :: time_littler
character(len=8):: startdate, enddate
integer :: timeLength
character(len=100) :: timeunits
logical bogus, append
data bogus /.false./
integer:: iseq_num = 1
real,dimension(:), allocatable :: time
logical :: file_exists
append = .false.
variable_name(1) = 'temperature'
variable_name(2) = 'humidity'
variable_mapping(1) = 'temperature'
variable_mapping(2) = 'humidity'
if (allocated(temperature)) deallocate(temperature)
allocate(temperature(countnum))
if (allocated(humidity)) deallocate(humidity)
allocate(humidity(countnum))
if (allocated(height)) deallocate(height)
allocate(height(countnum))
if (allocated(speed)) deallocate(speed)
allocate(speed(countnum))
if (allocated(dew_point)) deallocate(dew_point)
allocate(dew_point(countnum))
if (allocated(pressure)) deallocate(pressure)
allocate(pressure(countnum))
if (allocated(refpres)) deallocate(refpres)
allocate(refpres(countnum))
if (allocated(direction)) deallocate(direction)
allocate(direction(countnum))
if (allocated(thickness)) deallocate(thickness)
allocate(thickness(countnum))
if (allocated(uwind)) deallocate(uwind)
allocate(uwind(countnum))
if (allocated(vwind)) deallocate(vwind)
allocate(vwind(countnum))
! read both temperature and humidity
filename = '../test_data/test_1d.nc'
do idx=1,2
call read_variables(lat, lon, elevation, humidity, height, speed, temperature, dew_point, &
pressure, refpres, direction, thickness, uwind, vwind, variable_name, &
variable_mapping, filename, fill_value, idx, device, dimensions, startindex, countnum)
end do
! get default values
call get_default_littler(dpressure, dheight, dtemperature, ddew_point, &
dspeed, ddirection, du, dv, drh, dthickness, dpsfc, drefpres, dpressure_qc, &
dheight_qc, dtemperature_qc, ddew_point_qc, dspeed_qc, ddirection_qc, du_qc, &
dv_qc, drh_qc, dthickness_qc, kx)
! read time dimensions
call readtimedim(filename, time, timeunits)
timeLength = size(time)
! convert to LITTLE_R time format
allocate(time_littler(timeLength))
startdate = '20140525'
enddate = '20140526'
call time_to_littler_date(time, timeunits, time_littler, startindex, &
countnum, startdate, enddate)
! define output file
outfile = 'test.out'
! write obs to file in LITTLE_R format
call write_obs_littler(pressure,height,temperature,dew_point,speed, &
direction,uwind,vwind,humidity,thickness,refpres, p_qc,z_qc,t_qc,td_qc,spd_qc, &
dir_qc,u_qc,v_qc,rh_qc,thick_qc,elevation,lat,lon,variable_mapping, &
kx, bogus, iseq_num, time_littler(startindex:startindex+countnum-1), fill_value, outfile, append)
! run tests
tests(n) = assert(lon==4.88883305, 'read_variables: longitude')
n=n+1
tests(n) = assert(lat==52.3687325, 'read_variables: latitude')
n=n+1
tests(n) = assert(elevation==1.8, 'read_variables: elevation')
n=n+1
tests(n) = assert(temperature(3)==20.5000000, 'read_variables: array value')
n=n+1
tests(n) = assert(humidity(2)==0.3729959, 'read_variables: array value')
n=n+1
tests(n) = assert((temperature(1)-temperature(10))==1.50000000, 'read_variables: array value difference')
n=n+1
tests(n) = assert(time_littler(3)=='20140525214504', 'time conversion to LITTLE_R format')
n=n+1
! check if LITTLE_R file is created
inquire(FILE=outfile, EXIST=file_exists)
tests(n) = assert(file_exists .eqv. .true., 'creation of LITTLE_R output file')
n=n+1
end subroutine test_read_variables
subroutine test_concat(tests, n)
! unit test for readstepnc subroutine
integer, intent(inout) :: n
logical, dimension(*), intent(inout) :: tests
! run tests
tests(n) = assert(concat_str_int('Number ', 1) == 'Number 1', 'concat str and int')
n=n+1
tests(n) = assert(concat_str_real('Number ', 1.0) == 'Number 1.00000000', 'concat str and real')
n=n+1
end subroutine test_concat
end module netcdf2littler_tests
| apache-2.0 |
tuxillo/aarch64-dragonfly-gcc | gcc/testsuite/gfortran.dg/internal_references_1.f90 | 135 | 1045 | ! { dg-do compile }
! This tests the patch for PRs 24327, 25024 & 25625, which
! are all connected with references to internal procedures.
! This is a composite of the PR testcases; and each is
! labelled by PR.
!
! Contributed by Paul Thomas <pault@gcc.gnu.org>
!
! PR25625 - would neglect to point out that there were 2 subroutines p.
module m
implicit none
contains
subroutine p (i) ! { dg-error "is already defined" }
integer :: i
end subroutine
subroutine p (i) ! { dg-error "is already defined" }
integer :: i
end subroutine
end module
!
! PR25124 - would happily ignore the declaration of foo in the main program.
program test
real :: foo, x ! { dg-error "explicit interface and must not have attributes declared" }
x = bar () ! This is OK because it is a regular reference.
x = foo ()
contains
function foo () ! { dg-error "explicit interface and must not have attributes declared" }
foo = 1.0
end function foo
function bar ()
bar = 1.0
end function bar
end program test
| gpl-2.0 |
Hellybean/SaberMod_ROM_Toolchain | gcc/testsuite/gfortran.dg/internal_references_1.f90 | 135 | 1045 | ! { dg-do compile }
! This tests the patch for PRs 24327, 25024 & 25625, which
! are all connected with references to internal procedures.
! This is a composite of the PR testcases; and each is
! labelled by PR.
!
! Contributed by Paul Thomas <pault@gcc.gnu.org>
!
! PR25625 - would neglect to point out that there were 2 subroutines p.
module m
implicit none
contains
subroutine p (i) ! { dg-error "is already defined" }
integer :: i
end subroutine
subroutine p (i) ! { dg-error "is already defined" }
integer :: i
end subroutine
end module
!
! PR25124 - would happily ignore the declaration of foo in the main program.
program test
real :: foo, x ! { dg-error "explicit interface and must not have attributes declared" }
x = bar () ! This is OK because it is a regular reference.
x = foo ()
contains
function foo () ! { dg-error "explicit interface and must not have attributes declared" }
foo = 1.0
end function foo
function bar ()
bar = 1.0
end function bar
end program test
| gpl-2.0 |
alongwithyou/rnnlib | hdf5_snap/fortran/test/tH5P_F03.f90 | 5 | 19335 | !****h* root/fortran/test/tH5P_F03.f90
!
! NAME
! tH5P_F03.f90
!
! FUNCTION
! Test FORTRAN HDF5 H5P APIs which are dependent on FORTRAN 2003
! features.
!
! 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. *
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!
! USES
! test_genprop_cls_cb1_mod
!
! CONTAINS SUBROUTINES
! test_create, test_genprop_class_callback
!
!*****
! *****************************************
! *** H 5 P T E S T S
! *****************************************
MODULE test_genprop_cls_cb1_mod
! Callback subroutine for test_genprop_class_callback
! and the function H5Pcreate_class_f.
USE HDF5
USE ISO_C_BINDING
IMPLICIT NONE
TYPE, bind(C) :: cop_cb_struct_ ! /* Struct for iterations */
INTEGER :: count
INTEGER(HID_T) :: id
END TYPE cop_cb_struct_
CONTAINS
INTEGER FUNCTION test_genprop_cls_cb1_f(list_id, create_data ) bind(C)
USE HDF5
USE ISO_C_BINDING
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN), VALUE :: list_id
TYPE(cop_cb_struct_) :: create_data
create_data%count = create_data%count + 1
create_data%id = list_id
test_genprop_cls_cb1_f = 0
END FUNCTION test_genprop_cls_cb1_f
END MODULE test_genprop_cls_cb1_mod
MODULE TH5P_F03
CONTAINS
!/*-------------------------------------------------------------------------
! * Function: test_create
! *
! * Purpose: Tests H5Pset_fill_value_f and H5Pget_fill_value_f
! *
! * Return: Success: 0
! *
! * Failure: number of errors
! *
! * Programmer: M. Scot Breitenfeld
! * June 24, 2008
! *
! * Modifications:
! *
! *-------------------------------------------------------------------------
! */
SUBROUTINE test_create(total_error)
USE HDF5
USE TH5_MISC
USE ISO_C_BINDING
IMPLICIT NONE
INTEGER, INTENT(INOUT) :: total_error
INTEGER(HID_T) :: fapl
INTEGER(hid_t) :: file=-1, space=-1, dcpl=-1, comp_type_id=-1
INTEGER(hid_t) :: dset9=-1
INTEGER(hsize_t), DIMENSION(1:5), PARAMETER :: cur_size = (/2, 8, 8, 4, 2/)
INTEGER(hsize_t), DIMENSION(1:5), PARAMETER :: ch_size= (/1, 1, 1, 4, 1/)
CHARACTER(LEN=14) :: filename ='test_create.h5'
! /* compound datatype operations */
TYPE, BIND(C) :: comp_datatype
REAL :: a
INTEGER :: x
DOUBLE PRECISION :: y
CHARACTER(LEN=1) :: z
END TYPE comp_datatype
TYPE(comp_datatype), TARGET :: rd_c, fill_ctype
INTEGER :: error
INTEGER(SIZE_T) :: h5off
TYPE(C_PTR) :: f_ptr
LOGICAL :: differ1, differ2
!/*
! * Create a file.
! */
CALL h5fcreate_f(filename,H5F_ACC_TRUNC_F,file,error)
CALL check("h5fcreate_f", error, total_error)
CALL h5screate_simple_f(5, cur_size, space, error, cur_size)
CALL check("h5screate_simple_f", error, total_error)
CALL H5Pcreate_f(H5P_DATASET_CREATE_F, dcpl, error)
CALL check("H5Pcreate_f", error, total_error)
CALL h5pset_chunk_f(dcpl, 5, ch_size, error)
CALL check("h5pset_chunk_f",error, total_error)
! /* Create a compound datatype */
CALL h5tcreate_f(H5T_COMPOUND_F, INT(SIZEOF(fill_ctype),size_t), comp_type_id, error)
CALL check("h5tcreate_f", error, total_error)
h5off = H5OFFSETOF(C_LOC(fill_ctype), C_LOC(fill_ctype%a))
CALL h5tinsert_f(comp_type_id, "a", h5off , H5T_NATIVE_REAL, error)
CALL check("h5tinsert_f", error, total_error)
CALL h5tinsert_f(comp_type_id, "x", H5OFFSETOF(C_LOC(fill_ctype), C_LOC(fill_ctype%x)), H5T_NATIVE_INTEGER, error)
CALL check("h5tinsert_f", error, total_error)
CALL h5tinsert_f(comp_type_id, "y", H5OFFSETOF(C_LOC(fill_ctype), C_LOC(fill_ctype%y)), H5T_NATIVE_DOUBLE, error)
CALL check("h5tinsert_f", error, total_error)
CALL h5tinsert_f(comp_type_id, "z", &
H5OFFSETOF(C_LOC(fill_ctype), C_LOC(fill_ctype%z)), H5T_NATIVE_CHARACTER, error)
CALL check("h5tinsert_f", error, total_error)
CALL H5Pset_alloc_time_f(dcpl, H5D_ALLOC_TIME_LATE_F,error)
CALL check("H5Pset_alloc_time_f",error, total_error)
CALL H5Pset_fill_time_f(dcpl, H5D_FILL_TIME_ALLOC_F, error)
CALL check("H5Pset_fill_time_f",error, total_error)
! /* Compound datatype test */
f_ptr = C_LOC(fill_ctype)
CALL H5Pget_fill_value_f(dcpl, comp_type_id, f_ptr, error)
CALL check("H5Pget_fill_value_f",error, total_error)
fill_ctype%y = 4444.D0
fill_ctype%z = 'S'
fill_ctype%a = 5555.
fill_ctype%x = 55
f_ptr = C_LOC(fill_ctype)
CALL H5Pset_fill_value_f(dcpl, comp_type_id, f_ptr, error)
CALL check("H5Pget_fill_value_f",error, total_error)
CALL h5dcreate_f(file,"dset9", comp_type_id, space, dset9, error, dcpl_id=dcpl)
CALL check("h5dcreate_f", error, total_error)
CALL h5dclose_f(dset9, error)
CALL check("h5dclose_f", error, total_error)
CALL h5fclose_f(file,error)
CALL check("h5fclose_f", error, total_error)
! /* Open the file and get the dataset fill value from each dataset */
CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl, error)
CALL check("H5Pcreate_f",error, total_error)
CALL H5Pset_libver_bounds_f(fapl, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error)
CALL check("H5Pset_libver_bounds_f",error, total_error)
CALL h5fopen_f (FILENAME, H5F_ACC_RDONLY_F, file, error, fapl)
CALL check("h5fopen_f", error, total_error)
!/* Compound datatype test */
CALL h5dopen_f(file, "dset9", dset9, error)
CALL check("h5dopen_f", error, total_error)
CALL H5Dget_create_plist_f(dset9, dcpl, error)
CALL check("H5Dget_create_plist_f", error, total_error)
f_ptr = C_LOC(rd_c)
CALL H5Pget_fill_value_f(dcpl, comp_type_id, f_ptr, error)
CALL check("H5Pget_fill_value_f", error, total_error)
IF( .NOT.dreal_eq( REAL(rd_c%a,dp), REAL(fill_ctype%a, dp)) .OR. &
.NOT.dreal_eq( REAL(rd_c%y,dp), REAL(fill_ctype%y, dp)) .OR. &
rd_c%x .NE. fill_ctype%x .OR. &
rd_c%z .NE. fill_ctype%z )THEN
PRINT*,"***ERROR: Returned wrong fill value"
total_error = total_error + 1
ENDIF
CALL h5dclose_f(dset9, error)
CALL check("h5dclose_f", error, total_error)
CALL H5Pclose_f(dcpl, error)
CALL check("H5Pclose_f", error, total_error)
CALL h5fclose_f(file,error)
CALL check("h5fclose_f", error, total_error)
END SUBROUTINE test_create
SUBROUTINE test_genprop_class_callback(total_error)
!
!
! test_genprop_class_callback(): Test basic generic property list code.
! Tests callbacks for property lists in a generic class.
!
! FORTRAN TESTS:
! Tests function H5Pcreate_class_f with callback.
!
!
USE HDF5
USE TH5_MISC
USE ISO_C_BINDING
USE test_genprop_cls_cb1_mod
IMPLICIT NONE
INTEGER, INTENT(INOUT) :: total_error
INTEGER(hid_t) :: cid1 !/* Generic Property class ID */
INTEGER(hid_t) :: lid1 !/* Generic Property list ID */
INTEGER(hid_t) :: lid2 !/* 2nd Generic Property list ID */
INTEGER(size_t) :: nprops !/* Number of properties in class */
TYPE cb_struct
INTEGER :: count
INTEGER(hid_t) :: id
END TYPE cb_struct
TYPE(cb_struct), TARGET :: crt_cb_struct, cls_cb_struct
CHARACTER(LEN=7) :: CLASS1_NAME = "Class 1"
TYPE(C_FUNPTR) :: f1, f5
TYPE(C_PTR) :: f2, f6
CHARACTER(LEN=10) :: PROP1_NAME = "Property 1"
INTEGER(SIZE_T) :: PROP1_SIZE = 10
CHARACTER(LEN=10) :: PROP2_NAME = "Property 2"
INTEGER(SIZE_T) :: PROP2_SIZE = 10
CHARACTER(LEN=10) :: PROP3_NAME = "Property 3"
INTEGER(SIZE_T) :: PROP3_SIZE = 10
CHARACTER(LEN=10) :: PROP4_NAME = "Property 4"
INTEGER(SIZE_T) :: PROP4_SIZE = 10
INTEGER :: PROP1_DEF_VALUE = 10
INTEGER :: PROP2_DEF_VALUE = 10
INTEGER :: PROP3_DEF_VALUE = 10
INTEGER :: PROP4_DEF_VALUE = 10
INTEGER :: error ! /* Generic RETURN value */
f1 = C_FUNLOC(test_genprop_cls_cb1_f)
f5 = C_FUNLOC(test_genprop_cls_cb1_f)
f2 = C_LOC(crt_cb_struct)
f6 = C_LOC(cls_cb_struct)
!/* Create a new generic class, derived from the root of the class hierarchy */
CALL h5pcreate_class_f(h5p_ROOT_F,CLASS1_NAME, cid1, error, f1, f2, c_null_funptr, c_null_ptr, f5, f6)
CALL check("h5pcreate_class_f", error, total_error)
!/* Insert first property into class (with no callbacks) */
CALL h5pregister_f(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, error)
CALL check("h5pregister_f", error, total_error)
!/* Insert second property into class (with no callbacks) */
CALL h5pregister_f(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, error)
CALL check("h5pregister_f", error, total_error)
!/* Insert third property into class (with no callbacks) */
CALL h5pregister_f(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, error)
CALL check("h5pregister_f", error, total_error)
!/* Insert fourth property into class (with no callbacks) */
CALL h5pregister_f(cid1, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, error)
CALL check("h5pregister_f", error, total_error)
! /* Check the number of properties in class */
CALL h5pget_nprops_f(cid1, nprops, error)
CALL check("h5pget_nprops_f", error, total_error)
CALL VERIFY("h5pget_nprops_f", INT(nprops), 4, total_error)
! /* Initialize class callback structs */
crt_cb_struct%count = 0
crt_cb_struct%id = -1
cls_cb_struct%count = 0
cls_cb_struct%id = -1
!/* Create a property list from the class */
CALL h5pcreate_f(cid1, lid1, error)
CALL check("h5pcreate_f", error, total_error)
!/* Verify that the creation callback occurred */
CALL VERIFY("h5pcreate_f", crt_cb_struct%count, 1, total_error)
CALL VERIFY("h5pcreate_f", INT(crt_cb_struct%id), INT(lid1), total_error)
! /* Check the number of properties in list */
CALL h5pget_nprops_f(lid1,nprops, error)
CALL check("h5pget_nprops_f", error, total_error)
CALL VERIFY("h5pget_nprops_f", INT(nprops), 4, total_error)
! /* Create another property list from the class */
CALL h5pcreate_f(cid1, lid2, error)
CALL check("h5pcreate_f", error, total_error)
! /* Verify that the creation callback occurred */
CALL VERIFY("h5pcreate_f", crt_cb_struct%count, 2, total_error)
CALL VERIFY("h5pcreate_f", INT(crt_cb_struct%id), INT(lid2), total_error)
! /* Check the number of properties in list */
CALL h5pget_nprops_f(lid2,nprops, error)
CALL check("h5pget_nprops_f", error, total_error)
CALL VERIFY("h5pget_nprops_f", INT(nprops), 4, total_error)
! /* Close first list */
CALL h5pclose_f(lid1, error);
CALL check("h5pclose_f", error, total_error)
!/* Verify that the close callback occurred */
CALL VERIFY("h5pcreate_f", cls_cb_struct%count, 1, total_error)
CALL VERIFY("h5pcreate_f", INT(cls_cb_struct%id), INT(lid1), total_error)
!/* Close second list */
CALL h5pclose_f(lid2, error);
CALL check("h5pclose_f", error, total_error)
!/* Verify that the close callback occurred */
CALL VERIFY("h5pcreate_f", cls_cb_struct%count, 2, total_error)
CALL VERIFY("h5pcreate_f", INT(cls_cb_struct%id), INT(lid2), total_error)
!/* Close class */
CALL h5pclose_class_f(cid1, error)
CALL check("h5pclose_class_f", error, total_error)
END SUBROUTINE test_genprop_class_callback
!-------------------------------------------------------------------------
! Function: test_h5p_file_image
!
! Purpose: Tests APIs:
! h5pget_file_image_f and h5pset_file_image_f
!
! Return: Success: 0
! Failure: -1
!
! FORTRAN Programmer: M. Scot Breitenfeld
! April 1, 2014
!-------------------------------------------------------------------------
SUBROUTINE test_h5p_file_image(total_error)
USE HDF5
USE TH5_MISC
USE, INTRINSIC :: iso_c_binding
IMPLICIT NONE
INTEGER, INTENT(INOUT) :: total_error
INTEGER(hid_t) :: fapl_1 = -1
INTEGER, PARAMETER :: count = 10
INTEGER, DIMENSION(1:count), TARGET :: buffer
INTEGER, DIMENSION(1:count), TARGET :: temp
INTEGER :: i
INTEGER(size_t) :: size
INTEGER(size_t) :: temp_size
INTEGER :: error ! error return value
TYPE(C_PTR) :: f_ptr
TYPE(C_PTR), DIMENSION(1:count) :: f_ptr1
TYPE(C_PTR), DIMENSION(1:1) :: f_ptr2
! Initialize file image buffer
DO i = 1, count
buffer(i) = i*10
ENDDO
! Create fapl
CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl_1, error)
CALL check("h5pcreate_f", error, total_error)
! Test with NULL ptr
f_ptr2(1) = C_NULL_PTR
temp_size = 1
CALL h5pget_file_image_f(fapl_1, f_ptr2, temp_size, error)
CALL check("h5pget_file_image_f", error, total_error)
CALL verify("h5pget_file_image_f", INT(temp_size), 0, total_error)
! Set file image
f_ptr = C_LOC(buffer(1))
size = SIZEOF(buffer)
CALL h5pset_file_image_f(fapl_1, f_ptr, size, error)
CALL check("h5pset_file_image_f", error, total_error)
! Get the same data back
DO i = 1, count
f_ptr1(i) = C_LOC(temp(i))
ENDDO
temp_size = 0
CALL h5pget_file_image_f(fapl_1, f_ptr1, temp_size, error)
CALL check("h5pget_file_image_f", error, total_error)
! Check that sizes are the same, and that the buffers are identical but separate
CALL VERIFY("h5pget_file_image_f", INT(temp_size), INT(size), total_error)
! Verify the image data is correct
DO i = 1, count
CALL VERIFY("h5pget_file_image_f", temp(i), buffer(i), total_error)
ENDDO
END SUBROUTINE test_h5p_file_image
!-------------------------------------------------------------------------
! Function: external_test_offset
!
! Purpose: Tests APIs:
! h5pset_external_f (with offsets not equal to zero), h5pget_external_f
!
! Return: Success: 0
! Failure: -1
!
! FORTRAN Programmer: M. Scot Breitenfeld
! January 10, 2012
!-------------------------------------------------------------------------
!
SUBROUTINE external_test_offset(cleanup,total_error)
USE ISO_C_BINDING
USE TH5_MISC
USE HDF5 ! This module contains all necessary modules
IMPLICIT NONE
INTEGER, INTENT(INOUT) :: total_error
LOGICAL, INTENT(IN) :: cleanup
INTEGER(hid_t) :: fapl=-1 ! file access property list
INTEGER(hid_t) :: file=-1 ! file to write to
INTEGER(hid_t) :: dcpl=-1 ! dataset creation properties
INTEGER(hid_t) :: space=-1 ! data space
INTEGER(hid_t) :: dset=-1 ! dataset
INTEGER(hid_t) :: grp=-1 ! group to emit diagnostics
INTEGER(size_t) :: i, j ! miscellaneous counters
CHARACTER(LEN=180) :: filename ! file names
INTEGER, DIMENSION(1:25) :: part ! raw data buffers
INTEGER, DIMENSION(1:100), TARGET :: whole ! raw data buffers
INTEGER(hsize_t), DIMENSION(1:1) :: cur_size ! current data space size
INTEGER(hid_t) :: hs_space ! hyperslab data space
INTEGER(hsize_t), DIMENSION(1:1) :: hs_start = (/30/) ! hyperslab starting offset
INTEGER(hsize_t), DIMENSION(1:1) :: hs_count = (/25/) ! hyperslab size
CHARACTER(LEN=1) :: ichr1 ! character conversion holder
INTEGER :: error ! error status
TYPE(C_PTR) :: f_ptr ! fortran pointer
CHARACTER(LEN=1,KIND=C_CHAR), DIMENSION(1:30) :: temparray
temparray(1:30)(1:1) = '0' ! 1 byte character
! Write the data to external files directly
DO i = 1, 4
DO j = 1, 25
part(j) = (i-1)*25+(j-1)
ENDDO
WRITE(ichr1,'(I1.1)') i
filename = "extern_"//ichr1//"a.raw"
OPEN(10, FILE=filename, ACCESS='STREAM', form='UNFORMATTED')
WRITE(10) temparray(1:(i-1)*10)
WRITE(10) part
CLOSE(10)
ENDDO
!
! Create the file and an initial group.
CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl, error)
CALL h5fcreate_f('extren_raw.h5', H5F_ACC_TRUNC_F, file, error, access_prp=fapl)
CALL check("h5fcreate_f",error,total_error)
CALL h5gcreate_f(file, "emit-diagnostics", grp, error)
CALL check("h5gcreate_f",error, total_error)
! Create the dataset
CALL h5pcreate_f(H5P_DATASET_CREATE_F, dcpl, error)
CALL check("h5pcreate_f", error, total_error)
CALL h5pset_external_f(dcpl, "extern_1a.raw", INT(0,off_t), INT(SIZEOF(part), hsize_t), error)
CALL check("h5pset_external_f",error,total_error)
CALL h5pset_external_f(dcpl, "extern_2a.raw", INT(10,off_t), INT(SIZEOF(part), hsize_t), error)
CALL check("h5pset_external_f",error,total_error)
CALL h5pset_external_f(dcpl, "extern_3a.raw", INT(20,off_t), INT(SIZEOF(part), hsize_t), error)
CALL check("h5pset_external_f",error,total_error)
CALL h5pset_external_f(dcpl, "extern_4a.raw", INT(30,off_t), INT(SIZEOF(part), hsize_t), error)
CALL check("h5pset_external_f",error,total_error)
cur_size(1) = 100
CALL h5screate_simple_f(1, cur_size, space, error)
CALL check("h5screate_simple_f", error, total_error)
CALL h5dcreate_f(file, "dset1", H5T_NATIVE_INTEGER, space, dset,error,dcpl_id=dcpl)
CALL check("h5dcreate_f", error, total_error)
!
! Read the entire dataset and compare with the original
whole(:) = 0
f_ptr = C_LOC(whole(1))
CALL h5dread_f(dset, H5T_NATIVE_INTEGER, f_ptr, error, mem_space_id=space, file_space_id=space)
CALL check("h5dread_f", error, total_error)
DO i = 1, 100
IF(whole(i) .NE. i-1)THEN
WRITE(*,*) "Incorrect value(s) read."
total_error = total_error + 1
EXIT
ENDIF
ENDDO
!
! Read the middle of the dataset
CALL h5scopy_f(space, hs_space, error)
CALL check("h5scopy_f", error, total_error)
CALL h5sselect_hyperslab_f(hs_space, H5S_SELECT_SET_F, hs_start, hs_count, error)
CALL check("h5sselect_hyperslab_f", error, total_error)
whole(:) = 0
f_ptr = C_LOC(whole(1))
CALL h5dread_f(dset, H5T_NATIVE_INTEGER, f_ptr, error, mem_space_id=hs_space, file_space_id=hs_space)
CALL check("h5dread_f", error, total_error)
CALL h5sclose_f(hs_space, error)
CALL check("h5sclose_f", error, total_error)
DO i = INT(hs_start(1))+1, INT(hs_start(1)+hs_count(1))
IF(whole(i) .NE. i-1)THEN
WRITE(*,*) "Incorrect value(s) read."
total_error = total_error + 1
EXIT
ENDIF
ENDDO
CALL h5dclose_f(dset, error)
CALL check("h5dclose_f", error, total_error)
CALL h5pclose_f(dcpl, error)
CALL check("h5pclose_f", error, total_error)
CALL h5sclose_f(space, error)
CALL check("h5sclose_f", error, total_error)
CALL h5fclose_f(file, error)
CALL check("h5fclose_f", error, total_error)
! cleanup
DO i = 1, 4
WRITE(ichr1,'(I1.1)') i
filename = "extern_"//ichr1//"a.raw"
CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error)
CALL check("h5_cleanup_f", error, total_error)
ENDDO
IF(cleanup) CALL h5_cleanup_f("extren_raw.h5", H5P_DEFAULT_F, error)
CALL check("h5_cleanup_f", error, total_error)
END SUBROUTINE external_test_offset
END MODULE TH5P_F03
| gpl-3.0 |
Hellybean/SaberMod_ROM_Toolchain | gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_trailz.f90 | 174 | 1541 | program test_intrinsic_trailz
implicit none
call test_trailz(0_1,0_2,0_4,0_8,1_1,1_2,1_4,1_8,8_1,8_2,8_4,8_8)
stop
contains
subroutine test_trailz(z1,z2,z4,z8,i1,i2,i4,i8,e1,e2,e4,e8)
integer(kind=1) :: z1, i1, e1
integer(kind=2) :: z2, i2, e2
integer(kind=4) :: z4, i4, e4
integer(kind=8) :: z8, i8, e8
if (trailz(0_1) /= 8) call abort()
if (trailz(0_2) /= 16) call abort()
if (trailz(0_4) /= 32) call abort()
if (trailz(0_8) /= 64) call abort()
if (trailz(1_1) /= 0) call abort()
if (trailz(1_2) /= 0) call abort()
if (trailz(1_4) /= 0) call abort()
if (trailz(1_8) /= 0) call abort()
if (trailz(8_1) /= 3) call abort()
if (trailz(8_2) /= 3) call abort()
if (trailz(8_4) /= 3) call abort()
if (trailz(8_8) /= 3) call abort()
if (trailz(z1) /= 8) call abort()
if (trailz(z2) /= 16) call abort()
if (trailz(z4) /= 32) call abort()
if (trailz(z8) /= 64) call abort()
if (trailz(i1) /= 0) call abort()
if (trailz(i2) /= 0) call abort()
if (trailz(i4) /= 0) call abort()
if (trailz(i8) /= 0) call abort()
if (trailz(e1) /= 3) call abort()
if (trailz(e2) /= 3) call abort()
if (trailz(e4) /= 3) call abort()
if (trailz(e8) /= 3) call abort()
end subroutine test_trailz
end program
| gpl-2.0 |
tuxillo/aarch64-dragonfly-gcc | gcc/testsuite/gfortran.dg/do_check_6.f90 | 139 | 2350 | ! { dg-do compile }
!
! PR fortran/54958
!
module m
integer, protected :: i
integer :: j
end module m
subroutine test1()
use m
implicit none
integer :: A(5)
! Valid: data-implied-do (has a scope of the statement or construct)
DATA (A(i), i=1,5)/5*42/ ! OK
! Valid: ac-implied-do (has a scope of the statement or construct)
print *, [(i, i=1,5 )] ! OK
! Valid: index-name (has a scope of the statement or construct)
forall (i = 1:5) ! OK
end forall
! Valid: index-name (has a scope of the statement or construct)
do concurrent (i = 1:5) ! OK
end do
! Invalid: io-implied-do
print *, (i, i=1,5 ) ! { dg-error "PROTECTED and can not appear in a variable definition context .iterator variable." }
! Invalid: do-variable in a do-stmt
do i = 1, 5 ! { dg-error "PROTECTED and can not appear in a variable definition context .iterator variable." }
end do
end subroutine test1
subroutine test2(i)
implicit none
integer, intent(in) :: i
integer :: A(5)
! Valid: data-implied-do (has a scope of the statement or construct)
DATA (A(i), i=1,5)/5*42/ ! OK
! Valid: ac-implied-do (has a scope of the statement or construct)
print *, [(i, i=1,5 )] ! OK
! Valid: index-name (has a scope of the statement or construct)
forall (i = 1:5) ! OK
end forall
! Valid: index-name (has a scope of the statement or construct)
do concurrent (i = 1:5) ! OK
end do
! Invalid: io-implied-do
print *, (i, i=1,5 ) ! { dg-error "INTENT.IN. in variable definition context .iterator variable." }
! Invalid: do-variable in a do-stmt
do i = 1, 5 ! { dg-error "INTENT.IN. in variable definition context .iterator variable." }
end do
end subroutine test2
pure subroutine test3()
use m
implicit none
integer :: A(5)
!DATA (A(j), j=1,5)/5*42/ ! Not allowed in pure
! Valid: ac-implied-do (has a scope of the statement or construct)
A = [(j, j=1,5 )] ! OK
! Valid: index-name (has a scope of the statement or construct)
forall (j = 1:5) ! OK
end forall
! Valid: index-name (has a scope of the statement or construct)
do concurrent (j = 1:5) ! OK
end do
! print *, (j, j=1,5 ) ! I/O not allowed in PURE
! Invalid: do-variable in a do-stmt
do j = 1, 5 ! { dg-error "variable definition context .iterator variable. at .1. in PURE procedure" }
end do
end subroutine test3
| gpl-2.0 |
FrontISTR/FrontISTR | fistr1/src/lib/element/hex20n.f90 | 1 | 4558 | !-------------------------------------------------------------------------------
! Copyright (c) 2019 FrontISTR Commons
! This software is released under the MIT License, see LICENSE.txt
!-------------------------------------------------------------------------------
!> \brief This module contains functions for interpolation in 20 node
!! hexahedral element (Serendipity interpolation)
module shape_hex20n
integer, parameter, private :: kreal = kind(0.0d0)
contains
subroutine ShapeFunc_hex20n(localcoord,func)
real(kind=kreal) :: localcoord(3)
real(kind=kreal) :: func(20)
real(kind=kreal) RI,SI,TI,RP,SP,TP,RM,SM,TM
RI=localcoord(1); SI=localcoord(2); TI=localcoord(3)
RP=1.0+RI; SP=1.0+SI; TP=1.0+TI
RM=1.0-RI; SM=1.0-SI; TM=1.0-TI
func(1)=-0.125*RM*SM*TM*(2.0+RI+SI+TI)
func(2)=-0.125*RP*SM*TM*(2.0-RI+SI+TI)
func(3)=-0.125*RP*SP*TM*(2.0-RI-SI+TI)
func(4)=-0.125*RM*SP*TM*(2.0+RI-SI+TI)
func(5)=-0.125*RM*SM*TP*(2.0+RI+SI-TI)
func(6)=-0.125*RP*SM*TP*(2.0-RI+SI-TI)
func(7)=-0.125*RP*SP*TP*(2.0-RI-SI-TI)
func(8)=-0.125*RM*SP*TP*(2.0+RI-SI-TI)
func(9)=0.25*(1.0-RI**2)*SM*TM
func(10)=0.25*RP*(1.0-SI**2)*TM
func(11)=0.25*(1.0-RI**2)*SP*TM
func(12)=0.25*RM*(1.0-SI**2)*TM
func(13)=0.25*(1.0-RI**2)*SM*TP
func(14)=0.25*RP*(1.0-SI**2)*TP
func(15)=0.25*(1.0-RI**2)*SP*TP
func(16)=0.25*RM*(1.0-SI**2)*TP
func(17)=0.25*RM*SM*(1.0-TI**2)
func(18)=0.25*RP*SM*(1.0-TI**2)
func(19)=0.25*RP*SP*(1.0-TI**2)
func(20)=0.25*RM*SP*(1.0-TI**2)
end subroutine
subroutine ShapeDeriv_hex20n(localcoord,func)
real(kind=kreal) :: localcoord(3)
real(kind=kreal) :: func(20,3)
real(kind=kreal) RI,SI,TI,RP,SP,TP,RM,SM,TM
RI=localcoord(1); SI=localcoord(2); TI=localcoord(3)
RP=1.d0+RI; SP=1.d0+SI; TP=1.d0+TI
RM=1.d0-RI; SM=1.d0-SI; TM=1.d0-TI
! FOR R-COORDINATE
func(1,1)=-0.125*RM*SM*TM+0.125*SM*TM*(2.0+RI+SI+TI)
func(2,1)=+0.125*RP*SM*TM-0.125*SM*TM*(2.0-RI+SI+TI)
func(3,1)=+0.125*RP*SP*TM-0.125*SP*TM*(2.0-RI-SI+TI)
func(4,1)=-0.125*RM*SP*TM+0.125*SP*TM*(2.0+RI-SI+TI)
func(5,1)=-0.125*RM*SM*TP+0.125*SM*TP*(2.0+RI+SI-TI)
func(6,1)=+0.125*RP*SM*TP-0.125*SM*TP*(2.0-RI+SI-TI)
func(7,1)=+0.125*RP*SP*TP-0.125*SP*TP*(2.0-RI-SI-TI)
func(8,1)=-0.125*RM*SP*TP+0.125*SP*TP*(2.0+RI-SI-TI)
func(9,1 )=-0.50*RI*SM*TM
func(10,1)=+0.25*(1.0-SI**2)*TM
func(11,1)=-0.50*RI*SP*TM
func(12,1)=-0.25*(1.0-SI**2)*TM
func(13,1)=-0.50*RI*SM*TP
func(14,1)=+0.25*(1.0-SI**2)*TP
func(15,1)=-0.50*RI*SP*TP
func(16,1)=-0.25*(1.0-SI**2)*TP
func(17,1)=-0.25*SM*(1.0-TI**2)
func(18,1)=+0.25*SM*(1.0-TI**2)
func(19,1)=+0.25*SP*(1.0-TI**2)
func(20,1)=-0.25*SP*(1.0-TI**2)
! FOR S-COORDINATE
func(1,2)=-0.125*RM*SM*TM+0.125*RM*TM*(2.0+RI+SI+TI)
func(2,2)=-0.125*RP*SM*TM+0.125*RP*TM*(2.0-RI+SI+TI)
func(3,2)=+0.125*RP*SP*TM-0.125*RP*TM*(2.0-RI-SI+TI)
func(4,2)=+0.125*RM*SP*TM-0.125*RM*TM*(2.0+RI-SI+TI)
func(5,2)=-0.125*RM*SM*TP+0.125*RM*TP*(2.0+RI+SI-TI)
func(6,2)=-0.125*RP*SM*TP+0.125*RP*TP*(2.0-RI+SI-TI)
func(7,2)=+0.125*RP*SP*TP-0.125*RP*TP*(2.0-RI-SI-TI)
func(8,2)=+0.125*RM*SP*TP-0.125*RM*TP*(2.0+RI-SI-TI)
func(9,2)=-0.25*(1.0-RI**2)*TM
func(10,2)=-0.50*RP*SI*TM
func(11,2)=+0.25*(1.0-RI**2)*TM
func(12,2)=-0.50*RM*SI*TM
func(13,2)=-0.25*(1.0-RI**2)*TP
func(14,2)=-0.50*RP*SI*TP
func(15,2)=+0.25*(1.0-RI**2)*TP
func(16,2)=-0.50*RM*SI*TP
func(17,2)=-0.25*RM*(1.0-TI**2)
func(18,2)=-0.25*RP*(1.0-TI**2)
func(19,2)=+0.25*RP*(1.0-TI**2)
func(20,2)=+0.25*RM*(1.0-TI**2)
! FOR T-COORDINATE
func(1,3)=-0.125*RM*SM*TM+0.125*RM*SM*(2.0+RI+SI+TI)
func(2,3)=-0.125*RP*SM*TM+0.125*RP*SM*(2.0-RI+SI+TI)
func(3,3)=-0.125*RP*SP*TM+0.125*RP*SP*(2.0-RI-SI+TI)
func(4,3)=-0.125*RM*SP*TM+0.125*RM*SP*(2.0+RI-SI+TI)
func(5,3)=+0.125*RM*SM*TP-0.125*RM*SM*(2.0+RI+SI-TI)
func(6,3)=+0.125*RP*SM*TP-0.125*RP*SM*(2.0-RI+SI-TI)
func(7,3)=+0.125*RP*SP*TP-0.125*RP*SP*(2.0-RI-SI-TI)
func(8,3)=+0.125*RM*SP*TP-0.125*RM*SP*(2.0+RI-SI-TI)
func(9,3)=-0.25*(1.0-RI**2)*SM
func(10,3)=-0.25*RP*(1.0-SI**2)
func(11,3)=-0.25*(1.0-RI**2)*SP
func(12,3)=-0.25*RM*(1.0-SI**2)
func(13,3)=0.25*(1.0-RI**2)*SM
func(14,3)=0.25*RP*(1.0-SI**2)
func(15,3)=0.25*(1.0-RI**2)*SP
func(16,3)=0.25*RM*(1.0-SI**2)
func(17,3)=-0.5*RM*SM*TI
func(18,3)=-0.5*RP*SM*TI
func(19,3)=-0.5*RP*SP*TI
func(20,3)=-0.5*RM*SP*TI
end subroutine
end module
| mit |
ovilab/atomify-lammps | libs/lammps/lib/linalg/dsygvd.f | 48 | 12188 | *> \brief \b DSYGST
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download DSYGVD + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsygvd.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsygvd.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsygvd.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE DSYGVD( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK,
* LWORK, IWORK, LIWORK, INFO )
*
* .. Scalar Arguments ..
* CHARACTER JOBZ, UPLO
* INTEGER INFO, ITYPE, LDA, LDB, LIWORK, LWORK, N
* ..
* .. Array Arguments ..
* INTEGER IWORK( * )
* DOUBLE PRECISION A( LDA, * ), B( LDB, * ), W( * ), WORK( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DSYGVD computes all the eigenvalues, and optionally, the eigenvectors
*> of a real generalized symmetric-definite eigenproblem, of the form
*> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A and
*> B are assumed to be symmetric 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] ITYPE
*> \verbatim
*> ITYPE is INTEGER
*> Specifies the problem type to be solved:
*> = 1: A*x = (lambda)*B*x
*> = 2: A*B*x = (lambda)*x
*> = 3: B*A*x = (lambda)*x
*> \endverbatim
*>
*> \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,out] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (LDA, N)
*> On entry, the symmetric matrix A. If UPLO = 'U', the
*> leading N-by-N upper triangular part of A contains the
*> upper triangular part of the matrix A. If UPLO = 'L',
*> the leading N-by-N lower triangular part of A contains
*> the lower triangular part of the matrix A.
*>
*> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
*> matrix Z of eigenvectors. The eigenvectors are normalized
*> as follows:
*> if ITYPE = 1 or 2, Z**T*B*Z = I;
*> if ITYPE = 3, Z**T*inv(B)*Z = I.
*> If JOBZ = 'N', then on exit the upper triangle (if UPLO='U')
*> or the lower triangle (if UPLO='L') of A, including the
*> diagonal, is destroyed.
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of the array A. LDA >= max(1,N).
*> \endverbatim
*>
*> \param[in,out] B
*> \verbatim
*> B is DOUBLE PRECISION array, dimension (LDB, N)
*> On entry, the symmetric matrix B. If UPLO = 'U', the
*> leading N-by-N upper triangular part of B contains the
*> upper triangular part of the matrix B. If UPLO = 'L',
*> the leading N-by-N lower triangular part of B contains
*> the lower triangular part of the matrix B.
*>
*> On exit, if INFO <= N, the part of B containing the matrix is
*> overwritten by the triangular factor U or L from the Cholesky
*> factorization B = U**T*U or B = L*L**T.
*> \endverbatim
*>
*> \param[in] LDB
*> \verbatim
*> LDB is INTEGER
*> The leading dimension of the array B. LDB >= max(1,N).
*> \endverbatim
*>
*> \param[out] W
*> \verbatim
*> W is DOUBLE PRECISION array, dimension (N)
*> If INFO = 0, the eigenvalues in ascending order.
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is DOUBLE PRECISION 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 >= 2*N+1.
*> If JOBZ = 'V' and N > 1, LWORK >= 1 + 6*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 INFO = 0, IWORK(1) returns the optimal LIWORK.
*> \endverbatim
*>
*> \param[in] LIWORK
*> \verbatim
*> LIWORK is INTEGER
*> The dimension of the array IWORK.
*> If N <= 1, LIWORK >= 1.
*> If JOBZ = 'N' and 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: DPOTRF or DSYEVD returned an error code:
*> <= N: if INFO = i and JOBZ = 'N', then the algorithm
*> failed to converge; i off-diagonal elements of an
*> intermediate tridiagonal form did not converge to
*> zero;
*> if INFO = i and JOBZ = 'V', then 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);
*> > N: if INFO = N + i, for 1 <= i <= N, then the leading
*> minor of order i of 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 2011
*
*> \ingroup doubleSYeigen
*
*> \par Further Details:
* =====================
*>
*> \verbatim
*>
*> Modified so that no backsubstitution is performed if DSYEVD fails to
*> converge (NEIG in old code could be greater than N causing out of
*> bounds reference to A - reported by Ralf Meyer). Also corrected the
*> description of INFO and the test on ITYPE. Sven, 16 Feb 05.
*> \endverbatim
*
*> \par Contributors:
* ==================
*>
*> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
*>
* =====================================================================
SUBROUTINE DSYGVD( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK,
$ LWORK, IWORK, LIWORK, 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 JOBZ, UPLO
INTEGER INFO, ITYPE, LDA, LDB, LIWORK, LWORK, N
* ..
* .. Array Arguments ..
INTEGER IWORK( * )
DOUBLE PRECISION A( LDA, * ), B( LDB, * ), W( * ), WORK( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ONE
PARAMETER ( ONE = 1.0D+0 )
* ..
* .. Local Scalars ..
LOGICAL LQUERY, UPPER, WANTZ
CHARACTER TRANS
INTEGER LIOPT, LIWMIN, LOPT, LWMIN
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. External Subroutines ..
EXTERNAL DPOTRF, DSYEVD, DSYGST, DTRMM, DTRSM, XERBLA
* ..
* .. Intrinsic Functions ..
INTRINSIC DBLE, MAX
* ..
* .. 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 + 6*N + 2*N**2
ELSE
LIWMIN = 1
LWMIN = 2*N + 1
END IF
LOPT = LWMIN
LIOPT = LIWMIN
IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
INFO = -1
ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
INFO = -2
ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
INFO = -3
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
END IF
*
IF( INFO.EQ.0 ) THEN
WORK( 1 ) = LOPT
IWORK( 1 ) = LIOPT
*
IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
INFO = -11
ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
INFO = -13
END IF
END IF
*
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'DSYGVD', -INFO )
RETURN
ELSE IF( LQUERY ) THEN
RETURN
END IF
*
* Quick return if possible
*
IF( N.EQ.0 )
$ RETURN
*
* Form a Cholesky factorization of B.
*
CALL DPOTRF( UPLO, N, B, LDB, INFO )
IF( INFO.NE.0 ) THEN
INFO = N + INFO
RETURN
END IF
*
* Transform problem to standard eigenvalue problem and solve.
*
CALL DSYGST( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
CALL DSYEVD( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, IWORK, LIWORK,
$ INFO )
LOPT = MAX( DBLE( LOPT ), DBLE( WORK( 1 ) ) )
LIOPT = MAX( DBLE( LIOPT ), DBLE( IWORK( 1 ) ) )
*
IF( WANTZ .AND. INFO.EQ.0 ) THEN
*
* Backtransform eigenvectors to the original problem.
*
IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
*
* For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
* backtransform eigenvectors: x = inv(L)**T*y or inv(U)*y
*
IF( UPPER ) THEN
TRANS = 'N'
ELSE
TRANS = 'T'
END IF
*
CALL DTRSM( 'Left', UPLO, TRANS, 'Non-unit', N, N, ONE,
$ B, LDB, A, LDA )
*
ELSE IF( ITYPE.EQ.3 ) THEN
*
* For B*A*x=(lambda)*x;
* backtransform eigenvectors: x = L*y or U**T*y
*
IF( UPPER ) THEN
TRANS = 'T'
ELSE
TRANS = 'N'
END IF
*
CALL DTRMM( 'Left', UPLO, TRANS, 'Non-unit', N, N, ONE,
$ B, LDB, A, LDA )
END IF
END IF
*
WORK( 1 ) = LOPT
IWORK( 1 ) = LIOPT
*
RETURN
*
* End of DSYGVD
*
END
| gpl-3.0 |
tuxillo/aarch64-dragonfly-gcc | gcc/testsuite/gfortran.dg/widechar_intrinsics_1.f90 | 181 | 4725 | ! { dg-do compile }
! { dg-options "-fmax-errors=100000" }
character(kind=1,len=20) :: s1, t1, u1, v1
character(kind=4,len=20) :: s4, t4, u4, v4
call date_and_time(date=s1)
call date_and_time(time=s1)
call date_and_time(zone=s1)
call date_and_time(s1, t1, u1)
call date_and_time(date=s4) ! { dg-error "must be of kind 1" }
call date_and_time(time=s4) ! { dg-error "must be of kind 1" }
call date_and_time(zone=s4) ! { dg-error "must be of kind 1" }
call date_and_time(s4, t4, u4) ! { dg-error "must be of kind 1" }
call get_command(s1)
call get_command(s4) ! { dg-error "Type of argument" }
call get_command_argument(1, s1)
call get_command_argument(1, s4) ! { dg-error "Type of argument" }
call get_environment_variable("PATH", s1)
call get_environment_variable(s1)
call get_environment_variable(s1, t1)
call get_environment_variable(4_"PATH", s1) ! { dg-error "Type of argument" }
call get_environment_variable(s4) ! { dg-error "Type of argument" }
call get_environment_variable(s1, t4) ! { dg-error "Type of argument" }
call get_environment_variable(s4, t1) ! { dg-error "Type of argument" }
print *, lge(s1,t1)
print *, lge(s1,"foo")
print *, lge("foo",t1)
print *, lge("bar","foo")
print *, lge(s1,t4) ! { dg-error "must be of kind 1" }
print *, lge(s1,4_"foo") ! { dg-error "must be of kind 1" }
print *, lge("foo",t4) ! { dg-error "must be of kind 1" }
print *, lge("bar",4_"foo") ! { dg-error "must be of kind 1" }
print *, lge(s4,t1) ! { dg-error "must be of kind 1" }
print *, lge(s4,"foo") ! { dg-error "must be of kind 1" }
print *, lge(4_"foo",t1) ! { dg-error "must be of kind 1" }
print *, lge(4_"bar","foo") ! { dg-error "must be of kind 1" }
print *, lge(s4,t4) ! { dg-error "must be of kind 1" }
print *, lge(s4,4_"foo") ! { dg-error "must be of kind 1" }
print *, lge(4_"foo",t4) ! { dg-error "must be of kind 1" }
print *, lge(4_"bar",4_"foo") ! { dg-error "must be of kind 1" }
print *, lgt(s1,t1)
print *, lgt(s1,"foo")
print *, lgt("foo",t1)
print *, lgt("bar","foo")
print *, lgt(s1,t4) ! { dg-error "must be of kind 1" }
print *, lgt(s1,4_"foo") ! { dg-error "must be of kind 1" }
print *, lgt("foo",t4) ! { dg-error "must be of kind 1" }
print *, lgt("bar",4_"foo") ! { dg-error "must be of kind 1" }
print *, lgt(s4,t1) ! { dg-error "must be of kind 1" }
print *, lgt(s4,"foo") ! { dg-error "must be of kind 1" }
print *, lgt(4_"foo",t1) ! { dg-error "must be of kind 1" }
print *, lgt(4_"bar","foo") ! { dg-error "must be of kind 1" }
print *, lgt(s4,t4) ! { dg-error "must be of kind 1" }
print *, lgt(s4,4_"foo") ! { dg-error "must be of kind 1" }
print *, lgt(4_"foo",t4) ! { dg-error "must be of kind 1" }
print *, lgt(4_"bar",4_"foo") ! { dg-error "must be of kind 1" }
print *, lle(s1,t1)
print *, lle(s1,"foo")
print *, lle("foo",t1)
print *, lle("bar","foo")
print *, lle(s1,t4) ! { dg-error "must be of kind 1" }
print *, lle(s1,4_"foo") ! { dg-error "must be of kind 1" }
print *, lle("foo",t4) ! { dg-error "must be of kind 1" }
print *, lle("bar",4_"foo") ! { dg-error "must be of kind 1" }
print *, lle(s4,t1) ! { dg-error "must be of kind 1" }
print *, lle(s4,"foo") ! { dg-error "must be of kind 1" }
print *, lle(4_"foo",t1) ! { dg-error "must be of kind 1" }
print *, lle(4_"bar","foo") ! { dg-error "must be of kind 1" }
print *, lle(s4,t4) ! { dg-error "must be of kind 1" }
print *, lle(s4,4_"foo") ! { dg-error "must be of kind 1" }
print *, lle(4_"foo",t4) ! { dg-error "must be of kind 1" }
print *, lle(4_"bar",4_"foo") ! { dg-error "must be of kind 1" }
print *, llt(s1,t1)
print *, llt(s1,"foo")
print *, llt("foo",t1)
print *, llt("bar","foo")
print *, llt(s1,t4) ! { dg-error "must be of kind 1" }
print *, llt(s1,4_"foo") ! { dg-error "must be of kind 1" }
print *, llt("foo",t4) ! { dg-error "must be of kind 1" }
print *, llt("bar",4_"foo") ! { dg-error "must be of kind 1" }
print *, llt(s4,t1) ! { dg-error "must be of kind 1" }
print *, llt(s4,"foo") ! { dg-error "must be of kind 1" }
print *, llt(4_"foo",t1) ! { dg-error "must be of kind 1" }
print *, llt(4_"bar","foo") ! { dg-error "must be of kind 1" }
print *, llt(s4,t4) ! { dg-error "must be of kind 1" }
print *, llt(s4,4_"foo") ! { dg-error "must be of kind 1" }
print *, llt(4_"foo",t4) ! { dg-error "must be of kind 1" }
print *, llt(4_"bar",4_"foo") ! { dg-error "must be of kind 1" }
print *, selected_char_kind("foo")
print *, selected_char_kind(4_"foo") ! { dg-error "must be of kind 1" }
print *, selected_char_kind(s1)
print *, selected_char_kind(s4) ! { dg-error "must be of kind 1" }
end
| gpl-2.0 |
Heathckliff/MeshTools | Fortran/gmsh2su2_3D.f90 | 3 | 20567 | ! ====================
! README Gmsh2SU3D ver 0.02
! ====================
!
! Original version by Ceanwang@gmail.com, Jan 2012
!
! Adapted from gmsh2dolfyn.f90 developed by dolfyn team.
! For dolfyn, please visit http://www.dolfyn.net/index_en.html
!
! Support Gmsh 2.5.0
!
! Purpose
! -------
! This Fortran95 program translates a mesh file from Gmsh (.msh) format
! to Su2 format.
!
! Input and Output
! ----------------
! Input : A Gmsh .msh file (version 2.0, ascii format).
! Output: SU2 files.
!
! Running the Program
!--------------------
! First compile it using a Fortran95 compiler (eg g95 or gfortran).
! Run it from the command line.
! The program prompts for the name of the input file.
!
! Bug reports
! -----------
! Please report bugs to ceanwang@gmail.com
!
! Important note about the Gmsh msh format and Physical Groups.
! -------------------------------------------------------------
! In order to define boundary conditions, the Gmsh geometry-builder allows a
! group of faces to be assigned a common 'physical group' label. The mesh
! inherits this label, and the label is used in the .su2 file.
!
! When saving the mesh, the default is to save only mesh elements with a
! physical group label. This means that some mesh elements will be missing,
! unless every mesh element belongs to a physical group.
!
! For example in the adapted gmsh tutorial t2.geo enter:
!
! Physical Volume ("Fluid") = {119,120};
! Physical Surface("Inlet") = {111};
! Physical Surface("Outlet") = {132};
!
! Mesh 3D and save it as t2.msh
!
!========================================================================
!========================================================================
!========================================================================
SUBROUTINE UPPERCASE(STR)
IMPLICIT NONE
CHARACTER(LEN=*), INTENT(IN OUT) :: STR
INTEGER :: I, DEL
DEL = IACHAR('a') - IACHAR('A')
DO I = 1, LEN_TRIM(STR)
IF (LGE(STR(I:I),'a') .AND. LLE(STR(I:I),'z')) THEN
STR(I:I) = ACHAR(IACHAR(STR(I:I)) - DEL)
END IF
END DO
RETURN
END SUBROUTINE UPPERCASE
integer function lens(string)
character(len=*) string
do i=len(string),0,-1
if( string(i:i) .ne. ' ') goto 10
end do
i = 0
10 continue
lens = i
end function lens
!======================================================================
subroutine openfile(iunit,casename,extension,reqform,status,idebug)
character(len=*) casename
character(len=*) extension
character(len=*) reqform
character(len=*) status
character(len=48) filename
character(len=11) form
logical exists
filename = casename(1:lens(casename))//extension(1:lens(extension))
length = lens(filename)
if( idebug > 2 )write(*,*) 'Opening ',filename(1:length)
if( status(1:3) == 'OLD' )then
inquire(file=filename(1:length),exist=exists,form=form)
if( .not. exists )then
write(*,*) '*** Error: File ',filename(1:length),' does not exist'
stop
endif
endif
open(iunit,file=filename(1:length),form=reqform,status=status)
if( idebug >= 2 ) write(*,*) 'File ',filename(1:length),' opened'
end subroutine openfile
!==============================================================================
program gmsh2SU2
implicit none
integer, parameter :: IOinp = 13, IOcel = 14 ! I/O file numbers
integer, parameter :: IOdbg = 63, IOcfg = 12
integer, parameter :: IOgmsh= 24 !Gmsh mesh file
integer :: Ninlet = 0
integer :: Noutlet = 0
integer :: Nsurface = 0
integer :: isur = 0
integer :: debug = 0
integer, parameter :: version = 0530
character(len=128) :: line
integer, parameter :: MaxNames = 100
integer, parameter :: MaxNperBnd = 500
integer, parameter :: MaxNodes = 90000
character(len=64), dimension(MaxNames) :: Names
character(len=64), dimension(MaxNames) :: Regions
integer, dimension(MaxNames) :: ICTID = -1
integer, dimension(MaxNames) :: Partition= 1
logical, dimension(MaxNames) :: Fluid = .false.
logical, dimension(MaxNames) :: Boundary = .false.
character(len=64) :: casename = 'su2'
character(len=72) :: c_input1, c_input2, c_input3
integer i, j, k, ie, icel, ibnd, iloop,ii
integer tbnd(maxnames)
integer nbnd
!
! nodes/vertices
!
integer n_nodes,inode
real node(MaxNodes,3)
integer mytags(MaxNames)
integer tv0(MaxNperBnd,MaxNames)
integer tv1(MaxNperBnd,MaxNames)
integer tv2(MaxNperBnd,MaxNames)
integer tv3(MaxNperBnd,MaxNames)
integer tv4(MaxNperBnd,MaxNames)
!
! there are 19 gmsh element types: \
!
! 1 : 2-node line
! 2 : 3-node triangle (face)
! 3 : 4-node quadrangle (face)
! 4 : 4-node tetrahedron
! 5 : 8-node hexahedron (eg cube)
! 6 : 6-node triangular-prism
! 7 : 5-node pyramid
!
! 8-14: 'second-order' elements. Ref Gmsh manual.
! 15 : 1-node point
! 16-19: more second-order FEM elements
!
! the nodes/vertices for each element are read into the
! v array.
!
! each element can have several tags.
! the first tag gives the physical_group number.
! all elements on the same boundary have the same physical_group number.
!
integer, parameter :: element_type(19) = &
(/ 2,3,4,4,8,6,5,3,6,9,10,27,18,14,1,8,20,15,13 /)
integer :: n_elements, ielement, ielement_type, n_tags, n_names, lens
integer :: tags(64), v(27)
integer :: bmarknew,bmarkold
integer :: i3, i4q, i4, i5, i6, i8
integer :: i2
integer :: ivs = 0
if( size(v) /= maxval(element_type) )then
stop'bug: error in dimensions of array v'
endif
!
! read the gmsh filename, then open the .msh file
!
write(*,*) 'Gmsh2SU2: Converts a Gmsh mesh file to SU2 format.'
write(*,*) '(Input must be in Gmsh version 2.0 ascii format.'
write(*,*) ' Output is in SU2 format.)'
write(*,*) ' '
write(*,*) 'Input Gmsh filename, excluding the .msh suffix'
read(*,'(A)') casename
write(*,*) 'Opening the Gmsh file'
call openfile(IOgmsh,casename,'.msh','FORMATTED','OLD',debug)
!
! read the Gmsh file header
!
write(*,*)'Reading MeshFormat'
read(IOgmsh,*) c_input1
call check_input_character(c_input1,'$MeshFormat')
read(IOgmsh,*) c_input1,c_input2,c_input3
if( c_input1 == '2.2' )then
ivs = 22
else if( c_input1 == '2.1' )then
ivs = 21
else if( c_input1 == '2' )then
ivs = 20
else
write(*,*) '*** WARNING: unknown Gmsh version'
write(*,*) '*** Unexpected results might happen'
ivs = 21
endif
if( ivs == 20 )then
call check_input_character(c_input1,'2')
else if( ivs == 21 )then
call check_input_character(c_input1,'2.1')
else if( ivs == 22 )then
call check_input_character(c_input1,'2.2')
else
write(*,*) '*** Version found ',c_input1
endif
call check_input_character(c_input2,'0')
call check_input_character(c_input3,'8')
write(*,*) 'MeshFormat: ', c_input1(1:lens(c_input1)),' ', &
c_input2(1:lens(c_input2)),' ', &
c_input3(1:lens(c_input3))
read(IOgmsh,*) c_input1
call check_input_character(c_input1,'$EndMeshFormat')
!
! read the Gmsh PhysicalNames
!
write(*,*)'Reading PhysicalNames'
read(IOgmsh,*) c_input1
call check_input_character(c_input1,'$PhysicalNames')
read(IOgmsh,*) n_names
if( n_names <= 0 )then
write(*,*) 'error: number of names must be a positive number'
stop
endif
if( ivs == 20 )then
do i=1,n_names
!read(IOgmsh,*) k,j,c_input1
read(IOgmsh,*) j,c_input1
write(*,*) 'Name ',j,'-> ', c_input1
Names(j) = c_input1
end do
else if( ivs == 21 )then
do i=1,n_names
read(IOgmsh,*) k,j,c_input1
write(*,*) 'Name ',j,'-> ', c_input1
Names(j) = c_input1
end do
else
do i=1,n_names
read(IOgmsh,*) k,j,c_input1
write(*,*) 'Name ',j,'-> ', c_input1
Names(j) = c_input1
end do
endif
do i=1,n_names
CALL UPPERCASE(Names(i))
enddo
read(IOgmsh,*) c_input1
call check_input_character(c_input1,'$EndPhysicalNames')
!
! read the nodes from the .msh file and write them
! to the .vrt file.
!
write(*,*)'Reading Nodes'
read(IOgmsh,*) c_input1
call check_input_character(c_input1,'$Nodes')
!nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
read(IOgmsh,*) n_nodes
if( n_nodes <= 0 )then
write(*,*) 'error: number of nodes must be a positive number'
stop
endif
if( n_nodes > MaxNodes )then
write(*,*) 'error: The Gmsh file contains ',n_nodes,' nodes.'
write(*,*) 'Gmsh2Su2 is hard-wired for a maximum of ',MaxNodes,&
'nodes. The dimension of this array needs to be increased.'
stop
endif
!
! open the su2 .vrt.su2 file
!
!write(*,*) 'Creating the su2 .vrt.su2 file'
!call openfile(IOvrt,casename,'.vrt.su2','FORMATTED','UNKNOWN',debug)
nodes: do iloop=1,n_nodes
read(IOgmsh,*) inode,(node(iloop,i), i=1,3)
!write(IOvrt,'(3g16.9,6x,i9)') (node(iloop,i),i=1,3),inode-1
enddo nodes
write(*,*) 'Nodes written ',n_nodes
!
! close the su2 .vrt.su2 file
!
!close(IOvrt)
read(IOgmsh,*) c_input1
call check_input_character(c_input1,'$EndNodes')
!eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
!
! read the elements from the .msh file and write them
! to the .cel and .bnd files.
!
read(IOgmsh,*) c_input1
call check_input_character(c_input1,'$Elements')
read(IOgmsh,*) n_elements
if( n_elements <= 0 )then
write(*,*) 'error: number of elements must be a positive number'
stop
endif
write(*,*) 'Total Gmsh elements to be read in:',n_elements
!
! open the su2 .cel files
!
write(*,*) 'Creating the .su2 files'
call openfile(IOcel,casename,'.su2','FORMATTED','UNKNOWN',debug)
write(IOcel,101) 3
101 format('NDIME= ',i1)
!
! note in Gmsh fluid cells and boudaries can be mixed
! we just keep track on them both
! remind default region is not assigned
!
icel = 0
ibnd = 0
nbnd=0
tbnd(nbnd)=0
i2 = 0
i3 = 0
i4q = 0
i4 = 0
i5 = 0
i6 = 0
i8 = 0
bmarkOld=0
do ie=1,n_elements
read(IOgmsh,*) ielement, ielement_type, n_tags
if( ivs <= 21 )then
if( n_tags /= 3 ) write(*,*) 'tag error n_tags /= 3:',ielement,n_tags
else
if( n_tags /= 2 ) write(*,*) 'tag error n_tags /= 2:',ielement,n_tags
endif
call check_element_type(ielement_type,element_type)
call check_n_tags(n_tags,tags)
backspace(IOgmsh)
!
! we need to circumvent backspace but
! advance='no' requires fixed format
! just keep it for now.
!
!
! now we know what to to expect to find on the line
!
read(IOgmsh,*) ielement, ielement_type, &
n_tags, (tags(i),i=1,n_tags),&
(v(i),i=1,element_type(ielement_type))
do ii=1,element_type(ielement_type)
v(ii)=v(ii)-1
end do
bmarkNew=tags(1)
if( 4 <= ielement_type .and. ielement_type <= 7 )then
if (icel==0) then
write(IOcel,121) n_elements-ibnd
121 format('NELEM= ',i10)
endif
icel = icel + 1
if( .not. Fluid(tags(1)) ) Fluid(tags(1)) = .true.
if( Boundary(tags(1)) )then
write(*,*) 'Inconsistent data: Physical names ids overlap 1'
endif
1 format(i8,8(1x,i8),2(1x,i4))
select case(ielement_type)
case(4) ! 4-node tet
write(IOcel,*) 10,v(1),v(2),v(3),v(4),icel-1
i4 = i4 + 1
case(5) ! 8-node hex
write(IOcel,*) 12,v(1),v(2),v(3),v(4), v(5),v(6),v(7),v(8),icel-1
!tags(1),tags(3)
i8 = i8 + 1
case(6) ! 6-node prism or wedge
write(IOcel,*) 13,v(1),v(2),v(3), v(4),v(5),v(6),icel-1
i6 = i6 + 1
case(7) ! 5-node pyramid
write(IOcel,*) 14,v(1),v(2),v(3),v(4), v(5),icel-1
i5 = i5 + 1
case default
write(*,*)'internal error 1'
end select
elseif( ielement_type == 2 .or. ielement_type == 3 )then
if (bmarkNew/=bmarkOld) then
bmarkOld=bmarkNew
nbnd=nbnd+1
tbnd(nbnd)=0
endif
ibnd = ibnd + 1
tbnd(nbnd) = tbnd(nbnd) + 1
if( .not. Boundary(tags(1)) ) Boundary(tags(1)) = .true.
if( Fluid(tags(1)) )then
write(*,*) 'Inconsistent data: Physical names ids overlap 2'
endif
select case(ielement_type)
case(2) ! 3-node tri
!write(IObnd,*) 5, v(1),v(2),v(3)
mytags(nbnd)=tags(1)
tv0(tbnd(nbnd),nbnd)=5
tv1(tbnd(nbnd),nbnd)=v(1)
tv2(tbnd(nbnd),nbnd)=v(2)
tv3(tbnd(nbnd),nbnd)=v(3)
i3 = i3 + 1
case(3) ! 4-node quad
!write(IObnd,1) 8, v(1),v(2),v(3),v(4)
mytags(nbnd)=tags(1)
tv0(tbnd(nbnd),nbnd)=8
tv1(tbnd(nbnd),nbnd)=v(1)
tv2(tbnd(nbnd),nbnd)=v(2)
tv3(tbnd(nbnd),nbnd)=v(3)
tv4(tbnd(nbnd),nbnd)=v(4)
i4q = i4q + 1
case default
write(*,*)'internal error 2'
end select
elseif( ielement_type == 1 )then
! 2- nodes line
!write(IObnd,*) 3, v(1),v(2)
mytags(nbnd)=tags(1)
tv0(tbnd(nbnd),nbnd)=3
tv1(tbnd(nbnd),nbnd)=v(1)
tv2(tbnd(nbnd),nbnd)=v(2)
i2 = i2 + 1
else
write(*,*)'internal error 3'
endif
end do
read(IOgmsh,*) c_input1
call check_input_character(c_input1,'$EndElements')
!------------------------------------------------------------
! write out points
!------------------------------------------------------------
write(IOcel,91) n_nodes
91 format('NPOIN= ',i10)
do iloop=1,n_nodes
write(IOcel,'(3g16.9,6x,i9)') (node(iloop,i),i=1,3),iloop-1
enddo
write(IOcel,111) n_names-1
111 format('NMARK= ',i10)
do j=1,n_names-1
write(IOcel,141) mytags(j)
write(IOcel,151) tbnd(j)
do i=1,tbnd(j)
if (tv0(i,j)==5) then
write(IOcel,*) tv0(i,j), tv1(i,j),tv2(i,j),tv3(i,j)
endif
201 format(1x, i10,3f15.6)
if (tv0(i,j)==8) then
write(IOcel,*) tv0(i,j), tv1(i,j),tv2(i,j),tv3(i,j),tv4(i,j)
endif
211 format(1x, i10,4f15.6)
enddo
end do
141 format('MARKER_TAG= ',i3)
151 format('MARKER_ELEMS= ', i10)
close(IOcel)
if( i3 > 0 ) write(*,*) 'Triangle boundaries: ',i3
if( i4q > 0 ) write(*,*) 'Quad boundaries: ',i4q
if( i4 > 0 ) write(*,*) 'Tetrahedral cells: ',i4
if( i5 > 0 ) write(*,*) 'Pyramid cells: ',i5
if( i6 > 0 ) write(*,*) 'Prism cells: ',i6
if( i8 > 0 ) write(*,*) 'Hexahedral cells: ',i8
!------------------------------------------------------------
! finally write out the boundary names
!------------------------------------------------------------
do i=1,n_Names
if (Names(i)=='INLET') then
Ninlet=Ninlet+1
endif
if (Names(i)=='OUTLET') then
Noutlet=Noutlet+1
endif
enddo
Nsurface=N_names-Ninlet-Noutlet-1
write(*,*) 'Writing the .inp file'
call openfile(IOinp,casename,'_inp.txt','FORMATTED','UNKNOWN',debug)
write(IOinp,'('''')')
write(IOinp,'(''% -------------------- BOUNDARY CONDITION DEFINITION --------------------------%'')')
write(IOinp,'(''%'')')
write(IOinp,'(''% Euler wall boundary marker(s) (NONE = no marker)'')')
!write(IOinp,'(''MARKER_EULER='')') !( 3,4,5,6,7,8,9,10 )
if (N_names>0) then
write(IOinp,'( "MARKER_EULER=(" )',ADVANCE = "NO")
do i=1,N_names
if (Names(i) .ne. 'INLET' .and. Names(i) .ne. 'OUTLET' .and. Names(i) .ne. 'FLUID') then
write(IOinp,'( i4 )',ADVANCE = "NO") i
isur=isur+1
if (isur<Nsurface) then
write(IOinp,'( "," )',ADVANCE = "NO")
endif
endif
end do
write(IOinp,'( ")" )')
else
write(IOinp,'(''MARKER_EULER = NONE'')')
endif
write(IOinp,'(''%'')')
write(IOinp,'(''% Inlet boundary marker(s) (NONE = no marker) '')')
write(IOinp,'(''% Format: ( inlet marker, total temperature, total pressure, flow_direction_x, '')')
write(IOinp,'(''% flow_direction_y, flow_direction_z, ... ) where flow_direction is'')')
write(IOinp,'(''% a unit vector.'')')
if (Ninlet>0) then
do i=1,MaxNames
if (Names(i)=='INLET') then
write(IOinp,'( "MARKER_INLET=(",i4,",288.6, 102010.0, 1.0, 0.0, 0.0)" )') i
endif
end do
else
write(IOinp,'(''MARKER_INLET= NONE'')')
endif
write(IOinp,'(''%'')')
!1001 format(1x,'MARKER_INLET=(',i10,'288.6, 102010.0, 1.0, 0.0, 0.0)')
write(IOinp,'(''% Outlet boundary marker(s) (NONE = no marker)'')')
write(IOinp,'(''% Format: ( outlet marker, back pressure (static), ... )'')')
if (Noutlet>0) then
do i=1,MaxNames
if (Names(i)=='OUTLET') then
write(IOinp,'( "MARKER_OUTLET=(",i4,",101300.0)" )') i
endif
end do
else
write(IOinp,'(''MARKER_OUTLET= NONE'')')
endif
write(IOinp,'(''%'')')
write(IOinp,'(''% Marker(s) of the surface to be plotted or designed'')')
write(IOinp,'( ''MARKER_PLOTTING=(4,5)'' )') ! ( 5,4 )
write(IOinp,'(''%'')')
write(IOinp,'(''% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated'')')
write(IOinp,'( ''MARKER_MONITORING=(4,5)'' )') ! ( 5, 4 )
write(IOinp,'('''')')
!do i=1,MaxNames
! if( Boundary(i) )then
! if( i <= 9 )then
! write(IOinp,'(''rname,'',i1,'','',A64)') i,Names(i)
! elseif( i <= 99 )then
! write(IOinp,'(''rname,'',i2,'','',A64)') i,Names(i)
! elseif( i <= 999 )then
! write(IOinp,'(''rname,'',i3,'','',A64)') i,Names(i)
! elseif( i <= 9999 )then
! write(IOinp,'(''rname,'',i4,'','',A64)') i,Names(i)
! elseif( i <= 99999 )then
! write(IOinp,'(''rname,'',i5,'','',A64)') i,Names(i)
! else
! write(IOinp,'(''rname,'',i6,'','',A64)') i,Names(i)
! endif
! endif
! end do
close(IOinp)
write(*,*) 'Done gmsh2su2'
contains
!------------------------------------------------------------------------------------
subroutine check_input_character(c1,c2)
implicit none
character (len=*) :: c1, c2
if( c1(1:len(c2)) /= c2 )then
write(*,*) 'error reading Gmsh input file: ',&
'the following two characters should be the ',&
'same but differ ',c1(1:len(c2)),c2
stop
endif
end subroutine
subroutine check_element_type(ielement_type,element_type)
implicit none
integer ielement_type
integer element_type(:)
if( ielement_type < 0 )then
write(*,*) 'error reading Gmsh file: element type must be positive'
write(*,*) 'element type = ',ielement_type
stop
endif
if( ielement_type > size(element_type) )then
write(*,*) 'error reading Gmsh file: unrecognised element type'
write(*,*) 'element type ',ielement_type
write(*,*) 'max recognised element type ',size(element_type)
stop
endif
end subroutine
subroutine check_n_tags(ntags,itags)
implicit none
integer ntags
integer itags(:)
if( ntags > size(itags) )then
write(*,*) 'error: The Gmsh file contains ',ntags,' tags per element'
write(*,*) 'Gmsh2Su2 is hard-wired for a maximum of ',size(itags),&
'tags. The dimension of this array needs to be increased.'
stop
endif
end subroutine
end
| lgpl-2.1 |
intervigilium/cs259-or32-gcc | gcc/testsuite/gfortran.dg/char_pointer_func.f90 | 166 | 1196 | ! { dg-do run }
! { dg-options "-std=legacy" }
!
program char_pointer_func
! Test assignments from character pointer functions, required
! to fix PR17192 and PR17202
! Provided by Paul Thomas pault@gcc.gnu.org
implicit none
character*4 :: c0
character*4, pointer :: c1
character*4, pointer :: c2(:)
allocate (c1, c2(1))
! Check that we have not broken non-pointer characters.
c0 = foo ()
if (c0 /= "abcd") call abort ()
! Value assignments
c1 = sfoo ()
if (c1 /= "abcd") call abort ()
c2 = afoo (c0)
if (c2(1) /= "abcd") call abort ()
deallocate (c1, c2)
! Pointer assignments
c1 => sfoo ()
if (c1 /= "abcd") call abort ()
c2 => afoo (c0)
if (c2(1) /= "abcd") call abort ()
deallocate (c1, c2)
contains
function foo () result (cc1)
character*4 :: cc1
cc1 = "abcd"
end function foo
function sfoo () result (sc1)
character*4, pointer :: sc1
allocate (sc1)
sc1 = "abcd"
end function sfoo
function afoo (c0) result (ac1)
character*4 :: c0
character*4, pointer :: ac1(:)
allocate (ac1(1))
ac1 = "abcd"
end function afoo
end program char_pointer_func
| gpl-2.0 |
tuxillo/aarch64-dragonfly-gcc | libgomp/testsuite/libgomp.fortran/simd7.f90 | 102 | 9430 | ! { dg-do run }
! { dg-additional-options "-msse2" { target sse2_runtime } }
! { dg-additional-options "-mavx" { target avx_runtime } }
subroutine foo (d, e, f, g, m, n)
integer :: i, j, b(2:9), c(3:n), d(:), e(2:n), f(2:,3:), n
integer, allocatable :: g(:), h(:), k, m
logical :: l
l = .false.
allocate (h(2:7))
i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
!$omp simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5)linear(g:6) &
!$omp & linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l)
do i = 0, 63
l = l .or. .not.allocated (g) .or. .not.allocated (h)
l = l .or. .not.allocated (k) .or. .not.allocated (m)
l = l .or. any (b /= 7 + i) .or. any (c /= 8 + 2 * i)
l = l .or. any (d /= 9 + 3 * i) .or. any (e /= 10 + 4 * i)
l = l .or. any (f /= 11 + 5 * i) .or. any (g /= 12 + 6 * i)
l = l .or. any (h /= 13 + 7 * i) .or. (k /= 14 + 8 * i)
l = l .or. (m /= 15 + 9 * i)
l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
h = h + 7; k = k + 8; m = m + 9
end do
if (l .or. i /= 64) call abort
if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
if (m /= 15 + 9 * 64) call abort
if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
!$omp simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5)linear(g:6) &
!$omp & linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l) collapse(2)
do i = 0, 7
do j = 0, 7
l = l .or. .not.allocated (g) .or. .not.allocated (h)
l = l .or. .not.allocated (k) .or. .not.allocated (m)
l = l .or. any (b /= 7 + (8 * i + j)) .or. any (c /= 8 + 2 * (8 * i + j))
l = l .or. any (d /= 9 + 3 * (8 * i + j)) .or. any (e /= 10 + 4 * (8 * i + j))
l = l .or. any (f /= 11 + 5 * (8 * i + j)) .or. any (g /= 12 + 6 * (8 * i + j))
l = l .or. any (h /= 13 + 7 * (8 * i + j)) .or. (k /= 14 + 8 * (8 * i + j))
l = l .or. (m /= 15 + 9 * (8 * i + j))
l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
h = h + 7; k = k + 8; m = m + 9
end do
end do
if (l .or. i /= 8 .or. j /= 8) call abort
if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
if (m /= 15 + 9 * 64) call abort
if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
!$omp parallel do simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5) &
!$omp & linear(g:6)linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l)
do i = 0, 63
l = l .or. .not.allocated (g) .or. .not.allocated (h)
l = l .or. .not.allocated (k) .or. .not.allocated (m)
l = l .or. any (b /= 7 + i) .or. any (c /= 8 + 2 * i)
l = l .or. any (d /= 9 + 3 * i) .or. any (e /= 10 + 4 * i)
l = l .or. any (f /= 11 + 5 * i) .or. any (g /= 12 + 6 * i)
l = l .or. any (h /= 13 + 7 * i) .or. (k /= 14 + 8 * i)
l = l .or. (m /= 15 + 9 * i)
l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
h = h + 7; k = k + 8; m = m + 9
end do
if (l .or. i /= 64) call abort
if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
if (m /= 15 + 9 * 64) call abort
if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
!$omp parallel do simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5) &
!$omp & linear(g:6)linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l) collapse(2)
do i = 0, 7
do j = 0, 7
l = l .or. .not.allocated (g) .or. .not.allocated (h)
l = l .or. .not.allocated (k) .or. .not.allocated (m)
l = l .or. any (b /= 7 + (8 * i + j)) .or. any (c /= 8 + 2 * (8 * i + j))
l = l .or. any (d /= 9 + 3 * (8 * i + j)) .or. any (e /= 10 + 4 * (8 * i + j))
l = l .or. any (f /= 11 + 5 * (8 * i + j)) .or. any (g /= 12 + 6 * (8 * i + j))
l = l .or. any (h /= 13 + 7 * (8 * i + j)) .or. (k /= 14 + 8 * (8 * i + j))
l = l .or. (m /= 15 + 9 * (8 * i + j))
l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
h = h + 7; k = k + 8; m = m + 9
end do
end do
if (l .or. i /= 8 .or. j /= 8) call abort
if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
if (m /= 15 + 9 * 64) call abort
if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
end subroutine
interface
subroutine foo (d, e, f, g, m, n)
integer :: d(:), e(2:n), f(2:,3:), n
integer, allocatable :: g(:), m
end subroutine
end interface
integer, parameter :: n = 8
integer :: d(2:18), e(3:n+1), f(5:6,7:9)
integer, allocatable :: g(:), m
allocate (g(7:10))
call foo (d, e, f, g, m, n)
end
| gpl-2.0 |
tuxillo/aarch64-dragonfly-gcc | gcc/testsuite/gfortran.dg/vect/vect-2.f90 | 48 | 1306 | ! { dg-do compile }
! { dg-require-effective-target vect_float }
SUBROUTINE FOO(A, B, C)
DIMENSION A(1000000), B(1000000), C(1000000)
READ*, X, Y
A = LOG(X); B = LOG(Y); C = A + B
PRINT*, C(500000)
END
! First loop (A=LOG(X)) is vectorized using peeling to align the store.
! Same for the second loop (B=LOG(Y)).
! Third loop (C = A + B) is vectorized using versioning (for targets that don't
! support unaligned loads) or using peeling to align the store (on targets that
! support unaligned loads).
! { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } }
! { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 3 "vect" { xfail { { vect_no_align && { ! vect_hw_misalign } } || { ! vector_alignment_reachable } } } } }
! { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { target { { vect_no_align && { ! vect_hw_misalign } } && { ! vector_alignment_reachable } } } } }
! { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } }
! { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 3 "vect" {target { { vect_no_align && { ! vect_hw_misalign } } || { { ! vector_alignment_reachable } && { ! vect_hw_misalign } } } } } }
| gpl-2.0 |
tuxillo/aarch64-dragonfly-gcc | gcc/testsuite/gfortran.dg/equiv_7.f90 | 174 | 3659 | ! { dg-do run }
! { dg-options "-std=gnu" }
! Tests the fix for PR29786, in which initialization of overlapping
! equivalence elements caused a compile error.
!
! Contributed by Bernhard Fischer <aldot@gcc.gnu.org>
!
block data
common /global/ ca (4)
integer(4) ca, cb
equivalence (cb, ca(3))
data (ca(i), i = 1, 2) /42,43/, ca(4) /44/
data cb /99/
end block data
integer(4), parameter :: abcd = ichar ("a") + 256_4 * (ichar("b") + 256_4 * &
(ichar ("c") + 256_4 * ichar ("d")))
logical(4), parameter :: bigendian = transfer (abcd, "wxyz") .eq. "abcd"
call int4_int4
call real4_real4
call complex_real
call check_block_data
call derived_types ! Thanks to Tobias Burnus for this:)
!
! This came up in PR29786 comment #9 - Note the need to treat endianess
! Thanks Dominique d'Humieres:)
!
if (bigendian) then
if (d1mach_little (1) .ne. transfer ((/0_4, 1048576_4/), 1d0)) call abort ()
if (d1mach_little (2) .ne. transfer ((/-1_4,2146435071_4/), 1d0)) call abort ()
else
if (d1mach_big (1) .ne. transfer ((/1048576_4, 0_4/), 1d0)) call abort ()
if (d1mach_big (2) .ne. transfer ((/2146435071_4,-1_4/), 1d0)) call abort ()
end if
!
contains
subroutine int4_int4
integer(4) a(4)
integer(4) b
equivalence (b,a(3))
data b/3/
data (a(i), i=1,2) /1,2/, a(4) /4/
if (any (a .ne. (/1, 2, 3, 4/))) call abort ()
end subroutine int4_int4
subroutine real4_real4
real(4) a(4)
real(4) b
equivalence (b,a(3))
data b/3.0_4/
data (a(i), i=1,2) /1.0_4, 2.0_4/, &
a(4) /4.0_4/
if (sum (abs (a - &
(/1.0_4, 2.0_4, 3.0_4, 4.0_4/))) > 1.0e-6) call abort ()
end subroutine real4_real4
subroutine complex_real
complex(4) a(4)
real(4) b(2)
equivalence (b,a(3))
data b(1)/3.0_4/, b(2)/4.0_4/
data (a(i), i=1,2) /(0.0_4, 1.0_4),(2.0_4,0.0_4)/, &
a(4) /(0.0_4,5.0_4)/
if (sum (abs (a - (/(0.0_4, 1.0_4),(2.0_4, 0.0_4), &
(3.0_4, 4.0_4),(0.0_4, 5.0_4)/))) > 1.0e-6) call abort ()
end subroutine complex_real
subroutine check_block_data
common /global/ ca (4)
equivalence (ca(3), cb)
integer(4) ca
if (any (ca .ne. (/42, 43, 99, 44/))) call abort ()
end subroutine check_block_data
function d1mach_little(i) result(d1mach)
implicit none
double precision d1mach,dmach(5)
integer i
integer*4 large(4),small(4)
equivalence ( dmach(1), small(1) )
equivalence ( dmach(2), large(1) )
data small(1),small(2) / 0, 1048576/
data large(1),large(2) /-1,2146435071/
d1mach = dmach(i)
end function d1mach_little
function d1mach_big(i) result(d1mach)
implicit none
double precision d1mach,dmach(5)
integer i
integer*4 large(4),small(4)
equivalence ( dmach(1), small(1) )
equivalence ( dmach(2), large(1) )
data small(1),small(2) /1048576, 0/
data large(1),large(2) /2146435071,-1/
d1mach = dmach(i)
end function d1mach_big
subroutine derived_types
TYPE T1
sequence
character (3) :: chr
integer :: i = 1
integer :: j
END TYPE T1
TYPE T2
sequence
character (3) :: chr = "wxy"
integer :: i = 1
integer :: j = 4
END TYPE T2
TYPE(T1) :: a1
TYPE(T2) :: a2
EQUIVALENCE(a1,a2) ! { dg-warning="mixed|components" }
if (a1%chr .ne. "wxy") call abort ()
if (a1%i .ne. 1) call abort ()
if (a1%j .ne. 4) call abort ()
end subroutine derived_types
end
| gpl-2.0 |
Hellybean/SaberMod_ROM_Toolchain | gcc/testsuite/gfortran.dg/equiv_7.f90 | 174 | 3659 | ! { dg-do run }
! { dg-options "-std=gnu" }
! Tests the fix for PR29786, in which initialization of overlapping
! equivalence elements caused a compile error.
!
! Contributed by Bernhard Fischer <aldot@gcc.gnu.org>
!
block data
common /global/ ca (4)
integer(4) ca, cb
equivalence (cb, ca(3))
data (ca(i), i = 1, 2) /42,43/, ca(4) /44/
data cb /99/
end block data
integer(4), parameter :: abcd = ichar ("a") + 256_4 * (ichar("b") + 256_4 * &
(ichar ("c") + 256_4 * ichar ("d")))
logical(4), parameter :: bigendian = transfer (abcd, "wxyz") .eq. "abcd"
call int4_int4
call real4_real4
call complex_real
call check_block_data
call derived_types ! Thanks to Tobias Burnus for this:)
!
! This came up in PR29786 comment #9 - Note the need to treat endianess
! Thanks Dominique d'Humieres:)
!
if (bigendian) then
if (d1mach_little (1) .ne. transfer ((/0_4, 1048576_4/), 1d0)) call abort ()
if (d1mach_little (2) .ne. transfer ((/-1_4,2146435071_4/), 1d0)) call abort ()
else
if (d1mach_big (1) .ne. transfer ((/1048576_4, 0_4/), 1d0)) call abort ()
if (d1mach_big (2) .ne. transfer ((/2146435071_4,-1_4/), 1d0)) call abort ()
end if
!
contains
subroutine int4_int4
integer(4) a(4)
integer(4) b
equivalence (b,a(3))
data b/3/
data (a(i), i=1,2) /1,2/, a(4) /4/
if (any (a .ne. (/1, 2, 3, 4/))) call abort ()
end subroutine int4_int4
subroutine real4_real4
real(4) a(4)
real(4) b
equivalence (b,a(3))
data b/3.0_4/
data (a(i), i=1,2) /1.0_4, 2.0_4/, &
a(4) /4.0_4/
if (sum (abs (a - &
(/1.0_4, 2.0_4, 3.0_4, 4.0_4/))) > 1.0e-6) call abort ()
end subroutine real4_real4
subroutine complex_real
complex(4) a(4)
real(4) b(2)
equivalence (b,a(3))
data b(1)/3.0_4/, b(2)/4.0_4/
data (a(i), i=1,2) /(0.0_4, 1.0_4),(2.0_4,0.0_4)/, &
a(4) /(0.0_4,5.0_4)/
if (sum (abs (a - (/(0.0_4, 1.0_4),(2.0_4, 0.0_4), &
(3.0_4, 4.0_4),(0.0_4, 5.0_4)/))) > 1.0e-6) call abort ()
end subroutine complex_real
subroutine check_block_data
common /global/ ca (4)
equivalence (ca(3), cb)
integer(4) ca
if (any (ca .ne. (/42, 43, 99, 44/))) call abort ()
end subroutine check_block_data
function d1mach_little(i) result(d1mach)
implicit none
double precision d1mach,dmach(5)
integer i
integer*4 large(4),small(4)
equivalence ( dmach(1), small(1) )
equivalence ( dmach(2), large(1) )
data small(1),small(2) / 0, 1048576/
data large(1),large(2) /-1,2146435071/
d1mach = dmach(i)
end function d1mach_little
function d1mach_big(i) result(d1mach)
implicit none
double precision d1mach,dmach(5)
integer i
integer*4 large(4),small(4)
equivalence ( dmach(1), small(1) )
equivalence ( dmach(2), large(1) )
data small(1),small(2) /1048576, 0/
data large(1),large(2) /2146435071,-1/
d1mach = dmach(i)
end function d1mach_big
subroutine derived_types
TYPE T1
sequence
character (3) :: chr
integer :: i = 1
integer :: j
END TYPE T1
TYPE T2
sequence
character (3) :: chr = "wxy"
integer :: i = 1
integer :: j = 4
END TYPE T2
TYPE(T1) :: a1
TYPE(T2) :: a2
EQUIVALENCE(a1,a2) ! { dg-warning="mixed|components" }
if (a1%chr .ne. "wxy") call abort ()
if (a1%i .ne. 1) call abort ()
if (a1%j .ne. 4) call abort ()
end subroutine derived_types
end
| gpl-2.0 |
intervigilium/cs259-or32-gcc | gcc/testsuite/gfortran.dg/namelist_22.f90 | 166 | 1390 | !{ dg-do run { target fd_truncate } }
!{ dg-options "-std=legacy" }
!
! Tests filling arrays from a namelist read when object list is not complete.
! This is the same as namelist_21.f90 except using spaces as seperators instead
! of commas. Developed from a test case provided by Christoph Jacob.
! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>.
program pr24794
implicit none
integer, parameter :: maxop=15, iunit=7
character*8 namea(maxop), nameb(maxop)
integer i, ier
namelist/ccsopr/ namea,nameb
namea=""
nameb=""
open (12, status="scratch", delim="apostrophe")
write (12, '(a)') "&ccsopr"
write (12, '(a)') " namea='spi01h' 'spi02o' 'spi03h' 'spi04o' 'spi05h'"
write (12, '(a)') " 'spi07o' 'spi08h' 'spi09h'"
write (12, '(a)') " nameb='spi01h' 'spi03h' 'spi05h' 'spi06h' 'spi08h'"
write (12, '(a)') "&end"
rewind (12)
read (12, nml=ccsopr, iostat=ier)
if (ier.ne.0) call abort()
rewind (12)
write(12,nml=ccsopr)
rewind (12)
read (12, nml=ccsopr, iostat=ier)
if (ier.ne.0) call abort()
if (namea(2).ne."spi02o ") call abort()
if (namea(9).ne." ") call abort()
if (namea(15).ne." ") call abort()
if (nameb(1).ne."spi01h ") call abort()
if (nameb(6).ne." ") call abort()
if (nameb(15).ne." ") call abort()
close (12)
end program pr24794
| gpl-2.0 |
intervigilium/cs259-or32-gcc | gcc/testsuite/gfortran.dg/c_ptr_tests_14.f90 | 30 | 1423 | ! { dg-do run }
! { dg-options "-fdump-tree-original" }
!
! PR fortran/41298
!
! Check that c_null_ptr default initializer is really applied
module m
use iso_c_binding
type, public :: fgsl_file
type(c_ptr) :: gsl_file = c_null_ptr
type(c_funptr) :: gsl_func = c_null_funptr
type(c_ptr) :: NIptr
type(c_funptr) :: NIfunptr
end type fgsl_file
contains
subroutine sub(aaa,bbb)
type(fgsl_file), intent(out) :: aaa
type(fgsl_file), intent(inout) :: bbb
end subroutine
subroutine proc() bind(C)
end subroutine proc
end module m
program test
use m
implicit none
type(fgsl_file) :: file, noreinit
integer, target :: tgt
call sub(file, noreinit)
if(c_associated(file%gsl_file)) call abort()
if(c_associated(file%gsl_func)) call abort()
file%gsl_file = c_loc(tgt)
file%gsl_func = c_funloc(proc)
call sub(file, noreinit)
if(c_associated(file%gsl_file)) call abort()
if(c_associated(file%gsl_func)) call abort()
end program test
! { dg-final { scan-tree-dump-times "gsl_file = 0B" 1 "original" } }
! { dg-final { scan-tree-dump-times "gsl_func = 0B" 1 "original" } }
! { dg-final { scan-tree-dump-times "NIptr = 0B" 0 "original" } }
! { dg-final { scan-tree-dump-times "NIfunptr = 0B" 0 "original" } }
! { dg-final { scan-tree-dump-times "bbb =" 0 "original" } }
! { dg-final { cleanup-tree-dump "original" } }
! { dg-final { cleanup-modules "m" } }
| gpl-2.0 |
ovilab/atomify-lammps | libs/lammps/tools/ch2lmp/other/pdb_to_crd.f | 60 | 3059 | c Reads PDB file, writes out charmm file
c Uses a temp file
c PDB format
c text IATOM TYPE RES IRES X Y Z W
c A6 I5 2X A4 A4 I5 4X 3F8.3 6X F6.2
c charmm format
c ATOMNO RESNO RES TYPE X Y Z SEGID RESID Weighting
c I5 I5 1X A4 1X A4 F10.5 F10.5 F10.5 1X A4 1X A4 F10.5
c
c
character*80 infile,outfile,line
character*4 str1,type,res,code,segid,resid,residold,resold
character*1 chain
logical loxt(1000)
write (6,*) 'Give input PDB files, output will be .crd'
1 read (5,'(a)') infile
i=1
2 i=i+1
if (infile(i:i).eq.' ') then
outfile=infile(1:i-1)//'.crd'
else
goto 2
endif
open (unit=11, file=infile, status='old')
open (unit=12, file='temppdb', status='unknown')
open (unit=13, file=outfile, status='new')
write (13,'(a80)') '* converted from '//infile
write (13,'(a)') '*'
do 4 i=1,1000
4 loxt(i)=.false.
nss=0
ires=0
iat=0
residold=' '
resold=' '
do 100 i=1,100000
read (11,'(a80)',end=1000) line
read (unit=line,fmt=500) str1
if (str1.eq.'SSBO') then
nss=nss+1
goto 100
else if (str1.eq.'ATOM') then
iat= iat+1
read (unit=line,fmt=500) str1,iatom,type,res,chain,resid,
& x,y,z,a,w,code
500 format (a4,2x,i5,1x,a4,1x,a4,a1,a4,4x,3f8.3,2f6.2,6x,a4)
if ((resid.ne.residold).or.(res.ne.resold)) ires=ires+1
residold=resid
resold= res
if (chain.ne.' ') then
segid=chain//code
elseif (code.ne.' ') then
segid=code
else
segid='MAIN'
endif
if (type.eq.'CD1 ') then
if (res.eq.'ILE ') type='CD '
elseif (type.eq.'OCT1') then
type='OT1 '
elseif (type.eq.'OCT2') then
type='OT2 '
elseif (type.eq.'OXT ') then
type='OT2 '
loxt(ires)=.true.
endif
c fluch resid left
5 if (resid(1:1).eq.' ') then
resid=resid(2:4)//' '
goto 5
endif
6 if (type(1:1).eq.' ') then
type=type(2:4)//' '
goto 6
endif
write (12,600) iat,ires,res,type,x,y,z,segid,resid,w
600 format (I5,I5,1X,A4,1X,A4,3F10.5,1X,A4,1X,a4,F10.5)
else
goto 100
endif
100 continue
1000 write (6,*) 'Disulfide bonds', nss
nres=ires
write (13,'(i5)') iat
close (unit=12)
open (unit=12,file='temppdb',status='old')
do 200 i=1,100000
read (12,'(a80)',end=2000) line
read (unit=line,fmt=600) iatom,ires,res,type,x,y,z,segid,resid,w
if (loxt(ires).and.(type.eq.'O ')) type='OT1 '
write (13,600) iatom,ires,res,type,x,y,z,segid,resid,w
200 continue
2000 close (unit=11)
close (unit=12)
close (unit=13)
goto 1
end
| gpl-3.0 |
intervigilium/cs259-or32-gcc | gcc/testsuite/gfortran.dg/where_operator_assign_2.f90 | 52 | 3388 | ! { dg-do compile }
! Tests the fix for PR30407, in which operator assignments did not work
! in WHERE blocks or simple WHERE statements.
!
! Contributed by Paul Thomas <pault@gcc.gnu.org>
!******************************************************************************
module global
type :: a
integer :: b
integer :: c
end type a
interface assignment(=)
module procedure a_to_a
end interface
interface operator(.ne.)
module procedure a_ne_a
end interface
type(a) :: x(4), y(4), z(4), u(4, 4)
logical :: l1(4), t = .true., f= .false.
contains
!******************************************************************************
elemental subroutine a_to_a (m, n)
type(a), intent(in) :: n
type(a), intent(out) :: m
m%b = n%b + 1
m%c = n%c
end subroutine a_to_a
!******************************************************************************
elemental logical function a_ne_a (m, n)
type(a), intent(in) :: n
type(a), intent(in) :: m
a_ne_a = (m%b .ne. n%b) .or. (m%c .ne. n%c)
end function a_ne_a
!******************************************************************************
elemental function foo (m)
type(a) :: foo
type(a), intent(in) :: m
foo%b = 0
foo%c = m%c
end function foo
end module global
!******************************************************************************
program test
use global
x = (/a (0, 1),a (0, 2),a (0, 3),a (0, 4)/)
y = x
z = x
l1 = (/t, f, f, t/)
call test_where_1
if (any (y .ne. (/a (2, 1),a (2, 2),a (2, 3),a (2, 4)/))) call abort ()
call test_where_2
if (any (y .ne. (/a (1, 0),a (2, 2),a (2, 3),a (1, 0)/))) call abort ()
if (any (z .ne. (/a (3, 4),a (1, 0),a (1, 0),a (3, 1)/))) call abort ()
call test_where_3
if (any (y .ne. (/a (1, 0),a (1, 2),a (1, 3),a (1, 0)/))) call abort ()
y = x
call test_where_forall_1
if (any (u(4, :) .ne. (/a (1, 4),a (2, 2),a (2, 3),a (1, 4)/))) call abort ()
l1 = (/t, f, t, f/)
call test_where_4
if (any (x .ne. (/a (1, 1),a (2, 1),a (1, 3),a (2, 3)/))) call abort ()
contains
!******************************************************************************
subroutine test_where_1 ! Test a simple WHERE
where (l1) y = x
end subroutine test_where_1
!******************************************************************************
subroutine test_where_2 ! Test a WHERE blocks
where (l1)
y = a (0, 0)
z = z(4:1:-1)
elsewhere
y = x
z = a (0, 0)
end where
end subroutine test_where_2
!******************************************************************************
subroutine test_where_3 ! Test a simple WHERE with a function assignment
where (.not. l1) y = foo (x)
end subroutine test_where_3
!******************************************************************************
subroutine test_where_forall_1 ! Test a WHERE in a FORALL block
forall (i = 1:4)
where (.not. l1)
u(i, :) = x
elsewhere
u(i, :) = a(0, i)
endwhere
end forall
end subroutine test_where_forall_1
!******************************************************************************
subroutine test_where_4 ! Test a WHERE assignment with dependencies
where (l1(1:3))
x(2:4) = x(1:3)
endwhere
end subroutine test_where_4
end program test
! { dg-final { cleanup-modules "global" } }
| gpl-2.0 |
Hellybean/SaberMod_ROM_Toolchain | 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 |
intervigilium/cs259-or32-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 |
Hellybean/SaberMod_ROM_Toolchain | 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 |
intervigilium/cs259-or32-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 |
intervigilium/cs259-or32-gcc | gcc/testsuite/gfortran.dg/alloc_comp_default_init_1.f90 | 171 | 1789 | ! { dg-do run }
! Checks the fixes for PR34681 and PR34704, in which various mixtures
! of default initializer and allocatable array were not being handled
! correctly for derived types with allocatable components.
!
! Contributed by Paolo Giannozzi <p.giannozzi@fisica.uniud.it>
!
program boh
integer :: c1, c2, c3, c4, c5
!
call mah (0, c1) ! These calls deal with PR34681
call mah (1, c2)
call mah (2, c3)
!
if (c1 /= c2) call abort
if (c1 /= c3) call abort
!
call mah0 (c4) ! These calls deal with PR34704
call mah1 (c5)
!
if (c4 /= c5) call abort
!
end program boh
!
subroutine mah (i, c)
!
integer, intent(in) :: i
integer, intent(OUT) :: c
!
type mix_type
real(8), allocatable :: a(:)
complex(8), allocatable :: b(:)
end type mix_type
type(mix_type), allocatable, save :: t(:)
integer :: j, n=1024
!
if (i==0) then
allocate (t(1))
allocate (t(1)%a(n))
allocate (t(1)%b(n))
do j=1,n
t(1)%a(j) = j
t(1)%b(j) = n-j
end do
end if
c = sum( t(1)%a(:) ) + sum( t(1)%b(:) )
if ( i==2) then
deallocate (t(1)%b)
deallocate (t(1)%a)
deallocate (t)
end if
end subroutine mah
subroutine mah0 (c)
!
integer, intent(OUT) :: c
type mix_type
real(8), allocatable :: a(:)
integer :: n=1023
end type mix_type
type(mix_type) :: t
!
allocate(t%a(1))
t%a=3.1415926
c = t%n
deallocate(t%a)
!
end subroutine mah0
!
subroutine mah1 (c)
!
integer, intent(OUT) :: c
type mix_type
real(8), allocatable :: a(:)
integer :: n=1023
end type mix_type
type(mix_type), save :: t
!
allocate(t%a(1))
t%a=3.1415926
c = t%n
deallocate(t%a)
!
end subroutine mah1
| gpl-2.0 |
MarkDekker/FSI-Foil | XFOIL/plotlib/examples/symbolsall.f | 4 | 4537 | C***********************************************************************
C Module: symbolsall.f
C
C Copyright (C) 1996 Harold Youngren, Mark Drela
C
C This program is free software; you can redistribute it and/or modify
C it under the terms of the GNU General Public License as published by
C the Free Software Foundation; either version 2 of the License, or
C (at your option) any later version.
C
C This program is distributed in the hope that it will be useful,
C but WITHOUT ANY WARRANTY; without even the implied warranty of
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C GNU General Public License for more details.
C
C You should have received a copy of the GNU General Public License
C along with this program; if not, write to the Free Software
C Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
C
C Report problems to: guppy@maine.com
C or drela@mit.edu
C***********************************************************************
C---Test routine for Pltlib
C Displays a symbol set in color
C
CHARACTER*4 INP, FNAME*80
CH = 0.02
C
C---Decide about what devices to plot to
WRITE(*,*) ' '
WRITE(*,*) 'Font plot test'
WRITE(*,*) ' You may just <cr> for each question to take defaults'
WRITE(*,*) ' '
1 WRITE(*,*) ' Enter -1 for no PS, 0 for B&W PS, 1 for color PS'
READ(*,1000,end=2000) INP
itype = -1
if(INP.ne.' ') then
READ(INP,*,end=2000,err=2000) itype
endif
IDEV = 1
IF(itype.eq.0) IDEV = 3
IF(itype.ge.1) IDEV = 5
C
WRITE(*,*) ' '
WRITE(*,*) ' Enter 0 for default PSfile'
WRITE(*,*) ' #>0 for external PSfile on unit #'
WRITE(*,*) ' Enter -1 for separate PSfiles'
READ(*,1000,end=2000) INP
iunit = 0
if(INP.ne.' ') then
READ(INP,*,end=2000,err=2000) iunit
endif
if(iunit.gt.0) then
WRITE(*,*) 'Enter file name for PSFILE'
READ(*,1000,end=2000) FNAME
OPEN(unit=iunit,file=FNAME,status='UNKNOWN')
endif
C
C---Initialize the plot package before we get into color plotting...
CALL PLINITIALIZE
C
C---Now, how many colors...
WRITE(*,*) ' Enter # colors (0 or 1 gives no colors)'
READ(*,1000,end=2000) INP
ncolors = 32
if(INP.ne.' ') then
READ(INP,*,end=2000,err=2000) ncolors
endif
C---Set up colormap spectrum colors
if(ncolors.LE.1) ncolors = 1
CALL COLORSPECTRUMHUES(ncolors,'MBCGYR')
C
C---Loop through the four defined fonts and symbols
DO 1500 IFNT = 1, 4
C
C---Take the default window (portrait, 2/3 screen dimension)
CALL PLOPEN(0.,iunit,IDEV)
C
CALL NEWFACTOR(5.0)
CALL PLOT(0.10,0.1,-3)
c CALL NEWCOLORNAME('black')
C
C---Plot the symbols in 8 columns of 32 characters each (256 total)
DO ISET=1, 8
C
I0 = (ISET-1)*32 + 1
IN = I0 + 31
C
DO I=I0, IN
RNUM = FLOAT(I-1)
XX = 0.2*FLOAT(ISET-1)
YY = (36.-FLOAT(I-I0))*2.0*CH
ICOLOR = MOD(I-1,NCOLORS) + 1
C WRITE(*,*) 'ICOLOR,ISYM ',ICOLOR,I-1
C---Select one of the colormap spectrum colors (repeat, modulo ncolors)
c write(*,*) ncolors, icolor
IF(ncolors.GT.1) CALL NEWCOLOR(-icolor)
CALL PLNUMB(XX,YY-0.5*CH,CH,RNUM,0.0,-1)
IF(IFNT.EQ.1) CALL PLCHAR(XX+4.0*CH,YY,CH,char(I-1),0.0,1)
IF(IFNT.EQ.2) CALL PLSLAN(XX+4.0*CH,YY,CH,char(I-1),0.0,1)
IF(IFNT.EQ.3) CALL PLMATH(XX+4.0*CH,YY,CH,char(I-1),0.0,1)
IF(IFNT.EQ.4) CALL PLSYMB(XX+4.0*CH,YY,CH,(I-1),0.0,0)
END DO
END DO
C
C---Put colored title at bottom of plot
CALL NEWCOLORNAME('blue')
CALL PLCHAR(0.,0.,2.*CH,'Xplot11 ',0.0,8)
CALL NEWCOLORNAME('green')
IF(IFNT.EQ.1) CALL PLCHAR(999.,999.,2.*CH,'PLCHAR ',0.0,7)
IF(IFNT.EQ.2) CALL PLCHAR(999.,999.,2.*CH,'PLSLAN ',0.0,7)
IF(IFNT.EQ.3) CALL PLCHAR(999.,999.,2.*CH,'PLMATH ',0.0,7)
IF(IFNT.EQ.4) CALL PLCHAR(999.,999.,2.*CH,'PLSYMB ',0.0,7)
CALL NEWCOLORNAME('red')
CALL PLCHAR(999.,999.,2.*CH,'test',0.0,4)
C
CALL PLFLUSH
WRITE(*,*) 'Hit return to proceed...'
READ(5,1000) INP
1000 FORMAT(A)
C
CALL PLEND
C
1500 CONTINUE
C
2000 CALL PLCLOSE
STOP
END
| gpl-2.0 |
bollig/pscf | src/crystal/unit_cell_mod.f | 3 | 25441 | !-----------------------------------------------------------------------
! PSCF - Polymer Self-Consistent Field Theory
! Copyright (2002-2016) Regents of the University of Minnesota
! contact: David Morse, morse012@umn.edu
!
! 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. A copy of this license is included in
! the LICENSE file in the top-level PSCF directory.
!----------------------------------------------------------------------
!****m scf/unit_cell_mod
! PURPOSE
! Define crystal unit cell and lattice basis vectors
! AUTHOR
! David Morse (2002)
! Chris Tyler (2002-2004)
! SOURCE
!----------------------------------------------------------------------
module unit_cell_mod
use const_mod
use io_mod
implicit none
private
! Public procedures
public :: input_unit_cell ! read dim, crystal_system, cell_param
public :: output_unit_cell ! write dim, crystal_system, cell_param
public :: standard_cell_param ! return parameters a,b,c, alpha,beta,gamma
public :: make_unit_cell ! create lattice basis vectors, etc.
public :: define_unit_cell ! reset cell parameters
public :: make_G_basis ! make G_basis from R_basis
! Public variables
public :: crystal_system, N_cell_param, cell_param
public :: R_basis, G_basis, dGG_basis
character(30) :: crystal_system ! type of crystal cell (cubic, etc.)
integer :: N_cell_param ! # of unit cell parameters
real(long) :: cell_param(6) ! unit cell parameters
real(long) :: R_basis(:,:) ! (dim,dim) lattice bases a_i
real(long) :: G_basis(:,:) ! (dim,dim) reciprocal bases b_i
real(long) :: dGG_basis(:,:,:) ! (dim,dim,6) derivatives of b_i.b_j
!***
allocatable :: R_basis, G_basis, dGG_basis
! Private variables
real(long), allocatable :: dR_basis(:,:,:) ! derivatives of a_i
real(long), allocatable :: dG_basis(:,:,:) ! derivatives of b_i
real(long), allocatable :: dRR_basis(:,:,:) ! derivatives of a_i.a_j
!--------------------------------------------------------------------
!****v* unit_cell_mod/crystal_system
! VARIABLE
! character(30) crystal_system = string identifying crystal system
!
! Allowed values:
! 3D crystal systems (dim = 3):
! 'cubic', 'tetragonal', 'orthorhombic', 'monoclinic',
! 'hexagonal', 'triclinic'
! 2D crystal systems (dim = 2)
! 'square', 'rectangular', 'rhombus', 'hexagonal', 'oblique'
! 1D crystal system (dim = 1):
! 'lamellar'
!*** ----------------------------------------------------------------
!****v* unit_cell_mod/N_cell_param
! VARIABLE
! integer N_cell_param = # of unit cell parameters
! Different values needed for different crystal
! systems (e.g., 1 for cubic, 6 for triclinic)
!*** ----------------------------------------------------------------
!****v* unit_cell_mod/cell_param
! VARIABLE
! real(long) cell_param(6) - array of cell parameters
! Only elements 1:N_cell_param are used
!*** ----------------------------------------------------------------
!****v* unit_cell_mod/R_basis
! VARIABLE
! real(long) R_basis(:,:) - dimension(dim,dim)
! R_basis(i,:) = a_i = Bravais lattice basis vector i
!*** ----------------------------------------------------------------
!****v* unit_cell_mod/G_basis
! VARIABLE
! real(long) G_basis(:,:) - dimension(dim,dim)
! G_basis(i,:) = b_i = reciprocal lattice basis vector i
!*** ----------------------------------------------------------------
!****v* unit_cell_mod/dGG_basis
! VARIABLE
! real(long) dGG_basis(:,:,:) - dimension(dim,dim,6)
! dGG_basis(i,j,k) = d(b_i.dot.b_j)/d(cell_param(k))
! Needed in calculation of stress by perturbation theory
!*** ----------------------------------------------------------------
contains
!---------------------------------------------------------------
!****p* unit_cell_mod/input_unit_cell
! SUBROUTINE
! input_unit_cell(i_unit, fmt_flag)
! PURPOSE
! Read data needed to construct unit cell from file i_unit.
! Inputs dim, crystal_system, N_cell_param, and cell_param
! If necessary, allocates R_basis, G_basis, related arrays
! ARGUMENTS
! integer i_unit - unit # of input file
! character(1) fmt_flag - flag specifying input format
! COMMENT
! Allowed values of fmt_flag:
! F -> formatted ascii input
! U -> unformatted input
! SOURCE
!---------------------------------------------------------------
subroutine input_unit_cell(i_unit,fmt_flag)
integer, intent(IN) :: i_unit
character(len = 1), intent(IN) :: fmt_flag
!***
call set_io_units(i=i_unit,o=6)
select case(fmt_flag)
case('F') ! Input formatted
call input(dim,'dim')
call input(crystal_system,'crystal_system')
call input(N_cell_param,'N_cell_param')
call input(cell_param,N_cell_param,'cell_param')
case('U')
read(i_unit) dim
read(i_unit) crystal_system
read(i_unit) N_cell_param
read(i_unit) cell_param
case default
print *, 'Illegal format specified in input_unit_cell'
print *, 'fmt_flag = ', fmt_flag
stop
end select
if (.not.allocated(R_basis)) allocate(R_basis(dim,dim))
if (.not.allocated(G_basis)) allocate(G_basis(dim,dim))
if (.not.allocated(dR_basis)) allocate(dR_basis(dim,dim,6))
if (.not.allocated(dG_basis)) allocate(dG_basis(dim,dim,6))
if (.not.allocated(dRR_basis)) allocate(dRR_basis(dim,dim,6))
if (.not.allocated(dGG_basis)) allocate(dGG_basis(dim,dim,6))
end subroutine input_unit_cell
!---------------------------------------------------------------
!---------------------------------------------------------------
!****p* unit_cell_mod/output_unit_cell
! SUBROUTINE
! output_unit_cell(o_unit,fmt_flag)
! PURPOSE
! Write crystal_system, N_cell_param, and cell_param to file
! ARGUMENTS
! integer o_unit - unit # of output file
! character(1) fmt_flag - flag specifying output format
! COMMENT
! Allowed values of fmt_flag:
! F -> formatted output
! U -> unformatted output
! SOURCE
!---------------------------------------------------------------
subroutine output_unit_cell(o_unit,fmt_flag)
integer, intent(IN) :: o_unit
character(len = 1), intent(IN) :: fmt_flag
!***
integer :: k
!call set_io_units(o=o_unit)
select case(fmt_flag)
case('F') ! Formatted for input
call output(dim,'dim',o=o_unit)
call output(trim(crystal_system),'crystal_system',o=o_unit)
call output(N_cell_param,'N_cell_param',o=o_unit)
call output(cell_param,N_cell_param,'cell_param',o=o_unit)
case('U')
write(o_unit) dim
write(o_unit) crystal_system
write(o_unit) N_cell_param
write(o_unit) cell_param
write(o_unit) R_basis
write(o_unit) G_basis
case default
print *, 'Invalid fmt_flag in output_unit_cell'
print *, 'fmt_flag = ', fmt_flag
stop
end select
end subroutine output_unit_cell
!------------------------------------------------------------------
!---------------------------------------------------------------
!****p* unit_cell_mod/standard_cell_param
! FUNCTION
! standard_cell_param(cell_param)
! PURPOSE
! Returns array (a, b, c, alpha, beta, gamma) for 3-d systems
! a, b, c are lengths of the three Bravais basis vectors
! alpha is the angle beween b, c
! beta is the angle between a, c
! gamma is the angle between a, b
! RETURN
! standard_cell_param(1:3) = (a,b,c)
! standard_cell_param(4:6) = (alpha,beta,gamma)
! AUTHOR
! Chris Tyler
! SOURCE
!---------------------------------------------------------------
function standard_cell_param(cell_param)
real(long), dimension(6), intent(IN) :: cell_param
real(long), dimension(6) :: standard_cell_param
!***
real(long) :: a, b, c, alpha, beta, gamma
standard_cell_param = 0.0_long
if ( dim .ne. 3 ) then
standard_cell_param = cell_param(1:N_cell_param)
return
endif
select case(crystal_system)
case('cubic')
a = cell_param(1)
b = cell_param(1)
c = cell_param(1)
alpha = 90.0
beta = 90.0
gamma = 90.0
case('tetragonal')
a = cell_param(1)
b = cell_param(1)
c = cell_param(2)
alpha = 90.0
beta = 90.0
gamma = 90.0
case('orthorhombic')
alpha = 90.0
beta = 90.0
gamma = 90.0
a = cell_param(1)
b = cell_param(2)
c = cell_param(3)
case('hexagonal')
a = cell_param(1)
b = cell_param(1)
c = cell_param(2)
gamma = 120.0
beta = 90.0
alpha = 90.0
case('trigonal')
a = cell_param(1)
b = cell_param(1)
c = cell_param(1)
alpha = cell_param(2) * 90/asin(1.0)
beta = alpha
gamma = alpha
case('monoclinic')
a = cell_param(1)
b = cell_param(2)
c = cell_param(3)
alpha = 90.0
beta = cell_param(4)
gamma = 90.0
case('triclinic')
a = cell_param(1)
b = cell_param(2)
c = cell_param(3)
alpha = cell_param(4)
beta = cell_param(5)
gamma = cell_param(6)
case default
a = 1
b = 1
c = 1
alpha = 90
beta = 90
gamma = 90
end select
standard_cell_param(1) = a
standard_cell_param(2) = b
standard_cell_param(3) = c
standard_cell_param(4) = alpha
standard_cell_param(5) = beta
standard_cell_param(6) = gamma
end function standard_cell_param
!---------------------------------------------------------------
!---------------------------------------------------------------
!****p unit_cell_mod/make_unit_cell
! SUBROUTINE
! make_unit_cell
! PURPOSE
! Constructs Bravais and reciprocal lattice vectors, and
! related arrays, from knowledge of module input variables.
! COMMENT
! All inputs and outputs are module variables, rather than
! explicit parameters.
! Inputs: crystal_system, N_cell_param, and cell_param
! Outputs: R_basis, G_basis, dRR_basis, dGG_basis
! SOURCE
!---------------------------------------------------------------
subroutine make_unit_cell
!***
integer :: i,j,k,l,m
real(long) :: a, b, c, alpha, beta, gamma, twopi
!C if ( size(cell_param) < N_cell_param ) then
!C print *,'Error: size(cell_param)<N_cell_param in make_unit_cell'
!C stop
!C endif
twopi = 4.0_long*acos(0.0_long)
R_basis = 0.0_long
G_basis = 0.0_long
dR_basis = 0.0_long
dG_basis = 0.0_long
dRR_basis = 0.0_long
dGG_basis = 0.0_long
select case(dim)
case(3)
select case(trim(crystal_system))
case('cubic')
If (N_cell_param /= 1) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
R_basis(1,1) = a
R_basis(2,2) = a
R_basis(3,3) = a
dR_basis(1,1,1) = 1.0_long
dR_basis(2,2,1) = 1.0_long
dR_basis(3,3,1) = 1.0_long
case('tetragonal')
If (N_cell_param /= 2) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
c = cell_param(2)
R_basis(1,1) = a
R_basis(2,2) = a
R_basis(3,3) = c
dR_basis(1,1,1) = 1.0_long
dR_basis(2,2,1) = 1.0_long
dR_basis(3,3,2) = 1.0_long
case('orthorhombic')
If (N_cell_param /= 3) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
b = cell_param(2)
c = cell_param(3)
R_basis(1,1) = a
R_basis(2,2) = b
R_basis(3,3) = c
dR_basis(1,1,1) = 1.0_long
dR_basis(2,2,2) = 1.0_long
dR_basis(3,3,3) = 1.0_long
case('hexagonal')
! Note: Unique axis is c axis
If (N_cell_param /= 2) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
c = cell_param(2)
R_basis(1,1) = a
R_basis(2,1) = -0.5_long*a
R_basis(2,2) = a * sqrt(0.75_long)
R_basis(3,3) = c
dR_basis(1,1,1) = 1.0_long
dR_basis(2,1,1) = -0.5_long
dR_basis(2,2,1) = sqrt(0.75_long)
dR_basis(3,3,2) = 1.0_long
case('trigonal')
!For Rhombohedral axes, otherwise use Hexagonal
If (N_cell_param /= 2) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1) ! length of one edge
beta = cell_param(2) ! angle between edges
! gamma is angle of rotation from a-b plane up to c-axis
gamma = cos(beta)/cos(beta* 0.5_long)
gamma = acos(gamma)
R_basis(1,1) = a
R_basis(2,1) = a * cos(beta)
R_basis(2,2) = a * sin(beta)
R_basis(3,1) = a * cos(gamma) * cos(beta*0.5_long)
R_basis(3,2) = a * cos(gamma) * sin(beta*0.5_long)
R_basis(3,3) = a * sin(gamma)
dR_basis(1,1,1) = 1.0_long
dR_basis(2,1,1) = cos(beta)
dR_basis(2,2,1) = sin(beta)
dR_basis(3,1,1) = cos(gamma) * cos(beta*0.5_long)
dR_basis(3,2,1) = cos(gamma) * sin(beta*0.5_long)
dR_basis(3,3,1) = sin(gamma)
dR_basis(2,1,2) = -a*sin(beta)
dR_basis(2,2,2) = a*cos(beta)
! alpha =d gamma/ d beta
alpha = 2._long* sin(beta) - cos(beta)* tan(beta*0.5_long) *0.5_long &
/ ( cos(beta*0.5) &
* sqrt( (1 + 2._long* cos(beta))* (tan(beta*0.5)**2)) )
dR_basis(3,1,2) = a * (-0.5_long * cos(gamma) * sin(beta*0.5_long) - &
sin(gamma) * alpha * cos(beta*0.5_long))
dR_basis(3,2,2) = a * ( 0.5_long * cos(beta*0.5_long) * cos(gamma) - &
sin(gamma) * sin(beta*0.5_long) * alpha )
dR_basis(3,3,2) = 1 * cos(gamma) * alpha
case('monoclinic')
! Note: Unique axis is b axis
If (N_cell_param /= 4) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
b = cell_param(2)
c = cell_param(3)
beta = cell_param(4)
R_basis(1,1) = a
R_basis(2,2) = b
R_basis(3,1) = c*cos(beta)
R_basis(3,3) = c*sin(beta)
dR_basis(1,1,1) = 1.0_long
dR_basis(2,2,2) = 1.0_long
dR_basis(3,1,3) = cos(beta)
dR_basis(3,3,3) = sin(beta)
dR_basis(3,1,4) = -c * sin(beta)
dR_basis(3,3,4) = c * cos(beta)
case('triclinic')
If (N_cell_param /= 6) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
b = cell_param(2)
c = cell_param(3)
alpha = cell_param(4) ! angle between c and x-y-plane
beta = cell_param(5) ! angle between c and z-axis
gamma = cell_param(6) ! angle between a and b
R_basis(1,1) = a
R_basis(2,1) = b * cos(gamma)
R_basis(2,2) = b * sin(gamma)
R_basis(3,1) = c * cos(alpha)*sin(beta)
R_basis(3,2) = c * sin(alpha)*sin(beta)
R_basis(3,3) = c * cos(beta)
dR_basis(1,1,1) = 1.0_long
dR_basis(2,1,2) = cos(gamma)
dR_basis(2,1,2) = sin(gamma)
dR_basis(3,1,3) = cos(alpha) * sin(beta)
dR_basis(3,2,3) = sin(alpha) * sin(beta)
dR_basis(3,3,3) = cos(beta)
dR_basis(3,1,4) = - c * sin(alpha) * sin(beta)
dR_basis(3,2,4) = c * cos(alpha) * sin(beta)
dR_basis(3,3,5) = - c * sin(beta)
dR_basis(2,1,6) = - b * sin(gamma)
dR_basis(2,2,6) = b * cos(gamma)
case('R-3m')
!For Rhombohedral axes, otherwise use Hexagonal
If (N_cell_param /= 2) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1) ! length of one edge
beta = cell_param(2) ! angle between edges
! gamma is angle of rotation from a-b plane up to c-axis
gamma = cos(beta)/cos(beta* 0.5_long)
gamma = acos(gamma)
R_basis(1,1) = a
R_basis(2,1) = a * cos(beta)
R_basis(2,2) = a * sin(beta)
R_basis(3,1) = a * cos(gamma) * cos(beta*0.5_long)
R_basis(3,2) = a * cos(gamma) * sin(beta*0.5_long)
R_basis(3,3) = a * sin(gamma)
dR_basis(1,1,1) = 1.0_long
dR_basis(2,1,1) = cos(beta)
dR_basis(2,2,1) = sin(beta)
dR_basis(3,1,1) = cos(gamma) * cos(beta*0.5_long)
dR_basis(3,2,1) = cos(gamma) * sin(beta*0.5_long)
dR_basis(3,3,1) = sin(gamma)
N_cell_param=1
case('pnna')
if (N_cell_param /= 1 ) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
R_basis(1,1) = 2.0_long * a
R_basis(2,2) = sqrt(3.0_long) *a
R_basis(3,3) = 1.0_long * a
dR_basis(1,1,1) = 2.0_long
dR_basis(2,2,1) = sqrt(3.0_long)
dR_basis(3,3,1) = 1.0_long
case('fddd1')
if (N_cell_param /= 1 ) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
R_basis(1,1) = a
R_basis(2,2) = sqrt(3.0_long) * a
R_basis(3,3) = sqrt(3.0_long) * 2.0_long * a
dR_basis(1,1,1) = 1
dR_basis(2,2,1) = sqrt(3.0_long)
dR_basis(3,3,1) = 2 * sqrt(3.0_long)
case('fddd2')
if (N_cell_param /= 2 ) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
alpha = cell_param(2) * atan(1.0)/45.0_long
R_basis(1,1) = 2.0_long * sin(alpha/2) * a
R_Basis(2,2) = 2.0_long * cos(alpha/2) * a
R_basis(3,3) = sqrt(3.0_long) * 2.0_long * a
dR_basis(1,1,1) = 2.0_long * sin(alpha/2)
dR_basis(2,2,1) = 2.0_long * cos(alpha/2)
dR_basis(3,3,1) = 2.0_long * sqrt(3.0_long)
dR_basis(1,1,2) = cos(alpha/2)
dR_basis(2,2,2) = -sin(alpha/2)
case default
write(6,*) 'Unknown crystal system, dim=3'
stop
end select
case(2)
select case(trim(crystal_system))
case('square')
if (N_cell_param /= 1 ) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
R_basis(1,1) = a
R_basis(2,2) = a
dR_basis(1,1,1) = 1.0_long
dR_basis(2,2,1) = 1.0_long
case('rectangular')
if (N_cell_param /=2) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
b = cell_param(2)
R_basis(1,1) = a
R_basis(2,2) = b
dR_basis(1,1,1) = 1.0_long
dR_basis(2,2,2) = 1.0_long
case('hexagonal')
if (N_cell_param /= 1) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
R_basis(1,1) = a
R_basis(2,1) = -0.5_long*a
R_basis(2,2) = a * sqrt(0.75_long)
dR_basis(1,1,1) = 1.0_long
dR_basis(2,1,1) = -0.5_long
dR_basis(2,2,1) = sqrt(0.75_long)
case('oblique')
if (N_cell_param /=3 ) then
write(6,*) 'Incorrect N_cell_param'
stop
endif
a = cell_param(1)
b = cell_param(2)
gamma = cell_param(3)
R_basis(1,1) = a
R_basis(2,1) = b * cos(gamma)
R_basis(2,2) = b * sin(gamma)
dR_basis(1,1,1) = a
dR_basis(2,1,2) = cos(gamma)
dR_basis(2,2,2) = sin(gamma)
dR_basis(2,1,3) = - b * sin(gamma)
dR_basis(2,2,3) = b * cos(gamma)
case default
write(6,*) 'Unknown crystal system, dim=2'
stop
end select
case(1) ! 1D crystal system - lamellar
if ( trim(crystal_system) == 'lamellar') then
a = cell_param(1)
R_basis(1,1) = a
dR_basis(1,1,1) = 1.0_long
else
write(6,*) 'Unknown crystal system, dim=2'
write(6,*) 'Only 1D system is "lamellar"'
stop
endif
case default
write(6,*) 'Invalid dimension, dim=', dim
stop
end select
! Invert R_basis to make G_basis
call make_G_basis(R_basis,G_basis)
! Calculate dG_basis
do k=1, N_cell_param
do i=1, dim
do j=1, dim
do l=1, dim
do m=1, dim
dG_basis(i,j,k) = dG_basis(i,j,k) &
- G_basis(i,l)*dR_basis(m,l,k)*G_basis(m,j)
enddo
enddo
enddo
enddo
enddo
dG_basis = dG_basis/twopi
! Calculate dRR_basis, dGG_basis
! do k=1, N_cell_param
! do i=1, dim
! do j=1, dim
! do l=1, dim
! dRR_basis(i,j,k) = dRR_basis(i,j,k) &
! + R_basis(i,l)*dR_basis(j,l,k)
! dGG_basis(i,j,k) = dGG_basis(i,j,k) &
! + G_basis(i,l)*dG_basis(j,l,k)
! enddo
! dRR_basis(i,j,k) = dRR_basis(i,j,k) + dRR_basis(j,i,k)
! dGG_basis(i,j,k) = dGG_basis(i,j,k) + dGG_basis(j,i,k)
! enddo
! enddo
! enddo
do k = 1,N_cell_param
do i = 1,dim
do j = 1,dim
do l = 1,dim
dRR_basis(i,j,k) = dRR_basis(i,j,k) &
+ R_basis(i,l) * dR_basis(l,j,k) &
+ R_basis(j,l) * dR_basis(l,i,k)
dGG_basis(i,j,k) = dGG_basis(i,j,k) &
+ G_basis(i,l) * dG_basis(j,l,k) &
+ G_basis(j,l) * dG_basis(i,l,k)
enddo
enddo
enddo
enddo
!dGG_basis = -dGG_basis/twopi
end subroutine make_unit_cell
!===================================================================
!---------------------------------------------------------------
!****p* unit_cell_mod/define_unit_cell
! SUBROUTINE
! define_unit_cell( mylattice, my_N, my_param )
! PURPOSE
! Modify crystal system and/or unit cell parameters
! ARGUMENTS
! mylattice - crystal system
! my_N - number of cell parameters
! my_param - array of cell parameters
! AUTHOR
! Chris Tyler
! SOURCE
!---------------------------------------------------------------
subroutine define_unit_cell( mylattice, my_N, my_param )
character(*), intent(IN) :: mylattice
integer, intent(IN) :: my_N
real(long), intent(IN) :: my_param(:)
!***
integer :: i
if ( size(my_param) < my_N ) then
print *, 'Error: size(my_param) < my_N in define_unit_cell'
stop
endif
crystal_system = mylattice
N_cell_param = my_N
cell_param = 0.0_long
do i = 1,N_cell_param
cell_param(i) = my_param(i)
enddo
allocate(R_basis(dim,dim))
allocate(G_basis(dim,dim))
allocate(dR_basis(dim,dim,6))
allocate(dG_basis(dim,dim,6))
allocate(dRR_basis(dim,dim,6))
allocate(dGG_basis(dim,dim,6))
end subroutine define_unit_cell
!==================================================================
!-------------------------------------------------------------------
!****p* unit_cell_mod/make_G_basis
! SUBROUTINE
! make_G_basis(R_basis,G_basis)
! PURPOSE
! Construct array G_basis of reciprocal lattice basis vectors
! from input array R_basis of Bravais lattice basis vectors
! SOURCE
!-------------------------------------------------------------------
subroutine make_G_basis(R_basis,G_basis)
use group_mod, only : Inverse
real(long), intent(IN) :: R_basis(:,:) ! (dim,dim) Bravais
real(long), intent(OUT) :: G_basis(:,:) ! (dim,dim) reciprocal
!***
real(long) :: R_local(3,3), G_local(3,3), twopi
integer :: i, j
twopi = 4.0_long*acos(0.0_long)
! Check dimensions for R_basis and G_basis
if ( ( size(R_basis,1) /= dim).or.( size(R_basis,2) /= dim ) ) then
write(6,*) 'Error in make_G_basis: Incorrect dimensions for R_basis'
endif
if ((size(G_basis,1)/=dim).or.(size(G_basis,2)/=dim)) then
write(6,*) 'Error in make_G_basis: Incorrect dimensions for G_basis'
endif
R_local = 0.0_long
G_local = 0.0_long
do i=1, dim
do j=1, dim
R_local(i,j) = R_basis(i,j)
enddo
enddo
R_local = inverse(R_local)
G_local = twopi*Transpose(R_local) ! Line split to compile on Regatta
do i=1, dim
do j=1, dim
G_basis(i,j) = G_local(i,j)
enddo
enddo
end subroutine make_G_basis
!===================================================================
end module unit_cell_mod
| gpl-2.0 |
intervigilium/cs259-or32-gcc | gcc/testsuite/gfortran.fortran-torture/execute/dep_fails.f90 | 191 | 1137 | ! This gives incorrect results when compiled with
! the intel and pgf90 compilers
Program Strange
Implicit None
Type Link
Integer, Dimension(2) :: Next
End Type Link
Integer, Parameter :: N = 2
Integer, dimension (2, 4) :: results
Integer :: i, j
Type(Link), Dimension(:,:), Pointer :: Perm
Integer, Dimension(2) :: Current
Allocate (Perm(N,N))
! Print*, 'Spanned by indices'
Do i = 1, N**2
Perm(mod(i-1,N)+1, (i-1)/N+1)%Next = (/ Mod(i,N) + 1, Mod(i/N+1,N)+1/)
! Write(*,100) mod(i-1,N)+1, (i-1)/N+1, Perm(mod(i-1,N)+1, (i-1)/N+1)%Next
! Expected output:
! Spanned by indices
! 1 1---> 2 2
! 2 1---> 1 1
! 1 2---> 2 1
! 2 2---> 1 2
End Do
! Print*, 'Spanned as a cycle'
Current = (/1,1/)
Do i = 1, n**2
results (:, i) = Perm(Current(1), Current(2))%Next
! Write(*,100) Current, Perm(Current(1), Current(2))%Next
! Expected output:
! 1 1---> 2 2
! 2 2---> 1 2
! 1 2---> 2 1
! 2 1---> 1 1
Current = Perm(Current(1), Current(2))%Next
End Do
if (any(results .ne. reshape ((/2,2,1,2,2,1,1,1/), (/2, 4/)))) call abort
! 100 Format( 2I3, '--->', 2I3)
DeAllocate (Perm)
End Program Strange
| gpl-2.0 |
Hellybean/SaberMod_ROM_Toolchain | gcc/testsuite/gfortran.dg/namelist_26.f90 | 180 | 1566 | ! { dg-do run }
! PR30918 Failure to skip commented out NAMELIST
! Before the patch, this read the commented out namelist and iuse would
! equal 2 when done. Test case from PR.
program gfcbug58
implicit none
integer :: iuse = 0, ios
integer, parameter :: nmlunit = 10 ! Namelist unit
!------------------
! Namelist 'REPORT'
!------------------
character(len=12) :: type, use
integer :: max_proc
namelist /REPORT/ type, use, max_proc
!------------------
! Set up the test file
!------------------
open(unit=nmlunit, status="scratch")
write(nmlunit, '(a)') "!================"
write(nmlunit, '(a)') "! Namelist REPORT"
write(nmlunit, '(a)') "!================"
write(nmlunit, '(a)') "! &REPORT use = 'ignore' / ! Comment"
write(nmlunit, '(a)') "!"
write(nmlunit, '(a)') " &REPORT type = 'SYNOP'"
write(nmlunit, '(a)') " use = 'active'"
write(nmlunit, '(a)') " max_proc = 20"
write(nmlunit, '(a)') " /"
rewind(nmlunit)
!-------------------------------------
! Loop to read namelist multiple times
!-------------------------------------
do
!----------------------------------------
! Preset namelist variables with defaults
!----------------------------------------
type = ''
use = ''
max_proc = -1
!--------------
! Read namelist
!--------------
read (nmlunit, nml=REPORT, iostat=ios)
if (ios /= 0) exit
iuse = iuse + 1
end do
if (iuse /= 1) call abort()
end program gfcbug58
| gpl-2.0 |
Hellybean/SaberMod_ROM_Toolchain | gcc/testsuite/gfortran.dg/integer_exponentiation_5.F90 | 136 | 1741 | ! { dg-do run { xfail spu-*-* } }
! FAILs on SPU because of invalid result of 1.0/0.0 inline code
! { dg-options "-fno-range-check" }
! { dg-add-options ieee }
module mod_check
implicit none
interface check
module procedure check_i8
module procedure check_i4
module procedure check_r8
module procedure check_r4
module procedure check_c8
module procedure check_c4
end interface check
contains
subroutine check_i8 (a, b)
integer(kind=8), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_i8
subroutine check_i4 (a, b)
integer(kind=4), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_i4
subroutine check_r8 (a, b)
real(kind=8), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_r8
subroutine check_r4 (a, b)
real(kind=4), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_r4
subroutine check_c8 (a, b)
complex(kind=8), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_c8
subroutine check_c4 (a, b)
complex(kind=4), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_c4
end module mod_check
program test
use mod_check
implicit none
integer(kind=4) :: i4
integer(kind=8) :: i8
real(kind=4) :: r4
real(kind=8) :: r8
complex(kind=4) :: c4
complex(kind=8) :: c8
#define TEST(base,exp,var) var = base; call check((var)**(exp),(base)**(exp))
!!!!! INTEGER BASE !!!!!
TEST(3,23,i4)
TEST(-3,23,i4)
TEST(3_8,43_8,i8)
TEST(-3_8,43_8,i8)
TEST(17_8,int(huge(0_4),kind=8)+1,i8)
!!!!! REAL BASE !!!!!
TEST(0.0,-1,r4)
TEST(0.0,-huge(0)-1,r4)
TEST(2.0,huge(0),r4)
TEST(nearest(1.0,-1.0),-huge(0),r4)
end program test
| gpl-2.0 |
tuxillo/aarch64-dragonfly-gcc | gcc/testsuite/gfortran.dg/namelist_use_only.f90 | 136 | 1248 | ! { dg-do run }
! { dg-options "-std=legacy" }
!
! This tests the fix for PR22010, where namelists were not being written to
! and read back from modules. It checks that namelists from modules that are
! selected by an ONLY declaration work correctly, even when the variables in
! the namelist are not host associated. Note that renaming a namelist by USE
! association is not allowed by the standard and this is trapped in module.c.
!
! Contributed by Paul Thomas pault@gcc.gnu.org
!
module global
character*4 :: aa, aaa
integer :: ii, iii
real :: rr, rrr
namelist /nml1/ aa, ii, rr
namelist /nml2/ aaa, iii, rrr
contains
logical function foo()
foo = (aaa.ne."pqrs").or.(iii.ne.2).or.(rrr.ne.3.5)
end function foo
end module global
program namelist_use_only
use global, only : nml1, aa, ii, rr
use global, only : nml2, rrrr=>rrr, foo
open (10, status="scratch")
write (10,'(a)') "&NML1 aa='lmno' ii=1 rr=2.5 /"
write (10,'(a)') "&NML2 aaa='pqrs' iii=2 rrr=3.5 /"
rewind (10)
read (10,nml=nml1,iostat=i)
if ((i.ne.0).or.(aa.ne."lmno").or.(ii.ne.1).or.(rr.ne.2.5)) call abort ()
read (10,nml=nml2,iostat=i)
if ((i.ne.0).or.(rrrr.ne.3.5).or.foo()) call abort ()
close (10)
end program namelist_use_only
| gpl-2.0 |
intervigilium/cs259-or32-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 |
robustrobotics/eigen | lapack/clarfb.f | 273 | 23424 | *> \brief \b CLARFB
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download CLARFB + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clarfb.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clarfb.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clarfb.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE CLARFB( SIDE, TRANS, DIRECT, STOREV, M, N, K, V, LDV,
* T, LDT, C, LDC, WORK, LDWORK )
*
* .. Scalar Arguments ..
* CHARACTER DIRECT, SIDE, STOREV, TRANS
* INTEGER K, LDC, LDT, LDV, LDWORK, M, N
* ..
* .. Array Arguments ..
* COMPLEX C( LDC, * ), T( LDT, * ), V( LDV, * ),
* $ WORK( LDWORK, * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> CLARFB applies a complex block reflector H or its transpose H**H to a
*> complex M-by-N matrix C, from either the left or the right.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] SIDE
*> \verbatim
*> SIDE is CHARACTER*1
*> = 'L': apply H or H**H from the Left
*> = 'R': apply H or H**H from the Right
*> \endverbatim
*>
*> \param[in] TRANS
*> \verbatim
*> TRANS is CHARACTER*1
*> = 'N': apply H (No transpose)
*> = 'C': apply H**H (Conjugate transpose)
*> \endverbatim
*>
*> \param[in] DIRECT
*> \verbatim
*> DIRECT is CHARACTER*1
*> Indicates how H is formed from a product of elementary
*> reflectors
*> = 'F': H = H(1) H(2) . . . H(k) (Forward)
*> = 'B': H = H(k) . . . H(2) H(1) (Backward)
*> \endverbatim
*>
*> \param[in] STOREV
*> \verbatim
*> STOREV is CHARACTER*1
*> Indicates how the vectors which define the elementary
*> reflectors are stored:
*> = 'C': Columnwise
*> = 'R': Rowwise
*> \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] K
*> \verbatim
*> K is INTEGER
*> The order of the matrix T (= the number of elementary
*> reflectors whose product defines the block reflector).
*> \endverbatim
*>
*> \param[in] V
*> \verbatim
*> V is COMPLEX array, dimension
*> (LDV,K) if STOREV = 'C'
*> (LDV,M) if STOREV = 'R' and SIDE = 'L'
*> (LDV,N) if STOREV = 'R' and SIDE = 'R'
*> The matrix V. See Further Details.
*> \endverbatim
*>
*> \param[in] LDV
*> \verbatim
*> LDV is INTEGER
*> The leading dimension of the array V.
*> If STOREV = 'C' and SIDE = 'L', LDV >= max(1,M);
*> if STOREV = 'C' and SIDE = 'R', LDV >= max(1,N);
*> if STOREV = 'R', LDV >= K.
*> \endverbatim
*>
*> \param[in] T
*> \verbatim
*> T is COMPLEX array, dimension (LDT,K)
*> The triangular K-by-K matrix T in the representation of the
*> block reflector.
*> \endverbatim
*>
*> \param[in] LDT
*> \verbatim
*> LDT is INTEGER
*> The leading dimension of the array T. LDT >= K.
*> \endverbatim
*>
*> \param[in,out] C
*> \verbatim
*> C is COMPLEX array, dimension (LDC,N)
*> On entry, the M-by-N matrix C.
*> On exit, C is overwritten by H*C or H**H*C or C*H or C*H**H.
*> \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 COMPLEX array, dimension (LDWORK,K)
*> \endverbatim
*>
*> \param[in] LDWORK
*> \verbatim
*> LDWORK is INTEGER
*> The leading dimension of the array WORK.
*> If SIDE = 'L', LDWORK >= max(1,N);
*> if SIDE = 'R', LDWORK >= max(1,M).
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup complexOTHERauxiliary
*
*> \par Further Details:
* =====================
*>
*> \verbatim
*>
*> The shape of the matrix V and the storage of the vectors which define
*> the H(i) is best illustrated by the following example with n = 5 and
*> k = 3. The elements equal to 1 are not stored; the corresponding
*> array elements are modified but restored on exit. The rest of the
*> array is not used.
*>
*> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
*>
*> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
*> ( v1 1 ) ( 1 v2 v2 v2 )
*> ( v1 v2 1 ) ( 1 v3 v3 )
*> ( v1 v2 v3 )
*> ( v1 v2 v3 )
*>
*> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
*>
*> V = ( v1 v2 v3 ) V = ( v1 v1 1 )
*> ( v1 v2 v3 ) ( v2 v2 v2 1 )
*> ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
*> ( 1 v3 )
*> ( 1 )
*> \endverbatim
*>
* =====================================================================
SUBROUTINE CLARFB( SIDE, TRANS, DIRECT, STOREV, M, N, K, V, LDV,
$ T, LDT, C, LDC, WORK, LDWORK )
*
* -- 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 DIRECT, SIDE, STOREV, TRANS
INTEGER K, LDC, LDT, LDV, LDWORK, M, N
* ..
* .. Array Arguments ..
COMPLEX C( LDC, * ), T( LDT, * ), V( LDV, * ),
$ WORK( LDWORK, * )
* ..
*
* =====================================================================
*
* .. Parameters ..
COMPLEX ONE
PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ) )
* ..
* .. Local Scalars ..
CHARACTER TRANST
INTEGER I, J, LASTV, LASTC
* ..
* .. External Functions ..
LOGICAL LSAME
INTEGER ILACLR, ILACLC
EXTERNAL LSAME, ILACLR, ILACLC
* ..
* .. External Subroutines ..
EXTERNAL CCOPY, CGEMM, CLACGV, CTRMM
* ..
* .. Intrinsic Functions ..
INTRINSIC CONJG
* ..
* .. Executable Statements ..
*
* Quick return if possible
*
IF( M.LE.0 .OR. N.LE.0 )
$ RETURN
*
IF( LSAME( TRANS, 'N' ) ) THEN
TRANST = 'C'
ELSE
TRANST = 'N'
END IF
*
IF( LSAME( STOREV, 'C' ) ) THEN
*
IF( LSAME( DIRECT, 'F' ) ) THEN
*
* Let V = ( V1 ) (first K rows)
* ( V2 )
* where V1 is unit lower triangular.
*
IF( LSAME( SIDE, 'L' ) ) THEN
*
* Form H * C or H**H * C where C = ( C1 )
* ( C2 )
*
LASTV = MAX( K, ILACLR( M, K, V, LDV ) )
LASTC = ILACLC( LASTV, N, C, LDC )
*
* W := C**H * V = (C1**H * V1 + C2**H * V2) (stored in WORK)
*
* W := C1**H
*
DO 10 J = 1, K
CALL CCOPY( LASTC, C( J, 1 ), LDC, WORK( 1, J ), 1 )
CALL CLACGV( LASTC, WORK( 1, J ), 1 )
10 CONTINUE
*
* W := W * V1
*
CALL CTRMM( 'Right', 'Lower', 'No transpose', 'Unit',
$ LASTC, K, ONE, V, LDV, WORK, LDWORK )
IF( LASTV.GT.K ) THEN
*
* W := W + C2**H *V2
*
CALL CGEMM( 'Conjugate transpose', 'No transpose',
$ LASTC, K, LASTV-K, ONE, C( K+1, 1 ), LDC,
$ V( K+1, 1 ), LDV, ONE, WORK, LDWORK )
END IF
*
* W := W * T**H or W * T
*
CALL CTRMM( 'Right', 'Upper', TRANST, 'Non-unit',
$ LASTC, K, ONE, T, LDT, WORK, LDWORK )
*
* C := C - V * W**H
*
IF( M.GT.K ) THEN
*
* C2 := C2 - V2 * W**H
*
CALL CGEMM( 'No transpose', 'Conjugate transpose',
$ LASTV-K, LASTC, K, -ONE, V( K+1, 1 ), LDV,
$ WORK, LDWORK, ONE, C( K+1, 1 ), LDC )
END IF
*
* W := W * V1**H
*
CALL CTRMM( 'Right', 'Lower', 'Conjugate transpose',
$ 'Unit', LASTC, K, ONE, V, LDV, WORK, LDWORK )
*
* C1 := C1 - W**H
*
DO 30 J = 1, K
DO 20 I = 1, LASTC
C( J, I ) = C( J, I ) - CONJG( WORK( I, J ) )
20 CONTINUE
30 CONTINUE
*
ELSE IF( LSAME( SIDE, 'R' ) ) THEN
*
* Form C * H or C * H**H where C = ( C1 C2 )
*
LASTV = MAX( K, ILACLR( N, K, V, LDV ) )
LASTC = ILACLR( M, LASTV, C, LDC )
*
* W := C * V = (C1*V1 + C2*V2) (stored in WORK)
*
* W := C1
*
DO 40 J = 1, K
CALL CCOPY( LASTC, C( 1, J ), 1, WORK( 1, J ), 1 )
40 CONTINUE
*
* W := W * V1
*
CALL CTRMM( 'Right', 'Lower', 'No transpose', 'Unit',
$ LASTC, K, ONE, V, LDV, WORK, LDWORK )
IF( LASTV.GT.K ) THEN
*
* W := W + C2 * V2
*
CALL CGEMM( 'No transpose', 'No transpose',
$ LASTC, K, LASTV-K,
$ ONE, C( 1, K+1 ), LDC, V( K+1, 1 ), LDV,
$ ONE, WORK, LDWORK )
END IF
*
* W := W * T or W * T**H
*
CALL CTRMM( 'Right', 'Upper', TRANS, 'Non-unit',
$ LASTC, K, ONE, T, LDT, WORK, LDWORK )
*
* C := C - W * V**H
*
IF( LASTV.GT.K ) THEN
*
* C2 := C2 - W * V2**H
*
CALL CGEMM( 'No transpose', 'Conjugate transpose',
$ LASTC, LASTV-K, K,
$ -ONE, WORK, LDWORK, V( K+1, 1 ), LDV,
$ ONE, C( 1, K+1 ), LDC )
END IF
*
* W := W * V1**H
*
CALL CTRMM( 'Right', 'Lower', 'Conjugate transpose',
$ 'Unit', LASTC, K, ONE, V, LDV, WORK, LDWORK )
*
* C1 := C1 - W
*
DO 60 J = 1, K
DO 50 I = 1, LASTC
C( I, J ) = C( I, J ) - WORK( I, J )
50 CONTINUE
60 CONTINUE
END IF
*
ELSE
*
* Let V = ( V1 )
* ( V2 ) (last K rows)
* where V2 is unit upper triangular.
*
IF( LSAME( SIDE, 'L' ) ) THEN
*
* Form H * C or H**H * C where C = ( C1 )
* ( C2 )
*
LASTV = MAX( K, ILACLR( M, K, V, LDV ) )
LASTC = ILACLC( LASTV, N, C, LDC )
*
* W := C**H * V = (C1**H * V1 + C2**H * V2) (stored in WORK)
*
* W := C2**H
*
DO 70 J = 1, K
CALL CCOPY( LASTC, C( LASTV-K+J, 1 ), LDC,
$ WORK( 1, J ), 1 )
CALL CLACGV( LASTC, WORK( 1, J ), 1 )
70 CONTINUE
*
* W := W * V2
*
CALL CTRMM( 'Right', 'Upper', 'No transpose', 'Unit',
$ LASTC, K, ONE, V( LASTV-K+1, 1 ), LDV,
$ WORK, LDWORK )
IF( LASTV.GT.K ) THEN
*
* W := W + C1**H*V1
*
CALL CGEMM( 'Conjugate transpose', 'No transpose',
$ LASTC, K, LASTV-K, ONE, C, LDC, V, LDV,
$ ONE, WORK, LDWORK )
END IF
*
* W := W * T**H or W * T
*
CALL CTRMM( 'Right', 'Lower', TRANST, 'Non-unit',
$ LASTC, K, ONE, T, LDT, WORK, LDWORK )
*
* C := C - V * W**H
*
IF( LASTV.GT.K ) THEN
*
* C1 := C1 - V1 * W**H
*
CALL CGEMM( 'No transpose', 'Conjugate transpose',
$ LASTV-K, LASTC, K, -ONE, V, LDV, WORK, LDWORK,
$ ONE, C, LDC )
END IF
*
* W := W * V2**H
*
CALL CTRMM( 'Right', 'Upper', 'Conjugate transpose',
$ 'Unit', LASTC, K, ONE, V( LASTV-K+1, 1 ), LDV,
$ WORK, LDWORK )
*
* C2 := C2 - W**H
*
DO 90 J = 1, K
DO 80 I = 1, LASTC
C( LASTV-K+J, I ) = C( LASTV-K+J, I ) -
$ CONJG( WORK( I, J ) )
80 CONTINUE
90 CONTINUE
*
ELSE IF( LSAME( SIDE, 'R' ) ) THEN
*
* Form C * H or C * H**H where C = ( C1 C2 )
*
LASTV = MAX( K, ILACLR( N, K, V, LDV ) )
LASTC = ILACLR( M, LASTV, C, LDC )
*
* W := C * V = (C1*V1 + C2*V2) (stored in WORK)
*
* W := C2
*
DO 100 J = 1, K
CALL CCOPY( LASTC, C( 1, LASTV-K+J ), 1,
$ WORK( 1, J ), 1 )
100 CONTINUE
*
* W := W * V2
*
CALL CTRMM( 'Right', 'Upper', 'No transpose', 'Unit',
$ LASTC, K, ONE, V( LASTV-K+1, 1 ), LDV,
$ WORK, LDWORK )
IF( LASTV.GT.K ) THEN
*
* W := W + C1 * V1
*
CALL CGEMM( 'No transpose', 'No transpose',
$ LASTC, K, LASTV-K,
$ ONE, C, LDC, V, LDV, ONE, WORK, LDWORK )
END IF
*
* W := W * T or W * T**H
*
CALL CTRMM( 'Right', 'Lower', TRANS, 'Non-unit',
$ LASTC, K, ONE, T, LDT, WORK, LDWORK )
*
* C := C - W * V**H
*
IF( LASTV.GT.K ) THEN
*
* C1 := C1 - W * V1**H
*
CALL CGEMM( 'No transpose', 'Conjugate transpose',
$ LASTC, LASTV-K, K, -ONE, WORK, LDWORK, V, LDV,
$ ONE, C, LDC )
END IF
*
* W := W * V2**H
*
CALL CTRMM( 'Right', 'Upper', 'Conjugate transpose',
$ 'Unit', LASTC, K, ONE, V( LASTV-K+1, 1 ), LDV,
$ WORK, LDWORK )
*
* C2 := C2 - W
*
DO 120 J = 1, K
DO 110 I = 1, LASTC
C( I, LASTV-K+J ) = C( I, LASTV-K+J )
$ - WORK( I, J )
110 CONTINUE
120 CONTINUE
END IF
END IF
*
ELSE IF( LSAME( STOREV, 'R' ) ) THEN
*
IF( LSAME( DIRECT, 'F' ) ) THEN
*
* Let V = ( V1 V2 ) (V1: first K columns)
* where V1 is unit upper triangular.
*
IF( LSAME( SIDE, 'L' ) ) THEN
*
* Form H * C or H**H * C where C = ( C1 )
* ( C2 )
*
LASTV = MAX( K, ILACLC( K, M, V, LDV ) )
LASTC = ILACLC( LASTV, N, C, LDC )
*
* W := C**H * V**H = (C1**H * V1**H + C2**H * V2**H) (stored in WORK)
*
* W := C1**H
*
DO 130 J = 1, K
CALL CCOPY( LASTC, C( J, 1 ), LDC, WORK( 1, J ), 1 )
CALL CLACGV( LASTC, WORK( 1, J ), 1 )
130 CONTINUE
*
* W := W * V1**H
*
CALL CTRMM( 'Right', 'Upper', 'Conjugate transpose',
$ 'Unit', LASTC, K, ONE, V, LDV, WORK, LDWORK )
IF( LASTV.GT.K ) THEN
*
* W := W + C2**H*V2**H
*
CALL CGEMM( 'Conjugate transpose',
$ 'Conjugate transpose', LASTC, K, LASTV-K,
$ ONE, C( K+1, 1 ), LDC, V( 1, K+1 ), LDV,
$ ONE, WORK, LDWORK )
END IF
*
* W := W * T**H or W * T
*
CALL CTRMM( 'Right', 'Upper', TRANST, 'Non-unit',
$ LASTC, K, ONE, T, LDT, WORK, LDWORK )
*
* C := C - V**H * W**H
*
IF( LASTV.GT.K ) THEN
*
* C2 := C2 - V2**H * W**H
*
CALL CGEMM( 'Conjugate transpose',
$ 'Conjugate transpose', LASTV-K, LASTC, K,
$ -ONE, V( 1, K+1 ), LDV, WORK, LDWORK,
$ ONE, C( K+1, 1 ), LDC )
END IF
*
* W := W * V1
*
CALL CTRMM( 'Right', 'Upper', 'No transpose', 'Unit',
$ LASTC, K, ONE, V, LDV, WORK, LDWORK )
*
* C1 := C1 - W**H
*
DO 150 J = 1, K
DO 140 I = 1, LASTC
C( J, I ) = C( J, I ) - CONJG( WORK( I, J ) )
140 CONTINUE
150 CONTINUE
*
ELSE IF( LSAME( SIDE, 'R' ) ) THEN
*
* Form C * H or C * H**H where C = ( C1 C2 )
*
LASTV = MAX( K, ILACLC( K, N, V, LDV ) )
LASTC = ILACLR( M, LASTV, C, LDC )
*
* W := C * V**H = (C1*V1**H + C2*V2**H) (stored in WORK)
*
* W := C1
*
DO 160 J = 1, K
CALL CCOPY( LASTC, C( 1, J ), 1, WORK( 1, J ), 1 )
160 CONTINUE
*
* W := W * V1**H
*
CALL CTRMM( 'Right', 'Upper', 'Conjugate transpose',
$ 'Unit', LASTC, K, ONE, V, LDV, WORK, LDWORK )
IF( LASTV.GT.K ) THEN
*
* W := W + C2 * V2**H
*
CALL CGEMM( 'No transpose', 'Conjugate transpose',
$ LASTC, K, LASTV-K, ONE, C( 1, K+1 ), LDC,
$ V( 1, K+1 ), LDV, ONE, WORK, LDWORK )
END IF
*
* W := W * T or W * T**H
*
CALL CTRMM( 'Right', 'Upper', TRANS, 'Non-unit',
$ LASTC, K, ONE, T, LDT, WORK, LDWORK )
*
* C := C - W * V
*
IF( LASTV.GT.K ) THEN
*
* C2 := C2 - W * V2
*
CALL CGEMM( 'No transpose', 'No transpose',
$ LASTC, LASTV-K, K,
$ -ONE, WORK, LDWORK, V( 1, K+1 ), LDV,
$ ONE, C( 1, K+1 ), LDC )
END IF
*
* W := W * V1
*
CALL CTRMM( 'Right', 'Upper', 'No transpose', 'Unit',
$ LASTC, K, ONE, V, LDV, WORK, LDWORK )
*
* C1 := C1 - W
*
DO 180 J = 1, K
DO 170 I = 1, LASTC
C( I, J ) = C( I, J ) - WORK( I, J )
170 CONTINUE
180 CONTINUE
*
END IF
*
ELSE
*
* Let V = ( V1 V2 ) (V2: last K columns)
* where V2 is unit lower triangular.
*
IF( LSAME( SIDE, 'L' ) ) THEN
*
* Form H * C or H**H * C where C = ( C1 )
* ( C2 )
*
LASTV = MAX( K, ILACLC( K, M, V, LDV ) )
LASTC = ILACLC( LASTV, N, C, LDC )
*
* W := C**H * V**H = (C1**H * V1**H + C2**H * V2**H) (stored in WORK)
*
* W := C2**H
*
DO 190 J = 1, K
CALL CCOPY( LASTC, C( LASTV-K+J, 1 ), LDC,
$ WORK( 1, J ), 1 )
CALL CLACGV( LASTC, WORK( 1, J ), 1 )
190 CONTINUE
*
* W := W * V2**H
*
CALL CTRMM( 'Right', 'Lower', 'Conjugate transpose',
$ 'Unit', LASTC, K, ONE, V( 1, LASTV-K+1 ), LDV,
$ WORK, LDWORK )
IF( LASTV.GT.K ) THEN
*
* W := W + C1**H * V1**H
*
CALL CGEMM( 'Conjugate transpose',
$ 'Conjugate transpose', LASTC, K, LASTV-K,
$ ONE, C, LDC, V, LDV, ONE, WORK, LDWORK )
END IF
*
* W := W * T**H or W * T
*
CALL CTRMM( 'Right', 'Lower', TRANST, 'Non-unit',
$ LASTC, K, ONE, T, LDT, WORK, LDWORK )
*
* C := C - V**H * W**H
*
IF( LASTV.GT.K ) THEN
*
* C1 := C1 - V1**H * W**H
*
CALL CGEMM( 'Conjugate transpose',
$ 'Conjugate transpose', LASTV-K, LASTC, K,
$ -ONE, V, LDV, WORK, LDWORK, ONE, C, LDC )
END IF
*
* W := W * V2
*
CALL CTRMM( 'Right', 'Lower', 'No transpose', 'Unit',
$ LASTC, K, ONE, V( 1, LASTV-K+1 ), LDV,
$ WORK, LDWORK )
*
* C2 := C2 - W**H
*
DO 210 J = 1, K
DO 200 I = 1, LASTC
C( LASTV-K+J, I ) = C( LASTV-K+J, I ) -
$ CONJG( WORK( I, J ) )
200 CONTINUE
210 CONTINUE
*
ELSE IF( LSAME( SIDE, 'R' ) ) THEN
*
* Form C * H or C * H**H where C = ( C1 C2 )
*
LASTV = MAX( K, ILACLC( K, N, V, LDV ) )
LASTC = ILACLR( M, LASTV, C, LDC )
*
* W := C * V**H = (C1*V1**H + C2*V2**H) (stored in WORK)
*
* W := C2
*
DO 220 J = 1, K
CALL CCOPY( LASTC, C( 1, LASTV-K+J ), 1,
$ WORK( 1, J ), 1 )
220 CONTINUE
*
* W := W * V2**H
*
CALL CTRMM( 'Right', 'Lower', 'Conjugate transpose',
$ 'Unit', LASTC, K, ONE, V( 1, LASTV-K+1 ), LDV,
$ WORK, LDWORK )
IF( LASTV.GT.K ) THEN
*
* W := W + C1 * V1**H
*
CALL CGEMM( 'No transpose', 'Conjugate transpose',
$ LASTC, K, LASTV-K, ONE, C, LDC, V, LDV, ONE,
$ WORK, LDWORK )
END IF
*
* W := W * T or W * T**H
*
CALL CTRMM( 'Right', 'Lower', TRANS, 'Non-unit',
$ LASTC, K, ONE, T, LDT, WORK, LDWORK )
*
* C := C - W * V
*
IF( LASTV.GT.K ) THEN
*
* C1 := C1 - W * V1
*
CALL CGEMM( 'No transpose', 'No transpose',
$ LASTC, LASTV-K, K, -ONE, WORK, LDWORK, V, LDV,
$ ONE, C, LDC )
END IF
*
* W := W * V2
*
CALL CTRMM( 'Right', 'Lower', 'No transpose', 'Unit',
$ LASTC, K, ONE, V( 1, LASTV-K+1 ), LDV,
$ WORK, LDWORK )
*
* C1 := C1 - W
*
DO 240 J = 1, K
DO 230 I = 1, LASTC
C( I, LASTV-K+J ) = C( I, LASTV-K+J )
$ - WORK( I, J )
230 CONTINUE
240 CONTINUE
*
END IF
*
END IF
END IF
*
RETURN
*
* End of CLARFB
*
END
| bsd-3-clause |
kmkolasinski/Quantulaba | include/blas.f90 | 2 | 153487 | !*******************************************************************************
! Copyright(C) 2005-2013 Intel Corporation. All Rights Reserved.
!
! The source code, information and material ("Material") contained herein is
! owned by Intel Corporation or its suppliers or licensors, and title to such
! Material remains with Intel Corporation or its suppliers or licensors. The
! Material contains proprietary information of Intel or its suppliers and
! licensors. The Material is protected by worldwide copyright laws and treaty
! provisions. No part of the Material may be used, copied, reproduced,
! modified, published, uploaded, posted, transmitted, distributed or disclosed
! in any way without Intel's prior express written permission. No license
! under any patent, copyright or other intellectual property rights in the
! Material is granted to or conferred upon you, either expressly, by
! implication, inducement, estoppel or otherwise. Any license under such
! intellectual property rights must be express and approved by Intel in
! writing.
!
! *Third Party trademarks are the property of their respective owners.
!
! Unless otherwise agreed by Intel in writing, you may not remove or alter
! this notice or any other notice embedded in Materials by Intel or Intel's
! suppliers or licensors in any way.
!
!*******************************************************************************
! Content:
! F95 interface for BLAS routines
!*******************************************************************************
! This file was generated automatically!
!*******************************************************************************
MODULE F95_PRECISION
INTEGER, PARAMETER :: SP = KIND(1.0E0)
INTEGER, PARAMETER :: DP = KIND(1.0D0)
END MODULE F95_PRECISION
MODULE BLAS95
INTERFACE ASUM
PURE FUNCTION SASUM_F95(X)
! Fortran77 call:
! SASUM(N,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP) :: SASUM_F95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION SASUM_F95
PURE FUNCTION SCASUM_F95(X)
! Fortran77 call:
! SCASUM(N,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP) :: SCASUM_F95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION SCASUM_F95
PURE FUNCTION DASUM_F95(X)
! Fortran77 call:
! DASUM(N,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP) :: DASUM_F95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION DASUM_F95
PURE FUNCTION DZASUM_F95(X)
! Fortran77 call:
! DZASUM(N,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP) :: DZASUM_F95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION DZASUM_F95
END INTERFACE ASUM
INTERFACE AXPY
! Default A=1
PURE SUBROUTINE SAXPY_F95(X,Y,A)
! Fortran77 call:
! SAXPY(N,A,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: A
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SAXPY_F95
PURE SUBROUTINE DAXPY_F95(X,Y,A)
! Fortran77 call:
! DAXPY(N,A,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: A
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DAXPY_F95
PURE SUBROUTINE CAXPY_F95(X,Y,A)
! Fortran77 call:
! CAXPY(N,A,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: A
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CAXPY_F95
PURE SUBROUTINE ZAXPY_F95(X,Y,A)
! Fortran77 call:
! ZAXPY(N,A,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: A
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZAXPY_F95
END INTERFACE AXPY
INTERFACE COPY
PURE SUBROUTINE SCOPY_F95(X,Y)
! Fortran77 call:
! SCOPY(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SCOPY_F95
PURE SUBROUTINE DCOPY_F95(X,Y)
! Fortran77 call:
! DCOPY(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DCOPY_F95
PURE SUBROUTINE CCOPY_F95(X,Y)
! Fortran77 call:
! CCOPY(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CCOPY_F95
PURE SUBROUTINE ZCOPY_F95(X,Y)
! Fortran77 call:
! ZCOPY(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZCOPY_F95
END INTERFACE COPY
INTERFACE DOT
PURE FUNCTION SDOT_F95(X,Y)
! Fortran77 call:
! SDOT(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP) :: SDOT_F95
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END FUNCTION SDOT_F95
PURE FUNCTION DDOT_F95(X,Y)
! Fortran77 call:
! DDOT(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP) :: DDOT_F95
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END FUNCTION DDOT_F95
END INTERFACE DOT
INTERFACE SDOT
PURE FUNCTION SDSDOT_F95(SX,SY,SB)
! Fortran77 call:
! SDSDOT(N,SB,SX,INCX,SY,INCY)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP) :: SDSDOT_F95
REAL(WP), INTENT(IN) :: SB
REAL(WP), INTENT(IN) :: SX(:)
REAL(WP), INTENT(IN) :: SY(:)
END FUNCTION SDSDOT_F95
PURE FUNCTION DSDOT_F95(SX,SY)
! Fortran77 call:
! DSDOT(N,SX,INCX,SY,INCY)
USE F95_PRECISION, ONLY: WP => DP, SP
REAL(WP) :: DSDOT_F95
REAL(SP), INTENT(IN) :: SX(:)
REAL(SP), INTENT(IN) :: SY(:)
END FUNCTION DSDOT_F95
END INTERFACE SDOT
INTERFACE DOTC
PURE FUNCTION CDOTC_F95(X,Y)
! Fortran77 call:
! CDOTC(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP) :: CDOTC_F95
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION CDOTC_F95
PURE FUNCTION ZDOTC_F95(X,Y)
! Fortran77 call:
! ZDOTC(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP) :: ZDOTC_F95
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION ZDOTC_F95
END INTERFACE DOTC
INTERFACE DOTU
PURE FUNCTION CDOTU_F95(X,Y)
! Fortran77 call:
! CDOTU(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP) :: CDOTU_F95
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION CDOTU_F95
PURE FUNCTION ZDOTU_F95(X,Y)
! Fortran77 call:
! ZDOTU(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP) :: ZDOTU_F95
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION ZDOTU_F95
END INTERFACE DOTU
INTERFACE NRM2
PURE FUNCTION SNRM2_F95(X)
! Fortran77 call:
! SNRM2(N,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP) :: SNRM2_F95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION SNRM2_F95
PURE FUNCTION DNRM2_F95(X)
! Fortran77 call:
! DNRM2(N,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP) :: DNRM2_F95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION DNRM2_F95
PURE FUNCTION SCNRM2_F95(X)
! Fortran77 call:
! SCNRM2(N,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP) :: SCNRM2_F95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION SCNRM2_F95
PURE FUNCTION DZNRM2_F95(X)
! Fortran77 call:
! DZNRM2(N,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP) :: DZNRM2_F95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION DZNRM2_F95
END INTERFACE NRM2
INTERFACE ROT
PURE SUBROUTINE SROT_F95(X,Y,C,S)
! Fortran77 call:
! SROT(N,X,INCX,Y,INCY,C,S)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SROT_F95
PURE SUBROUTINE DROT_F95(X,Y,C,S)
! Fortran77 call:
! DROT(N,X,INCX,Y,INCY,C,S)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DROT_F95
PURE SUBROUTINE CSROT_F95(X,Y,C,S)
! Fortran77 call:
! CSROT(N,X,INCX,Y,INCY,C,S)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
COMPLEX(WP), INTENT(INOUT) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CSROT_F95
PURE SUBROUTINE ZDROT_F95(X,Y,C,S)
! Fortran77 call:
! ZDROT(N,X,INCX,Y,INCY,C,S)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
COMPLEX(WP), INTENT(INOUT) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZDROT_F95
END INTERFACE ROT
INTERFACE ROTG
PURE SUBROUTINE SROTG(A,B,C,S)
! Fortran77 call:
! SROTG(A,B,C,S)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(INOUT) :: A
REAL(WP), INTENT(INOUT) :: B
REAL(WP), INTENT(OUT) :: C
REAL(WP), INTENT(OUT) :: S
END SUBROUTINE SROTG
PURE SUBROUTINE DROTG(A,B,C,S)
! Fortran77 call:
! DROTG(A,B,C,S)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(INOUT) :: A
REAL(WP), INTENT(INOUT) :: B
REAL(WP), INTENT(OUT) :: C
REAL(WP), INTENT(OUT) :: S
END SUBROUTINE DROTG
PURE SUBROUTINE CROTG(A,B,C,S)
! Fortran77 call:
! CROTG(A,B,C,S)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(INOUT) :: A
COMPLEX(WP), INTENT(INOUT) :: B
REAL(WP), INTENT(OUT) :: C
COMPLEX(WP), INTENT(OUT) :: S
END SUBROUTINE CROTG
PURE SUBROUTINE ZROTG(A,B,C,S)
! Fortran77 call:
! ZROTG(A,B,C,S)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(INOUT) :: A
COMPLEX(WP), INTENT(INOUT) :: B
REAL(WP), INTENT(OUT) :: C
COMPLEX(WP), INTENT(OUT) :: S
END SUBROUTINE ZROTG
END INTERFACE ROTG
INTERFACE ROTM
PURE SUBROUTINE SROTM_F95(X,Y,PARAM)
! Fortran77 call:
! SROTM(N,X,INCX,Y,INCY,PARAM)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
REAL(WP), INTENT(IN) :: PARAM(5)
END SUBROUTINE SROTM_F95
PURE SUBROUTINE DROTM_F95(X,Y,PARAM)
! Fortran77 call:
! DROTM(N,X,INCX,Y,INCY,PARAM)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
REAL(WP), INTENT(IN) :: PARAM(5)
END SUBROUTINE DROTM_F95
END INTERFACE ROTM
INTERFACE ROTMG
PURE SUBROUTINE SROTMG_F95(D1,D2,X1,Y1,PARAM)
! Fortran77 call:
! SROTMG(D1,D2,X1,Y1,PARAM)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(INOUT) :: D1
REAL(WP), INTENT(INOUT) :: D2
REAL(WP), INTENT(INOUT) :: X1
REAL(WP), INTENT(IN) :: Y1
REAL(WP), INTENT(OUT) :: PARAM(5)
END SUBROUTINE SROTMG_F95
PURE SUBROUTINE DROTMG_F95(D1,D2,X1,Y1,PARAM)
! Fortran77 call:
! DROTMG(D1,D2,X1,Y1,PARAM)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(INOUT) :: D1
REAL(WP), INTENT(INOUT) :: D2
REAL(WP), INTENT(INOUT) :: X1
REAL(WP), INTENT(IN) :: Y1
REAL(WP), INTENT(OUT) :: PARAM(5)
END SUBROUTINE DROTMG_F95
END INTERFACE ROTMG
INTERFACE SCAL
PURE SUBROUTINE SSCAL_F95(X,A)
! Fortran77 call:
! SSCAL(N,A,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: A
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE SSCAL_F95
PURE SUBROUTINE DSCAL_F95(X,A)
! Fortran77 call:
! DSCAL(N,A,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: A
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DSCAL_F95
PURE SUBROUTINE CSCAL_F95(X,A)
! Fortran77 call:
! CSCAL(N,A,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN) :: A
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CSCAL_F95
PURE SUBROUTINE ZSCAL_F95(X,A)
! Fortran77 call:
! ZSCAL(N,A,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN) :: A
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZSCAL_F95
PURE SUBROUTINE CSSCAL_F95(X,A)
! Fortran77 call:
! CSSCAL(N,A,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: A
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CSSCAL_F95
PURE SUBROUTINE ZDSCAL_F95(X,A)
! Fortran77 call:
! ZDSCAL(N,A,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: A
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZDSCAL_F95
END INTERFACE SCAL
INTERFACE SWAP
PURE SUBROUTINE SSWAP_F95(X,Y)
! Fortran77 call:
! SSWAP(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SSWAP_F95
PURE SUBROUTINE DSWAP_F95(X,Y)
! Fortran77 call:
! DSWAP(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DSWAP_F95
PURE SUBROUTINE CSWAP_F95(X,Y)
! Fortran77 call:
! CSWAP(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(INOUT) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CSWAP_F95
PURE SUBROUTINE ZSWAP_F95(X,Y)
! Fortran77 call:
! ZSWAP(N,X,INCX,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(INOUT) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZSWAP_F95
END INTERFACE SWAP
INTERFACE IAMAX
PURE FUNCTION ISAMAX_F95(X)
! Fortran77 call:
! ISAMAX(N,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
INTEGER :: ISAMAX_F95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION ISAMAX_F95
PURE FUNCTION IDAMAX_F95(X)
! Fortran77 call:
! IDAMAX(N,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
INTEGER :: IDAMAX_F95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION IDAMAX_F95
PURE FUNCTION ICAMAX_F95(X)
! Fortran77 call:
! ICAMAX(N,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
INTEGER :: ICAMAX_F95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION ICAMAX_F95
PURE FUNCTION IZAMAX_F95(X)
! Fortran77 call:
! IZAMAX(N,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
INTEGER :: IZAMAX_F95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION IZAMAX_F95
END INTERFACE IAMAX
INTERFACE IAMIN
PURE FUNCTION ISAMIN_F95(X)
! Fortran77 call:
! ISAMIN(N,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
INTEGER :: ISAMIN_F95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION ISAMIN_F95
PURE FUNCTION IDAMIN_F95(X)
! Fortran77 call:
! IDAMIN(N,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
INTEGER :: IDAMIN_F95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION IDAMIN_F95
PURE FUNCTION ICAMIN_F95(X)
! Fortran77 call:
! ICAMIN(N,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
INTEGER :: ICAMIN_F95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION ICAMIN_F95
PURE FUNCTION IZAMIN_F95(X)
! Fortran77 call:
! IZAMIN(N,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
INTEGER :: IZAMIN_F95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION IZAMIN_F95
END INTERFACE IAMIN
INTERFACE CABS1
PURE FUNCTION SCABS1(C)
! Fortran77 call:
! SCABS1(C)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP) :: SCABS1
COMPLEX(WP), INTENT(IN) :: C
END FUNCTION SCABS1
PURE FUNCTION DCABS1(Z)
! Fortran77 call:
! DCABS1(Z)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP) :: DCABS1
COMPLEX(WP), INTENT(IN) :: Z
END FUNCTION DCABS1
END INTERFACE CABS1
INTERFACE GBMV
! TRANS='N','C','T'; default: 'N'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SGBMV_F95(A,X,Y,KL,M,ALPHA,BETA,TRANS)
! Fortran77 call:
! SGBMV(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
INTEGER, INTENT(IN), OPTIONAL :: KL
INTEGER, INTENT(IN), OPTIONAL :: M
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SGBMV_F95
PURE SUBROUTINE DGBMV_F95(A,X,Y,KL,M,ALPHA,BETA,TRANS)
! Fortran77 call:
! DGBMV(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
INTEGER, INTENT(IN), OPTIONAL :: KL
INTEGER, INTENT(IN), OPTIONAL :: M
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DGBMV_F95
PURE SUBROUTINE CGBMV_F95(A,X,Y,KL,M,ALPHA,BETA,TRANS)
! Fortran77 call:
! CGBMV(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
INTEGER, INTENT(IN), OPTIONAL :: KL
INTEGER, INTENT(IN), OPTIONAL :: M
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CGBMV_F95
PURE SUBROUTINE ZGBMV_F95(A,X,Y,KL,M,ALPHA,BETA,TRANS)
! Fortran77 call:
! ZGBMV(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
INTEGER, INTENT(IN), OPTIONAL :: KL
INTEGER, INTENT(IN), OPTIONAL :: M
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZGBMV_F95
END INTERFACE GBMV
INTERFACE GEMV
! TRANS='N','C','T'; default: 'N'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SGEMV_F95(A,X,Y,ALPHA,BETA,TRANS)
! Fortran77 call:
! SGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SGEMV_F95
PURE SUBROUTINE DGEMV_F95(A,X,Y,ALPHA,BETA,TRANS)
! Fortran77 call:
! DGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DGEMV_F95
PURE SUBROUTINE CGEMV_F95(A,X,Y,ALPHA,BETA,TRANS)
! Fortran77 call:
! CGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CGEMV_F95
PURE SUBROUTINE ZGEMV_F95(A,X,Y,ALPHA,BETA,TRANS)
! Fortran77 call:
! ZGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZGEMV_F95
PURE SUBROUTINE SCGEMV_F95(A,X,Y,ALPHA,BETA,TRANS)
! Fortran77 call:
! SCGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SCGEMV_F95
PURE SUBROUTINE DZGEMV_F95(A,X,Y,ALPHA,BETA,TRANS)
! Fortran77 call:
! DZGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DZGEMV_F95
END INTERFACE GEMV
INTERFACE GER
! Default ALPHA=1
PURE SUBROUTINE SGER_F95(A,X,Y,ALPHA)
! Fortran77 call:
! SGER(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SGER_F95
PURE SUBROUTINE DGER_F95(A,X,Y,ALPHA)
! Fortran77 call:
! DGER(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DGER_F95
END INTERFACE GER
INTERFACE GERC
! Default ALPHA=1
PURE SUBROUTINE CGERC_F95(A,X,Y,ALPHA)
! Fortran77 call:
! CGERC(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CGERC_F95
PURE SUBROUTINE ZGERC_F95(A,X,Y,ALPHA)
! Fortran77 call:
! ZGERC(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZGERC_F95
END INTERFACE GERC
INTERFACE GERU
! Default ALPHA=1
PURE SUBROUTINE CGERU_F95(A,X,Y,ALPHA)
! Fortran77 call:
! CGERU(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CGERU_F95
PURE SUBROUTINE ZGERU_F95(A,X,Y,ALPHA)
! Fortran77 call:
! ZGERU(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZGERU_F95
END INTERFACE GERU
INTERFACE HBMV
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE CHBMV_F95(A,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! CHBMV(UPLO,N,K,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CHBMV_F95
PURE SUBROUTINE ZHBMV_F95(A,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! ZHBMV(UPLO,N,K,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZHBMV_F95
END INTERFACE HBMV
INTERFACE HEMV
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE CHEMV_F95(A,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! CHEMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CHEMV_F95
PURE SUBROUTINE ZHEMV_F95(A,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! ZHEMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZHEMV_F95
END INTERFACE HEMV
INTERFACE HER
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
PURE SUBROUTINE CHER_F95(A,X,UPLO,ALPHA)
! Fortran77 call:
! CHER(UPLO,N,ALPHA,X,INCX,A,LDA)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
END SUBROUTINE CHER_F95
PURE SUBROUTINE ZHER_F95(A,X,UPLO,ALPHA)
! Fortran77 call:
! ZHER(UPLO,N,ALPHA,X,INCX,A,LDA)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
END SUBROUTINE ZHER_F95
END INTERFACE HER
INTERFACE HER2
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
PURE SUBROUTINE CHER2_F95(A,X,Y,UPLO,ALPHA)
! Fortran77 call:
! CHER2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CHER2_F95
PURE SUBROUTINE ZHER2_F95(A,X,Y,UPLO,ALPHA)
! Fortran77 call:
! ZHER2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZHER2_F95
END INTERFACE HER2
INTERFACE HPMV
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE CHPMV_F95(AP,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! CHPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CHPMV_F95
PURE SUBROUTINE ZHPMV_F95(AP,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! ZHPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZHPMV_F95
END INTERFACE HPMV
INTERFACE HPR
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
PURE SUBROUTINE CHPR_F95(AP,X,UPLO,ALPHA)
! Fortran77 call:
! CHPR(UPLO,N,ALPHA,X,INCX,AP)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
END SUBROUTINE CHPR_F95
PURE SUBROUTINE ZHPR_F95(AP,X,UPLO,ALPHA)
! Fortran77 call:
! ZHPR(UPLO,N,ALPHA,X,INCX,AP)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
END SUBROUTINE ZHPR_F95
END INTERFACE HPR
INTERFACE HPR2
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
PURE SUBROUTINE CHPR2_F95(AP,X,Y,UPLO,ALPHA)
! Fortran77 call:
! CHPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CHPR2_F95
PURE SUBROUTINE ZHPR2_F95(AP,X,Y,UPLO,ALPHA)
! Fortran77 call:
! ZHPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZHPR2_F95
END INTERFACE HPR2
INTERFACE SBMV
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SSBMV_F95(A,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! SSBMV(UPLO,N,K,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SSBMV_F95
PURE SUBROUTINE DSBMV_F95(A,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! DSBMV(UPLO,N,K,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DSBMV_F95
END INTERFACE SBMV
INTERFACE SPMV
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SSPMV_F95(AP,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! SSPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SSPMV_F95
PURE SUBROUTINE DSPMV_F95(AP,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! DSPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DSPMV_F95
END INTERFACE SPMV
INTERFACE SPR
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
PURE SUBROUTINE SSPR_F95(AP,X,UPLO,ALPHA)
! Fortran77 call:
! SSPR(UPLO,N,ALPHA,X,INCX,AP)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
END SUBROUTINE SSPR_F95
PURE SUBROUTINE DSPR_F95(AP,X,UPLO,ALPHA)
! Fortran77 call:
! DSPR(UPLO,N,ALPHA,X,INCX,AP)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
END SUBROUTINE DSPR_F95
END INTERFACE SPR
INTERFACE SPR2
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
PURE SUBROUTINE SSPR2_F95(AP,X,Y,UPLO,ALPHA)
! Fortran77 call:
! SSPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SSPR2_F95
PURE SUBROUTINE DSPR2_F95(AP,X,Y,UPLO,ALPHA)
! Fortran77 call:
! DSPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DSPR2_F95
END INTERFACE SPR2
INTERFACE SYMV
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SSYMV_F95(A,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! SSYMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SSYMV_F95
PURE SUBROUTINE DSYMV_F95(A,X,Y,UPLO,ALPHA,BETA)
! Fortran77 call:
! DSYMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DSYMV_F95
END INTERFACE SYMV
INTERFACE SYR
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
PURE SUBROUTINE SSYR_F95(A,X,UPLO,ALPHA)
! Fortran77 call:
! SSYR(UPLO,N,ALPHA,X,INCX,A,LDA)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
END SUBROUTINE SSYR_F95
PURE SUBROUTINE DSYR_F95(A,X,UPLO,ALPHA)
! Fortran77 call:
! DSYR(UPLO,N,ALPHA,X,INCX,A,LDA)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
END SUBROUTINE DSYR_F95
END INTERFACE SYR
INTERFACE SYR2
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
PURE SUBROUTINE SSYR2_F95(A,X,Y,UPLO,ALPHA)
! Fortran77 call:
! SSYR2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SSYR2_F95
PURE SUBROUTINE DSYR2_F95(A,X,Y,UPLO,ALPHA)
! Fortran77 call:
! DSYR2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DSYR2_F95
END INTERFACE SYR2
INTERFACE TBMV
! UPLO='U','L'; default: 'U'
! TRANS='N','C','T'; default: 'N'
! DIAG='N','U'; default: 'N'
PURE SUBROUTINE STBMV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! STBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STBMV_F95
PURE SUBROUTINE DTBMV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! DTBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTBMV_F95
PURE SUBROUTINE CTBMV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! CTBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTBMV_F95
PURE SUBROUTINE ZTBMV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! ZTBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTBMV_F95
END INTERFACE TBMV
INTERFACE TBSV
! UPLO='U','L'; default: 'U'
! TRANS='N','C','T'; default: 'N'
! DIAG='N','U'; default: 'N'
PURE SUBROUTINE STBSV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! STBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STBSV_F95
PURE SUBROUTINE DTBSV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! DTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTBSV_F95
PURE SUBROUTINE CTBSV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! CTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTBSV_F95
PURE SUBROUTINE ZTBSV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! ZTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTBSV_F95
END INTERFACE TBSV
INTERFACE TPMV
! UPLO='U','L'; default: 'U'
! TRANS='N','C','T'; default: 'N'
! DIAG='N','U'; default: 'N'
PURE SUBROUTINE STPMV_F95(AP,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! STPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STPMV_F95
PURE SUBROUTINE DTPMV_F95(AP,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! DTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTPMV_F95
PURE SUBROUTINE CTPMV_F95(AP,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! CTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTPMV_F95
PURE SUBROUTINE ZTPMV_F95(AP,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! ZTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTPMV_F95
END INTERFACE TPMV
INTERFACE TPSV
! UPLO='U','L'; default: 'U'
! TRANS='N','C','T'; default: 'N'
! DIAG='N','U'; default: 'N'
PURE SUBROUTINE STPSV_F95(AP,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! STPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STPSV_F95
PURE SUBROUTINE DTPSV_F95(AP,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! DTPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTPSV_F95
PURE SUBROUTINE CTPSV_F95(AP,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! CTPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTPSV_F95
PURE SUBROUTINE ZTPSV_F95(AP,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! ZTPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTPSV_F95
END INTERFACE TPSV
INTERFACE TRMV
! UPLO='U','L'; default: 'U'
! TRANS='N','C','T'; default: 'N'
! DIAG='N','U'; default: 'N'
PURE SUBROUTINE STRMV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! STRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STRMV_F95
PURE SUBROUTINE DTRMV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! DTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTRMV_F95
PURE SUBROUTINE CTRMV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! CTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTRMV_F95
PURE SUBROUTINE ZTRMV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! ZTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTRMV_F95
END INTERFACE TRMV
INTERFACE TRSV
! UPLO='U','L'; default: 'U'
! TRANS='N','C','T'; default: 'N'
! DIAG='N','U'; default: 'N'
PURE SUBROUTINE STRSV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! STRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STRSV_F95
PURE SUBROUTINE DTRSV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! DTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTRSV_F95
PURE SUBROUTINE CTRSV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! CTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTRSV_F95
PURE SUBROUTINE ZTRSV_F95(A,X,UPLO,TRANS,DIAG)
! Fortran77 call:
! ZTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTRSV_F95
END INTERFACE TRSV
INTERFACE GEMM
! TRANSA='N','C','T'; default: 'N'
! TRANSB='N','C','T'; default: 'N'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SGEMM_F95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! Fortran77 call:
! SGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE SGEMM_F95
PURE SUBROUTINE DGEMM_F95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! Fortran77 call:
! DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE DGEMM_F95
PURE SUBROUTINE CGEMM_F95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! Fortran77 call:
! CGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CGEMM_F95
PURE SUBROUTINE ZGEMM_F95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! Fortran77 call:
! ZGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZGEMM_F95
PURE SUBROUTINE SCGEMM_F95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! Fortran77 call:
! SCGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE SCGEMM_F95
PURE SUBROUTINE DZGEMM_F95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! Fortran77 call:
! DZGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE DZGEMM_F95
END INTERFACE GEMM
INTERFACE HEMM
! SIDE='L','R'; default: 'L'
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE CHEMM_F95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! Fortran77 call:
! CHEMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CHEMM_F95
PURE SUBROUTINE ZHEMM_F95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! Fortran77 call:
! ZHEMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZHEMM_F95
END INTERFACE HEMM
INTERFACE HERK
! UPLO='U','L'; default: 'U'
! TRANS='N','C'; default: 'N'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE CHERK_F95(A,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! CHERK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CHERK_F95
PURE SUBROUTINE ZHERK_F95(A,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! ZHERK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZHERK_F95
END INTERFACE HERK
INTERFACE HER2K
! UPLO='U','L'; default: 'U'
! TRANS='N','C'; default: 'N'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE CHER2K_F95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! CHER2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CHER2K_F95
PURE SUBROUTINE ZHER2K_F95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! ZHER2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZHER2K_F95
END INTERFACE HER2K
INTERFACE SYMM
! SIDE='L','R'; default: 'L'
! UPLO='U','L'; default: 'U'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SSYMM_F95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! Fortran77 call:
! SSYMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE SSYMM_F95
PURE SUBROUTINE DSYMM_F95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! Fortran77 call:
! DSYMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE DSYMM_F95
PURE SUBROUTINE CSYMM_F95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! Fortran77 call:
! CSYMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CSYMM_F95
PURE SUBROUTINE ZSYMM_F95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! Fortran77 call:
! ZSYMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZSYMM_F95
END INTERFACE SYMM
INTERFACE SYRK
! UPLO='U','L'; default: 'U'
! TRANS='N','C','T'; default: 'N'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SSYRK_F95(A,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! SSYRK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE SSYRK_F95
PURE SUBROUTINE DSYRK_F95(A,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! DSYRK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE DSYRK_F95
PURE SUBROUTINE CSYRK_F95(A,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! CSYRK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CSYRK_F95
PURE SUBROUTINE ZSYRK_F95(A,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! ZSYRK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZSYRK_F95
END INTERFACE SYRK
INTERFACE SYR2K
! UPLO='U','L'; default: 'U'
! TRANS='N','C','T'; default: 'N'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SSYR2K_F95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! SSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE SSYR2K_F95
PURE SUBROUTINE DSYR2K_F95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! DSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE DSYR2K_F95
PURE SUBROUTINE CSYR2K_F95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! CSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CSYR2K_F95
PURE SUBROUTINE ZSYR2K_F95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! Fortran77 call:
! ZSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZSYR2K_F95
END INTERFACE SYR2K
INTERFACE TRMM
! SIDE='L','R'; default: 'L'
! UPLO='U','L'; default: 'U'
! TRANSA='N','C','T'; default: 'N'
! DIAG='N','U'; default: 'N'
! Default ALPHA=1
PURE SUBROUTINE STRMM_F95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! Fortran77 call:
! STRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE STRMM_F95
PURE SUBROUTINE DTRMM_F95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! Fortran77 call:
! DTRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE DTRMM_F95
PURE SUBROUTINE CTRMM_F95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! Fortran77 call:
! CTRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE CTRMM_F95
PURE SUBROUTINE ZTRMM_F95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! Fortran77 call:
! ZTRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE ZTRMM_F95
END INTERFACE TRMM
INTERFACE TRSM
! SIDE='L','R'; default: 'L'
! UPLO='U','L'; default: 'U'
! TRANSA='N','C','T'; default: 'N'
! DIAG='N','U'; default: 'N'
! Default ALPHA=1
PURE SUBROUTINE STRSM_F95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! Fortran77 call:
! STRSM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE STRSM_F95
PURE SUBROUTINE DTRSM_F95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! Fortran77 call:
! DTRSM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE DTRSM_F95
PURE SUBROUTINE CTRSM_F95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! Fortran77 call:
! CTRSM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE CTRSM_F95
PURE SUBROUTINE ZTRSM_F95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! Fortran77 call:
! ZTRSM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE ZTRSM_F95
END INTERFACE TRSM
INTERFACE AXPYI
! Default A=1
PURE SUBROUTINE SAXPYI_F95(X,INDX,Y,A)
! Fortran77 call:
! SAXPYI(NZ,A,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: A
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SAXPYI_F95
PURE SUBROUTINE DAXPYI_F95(X,INDX,Y,A)
! Fortran77 call:
! DAXPYI(NZ,A,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: A
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DAXPYI_F95
PURE SUBROUTINE CAXPYI_F95(X,INDX,Y,A)
! Fortran77 call:
! CAXPYI(NZ,A,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: A
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CAXPYI_F95
PURE SUBROUTINE ZAXPYI_F95(X,INDX,Y,A)
! Fortran77 call:
! ZAXPYI(NZ,A,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: A
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZAXPYI_F95
END INTERFACE AXPYI
INTERFACE DOTI
PURE FUNCTION SDOTI_F95(X,INDX,Y)
! Fortran77 call:
! SDOTI(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP) :: SDOTI_F95
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END FUNCTION SDOTI_F95
PURE FUNCTION DDOTI_F95(X,INDX,Y)
! Fortran77 call:
! DDOTI(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP) :: DDOTI_F95
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END FUNCTION DDOTI_F95
END INTERFACE DOTI
INTERFACE DOTCI
PURE FUNCTION CDOTCI_F95(X,INDX,Y)
! Fortran77 call:
! CDOTCI(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP) :: CDOTCI_F95
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION CDOTCI_F95
PURE FUNCTION ZDOTCI_F95(X,INDX,Y)
! Fortran77 call:
! ZDOTCI(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP) :: ZDOTCI_F95
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION ZDOTCI_F95
END INTERFACE DOTCI
INTERFACE DOTUI
PURE FUNCTION CDOTUI_F95(X,INDX,Y)
! Fortran77 call:
! CDOTUI(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP) :: CDOTUI_F95
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION CDOTUI_F95
PURE FUNCTION ZDOTUI_F95(X,INDX,Y)
! Fortran77 call:
! ZDOTUI(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP) :: ZDOTUI_F95
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION ZDOTUI_F95
END INTERFACE DOTUI
INTERFACE GTHR
PURE SUBROUTINE SGTHR_F95(X,INDX,Y)
! Fortran77 call:
! SGTHR(NZ,Y,X,INDX)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SGTHR_F95
PURE SUBROUTINE DGTHR_F95(X,INDX,Y)
! Fortran77 call:
! DGTHR(NZ,Y,X,INDX)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DGTHR_F95
PURE SUBROUTINE CGTHR_F95(X,INDX,Y)
! Fortran77 call:
! CGTHR(NZ,Y,X,INDX)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CGTHR_F95
PURE SUBROUTINE ZGTHR_F95(X,INDX,Y)
! Fortran77 call:
! ZGTHR(NZ,Y,X,INDX)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZGTHR_F95
END INTERFACE GTHR
INTERFACE GTHRZ
PURE SUBROUTINE SGTHRZ_F95(X,INDX,Y)
! Fortran77 call:
! SGTHRZ(NZ,Y,X,INDX)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SGTHRZ_F95
PURE SUBROUTINE DGTHRZ_F95(X,INDX,Y)
! Fortran77 call:
! DGTHRZ(NZ,Y,X,INDX)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DGTHRZ_F95
PURE SUBROUTINE CGTHRZ_F95(X,INDX,Y)
! Fortran77 call:
! CGTHRZ(NZ,Y,X,INDX)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CGTHRZ_F95
PURE SUBROUTINE ZGTHRZ_F95(X,INDX,Y)
! Fortran77 call:
! ZGTHRZ(NZ,Y,X,INDX)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZGTHRZ_F95
END INTERFACE GTHRZ
INTERFACE ROTI
! Default C=1
! Default S=1
PURE SUBROUTINE SROTI_F95(X,INDX,Y,C,S)
! Fortran77 call:
! SROTI(NZ,X,INDX,Y,C,S)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
REAL(WP), INTENT(INOUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SROTI_F95
PURE SUBROUTINE DROTI_F95(X,INDX,Y,C,S)
! Fortran77 call:
! DROTI(NZ,X,INDX,Y,C,S)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
REAL(WP), INTENT(INOUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DROTI_F95
END INTERFACE ROTI
INTERFACE SCTR
PURE SUBROUTINE SSCTR_F95(X,INDX,Y)
! Fortran77 call:
! SSCTR(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(OUT) :: Y(:)
END SUBROUTINE SSCTR_F95
PURE SUBROUTINE DSCTR_F95(X,INDX,Y)
! Fortran77 call:
! DSCTR(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(OUT) :: Y(:)
END SUBROUTINE DSCTR_F95
PURE SUBROUTINE CSCTR_F95(X,INDX,Y)
! Fortran77 call:
! CSCTR(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(OUT) :: Y(:)
END SUBROUTINE CSCTR_F95
PURE SUBROUTINE ZSCTR_F95(X,INDX,Y)
! Fortran77 call:
! ZSCTR(NZ,X,INDX,Y)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(OUT) :: Y(:)
END SUBROUTINE ZSCTR_F95
END INTERFACE SCTR
INTERFACE GEMM3M
! TRANSA='N','C','T'; default: 'N'
! TRANSB='N','C','T'; default: 'N'
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE CGEMM3M_F95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! Fortran77 call:
! CGEMM3M(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CGEMM3M_F95
PURE SUBROUTINE ZGEMM3M_F95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! Fortran77 call:
! ZGEMM3M(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE F95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZGEMM3M_F95
END INTERFACE GEMM3M
INTERFACE AXPBY
! Default ALPHA=1
! Default BETA=1
PURE SUBROUTINE SAXPBY_F95(X,Y,ALPHA,BETA)
! Fortran77 call:
! SAXPBY(N,ALPHA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SAXPBY_F95
PURE SUBROUTINE DAXPBY_F95(X,Y,ALPHA,BETA)
! Fortran77 call:
! DAXPBY(N,ALPHA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DAXPBY_F95
PURE SUBROUTINE CAXPBY_F95(X,Y,ALPHA,BETA)
! Fortran77 call:
! CAXPBY(N,ALPHA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CAXPBY_F95
PURE SUBROUTINE ZAXPBY_F95(X,Y,ALPHA,BETA)
! Fortran77 call:
! ZAXPBY(N,ALPHA,X,INCX,BETA,Y,INCY)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZAXPBY_F95
END INTERFACE AXPBY
INTERFACE GEM2V
! Default ALPHA=1
! Default BETA=0
PURE SUBROUTINE SGEM2VU_F95(A,X1,X2,Y1,Y2,ALPHA,BETA)
! Fortran77 call:
! SGEM2VU(M,N,ALPHA,A,LDA,X1,INCX1,X2,INCX2,BETA,Y1,INCY1,Y2,
! INCY2)
USE F95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X1(:)
REAL(WP), INTENT(IN) :: X2(:)
REAL(WP), INTENT(INOUT) :: Y1(:)
REAL(WP), INTENT(INOUT) :: Y2(:)
END SUBROUTINE SGEM2VU_F95
PURE SUBROUTINE DGEM2VU_F95(A,X1,X2,Y1,Y2,ALPHA,BETA)
! Fortran77 call:
! DGEM2VU(M,N,ALPHA,A,LDA,X1,INCX1,X2,INCX2,BETA,Y1,INCY1,Y2,
! INCY2)
USE F95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X1(:)
REAL(WP), INTENT(IN) :: X2(:)
REAL(WP), INTENT(INOUT) :: Y1(:)
REAL(WP), INTENT(INOUT) :: Y2(:)
END SUBROUTINE DGEM2VU_F95
PURE SUBROUTINE CGEM2VC_F95(A,X1,X2,Y1,Y2,ALPHA,BETA)
! Fortran77 call:
! CGEM2VC(M,N,ALPHA,A,LDA,X1,INCX1,X2,INCX2,BETA,Y1,INCY1,Y2,
! INCY2)
USE F95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X1(:)
COMPLEX(WP), INTENT(IN) :: X2(:)
COMPLEX(WP), INTENT(INOUT) :: Y1(:)
COMPLEX(WP), INTENT(INOUT) :: Y2(:)
END SUBROUTINE CGEM2VC_F95
PURE SUBROUTINE ZGEM2VC_F95(A,X1,X2,Y1,Y2,ALPHA,BETA)
! Fortran77 call:
! ZGEM2VC(M,N,ALPHA,A,LDA,X1,INCX1,X2,INCX2,BETA,Y1,INCY1,Y2,
! INCY2)
USE F95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X1(:)
COMPLEX(WP), INTENT(IN) :: X2(:)
COMPLEX(WP), INTENT(INOUT) :: Y1(:)
COMPLEX(WP), INTENT(INOUT) :: Y2(:)
END SUBROUTINE ZGEM2VC_F95
END INTERFACE GEM2V
END MODULE BLAS95
MODULE MKL95_PRECISION
INTEGER, PARAMETER :: SP = KIND(1.0E0)
INTEGER, PARAMETER :: DP = KIND(1.0D0)
END MODULE MKL95_PRECISION
MODULE MKL95_BLAS
INTERFACE ASUM
PURE FUNCTION SASUM_MKL95(X)
! MKL Fortran77 call:
! SASUM(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP) :: SASUM_MKL95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION SASUM_MKL95
PURE FUNCTION SCASUM_MKL95(X)
! MKL Fortran77 call:
! SCASUM(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP) :: SCASUM_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION SCASUM_MKL95
PURE FUNCTION DASUM_MKL95(X)
! MKL Fortran77 call:
! DASUM(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP) :: DASUM_MKL95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION DASUM_MKL95
PURE FUNCTION DZASUM_MKL95(X)
! MKL Fortran77 call:
! DZASUM(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP) :: DZASUM_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION DZASUM_MKL95
END INTERFACE ASUM
INTERFACE AXPY
PURE SUBROUTINE SAXPY_MKL95(X,Y,A)
! MKL Fortran77 call:
! SAXPY(N,A,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: A
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SAXPY_MKL95
PURE SUBROUTINE DAXPY_MKL95(X,Y,A)
! MKL Fortran77 call:
! DAXPY(N,A,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: A
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DAXPY_MKL95
PURE SUBROUTINE CAXPY_MKL95(X,Y,A)
! MKL Fortran77 call:
! CAXPY(N,A,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: A
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CAXPY_MKL95
PURE SUBROUTINE ZAXPY_MKL95(X,Y,A)
! MKL Fortran77 call:
! ZAXPY(N,A,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: A
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZAXPY_MKL95
END INTERFACE AXPY
INTERFACE COPY
PURE SUBROUTINE SCOPY_MKL95(X,Y)
! MKL Fortran77 call:
! SCOPY(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SCOPY_MKL95
PURE SUBROUTINE DCOPY_MKL95(X,Y)
! MKL Fortran77 call:
! DCOPY(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DCOPY_MKL95
PURE SUBROUTINE CCOPY_MKL95(X,Y)
! MKL Fortran77 call:
! CCOPY(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CCOPY_MKL95
PURE SUBROUTINE ZCOPY_MKL95(X,Y)
! MKL Fortran77 call:
! ZCOPY(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZCOPY_MKL95
END INTERFACE COPY
INTERFACE DOT
PURE FUNCTION SDOT_MKL95(X,Y)
! MKL Fortran77 call:
! SDOT(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP) :: SDOT_MKL95
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END FUNCTION SDOT_MKL95
PURE FUNCTION DDOT_MKL95(X,Y)
! MKL Fortran77 call:
! DDOT(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP) :: DDOT_MKL95
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END FUNCTION DDOT_MKL95
END INTERFACE DOT
INTERFACE SDOT
PURE FUNCTION SDSDOT_MKL95(SX,SY,SB)
! MKL Fortran77 call:
! SDSDOT(N,SB,SX,INCX,SY,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP) :: SDSDOT_MKL95
REAL(WP), INTENT(IN) :: SB
REAL(WP), INTENT(IN) :: SX(:)
REAL(WP), INTENT(IN) :: SY(:)
END FUNCTION SDSDOT_MKL95
PURE FUNCTION DSDOT_MKL95(SX,SY)
! MKL Fortran77 call:
! DSDOT(N,SX,INCX,SY,INCY)
USE MKL95_PRECISION, ONLY: WP => DP, SP
REAL(WP) :: DSDOT_MKL95
REAL(SP), INTENT(IN) :: SX(:)
REAL(SP), INTENT(IN) :: SY(:)
END FUNCTION DSDOT_MKL95
END INTERFACE SDOT
INTERFACE DOTC
PURE FUNCTION CDOTC_MKL95(X,Y)
! MKL Fortran77 call:
! CDOTC(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP) :: CDOTC_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION CDOTC_MKL95
PURE FUNCTION ZDOTC_MKL95(X,Y)
! MKL Fortran77 call:
! ZDOTC(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP) :: ZDOTC_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION ZDOTC_MKL95
END INTERFACE DOTC
INTERFACE DOTU
PURE FUNCTION CDOTU_MKL95(X,Y)
! MKL Fortran77 call:
! CDOTU(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP) :: CDOTU_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION CDOTU_MKL95
PURE FUNCTION ZDOTU_MKL95(X,Y)
! MKL Fortran77 call:
! ZDOTU(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP) :: ZDOTU_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION ZDOTU_MKL95
END INTERFACE DOTU
INTERFACE NRM2
PURE FUNCTION SNRM2_MKL95(X)
! MKL Fortran77 call:
! SNRM2(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP) :: SNRM2_MKL95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION SNRM2_MKL95
PURE FUNCTION DNRM2_MKL95(X)
! MKL Fortran77 call:
! DNRM2(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP) :: DNRM2_MKL95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION DNRM2_MKL95
PURE FUNCTION SCNRM2_MKL95(X)
! MKL Fortran77 call:
! SCNRM2(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP) :: SCNRM2_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION SCNRM2_MKL95
PURE FUNCTION DZNRM2_MKL95(X)
! MKL Fortran77 call:
! DZNRM2(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP) :: DZNRM2_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION DZNRM2_MKL95
END INTERFACE NRM2
INTERFACE ROT
PURE SUBROUTINE SROT_MKL95(X,Y,C,S)
! MKL Fortran77 call:
! SROT(N,X,INCX,Y,INCY,C,S)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SROT_MKL95
PURE SUBROUTINE DROT_MKL95(X,Y,C,S)
! MKL Fortran77 call:
! DROT(N,X,INCX,Y,INCY,C,S)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DROT_MKL95
PURE SUBROUTINE CSROT_MKL95(X,Y,C,S)
! MKL Fortran77 call:
! CSROT(N,X,INCX,Y,INCY,C,S)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
COMPLEX(WP), INTENT(INOUT) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CSROT_MKL95
PURE SUBROUTINE ZDROT_MKL95(X,Y,C,S)
! MKL Fortran77 call:
! ZDROT(N,X,INCX,Y,INCY,C,S)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
COMPLEX(WP), INTENT(INOUT) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZDROT_MKL95
END INTERFACE ROT
INTERFACE ROTG
PURE SUBROUTINE SROTG(A,B,C,S)
! MKL Fortran77 call:
! SROTG(A,B,C,S)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(INOUT) :: A
REAL(WP), INTENT(INOUT) :: B
REAL(WP), INTENT(OUT) :: C
REAL(WP), INTENT(OUT) :: S
END SUBROUTINE SROTG
PURE SUBROUTINE DROTG(A,B,C,S)
! MKL Fortran77 call:
! DROTG(A,B,C,S)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(INOUT) :: A
REAL(WP), INTENT(INOUT) :: B
REAL(WP), INTENT(OUT) :: C
REAL(WP), INTENT(OUT) :: S
END SUBROUTINE DROTG
PURE SUBROUTINE CROTG(A,B,C,S)
! MKL Fortran77 call:
! CROTG(A,B,C,S)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(INOUT) :: A
COMPLEX(WP), INTENT(INOUT) :: B
REAL(WP), INTENT(OUT) :: C
COMPLEX(WP), INTENT(OUT) :: S
END SUBROUTINE CROTG
PURE SUBROUTINE ZROTG(A,B,C,S)
! MKL Fortran77 call:
! ZROTG(A,B,C,S)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(INOUT) :: A
COMPLEX(WP), INTENT(INOUT) :: B
REAL(WP), INTENT(OUT) :: C
COMPLEX(WP), INTENT(OUT) :: S
END SUBROUTINE ZROTG
END INTERFACE ROTG
INTERFACE ROTM
PURE SUBROUTINE SROTM_MKL95(X,Y,PARAM)
! MKL Fortran77 call:
! SROTM(N,X,INCX,Y,INCY,PARAM)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
REAL(WP), INTENT(IN) :: PARAM(5)
END SUBROUTINE SROTM_MKL95
PURE SUBROUTINE DROTM_MKL95(X,Y,PARAM)
! MKL Fortran77 call:
! DROTM(N,X,INCX,Y,INCY,PARAM)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
REAL(WP), INTENT(IN) :: PARAM(5)
END SUBROUTINE DROTM_MKL95
END INTERFACE ROTM
INTERFACE ROTMG
PURE SUBROUTINE SROTMG_MKL95(D1,D2,X1,Y1,PARAM)
! MKL Fortran77 call:
! SROTMG(D1,D2,X1,Y1,PARAM)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(INOUT) :: D1
REAL(WP), INTENT(INOUT) :: D2
REAL(WP), INTENT(INOUT) :: X1
REAL(WP), INTENT(IN) :: Y1
REAL(WP), INTENT(OUT) :: PARAM(5)
END SUBROUTINE SROTMG_MKL95
PURE SUBROUTINE DROTMG_MKL95(D1,D2,X1,Y1,PARAM)
! MKL Fortran77 call:
! DROTMG(D1,D2,X1,Y1,PARAM)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(INOUT) :: D1
REAL(WP), INTENT(INOUT) :: D2
REAL(WP), INTENT(INOUT) :: X1
REAL(WP), INTENT(IN) :: Y1
REAL(WP), INTENT(OUT) :: PARAM(5)
END SUBROUTINE DROTMG_MKL95
END INTERFACE ROTMG
INTERFACE SCAL
PURE SUBROUTINE SSCAL_MKL95(X,A)
! MKL Fortran77 call:
! SSCAL(N,A,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: A
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE SSCAL_MKL95
PURE SUBROUTINE DSCAL_MKL95(X,A)
! MKL Fortran77 call:
! DSCAL(N,A,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: A
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DSCAL_MKL95
PURE SUBROUTINE CSCAL_MKL95(X,A)
! MKL Fortran77 call:
! CSCAL(N,A,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN) :: A
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CSCAL_MKL95
PURE SUBROUTINE ZSCAL_MKL95(X,A)
! MKL Fortran77 call:
! ZSCAL(N,A,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN) :: A
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZSCAL_MKL95
PURE SUBROUTINE CSSCAL_MKL95(X,A)
! MKL Fortran77 call:
! CSSCAL(N,A,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: A
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CSSCAL_MKL95
PURE SUBROUTINE ZDSCAL_MKL95(X,A)
! MKL Fortran77 call:
! ZDSCAL(N,A,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: A
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZDSCAL_MKL95
END INTERFACE SCAL
INTERFACE SWAP
PURE SUBROUTINE SSWAP_MKL95(X,Y)
! MKL Fortran77 call:
! SSWAP(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SSWAP_MKL95
PURE SUBROUTINE DSWAP_MKL95(X,Y)
! MKL Fortran77 call:
! DSWAP(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(INOUT) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DSWAP_MKL95
PURE SUBROUTINE CSWAP_MKL95(X,Y)
! MKL Fortran77 call:
! CSWAP(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(INOUT) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CSWAP_MKL95
PURE SUBROUTINE ZSWAP_MKL95(X,Y)
! MKL Fortran77 call:
! ZSWAP(N,X,INCX,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(INOUT) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZSWAP_MKL95
END INTERFACE SWAP
INTERFACE IAMAX
PURE FUNCTION ISAMAX_MKL95(X)
! MKL Fortran77 call:
! ISAMAX(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
INTEGER :: ISAMAX_MKL95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION ISAMAX_MKL95
PURE FUNCTION IDAMAX_MKL95(X)
! MKL Fortran77 call:
! IDAMAX(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
INTEGER :: IDAMAX_MKL95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION IDAMAX_MKL95
PURE FUNCTION ICAMAX_MKL95(X)
! MKL Fortran77 call:
! ICAMAX(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
INTEGER :: ICAMAX_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION ICAMAX_MKL95
PURE FUNCTION IZAMAX_MKL95(X)
! MKL Fortran77 call:
! IZAMAX(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
INTEGER :: IZAMAX_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION IZAMAX_MKL95
END INTERFACE IAMAX
INTERFACE IAMIN
PURE FUNCTION ISAMIN_MKL95(X)
! MKL Fortran77 call:
! ISAMIN(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
INTEGER :: ISAMIN_MKL95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION ISAMIN_MKL95
PURE FUNCTION IDAMIN_MKL95(X)
! MKL Fortran77 call:
! IDAMIN(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
INTEGER :: IDAMIN_MKL95
REAL(WP), INTENT(IN) :: X(:)
END FUNCTION IDAMIN_MKL95
PURE FUNCTION ICAMIN_MKL95(X)
! MKL Fortran77 call:
! ICAMIN(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
INTEGER :: ICAMIN_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION ICAMIN_MKL95
PURE FUNCTION IZAMIN_MKL95(X)
! MKL Fortran77 call:
! IZAMIN(N,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
INTEGER :: IZAMIN_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
END FUNCTION IZAMIN_MKL95
END INTERFACE IAMIN
INTERFACE DCABS1
PURE FUNCTION DCABS1(Z)
! MKL Fortran77 call:
! DCABS1(Z)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP) :: DCABS1
COMPLEX(WP), INTENT(IN) :: Z
END FUNCTION DCABS1
END INTERFACE DCABS1
INTERFACE GBMV
PURE SUBROUTINE SGBMV_MKL95(A,X,Y,KL,M,ALPHA,BETA,TRANS)
! MKL Fortran77 call:
! SGBMV(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
INTEGER, INTENT(IN), OPTIONAL :: KL
INTEGER, INTENT(IN), OPTIONAL :: M
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SGBMV_MKL95
PURE SUBROUTINE DGBMV_MKL95(A,X,Y,KL,M,ALPHA,BETA,TRANS)
! MKL Fortran77 call:
! DGBMV(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
INTEGER, INTENT(IN), OPTIONAL :: KL
INTEGER, INTENT(IN), OPTIONAL :: M
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DGBMV_MKL95
PURE SUBROUTINE CGBMV_MKL95(A,X,Y,KL,M,ALPHA,BETA,TRANS)
! MKL Fortran77 call:
! CGBMV(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
INTEGER, INTENT(IN), OPTIONAL :: KL
INTEGER, INTENT(IN), OPTIONAL :: M
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CGBMV_MKL95
PURE SUBROUTINE ZGBMV_MKL95(A,X,Y,KL,M,ALPHA,BETA,TRANS)
! MKL Fortran77 call:
! ZGBMV(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
INTEGER, INTENT(IN), OPTIONAL :: KL
INTEGER, INTENT(IN), OPTIONAL :: M
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZGBMV_MKL95
END INTERFACE GBMV
INTERFACE GEMV
PURE SUBROUTINE SGEMV_MKL95(A,X,Y,ALPHA,BETA,TRANS)
! MKL Fortran77 call:
! SGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SGEMV_MKL95
PURE SUBROUTINE DGEMV_MKL95(A,X,Y,ALPHA,BETA,TRANS)
! MKL Fortran77 call:
! DGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DGEMV_MKL95
PURE SUBROUTINE CGEMV_MKL95(A,X,Y,ALPHA,BETA,TRANS)
! MKL Fortran77 call:
! CGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CGEMV_MKL95
PURE SUBROUTINE ZGEMV_MKL95(A,X,Y,ALPHA,BETA,TRANS)
! MKL Fortran77 call:
! ZGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZGEMV_MKL95
END INTERFACE GEMV
INTERFACE GER
PURE SUBROUTINE SGER_MKL95(A,X,Y,ALPHA)
! MKL Fortran77 call:
! SGER(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SGER_MKL95
PURE SUBROUTINE DGER_MKL95(A,X,Y,ALPHA)
! MKL Fortran77 call:
! DGER(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DGER_MKL95
END INTERFACE GER
INTERFACE GERC
PURE SUBROUTINE CGERC_MKL95(A,X,Y,ALPHA)
! MKL Fortran77 call:
! CGERC(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CGERC_MKL95
PURE SUBROUTINE ZGERC_MKL95(A,X,Y,ALPHA)
! MKL Fortran77 call:
! ZGERC(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZGERC_MKL95
END INTERFACE GERC
INTERFACE GERU
PURE SUBROUTINE CGERU_MKL95(A,X,Y,ALPHA)
! MKL Fortran77 call:
! CGERU(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CGERU_MKL95
PURE SUBROUTINE ZGERU_MKL95(A,X,Y,ALPHA)
! MKL Fortran77 call:
! ZGERU(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZGERU_MKL95
END INTERFACE GERU
INTERFACE HBMV
PURE SUBROUTINE CHBMV_MKL95(A,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! CHBMV(UPLO,N,K,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CHBMV_MKL95
PURE SUBROUTINE ZHBMV_MKL95(A,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! ZHBMV(UPLO,N,K,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZHBMV_MKL95
END INTERFACE HBMV
INTERFACE HEMV
PURE SUBROUTINE CHEMV_MKL95(A,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! CHEMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CHEMV_MKL95
PURE SUBROUTINE ZHEMV_MKL95(A,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! ZHEMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZHEMV_MKL95
END INTERFACE HEMV
INTERFACE HER
PURE SUBROUTINE CHER_MKL95(A,X,UPLO,ALPHA)
! MKL Fortran77 call:
! CHER(UPLO,N,ALPHA,X,INCX,A,LDA)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
END SUBROUTINE CHER_MKL95
PURE SUBROUTINE ZHER_MKL95(A,X,UPLO,ALPHA)
! MKL Fortran77 call:
! ZHER(UPLO,N,ALPHA,X,INCX,A,LDA)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
END SUBROUTINE ZHER_MKL95
END INTERFACE HER
INTERFACE HER2
PURE SUBROUTINE CHER2_MKL95(A,X,Y,UPLO,ALPHA)
! MKL Fortran77 call:
! CHER2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CHER2_MKL95
PURE SUBROUTINE ZHER2_MKL95(A,X,Y,UPLO,ALPHA)
! MKL Fortran77 call:
! ZHER2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZHER2_MKL95
END INTERFACE HER2
INTERFACE HPMV
PURE SUBROUTINE CHPMV_MKL95(AP,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! CHPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CHPMV_MKL95
PURE SUBROUTINE ZHPMV_MKL95(AP,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! ZHPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZHPMV_MKL95
END INTERFACE HPMV
INTERFACE HPR
PURE SUBROUTINE CHPR_MKL95(AP,X,UPLO,ALPHA)
! MKL Fortran77 call:
! CHPR(UPLO,N,ALPHA,X,INCX,AP)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
END SUBROUTINE CHPR_MKL95
PURE SUBROUTINE ZHPR_MKL95(AP,X,UPLO,ALPHA)
! MKL Fortran77 call:
! ZHPR(UPLO,N,ALPHA,X,INCX,AP)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
END SUBROUTINE ZHPR_MKL95
END INTERFACE HPR
INTERFACE HPR2
PURE SUBROUTINE CHPR2_MKL95(AP,X,Y,UPLO,ALPHA)
! MKL Fortran77 call:
! CHPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CHPR2_MKL95
PURE SUBROUTINE ZHPR2_MKL95(AP,X,Y,UPLO,ALPHA)
! MKL Fortran77 call:
! ZHPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(INOUT) :: AP(:)
COMPLEX(WP), INTENT(IN) :: X(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZHPR2_MKL95
END INTERFACE HPR2
INTERFACE SBMV
PURE SUBROUTINE SSBMV_MKL95(A,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! SSBMV(UPLO,N,K,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SSBMV_MKL95
PURE SUBROUTINE DSBMV_MKL95(A,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! DSBMV(UPLO,N,K,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DSBMV_MKL95
END INTERFACE SBMV
INTERFACE SPMV
PURE SUBROUTINE SSPMV_MKL95(AP,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! SSPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SSPMV_MKL95
PURE SUBROUTINE DSPMV_MKL95(AP,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! DSPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DSPMV_MKL95
END INTERFACE SPMV
INTERFACE SPR
PURE SUBROUTINE SSPR_MKL95(AP,X,UPLO,ALPHA)
! MKL Fortran77 call:
! SSPR(UPLO,N,ALPHA,X,INCX,AP)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
END SUBROUTINE SSPR_MKL95
PURE SUBROUTINE DSPR_MKL95(AP,X,UPLO,ALPHA)
! MKL Fortran77 call:
! DSPR(UPLO,N,ALPHA,X,INCX,AP)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
END SUBROUTINE DSPR_MKL95
END INTERFACE SPR
INTERFACE SPR2
PURE SUBROUTINE SSPR2_MKL95(AP,X,Y,UPLO,ALPHA)
! MKL Fortran77 call:
! SSPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SSPR2_MKL95
PURE SUBROUTINE DSPR2_MKL95(AP,X,Y,UPLO,ALPHA)
! MKL Fortran77 call:
! DSPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: AP(:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DSPR2_MKL95
END INTERFACE SPR2
INTERFACE SYMV
PURE SUBROUTINE SSYMV_MKL95(A,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! SSYMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SSYMV_MKL95
PURE SUBROUTINE DSYMV_MKL95(A,X,Y,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! DSYMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DSYMV_MKL95
END INTERFACE SYMV
INTERFACE SYR
PURE SUBROUTINE SSYR_MKL95(A,X,UPLO,ALPHA)
! MKL Fortran77 call:
! SSYR(UPLO,N,ALPHA,X,INCX,A,LDA)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
END SUBROUTINE SSYR_MKL95
PURE SUBROUTINE DSYR_MKL95(A,X,UPLO,ALPHA)
! MKL Fortran77 call:
! DSYR(UPLO,N,ALPHA,X,INCX,A,LDA)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
END SUBROUTINE DSYR_MKL95
END INTERFACE SYR
INTERFACE SYR2
PURE SUBROUTINE SSYR2_MKL95(A,X,Y,UPLO,ALPHA)
! MKL Fortran77 call:
! SSYR2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SSYR2_MKL95
PURE SUBROUTINE DSYR2_MKL95(A,X,Y,UPLO,ALPHA)
! MKL Fortran77 call:
! DSYR2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(INOUT) :: A(:,:)
REAL(WP), INTENT(IN) :: X(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DSYR2_MKL95
END INTERFACE SYR2
INTERFACE TBMV
PURE SUBROUTINE STBMV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! STBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STBMV_MKL95
PURE SUBROUTINE DTBMV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! DTBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTBMV_MKL95
PURE SUBROUTINE CTBMV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! CTBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTBMV_MKL95
PURE SUBROUTINE ZTBMV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! ZTBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTBMV_MKL95
END INTERFACE TBMV
INTERFACE TBSV
PURE SUBROUTINE STBSV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! STBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STBSV_MKL95
PURE SUBROUTINE DTBSV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! DTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTBSV_MKL95
PURE SUBROUTINE CTBSV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! CTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTBSV_MKL95
PURE SUBROUTINE ZTBSV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! ZTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTBSV_MKL95
END INTERFACE TBSV
INTERFACE TPMV
PURE SUBROUTINE STPMV_MKL95(AP,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! STPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STPMV_MKL95
PURE SUBROUTINE DTPMV_MKL95(AP,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! DTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTPMV_MKL95
PURE SUBROUTINE CTPMV_MKL95(AP,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! CTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTPMV_MKL95
PURE SUBROUTINE ZTPMV_MKL95(AP,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! ZTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTPMV_MKL95
END INTERFACE TPMV
INTERFACE TPSV
PURE SUBROUTINE STPSV_MKL95(AP,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! STPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STPSV_MKL95
PURE SUBROUTINE DTPSV_MKL95(AP,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! DTPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: AP(:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTPSV_MKL95
PURE SUBROUTINE CTPSV_MKL95(AP,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! CTPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTPSV_MKL95
PURE SUBROUTINE ZTPSV_MKL95(AP,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! ZTPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: AP(:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTPSV_MKL95
END INTERFACE TPSV
INTERFACE TRMV
PURE SUBROUTINE STRMV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! STRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STRMV_MKL95
PURE SUBROUTINE DTRMV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! DTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTRMV_MKL95
PURE SUBROUTINE CTRMV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! CTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTRMV_MKL95
PURE SUBROUTINE ZTRMV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! ZTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTRMV_MKL95
END INTERFACE TRMV
INTERFACE TRSV
PURE SUBROUTINE STRSV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! STRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE STRSV_MKL95
PURE SUBROUTINE DTRSV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! DTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE DTRSV_MKL95
PURE SUBROUTINE CTRSV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! CTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE CTRSV_MKL95
PURE SUBROUTINE ZTRSV_MKL95(A,X,UPLO,TRANS,DIAG)
! MKL Fortran77 call:
! ZTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: X(:)
END SUBROUTINE ZTRSV_MKL95
END INTERFACE TRSV
INTERFACE GEMM
PURE SUBROUTINE SGEMM_MKL95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! MKL Fortran77 call:
! SGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE SGEMM_MKL95
PURE SUBROUTINE DGEMM_MKL95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! MKL Fortran77 call:
! DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE DGEMM_MKL95
PURE SUBROUTINE CGEMM_MKL95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! MKL Fortran77 call:
! CGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CGEMM_MKL95
PURE SUBROUTINE ZGEMM_MKL95(A,B,C,TRANSA,TRANSB,ALPHA,BETA)
! MKL Fortran77 call:
! ZGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSB
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZGEMM_MKL95
END INTERFACE GEMM
INTERFACE HEMM
PURE SUBROUTINE CHEMM_MKL95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! CHEMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CHEMM_MKL95
PURE SUBROUTINE ZHEMM_MKL95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! ZHEMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZHEMM_MKL95
END INTERFACE HEMM
INTERFACE HERK
PURE SUBROUTINE CHERK_MKL95(A,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! CHERK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CHERK_MKL95
PURE SUBROUTINE ZHERK_MKL95(A,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! ZHERK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZHERK_MKL95
END INTERFACE HERK
INTERFACE HER2K
PURE SUBROUTINE CHER2K_MKL95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! CHER2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CHER2K_MKL95
PURE SUBROUTINE ZHER2K_MKL95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! ZHER2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZHER2K_MKL95
END INTERFACE HER2K
INTERFACE SYMM
PURE SUBROUTINE SSYMM_MKL95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! SSYMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE SSYMM_MKL95
PURE SUBROUTINE DSYMM_MKL95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! DSYMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE DSYMM_MKL95
PURE SUBROUTINE CSYMM_MKL95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! CSYMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CSYMM_MKL95
PURE SUBROUTINE ZSYMM_MKL95(A,B,C,SIDE,UPLO,ALPHA,BETA)
! MKL Fortran77 call:
! ZSYMM(SIDE,UPLO,M,N,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZSYMM_MKL95
END INTERFACE SYMM
INTERFACE SYRK
PURE SUBROUTINE SSYRK_MKL95(A,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! SSYRK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE SSYRK_MKL95
PURE SUBROUTINE DSYRK_MKL95(A,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! DSYRK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE DSYRK_MKL95
PURE SUBROUTINE CSYRK_MKL95(A,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! CSYRK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CSYRK_MKL95
PURE SUBROUTINE ZSYRK_MKL95(A,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! ZSYRK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZSYRK_MKL95
END INTERFACE SYRK
INTERFACE SYR2K
PURE SUBROUTINE SSYR2K_MKL95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! SSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE SSYR2K_MKL95
PURE SUBROUTINE DSYR2K_MKL95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! DSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN), OPTIONAL :: BETA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(IN) :: B(:,:)
REAL(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE DSYR2K_MKL95
PURE SUBROUTINE CSYR2K_MKL95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! CSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE CSYR2K_MKL95
PURE SUBROUTINE ZSYR2K_MKL95(A,B,C,UPLO,TRANS,ALPHA,BETA)
! MKL Fortran77 call:
! ZSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN), OPTIONAL :: BETA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(IN) :: B(:,:)
COMPLEX(WP), INTENT(INOUT) :: C(:,:)
END SUBROUTINE ZSYR2K_MKL95
END INTERFACE SYR2K
INTERFACE TRMM
PURE SUBROUTINE STRMM_MKL95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! MKL Fortran77 call:
! STRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE STRMM_MKL95
PURE SUBROUTINE DTRMM_MKL95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! MKL Fortran77 call:
! DTRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE DTRMM_MKL95
PURE SUBROUTINE CTRMM_MKL95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! MKL Fortran77 call:
! CTRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE CTRMM_MKL95
PURE SUBROUTINE ZTRMM_MKL95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! MKL Fortran77 call:
! ZTRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE ZTRMM_MKL95
END INTERFACE TRMM
INTERFACE TRSM
PURE SUBROUTINE STRSM_MKL95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! MKL Fortran77 call:
! STRSM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE STRSM_MKL95
PURE SUBROUTINE DTRSM_MKL95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! MKL Fortran77 call:
! DTRSM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
REAL(WP), INTENT(IN), OPTIONAL :: ALPHA
REAL(WP), INTENT(IN) :: A(:,:)
REAL(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE DTRSM_MKL95
PURE SUBROUTINE CTRSM_MKL95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! MKL Fortran77 call:
! CTRSM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE MKL95_PRECISION, ONLY: WP => SP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE CTRSM_MKL95
PURE SUBROUTINE ZTRSM_MKL95(A,B,SIDE,UPLO,TRANSA,DIAG,ALPHA)
! MKL Fortran77 call:
! ZTRSM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
USE MKL95_PRECISION, ONLY: WP => DP
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: SIDE
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: UPLO
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANSA
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: DIAG
COMPLEX(WP), INTENT(IN), OPTIONAL :: ALPHA
COMPLEX(WP), INTENT(IN) :: A(:,:)
COMPLEX(WP), INTENT(INOUT) :: B(:,:)
END SUBROUTINE ZTRSM_MKL95
END INTERFACE TRSM
INTERFACE AXPYI
PURE SUBROUTINE SAXPYI_MKL95(X,INDX,Y,A)
! MKL Fortran77 call:
! SAXPYI(NZ,A,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN), OPTIONAL :: A
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SAXPYI_MKL95
PURE SUBROUTINE DAXPYI_MKL95(X,INDX,Y,A)
! MKL Fortran77 call:
! DAXPYI(NZ,A,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN), OPTIONAL :: A
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DAXPYI_MKL95
PURE SUBROUTINE CAXPYI_MKL95(X,INDX,Y,A)
! MKL Fortran77 call:
! CAXPYI(NZ,A,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN), OPTIONAL :: A
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CAXPYI_MKL95
PURE SUBROUTINE ZAXPYI_MKL95(X,INDX,Y,A)
! MKL Fortran77 call:
! ZAXPYI(NZ,A,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN), OPTIONAL :: A
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZAXPYI_MKL95
END INTERFACE AXPYI
INTERFACE DOTI
PURE FUNCTION SDOTI_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! SDOTI(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP) :: SDOTI_MKL95
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END FUNCTION SDOTI_MKL95
PURE FUNCTION DDOTI_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! DDOTI(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP) :: DDOTI_MKL95
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END FUNCTION DDOTI_MKL95
END INTERFACE DOTI
INTERFACE DOTCI
PURE FUNCTION CDOTCI_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! CDOTCI(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP) :: CDOTCI_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION CDOTCI_MKL95
PURE FUNCTION ZDOTCI_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! ZDOTCI(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP) :: ZDOTCI_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION ZDOTCI_MKL95
END INTERFACE DOTCI
INTERFACE DOTUI
PURE FUNCTION CDOTUI_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! CDOTUI(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP) :: CDOTUI_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION CDOTUI_MKL95
PURE FUNCTION ZDOTUI_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! ZDOTUI(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP) :: ZDOTUI_MKL95
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END FUNCTION ZDOTUI_MKL95
END INTERFACE DOTUI
INTERFACE GTHR
PURE SUBROUTINE SGTHR_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! SGTHR(NZ,Y,X,INDX)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SGTHR_MKL95
PURE SUBROUTINE DGTHR_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! DGTHR(NZ,Y,X,INDX)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DGTHR_MKL95
PURE SUBROUTINE CGTHR_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! CGTHR(NZ,Y,X,INDX)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE CGTHR_MKL95
PURE SUBROUTINE ZGTHR_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! ZGTHR(NZ,Y,X,INDX)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(IN) :: Y(:)
END SUBROUTINE ZGTHR_MKL95
END INTERFACE GTHR
INTERFACE GTHRZ
PURE SUBROUTINE SGTHRZ_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! SGTHRZ(NZ,Y,X,INDX)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE SGTHRZ_MKL95
PURE SUBROUTINE DGTHRZ_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! DGTHRZ(NZ,Y,X,INDX)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE DGTHRZ_MKL95
PURE SUBROUTINE CGTHRZ_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! CGTHRZ(NZ,Y,X,INDX)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE CGTHRZ_MKL95
PURE SUBROUTINE ZGTHRZ_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! ZGTHRZ(NZ,Y,X,INDX)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(OUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(INOUT) :: Y(:)
END SUBROUTINE ZGTHRZ_MKL95
END INTERFACE GTHRZ
INTERFACE ROTI
PURE SUBROUTINE SROTI_MKL95(X,INDX,Y,C,S)
! MKL Fortran77 call:
! SROTI(NZ,X,INDX,Y,C,S)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
REAL(WP), INTENT(INOUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE SROTI_MKL95
PURE SUBROUTINE DROTI_MKL95(X,INDX,Y,C,S)
! MKL Fortran77 call:
! DROTI(NZ,X,INDX,Y,C,S)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: C
REAL(WP), INTENT(IN) :: S
REAL(WP), INTENT(INOUT) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(IN) :: Y(:)
END SUBROUTINE DROTI_MKL95
END INTERFACE ROTI
INTERFACE SCTR
PURE SUBROUTINE SSCTR_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! SSCTR(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => SP
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(OUT) :: Y(:)
END SUBROUTINE SSCTR_MKL95
PURE SUBROUTINE DSCTR_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! DSCTR(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => DP
REAL(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
REAL(WP), INTENT(OUT) :: Y(:)
END SUBROUTINE DSCTR_MKL95
PURE SUBROUTINE CSCTR_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! CSCTR(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => SP
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(OUT) :: Y(:)
END SUBROUTINE CSCTR_MKL95
PURE SUBROUTINE ZSCTR_MKL95(X,INDX,Y)
! MKL Fortran77 call:
! ZSCTR(NZ,X,INDX,Y)
USE MKL95_PRECISION, ONLY: WP => DP
COMPLEX(WP), INTENT(IN) :: X(:)
INTEGER, INTENT(IN) :: INDX(:)
COMPLEX(WP), INTENT(OUT) :: Y(:)
END SUBROUTINE ZSCTR_MKL95
END INTERFACE SCTR
END MODULE MKL95_BLAS
| mit |
intervigilium/cs259-or32-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 |
Hellybean/SaberMod_ROM_Toolchain | libgfortran/generated/_aimag_c16.F90 | 26 | 1466 | ! Copyright (C) 2002-2013 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_COMPLEX_16)
elemental function _gfortran_specific__aimag_c16 (parm)
complex (kind=16), intent (in) :: parm
real (kind=16) :: _gfortran_specific__aimag_c16
_gfortran_specific__aimag_c16 = aimag (parm)
end function
#endif
| gpl-2.0 |
ganzenmg/lammps_current | tools/ch2lmp/other/mkpdb.f | 60 | 11604 | c -------------------------------------------------------------------------
c Code converts LAMMPS output to .pdb files
c Overlays coordinates from LAMMPS output onto template pdb
c Assumes atom order is the same between the two
c Converts from atom-based pbc to residue-based pbc
c Also assumes starting config fed to LAMMPS had residue-based pbc
c Paul Crozier, SNL, 2002
c -------------------------------------------------------------------------
module global
real*8 xprd,yprd,zprd,box(2,3)
real*8, allocatable :: x(:,:),q(:),mass(:)
real*8, allocatable :: comx(:),comy(:),comz(:),totmass(:)
integer ntimestep,natoms,nframes,iframe,nper
integer nbonds,nangles,ndihedrals,nimpropers,ntypes
integer nbondtypes,nangletypes,ndihedtypes,nimprotypes
integer nconfig,nconfig_skip,nskip,nframes_between_pdbs
integer nmolecules,nprotein_residues
integer, allocatable :: mytrue(:,:),type(:),molecule(:)
integer, allocatable :: nboxx(:),nboxy(:),nboxz(:)
character*200 data_file_path,config_file_path,pdb_file_path
character*200 compare_file_path
character*76, allocatable :: outbeg(:),outend(:)
end module
c -------------------------------------------------------------------------
c -------------------------------------------------------------------------
program mkpdb
use global
implicit none
call read_in_mkpdb
call read_data
call mkpdb_start
do iframe = nskip+1, nframes
call find_config
call read_config
write(6,*) 'Frame # ', iframe
if (mod(iframe,nframes_between_pdbs) == 0) call mk_pdb
enddo
write(6,*) 'Done.'
stop
end
c -------------------------------------------------------------------------
subroutine find_config
use global
implicit none
integer l,m,n,i,j,ntotal
real*8 buf(8)
if (mod((iframe-1),nper) == 0) then
n = (iframe-1)/nper + 1
write(6,*) 'On config file # ', n
close(21)
c l = n/100
c m = n/10 - l*10
c n = mod(n,10)
open(21,file=trim(config_file_path)
$ //char(48+n),status='old')
rewind 21
c skip the first frame of each config file
read(21,*)
read(21,*) ntimestep
read(21,*)
read(21,*) ntotal
read(21,*)
read(21,*) box(1,1),box(2,1)
read(21,*) box(1,2),box(2,2)
read(21,*) box(1,3),box(2,3)
read(21,*)
if (ntotal /= natoms) write(6,*) 'Mismatch # of atoms'
do i = 1, natoms
read (21,*) (buf(j),j=1,5)
enddo
endif
return
end
c -------------------------------------------------------------------------
logical function match(str1,str2,m)
implicit none
character*(*) str1,str2
integer m
match = .FALSE.
m = len(str1) + 1
if (len(str1).gt.len(str2)) return
if (str1.eq.str2(1:len(str1))) match = .TRUE.
return
end
c -------------------------------------------------------------------------
subroutine mk_pdb
use global
implicit none
integer i,j,k,l,m,n,o,imolecule,ith_pdb
real*8 xx,yy,zz,shiftx,shifty,shiftz,proteinmass
ith_pdb = iframe/nframes_between_pdbs
j = ith_pdb/1E4
k = (ith_pdb - j*1E4)/1E3
l = (ith_pdb - j*1E4 - k*1E3)/1E2
m = (ith_pdb - j*1E4 - k*1E3 - l*1E2)/1E1
n = (ith_pdb - j*1E4 - k*1E3 - l*1E2 - m*1E1)
open(26,file=trim(pdb_file_path)//char(48+j)//char(48+k)//
1 char(48+l)//char(48+m)//char(48+n)//'.pdb')
c Have to convert from pbc applied on an atomic basis to pbc applied
c on a residue basis.
c Step 1: Recenter system based on protein c.o.m.
shiftx = 0.0
shifty = 0.0
shiftz = 0.0
proteinmass = 0.0
do i = 1, natoms
imolecule = molecule(i)
if (imolecule <= nprotein_residues) then
shiftx = shiftx + (x(1,i) + mytrue(1,i)*xprd)*mass(type(i))
shifty = shifty + (x(2,i) + mytrue(2,i)*yprd)*mass(type(i))
shiftz = shiftz + (x(3,i) + mytrue(3,i)*zprd)*mass(type(i))
proteinmass = proteinmass + mass(type(i))
endif
enddo
shiftx = shiftx/proteinmass
shifty = shifty/proteinmass
shiftz = shiftz/proteinmass
do i = 1, natoms
x(1,i) = x(1,i) - shiftx
x(2,i) = x(2,i) - shifty
x(3,i) = x(3,i) - shiftz
enddo
c Step 2: Find the c.o.m. of each residue --- "molecule"
do i = 1, nmolecules
comx(i) = 0.0
comy(i) = 0.0
comz(i) = 0.0
totmass(i) = 0.0
enddo
do i = 1, natoms
imolecule = molecule(i)
comx(imolecule) = comx(imolecule) +
1 (x(1,i) + mytrue(1,i)*xprd)*mass(type(i))
comy(imolecule) = comy(imolecule) +
1 (x(2,i) + mytrue(2,i)*yprd)*mass(type(i))
comz(imolecule) = comz(imolecule) +
1 (x(3,i) + mytrue(3,i)*zprd)*mass(type(i))
totmass(imolecule) = totmass(imolecule) + mass(type(i))
enddo
do i = 1, nmolecules
comx(i) = comx(i)/totmass(i)
comy(i) = comy(i)/totmass(i)
comz(i) = comz(i)/totmass(i)
enddo
c Step 3: Decide how many boxes must be moved in each direction
do i = 1, nmolecules
nboxx(i) = nint(comx(i)/xprd)
nboxy(i) = nint(comy(i)/yprd)
nboxz(i) = nint(comz(i)/zprd)
enddo
c Step 4: Apply moves to atoms. Write pdb file.
do i = 1, natoms
imolecule = molecule(i)
xx = x(1,i) + (mytrue(1,i) - nboxx(imolecule))*xprd
yy = x(2,i) + (mytrue(2,i) - nboxy(imolecule))*yprd
zz = x(3,i) + (mytrue(3,i) - nboxz(imolecule))*zprd
write(26,100) outbeg(i),xx,yy,zz,outend(i)
enddo
100 format(a30,3f8.3,a22)
write(26,200) 'END'
200 format(a3)
close(26)
return
end
c -------------------------------------------------------------------------
subroutine mkpdb_start
use global
implicit none
integer i
character*76 pdbline(natoms),str
open(25,file=trim(compare_file_path),status='old')
rewind 25
do i = 1, natoms
read(25,100) pdbline(i)
enddo
100 format (a)
do i = 1, natoms
str = pdbline(i)
read (str(1:30),100) outbeg(i)
read (str(55:76),100) outend(i)
enddo
return
end
c -------------------------------------------------------------------------
c input data from config file
subroutine read_config
use global
implicit none
c local variables
integer i,j,itag,itrue,ntotal
real*8 buf(8)
read(21,*)
read(21,*) ntimestep
read(21,*)
read(21,*) ntotal
read(21,*)
read(21,*) box(1,1),box(2,1)
read(21,*) box(1,2),box(2,2)
read(21,*) box(1,3),box(2,3)
read(21,*)
if (ntotal /= natoms) write(6,*) 'Mismatch # of atoms'
xprd = box(2,1) - box(1,1)
yprd = box(2,2) - box(1,2)
zprd = box(2,3) - box(1,3)
do i = 1, natoms
read (21,*) (buf(j),j=1,5)
itag = nint(buf(1))
type(itag)= nint(buf(2))
x(1,itag) = buf(3)*xprd + box(1,1)
x(2,itag) = buf(4)*yprd + box(1,2)
x(3,itag) = buf(5)*zprd + box(1,3)
mytrue(1,itag) = 0
mytrue(2,itag) = 0
mytrue(3,itag) = 0
enddo
return
end
c -------------------------------------------------------------------------
c read data from input file
subroutine read_data
use global
implicit none
c local variables
logical match
integer i,j,jtmp,m,itag
real*8 buf(7)
character*80 str
900 format (a)
open(27,file=trim(data_file_path),status='old')
rewind 27
read (27,*)
read (27,*)
read (27,*) natoms
read (27,*) nbonds
read (27,*) nangles
read (27,*) ndihedrals
read (27,*) nimpropers
read (27,*)
read (27,*) ntypes
if (nbonds.gt.0) read (27,*) nbondtypes
if (nangles.gt.0) read (27,*) nangletypes
if (ndihedrals.gt.0) read (27,*) ndihedtypes
if (nimpropers.gt.0) read (27,*) nimprotypes
read (27,*)
read (27,*)
read (27,*)
read (27,*)
allocate(q(natoms))
allocate(type(natoms))
allocate(molecule(natoms))
allocate(mass(natoms))
allocate(x(3,natoms))
allocate(mytrue(3,natoms))
allocate(outbeg(natoms))
allocate(outend(natoms))
do
read (27,*,end=999,err=999)
read (27,900,end=999,err=999) str
read (27,*,end=999,err=999)
if (match('All Done',str,m)) then
goto 999
else if (match('Masses',str,m)) then
write (6,*) 'Masses ...'
do i = 1,ntypes
read (27,*) jtmp,mass(i)
enddo
else if (match('Atoms',str,m)) then
write (6,*) 'Atoms ...'
do i = 1,natoms
read (27,*) (buf(j),j=1,7)
itag = nint(buf(1))
molecule(itag) = nint(buf(2))
type(itag) = nint(buf(3))
q(itag) = buf(4)
enddo
else if (match('Bonds',str,m)) then
do i = 1,nbonds
read (27,*)
enddo
else if (match('Angles',str,m)) then
do i = 1,nangles
read (27,*)
enddo
else if (match('Impropers',str,m)) then
do i = 1,nimpropers
read (27,*)
enddo
else if (match('Pair Coeffs',str,m)) then
write (6,*) 'Pair Coeffs ...'
do i = 1,ntypes
read (27,*)
enddo
else if (match('Bond Coeffs',str,m)) then
do i = 1,nbondtypes
read (27,*)
enddo
else if (match('Angle Coeffs',str,m)) then
do i = 1,nangletypes
read (27,*)
enddo
else if (match('Dihedral Coeffs',str,m)) then
do i = 1,ndihedtypes
read (27,*)
enddo
else if (match('Dihedrals',str,m)) then
do i = 1,ndihedrals
read (27,*)
enddo
goto 999
else
write (6,*) 'UNKNOWN: ',trim(str)
write (6,*) 'Unknown identifier in data file'
endif
enddo
999 continue
close (27)
nmolecules = molecule(natoms)
allocate(nboxx(nmolecules))
allocate(nboxy(nmolecules))
allocate(nboxz(nmolecules))
allocate(comx(nmolecules))
allocate(comy(nmolecules))
allocate(comz(nmolecules))
allocate(totmass(nmolecules))
return
end
c -------------------------------------------------------------------------
c read data from in_mkpdb file
subroutine read_in_mkpdb
use global
implicit none
100 format (a)
open(22,file='in_mkpdb')
rewind 22
read (22,*) nconfig
read (22,*) nper
read (22,*) nconfig_skip
read (22,*) nframes_between_pdbs
read (22,*) nprotein_residues
read (22,100) data_file_path
read (22,100) config_file_path
read (22,100) pdb_file_path
read (22,100) compare_file_path
nframes = nconfig*nper
nskip = nconfig_skip*nper
iframe = nskip
close (22)
return
end
c -------------------------------------------------------------------------
| gpl-2.0 |
unofficial-opensource-apple/gcc_40 | gcc/testsuite/gfortran.dg/g77/960317-1.f | 17 | 4755 | c { dg-do compile }
* Date: Sat, 16 Mar 1996 19:58:37 -0500 (EST)
* From: Kate Hedstrom <kate@ahab.Rutgers.EDU>
* To: burley@gnu.ai.mit.edu
* Subject: g77 bug in assign
*
* I found some files in the NCAR graphics source code which used to
* compile with g77 and now don't. All contain the following combination
* of "save" and "assign". It fails on a Sun running SunOS 4.1.3 and a
* Sun running SunOS 5.5 (slightly older g77), but compiles on an
* IBM/RS6000:
*
C
SUBROUTINE QUICK
SAVE
C
ASSIGN 101 TO JUMP ! { dg-warning "Obsolete: ASSIGN" "" }
101 Continue
C
RETURN
END
*
* Everything else in the NCAR distribution compiled, including quite a
* few C routines.
*
* Kate
*
*
* nemo% g77 -v -c quick.f
* gcc -v -c -xf77 quick.f
* Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.2/specs
* gcc version 2.7.2
* /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.2/f771 quick.f -fset-g77-defaults -quiet -dumpbase quick.f -version -fversion -o /usr/tmp/cca24166.s
* GNU F77 version 2.7.2 (sparc) compiled by GNU C version 2.7.1.
* GNU Fortran Front End version 0.5.18-960314 compiled: Mar 16 1996 14:28:11
* gcc: Internal compiler error: program f771 got fatal signal 11
*
*
* nemo% gdb /usr/local/lib/gcc-lib/*/*/f771 core
* GDB is free software and you are welcome to distribute copies of it
* under certain conditions; type "show copying" to see the conditions.
* There is absolutely no warranty for GDB; type "show warranty" for details.
* GDB 4.14 (sparc-sun-sunos4.1.3),
* Copyright 1995 Free Software Foundation, Inc...
* Core was generated by `f771'.
* Program terminated with signal 11, Segmentation fault.
* Couldn't read input and local registers from core file
* find_solib: Can't read pathname for load map: I/O error
*
* Couldn't read input and local registers from core file
* #0 0x21aa4 in ffecom_sym_transform_assign_ (s=???) at f/com.c:7881
* 7881 if ((ffesymbol_save (s) || ffe_is_saveall ())
* (gdb) where
* #0 0x21aa4 in ffecom_sym_transform_assign_ (s=???) at f/com.c:7881
* Error accessing memory address 0xefffefcc: Invalid argument.
* (gdb)
*
*
* ahab% g77 -v -c quick.f
* gcc -v -c -xf77 quick.f
* Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/specs
* gcc version 2.7.2
* /usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/f771 quick.f -quiet -dumpbase quick.f -version -fversion -o /var/tmp/cca003D2.s
* GNU F77 version 2.7.2 (sparc) compiled by GNU C version 2.7.2.
* GNU Fortran Front End version 0.5.18-960304 compiled: Mar 5 1996 16:12:46
* gcc: Internal compiler error: program f771 got fatal signal 11
*
*
* ahab% !gdb
* gdb /usr/local/lib/gcc-lib/*/*/f771 core
* GDB is free software and you are welcome to distribute copies of it
* under certain conditions; type "show copying" to see the conditions.
* There is absolutely no warranty for GDB; type "show warranty" for details.
* GDB 4.15.1 (sparc-sun-solaris2.4),
* Copyright 1995 Free Software Foundation, Inc...
* Core was generated by
* `/usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/f771 quick.f -quiet -dumpbase'.
* Program terminated with signal 11, Segmentation fault.
* Reading symbols from /usr/lib/libc.so.1...done.
* Reading symbols from /usr/lib/libdl.so.1...done.
* #0 0x43e04 in ffecom_sym_transform_assign_ (s=0x3a22f8) at f/com.c:7963
* Source file is more recent than executable.
* 7963 assert (st != NULL);
* (gdb) where
* #0 0x43e04 in ffecom_sym_transform_assign_ (s=0x3a22f8) at f/com.c:7963
* #1 0x38044 in ffecom_expr_ (expr=0x3a23c0, dest_tree=0x0, dest=0x0, dest_used=0x0, assignp=true) at f/com.c:2100
* #2 0x489c8 in ffecom_expr_assign_w (expr=0x3a23c0) at f/com.c:10238
* #3 0xe9228 in ffeste_R838 (label=0x3a1ba8, target=0x3a23c0) at f/ste.c:2769
* #4 0xdae60 in ffestd_stmt_pass_ () at f/std.c:840
* #5 0xdc090 in ffestd_exec_end () at f/std.c:1405
* #6 0xcb534 in ffestc_shriek_subroutine_ (ok=true) at f/stc.c:4849
* #7 0xd8f00 in ffestc_R1225 (name=0x0) at f/stc.c:12307
* #8 0xcc808 in ffestc_end () at f/stc.c:5572
* #9 0x9fa84 in ffestb_end3_ (t=0x3a19c8) at f/stb.c:3216
* #10 0x9f30c in ffestb_end (t=0x3a19c8) at f/stb.c:2995
* #11 0x98414 in ffesta_save_ (t=0x3a19c8) at f/sta.c:453
* #12 0x997ec in ffesta_second_ (t=0x3a19c8) at f/sta.c:1178
* #13 0x8ed84 in ffelex_send_token_ () at f/lex.c:1614
* #14 0x8cab8 in ffelex_finish_statement_ () at f/lex.c:946
* #15 0x91684 in ffelex_file_fixed (wf=0x397780, f=0x37a560) at f/lex.c:2946
* #16 0x107a94 in ffe_file (wf=0x397780, f=0x37a560) at f/top.c:456
* #17 0x96218 in yyparse () at f/parse.c:77
* #18 0x10beac in compile_file (name=0xdffffaf7 "quick.f") at toplev.c:2239
* #19 0x110dc0 in main (argc=9, argv=0xdffff994, envp=0xdffff9bc) at toplev.c:3927
| gpl-2.0 |
shengren/magma-1.6.1 | testing/lin/dpot06.f | 9 | 4109 | SUBROUTINE DPOT06( UPLO, N, NRHS, A, LDA, X, LDX, B, LDB,
$ RWORK, RESID )
*
* -- LAPACK test routine (version 3.1.2) --
* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
* April 2007
*
* .. Scalar Arguments ..
CHARACTER UPLO
INTEGER LDA, LDB, LDX, N, NRHS
DOUBLE PRECISION RESID
* ..
* .. Array Arguments ..
DOUBLE PRECISION A( LDA, * ), B( LDB, * ), RWORK( * ),
$ X( LDX, * )
* ..
*
* Purpose
* =======
*
* DPOT06 computes the residual for a solution of a system of linear
* equations A*x = b :
* RESID = norm(B - A*X,inf) / ( norm(A,inf) * norm(X,inf) * EPS ),
* where EPS is the machine epsilon.
*
* Arguments
* =========
*
* UPLO (input) CHARACTER*1
* Specifies whether the upper or lower triangular part of the
* symmetric matrix A is stored:
* = 'U': Upper triangular
* = 'L': Lower triangular
*
* N (input) INTEGER
* The number of rows and columns of the matrix A. N >= 0.
*
* NRHS (input) INTEGER
* The number of columns of B, the matrix of right hand sides.
* NRHS >= 0.
*
* A (input) DOUBLE PRECISION array, dimension (LDA,N)
* The original M x N matrix A.
*
* LDA (input) INTEGER
* The leading dimension of the array A. LDA >= max(1,N).
*
* X (input) DOUBLE PRECISION array, dimension (LDX,NRHS)
* The computed solution vectors for the system of linear
* equations.
*
* LDX (input) INTEGER
* The leading dimension of the array X. If TRANS = 'N',
* LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,N).
*
* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
* On entry, the right hand side vectors for the system of
* linear equations.
* On exit, B is overwritten with the difference B - A*X.
*
* LDB (input) INTEGER
* The leading dimension of the array B. IF TRANS = 'N',
* LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N).
*
* RWORK (workspace) DOUBLE PRECISION array, dimension (N)
*
* RESID (output) DOUBLE PRECISION
* The maximum over the number of right hand sides of
* norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO, ONE, NEGONE
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
PARAMETER ( NEGONE = -1.0D+0 )
* ..
* .. Local Scalars ..
INTEGER IFAIL, J
DOUBLE PRECISION ANORM, BNORM, EPS, XNORM
* ..
* .. External Functions ..
LOGICAL LSAME
INTEGER IDAMAX
DOUBLE PRECISION DLAMCH, DLANSY
EXTERNAL LSAME, IDAMAX, DLAMCH, DLANSY
* ..
* .. External Subroutines ..
EXTERNAL DSYMM
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, ABS
* ..
* .. Executable Statements ..
*
* Quick exit if N = 0 or NRHS = 0
*
IF( N.LE.0 .OR. NRHS.EQ.0 ) THEN
RESID = ZERO
RETURN
END IF
*
* Exit with RESID = 1/EPS if ANORM = 0.
*
EPS = DLAMCH( 'Epsilon' )
ANORM = DLANSY( 'I', UPLO, N, A, LDA, RWORK )
IF( ANORM.LE.ZERO ) THEN
RESID = ONE / EPS
RETURN
END IF
*
* Compute B - A*X and store in B.
IFAIL=0
*
CALL DSYMM( 'Left', UPLO, N, NRHS, NEGONE, A, LDA, X,
$ LDX, ONE, B, LDB )
*
* Compute the maximum over the number of right hand sides of
* norm(B - A*X) / ( norm(A) * norm(X) * EPS ) .
*
RESID = ZERO
DO 10 J = 1, NRHS
BNORM = ABS(B(IDAMAX( N, B( 1, J ), 1 ),J))
XNORM = ABS(X(IDAMAX( N, X( 1, J ), 1 ),J))
IF( XNORM.LE.ZERO ) THEN
RESID = ONE / EPS
ELSE
RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )
END IF
10 CONTINUE
*
RETURN
*
* End of DPOT06
*
END
| bsd-3-clause |
bftg/gcc-5.3.0 | libgomp/testsuite/libgomp.fortran/udr12.f90 | 102 | 1875 | ! { dg-do run }
interface
elemental subroutine sub1 (x, y)
integer, intent(in) :: y
integer, intent(out) :: x
end subroutine
elemental function fn2 (x)
integer, intent(in) :: x
integer :: fn2
end function
end interface
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn1 (omp_out, omp_in)) &
!$omp & initializer (sub1 (omp_priv, omp_orig))
!$omp declare reduction (baz : integer : sub2 (omp_out, omp_in)) &
!$omp initializer (omp_priv = fn2 (omp_orig))
interface
elemental function fn1 (x, y)
integer, intent(in) :: x, y
integer :: fn1
end function
elemental subroutine sub2 (x, y)
integer, intent(in) :: y
integer, intent(inout) :: x
end subroutine
end interface
integer :: a(10), b, r
a(:) = 0
b = 0
r = 0
!$omp parallel reduction (foo : a, b) reduction (+: r)
a = a + 2
b = b + 3
r = r + 1
!$omp end parallel
if (any (a /= 2 * r) .or. b /= 3 * r) call abort
a(:) = 0
b = 0
r = 0
!$omp parallel reduction (bar : a, b) reduction (+: r)
a = a + 2
b = b + 3
r = r + 1
!$omp end parallel
if (any (a /= 4 * r) .or. b /= 6 * r) call abort
a(:) = 0
b = 0
r = 0
!$omp parallel reduction (baz : a, b) reduction (+: r)
a = a + 2
b = b + 3
r = r + 1
!$omp end parallel
if (any (a /= 2 * r) .or. b /= 3 * r) call abort
end
elemental function fn1 (x, y)
integer, intent(in) :: x, y
integer :: fn1
fn1 = x + 2 * y
end function
elemental subroutine sub1 (x, y)
integer, intent(in) :: y
integer, intent(out) :: x
x = 0
end subroutine
elemental function fn2 (x)
integer, intent(in) :: x
integer :: fn2
fn2 = x
end function
elemental subroutine sub2 (x, y)
integer, intent(inout) :: x
integer, intent(in) :: y
x = x + y
end subroutine
| gpl-2.0 |
mortada/scipy | scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/dsesrt.f | 171 | 5368 | c-----------------------------------------------------------------------
c\BeginDoc
c
c\Name: dsesrt
c
c\Description:
c Sort the array X in the order specified by WHICH and optionally
c apply the permutation to the columns of the matrix A.
c
c\Usage:
c call dsesrt
c ( WHICH, APPLY, N, X, NA, A, LDA)
c
c\Arguments
c WHICH Character*2. (Input)
c 'LM' -> X is sorted into increasing order of magnitude.
c 'SM' -> X is sorted into decreasing order of magnitude.
c 'LA' -> X is sorted into increasing order of algebraic.
c 'SA' -> X is sorted into decreasing order of algebraic.
c
c APPLY Logical. (Input)
c APPLY = .TRUE. -> apply the sorted order to A.
c APPLY = .FALSE. -> do not apply the sorted order to A.
c
c N Integer. (INPUT)
c Dimension of the array X.
c
c X Double precision array of length N. (INPUT/OUTPUT)
c The array to be sorted.
c
c NA Integer. (INPUT)
c Number of rows of the matrix A.
c
c A Double precision array of length NA by N. (INPUT/OUTPUT)
c
c LDA Integer. (INPUT)
c Leading dimension of A.
c
c\EndDoc
c
c-----------------------------------------------------------------------
c
c\BeginLib
c
c\Routines
c dswap Level 1 BLAS that swaps the contents of two vectors.
c
c\Authors
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 12/15/93: Version ' 2.1'.
c Adapted from the sort routine in LANSO and
c the ARPACK code dsortr
c
c\SCCS Information: @(#)
c FILE: sesrt.F SID: 2.3 DATE OF SID: 4/19/96 RELEASE: 2
c
c\EndLib
c
c-----------------------------------------------------------------------
c
subroutine dsesrt (which, apply, n, x, na, a, lda)
c
c %------------------%
c | Scalar Arguments |
c %------------------%
c
character*2 which
logical apply
integer lda, n, na
c
c %-----------------%
c | Array Arguments |
c %-----------------%
c
Double precision
& x(0:n-1), a(lda, 0:n-1)
c
c %---------------%
c | Local Scalars |
c %---------------%
c
integer i, igap, j
Double precision
& temp
c
c %----------------------%
c | External Subroutines |
c %----------------------%
c
external dswap
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
c
igap = n / 2
c
if (which .eq. 'SA') then
c
c X is sorted into decreasing order of algebraic.
c
10 continue
if (igap .eq. 0) go to 9000
do 30 i = igap, n-1
j = i-igap
20 continue
c
if (j.lt.0) go to 30
c
if (x(j).lt.x(j+igap)) then
temp = x(j)
x(j) = x(j+igap)
x(j+igap) = temp
if (apply) call dswap( na, a(1, j), 1, a(1,j+igap), 1)
else
go to 30
endif
j = j-igap
go to 20
30 continue
igap = igap / 2
go to 10
c
else if (which .eq. 'SM') then
c
c X is sorted into decreasing order of magnitude.
c
40 continue
if (igap .eq. 0) go to 9000
do 60 i = igap, n-1
j = i-igap
50 continue
c
if (j.lt.0) go to 60
c
if (abs(x(j)).lt.abs(x(j+igap))) then
temp = x(j)
x(j) = x(j+igap)
x(j+igap) = temp
if (apply) call dswap( na, a(1, j), 1, a(1,j+igap), 1)
else
go to 60
endif
j = j-igap
go to 50
60 continue
igap = igap / 2
go to 40
c
else if (which .eq. 'LA') then
c
c X is sorted into increasing order of algebraic.
c
70 continue
if (igap .eq. 0) go to 9000
do 90 i = igap, n-1
j = i-igap
80 continue
c
if (j.lt.0) go to 90
c
if (x(j).gt.x(j+igap)) then
temp = x(j)
x(j) = x(j+igap)
x(j+igap) = temp
if (apply) call dswap( na, a(1, j), 1, a(1,j+igap), 1)
else
go to 90
endif
j = j-igap
go to 80
90 continue
igap = igap / 2
go to 70
c
else if (which .eq. 'LM') then
c
c X is sorted into increasing order of magnitude.
c
100 continue
if (igap .eq. 0) go to 9000
do 120 i = igap, n-1
j = i-igap
110 continue
c
if (j.lt.0) go to 120
c
if (abs(x(j)).gt.abs(x(j+igap))) then
temp = x(j)
x(j) = x(j+igap)
x(j+igap) = temp
if (apply) call dswap( na, a(1, j), 1, a(1,j+igap), 1)
else
go to 120
endif
j = j-igap
go to 110
120 continue
igap = igap / 2
go to 100
end if
c
9000 continue
return
c
c %---------------%
c | End of dsesrt |
c %---------------%
c
end
| bsd-3-clause |
jseabold/scipy | scipy/special/amos/zunk2.f | 118 | 17247 | SUBROUTINE ZUNK2(ZR, ZI, FNU, KODE, MR, N, YR, YI, NZ, TOL, ELIM,
* ALIM)
C***BEGIN PROLOGUE ZUNK2
C***REFER TO ZBESK
C
C ZUNK2 COMPUTES K(FNU,Z) AND ITS ANALYTIC CONTINUATION FROM THE
C RIGHT HALF PLANE TO THE LEFT HALF PLANE BY MEANS OF THE
C UNIFORM ASYMPTOTIC EXPANSIONS FOR H(KIND,FNU,ZN) AND J(FNU,ZN)
C WHERE ZN IS IN THE RIGHT HALF PLANE, KIND=(3-MR)/2, MR=+1 OR
C -1. HERE ZN=ZR*I OR -ZR*I WHERE ZR=Z IF Z IS IN THE RIGHT
C HALF PLANE OR ZR=-Z IF Z IS IN THE LEFT HALF PLANE. MR INDIC-
C ATES THE DIRECTION OF ROTATION FOR ANALYTIC CONTINUATION.
C NZ=-1 MEANS AN OVERFLOW WILL OCCUR
C
C***ROUTINES CALLED ZAIRY,ZKSCL,ZS1S2,ZUCHK,ZUNHJ,D1MACH,AZABS
C***END PROLOGUE ZUNK2
C COMPLEX AI,ARG,ARGD,ASUM,ASUMD,BSUM,BSUMD,CFN,CI,CIP,CK,CONE,CRSC,
C *CR1,CR2,CS,CSCL,CSGN,CSPN,CSR,CSS,CY,CZERO,C1,C2,DAI,PHI,PHID,RZ,
C *S1,S2,Y,Z,ZB,ZETA1,ZETA1D,ZETA2,ZETA2D,ZN,ZR
DOUBLE PRECISION AARG, AIC, AII, AIR, ALIM, ANG, APHI, ARGDI,
* ARGDR, ARGI, ARGR, ASC, ASCLE, ASUMDI, ASUMDR, ASUMI, ASUMR,
* BRY, BSUMDI, BSUMDR, BSUMI, BSUMR, CAR, CIPI, CIPR, CKI, CKR,
* CONER, CRSC, CR1I, CR1R, CR2I, CR2R, CSCL, CSGNI, CSI,
* CSPNI, CSPNR, CSR, CSRR, CSSR, CYI, CYR, C1I, C1R, C2I, C2M,
* C2R, DAII, DAIR, ELIM, FMR, FN, FNF, FNU, HPI, PHIDI, PHIDR,
* PHII, PHIR, PI, PTI, PTR, RAST, RAZR, RS1, RZI, RZR, SAR, SGN,
* STI, STR, S1I, S1R, S2I, S2R, TOL, YI, YR, YY, ZBI, ZBR, ZEROI,
* ZEROR, ZETA1I, ZETA1R, ZETA2I, ZETA2R, ZET1DI, ZET1DR, ZET2DI,
* ZET2DR, ZI, ZNI, ZNR, ZR, ZRI, ZRR, D1MACH, AZABS
INTEGER I, IB, IFLAG, IFN, IL, IN, INU, IUF, K, KDFLG, KFLAG, KK,
* KODE, MR, N, NAI, NDAI, NW, NZ, IDUM, J, IPARD, IC
DIMENSION BRY(3), YR(N), YI(N), ASUMR(2), ASUMI(2), BSUMR(2),
* BSUMI(2), PHIR(2), PHII(2), ARGR(2), ARGI(2), ZETA1R(2),
* ZETA1I(2), ZETA2R(2), ZETA2I(2), CYR(2), CYI(2), CIPR(4),
* CIPI(4), CSSR(3), CSRR(3)
DATA ZEROR,ZEROI,CONER,CR1R,CR1I,CR2R,CR2I /
1 0.0D0, 0.0D0, 1.0D0,
1 1.0D0,1.73205080756887729D0 , -0.5D0,-8.66025403784438647D-01 /
DATA HPI, PI, AIC /
1 1.57079632679489662D+00, 3.14159265358979324D+00,
1 1.26551212348464539D+00/
DATA CIPR(1),CIPI(1),CIPR(2),CIPI(2),CIPR(3),CIPI(3),CIPR(4),
* CIPI(4) /
1 1.0D0,0.0D0 , 0.0D0,-1.0D0 , -1.0D0,0.0D0 , 0.0D0,1.0D0 /
C
KDFLG = 1
NZ = 0
C-----------------------------------------------------------------------
C EXP(-ALIM)=EXP(-ELIM)/TOL=APPROX. ONE PRECISION GREATER THAN
C THE UNDERFLOW LIMIT
C-----------------------------------------------------------------------
CSCL = 1.0D0/TOL
CRSC = TOL
CSSR(1) = CSCL
CSSR(2) = CONER
CSSR(3) = CRSC
CSRR(1) = CRSC
CSRR(2) = CONER
CSRR(3) = CSCL
BRY(1) = 1.0D+3*D1MACH(1)/TOL
BRY(2) = 1.0D0/BRY(1)
BRY(3) = D1MACH(2)
ZRR = ZR
ZRI = ZI
IF (ZR.GE.0.0D0) GO TO 10
ZRR = -ZR
ZRI = -ZI
10 CONTINUE
YY = ZRI
ZNR = ZRI
ZNI = -ZRR
ZBR = ZRR
ZBI = ZRI
INU = INT(SNGL(FNU))
FNF = FNU - DBLE(FLOAT(INU))
ANG = -HPI*FNF
CAR = DCOS(ANG)
SAR = DSIN(ANG)
C2R = HPI*SAR
C2I = -HPI*CAR
KK = MOD(INU,4) + 1
STR = C2R*CIPR(KK) - C2I*CIPI(KK)
STI = C2R*CIPI(KK) + C2I*CIPR(KK)
CSR = CR1R*STR - CR1I*STI
CSI = CR1R*STI + CR1I*STR
IF (YY.GT.0.0D0) GO TO 20
ZNR = -ZNR
ZBI = -ZBI
20 CONTINUE
C-----------------------------------------------------------------------
C K(FNU,Z) IS COMPUTED FROM H(2,FNU,-I*Z) WHERE Z IS IN THE FIRST
C QUADRANT. FOURTH QUADRANT VALUES (YY.LE.0.0E0) ARE COMPUTED BY
C CONJUGATION SINCE THE K FUNCTION IS REAL ON THE POSITIVE REAL AXIS
C-----------------------------------------------------------------------
J = 2
DO 80 I=1,N
C-----------------------------------------------------------------------
C J FLIP FLOPS BETWEEN 1 AND 2 IN J = 3 - J
C-----------------------------------------------------------------------
J = 3 - J
FN = FNU + DBLE(FLOAT(I-1))
CALL ZUNHJ(ZNR, ZNI, FN, 0, TOL, PHIR(J), PHII(J), ARGR(J),
* ARGI(J), ZETA1R(J), ZETA1I(J), ZETA2R(J), ZETA2I(J), ASUMR(J),
* ASUMI(J), BSUMR(J), BSUMI(J))
IF (KODE.EQ.1) GO TO 30
STR = ZBR + ZETA2R(J)
STI = ZBI + ZETA2I(J)
RAST = FN/AZABS(STR,STI)
STR = STR*RAST*RAST
STI = -STI*RAST*RAST
S1R = ZETA1R(J) - STR
S1I = ZETA1I(J) - STI
GO TO 40
30 CONTINUE
S1R = ZETA1R(J) - ZETA2R(J)
S1I = ZETA1I(J) - ZETA2I(J)
40 CONTINUE
C-----------------------------------------------------------------------
C TEST FOR UNDERFLOW AND OVERFLOW
C-----------------------------------------------------------------------
RS1 = S1R
IF (DABS(RS1).GT.ELIM) GO TO 70
IF (KDFLG.EQ.1) KFLAG = 2
IF (DABS(RS1).LT.ALIM) GO TO 50
C-----------------------------------------------------------------------
C REFINE TEST AND SCALE
C-----------------------------------------------------------------------
APHI = AZABS(PHIR(J),PHII(J))
AARG = AZABS(ARGR(J),ARGI(J))
RS1 = RS1 + DLOG(APHI) - 0.25D0*DLOG(AARG) - AIC
IF (DABS(RS1).GT.ELIM) GO TO 70
IF (KDFLG.EQ.1) KFLAG = 1
IF (RS1.LT.0.0D0) GO TO 50
IF (KDFLG.EQ.1) KFLAG = 3
50 CONTINUE
C-----------------------------------------------------------------------
C SCALE S1 TO KEEP INTERMEDIATE ARITHMETIC ON SCALE NEAR
C EXPONENT EXTREMES
C-----------------------------------------------------------------------
C2R = ARGR(J)*CR2R - ARGI(J)*CR2I
C2I = ARGR(J)*CR2I + ARGI(J)*CR2R
CALL ZAIRY(C2R, C2I, 0, 2, AIR, AII, NAI, IDUM)
CALL ZAIRY(C2R, C2I, 1, 2, DAIR, DAII, NDAI, IDUM)
STR = DAIR*BSUMR(J) - DAII*BSUMI(J)
STI = DAIR*BSUMI(J) + DAII*BSUMR(J)
PTR = STR*CR2R - STI*CR2I
PTI = STR*CR2I + STI*CR2R
STR = PTR + (AIR*ASUMR(J)-AII*ASUMI(J))
STI = PTI + (AIR*ASUMI(J)+AII*ASUMR(J))
PTR = STR*PHIR(J) - STI*PHII(J)
PTI = STR*PHII(J) + STI*PHIR(J)
S2R = PTR*CSR - PTI*CSI
S2I = PTR*CSI + PTI*CSR
STR = DEXP(S1R)*CSSR(KFLAG)
S1R = STR*DCOS(S1I)
S1I = STR*DSIN(S1I)
STR = S2R*S1R - S2I*S1I
S2I = S1R*S2I + S2R*S1I
S2R = STR
IF (KFLAG.NE.1) GO TO 60
CALL ZUCHK(S2R, S2I, NW, BRY(1), TOL)
IF (NW.NE.0) GO TO 70
60 CONTINUE
IF (YY.LE.0.0D0) S2I = -S2I
CYR(KDFLG) = S2R
CYI(KDFLG) = S2I
YR(I) = S2R*CSRR(KFLAG)
YI(I) = S2I*CSRR(KFLAG)
STR = CSI
CSI = -CSR
CSR = STR
IF (KDFLG.EQ.2) GO TO 85
KDFLG = 2
GO TO 80
70 CONTINUE
IF (RS1.GT.0.0D0) GO TO 320
C-----------------------------------------------------------------------
C FOR ZR.LT.0.0, THE I FUNCTION TO BE ADDED WILL OVERFLOW
C-----------------------------------------------------------------------
IF (ZR.LT.0.0D0) GO TO 320
KDFLG = 1
YR(I)=ZEROR
YI(I)=ZEROI
NZ=NZ+1
STR = CSI
CSI =-CSR
CSR = STR
IF (I.EQ.1) GO TO 80
IF ((YR(I-1).EQ.ZEROR).AND.(YI(I-1).EQ.ZEROI)) GO TO 80
YR(I-1)=ZEROR
YI(I-1)=ZEROI
NZ=NZ+1
80 CONTINUE
I = N
85 CONTINUE
RAZR = 1.0D0/AZABS(ZRR,ZRI)
STR = ZRR*RAZR
STI = -ZRI*RAZR
RZR = (STR+STR)*RAZR
RZI = (STI+STI)*RAZR
CKR = FN*RZR
CKI = FN*RZI
IB = I + 1
IF (N.LT.IB) GO TO 180
C-----------------------------------------------------------------------
C TEST LAST MEMBER FOR UNDERFLOW AND OVERFLOW. SET SEQUENCE TO ZERO
C ON UNDERFLOW.
C-----------------------------------------------------------------------
FN = FNU + DBLE(FLOAT(N-1))
IPARD = 1
IF (MR.NE.0) IPARD = 0
CALL ZUNHJ(ZNR, ZNI, FN, IPARD, TOL, PHIDR, PHIDI, ARGDR, ARGDI,
* ZET1DR, ZET1DI, ZET2DR, ZET2DI, ASUMDR, ASUMDI, BSUMDR, BSUMDI)
IF (KODE.EQ.1) GO TO 90
STR = ZBR + ZET2DR
STI = ZBI + ZET2DI
RAST = FN/AZABS(STR,STI)
STR = STR*RAST*RAST
STI = -STI*RAST*RAST
S1R = ZET1DR - STR
S1I = ZET1DI - STI
GO TO 100
90 CONTINUE
S1R = ZET1DR - ZET2DR
S1I = ZET1DI - ZET2DI
100 CONTINUE
RS1 = S1R
IF (DABS(RS1).GT.ELIM) GO TO 105
IF (DABS(RS1).LT.ALIM) GO TO 120
C----------------------------------------------------------------------------
C REFINE ESTIMATE AND TEST
C-------------------------------------------------------------------------
APHI = AZABS(PHIDR,PHIDI)
RS1 = RS1+DLOG(APHI)
IF (DABS(RS1).LT.ELIM) GO TO 120
105 CONTINUE
IF (RS1.GT.0.0D0) GO TO 320
C-----------------------------------------------------------------------
C FOR ZR.LT.0.0, THE I FUNCTION TO BE ADDED WILL OVERFLOW
C-----------------------------------------------------------------------
IF (ZR.LT.0.0D0) GO TO 320
NZ = N
DO 106 I=1,N
YR(I) = ZEROR
YI(I) = ZEROI
106 CONTINUE
RETURN
120 CONTINUE
S1R = CYR(1)
S1I = CYI(1)
S2R = CYR(2)
S2I = CYI(2)
C1R = CSRR(KFLAG)
ASCLE = BRY(KFLAG)
DO 130 I=IB,N
C2R = S2R
C2I = S2I
S2R = CKR*C2R - CKI*C2I + S1R
S2I = CKR*C2I + CKI*C2R + S1I
S1R = C2R
S1I = C2I
CKR = CKR + RZR
CKI = CKI + RZI
C2R = S2R*C1R
C2I = S2I*C1R
YR(I) = C2R
YI(I) = C2I
IF (KFLAG.GE.3) GO TO 130
STR = DABS(C2R)
STI = DABS(C2I)
C2M = DMAX1(STR,STI)
IF (C2M.LE.ASCLE) GO TO 130
KFLAG = KFLAG + 1
ASCLE = BRY(KFLAG)
S1R = S1R*C1R
S1I = S1I*C1R
S2R = C2R
S2I = C2I
S1R = S1R*CSSR(KFLAG)
S1I = S1I*CSSR(KFLAG)
S2R = S2R*CSSR(KFLAG)
S2I = S2I*CSSR(KFLAG)
C1R = CSRR(KFLAG)
130 CONTINUE
180 CONTINUE
IF (MR.EQ.0) RETURN
C-----------------------------------------------------------------------
C ANALYTIC CONTINUATION FOR RE(Z).LT.0.0D0
C-----------------------------------------------------------------------
NZ = 0
FMR = DBLE(FLOAT(MR))
SGN = -DSIGN(PI,FMR)
C-----------------------------------------------------------------------
C CSPN AND CSGN ARE COEFF OF K AND I FUNCIONS RESP.
C-----------------------------------------------------------------------
CSGNI = SGN
IF (YY.LE.0.0D0) CSGNI = -CSGNI
IFN = INU + N - 1
ANG = FNF*SGN
CSPNR = DCOS(ANG)
CSPNI = DSIN(ANG)
IF (MOD(IFN,2).EQ.0) GO TO 190
CSPNR = -CSPNR
CSPNI = -CSPNI
190 CONTINUE
C-----------------------------------------------------------------------
C CS=COEFF OF THE J FUNCTION TO GET THE I FUNCTION. I(FNU,Z) IS
C COMPUTED FROM EXP(I*FNU*HPI)*J(FNU,-I*Z) WHERE Z IS IN THE FIRST
C QUADRANT. FOURTH QUADRANT VALUES (YY.LE.0.0E0) ARE COMPUTED BY
C CONJUGATION SINCE THE I FUNCTION IS REAL ON THE POSITIVE REAL AXIS
C-----------------------------------------------------------------------
CSR = SAR*CSGNI
CSI = CAR*CSGNI
IN = MOD(IFN,4) + 1
C2R = CIPR(IN)
C2I = CIPI(IN)
STR = CSR*C2R + CSI*C2I
CSI = -CSR*C2I + CSI*C2R
CSR = STR
ASC = BRY(1)
IUF = 0
KK = N
KDFLG = 1
IB = IB - 1
IC = IB - 1
DO 290 K=1,N
FN = FNU + DBLE(FLOAT(KK-1))
C-----------------------------------------------------------------------
C LOGIC TO SORT OUT CASES WHOSE PARAMETERS WERE SET FOR THE K
C FUNCTION ABOVE
C-----------------------------------------------------------------------
IF (N.GT.2) GO TO 175
172 CONTINUE
PHIDR = PHIR(J)
PHIDI = PHII(J)
ARGDR = ARGR(J)
ARGDI = ARGI(J)
ZET1DR = ZETA1R(J)
ZET1DI = ZETA1I(J)
ZET2DR = ZETA2R(J)
ZET2DI = ZETA2I(J)
ASUMDR = ASUMR(J)
ASUMDI = ASUMI(J)
BSUMDR = BSUMR(J)
BSUMDI = BSUMI(J)
J = 3 - J
GO TO 210
175 CONTINUE
IF ((KK.EQ.N).AND.(IB.LT.N)) GO TO 210
IF ((KK.EQ.IB).OR.(KK.EQ.IC)) GO TO 172
CALL ZUNHJ(ZNR, ZNI, FN, 0, TOL, PHIDR, PHIDI, ARGDR,
* ARGDI, ZET1DR, ZET1DI, ZET2DR, ZET2DI, ASUMDR,
* ASUMDI, BSUMDR, BSUMDI)
210 CONTINUE
IF (KODE.EQ.1) GO TO 220
STR = ZBR + ZET2DR
STI = ZBI + ZET2DI
RAST = FN/AZABS(STR,STI)
STR = STR*RAST*RAST
STI = -STI*RAST*RAST
S1R = -ZET1DR + STR
S1I = -ZET1DI + STI
GO TO 230
220 CONTINUE
S1R = -ZET1DR + ZET2DR
S1I = -ZET1DI + ZET2DI
230 CONTINUE
C-----------------------------------------------------------------------
C TEST FOR UNDERFLOW AND OVERFLOW
C-----------------------------------------------------------------------
RS1 = S1R
IF (DABS(RS1).GT.ELIM) GO TO 280
IF (KDFLG.EQ.1) IFLAG = 2
IF (DABS(RS1).LT.ALIM) GO TO 240
C-----------------------------------------------------------------------
C REFINE TEST AND SCALE
C-----------------------------------------------------------------------
APHI = AZABS(PHIDR,PHIDI)
AARG = AZABS(ARGDR,ARGDI)
RS1 = RS1 + DLOG(APHI) - 0.25D0*DLOG(AARG) - AIC
IF (DABS(RS1).GT.ELIM) GO TO 280
IF (KDFLG.EQ.1) IFLAG = 1
IF (RS1.LT.0.0D0) GO TO 240
IF (KDFLG.EQ.1) IFLAG = 3
240 CONTINUE
CALL ZAIRY(ARGDR, ARGDI, 0, 2, AIR, AII, NAI, IDUM)
CALL ZAIRY(ARGDR, ARGDI, 1, 2, DAIR, DAII, NDAI, IDUM)
STR = DAIR*BSUMDR - DAII*BSUMDI
STI = DAIR*BSUMDI + DAII*BSUMDR
STR = STR + (AIR*ASUMDR-AII*ASUMDI)
STI = STI + (AIR*ASUMDI+AII*ASUMDR)
PTR = STR*PHIDR - STI*PHIDI
PTI = STR*PHIDI + STI*PHIDR
S2R = PTR*CSR - PTI*CSI
S2I = PTR*CSI + PTI*CSR
STR = DEXP(S1R)*CSSR(IFLAG)
S1R = STR*DCOS(S1I)
S1I = STR*DSIN(S1I)
STR = S2R*S1R - S2I*S1I
S2I = S2R*S1I + S2I*S1R
S2R = STR
IF (IFLAG.NE.1) GO TO 250
CALL ZUCHK(S2R, S2I, NW, BRY(1), TOL)
IF (NW.EQ.0) GO TO 250
S2R = ZEROR
S2I = ZEROI
250 CONTINUE
IF (YY.LE.0.0D0) S2I = -S2I
CYR(KDFLG) = S2R
CYI(KDFLG) = S2I
C2R = S2R
C2I = S2I
S2R = S2R*CSRR(IFLAG)
S2I = S2I*CSRR(IFLAG)
C-----------------------------------------------------------------------
C ADD I AND K FUNCTIONS, K SEQUENCE IN Y(I), I=1,N
C-----------------------------------------------------------------------
S1R = YR(KK)
S1I = YI(KK)
IF (KODE.EQ.1) GO TO 270
CALL ZS1S2(ZRR, ZRI, S1R, S1I, S2R, S2I, NW, ASC, ALIM, IUF)
NZ = NZ + NW
270 CONTINUE
YR(KK) = S1R*CSPNR - S1I*CSPNI + S2R
YI(KK) = S1R*CSPNI + S1I*CSPNR + S2I
KK = KK - 1
CSPNR = -CSPNR
CSPNI = -CSPNI
STR = CSI
CSI = -CSR
CSR = STR
IF (C2R.NE.0.0D0 .OR. C2I.NE.0.0D0) GO TO 255
KDFLG = 1
GO TO 290
255 CONTINUE
IF (KDFLG.EQ.2) GO TO 295
KDFLG = 2
GO TO 290
280 CONTINUE
IF (RS1.GT.0.0D0) GO TO 320
S2R = ZEROR
S2I = ZEROI
GO TO 250
290 CONTINUE
K = N
295 CONTINUE
IL = N - K
IF (IL.EQ.0) RETURN
C-----------------------------------------------------------------------
C RECUR BACKWARD FOR REMAINDER OF I SEQUENCE AND ADD IN THE
C K FUNCTIONS, SCALING THE I SEQUENCE DURING RECURRENCE TO KEEP
C INTERMEDIATE ARITHMETIC ON SCALE NEAR EXPONENT EXTREMES.
C-----------------------------------------------------------------------
S1R = CYR(1)
S1I = CYI(1)
S2R = CYR(2)
S2I = CYI(2)
CSR = CSRR(IFLAG)
ASCLE = BRY(IFLAG)
FN = DBLE(FLOAT(INU+IL))
DO 310 I=1,IL
C2R = S2R
C2I = S2I
S2R = S1R + (FN+FNF)*(RZR*C2R-RZI*C2I)
S2I = S1I + (FN+FNF)*(RZR*C2I+RZI*C2R)
S1R = C2R
S1I = C2I
FN = FN - 1.0D0
C2R = S2R*CSR
C2I = S2I*CSR
CKR = C2R
CKI = C2I
C1R = YR(KK)
C1I = YI(KK)
IF (KODE.EQ.1) GO TO 300
CALL ZS1S2(ZRR, ZRI, C1R, C1I, C2R, C2I, NW, ASC, ALIM, IUF)
NZ = NZ + NW
300 CONTINUE
YR(KK) = C1R*CSPNR - C1I*CSPNI + C2R
YI(KK) = C1R*CSPNI + C1I*CSPNR + C2I
KK = KK - 1
CSPNR = -CSPNR
CSPNI = -CSPNI
IF (IFLAG.GE.3) GO TO 310
C2R = DABS(CKR)
C2I = DABS(CKI)
C2M = DMAX1(C2R,C2I)
IF (C2M.LE.ASCLE) GO TO 310
IFLAG = IFLAG + 1
ASCLE = BRY(IFLAG)
S1R = S1R*CSR
S1I = S1I*CSR
S2R = CKR
S2I = CKI
S1R = S1R*CSSR(IFLAG)
S1I = S1I*CSSR(IFLAG)
S2R = S2R*CSSR(IFLAG)
S2I = S2I*CSSR(IFLAG)
CSR = CSRR(IFLAG)
310 CONTINUE
RETURN
320 CONTINUE
NZ = -1
RETURN
END
| bsd-3-clause |
jseabold/scipy | scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/dnapps.f | 102 | 23505 | c-----------------------------------------------------------------------
c\BeginDoc
c
c\Name: dnapps
c
c\Description:
c Given the Arnoldi factorization
c
c A*V_{k} - V_{k}*H_{k} = r_{k+p}*e_{k+p}^T,
c
c apply NP implicit shifts resulting in
c
c A*(V_{k}*Q) - (V_{k}*Q)*(Q^T* H_{k}*Q) = r_{k+p}*e_{k+p}^T * Q
c
c where Q is an orthogonal matrix which is the product of rotations
c and reflections resulting from the NP bulge chage sweeps.
c The updated Arnoldi factorization becomes:
c
c A*VNEW_{k} - VNEW_{k}*HNEW_{k} = rnew_{k}*e_{k}^T.
c
c\Usage:
c call dnapps
c ( N, KEV, NP, SHIFTR, SHIFTI, V, LDV, H, LDH, RESID, Q, LDQ,
c WORKL, WORKD )
c
c\Arguments
c N Integer. (INPUT)
c Problem size, i.e. size of matrix A.
c
c KEV Integer. (INPUT/OUTPUT)
c KEV+NP is the size of the input matrix H.
c KEV is the size of the updated matrix HNEW. KEV is only
c updated on ouput when fewer than NP shifts are applied in
c order to keep the conjugate pair together.
c
c NP Integer. (INPUT)
c Number of implicit shifts to be applied.
c
c SHIFTR, Double precision array of length NP. (INPUT)
c SHIFTI Real and imaginary part of the shifts to be applied.
c Upon, entry to dnapps, the shifts must be sorted so that the
c conjugate pairs are in consecutive locations.
c
c V Double precision N by (KEV+NP) array. (INPUT/OUTPUT)
c On INPUT, V contains the current KEV+NP Arnoldi vectors.
c On OUTPUT, V contains the updated KEV Arnoldi vectors
c in the first KEV columns of V.
c
c LDV Integer. (INPUT)
c Leading dimension of V exactly as declared in the calling
c program.
c
c H Double precision (KEV+NP) by (KEV+NP) array. (INPUT/OUTPUT)
c On INPUT, H contains the current KEV+NP by KEV+NP upper
c Hessenber matrix of the Arnoldi factorization.
c On OUTPUT, H contains the updated KEV by KEV upper Hessenberg
c matrix in the KEV leading submatrix.
c
c LDH Integer. (INPUT)
c Leading dimension of H exactly as declared in the calling
c program.
c
c RESID Double precision array of length N. (INPUT/OUTPUT)
c On INPUT, RESID contains the the residual vector r_{k+p}.
c On OUTPUT, RESID is the update residual vector rnew_{k}
c in the first KEV locations.
c
c Q Double precision KEV+NP by KEV+NP work array. (WORKSPACE)
c Work array used to accumulate the rotations and reflections
c during the bulge chase sweep.
c
c LDQ Integer. (INPUT)
c Leading dimension of Q exactly as declared in the calling
c program.
c
c WORKL Double precision work array of length (KEV+NP). (WORKSPACE)
c Private (replicated) array on each PE or array allocated on
c the front end.
c
c WORKD Double precision work array of length 2*N. (WORKSPACE)
c Distributed array used in the application of the accumulated
c orthogonal matrix Q.
c
c\EndDoc
c
c-----------------------------------------------------------------------
c
c\BeginLib
c
c\Local variables:
c xxxxxx real
c
c\References:
c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in
c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992),
c pp 357-385.
c
c\Routines called:
c ivout ARPACK utility routine that prints integers.
c arscnd ARPACK utility routine for timing.
c dmout ARPACK utility routine that prints matrices.
c dvout ARPACK utility routine that prints vectors.
c dlabad LAPACK routine that computes machine constants.
c dlacpy LAPACK matrix copy routine.
c dlamch LAPACK routine that determines machine constants.
c dlanhs LAPACK routine that computes various norms of a matrix.
c dlapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully.
c dlarf LAPACK routine that applies Householder reflection to
c a matrix.
c dlarfg LAPACK Householder reflection construction routine.
c dlartg LAPACK Givens rotation construction routine.
c dlaset LAPACK matrix initialization routine.
c dgemv Level 2 BLAS routine for matrix vector multiplication.
c daxpy Level 1 BLAS that computes a vector triad.
c dcopy Level 1 BLAS that copies one vector to another .
c dscal Level 1 BLAS that scales 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/92: Version ' 2.4'
c
c\SCCS Information: @(#)
c FILE: napps.F SID: 2.4 DATE OF SID: 3/28/97 RELEASE: 2
c
c\Remarks
c 1. In this version, each shift is applied to all the sublocks of
c the Hessenberg matrix H and not just to the submatrix that it
c comes from. Deflation as in LAPACK routine dlahqr (QR algorithm
c for upper Hessenberg matrices ) is used.
c The subdiagonals of H are enforced to be non-negative.
c
c\EndLib
c
c-----------------------------------------------------------------------
c
subroutine dnapps
& ( n, kev, np, shiftr, shifti, v, ldv, h, ldh, resid, q, ldq,
& workl, workd )
c
c %----------------------------------------------------%
c | Include files for debugging and timing information |
c %----------------------------------------------------%
c
include 'debug.h'
include 'stat.h'
c
c %------------------%
c | Scalar Arguments |
c %------------------%
c
integer kev, ldh, ldq, ldv, n, np
c
c %-----------------%
c | Array Arguments |
c %-----------------%
c
Double precision
& h(ldh,kev+np), resid(n), shifti(np), shiftr(np),
& v(ldv,kev+np), q(ldq,kev+np), workd(2*n), workl(kev+np)
c
c %------------%
c | Parameters |
c %------------%
c
Double precision
& one, zero
parameter (one = 1.0D+0, zero = 0.0D+0)
c
c %------------------------%
c | Local Scalars & Arrays |
c %------------------------%
c
integer i, iend, ir, istart, j, jj, kplusp, msglvl, nr
logical cconj, first
Double precision
& c, f, g, h11, h12, h21, h22, h32, ovfl, r, s, sigmai,
& sigmar, smlnum, ulp, unfl, u(3), t, tau, tst1
save first, ovfl, smlnum, ulp, unfl
c
c %----------------------%
c | External Subroutines |
c %----------------------%
c
external daxpy, dcopy, dscal, dlacpy, dlarfg, dlarf,
& dlaset, dlabad, arscnd, dlartg
c
c %--------------------%
c | External Functions |
c %--------------------%
c
Double precision
& dlamch, dlanhs, dlapy2
external dlamch, dlanhs, dlapy2
c
c %----------------------%
c | Intrinsics Functions |
c %----------------------%
c
intrinsic abs, max, min
c
c %----------------%
c | Data statments |
c %----------------%
c
data first / .true. /
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
c
if (first) then
c
c %-----------------------------------------------%
c | Set machine-dependent constants for the |
c | stopping criterion. If norm(H) <= sqrt(OVFL), |
c | overflow should not occur. |
c | REFERENCE: LAPACK subroutine dlahqr |
c %-----------------------------------------------%
c
unfl = dlamch( 'safe minimum' )
ovfl = one / unfl
call dlabad( unfl, ovfl )
ulp = dlamch( 'precision' )
smlnum = unfl*( n / ulp )
first = .false.
end if
c
c %-------------------------------%
c | Initialize timing statistics |
c | & message level for debugging |
c %-------------------------------%
c
call arscnd (t0)
msglvl = mnapps
kplusp = kev + np
c
c %--------------------------------------------%
c | Initialize Q to the identity to accumulate |
c | the rotations and reflections |
c %--------------------------------------------%
c
call dlaset ('All', kplusp, kplusp, zero, one, q, ldq)
c
c %----------------------------------------------%
c | Quick return if there are no shifts to apply |
c %----------------------------------------------%
c
if (np .eq. 0) go to 9000
c
c %----------------------------------------------%
c | Chase the bulge with the application of each |
c | implicit shift. Each shift is applied to the |
c | whole matrix including each block. |
c %----------------------------------------------%
c
cconj = .false.
do 110 jj = 1, np
sigmar = shiftr(jj)
sigmai = shifti(jj)
c
if (msglvl .gt. 2 ) then
call ivout (logfil, 1, jj, ndigit,
& '_napps: shift number.')
call dvout (logfil, 1, sigmar, ndigit,
& '_napps: The real part of the shift ')
call dvout (logfil, 1, sigmai, ndigit,
& '_napps: The imaginary part of the shift ')
end if
c
c %-------------------------------------------------%
c | The following set of conditionals is necessary |
c | in order that complex conjugate pairs of shifts |
c | are applied together or not at all. |
c %-------------------------------------------------%
c
if ( cconj ) then
c
c %-----------------------------------------%
c | cconj = .true. means the previous shift |
c | had non-zero imaginary part. |
c %-----------------------------------------%
c
cconj = .false.
go to 110
else if ( jj .lt. np .and. abs( sigmai ) .gt. zero ) then
c
c %------------------------------------%
c | Start of a complex conjugate pair. |
c %------------------------------------%
c
cconj = .true.
else if ( jj .eq. np .and. abs( sigmai ) .gt. zero ) then
c
c %----------------------------------------------%
c | The last shift has a nonzero imaginary part. |
c | Don't apply it; thus the order of the |
c | compressed H is order KEV+1 since only np-1 |
c | were applied. |
c %----------------------------------------------%
c
kev = kev + 1
go to 110
end if
istart = 1
20 continue
c
c %--------------------------------------------------%
c | if sigmai = 0 then |
c | Apply the jj-th shift ... |
c | else |
c | Apply the jj-th and (jj+1)-th together ... |
c | (Note that jj < np at this point in the code) |
c | end |
c | to the current block of H. The next do loop |
c | determines the current block ; |
c %--------------------------------------------------%
c
do 30 i = istart, kplusp-1
c
c %----------------------------------------%
c | Check for splitting and deflation. Use |
c | a standard test as in the QR algorithm |
c | REFERENCE: LAPACK subroutine dlahqr |
c %----------------------------------------%
c
tst1 = abs( h( i, i ) ) + abs( h( i+1, i+1 ) )
if( tst1.eq.zero )
& tst1 = dlanhs( '1', kplusp-jj+1, h, ldh, workl )
if( abs( h( i+1,i ) ).le.max( ulp*tst1, smlnum ) ) then
if (msglvl .gt. 0) then
call ivout (logfil, 1, i, ndigit,
& '_napps: matrix splitting at row/column no.')
call ivout (logfil, 1, jj, ndigit,
& '_napps: matrix splitting with shift number.')
call dvout (logfil, 1, h(i+1,i), ndigit,
& '_napps: off diagonal element.')
end if
iend = i
h(i+1,i) = zero
go to 40
end if
30 continue
iend = kplusp
40 continue
c
if (msglvl .gt. 2) then
call ivout (logfil, 1, istart, ndigit,
& '_napps: Start of current block ')
call ivout (logfil, 1, iend, ndigit,
& '_napps: End of current block ')
end if
c
c %------------------------------------------------%
c | No reason to apply a shift to block of order 1 |
c %------------------------------------------------%
c
if ( istart .eq. iend ) go to 100
c
c %------------------------------------------------------%
c | If istart + 1 = iend then no reason to apply a |
c | complex conjugate pair of shifts on a 2 by 2 matrix. |
c %------------------------------------------------------%
c
if ( istart + 1 .eq. iend .and. abs( sigmai ) .gt. zero )
& go to 100
c
h11 = h(istart,istart)
h21 = h(istart+1,istart)
if ( abs( sigmai ) .le. zero ) then
c
c %---------------------------------------------%
c | Real-valued shift ==> apply single shift QR |
c %---------------------------------------------%
c
f = h11 - sigmar
g = h21
c
do 80 i = istart, iend-1
c
c %-----------------------------------------------------%
c | Contruct the plane rotation G to zero out the bulge |
c %-----------------------------------------------------%
c
call dlartg (f, g, c, s, r)
if (i .gt. istart) then
c
c %-------------------------------------------%
c | The following ensures that h(1:iend-1,1), |
c | the first iend-2 off diagonal of elements |
c | H, remain non negative. |
c %-------------------------------------------%
c
if (r .lt. zero) then
r = -r
c = -c
s = -s
end if
h(i,i-1) = r
h(i+1,i-1) = zero
end if
c
c %---------------------------------------------%
c | Apply rotation to the left of H; H <- G'*H |
c %---------------------------------------------%
c
do 50 j = i, kplusp
t = c*h(i,j) + s*h(i+1,j)
h(i+1,j) = -s*h(i,j) + c*h(i+1,j)
h(i,j) = t
50 continue
c
c %---------------------------------------------%
c | Apply rotation to the right of H; H <- H*G |
c %---------------------------------------------%
c
do 60 j = 1, min(i+2,iend)
t = c*h(j,i) + s*h(j,i+1)
h(j,i+1) = -s*h(j,i) + c*h(j,i+1)
h(j,i) = t
60 continue
c
c %----------------------------------------------------%
c | Accumulate the rotation in the matrix Q; Q <- Q*G |
c %----------------------------------------------------%
c
do 70 j = 1, min( i+jj, kplusp )
t = c*q(j,i) + s*q(j,i+1)
q(j,i+1) = - s*q(j,i) + c*q(j,i+1)
q(j,i) = t
70 continue
c
c %---------------------------%
c | Prepare for next rotation |
c %---------------------------%
c
if (i .lt. iend-1) then
f = h(i+1,i)
g = h(i+2,i)
end if
80 continue
c
c %-----------------------------------%
c | Finished applying the real shift. |
c %-----------------------------------%
c
else
c
c %----------------------------------------------------%
c | Complex conjugate shifts ==> apply double shift QR |
c %----------------------------------------------------%
c
h12 = h(istart,istart+1)
h22 = h(istart+1,istart+1)
h32 = h(istart+2,istart+1)
c
c %---------------------------------------------------------%
c | Compute 1st column of (H - shift*I)*(H - conj(shift)*I) |
c %---------------------------------------------------------%
c
s = 2.0*sigmar
t = dlapy2 ( sigmar, sigmai )
u(1) = ( h11 * (h11 - s) + t * t ) / h21 + h12
u(2) = h11 + h22 - s
u(3) = h32
c
do 90 i = istart, iend-1
c
nr = min ( 3, iend-i+1 )
c
c %-----------------------------------------------------%
c | Construct Householder reflector G to zero out u(1). |
c | G is of the form I - tau*( 1 u )' * ( 1 u' ). |
c %-----------------------------------------------------%
c
call dlarfg ( nr, u(1), u(2), 1, tau )
c
if (i .gt. istart) then
h(i,i-1) = u(1)
h(i+1,i-1) = zero
if (i .lt. iend-1) h(i+2,i-1) = zero
end if
u(1) = one
c
c %--------------------------------------%
c | Apply the reflector to the left of H |
c %--------------------------------------%
c
call dlarf ('Left', nr, kplusp-i+1, u, 1, tau,
& h(i,i), ldh, workl)
c
c %---------------------------------------%
c | Apply the reflector to the right of H |
c %---------------------------------------%
c
ir = min ( i+3, iend )
call dlarf ('Right', ir, nr, u, 1, tau,
& h(1,i), ldh, workl)
c
c %-----------------------------------------------------%
c | Accumulate the reflector in the matrix Q; Q <- Q*G |
c %-----------------------------------------------------%
c
call dlarf ('Right', kplusp, nr, u, 1, tau,
& q(1,i), ldq, workl)
c
c %----------------------------%
c | Prepare for next reflector |
c %----------------------------%
c
if (i .lt. iend-1) then
u(1) = h(i+1,i)
u(2) = h(i+2,i)
if (i .lt. iend-2) u(3) = h(i+3,i)
end if
c
90 continue
c
c %--------------------------------------------%
c | Finished applying a complex pair of shifts |
c | to the current block |
c %--------------------------------------------%
c
end if
c
100 continue
c
c %---------------------------------------------------------%
c | Apply the same shift to the next block if there is any. |
c %---------------------------------------------------------%
c
istart = iend + 1
if (iend .lt. kplusp) go to 20
c
c %---------------------------------------------%
c | Loop back to the top to get the next shift. |
c %---------------------------------------------%
c
110 continue
c
c %--------------------------------------------------%
c | Perform a similarity transformation that makes |
c | sure that H will have non negative sub diagonals |
c %--------------------------------------------------%
c
do 120 j=1,kev
if ( h(j+1,j) .lt. zero ) then
call dscal( kplusp-j+1, -one, h(j+1,j), ldh )
call dscal( min(j+2, kplusp), -one, h(1,j+1), 1 )
call dscal( min(j+np+1,kplusp), -one, q(1,j+1), 1 )
end if
120 continue
c
do 130 i = 1, kev
c
c %--------------------------------------------%
c | Final check for splitting and deflation. |
c | Use a standard test as in the QR algorithm |
c | REFERENCE: LAPACK subroutine dlahqr |
c %--------------------------------------------%
c
tst1 = abs( h( i, i ) ) + abs( h( i+1, i+1 ) )
if( tst1.eq.zero )
& tst1 = dlanhs( '1', kev, h, ldh, workl )
if( h( i+1,i ) .le. max( ulp*tst1, smlnum ) )
& h(i+1,i) = zero
130 continue
c
c %-------------------------------------------------%
c | Compute the (kev+1)-st column of (V*Q) and |
c | temporarily store the result in WORKD(N+1:2*N). |
c | This is needed in the residual update since we |
c | cannot GUARANTEE that the corresponding entry |
c | of H would be zero as in exact arithmetic. |
c %-------------------------------------------------%
c
if (h(kev+1,kev) .gt. zero)
& call dgemv ('N', n, kplusp, one, v, ldv, q(1,kev+1), 1, zero,
& workd(n+1), 1)
c
c %----------------------------------------------------------%
c | Compute column 1 to kev of (V*Q) in backward order |
c | taking advantage of the upper Hessenberg structure of Q. |
c %----------------------------------------------------------%
c
do 140 i = 1, kev
call dgemv ('N', n, kplusp-i+1, one, v, ldv,
& q(1,kev-i+1), 1, zero, workd, 1)
call dcopy (n, workd, 1, v(1,kplusp-i+1), 1)
140 continue
c
c %-------------------------------------------------%
c | Move v(:,kplusp-kev+1:kplusp) into v(:,1:kev). |
c %-------------------------------------------------%
c
call dlacpy ('A', n, kev, v(1,kplusp-kev+1), ldv, v, ldv)
c
c %--------------------------------------------------------------%
c | Copy the (kev+1)-st column of (V*Q) in the appropriate place |
c %--------------------------------------------------------------%
c
if (h(kev+1,kev) .gt. zero)
& call dcopy (n, workd(n+1), 1, v(1,kev+1), 1)
c
c %-------------------------------------%
c | Update the residual vector: |
c | r <- sigmak*r + betak*v(:,kev+1) |
c | where |
c | sigmak = (e_{kplusp}'*Q)*e_{kev} |
c | betak = e_{kev+1}'*H*e_{kev} |
c %-------------------------------------%
c
call dscal (n, q(kplusp,kev), resid, 1)
if (h(kev+1,kev) .gt. zero)
& call daxpy (n, h(kev+1,kev), v(1,kev+1), 1, resid, 1)
c
if (msglvl .gt. 1) then
call dvout (logfil, 1, q(kplusp,kev), ndigit,
& '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
call dvout (logfil, 1, h(kev+1,kev), ndigit,
& '_napps: betak = e_{kev+1}^T*H*e_{kev}')
call ivout (logfil, 1, kev, ndigit,
& '_napps: Order of the final Hessenberg matrix ')
if (msglvl .gt. 2) then
call dmout (logfil, kev, kev, h, ldh, ndigit,
& '_napps: updated Hessenberg matrix H for next iteration')
end if
c
end if
c
9000 continue
call arscnd (t1)
tnapps = tnapps + (t1 - t0)
c
return
c
c %---------------%
c | End of dnapps |
c %---------------%
c
end
| bsd-3-clause |
olpotkin/CarND-Path-Planning | src/Eigen-3.3/lapack/iladlr.f | 271 | 3000 | *> \brief \b ILADLR
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download ILADLR + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/iladlr.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/iladlr.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/iladlr.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* INTEGER FUNCTION ILADLR( M, N, A, LDA )
*
* .. Scalar Arguments ..
* INTEGER M, N, LDA
* ..
* .. Array Arguments ..
* DOUBLE PRECISION A( LDA, * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ILADLR scans A for its last non-zero row.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> The number of rows of the matrix A.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of columns of the matrix A.
*> \endverbatim
*>
*> \param[in] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (LDA,N)
*> The m by n matrix A.
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of the array A. LDA >= max(1,M).
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date April 2012
*
*> \ingroup auxOTHERauxiliary
*
* =====================================================================
INTEGER FUNCTION ILADLR( M, N, A, LDA )
*
* -- LAPACK auxiliary 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 ..
INTEGER M, N, LDA
* ..
* .. Array Arguments ..
DOUBLE PRECISION A( LDA, * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO
PARAMETER ( ZERO = 0.0D+0 )
* ..
* .. Local Scalars ..
INTEGER I, J
* ..
* .. Executable Statements ..
*
* Quick test for the common case where one corner is non-zero.
IF( M.EQ.0 ) THEN
ILADLR = M
ELSE IF( A(M, 1).NE.ZERO .OR. A(M, N).NE.ZERO ) THEN
ILADLR = M
ELSE
* Scan up each column tracking the last zero row seen.
ILADLR = 0
DO J = 1, N
I=M
DO WHILE((A(MAX(I,1),J).EQ.ZERO).AND.(I.GE.1))
I=I-1
ENDDO
ILADLR = MAX( ILADLR, I )
END DO
END IF
RETURN
END
| mit |
aosm/llvmgcc42 | gcc/testsuite/gfortran.dg/namelist_18.f90 | 16 | 1068 | !{ dg-do run }
! Tests character delimiters for namelist write
! provided by Paul Thomas - pault@gcc.gnu.org
program namelist_18
character*3 :: ch = "foo"
character*80 :: buffer
namelist /mynml/ ch
open (10, status = "scratch")
write (10, mynml)
rewind (10)
read (10, '(a)', iostat = ier) buffer
read (10, '(a)', iostat = ier) buffer
if (ier .ne. 0) call abort ()
close (10)
If ((buffer(5:5) /= "f") .or. (buffer(9:9) /= " ")) call abort ()
open (10, status = "scratch", delim ="quote")
write (10, mynml)
rewind (10)
read (10, '(a)', iostat = ier) buffer
read (10, '(a)', iostat = ier) buffer
if (ier .ne. 0) call abort ()
close (10)
If ((buffer(5:5) /= """") .or. (buffer(9:9) /= """")) call abort ()
open (10, status = "scratch", delim ="apostrophe")
write (10, mynml)
rewind (10)
read (10, '(a)', iostat = ier) buffer
read (10, '(a)', iostat = ier) buffer
if (ier .ne. 0) call abort ()
close (10)
If ((buffer(5:5) /= "'") .or. (buffer(9:9) /= "'")) call abort ()
end program namelist_18
| gpl-2.0 |
nisihara1/q-e | PP/src/local_dos.f90 | 4 | 17829 | !
! 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 local_dos (iflag, lsign, kpoint, kband, spin_component, &
emin, emax, dos)
!--------------------------------------------------------------------
!
! iflag=0: calculates |psi|^2 for band "kband" at point "kpoint"
! iflag=1: calculates the local density of state at e_fermi
! (only for metals)
! iflag=2: calculates the local density of electronic entropy
! (only for metals with fermi spreading)
! iflag=3: calculates the integral of local dos from "emin" to "emax"
! (emin, emax in Ry)
!
! lsign: if true and k=gamma and iflag=0, write |psi|^2 * sign(psi)
! spin_component: for iflag=3 and LSDA calculations only
! 0 for up+down dos, 1 for up dos, 2 for down dos
!
USE kinds, ONLY : DP
USE cell_base, ONLY : omega
USE ions_base, ONLY : nat, ntyp => nsp, ityp
USE ener, ONLY : ef
USE fft_base, ONLY : dffts, dfftp
USE fft_interfaces, ONLY : fwfft, invfft
USE gvect, ONLY : nl, ngm, g
USE gvecs, ONLY : nls, nlsm, doublegrid
USE klist, ONLY : lgauss, degauss, ngauss, nks, wk, xk, &
nkstot, ngk, igk_k
USE lsda_mod, ONLY : lsda, nspin, current_spin, isk
USE scf, ONLY : rho
USE symme, ONLY : sym_rho, sym_rho_init, sym_rho_deallocate
USE uspp, ONLY : nkb, vkb, becsum, nhtol, nhtoj, indv
USE uspp_param, ONLY : upf, nh, nhm
USE wavefunctions_module, ONLY : evc, psic, psic_nc
USE wvfct, ONLY : nbnd, npwx, wg, et
USE control_flags, ONLY : gamma_only
USE noncollin_module, ONLY : noncolin, npol
USE spin_orb, ONLY : lspinorb, fcoef
USE io_files, ONLY : iunwfc, nwordwfc
USE mp_global, ONLY : me_pool, nproc_pool, my_pool_id, npool
USE mp, ONLY : mp_bcast, mp_sum
USE mp_global, ONLY : inter_pool_comm, intra_pool_comm
USE becmod, ONLY : calbec
USE control_flags, ONLY : tqr
USE realus, ONLY : addusdens_r
IMPLICIT NONE
!
! input variables
!
INTEGER, INTENT(in) :: iflag, kpoint, kband, spin_component
LOGICAL, INTENT(in) :: lsign
REAL(DP), INTENT(in) :: emin, emax
!
REAL(DP), INTENT(out) :: dos (dfftp%nnr)
!
! local variables
!
! counters for US PPs
INTEGER :: npw, ikb, jkb, ijkb0, ih, jh, kh, na, ijh, np
! counters
INTEGER :: ir, is, ig, ibnd, ik, irm, isup, isdw, ipol, kkb, is1, is2
REAL(DP) :: w, w1, modulus, wg_max
REAL(DP), ALLOCATABLE :: rbecp(:,:), segno(:), maxmod(:)
COMPLEX(DP), ALLOCATABLE :: becp(:,:), &
becp_nc(:,:,:), be1(:,:), be2(:,:)
INTEGER :: who_calculate, iproc
COMPLEX(DP) :: phase
REAL(DP), EXTERNAL :: w0gauss, w1gauss
LOGICAL :: i_am_the_pool
INTEGER :: which_pool, kpoint_pool
!
! input checks
!
IF (noncolin.and. lsign) CALL errore('local_dos','not available',1)
IF (noncolin.and. gamma_only) CALL errore('local_dos','not available',1)
!
IF ( (iflag == 0) .and. ( kband < 1 .or. kband > nbnd ) ) &
CALL errore ('local_dos', 'wrong band specified', 1)
IF ( (iflag == 0) .and. ( kpoint < 1 .or. kpoint > nkstot ) ) &
CALL errore ('local_dos', 'wrong kpoint specified', 1)
IF (lsign) THEN
IF (iflag /= 0) CALL errore ('local_dos', 'inconsistent flags', 1)
IF (sqrt(xk(1,kpoint)**2+xk(2,kpoint)**2+xk(3,kpoint)**2) > 1d-9 ) &
CALL errore ('local_dos', 'k must be zero', 1)
ENDIF
!
IF (gamma_only) THEN
ALLOCATE (rbecp(nkb,nbnd))
ELSE
IF (noncolin) THEN
ALLOCATE (becp_nc(nkb,npol,nbnd))
IF (lspinorb) THEN
ALLOCATE(be1(nhm,2))
ALLOCATE(be2(nhm,2))
ENDIF
ELSE
ALLOCATE (becp(nkb,nbnd))
ENDIF
ENDIF
rho%of_r(:,:) = 0.d0
dos(:) = 0.d0
becsum(:,:,:) = 0.d0
IF (lsign) ALLOCATE(segno(dfftp%nnr))
!
! calculate the correct weights
!
IF (iflag /= 0.and. iflag /=3 .and. .not.lgauss) CALL errore ('local_dos', &
'gaussian broadening needed', 1)
IF (iflag == 2 .and. ngauss /= -99) CALL errore ('local_dos', &
' beware: not using Fermi-Dirac function ', - ngauss)
DO ik = 1, nks
DO ibnd = 1, nbnd
IF (iflag == 0) THEN
wg (ibnd, ik) = 0.d0
ELSEIF (iflag == 1) THEN
! Local density of states at energy emin with broadening emax
wg(ibnd,ik) = wk(ik) * w0gauss((emin - et(ibnd, ik))/emax, ngauss) / emax
ELSEIF (iflag == 2) THEN
wg (ibnd, ik) = - wk (ik) * w1gauss ( (ef - et (ibnd, ik) ) &
/ degauss, ngauss)
ELSEIF (iflag == 3) THEN
IF (et (ibnd, ik) <= emax .and. et (ibnd, ik) >= emin) THEN
wg (ibnd, ik) = wk (ik)
ELSE
wg (ibnd, ik) = 0.d0
ENDIF
ELSE
CALL errore ('local_dos', ' iflag not allowed', abs (iflag) )
ENDIF
ENDDO
ENDDO
wg_max = MAXVAL(wg(:,:))
IF ( iflag == 0 .and. npool > 1 ) THEN
CALL xk_pool( kpoint, nkstot, kpoint_pool, which_pool )
IF ( kpoint_pool < 1 .or. kpoint_pool > nks ) &
CALL errore('local_dos','problems with xk_pool',1)
i_am_the_pool=(my_pool_id==which_pool)
ELSE
i_am_the_pool=.true.
kpoint_pool=kpoint
ENDIF
IF (iflag == 0.and.i_am_the_pool) wg (kband, kpoint_pool) = 1.d0
!
! here we sum for each k point the contribution
! of the wavefunctions to the density of states
!
DO ik = 1, nks
IF (ik == kpoint_pool .and.i_am_the_pool.or. iflag /= 0) THEN
IF (lsda) current_spin = isk (ik)
CALL davcio (evc, 2*nwordwfc, iunwfc, ik, - 1)
npw = ngk(ik)
CALL init_us_2 (npw, igk_k(1,ik), xk (1, ik), vkb)
IF (gamma_only) THEN
CALL calbec ( npw, vkb, evc, rbecp )
ELSEIF (noncolin) THEN
CALL calbec ( npw, vkb, evc, becp_nc )
ELSE
CALL calbec ( npw, vkb, evc, becp )
ENDIF
!
! here we compute the density of states
!
DO ibnd = 1, nbnd
! Neglect summands with relative weights below machine epsilon
IF ( wg(ibnd, ik) > epsilon(0.0_DP) * wg_max .and. &
(ibnd == kband .or. iflag /= 0)) THEN
IF (noncolin) THEN
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)
ENDDO
DO ipol=1,npol
CALL invfft ('Wave', psic_nc(:,ipol), dffts)
ENDDO
ELSE
psic(1:dffts%nnr) = (0.d0,0.d0)
DO ig = 1, npw
psic (nls (igk_k(ig,ik) ) ) = evc (ig, ibnd)
ENDDO
IF (gamma_only) THEN
DO ig = 1, npw
psic (nlsm(igk_k (ig,ik) ) ) = conjg(evc (ig, ibnd))
ENDDO
ENDIF
CALL invfft ('Wave', psic, dffts)
ENDIF
w1 = wg (ibnd, ik) / omega
!
! Compute and save the sign of the wavefunction at the gamma point
!
IF (lsign) THEN
IF (gamma_only) THEN
! psi(r) is real by construction
segno(1:dffts%nnr) = dble(psic(1:dffts%nnr))
ELSE
! determine the phase factor that makes psi(r) real.
ALLOCATE(maxmod(nproc_pool))
maxmod(me_pool+1)=0.0_DP
DO ir = 1, dffts%nnr
modulus=abs(psic(ir))
IF (modulus > maxmod(me_pool+1)) THEN
irm=ir
maxmod(me_pool+1)=modulus
ENDIF
ENDDO
who_calculate=1
#if defined(__MPI)
CALL mp_sum(maxmod,intra_pool_comm)
DO iproc=2,nproc_pool
IF (maxmod(iproc)>maxmod(who_calculate)) &
who_calculate=iproc
ENDDO
#endif
IF (maxmod(who_calculate) < 1.d-10) &
CALL errore('local_dos','zero wavefunction',1)
IF (me_pool+1==who_calculate) &
phase = psic(irm)/maxmod(who_calculate)
DEALLOCATE(maxmod)
#if defined(__MPI)
CALL mp_bcast(phase,who_calculate-1,intra_pool_comm)
#endif
segno(1:dffts%nnr) = dble( psic(1:dffts%nnr)*conjg(phase) )
ENDIF
IF (doublegrid) CALL interpolate (segno, segno, 1)
segno(:) = sign( 1.d0, segno(:) )
ENDIF
!
IF (noncolin) THEN
DO ipol=1,npol
DO ir=1,dffts%nnr
rho%of_r(ir,current_spin)=rho%of_r(ir,current_spin)+&
w1*(dble(psic_nc(ir,ipol))**2+ &
aimag(psic_nc(ir,ipol))**2)
ENDDO
ENDDO
ELSE
DO ir=1,dffts%nnr
rho%of_r(ir,current_spin)=rho%of_r(ir,current_spin) + &
w1 * (dble( psic (ir) ) **2 + aimag (psic (ir) ) **2)
ENDDO
ENDIF
!
! If we have a US pseudopotential we compute here the becsum term
!
w1 = wg (ibnd, ik)
ijkb0 = 0
DO np = 1, ntyp
IF (upf(np)%tvanp ) THEN
DO na = 1, nat
IF (ityp (na) == np) THEN
IF (noncolin) THEN
IF (upf(np)%has_so) THEN
be1=(0.d0,0.d0)
be2=(0.d0,0.d0)
DO ih = 1, nh(np)
ikb = ijkb0 + ih
DO kh = 1, nh(np)
IF ((nhtol(kh,np)==nhtol(ih,np)).and. &
(nhtoj(kh,np)==nhtoj(ih,np)).and. &
(indv(kh,np)==indv(ih,np))) THEN
kkb=ijkb0 + kh
DO is1=1,2
DO is2=1,2
be1(ih,is1)=be1(ih,is1)+ &
fcoef(ih,kh,is1,is2,np)* &
becp_nc(kkb,is2,ibnd)
be2(ih,is1)=be2(ih,is1)+ &
fcoef(kh,ih,is2,is1,np)* &
conjg(becp_nc(kkb,is2,ibnd))
ENDDO
ENDDO
ENDIF
ENDDO
ENDDO
ENDIF
ijh = 1
DO ih = 1, nh (np)
ikb = ijkb0 + ih
IF (upf(np)%has_so) THEN
becsum(ijh,na,1)=becsum(ijh,na,1)+ w1* &
(be1(ih,1)*be2(ih,1)+be1(ih,2)*be2(ih,2))
ELSE
becsum(ijh,na,1) = becsum(ijh,na,1)+ &
w1*(conjg(becp_nc(ikb,1,ibnd))* &
becp_nc(ikb,1,ibnd)+ &
conjg(becp_nc(ikb,2,ibnd))* &
becp_nc(ikb,2,ibnd))
ENDIF
ijh = ijh + 1
DO jh = ih + 1, nh (np)
jkb = ijkb0 + jh
IF (upf(np)%has_so) THEN
becsum(ijh,na,1)=becsum(ijh,na,1) &
+ w1*((be1(jh,1)*be2(ih,1)+ &
be1(jh,2)*be2(ih,2))+ &
(be1(ih,1)*be2(jh,1)+ &
be1(ih,2)*be2(jh,2)) )
ELSE
becsum(ijh,na,1)= becsum(ijh,na,1)+ &
w1*2.d0*dble(conjg(becp_nc(ikb,1,ibnd)) &
*becp_nc(jkb,1,ibnd) + &
conjg(becp_nc(ikb,2,ibnd)) &
*becp_nc(jkb,2,ibnd) )
ENDIF
ijh = ijh + 1
ENDDO
ENDDO
ELSE
ijh = 1
DO ih = 1, nh (np)
ikb = ijkb0 + ih
IF (gamma_only) THEN
becsum(ijh,na,current_spin) = &
becsum(ijh,na,current_spin) + w1 * &
rbecp(ikb,ibnd)*rbecp(ikb,ibnd)
ELSE
becsum(ijh,na,current_spin) = &
becsum(ijh,na,current_spin) + w1 * &
dble(conjg(becp(ikb,ibnd))*becp(ikb,ibnd))
ENDIF
ijh = ijh + 1
DO jh = ih + 1, nh (np)
jkb = ijkb0 + jh
IF (gamma_only) THEN
becsum(ijh,na,current_spin) = &
becsum(ijh,na,current_spin) + 2.d0*w1 * &
rbecp(ikb,ibnd)*rbecp(jkb,ibnd)
ELSE
becsum(ijh,na,current_spin) = &
becsum(ijh,na,current_spin) + 2.d0*w1 * &
dble(conjg(becp(ikb,ibnd))*becp(jkb,ibnd))
ENDIF
ijh = ijh + 1
ENDDO
ENDDO
ENDIF
ijkb0 = ijkb0 + nh (np)
ENDIF
ENDDO
ELSE
DO na = 1, nat
IF (ityp (na) == np) ijkb0 = ijkb0 + nh (np)
ENDDO
ENDIF
ENDDO
ENDIF
ENDDO ! loop over bands
ENDIF
ENDDO ! loop over k-points
IF (gamma_only) THEN
DEALLOCATE(rbecp)
ELSE
IF (noncolin) THEN
IF (lspinorb) THEN
DEALLOCATE(be1)
DEALLOCATE(be2)
ENDIF
DEALLOCATE(becp_nc)
ELSE
DEALLOCATE(becp)
ENDIF
ENDIF
IF (doublegrid) THEN
IF (noncolin) THEN
CALL interpolate(rho%of_r, rho%of_r, 1)
ELSE
DO is = 1, nspin
CALL interpolate(rho%of_r(1, is), rho%of_r(1, is), 1)
ENDDO
ENDIF
ENDIF
!
! Here we add the US contribution to the charge
!
IF ( tqr ) THEN
CALL addusdens_r(rho%of_r(:,:),.false.)
ELSE
!
CALL addusdens(rho%of_r(:,:))
!
ENDIF
!
IF (nspin == 1 .or. nspin==4) THEN
is = 1
dos(:) = rho%of_r (:, is)
ELSE
IF ( iflag==3 .and. (spin_component==1 .or. spin_component==2 ) ) THEN
dos(:) = rho%of_r (:, spin_component)
ELSE
isup = 1
isdw = 2
dos(:) = rho%of_r (:, isup) + rho%of_r (:, isdw)
ENDIF
ENDIF
IF (lsign) THEN
dos(:) = dos(:) * segno(:)
DEALLOCATE(segno)
ENDIF
#if defined(__MPI)
CALL mp_sum( dos, inter_pool_comm )
#endif
IF (iflag == 0 .or. gamma_only) RETURN
!
! symmetrization of the local dos
!
CALL sym_rho_init (gamma_only )
!
psic(:) = cmplx ( dos(:), 0.0_dp, kind=dp)
CALL fwfft ('Dense', psic, dfftp)
rho%of_g(:,1) = psic(nl(:))
!
CALL sym_rho (1, rho%of_g)
!
psic(:) = (0.0_dp, 0.0_dp)
psic(nl(:)) = rho%of_g(:,1)
CALL invfft ('Dense', psic, dfftp)
dos(:) = dble(psic(:))
!
CALL sym_rho_deallocate()
!
RETURN
END SUBROUTINE local_dos
!------------------------------------------------------------------------
SUBROUTINE xk_pool( ik, nkstot, ik_pool, which_pool )
!------------------------------------------------------------------------
!
! This routine is a simplified version of set_kpoint_vars in
! xml_io_files. It receives the index ik of a k_point in the complete
! k point list and return the index within the pool ik_pool, and
! the number of the pool that has that k point.
!
!
USE mp_global, ONLY : npool, kunit
!
IMPLICIT NONE
INTEGER, INTENT(in) :: ik, nkstot
INTEGER, INTENT(out) :: ik_pool, which_pool
!
INTEGER :: nkl, nkr, nkbl
!
!
IF (npool==1) THEN
which_pool=1
ik_pool=ik
RETURN
ENDIF
!
! ... find out number of k points blocks
!
nkbl = nkstot / kunit
!
! ... k points per pool
!
nkl = kunit * ( nkbl / npool )
!
! ... find out the reminder
!
nkr = ( nkstot - nkl * npool ) / kunit
!
! ... calculate the pool and the index within the pool
!
IF (ik<=nkr*(nkl+1)) THEN
which_pool=(ik-1)/(nkl+1)
ik_pool=ik-which_pool*(nkl+1)
ELSE
which_pool=nkr+(ik-nkr*(nkl+1)-1)/nkl
ik_pool=ik-nkr*(nkl+1)-(which_pool-nkr)*nkl
ENDIF
RETURN
END SUBROUTINE xk_pool
| gpl-2.0 |
rongzhen/FPLAPW-KP | src/src_advanced/exxengyk.f90 | 1 | 9310 | !
!
!
! Copyright (C) 2002-2005 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 exxengyk (ikp, evv, ecv)
Use modmain
Use modinput
Implicit None
! arguments
Integer, Intent (In) :: ikp
Real (8), Intent (Inout) :: evv
Real (8), Intent (Inout) :: ecv
! local variables
Integer :: ngknr, ik, ist, jst
Integer :: is, ia, ias, nrc, m, lmax
Integer :: iv (3), iq, ig, igq0
Real (8) :: cfq, v (3), t1
Complex (8) zrho0, zt1
! automatic arrays
Real (8) :: zn (nspecies)
! allocatable arrays
Integer, Allocatable :: igkignr (:)
Real (8), Allocatable :: vgklnr (:, :)
Real (8), Allocatable :: vgkcnr (:, :)
Real (8), Allocatable :: gkcnr (:)
Real (8), Allocatable :: tpgkcnr (:, :)
Real (8), Allocatable :: vgqc (:, :)
Real (8), Allocatable :: tpgqc (:, :)
Real (8), Allocatable :: gqc (:)
Real (8), Allocatable :: jlgqr (:, :, :)
Real (8), Allocatable :: evalsvp (:)
Real (8), Allocatable :: evalsvnr (:)
Complex (8), Allocatable :: sfacgknr (:, :)
Complex (8), Allocatable :: apwalm (:, :, :, :)
Complex (8), Allocatable :: evecfv (:, :)
Complex (8), Allocatable :: evecsv (:, :)
Complex (8), Allocatable :: ylmgq (:, :)
Complex (8), Allocatable :: sfacgq (:, :)
Complex (8), Allocatable :: wfmt1 (:, :, :, :, :)
Complex (8), Allocatable :: wfmt2 (:, :, :, :, :)
Complex (8), Allocatable :: wfir1 (:, :, :)
Complex (8), Allocatable :: wfir2 (:, :, :)
Complex (8), Allocatable :: wfcr (:, :, :)
Complex (8), Allocatable :: zrhomt (:, :, :)
Complex (8), Allocatable :: zrhoir (:)
Complex (8), Allocatable :: zvclmt (:, :, :)
Complex (8), Allocatable :: zvclir (:)
Complex (8), Allocatable :: zfmt (:, :)
! external functions
Complex (8) zfinp, zfmtinp
External zfinp, zfmtinp
! allocate local arrays
Allocate (igkignr(ngkmax))
Allocate (vgklnr(3, ngkmax))
Allocate (vgkcnr(3, ngkmax))
Allocate (gkcnr(ngkmax))
Allocate (tpgkcnr(2, ngkmax))
Allocate (vgqc(3, ngvec))
Allocate (tpgqc(2, ngvec))
Allocate (gqc(ngvec))
Allocate &
& (jlgqr(0:input%groundstate%lmaxvr+input%groundstate%npsden+1, &
& ngvec, nspecies))
Allocate (evalsvp(nstsv))
Allocate (evalsvnr(nstsv))
Allocate (sfacgknr(ngkmax, natmtot))
Allocate (ylmgq(lmmaxvr, ngvec))
Allocate (sfacgq(ngvec, natmtot))
Allocate (apwalm(ngkmax, apwordmax, lmmaxapw, natmtot))
Allocate (evecfv(nmatmax, nstfv))
Allocate (evecsv(nstsv, nstsv))
Allocate (wfmt1(lmmaxvr, nrcmtmax, natmtot, nspinor, nstsv))
Allocate (wfmt2(lmmaxvr, nrcmtmax, natmtot, nspinor, nstsv))
Allocate (wfir1(ngrtot, nspinor, nstsv))
Allocate (wfir2(ngrtot, nspinor, nstsv))
Allocate (zrhomt(lmmaxvr, nrcmtmax, natmtot))
Allocate (zrhoir(ngrtot))
Allocate (zvclmt(lmmaxvr, nrcmtmax, natmtot))
Allocate (zvclir(ngrtot))
Allocate (wfcr(lmmaxvr, nrcmtmax, 2))
Allocate (zfmt(lmmaxvr, nrcmtmax))
! coefficient for long-range term
cfq = 0.5d0 * (omega/pi) ** 2
! set the nuclear charges to zero
zn (:) = 0.d0
! get the eigenvalues/vectors from file for input k-point
Call getevalsv (vkl(:, ikp), evalsvp)
Call getevecfv (vkl(:, ikp), vgkl(:, :, :, ikp), evecfv)
Call getevecsv (vkl(:, ikp), evecsv)
! find the matching coefficients
Call match (ngk(1, ikp), gkc(:, 1, ikp), tpgkc(:, :, 1, ikp), &
& sfacgk(:, :, 1, ikp), apwalm)
! calculate the wavefunctions for occupied states for the input k-point
Call genwfsv (.True., ngk(1, ikp), igkig(:, 1, ikp), evalsvp, &
& apwalm, evecfv, evecsv, wfmt1, wfir1)
! start loop over non-reduced k-point set
Do ik = 1, nkptnr
! generate G+k vectors
Call gengpvec (vklnr(:, ik), vkcnr(:, ik), ngknr, igkignr, &
& vgklnr, vgkcnr, gkcnr, tpgkcnr)
! get the eigenvalues/vectors from file for non-reduced k-points
Call getevalsv (vklnr(:, ik), evalsvnr)
Call getevecfv (vklnr(:, ik), vgklnr, evecfv)
Call getevecsv (vklnr(:, ik), evecsv)
! generate the structure factors
Call gensfacgp (ngknr, vgkcnr, ngkmax, sfacgknr)
! find the matching coefficients
Call match (ngknr, gkcnr, tpgkcnr, sfacgknr, apwalm)
! determine q-vector
iv (:) = ivk (:, ikp) - ivknr (:, ik)
iv (:) = modulo (iv(:), input%groundstate%ngridk(:))
iq = iqmap (iv(1), iv(2), iv(3))
v (:) = vkc (:, ikp) - vkcnr (:, ik)
Do ig = 1, ngvec
! determine G+q vectors
vgqc (:, ig) = vgc (:, ig) + v (:)
! G+q-vector length and (theta, phi) coordinates
Call sphcrd (vgqc(:, ig), gqc(ig), tpgqc(:, ig))
! spherical harmonics for G+q-vectors
Call genylm (input%groundstate%lmaxvr, tpgqc(:, ig), &
& ylmgq(:, ig))
End Do
! structure factor for G+q
Call gensfacgp (ngvec, vgqc, ngvec, sfacgq)
! find the shortest G+q-vector
Call findigp0 (ngvec, gqc, igq0)
! compute the required spherical Bessel functions
lmax = input%groundstate%lmaxvr + input%groundstate%npsden + 1
Call genjlgpr (lmax, gqc, jlgqr)
! calculate the wavefunctions for occupied states
Call genwfsv (.True., ngknr, igkignr, evalsvnr, apwalm, &
& evecfv, evecsv, wfmt2, wfir2)
!--------------------------------------------!
! valence-valence-valence contribution !
!--------------------------------------------!
Do jst = 1, nstsv
If (evalsvnr(jst) .Lt. efermi) Then
Do ist = 1, nstsv
If (evalsvp(ist) .Lt. efermi) Then
! calculate the complex overlap density
Call vnlrho (.True., wfmt2(:, :, :, :, jst), &
& wfmt1(:, :, :, :, ist), wfir2(:, :, jst), &
& wfir1(:, :, ist), zrhomt, zrhoir)
! calculate the Coulomb potential
Call zpotcoul (nrcmt, nrcmtmax, nrcmtmax, rcmt, &
& igq0, gqc, jlgqr, ylmgq, sfacgq, zn, zrhomt, &
& zrhoir, zvclmt, zvclir, zrho0)
zt1 = zfinp (.True., zrhomt, zvclmt, zrhoir, &
& zvclir)
t1 = cfq * wiq2 (iq) * &
& (dble(zrho0)**2+aimag(zrho0)**2)
!$OMP CRITICAL
evv = evv - 0.5d0 * occmax * wkpt (ikp) * &
& (wkptnr(ik)*dble(zt1)+t1)
!$OMP END CRITICAL
! end loop over ist
End If
End Do
! end loop over jst
End If
End Do
! end loop over non-reduced k-point set
End Do
!-----------------------------------------!
! valence-core-valence contribution !
!-----------------------------------------!
! begin loops over atoms and species
Do is = 1, nspecies
nrc = nrcmt (is)
Do ia = 1, natoms (is)
ias = idxas (ia, is)
Do jst = 1, spnst (is)
If (spcore(jst, is)) Then
Do m = - spk (jst, is), spk (jst, is) - 1
! pass m-1/2 to wavefcr
Call wavefcr (input%groundstate%lradstep, is, ia, &
& jst, m, nrcmtmax, wfcr)
Do ist = 1, nstsv
If (evalsvp(ist) .Lt. efermi) Then
! calculate the complex overlap density
Call vnlrhomt (.True., is, wfcr(:, :, 1), &
& wfmt1(:, :, ias, 1, ist), zrhomt(:, :, &
& ias))
If (associated(input%groundstate%spin)) Then
Call vnlrhomt (.True., is, wfcr(:, :, 2), &
& wfmt1(:, :, ias, 2, ist), zfmt)
zrhomt (:, 1:nrc, ias) = zrhomt (:, &
& 1:nrc, ias) + zfmt (:, 1:nrc)
End If
! calculate the Coulomb potential
Call zpotclmt (input%groundstate%ptnucl, &
& input%groundstate%lmaxvr, nrc, rcmt(:, is), &
& 0.d0, lmmaxvr, zrhomt(:, :, ias), zvclmt(:, &
& :, ias))
zt1 = zfmtinp (.True., &
& input%groundstate%lmaxvr, nrc, rcmt(:, is), &
& lmmaxvr, zrhomt(:, :, ias), zvclmt(:, :, &
& ias))
!$OMP CRITICAL
ecv = ecv - occmax * wkpt (ikp) * dble (zt1)
!$OMP END CRITICAL
! end loop over ist
End If
End Do
! end loop over m
End Do
! end loop over jst
End If
End Do
! end loops over atoms and species
End Do
End Do
Deallocate (igkignr, vgklnr, vgkcnr, gkcnr, tpgkcnr)
Deallocate (vgqc, tpgqc, gqc, jlgqr)
Deallocate (evalsvp, evalsvnr, evecfv, evecsv)
Deallocate (sfacgknr, apwalm, ylmgq, sfacgq)
Deallocate (wfmt1, wfmt2, wfir1, wfir2, wfcr)
Deallocate (zrhomt, zrhoir, zvclmt, zvclir, zfmt)
Return
End Subroutine
| lgpl-2.1 |
carlren/CuCV | CuCV/3rdparty/Eigen/lapack/sladiv.f | 272 | 2897 | *> \brief \b SLADIV
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download SLADIV + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sladiv.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sladiv.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sladiv.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE SLADIV( A, B, C, D, P, Q )
*
* .. Scalar Arguments ..
* REAL A, B, C, D, P, Q
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SLADIV performs complex division in real arithmetic
*>
*> a + i*b
*> p + i*q = ---------
*> c + i*d
*>
*> The algorithm is due to Robert L. Smith and can be found
*> in D. Knuth, The art of Computer Programming, Vol.2, p.195
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] A
*> \verbatim
*> A is REAL
*> \endverbatim
*>
*> \param[in] B
*> \verbatim
*> B is REAL
*> \endverbatim
*>
*> \param[in] C
*> \verbatim
*> C is REAL
*> \endverbatim
*>
*> \param[in] D
*> \verbatim
*> D is REAL
*> The scalars a, b, c, and d in the above expression.
*> \endverbatim
*>
*> \param[out] P
*> \verbatim
*> P is REAL
*> \endverbatim
*>
*> \param[out] Q
*> \verbatim
*> Q is REAL
*> The scalars p and q in the above expression.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup auxOTHERauxiliary
*
* =====================================================================
SUBROUTINE SLADIV( A, B, C, D, P, Q )
*
* -- 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 ..
REAL A, B, C, D, P, Q
* ..
*
* =====================================================================
*
* .. Local Scalars ..
REAL E, F
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS
* ..
* .. Executable Statements ..
*
IF( ABS( D ).LT.ABS( C ) ) THEN
E = D / C
F = C + D*E
P = ( A+B*E ) / F
Q = ( B-A*E ) / F
ELSE
E = C / D
F = D + C*E
P = ( B+A*E ) / F
Q = ( -A+B*E ) / F
END IF
*
RETURN
*
* End of SLADIV
*
END
| bsd-2-clause |
nisihara1/q-e | FFTXlib/test0.f90 | 4 | 15699 | !
! Copyright (C) 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 .
!
! by F. Affinito and C. Cavazzoni, Cineca
! & S. de Gironcoli, SISSA
program test
USE fft_types, ONLY: fft_type_descriptor, fft_type_deallocate
USE fft_interfaces
USE fft_parallel
USE fft_scalar
USE fft_support
USE fft_param
IMPLICIT NONE
TYPE(fft_type_descriptor) :: dfftp, dffts, dfft3d
INTEGER :: nx = 128
INTEGER :: ny = 128
INTEGER :: nz = 256
!
INTEGER :: mype, npes, comm, ntgs, root, nbnd
LOGICAL :: iope
INTEGER :: ierr, i, j, k, ncount, ib, ireq, nreq, ipsi, iloop
INTEGER :: stdout
INTEGER :: ngw_ , ngm_ , ngs_
REAL*8 :: gcutm, gkcut, gcutms
REAL*8 :: ecutm, ecutw, ecutms
REAL*8 :: ecutwfc, ecutrho
REAL*8 :: tpiba, alat, alat_in
REAL*8 :: time(100), my_time(100), time_min(100), time_max(100), time_avg(100)
REAL*8 :: wall
REAL*8 :: wall_avg
!
REAL*8 :: tmp1(10000),tmp2(10000)
!
LOGICAL :: gamma_only
REAL*8 :: at(3,3), bg(3,3)
REAL(DP), PARAMETER :: pi = 3.14159265358979323846_DP
!
COMPLEX(DP), ALLOCATABLE :: psis(:,:)
COMPLEX(DP), ALLOCATABLE :: aux(:)
COMPLEX(DP) :: f_aux, ff(5)
!
integer :: nargs
CHARACTER(LEN=80) :: arg
!
#if defined(__OPENMP)
INTEGER :: PROVIDED
#endif
!
! ........
!
! default parameter (32 water molecules)
!
ecutwfc = 80.0d0
ecutrho = 0.d0
alat_in = 18.65
ntgs = 1
nbnd = 1
!
nargs = command_argument_count()
do i = 1, nargs - 1
CALL get_command_argument(i, arg)
IF( TRIM( arg ) == '-ecutrho' ) THEN
CALL get_command_argument(i+1, arg)
READ( arg, * ) ecutrho
END IF
IF( TRIM( arg ) == '-ecutwfc' ) THEN
CALL get_command_argument(i+1, arg)
READ( arg, * ) ecutwfc
END IF
IF( TRIM( arg ) == '-alat' ) THEN
CALL get_command_argument(i+1, arg)
READ( arg, * ) alat_in
END IF
IF( TRIM( arg ) == '-ntg' ) THEN
CALL get_command_argument(i+1, arg)
READ( arg, * ) ntgs
END IF
IF( TRIM( arg ) == '-nbnd' ) THEN
CALL get_command_argument(i+1, arg)
READ( arg, * ) nbnd
END IF
end do
if (ecutrho == 0.d0) ecutrho = 4.0d0 * ecutwfc
#if defined(__MPI)
#if defined(__OPENMP)
CALL MPI_Init_thread(MPI_THREAD_FUNNELED, PROVIDED, ierr)
#else
CALL MPI_Init(ierr)
#endif
CALL mpi_comm_rank(MPI_COMM_WORLD,mype,ierr)
CALL mpi_comm_size(MPI_COMM_WORLD,npes,ierr)
comm = MPI_COMM_WORLD
root = 0
IF(mype==root) THEN
iope = .true.
ELSE
iope = .false.
ENDIF
#else
mype = 0
npes = 1
comm = 0
ntgs = 1
root = 0
iope = .true.
#endif
!
! Broadcast input parameter first
!
#if defined(__MPI)
CALL MPI_BCAST(ecutrho, 1, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr )
CALL MPI_BCAST(ecutwfc, 1, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr )
CALL MPI_BCAST(alat_in, 1, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr )
CALL MPI_BCAST(ntgs, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr )
CALL MPI_BCAST(nbnd, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr )
#endif
!
ecutw = ecutwfc
! dual
ecutm = ecutrho
ecutms = ecutrho
!
at(1,:) = (/ 0.5d0 , 1.0d0, 0.0d0 /)
at(2,:) = (/ 0.5d0 , 0.0d0, 0.5d0 /)
at(3,:) = (/ 0.0d0 , 0.5d0, 1.5d0 /)
!
at = at * alat_in
!
alat = SQRT ( at(1,1)**2+at(2,1)**2+at(3,1)**2 )
!
tpiba = 2.0d0 * pi / alat
!
gcutm = ecutm / tpiba**2 ! potential cut-off
gcutms= ecutms / tpiba**2 ! smooth mesh cut-off
gkcut = ecutw / tpiba**2 ! wave function cut-off
!
if( mype == 0 ) then
write(*,*) '+-----------------------------------+'
write(*,*) '| QE FFT |'
write(*,*) '| testing & timing |'
write(*,*) '| by Carlo Cavazzoni |'
write(*,*) '+-----------------------------------+'
write(*,*)
write(*,*) 'alat = ', alat
write(*,*) 'Ecutwfc = ', ecutw
write(*,*) 'Ecutrho = ', ecutm
write(*,*) 'Ecuts = ', ecutms
write(*,*) 'Gcutrho = ', SQRT(gcutm)
write(*,*) 'Gcuts = ', SQRT(gcutms)
write(*,*) 'Gcutwfc = ', SQRT(gkcut)
write(*,*) 'Num bands = ', nbnd
write(*,*) 'Num procs = ', npes
write(*,*) 'Num Task Group = ', ntgs
end if
!
at = at / alat
!
call recips( at(1,1), at(1,2), at(1,3), bg(1,1), bg(1,2), bg(1,3) )
!
nx = 2 * int ( sqrt (gcutm) * sqrt (at(1, 1)**2 + at(2, 1)**2 + at(3, 1)**2) ) + 1
ny = 2 * int ( sqrt (gcutm) * sqrt (at(1, 2)**2 + at(2, 2)**2 + at(3, 2)**2) ) + 1
nz = 2 * int ( sqrt (gcutm) * sqrt (at(1, 3)**2 + at(2, 3)**2 + at(3, 3)**2) ) + 1
!
if( mype == 0 ) then
write(*,*) 'nx = ', nx,' ny = ', ny, ' nz = ', nz
end if
!
dffts%nr1 = good_fft_order( nx )
dffts%nr2 = good_fft_order( ny )
dffts%nr3 = good_fft_order( nz )
dffts%nr1x = good_fft_dimension( dffts%nr1 )
dffts%nr2x = dffts%nr2
dffts%nr3x = good_fft_dimension( dffts%nr3 )
!
if( mype == 0 ) then
write(*,*) 'dffts: nr1 = ', dffts%nr1 ,' nr2 = ', dffts%nr2 , ' nr3 = ', dffts%nr3
write(*,*) ' nr1x= ', dffts%nr1x,' nr2x= ', dffts%nr2x, ' nr3x= ', dffts%nr3x
end if
dfftp%nr1 = good_fft_order( nx )
dfftp%nr2 = good_fft_order( ny )
dfftp%nr3 = good_fft_order( nz )
dfftp%nr1x = good_fft_dimension( dfftp%nr1 )
dfftp%nr2x = dfftp%nr2
dfftp%nr3x = good_fft_dimension( dfftp%nr3 )
!
dfft3d%nr1 = good_fft_order( nx )
dfft3d%nr2 = good_fft_order( ny )
dfft3d%nr3 = good_fft_order( nz )
dfft3d%nr1x = good_fft_dimension( dfft3d%nr1 )
dfft3d%nr2x = dfft3d%nr2
dfft3d%nr3x = good_fft_dimension( dfft3d%nr3 )
gamma_only = .true.
stdout = 6
CALL pstickset( gamma_only, bg, gcutm, gkcut, gcutms, &
dfftp, dffts, ngw_ , ngm_ , ngs_ , mype, root, &
npes, comm, ntgs, iope, stdout, dfft3d )
! write (6,'(25i5)') dffts%isind
ALLOCATE( psis( dffts%tg_nnr * dffts%nogrp, 2 ) )
ALLOCATE( aux( dffts%tg_nnr * dffts%nogrp ) )
time = 0.0d0
my_time = 0.0d0
time_min = 0.0d0
time_max = 0.0d0
time_avg = 0.0d0
!
! Test FFT for wave functions - First calls may be biased by MPI and FFT initialization
!
if( mype == 0 ) then
write (*,*) 'Define a function in Reciprocal space such that it contains'
write (*,*) ' f(1,1,1) = (1.0,0.0) | a constant term'
write (*,*) ' f(2,1,1) = (0.d0,0.5d0) | something varying along x '
write (*,*) ' f(1,2,1) = (0.d0,0.3d0) | something varying along y '
write (*,*) ' f(1,1,2) = (0.d0,0.7d0) | something varying along z '
end if
aux = 0.0d0
f_aux = (1.0,0.0) ; call put_f_of_G(f_aux,1,1,1,aux,dffts) ! constant
f_aux = (0.d0,0.5d0); call put_f_of_G(f_aux,2,1,1,aux,dffts) ! something varying along x
f_aux = (0.d0,0.3d0); call put_f_of_G(f_aux,1,2,1,aux,dffts) ! something varying along y
f_aux = (0.d0,0.7d0); call put_f_of_G(f_aux,1,1,2,aux,dffts) ! something varying along z
if( mype == 0 ) write (*,*) 'function in Reciprocal space '
do k =1, 5
if( mype == 0 ) write (*,*) 'k = ',k
do j =1,5
do i =1,5
ff(i) = get_f_of_G(i,j,k,aux,dffts)
end do
if( mype == 0 ) write (*,'(5("(",2f10.6,")",3x))') (ff(i),i=1,5)
end do
end do
#if defined(__MPI)
CALL MPI_BARRIER( MPI_COMM_WORLD, ierr)
#endif
call invfft ('Dense',aux,dffts)
if( mype == 0 ) write (*,*) 'function in Real space (i,j,k)'
do k =1, 5
if( mype == 0 ) write (*,*) 'k = ',k
do j =1,5
do i =1,5
ff(i) = get_f_of_R(i,j,k,aux,dffts)
end do
if( mype == 0 ) write (*,'(5("(",2f10.6,")",3x))') (ff(i),i=1,5)
end do
end do
call fwfft ('Dense',aux,dffts)
if( mype == 0 ) write (*,*) 'function in Reciprocal space '
do k =1, 5
if( mype == 0 ) write (*,*) 'k = ',k
do j =1,5
do i =1,5
ff(i) = get_f_of_G(i,j,k,aux,dffts)
end do
if( mype == 0 ) write (*,'(5("(",2f10.6,")",3x))') (ff(i),i=1,5)
end do
end do
!
! Execute FFT calls once more, this time as Wave, and Take time
!
!
if( mype == 0 ) write (*,*) ' Execute FFT calls once more, this time as Wave !'
#if defined(__MPI)
CALL MPI_BARRIER( MPI_COMM_WORLD, ierr)
wall = MPI_WTIME()
#endif
call invfft ('Wave',aux,dffts)
if( mype == 0 ) write (*,*) 'function in Real space (i,j,k)'
do k =1, 5
if( mype == 0 ) write (*,*) 'k = ',k
do j =1,5
do i =1,5
ff(i) = get_f_of_R(i,j,k,aux,dffts)
end do
if( mype == 0 ) write (*,'(5("(",2f10.6,")",3x))') (ff(i),i=1,5)
end do
end do
call fwfft ('Wave',aux,dffts)
if( mype == 0 ) write (*,*) 'function in Reciprocal space '
do k =1, 5
if( mype == 0 ) write (*,*) 'k = ',k
do j =1,5
do i =1,5
ff(i) = get_f_of_G(i,j,k,aux,dffts)
end do
if( mype == 0 ) write (*,'(5("(",2f10.6,")",3x))') (ff(i),i=1,5)
end do
end do
DEALLOCATE( aux )
if( mype == 0 ) write (*,*) ' Execute FFT calls once more, this time as with cft3ds !'
ALLOCATE( aux (dffts%nr1x * dffts%nr2x * dffts%nr3x ) )
#if defined(__MPI)
CALL MPI_BARRIER( MPI_COMM_WORLD, ierr)
wall = MPI_WTIME()
#endif
aux = 0.0d0
f_aux = (1.0,0.0) ; i=1;j=1;k=1; aux( i+dffts%nr1x *(j-1) + dffts%nr1x*dffts%nr2x*(k-1) ) = f_aux
f_aux = (0.d0,0.5d0); i=2;j=1;k=1; aux( i+dffts%nr1x *(j-1) + dffts%nr1x*dffts%nr2x*(k-1) ) = f_aux
f_aux = (0.d0,0.3d0); i=1;j=2;k=1; aux( i+dffts%nr1x *(j-1) + dffts%nr1x*dffts%nr2x*(k-1) ) = f_aux
f_aux = (0.d0,0.7d0); i=1;j=1;k=2; aux( i+dffts%nr1x *(j-1) + dffts%nr1x*dffts%nr2x*(k-1) ) = f_aux
CALL cfft3ds( aux, dffts%nr1, dffts%nr2, dffts%nr3, &
dffts%nr1x,dffts%nr2x,dffts%nr3x, 1, &
dffts%isind, dffts%iplw )
if( mype == 0 ) write (*,*) 'function in Real space (i,j,k)'
do k =1, 5
if( mype == 0 ) write (*,*) 'k = ',k
do j =1,5
do i =1,5
ff(i) =aux (i+dffts%nr1x *(j-1) + dffts%nr1x*dffts%nr2x*(k-1) )
end do
if( mype == 0 ) write (*,'(5("(",2f10.6,")",3x))') (ff(i),i=1,5)
end do
end do
CALL cfft3ds( aux, dffts%nr1, dffts%nr2, dffts%nr3, &
dffts%nr1x,dffts%nr2x,dffts%nr3x, -1, &
dffts%isind, dffts%iplw )
if( mype == 0 ) write (*,*) 'function in Reciprocal space '
do k =1, 5
if( mype == 0 ) write (*,*) 'k = ',k
do j =1,5
do i =1,5
ff(i) =aux (i+dffts%nr1x *(j-1) + dffts%nr1x*dffts%nr2x*(k-1) )
end do
if( mype == 0 ) write (*,'(5("(",2f10.6,")",3x))') (ff(i),i=1,5)
end do
end do
#if defined(__MPI)
wall = MPI_WTIME() - wall
#endif
DEALLOCATE( psis, aux )
CALL fft_type_deallocate( dffts )
CALL fft_type_deallocate( dfftp )
CALL fft_type_deallocate( dfft3d )
if( ncount > 0 ) then
my_time = my_time / DBLE(ncount)
endif
!write(*,*)my_time(2), my_time(3), my_time(4)
#if defined(__MPI)
CALL MPI_ALLREDUCE( my_time, time_min, 10, MPI_DOUBLE_PRECISION, MPI_MIN, MPI_COMM_WORLD, ierr )
CALL MPI_ALLREDUCE( my_time, time_max, 10, MPI_DOUBLE_PRECISION, MPI_MAX, MPI_COMM_WORLD, ierr )
CALL MPI_ALLREDUCE( my_time, time_avg, 10, MPI_DOUBLE_PRECISION, MPI_SUM, MPI_COMM_WORLD, ierr )
CALL MPI_ALLREDUCE( wall, wall_avg, 1, MPI_DOUBLE_PRECISION, MPI_SUM, MPI_COMM_WORLD, ierr )
#else
time_min = time
time_max = time
#endif
!write(*,*)time_min(2), time_min(3), time_min(4)
time_avg = time_avg / npes
wall_avg = wall_avg / npes
if( mype == 0 ) then
write(*,*) '**** QE 3DFFT Timing ****'
write(*,*) 'grid size = ', dffts%nr1, dffts%nr2, dffts%nr3
write(*,*) 'num proc = ', npes
write(*,*) 'num band = ', nbnd
write(*,*) 'num task group = ', ntgs
write(*,*) 'num fft cycles = ', ncount
write(*,100)
write(*,1)
write(*,100)
write(*,2) time_min(2), time_max(2), time_avg(2)
write(*,3) time_min(3), time_max(3), time_avg(3)
write(*,4) time_min(4), time_max(4), time_avg(4)
write(*,5) time_min(5), time_max(5), time_avg(5)
write(*,6) time_min(6), time_max(6), time_avg(6)
write(*,7) time_min(7), time_max(7), time_avg(7)
write(*,8) time_min(8), time_max(8), time_avg(8)
write(*,9) time_min(9), time_max(9), time_avg(9)
write(*,10) time_min(10), time_max(10), time_avg(10)
write(*,11) wall
write(*,100)
100 FORMAT(' +--------------------+----------------+-----------------+----------------+' )
1 FORMAT(' |FFT subroutine | sec. min | sec. max | sec. avg |' )
2 FORMAT(' |pack_group_sticks/w | ', D14.5, ' | ', D14.3, ' | ', D14.3, ' |' )
3 FORMAT(' |fw_tg_cft3_z | ', D14.5, ' | ', D14.3, ' | ', D14.3, ' |' )
4 FORMAT(' |fw_tg_cft3_scatter | ', D14.5, ' | ', D14.3, ' | ', D14.3 , ' |')
5 FORMAT(' |fw_tg_cft3_xy | ', D14.5, ' | ', D14.3, ' | ', D14.3 , ' |')
6 FORMAT(' |workload | ', D14.5, ' | ', D14.3, ' | ', D14.3 , ' |')
7 FORMAT(' |bw_tg_cft3_xy | ', D14.5, ' | ', D14.3, ' | ', D14.3 , ' |')
8 FORMAT(' |bw_tg_cft3_scatter | ', D14.5, ' | ', D14.3, ' | ', D14.3 , ' |')
9 FORMAT(' |bw_tg_cft3_z | ', D14.5, ' | ', D14.3, ' | ', D14.3 , ' |')
10 FORMAT(' |unpack_group_sticks | ', D14.5, ' | ', D14.3, ' | ', D14.3 , ' |')
11 FORMAT(' |wall time | ', D14.5, ' |')
end if
#if defined(__MPI)
CALL mpi_finalize(ierr)
#endif
contains
!
! 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 recips (a1, a2, a3, b1, b2, b3)
!---------------------------------------------------------------------
!
! This routine generates the reciprocal lattice vectors b1,b2,b3
! given the real space vectors a1,a2,a3. The b's are units of 2 pi/a.
!
! first the input variables
!
implicit none
real(DP) :: a1 (3), a2 (3), a3 (3), b1 (3), b2 (3), b3 (3)
! input: first direct lattice vector
! input: second direct lattice vector
! input: third direct lattice vector
! output: first reciprocal lattice vector
! output: second reciprocal lattice vector
! output: third reciprocal lattice vector
!
! then the local variables
!
real(DP) :: den, s
! the denominator
! the sign of the permutations
integer :: iperm, i, j, k, l, ipol
! counter on the permutations
!\
! Auxiliary variables
!/
!
! Counter on the polarizations
!
! first we compute the denominator
!
den = 0
i = 1
j = 2
k = 3
s = 1.d0
100 do iperm = 1, 3
den = den + s * a1 (i) * a2 (j) * a3 (k)
l = i
i = j
j = k
k = l
enddo
i = 2
j = 1
k = 3
s = - s
if (s.lt.0.d0) goto 100
!
! here we compute the reciprocal vectors
!
i = 1
j = 2
k = 3
do ipol = 1, 3
b1 (ipol) = (a2 (j) * a3 (k) - a2 (k) * a3 (j) ) / den
b2 (ipol) = (a3 (j) * a1 (k) - a3 (k) * a1 (j) ) / den
b3 (ipol) = (a1 (j) * a2 (k) - a1 (k) * a2 (j) ) / den
l = i
i = j
j = k
k = l
enddo
return
end subroutine recips
end program test
subroutine start_clock( label )
implicit none
character(len=*) :: label
end subroutine
subroutine stop_clock( label )
implicit none
character(len=*) :: label
end subroutine
| gpl-2.0 |
AndresYague/Snuppat | loader.f90 | 1 | 16558 | MODULE loader
USE readvars_mod
USE structures_mod
USE math_routines
IMPLICIT NONE
CONTAINS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! This subroutine creates the cross sections linked list. !!!
!!! !!!
!!! The input values are: !!!
!!! -highTempReacts, a pointer to type REACT. !!!
!!! -lowTempReacts, a pointer to type REACT. !!!
!!! !!!
!!! At the output, both highTempReacts and lowTempReacts are the heads of !!!
!!! two linked lists, the first one containing all the reactions in the !!!
!!! network, and the second one containing just decay reactions, which can !!!
!!! be followed in low temperature shells. !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE loadNetwork(highTempReacts, lowTempReacts)
IMPLICIT NONE
! Input variables
TYPE (REACT), POINTER::highTempReacts, lowTempReacts
! Local variables
TYPE (REACT), POINTER::curr, last
DOUBLE PRECISION, DIMENSION(7)::avector
DOUBLE PRECISION, ALLOCATABLE::locTempTable(:)
CHARACTER(10)::source
INTEGER, DIMENSION(3)::neg
INTEGER, DIMENSION(4)::pos
INTEGER::kk, jj, jumpSiz, locTabSiz, kkindx
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!END OF DECLARATIONS!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! This reads the files with the reactions and makes the linked list.
NULLIFY(last)
DO kk = 1, SIZE(filenames) + SIZE(lowTempFiles)
IF ((kk - SIZE(filenames)).LT.1) THEN
kkindx = kk
OPEN(UNIT = uni, FILE = "data/"//filenames(kk)//".lst")
ELSE
kkindx = kk - SIZE(filenames)
OPEN(UNIT = uni, FILE = "data/"//lowTempFiles(kkindx)//".lst")
END IF
! For the first list we must skip the first jumpSiz lines.
IF (kk.EQ.1) THEN
READ(uni, *) jumpSiz
DO jj = 1, jumpSiz
READ(uni, *)
END DO
END IF
! Nullify last if we are at the head
IF (kkindx.EQ.1) NULLIFY(last)
! In this loop the coefficients are read.
DO
! This line reads the nucleon tag, the reaction source and coefs.
neg = 0; pos = 0
IF (kk.EQ.kkindx) THEN
READ(uni, *, IOSTAT = error) neg(1:targ(kk)), pos(1:prod(kk)), &
source, avector
ELSE
READ(uni, *, IOSTAT = error) neg(1:targ(kkindx)), &
pos(1:prod(kkindx)), source, &
locTabSiz
END IF
IF (error.NE.0) EXIT
! Check that tabSiz has not changed
IF ((kk.NE.kkindx).AND.(tabSiz.NE.locTabSiz)) THEN
PRINT*, "Not the same table size for starlib reactions!"
PRINT*, tabSiz, locTabSiz
STOP
END IF
! Put reaction in the list:
ALLOCATE(curr)
IF (kk.EQ.kkindx) THEN
!Allocate space for avector
ALLOCATE(curr%avector(7))
curr%avector = avector
ELSE
! Allocate space for the tables
ALLOCATE(locTempTable(locTabSiz))
ALLOCATE(curr%crossTable(tabSiz))
! Read the tables
READ(uni, *) locTempTable
READ(uni, *) curr%crossTable
! Make all zeros in crossTable 1e-100
DO jj = 1, tabSiz
IF (curr%crossTable(jj).LT.1.D-100) THEN
curr%crossTable(jj) = 1.D-100
END IF
END DO
! Define tempTable if not done already
IF (MAXVAL(tempTable).LE.0.D0) tempTable = locTempTable
! Check that the temperature table is the same
IF (MAXVAL(ABS(tempTable - locTempTable)).GT.0.D0) THEN
PRINT*, "Not the same temperatures for starlib reactions!"
DO jj = 1, tabSiz
PRINT*, tempTable(jj), locTempTable(jj)
END DO
STOP
END IF
DEALLOCATE(locTempTable)
END IF
! Input all common values
curr%source = source
curr%targnum = targ(kkindx)
curr%prodnum = prod(kkindx)
curr%totnum = targ(kkindx) + prod(kkindx)
curr%targindx = neg
curr%prodindx = pos
IF (curr%source(1:2).EQ."ec") THEN
curr%isEc = .TRUE.
ELSE
curr%isEc = .FALSE.
END IF
! Introduce new reaction at the end
IF (ASSOCIATED(last)) THEN
last%next => curr
ELSE IF (kk.EQ.1) THEN
highTempReacts => curr
ELSE IF (kkindx.EQ.1) THEN
lowTempReacts => curr
END IF
last => curr
! Nullify next to be in the safe side
NULLIFY(curr%next)
END DO
CLOSE(UNIT = uni)
END DO
END SUBROUTINE loadNetwork
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! This subroutine loads the partition functions in "partfunct". !!!
!!! !!!
!!! The input value is: !!!
!!! -partfunct, a two-dimensional array. !!!
!!! !!!
!!! At the output, the array partfunct contains all the partition function !!!
!!! tabulated values for a given nucleon. The first index is the label of !!!
!!! said nucleon. !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE loadPartitions(partfunct)
IMPLICIT NONE
! Input variables
DOUBLE PRECISION::partfunct(:, :)
! Local variables
INTEGER::ii
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!END OF DECLARATIONS!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Read file and store
OPEN(UNIT = uni, FILE = "data/partition.lst")
DO
READ(uni, *, IOSTAT = error) ii
READ(uni, *, IOSTAT = error) partfunct(ii, :)
IF (error.NE.0) EXIT
END DO
CLOSE(UNIT = uni)
END SUBROUTINE loadPartitions
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! This subroutine calculates the cross section for every reaction for the !!!
!!! given temperature and density. !!!
!!! !!!
!!! The input values are: !!!
!!! -reacts, the linked list of CROSSARR types with the cross sections. !!!
!!! -fullReacts, the linked list of REACT types with the cross sections. !!!
!!! -temp, the temperature in T9 units. !!!
!!! -rho, the density in g/cm^3. !!!
!!! -partfun, the array with the partition function tables. !!!
!!! -isLowTemp, boolean telling us if we are in low temperature reactions. !!!
!!! !!!
!!! At the output, all the cross sections in the linked list have been !!!
!!! calculated for the given temperature and density. !!!
!!! !!!
!!! An additional function is included to calculate the cross sections. !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE calculateReacts(reacts, fullReacts, temp, rho, partfun, isLowTemp)
IMPLICIT NONE
! Input variables
TYPE (CROSSARR), TARGET::reacts
TYPE (REACT), TARGET::fullReacts
DOUBLE PRECISION::temp, rho, partfun(:, :)
LOGICAL::isLowTemp
! Local variables
TYPE (CROSSARR), POINTER::cCross
TYPE (REACT), POINTER::cReact
DOUBLE PRECISION::crsect, partval
INTEGER::ii, jj1, jj2, jj3, targIndx(3), prodIndx(4)
LOGICAL::isRepeated, firstAdded, isSameReaction
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!END OF DECLARATIONS!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Initialize
targIndx = 0
prodIndx = 0
! Point to lists beginning
cCross => reacts
cReact => fullReacts
firstAdded = .FALSE.
! In this loop the reactions are calculated
DO
! Calculate cross section.
IF (isLowTemp) THEN
crsect = interpolateOneValue(log(temp), log(tempTable), &
log(cReact%crossTable))
crsect = exp(crsect)
ELSE
crsect = highTempCross(cReact%avector, temp)
END IF
crsect = crsect*(rho**(cReact%targnum - 1))
! If reaction is "ec", we have to multiply again by rho.
IF (cReact%isEc) crsect = crsect*rho
! If there are more than one of each target, then we have to divide
! by the factorial of the number of repetitions, so by 2 or by 6.
IF (cReact%targnum.GE.2) THEN
jj1 = cReact%targindx(1)
jj2 = cReact%targindx(2)
jj3 = cReact%targindx(3)
IF ((jj1.EQ.jj2).AND.(jj2.EQ.jj3)) THEN
crsect = crsect/6.D0
ELSE IF ((jj1.EQ.jj2).OR.(jj1.EQ.jj3).OR.(jj2.EQ.jj3)) THEN
crsect = crsect/2.D0
END IF
END IF
! This block reads the partition function and calculates it.
IF ((cReact%source(5:5).EQ.'v').OR.(cReact%source(6:6).EQ.'v')) THEN
! If the temperature is lower than 10^8 K, the partition
! functions will always be 1, if the temperature is higher,
! a logarithmical interpolation is made.
IF ((temp.GE.1D-1).AND.(.NOT.isLowTemp)) THEN
DO ii = 1, cReact%targnum + cReact%prodnum
IF (ii.LE.cReact%targnum) THEN
jj1 = cReact%targindx(ii)
CALL partitionValue(temp, partfun(jj1, :), partval)
crsect = crsect/partval
ELSE
jj1 = cReact%prodindx(ii - cReact%targnum)
CALL partitionValue(temp, partfun(jj1, :), partval)
crsect = crsect*partval
END IF
END DO
END IF
END IF
! Check that crsect is bigger than a value
! If the reaction is a repeat, simply add it to the last one
IF (crsect.GT.1.D-40) THEN
isRepeated = .TRUE.
isSameReaction = .TRUE.
IF (targIndx(1).NE.cReact%targIndx(1)) THEN
isRepeated = .FALSE.
isSameReaction = .FALSE.
ELSE IF (targIndx(2).NE.cReact%targIndx(2)) THEN
isRepeated = .FALSE.
isSameReaction = .FALSE.
ELSE IF (targIndx(3).NE.cReact%targIndx(3)) THEN
isRepeated = .FALSE.
isSameReaction = .FALSE.
ELSE IF (prodIndx(1).NE.cReact%prodIndx(1)) THEN
isSameReaction = .FALSE.
ELSE IF (prodIndx(2).NE.cReact%prodIndx(2)) THEN
isSameReaction = .FALSE.
ELSE IF (prodIndx(3).NE.cReact%prodIndx(3)) THEN
isSameReaction = .FALSE.
ELSE IF (prodIndx(4).NE.cReact%prodIndx(4)) THEN
isSameReaction = .FALSE.
END IF
! If not repeated, fill this bit and allocate the next
! If repeated, add to the last one
IF (.NOT.isSameReaction) THEN
IF (firstAdded) THEN
ALLOCATE(cCross%next)
cCross => cCross%next
NULLIFY(cCross%next)
ELSE
firstAdded = .TRUE.
END IF
cCross%crossect = crsect
cCross%targIndx = cReact%targIndx
cCross%prodIndx = cReact%prodIndx
cCross%targnum = cReact%targnum
cCross%prodnum = cReact%prodnum
cCross%totnum = cReact%totnum
cCross%isEc = cReact%isEc
cCross%isRepeated = isRepeated
ELSE
cCross%crossect = cCross%crossect + crsect
END IF
targIndx = cReact%targIndx
prodIndx = cReact%prodIndx
END IF
! Go to next reaction
IF (ASSOCIATED(cReact%next)) THEN
cReact => cReact%next
ELSE
EXIT
END IF
END DO
END SUBROUTINE calculateReacts
FUNCTION highTempCross(avector, temp) RESULT(crsect)
IMPLICIT NONE
! Input variables
DOUBLE PRECISION::avector(:), temp
! Function
DOUBLE PRECISION::crsect
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!END OF DECLARATIONS!!!!!!!!!!!!!!!!!!!!!!!!!!!!
crsect = avector(1) + avector(2)/temp + avector(3)*temp**(-1.d0/3.d0) + &
avector(4)*temp**(1.d0/3.d0) + avector(5)*temp + &
avector(6)*temp**(5.d0/3.d0) + avector(7)*log(temp)
! Check that there are no underflows
IF (crsect.LT.-300) THEN
crsect = 0
ELSE
crsect = exp(crsect)
END IF
END FUNCTION highTempCross
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! This subroutine calculates the partition function for each element using !!!
!!! the data from reaclib and performing a logarithmic interpolation. !!!
!!! !!!
!!! The input values are: !!!
!!! -temp, the temperature in T9 units. !!!
!!! -partit, the array with the partition function tables. !!!
!!! -partVal, the interpolated value. !!!
!!! !!!
!!! At the output, partVal carries the interpolated value. !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE partitionValue(temp, partit, partVal)
IMPLICIT NONE
! Input
DOUBLE PRECISION::temp, partit(24), partVal
! Temperature array for interpolation (in T9).
DOUBLE PRECISION, DIMENSION(24)::tempArr = (/ 1D-1, 1.5D-1, 2D-1, 3D-1, &
4D-1, 5D-1, 6D-1, 7D-1, 8D-1, 9D-1, 1D0, 1.5D0, 2D0, 2.5D0, &
3D0, 3.5D0, 4D0, 4.5D0, 5D0, 6D0,7D0, 8D0, 9D0, 1D1 /)
! Local
INTEGER::kk
DOUBLE PRECISION::aa, bb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!END OF DECLARATIONS!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! First we search between which two temperatures is our temp.
DO kk = 1, 23
IF ((temp.GE.tempArr(kk)).AND.(temp.LE.tempArr(kk+1))) EXIT
END DO
! Now we avoid calculation if the partition function is constant between the
! two temperatures and make the logarithmic interpolation if it's not.
IF (ABS(partit(kk) - partit(kk+1)).LE.1.D-5) THEN
partVal = partit(kk)
ELSE
aa = (log(partit(kk+1)) - log(partit(kk)))/ &
(log(tempArr(kk+1)) - log(tempArr(kk)))
bb = -(log(partit(kk+1))*log(tempArr(kk)) - log(partit(kk))* &
log(tempArr(kk+1)))/(log(tempArr(kk+1)) - log(tempArr(kk)))
partVal = (temp**aa)*exp(bb)
END IF
END SUBROUTINE partitionValue
END MODULE loader
| mit |
bftg/gcc-5.3.0 | gcc/testsuite/gfortran.dg/mvbits_4.f90 | 174 | 1031 | ! { dg-do run }
! PR fortran/35681
! Check that dependencies of MVBITS arguments are resolved correctly by using
! temporaries if both arguments refer to the same variable.
integer, dimension(10) :: ila1 = (/1,2,3,4,5,6,7,8,9,10/)
integer, dimension(20) :: ila2
integer, dimension(10), target :: ila3
integer, pointer :: ila3_ptr(:)
integer, parameter :: SHOULD_BE(10) = (/17,18,11,4,13,22,7,16,9,18/)
integer, parameter :: INDEX_VECTOR(10) = (/9,9,6,2,4,9,2,9,6,10/)
ila2(2:20:2) = ila1
ila3 = ila1
! Argument is already packed.
call mvbits (ila1(INDEX_VECTOR), 2, 4, ila1, 3)
write (*,'(10(I3))') ila1
if (any (ila1 /= SHOULD_BE)) call abort ()
! Argument is not packed.
call mvbits (ila2(2*INDEX_VECTOR), 2, 4, ila2(2:20:2), 3)
write (*,'(10(I3))') ila2(2:20:2)
if (any (ila2(2:20:2) /= SHOULD_BE)) call abort ()
! Pointer and target
ila3_ptr => ila3
call mvbits (ila3(INDEX_VECTOR), 2, 4, ila3_ptr, 3)
write (*,'(10(I3))') ila3
if (any (ila3 /= SHOULD_BE)) call abort ()
end
| gpl-2.0 |
shengren/magma-1.6.1 | testing/lin/dchkpp.f | 9 | 13624 | SUBROUTINE DCHKPP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
$ NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
$ IWORK, NOUT )
*
* -- LAPACK test routine (version 3.1) --
* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
* November 2006
*
* .. Scalar Arguments ..
LOGICAL TSTERR
INTEGER NMAX, NN, NNS, NOUT
DOUBLE PRECISION THRESH
* ..
* .. Array Arguments ..
LOGICAL DOTYPE( * )
INTEGER IWORK( * ), NSVAL( * ), NVAL( * )
DOUBLE PRECISION A( * ), AFAC( * ), AINV( * ), B( * ),
$ RWORK( * ), WORK( * ), X( * ), XACT( * )
* ..
*
* Purpose
* =======
*
* DCHKPP tests DPPTRF, -TRI, -TRS, -RFS, and -CON
*
* Arguments
* =========
*
* DOTYPE (input) 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.
*
* NN (input) INTEGER
* The number of values of N contained in the vector NVAL.
*
* NVAL (input) INTEGER array, dimension (NN)
* The values of the matrix dimension N.
*
* NNS (input) INTEGER
* The number of values of NRHS contained in the vector NSVAL.
*
* NSVAL (input) INTEGER array, dimension (NNS)
* The values of the number of right hand sides NRHS.
*
* THRESH (input) 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.
*
* TSTERR (input) LOGICAL
* Flag that indicates whether error exits are to be tested.
*
* NMAX (input) INTEGER
* The maximum value permitted for N, used in dimensioning the
* work arrays.
*
* A (workspace) DOUBLE PRECISION array, dimension
* (NMAX*(NMAX+1)/2)
*
* AFAC (workspace) DOUBLE PRECISION array, dimension
* (NMAX*(NMAX+1)/2)
*
* AINV (workspace) DOUBLE PRECISION array, dimension
* (NMAX*(NMAX+1)/2)
*
* B (workspace) DOUBLE PRECISION array, dimension (NMAX*NSMAX)
* where NSMAX is the largest entry in NSVAL.
*
* X (workspace) DOUBLE PRECISION array, dimension (NMAX*NSMAX)
*
* XACT (workspace) DOUBLE PRECISION array, dimension (NMAX*NSMAX)
*
* WORK (workspace) DOUBLE PRECISION array, dimension
* (NMAX*max(3,NSMAX))
*
* RWORK (workspace) DOUBLE PRECISION array, dimension
* (max(NMAX,2*NSMAX))
*
* IWORK (workspace) INTEGER array, dimension (NMAX)
*
* NOUT (input) INTEGER
* The unit number for output.
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO
PARAMETER ( ZERO = 0.0D+0 )
INTEGER NTYPES
PARAMETER ( NTYPES = 9 )
INTEGER NTESTS
PARAMETER ( NTESTS = 8 )
* ..
* .. Local Scalars ..
LOGICAL ZEROT
CHARACTER DIST, PACKIT, TYPE, UPLO, XTYPE
CHARACTER*3 PATH
INTEGER I, IMAT, IN, INFO, IOFF, IRHS, IUPLO, IZERO, K,
$ KL, KU, LDA, MODE, N, NERRS, NFAIL, NIMAT, NPP,
$ NRHS, NRUN
DOUBLE PRECISION ANORM, CNDNUM, RCOND, RCONDC
* ..
* .. Local Arrays ..
CHARACTER PACKS( 2 ), UPLOS( 2 )
INTEGER ISEED( 4 ), ISEEDY( 4 )
DOUBLE PRECISION RESULT( NTESTS )
* ..
* .. External Functions ..
DOUBLE PRECISION DGET06, DLANSP
EXTERNAL DGET06, DLANSP
* ..
* .. External Subroutines ..
EXTERNAL ALAERH, ALAHD, ALASUM, DCOPY, DERRPO, DGET04,
$ DLACPY, DLARHS, DLATB4, DLATMS, DPPCON, DPPRFS,
$ DPPT01, DPPT02, DPPT03, DPPT05, DPPTRF, DPPTRI,
$ DPPTRS
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, NUNIT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, NUNIT, OK, LERR
COMMON / SRNAMC / SRNAMT
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX
* ..
* .. Data statements ..
DATA ISEEDY / 1988, 1989, 1990, 1991 /
DATA UPLOS / 'U', 'L' / , PACKS / 'C', 'R' /
* ..
* .. Executable Statements ..
*
* Initialize constants and the random number seed.
*
PATH( 1: 1 ) = 'Double precision'
PATH( 2: 3 ) = 'PP'
NRUN = 0
NFAIL = 0
NERRS = 0
DO 10 I = 1, 4
ISEED( I ) = ISEEDY( I )
10 CONTINUE
*
* Test the error exits
*
IF( TSTERR )
$ CALL DERRPO( PATH, NOUT )
INFOT = 0
*
* Do for each value of N in NVAL
*
DO 110 IN = 1, NN
N = NVAL( IN )
LDA = MAX( N, 1 )
XTYPE = 'N'
NIMAT = NTYPES
IF( N.LE.0 )
$ NIMAT = 1
*
DO 100 IMAT = 1, NIMAT
*
* Do the tests only if DOTYPE( IMAT ) is true.
*
IF( .NOT.DOTYPE( IMAT ) )
$ GO TO 100
*
* Skip types 3, 4, or 5 if the matrix size is too small.
*
ZEROT = IMAT.GE.3 .AND. IMAT.LE.5
IF( ZEROT .AND. N.LT.IMAT-2 )
$ GO TO 100
*
* Do first for UPLO = 'U', then for UPLO = 'L'
*
DO 90 IUPLO = 1, 2
UPLO = UPLOS( IUPLO )
PACKIT = PACKS( IUPLO )
*
* Set up parameters with DLATB4 and generate a test matrix
* with DLATMS.
*
CALL DLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM, MODE,
$ CNDNUM, DIST )
*
SRNAMT = 'DLATMS'
CALL DLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
$ CNDNUM, ANORM, KL, KU, PACKIT, A, LDA, WORK,
$ INFO )
*
* Check error code from DLATMS.
*
IF( INFO.NE.0 ) THEN
CALL ALAERH( PATH, 'DLATMS', INFO, 0, UPLO, N, N, -1,
$ -1, -1, IMAT, NFAIL, NERRS, NOUT )
GO TO 90
END IF
*
* For types 3-5, zero one row and column 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
*
* Set row and column IZERO of A to 0.
*
IF( IUPLO.EQ.1 ) THEN
IOFF = ( IZERO-1 )*IZERO / 2
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 + I
30 CONTINUE
ELSE
IOFF = IZERO
DO 40 I = 1, IZERO - 1
A( IOFF ) = ZERO
IOFF = IOFF + N - I
40 CONTINUE
IOFF = IOFF - IZERO
DO 50 I = IZERO, N
A( IOFF+I ) = ZERO
50 CONTINUE
END IF
ELSE
IZERO = 0
END IF
*
* Compute the L*L' or U'*U factorization of the matrix.
*
NPP = N*( N+1 ) / 2
CALL DCOPY( NPP, A, 1, AFAC, 1 )
SRNAMT = 'DPPTRF'
CALL DPPTRF( UPLO, N, AFAC, INFO )
*
* Check error code from DPPTRF.
*
IF( INFO.NE.IZERO ) THEN
CALL ALAERH( PATH, 'DPPTRF', INFO, IZERO, UPLO, N, N,
$ -1, -1, -1, IMAT, NFAIL, NERRS, NOUT )
GO TO 90
END IF
*
* Skip the tests if INFO is not 0.
*
IF( INFO.NE.0 )
$ GO TO 90
*
*+ TEST 1
* Reconstruct matrix from factors and compute residual.
*
CALL DCOPY( NPP, AFAC, 1, AINV, 1 )
CALL DPPT01( UPLO, N, A, AINV, RWORK, RESULT( 1 ) )
*
*+ TEST 2
* Form the inverse and compute the residual.
*
CALL DCOPY( NPP, AFAC, 1, AINV, 1 )
SRNAMT = 'DPPTRI'
CALL DPPTRI( UPLO, N, AINV, INFO )
*
* Check error code from DPPTRI.
*
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'DPPTRI', INFO, 0, UPLO, N, N, -1,
$ -1, -1, IMAT, NFAIL, NERRS, NOUT )
*
CALL DPPT03( UPLO, N, A, AINV, WORK, LDA, RWORK, RCONDC,
$ RESULT( 2 ) )
*
* Print information about the tests that did not pass
* the threshold.
*
DO 60 K = 1, 2
IF( RESULT( K ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
$ CALL ALAHD( NOUT, PATH )
WRITE( NOUT, FMT = 9999 )UPLO, N, IMAT, K,
$ RESULT( K )
NFAIL = NFAIL + 1
END IF
60 CONTINUE
NRUN = NRUN + 2
*
DO 80 IRHS = 1, NNS
NRHS = NSVAL( IRHS )
*
*+ TEST 3
* Solve and compute residual for A * X = B.
*
SRNAMT = 'DLARHS'
CALL DLARHS( PATH, 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 = 'DPPTRS'
CALL DPPTRS( UPLO, N, NRHS, AFAC, X, LDA, INFO )
*
* Check error code from DPPTRS.
*
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'DPPTRS', INFO, 0, UPLO, N, N,
$ -1, -1, NRHS, IMAT, NFAIL, NERRS,
$ NOUT )
*
CALL DLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
CALL DPPT02( UPLO, N, NRHS, A, X, LDA, WORK, LDA,
$ RWORK, RESULT( 3 ) )
*
*+ TEST 4
* Check solution from generated exact solution.
*
CALL DGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
$ RESULT( 4 ) )
*
*+ TESTS 5, 6, and 7
* Use iterative refinement to improve the solution.
*
SRNAMT = 'DPPRFS'
CALL DPPRFS( UPLO, N, NRHS, A, AFAC, B, LDA, X, LDA,
$ RWORK, RWORK( NRHS+1 ), WORK, IWORK,
$ INFO )
*
* Check error code from DPPRFS.
*
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'DPPRFS', INFO, 0, UPLO, N, N,
$ -1, -1, NRHS, IMAT, NFAIL, NERRS,
$ NOUT )
*
CALL DGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
$ RESULT( 5 ) )
CALL DPPT05( UPLO, N, NRHS, A, B, LDA, X, LDA, XACT,
$ LDA, RWORK, RWORK( NRHS+1 ),
$ RESULT( 6 ) )
*
* Print information about the tests that did not pass
* the threshold.
*
DO 70 K = 3, 7
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
70 CONTINUE
NRUN = NRUN + 5
80 CONTINUE
*
*+ TEST 8
* Get an estimate of RCOND = 1/CNDNUM.
*
ANORM = DLANSP( '1', UPLO, N, A, RWORK )
SRNAMT = 'DPPCON'
CALL DPPCON( UPLO, N, AFAC, ANORM, RCOND, WORK, IWORK,
$ INFO )
*
* Check error code from DPPCON.
*
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'DPPCON', INFO, 0, UPLO, N, N, -1,
$ -1, -1, IMAT, NFAIL, NERRS, NOUT )
*
RESULT( 8 ) = DGET06( RCOND, RCONDC )
*
* Print the test ratio if greater than or equal to THRESH.
*
IF( RESULT( 8 ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
$ CALL ALAHD( NOUT, PATH )
WRITE( NOUT, FMT = 9999 )UPLO, N, IMAT, 8,
$ RESULT( 8 )
NFAIL = NFAIL + 1
END IF
NRUN = NRUN + 1
90 CONTINUE
100 CONTINUE
110 CONTINUE
*
* Print a summary of the results.
*
CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
*
9999 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', type ', I2, ', test ',
$ I2, ', ratio =', G12.5 )
9998 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NRHS=', I3, ', type ',
$ I2, ', test(', I2, ') =', G12.5 )
RETURN
*
* End of DCHKPP
*
END
| bsd-3-clause |
bftg/gcc-5.3.0 | gcc/testsuite/gfortran.dg/coarray_10.f90 | 99 | 2137 | ! { dg-do compile }
! { dg-options "-fcoarray=single" }
!
! PR fortran/18918
!
! Coarray intrinsics
!
subroutine image_idx_test1()
INTEGER,save :: array[2,-1:4,8,*]
WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
WRITE (*,*) IMAGE_INDEX (array, [0,0,3,1]) ! { dg-error "for dimension 1, SUB has 0 and COARRAY lower bound is 1" }
WRITE (*,*) IMAGE_INDEX (array, [1,2,9,0]) ! { dg-error "for dimension 3, SUB has 9 and COARRAY upper bound is 8" }
WRITE (*,*) IMAGE_INDEX (array, [2,0,3]) ! { dg-error "array elements of the SUB argument to IMAGE_INDEX at .1. shall be 4" }
WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1,1])! { dg-error "array elements of the SUB argument to IMAGE_INDEX at .1. shall be 4" }
end subroutine
subroutine this_image_check()
integer,save :: a(1,2,3,5)[0:3,*]
integer :: j
integer,save :: z(4)[*], i
j = this_image(a,dim=3) ! { dg-error "not a valid codimension index" }
j = this_image(dim=3) ! { dg-error "DIM argument without COARRAY argument" }
i = image_index(i, [ 1 ]) ! { dg-error "Expected coarray variable" }
i = image_index(z, 2) ! { dg-error "must be a rank one array" }
end subroutine this_image_check
subroutine rank_mismatch()
implicit none
integer,allocatable :: A(:)[:,:,:,:]
allocate(A(1)[1,1,1:*]) ! { dg-error "Too few codimensions" }
allocate(A(1)[1,1,1,1,1,*]) ! { dg-error "Invalid codimension 5" }
allocate(A(1)[1,1,1,*])
allocate(A(1)[1,1]) ! { dg-error "Too few codimensions" }
allocate(A(1)[1,*]) ! { dg-error "Too few codimensions" }
allocate(A(1)[1,1:*]) ! { dg-error "Too few codimensions" }
A(1)[1,1,1] = 1 ! { dg-error "Too few codimensions" }
A(1)[1,1,1,1,1,1] = 1 ! { dg-error "Invalid codimension 5" }
A(1)[1,1,1,1] = 1
A(1)[1,1] = 1 ! { dg-error "Too few codimensions" }
A(1)[1,1] = 1 ! { dg-error "Too few codimensions" }
A(1)[1,1:1] = 1 ! { dg-error "Too few codimensions" }
end subroutine rank_mismatch
subroutine rank_mismatch2()
implicit none
integer, allocatable:: A(:)[:,:,:]
allocate(A(1)[7:8,4:*]) ! { dg-error "Too few codimensions" }
end subroutine rank_mismatch2
| gpl-2.0 |
bftg/gcc-5.3.0 | gcc/testsuite/gfortran.dg/ichar_1.f90 | 163 | 2107 | ! { dg-do compile }
! { dg-options "-std=legacy" }
!
! PR20879
! Check that we reject expressions longer than one character for the
! ICHAR and IACHAR intrinsics.
! Assumed length variables are special because the frontend doesn't have
! an expression for their length
subroutine test (c)
character(len=*) :: c
integer i
i = ichar(c)
i = ichar(c(2:))
i = ichar(c(:1))
end subroutine
program ichar_1
type derivedtype
character(len=4) :: addr
end type derivedtype
type derivedtype1
character(len=1) :: addr
end type derivedtype1
integer i
integer, parameter :: j = 2
character(len=8) :: c = 'abcd'
character(len=1) :: g1(2)
character(len=1) :: g2(2,2)
character*1, parameter :: s1 = 'e'
character*2, parameter :: s2 = 'ef'
type(derivedtype) :: dt
type(derivedtype1) :: dt1
if (ichar(c(3:3)) /= 97) call abort
if (ichar(c(:1)) /= 97) call abort
if (ichar(c(j:j)) /= 98) call abort
if (ichar(s1) /= 101) call abort
if (ichar('f') /= 102) call abort
g1(1) = 'a'
if (ichar(g1(1)) /= 97) call abort
if (ichar(g1(1)(:)) /= 97) call abort
g2(1,1) = 'a'
if (ichar(g2(1,1)) /= 97) call abort
i = ichar(c) ! { dg-error "must be of length one" "" }
i = ichar(c(:)) ! { dg-error "must be of length one" "" }
i = ichar(s2) ! { dg-error "must be of length one" "" }
i = ichar(c(1:2)) ! { dg-error "must be of length one" "" }
i = ichar(c(1:)) ! { dg-error "must be of length one" "" }
i = ichar('abc') ! { dg-error "must be of length one" "" }
! ichar and iachar use the same checking routines. DO a couple of tests to
! make sure it's not totally broken.
if (ichar(c(3:3)) /= 97) call abort
i = ichar(c) ! { dg-error "must be of length one" "" }
i = ichar(dt%addr(1:1))
i = ichar(dt%addr) ! { dg-error "must be of length one" "" }
i = ichar(dt%addr(1:2)) ! { dg-error "must be of length one" "" }
i = ichar(dt%addr(1:)) ! { dg-error "must be of length one" "" }
i = ichar(dt1%addr(1:1))
i = ichar(dt1%addr)
call test(g1(1))
end program ichar_1
| gpl-2.0 |
nisihara1/q-e | LR_Modules/addusdbec_nc.f90 | 9 | 3676 | !
! Copyright (C) 2001-2016 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 addusdbec_nc (ik, wgt, dpsi, dbecsum_nc)
!----------------------------------------------------------------------
!
! This routine adds to the dbecsum the term which correspond to this
! k point. After the accumulation the additional part of the charge
! is computed in addusddens.
!
USE kinds, ONLY : DP
USE lsda_mod, ONLY : nspin
USE ions_base, ONLY : nat, ityp, ntyp => nsp
USE becmod, ONLY : calbec
USE wvfct, ONLY : npwx, nbnd
USE uspp, ONLY : nkb, vkb, okvan
USE noncollin_module, ONLY : noncolin, npol
USE uspp_param, ONLY : upf, nh, nhm
USE mp_bands, ONLY : intra_bgrp_comm
USE klist, ONLY : ngk
USE lrus, ONLY : becp1
USE qpoint, ONLY : ikks, ikqs
USE control_lr, ONLY : nbnd_occ
!
IMPLICIT NONE
!
! the dummy variables
!
COMPLEX(DP) :: dbecsum_nc (nhm,nhm,nat,nspin), dpsi(npwx*npol,nbnd)
! inp/out: the sum kv of bec *
! input : contains delta psi
INTEGER :: ik
! input: the k point
REAL(DP) :: wgt
! input: the weight of this k point
!
! here the local variables
!
INTEGER :: na, nt, ih, jh, ibnd, ikb, jkb, startb, &
lastb, ijkb0, is1, is2, ijs
! counter on atoms
! counter on atomic type
! counter on solid beta functions
! counter on solid beta functions
! counter on the bands
! the real k point
! counter on solid becp
! counter on solid becp
! composite index for dbecsum
! divide among processors the sum
! auxiliary variable for counting
INTEGER :: ikk, ikq, npwq
! index of the point k
! index of the point k+q
! number of the plane-waves at point k+q
COMPLEX(DP), ALLOCATABLE :: dbecq_nc(:,:,:)
! the change of becq
IF (.NOT.okvan) RETURN
!
CALL start_clock ('addusdbec_nc')
!
ALLOCATE (dbecq_nc( nkb,npol, nbnd))
!
ikk = ikks(ik)
ikq = ikqs(ik)
npwq = ngk(ikq)
!
! First compute the product of dpsi and vkb
!
CALL calbec (npwq, vkb, dpsi, dbecq_nc)
!
! And then we add the product to becsum
!
! Band parallelization: each processor takes care of its slice of bands
!
CALL divide (intra_bgrp_comm, nbnd_occ (ikk), startb, lastb)
!
ijkb0 = 0
do nt = 1, ntyp
if (upf(nt)%tvanp ) then
do na = 1, nat
if (ityp (na) .eq.nt) then
do ih = 1, nh (nt)
ikb = ijkb0 + ih
do jh = 1, nh (nt)
jkb = ijkb0 + jh
DO ibnd = startb, lastb
ijs=0
DO is1=1,npol
DO is2=1,npol
ijs=ijs+1
dbecsum_nc(ih,jh,na,ijs)=dbecsum_nc(ih,jh,na,ijs)+&
wgt*CONJG(becp1(ik)%nc(ikb,is1,ibnd)) &
*dbecq_nc(jkb,is2,ibnd)
ENDDO
ENDDO
ENDDO
enddo
enddo
ijkb0 = ijkb0 + nh (nt)
endif
enddo
else
do na = 1, nat
if (ityp (na) .eq.nt) ijkb0 = ijkb0 + nh (nt)
enddo
endif
enddo
!
DEALLOCATE (dbecq_nc)
!
CALL stop_clock ('addusdbec_nc')
!
RETURN
!
end subroutine addusdbec_nc
| gpl-2.0 |
healpy/healpixmirror | src/f90/mod/paramfile_io.F90 | 1 | 37962 | !-----------------------------------------------------------------------------
!
! Copyright (C) 1997-2013 Krzysztof M. Gorski, Eric Hivon,
! Benjamin D. Wandelt, Anthony J. Banday,
! Matthias Bartelmann, Hans K. Eriksen,
! Frode K. Hansen, Martin Reinecke
!
!
! This file is part of HEALPix.
!
! HEALPix 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.
!
! HEALPix 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 HEALPix; if not, write to the Free Software
! Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
!
! For more information about HEALPix see http://healpix.sourceforge.net
!
!-----------------------------------------------------------------------------
! -*- f90 -*-
!
! v1.0: M. Reinecke
! v1.1: 2002-09, E. Hivon, added concatnl, scan_directories, numeric_string
! made interactive mode more user friendly
! v1.2: added parse_summarize
! v1.3: 2008-01-22, added parse_check_unused
! 2008-01-29, addition of silent keyword in parse_init
! 2008-03-25: expand environment variables (${XXX}) in parse_string
! v1.4: 2008-10-15, avoid over-running keylist in parse_summarize
! v1.5: 2009-09-07, introduces get_healpix_main_dir, get_healpix_data_dir, get_healpix_test_dir
! v1.6: 2009-11-26: bug correction in get_healpix_*_dir
! v1.7: 2011-01-03: addition of get_healpix_pixel_window_file & get_healpix_ring_weight_file
! v1.8: 2012-10-29: replaced F90 inquire with misc_utils's file_present which will accept remote files
! v1.9: 2012-11-14: deal correctly with undefined HEALPIX (or equivalent) in get_healpix_data_dir
! v2.0: 2018-05-18: added get_healpix_pixel_weight_file and get_healpix_weight_file
module paramfile_io
use healpix_types
use extension
use misc_utils
implicit none
private
public paramfile_handle, parse_init, parse_real, parse_double, parse_int, &
parse_long, parse_lgt, parse_string, parse_summarize, parse_finish, &
parse_check_unused
public concatnl, scan_directories
public get_healpix_main_dir, get_healpix_data_dir, get_healpix_test_dir
public get_healpix_pixel_window_file, get_healpix_ring_weight_file, &
get_healpix_pixel_weight_file, get_healpix_weight_file
type paramfile_handle
character(len=filenamelen) filename
character(len=filenamelen), pointer, dimension(:) :: keylist=>NULL()
character(len=filenamelen), pointer, dimension(:) :: valuelist=>NULL()
logical(LGT), pointer, dimension(:) :: usedlist=>NULL()
logical interactive, verbose
end type paramfile_handle
character(len=*), parameter, public :: ret = achar(10)//' '
character(len=*), parameter, private :: swdef = ' <default>'
contains
!=====================================================================
subroutine notify_user (keyname, rdef, rmin, rmax, ddef, dmin, dmax, &
idef, imin, imax, ldef, lmin, lmax, logdef, chdef, descr, ivalid)
!=====================================================================
! prompts user for next parameter when in interactive mode
!=====================================================================
character(len=*), intent(in) :: keyname
real(sp), intent(in), optional :: rdef, rmin, rmax
real(dp), intent(in), optional :: ddef, dmin, dmax
integer(i4b), intent(in), optional :: idef, imin, imax
integer(i8b), intent(in), optional :: ldef, lmin, lmax
logical, intent(in), optional :: logdef
character(len=*), intent(in), optional :: chdef, descr
integer(i4b), intent(in), optional, dimension(1:) :: ivalid
if (present(descr)) then
write(*,'(a)') trim(descr)
else
print *, 'Please enter a value for the key ', keyname
endif
if (present(rmin) .and. present(rmax)) then
print *, "allowed range: ", rmin, rmax
else
if (present(rmin)) print *, "min value: ", rmin
if (present(rmax)) print *, "max value: ", rmax
endif
if (present(dmin) .and. present(dmax)) then
print *, "allowed range: ", dmin, dmax
else
if (present(dmin)) print *, "min value: ", dmin
if (present(dmax)) print *, "max value: ", dmax
endif
if (present(imin) .and. present(imax)) then
print *, "allowed range: ", imin, imax
else
if (present(imin)) print *, "min value: ", imin
if (present(imax)) print *, "max value: ", imax
endif
if (present(ivalid)) then
print *, "allowed values: ",ivalid(1:)
endif
if (present(lmin) .and. present(lmax)) then
print *, "allowed range: ", lmin, lmax
else
if (present(lmin)) print *, "min value: ", lmin
if (present(lmax)) print *, "max value: ", lmax
endif
if (present(rdef)) print *, "default value: ", rdef
if (present(ddef)) print *, "default value: ", ddef
if (present(idef)) print *, "default value: ", idef
if (present(ldef)) print *, "default value: ", ldef
if (present(logdef)) print *, "default value: ", logdef
if (present(chdef)) print *, "default value: ", trim(chdef)
end subroutine notify_user
!===================================================================
function parse_init (fname, silent)
!===================================================================
character(len=*), intent(in) :: fname
type(paramfile_handle) parse_init
logical(LGT), intent(in), optional :: silent
integer :: i,cnt
character(len=filenamelen) :: line, name, value
logical(LGT) :: myverbose
! be verbose by default
myverbose = .true.
if (present(silent)) myverbose = .not.silent
if (len(trim(fname))==0) then
parse_init%filename = ''
parse_init%interactive = .true.
parse_init%verbose = .true.
parse_init%keylist => NULL()
parse_init%valuelist => NULL()
parse_init%usedlist => NULL()
cnt = 30
allocate(parse_init%keylist(cnt),parse_init%valuelist(cnt))
allocate(parse_init%usedlist(cnt))
parse_init%keylist = ''
parse_init%valuelist = ''
parse_init%usedlist = .false.
else
call assert_present (fname)
call assert(len(fname)<=filenamelen, 'Parser: error: file name too long')
parse_init%filename = fname
parse_init%interactive = .false.
parse_init%verbose = myverbose
parse_init%keylist => NULL()
parse_init%valuelist => NULL()
parse_init%usedlist => NULL()
! count valid lines
open (1, file=trim(fname))
cnt=0
do
read (1,'(a)',end=2) line
line = adjustl(line)
i=scan(line,'=')
if (i/=0 .and. line(1:1)/='#' .and. line(1:1)/='!') cnt=cnt+1
end do
2 close (1)
! read and parse valid lines
allocate(parse_init%keylist(cnt),parse_init%valuelist(cnt))
allocate(parse_init%usedlist(cnt))
open (1, file=trim(fname))
cnt=0
do
read (1,'(a)',end=3) line
line = adjustl(line)
i=scan(line,'=')
if (i/=0 .and. line(1:1)/='#' .and. line(1:1)/='!') then
cnt=cnt+1
name = trim(adjustl(line(:i-1)))
value = trim(adjustl(line(i+1:)))
if (trim(value)=="") then
write(*,'(a)') ' '
write(*,'(a)') 'ERROR: Inputs of the form '
write(*,'(a)') trim(name)//' = '
write(*,'(a)') ' (ie, defined as a blank value) are not valid'
write(*,'(a)') 'To get the default value, comment out the keyword in '&
& //trim(parse_init%filename)
write(*,'(a)') '# '//trim(name)//' = '
write(*,'(a)') "If you mean 'No file', use"
write(*,'(a)') trim(name)//" = '' "
write(*,'(a)') ' '
call fatal_error
endif
parse_init%keylist(cnt) = name
parse_init%valuelist(cnt) = value
parse_init%usedlist(cnt) = .false.
endif
end do
3 close (1)
endif
! be verbose
if (parse_init%interactive) then
write(*,'(a)') 'Interactive mode. Answer the following questions.'
write(*,'(a)') 'If no answer is entered, the default value will be taken'
else
if (parse_init%verbose) then
write(*,'(a)') 'Reading run parameters from '//trim(parse_init%filename)
write(*,'(a)') ' parameters not defined in that file will be set to their default value'
endif
endif
end function parse_init
!===================================================================
subroutine parse_summarize (handle, code, prec)
!===================================================================
type(paramfile_handle), intent(in) :: handle
character(len=*), optional, intent(in) :: code
integer(i4b), optional, intent(in) :: prec
!
integer(i4b) :: i, nkeys
character(len=filenamelen) :: name, value, next_name, command
if (handle%interactive) then
command = ''
if (present(code)) then
command = trim(code)
if (present(prec)) then
if (prec == SP) command = trim(command)//' --single'
if (prec == DP) command = trim(command)//' --double'
endif
endif
if (trim(command) /= '') then
print*,' This run can be reproduced in non-interactive mode, with the command'
print*,trim(command)//' paramfile'
print*,'where paramfile contains'
else
print*,' This run can be reproduced in non-interactive mode'
print*,'if a parameter file with the following content is provided:'
endif
nkeys = size(handle%keylist)
do i=1, nkeys
name = handle%keylist(i)
if (i < nkeys) then
next_name = handle%keylist(i+1)
else
next_name = ''
endif
value = handle%valuelist(i)
if (trim(name) /= '' .and. trim(name) /= trim(next_name)) then
if (trim(value) == '') then
write(*,'(a)') '# '//trim(name)
else
write(*,'(a)') trim(name)//' = '//trim(value)
endif
endif
enddo
print*,' '
endif
end subroutine parse_summarize
!===================================================================
subroutine parse_check_unused(handle, code)
!===================================================================
! print out unused keywords, if any
!===================================================================
type(paramfile_handle), intent(in) :: handle
character(len=*), optional, intent(in) :: code
!
integer(i4b) :: i, unused
character(len=80) :: mycode
! character(len=filenamelen) :: name, value, next_name, command
! non interactive mode
if (.not.handle%interactive) then
mycode = 'this code'
if (present(code)) mycode = trim(code)
! count unused keywords in input parameter files
unused = 0
do i=1,size(handle%keylist)
if (.not. handle%usedlist(i)) unused = unused + 1
enddo
if (unused > 0) then
print*,' '
print*,' ====================================================='
print*,' WARNING: the following keywords found in '//trim(handle%filename)
print*,' have NOT been used by '//trim(mycode)
!print*,' Make sure they are correctly spelled.'
do i=1,size(handle%keylist)
if (.not. handle%usedlist(i)) then
write(*,'(a)') trim(handle%keylist(i))//' = '//trim(handle%valuelist(i))
endif
enddo
print*,' ====================================================='
print*,' '
endif
end if
return
end subroutine parse_check_unused
!===================================================================
subroutine parse_finish (handle)
!===================================================================
type(paramfile_handle), intent(inout) :: handle
if (associated(handle%keylist)) then
deallocate(handle%keylist, handle%valuelist)
deallocate(handle%usedlist)
endif
end subroutine parse_finish
!===================================================================
subroutine find_param (handle,keyname,result,found,rdef,rmin,rmax, &
ddef,dmin,dmax,idef,imin,imax,ldef,lmin,lmax,logdef,chdef,descr, &
ivalid)
!===================================================================
! extract parameter from file or read from standard input
!===================================================================
type(paramfile_handle), intent(inout) :: handle
character(len=*), intent(in) :: keyname
character(len=*), intent(out) :: result
logical, intent(out) :: found
real(sp), intent(in), optional :: rdef, rmin, rmax
real(dp), intent(in), optional :: ddef, dmin, dmax
integer(i4b), intent(in), optional :: idef, imin, imax
integer(i8b), intent(in), optional :: ldef, lmin, lmax
logical, intent(in), optional :: logdef
character(len=*), intent(in), optional :: chdef, descr
integer(i4b), intent(in), optional, dimension(1:) :: ivalid
character(len=filenamelen) :: line, name, value
integer i
!===================================================================
found=.false.
if (handle%interactive) then
call notify_user (keyname,rdef,rmin,rmax,ddef,dmin,dmax, &
& idef,imin,imax,ldef,lmin,lmax,logdef,chdef,descr, &
& ivalid)
read (*,'(a)',err=5) result
found = (trim(result)/='')
do i=1,size(handle%keylist)
if (trim(handle%keylist(i))=='') then
handle%keylist(i) = trim(keyname)
if (found) then
handle%valuelist(i) = trim(result)
handle%usedlist(i) = .true.
else
if (present(rdef)) write(handle%valuelist(i),*) rdef
if (present(ddef)) write(handle%valuelist(i),*) ddef
if (present(idef)) write(handle%valuelist(i),*) idef
if (present(ldef)) write(handle%valuelist(i),*) ldef
if (present(logdef)) write(handle%valuelist(i),*) logdef
if (present(chdef)) handle%valuelist(i) = chdef
endif
exit
end if
end do
else
do i=1,size(handle%keylist)
if (trim(handle%keylist(i))==keyname) then
result=trim(handle%valuelist(i))
found=.true.
handle%usedlist(i) = .true.
end if
end do
2 close (1)
endif
return
5 print*,'Parser: find_param: error reading value'
call fatal_error
end subroutine find_param
!===================================================================
!===================================================================
function parse_real (handle, keyname, default, vmin, vmax, descr)
!===================================================================
!===================================================================
type(paramfile_handle), intent(inout) :: handle
character(len=*), intent(in) :: keyname
real(sp), intent(in), optional :: default, vmin, vmax
character(len=*), intent(in), optional :: descr
real(sp) :: parse_real
character(len=filenamelen) :: result
character(len=30) :: about_def
logical found
!===================================================================
10 continue
about_def = ''
call find_param (handle, trim(keyname), result, found, rdef=default, &
& rmin=vmin, rmax=vmax, descr=descr)
if (found) then
read (result,*,err=5) parse_real
else
if (present(default)) then
! print *,'Parser: warning: using default value for ',trim(keyname)
about_def = swdef
parse_real = default
else
print *,'Parser: error: ',trim(keyname),' not found.'
goto 2
endif
endif
if (handle%verbose) print *,'Parser: ',trim(keyname),' = ',parse_real, trim(about_def)
if (present(vmin)) then
if (parse_real<vmin) then
print *,'Parser: error: value for ', trim(keyname),' too small.'
goto 2
endif
endif
if (present(vmax)) then
if (parse_real>vmax) then
print *,'Parser: error: value for ', trim(keyname),' too large.'
goto 2
endif
endif
return ! normal exit
5 print*,'Parser: parse_real: error reading value'
2 if (handle%interactive) goto 10 ! try again
call fatal_error
end function parse_real
!===================================================================
function parse_double (handle, keyname, default, vmin, vmax, descr)
!===================================================================
!===================================================================
type(paramfile_handle), intent(inout) :: handle
character(len=*), intent(in) :: keyname
real(dp), intent(in), optional :: default, vmin, vmax
character(len=*), intent(in), optional :: descr
real(dp) :: parse_double
character(len=filenamelen) :: result
character(len=30) :: about_def
logical found
!===================================================================
10 continue
about_def = ''
call find_param (handle, trim(keyname), result, found, ddef=default, &
& dmin=vmin, dmax=vmax, descr=descr)
if (found) then
read (result,*,err=5) parse_double
else
if (present(default)) then
! print *,'Parser: warning: using default value for ',trim(keyname)
about_def = swdef
parse_double = default
else
print *,'Parser: error: ',trim(keyname),' not found.'
goto 2
endif
endif
if (handle%verbose) print *,'Parser: ',trim(keyname),' = ',parse_double, trim(about_def)
if (present(vmin)) then
if (parse_double<vmin) then
print *,'Parser: error: value for ', trim(keyname),' too small.'
goto 2
endif
endif
if (present(vmax)) then
if (parse_double>vmax) then
print *,'Parser: error: value for ', trim(keyname),' too large.'
goto 2
endif
endif
return ! normal exit
5 print*,'Parser: parse_double: error reading value'
2 if (handle%interactive) goto 10 ! try again
call fatal_error
end function parse_double
!==================================================================
function parse_int (handle, keyname, default, vmin, vmax, descr, valid)
!==================================================================
! parse 4 byte integer parameter
!==================================================================
type(paramfile_handle), intent(inout) :: handle
character(len=*), intent(in) :: keyname
integer(i4b), intent(in), optional :: default, vmin, vmax
integer(i4b), intent(in), optional, dimension(1:) :: valid
character(len=*), intent(in), optional :: descr
integer(i4b) :: parse_int
character(len=filenamelen) :: result
character(len=30) :: about_def
logical :: found
integer(i4b) :: i
!==================================================================
10 continue
about_def = ''
call find_param (handle, trim(keyname), result, found, idef=default, &
& imin=vmin, imax=vmax, descr=descr, ivalid=valid)
if (found) then
read (result,*,err=5) parse_int
else
if (present(default)) then
! print *,'Parser: warning: using default value for ',trim(keyname)
about_def = swdef
parse_int = default
else
print *,'Parser: error: ',trim(keyname),' not found.'
goto 2
endif
endif
if (handle%verbose) print *,'Parser: ',trim(keyname),' = ',parse_int, trim(about_def)
if (present(vmin)) then
if (parse_int<vmin) then
print *,'Parser: error: value for ', trim(keyname),' too small.'
goto 2
endif
endif
if (present(vmax)) then
if (parse_int>vmax) then
print *,'Parser: error: value for ', trim(keyname),' too large.'
goto 2
endif
endif
if (present(valid)) then
found = .false.
do i=1, size(valid)
if (parse_int == valid(i)) found=.true.
enddo
if (.not.found) then
print *,'Parser: error: invalid value for '//trim(keyname)
goto 2
endif
endif
return ! normal exit
5 print*,'Parser: parse_int: error reading value'
2 if (handle%interactive) goto 10 ! try again
call fatal_error
end function parse_int
!==================================================================
!==================================================================
function parse_long (handle, keyname, default, vmin, vmax, descr)
!==================================================================
! parse 8 byte integer parameter
!==================================================================
type(paramfile_handle), intent(inout) :: handle
character(len=*), intent(in) :: keyname
integer(i8b), intent(in), optional :: default, vmin, vmax
character(len=*), intent(in), optional :: descr
integer(i8b) :: parse_long
character(len=filenamelen) :: result
character(len=30) :: about_def
logical found
!==================================================================
10 continue
about_def = ''
call find_param (handle, trim(keyname), result, found, ldef=default, &
lmin=vmin, lmax=vmax, descr=descr)
if (found) then
read (result,*,err=5) parse_long
else
if (present(default)) then
! print *,'Parser: warning: using default value for ',trim(keyname)
about_def = swdef
parse_long = default
else
print *,'Parser: error: ',trim(keyname),' not found.'
goto 2
endif
endif
if (handle%verbose) print *,'Parser: ',trim(keyname),' = ',parse_long, trim(about_def)
if (present(vmin)) then
if (parse_long<vmin) then
print *,'Parser: error: value for ', trim(keyname),' too small.'
goto 2
endif
endif
if (present(vmax)) then
if (parse_long>vmax) then
print *,'Parser: error: value for ', trim(keyname),' too large.'
goto 2
endif
endif
return ! normal exit
5 print*,'Parser: parse_long: error reading value'
2 if (handle%interactive) goto 10 ! try again
call fatal_error
end function parse_long
!===================================================================
function parse_lgt (handle, keyname, default, descr)
!===================================================================
! parse (1 byte) logical parameter
!===================================================================
type(paramfile_handle), intent(inout) :: handle
character(len=*), intent(in) :: keyname
logical, intent(in), optional :: default
character(len=*), intent(in), optional :: descr
logical :: parse_lgt
character(len=filenamelen) :: result
character(len=30) :: about_def
logical found
!===================================================================
10 continue
about_def = ''
call find_param (handle, trim(keyname), result, found, logdef=default, &
& descr=descr)
if (found) then
select case (strupcase(result))
case ('Y','YES','T','TRUE', '.TRUE.','1')
parse_lgt = .true.
case ('N','NO', 'F','FALSE','.FALSE.','0')
parse_lgt= .false.
case default
goto 5
end select
else
if (present(default)) then
! print *,'Parser: warning: using default value for ',trim(keyname)
parse_lgt = default
else
print *,'Parser: error: ',trim(keyname),' not found.'
goto 2
endif
endif
if (handle%verbose) print *,'Parser: ',trim(keyname),' = ',parse_lgt, trim(about_def)
return ! normal exit
5 print*,'Parser: parse_lgt: error reading value'
2 if (handle%interactive) goto 10 ! try again
call fatal_error
end function parse_lgt
!===================================================================
function parse_string (handle, keyname, default, descr, filestatus, options)
!===================================================================
! parse a character string parameter
!
! if filestatus is 'old', look for an existing file having the name of the string
!
! if filestatus is 'new', no file with the exact same name as the string should exist
!
! options is the list of valid options
!
!===================================================================
type(paramfile_handle), intent(inout) :: handle
character(len=*), intent(in) :: keyname
character(len=*), intent(in), optional :: default
character(len=*), intent(in), optional :: descr
character(len=*), intent(in), optional :: filestatus
character(len=*), intent(in), optional, dimension(1:) :: options
character(len=filenamelen) :: parse_string
character(len=filenamelen) :: result
character(len=30) :: about_def
logical :: found, there
integer :: i
!===================================================================
10 continue
about_def = ''
call find_param (handle, trim(keyname), result, found, chdef=default, &
descr=descr)
if (found) then
parse_string = trim(result)
else
if (present(default)) then
! write(*,'(1x,a)') 'Parser: warning: using default value for '//trim(keyname)
about_def = swdef
parse_string = trim(default)
else
write(*,'(1x,a)') 'Parser: error: '//trim(keyname)//' not found.'
goto 2
endif
endif
parse_string = expand_env_var(parse_string)
if (handle%verbose) write(*,'(1x,a)') 'Parser: '//trim(keyname)//' = '//trim(parse_string)//trim(about_def)
! 0 (zero), '' and ' ' (2 single quotes with nothing or one space in between)
! are interpreted as "No File"
if (trim(adjustl(parse_string)) == "0" ) parse_string = ''
if (trim(adjustl(parse_string)) == "''") parse_string = ''
if (trim(adjustl(parse_string)) == "' '") parse_string = ''
if (present(filestatus) .and. trim(parse_string) /= '') then
if (trim(filestatus)=='new' .or. trim(filestatus)=='NEW') then
!inquire(file=trim(parse_string),exist=there)
there = file_present(trim(parse_string))
if (there) then
print *, 'Parser: error: output file ' // trim(parse_string) // &
' already exists!'
goto 2
end if
else if (trim(filestatus)=='old' .or. trim(filestatus)=='OLD') then
!inquire(file=trim(parse_string),exist=there)
there = file_present(trim(parse_string))
if (.not. there) then
print *, 'Parser: error: input file ' // trim(parse_string) // &
' does not exist!'
goto 2
end if
else
print *, 'Parser: error: wrong value for filestatus :',filestatus
call fatal_error
endif
endif
if (present(options)) then
do i=1, size(options)
if (trim(adjustl(parse_string)) == trim(adjustl(options(i)))) goto 5
enddo
print*,'Invalid choice'
goto 2
5 continue
endif
return ! normal exit
2 if (handle%interactive) goto 10 ! try again
call fatal_error
end function parse_string
!========================================================================
function concatnl(line1,line2,line3,line4,line5,line6,line7,line8,line9,line10)
!========================================================================
! concatenate line1, line2, line3,... into one string,
! while putting a char(10) Line Feed in between
!========================================================================
character(len=*), intent(in) :: line1
character(len=*), intent(in), optional :: line2,line3,line4,line5
character(len=*), intent(in), optional :: line6,line7,line8,line9,line10
character(len=filenamelen) :: concatnl
concatnl = trim(line1)
if (present(line2)) concatnl = trim(concatnl)//ret//trim(line2)
if (present(line3)) concatnl = trim(concatnl)//ret//trim(line3)
if (present(line4)) concatnl = trim(concatnl)//ret//trim(line4)
if (present(line5)) concatnl = trim(concatnl)//ret//trim(line5)
if (present(line6)) concatnl = trim(concatnl)//ret//trim(line6)
if (present(line7)) concatnl = trim(concatnl)//ret//trim(line7)
if (present(line8)) concatnl = trim(concatnl)//ret//trim(line8)
if (present(line9)) concatnl = trim(concatnl)//ret//trim(line9)
if (present(line10)) concatnl = trim(concatnl)//ret//trim(line10)
end function concatnl
!========================================================================
!========================================================================
function scan_directories(directories, filename, fullpath)
!========================================================================
! scan directories in search of filename,
! if found, returns .true. and the full path is in fullpath.
! The search is *NOT* recursive
!
! it assumes that the given directory and filename are separated by either
! nothing, a / (slash) or a \ (backslash)
!
! if several directories are to be searched (up to 20),
! concatenate them into 'directories',
! putting a special character (ASCII < 32) between them.
! see concatnl
! NB: a space is not a special character
!========================================================================
logical(LGT) :: scan_directories
character(len=*), intent(in) :: filename, directories
character(len=*), intent(out) :: fullpath
logical :: found
integer(I4B), dimension(1:20) :: index
integer(I4B) :: i, k, nc, nspecial
character(len=1) :: ch
character(len=filenamelen) :: directory
character(len=3000) :: string
character(LEN=1), DIMENSION(1:3) :: separator
character(len=*), parameter :: code = 'scan_directories'
!========================================================================
! define separators (this is the only way that works for all compilers)
separator(1) = char(32) ! ' '
separator(2) = char(47) ! '/'
separator(3) = char(92) ! '\'
! find location of special characters
nc = len_trim(directories)
index(1) = 0
nspecial = 2
do i=1,nc
ch = directories(i:i)
if (iachar(ch) < 32) then
index(nspecial) = i
nspecial = nspecial + 1
endif
enddo
index(nspecial) = nc + 1
! test string between special character as potential directory
fullpath = ''
found = .false.
do i = 1, nspecial-1
directory=trim(adjustl(directories(index(i)+1:index(i+1)-1)))
do k = 1, size(separator)
string = trim(directory)//trim(separator(k))//trim(filename)
! inquire(&
! & file=string, &
! & exist=found)
found = file_present(string)
if (found) goto 10
enddo
enddo
10 continue
if (found) then
if (len(fullpath) >= len_trim(string)) then
fullpath = trim(string)
else
print*,code
print*,'variable fullpath is not large enough'
print*,'requires ',len_trim(string),' characters'
print*,'has only ',trim(fullpath)
call fatal_error
endif
endif
scan_directories = found
end function scan_directories
!-----------------------------------------------------------
function get_healpix_main_dir() result (hmd)
character(len=FILENAMELEN) :: hmd
!-----------------------------------------------------------
! healpix_dir = get_healpix_main_dir()
! returns the full path to the HEALPIX main directory
! using
! 1) the preprocessing macros
! 1a HEALPIX
! 1b HEALPIXDIR
! 2) the environment variable
! 2a HEALPIX
!-----------------------------------------------------------
hmd = ''
! print*,'get_healpix_main'
#ifdef HEALPIX
hmd = HEALPIX
#else
#ifdef HEALPIXDIR
hmd = HEALPIXDIR
#else
call getEnvironment('HEALPIX',hmd)
#endif
#endif
if (trim(hmd) == '') then
!!! call fatal_error("Can not determine main HEALPIX directory")
else
hmd = trim(hmd) // '/'
endif
return
end function get_healpix_main_dir
!-----------------------------------------------------------
function get_healpix_data_dir() result (hdd)
character(len=FILENAMELEN) :: hdd
character(len=FILENAMELEN) :: def_dir, healpixdir
!-----------------------------------------------------------
! healpix_data_dir = get_healpix_data_dir()
! returns the full path to the HEALPIX DATA directory
! using
! 1) the preprocessing macro
! HEALPIXDATA
! 2) the environment variable
! $HEALPIXDATA
! otherwise, it will return the list of directories:
! .
! ../data
! ./data
! ..
! (and if $HEALPIX is defined)
! $HEALPIX
! $HEALPIX/data
! $HEALPIX/../data
! $HEALPIX\data
! separated by LineFeed
!
! bug correction 2009-11-26
! treat correctly the case where HEALPIX not defined 2012-11-14
!-----------------------------------------------------------
hdd = ''
! print*,'get_healpix_data'
#ifdef HEALPIXDATA
hdd = HEALPIXDATA
#else
call getEnvironment('HEALPIXDATA',hdd)
if (trim(hdd) == '') then
def_dir = concatnl("","../data","./data","..")
healpixdir = get_healpix_main_dir()
if (trim(healpixdir) /= "") then ! if $HEALPIX defined
! def_dir = concatnl(&
hdd = concatnl(&
& def_dir, &
& healpixdir, &
& trim(healpixdir)//"/data", &
& trim(healpixdir)//"/../data", &
& trim(healpixdir)//char(92)//"data") !backslash
else ! if $HEALPIX (or equivalent) not defined
hdd = def_dir
endif
endif
#endif
if (trim(hdd) == '') then
!!! call fatal_error("Can not determine HEALPIX DATA directory")
else
hdd = trim(hdd) // '/'
endif
return
end function get_healpix_data_dir
!-----------------------------------------------------------
function get_healpix_test_dir() result (htd)
character(len=FILENAMELEN) :: htd
character(len=FILENAMELEN) :: hmd
!-----------------------------------------------------------
! healpix_test_dir = get_healpix_test_dir()
! returns the full path to the HEALPIX TEST directory
! using
! 1) the preprocessing macro
! HEALPIXTEST
! 2) the environment variable
! $HEALPIXTEST
! 3)
! $HEALPIX/test
! bug correction 2009-11-26
!-----------------------------------------------------------
htd = ''
! print*,'get_healpix_test'
#ifdef HEALPIXTEST
htd = HEALPIXTEST
#else
call getEnvironment('HEALPIXTEST',htd)
if (trim(htd) == '') then
call getEnvironment('HEALPIX',hmd)
if (trim(hmd) /= '') then ! bug correction
htd = trim(hmd)//'/test'
endif
endif
#endif
if (trim(htd) == '') then
!!! call fatal_error("Can not determine HEALPIX TEST directory")
else
htd = trim(htd) // '/'
endif
return
end function get_healpix_test_dir
!-----------------------------------------------------------
! file = get_healpix_pixel_window_file(nside)
! returns default file name of Healpix pixel window
!-----------------------------------------------------------
function get_healpix_pixel_window_file(nside) result(filename)
integer(i4b), intent(in) :: nside
character(len=FILENAMELEN) :: filename
character(len=6) :: sstr
if (nside <= 8192) then
sstr = adjustl(string(nside,'(i4.4)'))
else
sstr = adjustl(string(nside,'(i6.6)'))
endif
filename = "pixel_window_n"//trim(sstr)//".fits"
end function get_healpix_pixel_window_file
!-----------------------------------------------------------
! file = get_healpix_ring_weight_file(nside)
! returns default file name of Healpix ring weights
!-----------------------------------------------------------
function get_healpix_ring_weight_file(nside) result (filename)
integer(i4b), intent(in) :: nside
character(len=FILENAMELEN) :: filename
character(len=6) :: sstr
if (nside <= 8192) then
sstr = adjustl(string(nside,'(i5.5)'))
else
sstr = adjustl(string(nside,'(i6.6)'))
endif
filename = "weight_ring_n"//trim(sstr)//".fits"
end function get_healpix_ring_weight_file
!-----------------------------------------------------------
! file = get_healpix_pixel_weight_file(nside)
! returns default file name of Healpix pixel weights
!-----------------------------------------------------------
function get_healpix_pixel_weight_file(nside) result (filename)
integer(i4b), intent(in) :: nside
character(len=FILENAMELEN) :: filename
character(len=6) :: sstr
if (nside <= 8192) then
sstr = adjustl(string(nside,'(i5.5)'))
else
sstr = adjustl(string(nside,'(i6.6)'))
endif
filename = "weight_pixel_n"//trim(sstr)//".fits"
end function get_healpix_pixel_weight_file
!-----------------------------------------------------------
! file = get_healpix_weight_file(nside, type)
! returns default file name of Healpix ring weights (if type=1)
! or pixel weigts (if type=2)
!-----------------------------------------------------------
function get_healpix_weight_file(nside, type) result (filename)
integer(i4b), intent(in) :: nside, type
character(len=FILENAMELEN) :: filename
if (type == 0) then
filename = ''
else if (type == 1) then
filename = get_healpix_ring_weight_file(nside)
else if (type == 2) then
filename = get_healpix_pixel_weight_file(nside)
else
print*,'Wrong choice of weight: must be either'
print*,' 0: no weight'
print*,' 1: ring-based weights'
print*,' 2: pixel-based weights'
print*,' value: '//string(type)
call fatal_error
endif
end function get_healpix_weight_file
end module paramfile_io
| gpl-2.0 |
cpatrick/ITK-RemoteIO | Modules/ThirdParty/VNL/src/vxl/v3p/netlib/lapack/single/sggsvp.f | 43 | 11543 | SUBROUTINE SGGSVP( JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB,
$ TOLA, TOLB, K, L, U, LDU, V, LDV, Q, LDQ,
$ IWORK, TAU, WORK, 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 JOBQ, JOBU, JOBV
INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P
REAL TOLA, TOLB
* ..
* .. Array Arguments ..
INTEGER IWORK( * )
REAL A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
$ TAU( * ), U( LDU, * ), V( LDV, * ), WORK( * )
* ..
*
* Purpose
* =======
*
* SGGSVP computes orthogonal matrices U, V and Q such that
*
* N-K-L K L
* U'*A*Q = K ( 0 A12 A13 ) if M-K-L >= 0;
* L ( 0 0 A23 )
* M-K-L ( 0 0 0 )
*
* N-K-L K L
* = K ( 0 A12 A13 ) if M-K-L < 0;
* M-K ( 0 0 A23 )
*
* N-K-L K L
* V'*B*Q = L ( 0 0 B13 )
* P-L ( 0 0 0 )
*
* where the K-by-K matrix A12 and L-by-L matrix B13 are nonsingular
* upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0,
* otherwise A23 is (M-K)-by-L upper trapezoidal. K+L = the effective
* numerical rank of the (M+P)-by-N matrix (A',B')'. Z' denotes the
* transpose of Z.
*
* This decomposition is the preprocessing step for computing the
* Generalized Singular Value Decomposition (GSVD), see subroutine
* SGGSVD.
*
* Arguments
* =========
*
* JOBU (input) CHARACTER*1
* = 'U': Orthogonal matrix U is computed;
* = 'N': U is not computed.
*
* JOBV (input) CHARACTER*1
* = 'V': Orthogonal matrix V is computed;
* = 'N': V is not computed.
*
* JOBQ (input) CHARACTER*1
* = 'Q': Orthogonal matrix Q is computed;
* = 'N': Q is not computed.
*
* M (input) INTEGER
* The number of rows of the matrix A. M >= 0.
*
* P (input) INTEGER
* The number of rows of the matrix B. P >= 0.
*
* N (input) INTEGER
* The number of columns of the matrices A and B. N >= 0.
*
* A (input/output) REAL array, dimension (LDA,N)
* On entry, the M-by-N matrix A.
* On exit, A contains the triangular (or trapezoidal) matrix
* described in the Purpose section.
*
* LDA (input) INTEGER
* The leading dimension of the array A. LDA >= max(1,M).
*
* B (input/output) REAL array, dimension (LDB,N)
* On entry, the P-by-N matrix B.
* On exit, B contains the triangular matrix described in
* the Purpose section.
*
* LDB (input) INTEGER
* The leading dimension of the array B. LDB >= max(1,P).
*
* TOLA (input) REAL
* TOLB (input) REAL
* TOLA and TOLB are the thresholds to determine the effective
* numerical rank of matrix B and a subblock of A. Generally,
* they are set to
* TOLA = MAX(M,N)*norm(A)*MACHEPS,
* TOLB = MAX(P,N)*norm(B)*MACHEPS.
* The size of TOLA and TOLB may affect the size of backward
* errors of the decomposition.
*
* K (output) INTEGER
* L (output) INTEGER
* On exit, K and L specify the dimension of the subblocks
* described in Purpose.
* K + L = effective numerical rank of (A',B')'.
*
* U (output) REAL array, dimension (LDU,M)
* If JOBU = 'U', U contains the orthogonal matrix U.
* If JOBU = 'N', U is not referenced.
*
* LDU (input) INTEGER
* The leading dimension of the array U. LDU >= max(1,M) if
* JOBU = 'U'; LDU >= 1 otherwise.
*
* V (output) REAL array, dimension (LDV,M)
* If JOBV = 'V', V contains the orthogonal matrix V.
* If JOBV = 'N', V is not referenced.
*
* LDV (input) INTEGER
* The leading dimension of the array V. LDV >= max(1,P) if
* JOBV = 'V'; LDV >= 1 otherwise.
*
* Q (output) REAL array, dimension (LDQ,N)
* If JOBQ = 'Q', Q contains the orthogonal matrix Q.
* If JOBQ = 'N', Q is not referenced.
*
* LDQ (input) INTEGER
* The leading dimension of the array Q. LDQ >= max(1,N) if
* JOBQ = 'Q'; LDQ >= 1 otherwise.
*
* IWORK (workspace) INTEGER array, dimension (N)
*
* TAU (workspace) REAL array, dimension (N)
*
* WORK (workspace) REAL array, dimension (max(3*N,M,P))
*
* INFO (output) INTEGER
* = 0: successful exit
* < 0: if INFO = -i, the i-th argument had an illegal value.
*
*
* Further Details
* ===============
*
* The subroutine uses LAPACK subroutine SGEQPF for the QR factorization
* with column pivoting to detect the effective numerical rank of the
* a matrix. It may be replaced by a better rank determination strategy.
*
* =====================================================================
*
* .. Parameters ..
REAL ZERO, ONE
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
* ..
* .. Local Scalars ..
LOGICAL FORWRD, WANTQ, WANTU, WANTV
INTEGER I, J
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. External Subroutines ..
EXTERNAL SGEQPF, SGEQR2, SGERQ2, SLACPY, SLAPMT, SLASET,
$ SORG2R, SORM2R, SORMR2, XERBLA
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, MAX, MIN
* ..
* .. Executable Statements ..
*
* Test the input parameters
*
WANTU = LSAME( JOBU, 'U' )
WANTV = LSAME( JOBV, 'V' )
WANTQ = LSAME( JOBQ, 'Q' )
FORWRD = .TRUE.
*
INFO = 0
IF( .NOT.( WANTU .OR. LSAME( JOBU, 'N' ) ) ) THEN
INFO = -1
ELSE IF( .NOT.( WANTV .OR. LSAME( JOBV, 'N' ) ) ) THEN
INFO = -2
ELSE IF( .NOT.( WANTQ .OR. LSAME( JOBQ, 'N' ) ) ) THEN
INFO = -3
ELSE IF( M.LT.0 ) THEN
INFO = -4
ELSE IF( P.LT.0 ) THEN
INFO = -5
ELSE IF( N.LT.0 ) THEN
INFO = -6
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
INFO = -8
ELSE IF( LDB.LT.MAX( 1, P ) ) THEN
INFO = -10
ELSE IF( LDU.LT.1 .OR. ( WANTU .AND. LDU.LT.M ) ) THEN
INFO = -16
ELSE IF( LDV.LT.1 .OR. ( WANTV .AND. LDV.LT.P ) ) THEN
INFO = -18
ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THEN
INFO = -20
END IF
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'SGGSVP', -INFO )
RETURN
END IF
*
* QR with column pivoting of B: B*P = V*( S11 S12 )
* ( 0 0 )
*
DO 10 I = 1, N
IWORK( I ) = 0
10 CONTINUE
CALL SGEQPF( P, N, B, LDB, IWORK, TAU, WORK, INFO )
*
* Update A := A*P
*
CALL SLAPMT( FORWRD, M, N, A, LDA, IWORK )
*
* Determine the effective rank of matrix B.
*
L = 0
DO 20 I = 1, MIN( P, N )
IF( ABS( B( I, I ) ).GT.TOLB )
$ L = L + 1
20 CONTINUE
*
IF( WANTV ) THEN
*
* Copy the details of V, and form V.
*
CALL SLASET( 'Full', P, P, ZERO, ZERO, V, LDV )
IF( P.GT.1 )
$ CALL SLACPY( 'Lower', P-1, N, B( 2, 1 ), LDB, V( 2, 1 ),
$ LDV )
CALL SORG2R( P, P, MIN( P, N ), V, LDV, TAU, WORK, INFO )
END IF
*
* Clean up B
*
DO 40 J = 1, L - 1
DO 30 I = J + 1, L
B( I, J ) = ZERO
30 CONTINUE
40 CONTINUE
IF( P.GT.L )
$ CALL SLASET( 'Full', P-L, N, ZERO, ZERO, B( L+1, 1 ), LDB )
*
IF( WANTQ ) THEN
*
* Set Q = I and Update Q := Q*P
*
CALL SLASET( 'Full', N, N, ZERO, ONE, Q, LDQ )
CALL SLAPMT( FORWRD, N, N, Q, LDQ, IWORK )
END IF
*
IF( P.GE.L .AND. N.NE.L ) THEN
*
* RQ factorization of (S11 S12): ( S11 S12 ) = ( 0 S12 )*Z
*
CALL SGERQ2( L, N, B, LDB, TAU, WORK, INFO )
*
* Update A := A*Z'
*
CALL SORMR2( 'Right', 'Transpose', M, N, L, B, LDB, TAU, A,
$ LDA, WORK, INFO )
*
IF( WANTQ ) THEN
*
* Update Q := Q*Z'
*
CALL SORMR2( 'Right', 'Transpose', N, N, L, B, LDB, TAU, Q,
$ LDQ, WORK, INFO )
END IF
*
* Clean up B
*
CALL SLASET( 'Full', L, N-L, ZERO, ZERO, B, LDB )
DO 60 J = N - L + 1, N
DO 50 I = J - N + L + 1, L
B( I, J ) = ZERO
50 CONTINUE
60 CONTINUE
*
END IF
*
* Let N-L L
* A = ( A11 A12 ) M,
*
* then the following does the complete QR decomposition of A11:
*
* A11 = U*( 0 T12 )*P1'
* ( 0 0 )
*
DO 70 I = 1, N - L
IWORK( I ) = 0
70 CONTINUE
CALL SGEQPF( M, N-L, A, LDA, IWORK, TAU, WORK, INFO )
*
* Determine the effective rank of A11
*
K = 0
DO 80 I = 1, MIN( M, N-L )
IF( ABS( A( I, I ) ).GT.TOLA )
$ K = K + 1
80 CONTINUE
*
* Update A12 := U'*A12, where A12 = A( 1:M, N-L+1:N )
*
CALL SORM2R( 'Left', 'Transpose', M, L, MIN( M, N-L ), A, LDA,
$ TAU, A( 1, N-L+1 ), LDA, WORK, INFO )
*
IF( WANTU ) THEN
*
* Copy the details of U, and form U
*
CALL SLASET( 'Full', M, M, ZERO, ZERO, U, LDU )
IF( M.GT.1 )
$ CALL SLACPY( 'Lower', M-1, N-L, A( 2, 1 ), LDA, U( 2, 1 ),
$ LDU )
CALL SORG2R( M, M, MIN( M, N-L ), U, LDU, TAU, WORK, INFO )
END IF
*
IF( WANTQ ) THEN
*
* Update Q( 1:N, 1:N-L ) = Q( 1:N, 1:N-L )*P1
*
CALL SLAPMT( FORWRD, N, N-L, Q, LDQ, IWORK )
END IF
*
* Clean up A: set the strictly lower triangular part of
* A(1:K, 1:K) = 0, and A( K+1:M, 1:N-L ) = 0.
*
DO 100 J = 1, K - 1
DO 90 I = J + 1, K
A( I, J ) = ZERO
90 CONTINUE
100 CONTINUE
IF( M.GT.K )
$ CALL SLASET( 'Full', M-K, N-L, ZERO, ZERO, A( K+1, 1 ), LDA )
*
IF( N-L.GT.K ) THEN
*
* RQ factorization of ( T11 T12 ) = ( 0 T12 )*Z1
*
CALL SGERQ2( K, N-L, A, LDA, TAU, WORK, INFO )
*
IF( WANTQ ) THEN
*
* Update Q( 1:N,1:N-L ) = Q( 1:N,1:N-L )*Z1'
*
CALL SORMR2( 'Right', 'Transpose', N, N-L, K, A, LDA, TAU,
$ Q, LDQ, WORK, INFO )
END IF
*
* Clean up A
*
CALL SLASET( 'Full', K, N-L-K, ZERO, ZERO, A, LDA )
DO 120 J = N - L - K + 1, N - L
DO 110 I = J - N + L + K + 1, K
A( I, J ) = ZERO
110 CONTINUE
120 CONTINUE
*
END IF
*
IF( M.GT.K ) THEN
*
* QR factorization of A( K+1:M,N-L+1:N )
*
CALL SGEQR2( M-K, L, A( K+1, N-L+1 ), LDA, TAU, WORK, INFO )
*
IF( WANTU ) THEN
*
* Update U(:,K+1:M) := U(:,K+1:M)*U1
*
CALL SORM2R( 'Right', 'No transpose', M, M-K, MIN( M-K, L ),
$ A( K+1, N-L+1 ), LDA, TAU, U( 1, K+1 ), LDU,
$ WORK, INFO )
END IF
*
* Clean up
*
DO 140 J = N - L + 1, N
DO 130 I = J - N + K + L + 1, M
A( I, J ) = ZERO
130 CONTINUE
140 CONTINUE
*
END IF
*
RETURN
*
* End of SGGSVP
*
END
| apache-2.0 |
ARTED/ARTED_noc | src/PSE_read_matrix_elements.f90 | 1 | 2205 | !
! Copyright 2016 ARTED developers
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
subroutine PSE_read_matrix_elements
use global_variables
implicit none
integer :: ik
character(50) :: cik, filename
if(myrank == 0)write(*,"(A)")"== Start reading matrix elements."
if(myrank == 0)then
open(200,file="basis_exp_basic.out",form='unformatted')
read(200)NB_basis
read(200)Amax,dAmax
read(200)Epdir_1
close(200)
end if
call MPI_BCAST(NB_basis,1,MPI_INTEGER,0,MPI_COMM_WORLD,ierr)
call MPI_BCAST(Amax,1,MPI_DOUBLE_PRECISION,0,MPI_COMM_WORLD,ierr)
call MPI_BCAST(dAmax,1,MPI_DOUBLE_PRECISION,0,MPI_COMM_WORLD,ierr)
call MPI_BCAST(Epdir_1,3,MPI_DOUBLE_PRECISION,0,MPI_COMM_WORLD,ierr)
if(abs(dble(NAmax) -Amax/dAmax) > 0.01d0)then
err_message='NAmax is not consistent.'
call err_finalize
end if
allocate(zH_loc(NB_basis,NB_basis,NK_s:NK_e))
allocate(zPi_loc(NB_basis,NB_basis,NK_s:NK_e))
allocate(zV_NL(NB_basis,NB_basis,NK_s:NK_e,-NAmax:NAmax))
allocate(zPi_NL(NB_basis,NB_basis,NK_s:NK_e,-NAmax:NAmax))
allocate(zH_tot(NB_basis,NB_basis,NK_s:NK_e))
allocate(zPi_tot(NB_basis,NB_basis,NK_s:NK_e))
allocate(zH0_tot(NB_basis,NB_basis,NK_s:NK_e))
allocate(zdH_tot(NB_basis,NB_basis,NK_s:NK_e))
allocate(H0_eigval(NB_basis,NK_s:NK_e))
do ik = NK_s,NK_e
write(cik,"(I9.9)")ik
filename=trim(cik)//"_matrix_elements.out"
open(201,file=filename,form='unformatted')
read(201)zH_loc(:,:,ik)
read(201)zPi_loc(:,:,ik)
read(201)zV_NL(:,:,ik,:)
read(201)zPi_NL(:,:,ik,:)
close(201)
end do
if(myrank == 0)write(*,"(A)")"== End reading matrix elements."
return
end subroutine PSE_read_matrix_elements
| apache-2.0 |
SaberMod/GCC_SaberMod | gcc/testsuite/gfortran.dg/interface_16.f90 | 155 | 3123 | ! { dg-do compile }
! This tests the fix for PR32634, in which the generic interface
! in foo_pr_mod was given the original rather than the local name.
! This meant that the original name had to be used in the calll
! in foo_sub.
!
! Contributed by Salvatore Filippone <salvatore.filippone@uniroma2.it>
module foo_base_mod
type foo_dmt
real(kind(1.d0)), allocatable :: rv(:)
integer, allocatable :: iv1(:), iv2(:)
end type foo_dmt
type foo_zmt
complex(kind(1.d0)), allocatable :: rv(:)
integer, allocatable :: iv1(:), iv2(:)
end type foo_zmt
type foo_cdt
integer, allocatable :: md(:)
integer, allocatable :: hi(:), ei(:)
end type foo_cdt
end module foo_base_mod
module bar_prt
use foo_base_mod, only : foo_dmt, foo_zmt, foo_cdt
type bar_dbprt
type(foo_dmt), allocatable :: av(:)
real(kind(1.d0)), allocatable :: d(:)
type(foo_cdt) :: cd
end type bar_dbprt
type bar_dprt
type(bar_dbprt), allocatable :: bpv(:)
end type bar_dprt
type bar_zbprt
type(foo_zmt), allocatable :: av(:)
complex(kind(1.d0)), allocatable :: d(:)
type(foo_cdt) :: cd
end type bar_zbprt
type bar_zprt
type(bar_zbprt), allocatable :: bpv(:)
end type bar_zprt
end module bar_prt
module bar_pr_mod
use bar_prt
interface bar_pwrk
subroutine bar_dppwrk(pr,x,y,cd,info,trans,work)
use foo_base_mod
use bar_prt
type(foo_cdt),intent(in) :: cd
type(bar_dprt), intent(in) :: pr
real(kind(0.d0)),intent(inout) :: x(:), y(:)
integer, intent(out) :: info
character(len=1), optional :: trans
real(kind(0.d0)),intent(inout), optional, target :: work(:)
end subroutine bar_dppwrk
subroutine bar_zppwrk(pr,x,y,cd,info,trans,work)
use foo_base_mod
use bar_prt
type(foo_cdt),intent(in) :: cd
type(bar_zprt), intent(in) :: pr
complex(kind(0.d0)),intent(inout) :: x(:), y(:)
integer, intent(out) :: info
character(len=1), optional :: trans
complex(kind(0.d0)),intent(inout), optional, target :: work(:)
end subroutine bar_zppwrk
end interface
end module bar_pr_mod
module foo_pr_mod
use bar_prt, &
& foo_dbprt => bar_dbprt,&
& foo_zbprt => bar_zbprt,&
& foo_dprt => bar_dprt,&
& foo_zprt => bar_zprt
use bar_pr_mod, &
& foo_pwrk => bar_pwrk
end module foo_pr_mod
Subroutine foo_sub(a,pr,b,x,eps,cd,info)
use foo_base_mod
use foo_pr_mod
Implicit None
!!$ parameters
Type(foo_dmt), Intent(in) :: a
Type(foo_dprt), Intent(in) :: pr
Type(foo_cdt), Intent(in) :: cd
Real(Kind(1.d0)), Intent(in) :: b(:)
Real(Kind(1.d0)), Intent(inout) :: x(:)
Real(Kind(1.d0)), Intent(in) :: eps
integer, intent(out) :: info
!!$ Local data
Real(Kind(1.d0)), allocatable, target :: aux(:),wwrk(:,:)
Real(Kind(1.d0)), allocatable :: p(:), f(:)
info = 0
Call foo_pwrk(pr,p,f,cd,info,work=aux) ! This worked if bar_pwrk was called!
return
End Subroutine foo_sub
| gpl-2.0 |
embecosm/avr32-gcc | gcc/testsuite/gfortran.dg/g77/20010519-1.f | 8 | 46708 | c { dg-do compile }
CHARMM Element source/dimb/nmdimb.src 1.1
C.##IF DIMB
SUBROUTINE NMDIMB(X,Y,Z,NAT3,BNBND,BIMAG,LNOMA,AMASS,DDS,DDSCR,
1 PARDDV,DDV,DDM,PARDDF,DDF,PARDDE,DDEV,DD1BLK,
2 DD1BLL,NADD,LRAISE,DD1CMP,INBCMP,JNBCMP,
3 NPAR,ATMPAR,ATMPAS,BLATOM,PARDIM,NFREG,NFRET,
4 PARFRQ,CUTF1,ITMX,TOLDIM,IUNMOD,IUNRMD,
5 LBIG,LSCI,ATMPAD,SAVF,NBOND,IB,JB,DDVALM)
C-----------------------------------------------------------------------
C 01-Jul-1992 David Perahia, Liliane Mouawad
C 15-Dec-1994 Herman van Vlijmen
C
C This is the main routine for the mixed-basis diagonalization.
C See: L.Mouawad and D.Perahia, Biopolymers (1993), 33, 599,
C and: D.Perahia and L.Mouawad, Comput. Chem. (1995), 19, 241.
C The method iteratively solves the diagonalization of the
C Hessian matrix. To save memory space, it uses a compressed
C form of the Hessian, which only contains the nonzero elements.
C In the diagonalization process, approximate eigenvectors are
C mixed with Cartesian coordinates to form a reduced basis. The
C Hessian is then diagonalized in the reduced basis. By iterating
C over different sets of Cartesian coordinates the method ultimately
C converges to the exact eigenvalues and eigenvectors (up to the
C requested accuracy).
C If no existing basis set is read, an initial basis will be created
C which consists of the low-frequency eigenvectors of diagonal blocks
C of the Hessian.
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/impnon.fcm'
C..##IF VAX IRIS HPUX IRIS GNU CSPP OS2 GWS CRAY ALPHA
IMPLICIT NONE
C..##ENDIF
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/stream.fcm'
LOGICAL LOWER,QLONGL
INTEGER MXSTRM,POUTU
PARAMETER (MXSTRM=20,POUTU=6)
INTEGER NSTRM,ISTRM,JSTRM,OUTU,PRNLEV,WRNLEV,IOLEV
COMMON /CASE/ LOWER, QLONGL
COMMON /STREAM/ NSTRM,ISTRM,JSTRM(MXSTRM),OUTU,PRNLEV,WRNLEV,IOLEV
C..##IF SAVEFCM
C..##ENDIF
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/dimens.fcm'
INTEGER LARGE,MEDIUM,SMALL,REDUCE
C..##IF QUANTA
C..##ELIF T3D
C..##ELSE
PARAMETER (LARGE=60120, MEDIUM=25140, SMALL=6120)
C..##ENDIF
PARAMETER (REDUCE=15000)
INTEGER SIZE
C..##IF XLARGE
C..##ELIF XXLARGE
C..##ELIF LARGE
C..##ELIF MEDIUM
PARAMETER (SIZE=MEDIUM)
C..##ELIF REDUCE
C..##ELIF SMALL
C..##ELIF XSMALL
C..##ENDIF
C..##IF MMFF
integer MAXDEFI
parameter(MAXDEFI=250)
INTEGER NAME0,NAMEQ0,NRES0,KRES0
PARAMETER (NAME0=4,NAMEQ0=10,NRES0=4,KRES0=4)
integer MaxAtN
parameter (MaxAtN=55)
INTEGER MAXAUX
PARAMETER (MAXAUX = 10)
C..##ENDIF
INTEGER MAXCSP, MAXHSET
C..##IF HMCM
PARAMETER (MAXHSET = 200)
C..##ELSE
C..##ENDIF
C..##IF REDUCE
C..##ELSE
PARAMETER (MAXCSP = 500)
C..##ENDIF
C..##IF HMCM
INTEGER MAXHCM,MAXPCM,MAXRCM
C...##IF REDUCE
C...##ELSE
PARAMETER (MAXHCM=500)
PARAMETER (MAXPCM=5000)
PARAMETER (MAXRCM=2000)
C...##ENDIF
C..##ENDIF
INTEGER MXCMSZ
C..##IF IBM IBMRS CRAY INTEL IBMSP T3D REDUCE
C..##ELSE
PARAMETER (MXCMSZ = 5000)
C..##ENDIF
INTEGER CHRSIZ
PARAMETER (CHRSIZ = SIZE)
INTEGER MAXATB
C..##IF REDUCE
C..##ELIF QUANTA
C..##ELSE
PARAMETER (MAXATB = 200)
C..##ENDIF
INTEGER MAXVEC
C..##IFN VECTOR PARVECT
PARAMETER (MAXVEC = 10)
C..##ELIF LARGE XLARGE XXLARGE
C..##ELIF MEDIUM
C..##ELIF SMALL REDUCE
C..##ELIF XSMALL
C..##ELSE
C..##ENDIF
INTEGER IATBMX
PARAMETER (IATBMX = 8)
INTEGER MAXHB
C..##IF LARGE XLARGE XXLARGE
C..##ELIF MEDIUM
PARAMETER (MAXHB = 8000)
C..##ELIF SMALL
C..##ELIF REDUCE XSMALL
C..##ELSE
C..##ENDIF
INTEGER MAXTRN,MAXSYM
C..##IFN NOIMAGES
PARAMETER (MAXTRN = 5000)
PARAMETER (MAXSYM = 192)
C..##ELSE
C..##ENDIF
C..##IF LONEPAIR (lonepair_max)
INTEGER MAXLP,MAXLPH
C...##IF REDUCE
C...##ELSE
PARAMETER (MAXLP = 2000)
PARAMETER (MAXLPH = 4000)
C...##ENDIF
C..##ENDIF (lonepair_max)
INTEGER NOEMAX,NOEMX2
C..##IF REDUCE
C..##ELSE
PARAMETER (NOEMAX = 2000)
PARAMETER (NOEMX2 = 4000)
C..##ENDIF
INTEGER MAXATC, MAXCB, MAXCH, MAXCI, MAXCP, MAXCT, MAXITC, MAXNBF
C..##IF REDUCE
C..##ELIF MMFF CFF
PARAMETER (MAXATC = 500, MAXCB = 1500, MAXCH = 3200, MAXCI = 600,
& MAXCP = 3000,MAXCT = 15500,MAXITC = 200, MAXNBF=1000)
C..##ELIF YAMMP
C..##ELIF LARGE
C..##ELSE
C..##ENDIF
INTEGER MAXCN
PARAMETER (MAXCN = MAXITC*(MAXITC+1)/2)
INTEGER MAXA, MAXAIM, MAXB, MAXT, MAXP
INTEGER MAXIMP, MAXNB, MAXPAD, MAXRES
INTEGER MAXSEG, MAXGRP
C..##IF LARGE XLARGE XXLARGE
C..##ELIF MEDIUM
PARAMETER (MAXA = SIZE, MAXB = SIZE, MAXT = SIZE,
& MAXP = 2*SIZE)
PARAMETER (MAXIMP = 9200, MAXNB = 17200, MAXPAD = 8160,
& MAXRES = 14000)
C...##IF MCSS
C...##ELSE
PARAMETER (MAXSEG = 1000)
C...##ENDIF
C..##ELIF SMALL
C..##ELIF XSMALL
C..##ELIF REDUCE
C..##ELSE
C..##ENDIF
C..##IF NOIMAGES
C..##ELSE
PARAMETER (MAXAIM = 2*SIZE)
PARAMETER (MAXGRP = 2*SIZE/3)
C..##ENDIF
INTEGER REDMAX,REDMX2
C..##IF REDUCE
C..##ELSE
PARAMETER (REDMAX = 20)
PARAMETER (REDMX2 = 80)
C..##ENDIF
INTEGER MXRTRS, MXRTA, MXRTB, MXRTT, MXRTP, MXRTI, MXRTX,
& MXRTHA, MXRTHD, MXRTBL, NICM
PARAMETER (MXRTRS = 200, MXRTA = 5000, MXRTB = 5000,
& MXRTT = 5000, MXRTP = 5000, MXRTI = 2000,
C..##IF YAMMP
C..##ELSE
& MXRTX = 5000, MXRTHA = 300, MXRTHD = 300,
C..##ENDIF
& MXRTBL = 5000, NICM = 10)
INTEGER NMFTAB, NMCTAB, NMCATM, NSPLIN
C..##IF REDUCE
C..##ELSE
PARAMETER (NMFTAB = 200, NMCTAB = 3, NMCATM = 12000, NSPLIN = 3)
C..##ENDIF
INTEGER MAXSHK
C..##IF XSMALL
C..##ELIF REDUCE
C..##ELSE
PARAMETER (MAXSHK = SIZE*3/4)
C..##ENDIF
INTEGER SCRMAX
C..##IF IBM IBMRS CRAY INTEL IBMSP T3D REDUCE
C..##ELSE
PARAMETER (SCRMAX = 5000)
C..##ENDIF
C..##IF TSM
INTEGER MXPIGG
C...##IF REDUCE
C...##ELSE
PARAMETER (MXPIGG=500)
C...##ENDIF
INTEGER MXCOLO,MXPUMB
PARAMETER (MXCOLO=20,MXPUMB=20)
C..##ENDIF
C..##IF ADUMB
INTEGER MAXUMP, MAXEPA, MAXNUM
C...##IF REDUCE
C...##ELSE
PARAMETER (MAXUMP = 10, MAXNUM = 4)
C...##ENDIF
C..##ENDIF
INTEGER MAXING
PARAMETER (MAXING=1000)
C..##IF MMFF
integer MAX_RINGSIZE, MAX_EACH_SIZE
parameter (MAX_RINGSIZE = 20, MAX_EACH_SIZE = 1000)
integer MAXPATHS
parameter (MAXPATHS = 8000)
integer MAX_TO_SEARCH
parameter (MAX_TO_SEARCH = 6)
C..##ENDIF
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/number.fcm'
REAL(KIND=8) ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX,
& SEVEN, EIGHT, NINE, TEN, ELEVEN, TWELVE, THIRTN,
& FIFTN, NINETN, TWENTY, THIRTY
C..##IF SINGLE
C..##ELSE
PARAMETER (ZERO = 0.D0, ONE = 1.D0, TWO = 2.D0,
& THREE = 3.D0, FOUR = 4.D0, FIVE = 5.D0,
& SIX = 6.D0, SEVEN = 7.D0, EIGHT = 8.D0,
& NINE = 9.D0, TEN = 10.D0, ELEVEN = 11.D0,
& TWELVE = 12.D0, THIRTN = 13.D0, FIFTN = 15.D0,
& NINETN = 19.D0, TWENTY = 20.D0, THIRTY = 30.D0)
C..##ENDIF
REAL(KIND=8) FIFTY, SIXTY, SVNTY2, EIGHTY, NINETY, HUNDRD,
& ONE2TY, ONE8TY, THRHUN, THR6TY, NINE99, FIFHUN, THOSND,
& FTHSND,MEGA
C..##IF SINGLE
C..##ELSE
PARAMETER (FIFTY = 50.D0, SIXTY = 60.D0, SVNTY2 = 72.D0,
& EIGHTY = 80.D0, NINETY = 90.D0, HUNDRD = 100.D0,
& ONE2TY = 120.D0, ONE8TY = 180.D0, THRHUN = 300.D0,
& THR6TY=360.D0, NINE99 = 999.D0, FIFHUN = 1500.D0,
& THOSND = 1000.D0,FTHSND = 5000.D0, MEGA = 1.0D6)
C..##ENDIF
REAL(KIND=8) MINONE, MINTWO, MINSIX
PARAMETER (MINONE = -1.D0, MINTWO = -2.D0, MINSIX = -6.D0)
REAL(KIND=8) TENM20,TENM14,TENM8,TENM5,PT0001,PT0005,PT001,PT005,
& PT01, PT02, PT05, PTONE, PT125, PT25, SIXTH, THIRD,
& PTFOUR, PTSIX, HALF, PT75, PT9999, ONEPT5, TWOPT4
C..##IF SINGLE
C..##ELSE
PARAMETER (TENM20 = 1.0D-20, TENM14 = 1.0D-14, TENM8 = 1.0D-8,
& TENM5 = 1.0D-5, PT0001 = 1.0D-4, PT0005 = 5.0D-4,
& PT001 = 1.0D-3, PT005 = 5.0D-3, PT01 = 0.01D0,
& PT02 = 0.02D0, PT05 = 0.05D0, PTONE = 0.1D0,
& PT125 = 0.125D0, SIXTH = ONE/SIX,PT25 = 0.25D0,
& THIRD = ONE/THREE,PTFOUR = 0.4D0, HALF = 0.5D0,
& PTSIX = 0.6D0, PT75 = 0.75D0, PT9999 = 0.9999D0,
& ONEPT5 = 1.5D0, TWOPT4 = 2.4D0)
C..##ENDIF
REAL(KIND=8) ANUM,FMARK
REAL(KIND=8) RSMALL,RBIG
C..##IF SINGLE
C..##ELSE
PARAMETER (ANUM=9999.0D0, FMARK=-999.0D0)
PARAMETER (RSMALL=1.0D-10,RBIG=1.0D20)
C..##ENDIF
REAL(KIND=8) RPRECI,RBIGST
C..##IF VAX DEC
C..##ELIF IBM
C..##ELIF CRAY
C..##ELIF ALPHA T3D T3E
C..##ELSE
C...##IF SINGLE
C...##ELSE
PARAMETER (RPRECI = 2.22045D-16, RBIGST = 4.49423D+307)
C...##ENDIF
C..##ENDIF
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/consta.fcm'
REAL(KIND=8) PI,RADDEG,DEGRAD,TWOPI
PARAMETER(PI=3.141592653589793D0,TWOPI=2.0D0*PI)
PARAMETER (RADDEG=180.0D0/PI)
PARAMETER (DEGRAD=PI/180.0D0)
REAL(KIND=8) COSMAX
PARAMETER (COSMAX=0.9999999999D0)
REAL(KIND=8) TIMFAC
PARAMETER (TIMFAC=4.88882129D-02)
REAL(KIND=8) KBOLTZ
PARAMETER (KBOLTZ=1.987191D-03)
REAL(KIND=8) CCELEC
C..##IF AMBER
C..##ELIF DISCOVER
C..##ELSE
PARAMETER (CCELEC=332.0716D0)
C..##ENDIF
REAL(KIND=8) CNVFRQ
PARAMETER (CNVFRQ=2045.5D0/(2.99793D0*6.28319D0))
REAL(KIND=8) SPEEDL
PARAMETER (SPEEDL=2.99793D-02)
REAL(KIND=8) ATMOSP
PARAMETER (ATMOSP=1.4584007D-05)
REAL(KIND=8) PATMOS
PARAMETER (PATMOS = 1.D0 / ATMOSP )
REAL(KIND=8) BOHRR
PARAMETER (BOHRR = 0.529177249D0 )
REAL(KIND=8) TOKCAL
PARAMETER (TOKCAL = 627.5095D0 )
C..##IF MMFF
REAL(KIND=8) MDAKCAL
parameter(MDAKCAL=143.9325D0)
C..##ENDIF
REAL(KIND=8) DEBYEC
PARAMETER ( DEBYEC = 2.541766D0 / BOHRR )
REAL(KIND=8) ZEROC
PARAMETER ( ZEROC = 298.15D0 )
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/exfunc.fcm'
C..##IF ACE
C..##ENDIF
C..##IF ADUMB
C..##ENDIF
CHARACTER*4 GTRMA, NEXTA4, CURRA4
CHARACTER*6 NEXTA6
CHARACTER*8 NEXTA8
CHARACTER*20 NEXT20
INTEGER ALLCHR, ALLSTK, ALLHP, DECODI, FIND52,
* GETATN, GETRES, GETRSN, GETSEG, GTRMI, I4VAL,
* ICHAR4, ICMP16, ILOGI4, INDX, INDXA, INDXAF,
* INDXRA, INTEG4, IREAL4, IREAL8, LOCDIF,
* LUNASS, MATOM, NEXTI, NINDX, NSELCT, NSELCTV, ATMSEL,
* PARNUM, PARINS,
* SRCHWD, SRCHWS, STRLNG, DSIZE, SSIZE
C..##IF ACE
* ,GETNNB
C..##ENDIF
LOGICAL CHKPTR, EQST, EQSTA, EQSTWC, EQWDWC, DOTRIM, CHECQUE,
* HYDROG, INITIA, LONE, LTSTEQ, ORDER, ORDER5,
* ORDERR, USEDDT, QTOKDEL, QDIGIT, QALPHA
REAL(KIND=8) DECODF, DOTVEC, GTRMF, LENVEC, NEXTF, RANDOM, GTRR8,
* RANUMB, R8VAL, RETVAL8, SUMVEC
C..##IF ADUMB
* ,UMFI
C..##ENDIF
EXTERNAL GTRMA, NEXTA4, CURRA4, NEXTA6, NEXTA8,NEXT20,
* ALLCHR, ALLSTK, ALLHP, DECODI, FIND52,
* GETATN, GETRES, GETRSN, GETSEG, GTRMI, I4VAL,
* ICHAR4, ICMP16, ILOGI4, INDX, INDXA, INDXAF,
* INDXRA, INTEG4, IREAL4, IREAL8, LOCDIF,
* LUNASS, MATOM, NEXTI, NINDX, NSELCT, NSELCTV, ATMSEL,
* PARNUM, PARINS,
* SRCHWD, SRCHWS, STRLNG, DSIZE, SSIZE,
* CHKPTR, EQST, EQSTA, EQSTWC, EQWDWC, DOTRIM, CHECQUE,
* HYDROG, INITIA, LONE, LTSTEQ, ORDER, ORDER5,
* ORDERR, USEDDT, QTOKDEL, QDIGIT, QALPHA,
* DECODF, DOTVEC, GTRMF, LENVEC, NEXTF, RANDOM, GTRR8,
* RANUMB, R8VAL, RETVAL8, SUMVEC
C..##IF ADUMB
* ,UMFI
C..##ENDIF
C..##IF ACE
* ,GETNNB
C..##ENDIF
C..##IFN NOIMAGES
INTEGER IMATOM
EXTERNAL IMATOM
C..##ENDIF
C..##IF MBOND
C..##ENDIF
C..##IF MMFF
INTEGER LEN_TRIM
EXTERNAL LEN_TRIM
CHARACTER*4 AtName
external AtName
CHARACTER*8 ElementName
external ElementName
CHARACTER*10 QNAME
external QNAME
integer IATTCH, IBORDR, CONN12, CONN13, CONN14
integer LEQUIV, LPATH
integer nbndx, nbnd2, nbnd3, NTERMA
external IATTCH, IBORDR, CONN12, CONN13, CONN14
external LEQUIV, LPATH
external nbndx, nbnd2, nbnd3, NTERMA
external find_loc
REAL(KIND=8) vangle, OOPNGL, TORNGL, ElementMass
external vangle, OOPNGL, TORNGL, ElementMass
C..##ENDIF
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/stack.fcm'
INTEGER STKSIZ
C..##IFN UNICOS
C...##IF LARGE XLARGE
C...##ELIF MEDIUM REDUCE
PARAMETER (STKSIZ=4000000)
C...##ELIF SMALL
C...##ELIF XSMALL
C...##ELIF XXLARGE
C...##ELSE
C...##ENDIF
INTEGER LSTUSD,MAXUSD,STACK
COMMON /ISTACK/ LSTUSD,MAXUSD,STACK(STKSIZ)
C..##ELSE
C..##ENDIF
C..##IF SAVEFCM
C..##ENDIF
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/heap.fcm'
INTEGER HEAPDM
C..##IFN UNICOS (unicos)
C...##IF XXLARGE (size)
C...##ELIF LARGE XLARGE (size)
C...##ELIF MEDIUM (size)
C....##IF T3D (t3d2)
C....##ELIF TERRA (t3d2)
C....##ELIF ALPHA (t3d2)
C....##ELIF T3E (t3d2)
C....##ELSE (t3d2)
PARAMETER (HEAPDM=2048000)
C....##ENDIF (t3d2)
C...##ELIF SMALL (size)
C...##ELIF REDUCE (size)
C...##ELIF XSMALL (size)
C...##ELSE (size)
C...##ENDIF (size)
INTEGER FREEHP,HEAPSZ,HEAP
COMMON /HEAPST/ FREEHP,HEAPSZ,HEAP(HEAPDM)
LOGICAL LHEAP(HEAPDM)
EQUIVALENCE (LHEAP,HEAP)
C..##ELSE (unicos)
C..##ENDIF (unicos)
C..##IF SAVEFCM (save)
C..##ENDIF (save)
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/fast.fcm'
INTEGER IACNB, NITCC, ICUSED, FASTER, LFAST, LMACH, OLMACH
INTEGER ICCOUNT, LOWTP, IGCNB, NITCC2
INTEGER ICCNBA, ICCNBB, ICCNBC, ICCNBD, LCCNBA, LCCNBD
COMMON /FASTI/ FASTER, LFAST, LMACH, OLMACH, NITCC, NITCC2,
& ICUSED(MAXATC), ICCOUNT(MAXATC), LOWTP(MAXATC),
& IACNB(MAXAIM), IGCNB(MAXATC),
& ICCNBA, ICCNBB, ICCNBC, ICCNBD, LCCNBA, LCCNBD
C..##IF SAVEFCM
C..##ENDIF
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/deriv.fcm'
REAL(KIND=8) DX,DY,DZ
COMMON /DERIVR/ DX(MAXAIM),DY(MAXAIM),DZ(MAXAIM)
C..##IF SAVEFCM
C..##ENDIF
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/energy.fcm'
INTEGER LENENP, LENENT, LENENV, LENENA
PARAMETER (LENENP = 50, LENENT = 70, LENENV = 50,
& LENENA = LENENP + LENENT + LENENV )
INTEGER TOTE, TOTKE, EPOT, TEMPS, GRMS, BPRESS, PJNK1, PJNK2,
& PJNK3, PJNK4, HFCTE, HFCKE, EHFC, EWORK, VOLUME, PRESSE,
& PRESSI, VIRI, VIRE, VIRKE, TEPR, PEPR, KEPR, KEPR2,
& DROFFA,
& XTLTE, XTLKE, XTLPE, XTLTEM, XTLPEP, XTLKEP, XTLKP2,
& TOT4, TOTK4, EPOT4, TEM4, MbMom, BodyT, PartT
C..##IF ACE
& , SELF, SCREEN, COUL ,SOLV, INTER
C..##ENDIF
C..##IF FLUCQ
& ,FQKIN
C..##ENDIF
PARAMETER (TOTE = 1, TOTKE = 2, EPOT = 3, TEMPS = 4,
& GRMS = 5, BPRESS = 6, PJNK1 = 7, PJNK2 = 8,
& PJNK3 = 9, PJNK4 = 10, HFCTE = 11, HFCKE = 12,
& EHFC = 13, EWORK = 11, VOLUME = 15, PRESSE = 16,
& PRESSI = 17, VIRI = 18, VIRE = 19, VIRKE = 20,
& TEPR = 21, PEPR = 22, KEPR = 23, KEPR2 = 24,
& DROFFA = 26, XTLTE = 27, XTLKE = 28,
& XTLPE = 29, XTLTEM = 30, XTLPEP = 31, XTLKEP = 32,
& XTLKP2 = 33,
& TOT4 = 37, TOTK4 = 38, EPOT4 = 39, TEM4 = 40,
& MbMom = 41, BodyT = 42, PartT = 43
C..##IF ACE
& , SELF = 45, SCREEN = 46, COUL = 47,
& SOLV = 48, INTER = 49
C..##ENDIF
C..##IF FLUCQ
& ,FQKIN = 50
C..##ENDIF
& )
C..##IF ACE
C..##ENDIF
C..##IF GRID
C..##ENDIF
C..##IF FLUCQ
C..##ENDIF
INTEGER BOND, ANGLE, UREYB, DIHE, IMDIHE, VDW, ELEC, HBOND,
& USER, CHARM, CDIHE, CINTCR, CQRT, NOE, SBNDRY,
& IMVDW, IMELEC, IMHBND, EWKSUM, EWSELF, EXTNDE, RXNFLD,
& ST2, IMST2, TSM, QMEL, QMVDW, ASP, EHARM, GEO, MDIP,
& PRMS, PANG, SSBP, BK4D, SHEL, RESD, SHAP,
& STRB, OOPL, PULL, POLAR, DMC, RGY, EWEXCL, EWQCOR,
& EWUTIL, PBELEC, PBNP, PINT, MbDefrm, MbElec, STRSTR,
& BNDBND, BNDTW, EBST, MBST, BBT, SST, GBEnr, GSBP
C..##IF HMCM
& , HMCM
C..##ENDIF
C..##IF ADUMB
& , ADUMB
C..##ENDIF
& , HYDR
C..##IF FLUCQ
& , FQPOL
C..##ENDIF
PARAMETER (BOND = 1, ANGLE = 2, UREYB = 3, DIHE = 4,
& IMDIHE = 5, VDW = 6, ELEC = 7, HBOND = 8,
& USER = 9, CHARM = 10, CDIHE = 11, CINTCR = 12,
& CQRT = 13, NOE = 14, SBNDRY = 15, IMVDW = 16,
& IMELEC = 17, IMHBND = 18, EWKSUM = 19, EWSELF = 20,
& EXTNDE = 21, RXNFLD = 22, ST2 = 23, IMST2 = 24,
& TSM = 25, QMEL = 26, QMVDW = 27, ASP = 28,
& EHARM = 29, GEO = 30, MDIP = 31, PINT = 32,
& PRMS = 33, PANG = 34, SSBP = 35, BK4D = 36,
& SHEL = 37, RESD = 38, SHAP = 39, STRB = 40,
& OOPL = 41, PULL = 42, POLAR = 43, DMC = 44,
& RGY = 45, EWEXCL = 46, EWQCOR = 47, EWUTIL = 48,
& PBELEC = 49, PBNP = 50, MbDefrm= 51, MbElec = 52,
& STRSTR = 53, BNDBND = 54, BNDTW = 55, EBST = 56,
& MBST = 57, BBT = 58, SST = 59, GBEnr = 60,
& GSBP = 65
C..##IF HMCM
& , HMCM = 61
C..##ENDIF
C..##IF ADUMB
& , ADUMB = 62
C..##ENDIF
& , HYDR = 63
C..##IF FLUCQ
& , FQPOL = 65
C..##ENDIF
& )
INTEGER VEXX, VEXY, VEXZ, VEYX, VEYY, VEYZ, VEZX, VEZY, VEZZ,
& VIXX, VIXY, VIXZ, VIYX, VIYY, VIYZ, VIZX, VIZY, VIZZ,
& PEXX, PEXY, PEXZ, PEYX, PEYY, PEYZ, PEZX, PEZY, PEZZ,
& PIXX, PIXY, PIXZ, PIYX, PIYY, PIYZ, PIZX, PIZY, PIZZ
PARAMETER ( VEXX = 1, VEXY = 2, VEXZ = 3, VEYX = 4,
& VEYY = 5, VEYZ = 6, VEZX = 7, VEZY = 8,
& VEZZ = 9,
& VIXX = 10, VIXY = 11, VIXZ = 12, VIYX = 13,
& VIYY = 14, VIYZ = 15, VIZX = 16, VIZY = 17,
& VIZZ = 18,
& PEXX = 19, PEXY = 20, PEXZ = 21, PEYX = 22,
& PEYY = 23, PEYZ = 24, PEZX = 25, PEZY = 26,
& PEZZ = 27,
& PIXX = 28, PIXY = 29, PIXZ = 30, PIYX = 31,
& PIYY = 32, PIYZ = 33, PIZX = 34, PIZY = 35,
& PIZZ = 36)
CHARACTER*4 CEPROP, CETERM, CEPRSS
COMMON /ANER/ CEPROP(LENENP), CETERM(LENENT), CEPRSS(LENENV)
LOGICAL QEPROP, QETERM, QEPRSS
COMMON /QENER/ QEPROP(LENENP), QETERM(LENENT), QEPRSS(LENENV)
REAL(KIND=8) EPROP, ETERM, EPRESS
COMMON /ENER/ EPROP(LENENP), ETERM(LENENT), EPRESS(LENENV)
C..##IF SAVEFCM
C..##ENDIF
REAL(KIND=8) EPRPA, EPRP2A, EPRPP, EPRP2P,
& ETRMA, ETRM2A, ETRMP, ETRM2P,
& EPRSA, EPRS2A, EPRSP, EPRS2P
COMMON /ENACCM/ EPRPA(LENENP), ETRMA(LENENT), EPRSA(LENENV),
& EPRP2A(LENENP),ETRM2A(LENENT),EPRS2A(LENENV),
& EPRPP(LENENP), ETRMP(LENENT), EPRSP(LENENV),
& EPRP2P(LENENP),ETRM2P(LENENT),EPRS2P(LENENV)
C..##IF SAVEFCM
C..##ENDIF
INTEGER ECALLS, TOT1ST, TOT2ND
COMMON /EMISCI/ ECALLS, TOT1ST, TOT2ND
REAL(KIND=8) EOLD, FITA, DRIFTA, EAT0A, CORRA, FITP, DRIFTP,
& EAT0P, CORRP
COMMON /EMISCR/ EOLD, FITA, DRIFTA, EAT0A, CORRA,
& FITP, DRIFTP, EAT0P, CORRP
C..##IF SAVEFCM
C..##ENDIF
C..##IF ACE
C..##ENDIF
C..##IF FLUCQ
C..##ENDIF
C..##IF ADUMB
C..##ENDIF
C..##IF GRID
C..##ENDIF
C..##IF FLUCQ
C..##ENDIF
C..##IF TSM
REAL(KIND=8) TSMTRM(LENENT),TSMTMP(LENENT)
COMMON /TSMENG/ TSMTRM,TSMTMP
C...##IF SAVEFCM
C...##ENDIF
C..##ENDIF
REAL(KIND=8) EHQBM
LOGICAL HQBM
COMMON /HQBMVAR/HQBM
C..##IF SAVEFCM
C..##ENDIF
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/dimb.fcm'
C..##IF DIMB (dimbfcm)
INTEGER NPARMX,MNBCMP,LENDSK
PARAMETER (NPARMX=1000,MNBCMP=300,LENDSK=200000)
INTEGER IJXXCM,IJXYCM,IJXZCM,IJYXCM,IJYYCM
INTEGER IJYZCM,IJZXCM,IJZYCM,IJZZCM
INTEGER IIXXCM,IIXYCM,IIXZCM,IIYYCM
INTEGER IIYZCM,IIZZCM
INTEGER JJXXCM,JJXYCM,JJXZCM,JJYYCM
INTEGER JJYZCM,JJZZCM
PARAMETER (IJXXCM=1,IJXYCM=2,IJXZCM=3,IJYXCM=4,IJYYCM=5)
PARAMETER (IJYZCM=6,IJZXCM=7,IJZYCM=8,IJZZCM=9)
PARAMETER (IIXXCM=1,IIXYCM=2,IIXZCM=3,IIYYCM=4)
PARAMETER (IIYZCM=5,IIZZCM=6)
PARAMETER (JJXXCM=1,JJXYCM=2,JJXZCM=3,JJYYCM=4)
PARAMETER (JJYZCM=5,JJZZCM=6)
INTEGER ITER,IPAR1,IPAR2,NFSAV,PINBCM,PJNBCM,PDD1CM,LENCMP
LOGICAL QDISK,QDW,QCMPCT
COMMON /DIMBI/ ITER,IPAR1,IPAR2,NFSAV,PINBCM,PJNBCM,LENCMP
COMMON /DIMBL/ QDISK,QDW,QCMPCT
C...##IF SAVEFCM
C...##ENDIF
C..##ENDIF (dimbfcm)
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C:::##INCLUDE '~/charmm_fcm/ctitla.fcm'
INTEGER MAXTIT
PARAMETER (MAXTIT=32)
INTEGER NTITLA,NTITLB
CHARACTER*80 TITLEA,TITLEB
COMMON /NTITLA/ NTITLA,NTITLB
COMMON /CTITLA/ TITLEA(MAXTIT),TITLEB(MAXTIT)
C..##IF SAVEFCM
C..##ENDIF
C-----------------------------------------------------------------------
C Passed variables
INTEGER NAT3,NADD,NPAR,NFREG,NFRET,BLATOM
INTEGER ATMPAR(2,*),ATMPAS(2,*),ATMPAD(2,*)
INTEGER BNBND(*),BIMAG(*)
INTEGER INBCMP(*),JNBCMP(*),PARDIM
INTEGER ITMX,IUNMOD,IUNRMD,SAVF
INTEGER NBOND,IB(*),JB(*)
REAL(KIND=8) X(*),Y(*),Z(*),AMASS(*),DDSCR(*)
REAL(KIND=8) DDV(NAT3,*),PARDDV(PARDIM,*),DDM(*),DDS(*)
REAL(KIND=8) DDF(*),PARDDF(*),DDEV(*),PARDDE(*)
REAL(KIND=8) DD1BLK(*),DD1BLL(*),DD1CMP(*)
REAL(KIND=8) TOLDIM,DDVALM
REAL(KIND=8) PARFRQ,CUTF1
LOGICAL LNOMA,LRAISE,LSCI,LBIG
C Local variables
INTEGER NATOM,NATP,NDIM,I,J,II,OLDFAS,OLDPRN,IUPD
INTEGER NPARC,NPARD,NPARS,NFCUT1,NFREG2,NFREG6
INTEGER IH1,IH2,IH3,IH4,IH5,IH6,IH7,IH8
INTEGER IS1,IS2,IS3,IS4,JSPACE,JSP,DDSS,DD5
INTEGER ISTRT,ISTOP,IPA1,IPA2,IRESF
INTEGER ATMPAF,INIDS,TRAROT
INTEGER SUBLIS,ATMCOR
INTEGER NFRRES,DDVBAS
INTEGER DDV2,DDVAL
INTEGER LENCM,NTR,NFRE,NFC,N1,N2,NFCUT,NSUBP
INTEGER SCIFV1,SCIFV2,SCIFV3,SCIFV4,SCIFV6
INTEGER DRATQ,ERATQ,E2RATQ,BDRATQ,INRATQ
INTEGER I620,I640,I660,I700,I720,I760,I800,I840,I880,I920
REAL(KIND=8) CVGMX,TOLER
LOGICAL LCARD,LAPPE,LPURG,LWDINI,QCALC,QMASWT,QMIX,QDIAG
C Begin
QCALC=.TRUE.
LWDINI=.FALSE.
INIDS=0
IS3=0
IS4=0
LPURG=.TRUE.
ITER=0
NADD=0
NFSAV=0
TOLER=TENM5
QDIAG=.TRUE.
CVGMX=HUNDRD
QMIX=.FALSE.
NATOM=NAT3/3
NFREG6=(NFREG-6)/NPAR
NFREG2=NFREG/2
NFRRES=(NFREG+6)/2
IF(NFREG.GT.PARDIM) CALL WRNDIE(-3,'<NMDIMB>',
1 'NFREG IS LARGER THAN PARDIM*3')
C
C ALLOCATE-SPACE-FOR-TRANSROT-VECTORS
ASSIGN 801 TO I800 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 800
801 CONTINUE
C ALLOCATE-SPACE-FOR-DIAGONALIZATION
ASSIGN 721 TO I720 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 720
721 CONTINUE
C ALLOCATE-SPACE-FOR-REDUCED-BASIS
ASSIGN 761 TO I760 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 760
761 CONTINUE
C ALLOCATE-SPACE-FOR-OTHER-ARRAYS
ASSIGN 921 TO I920 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 920
921 CONTINUE
C
C Space allocation for working arrays of EISPACK
C diagonalization subroutines
IF(LSCI) THEN
C ALLOCATE-SPACE-FOR-LSCI
ASSIGN 841 TO I840 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 840
841 CONTINUE
ELSE
C ALLOCATE-DUMMY-SPACE-FOR-LSCI
ASSIGN 881 TO I880 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 880
881 CONTINUE
ENDIF
QMASWT=(.NOT.LNOMA)
IF(.NOT. QDISK) THEN
LENCM=INBCMP(NATOM-1)*9+NATOM*6
DO I=1,LENCM
DD1CMP(I)=0.0
ENDDO
OLDFAS=LFAST
QCMPCT=.TRUE.
LFAST = -1
CALL ENERGY(X,Y,Z,DX,DY,DZ,BNBND,BIMAG,NAT3,DD1CMP,.TRUE.,1)
LFAST=OLDFAS
QCMPCT=.FALSE.
C
C Mass weight DD1CMP matrix
C
CALL MASSDD(DD1CMP,DDM,INBCMP,JNBCMP,NATOM)
ELSE
CALL WRNDIE(-3,'<NMDIMB>','QDISK OPTION NOT SUPPORTED YET')
C DO I=1,LENDSK
C DD1CMP(I)=0.0
C ENDDO
C OLDFAS=LFAST
C LFAST = -1
ENDIF
C
C Fill DDV with six translation-rotation vectors
C
CALL TRROT(X,Y,Z,DDV,NAT3,1,DDM)
CALL CPARAY(HEAP(TRAROT),DDV,NAT3,1,6,1)
NTR=6
OLDPRN=PRNLEV
PRNLEV=1
CALL ORTHNM(1,6,NTR,HEAP(TRAROT),NAT3,.FALSE.,TOLER)
PRNLEV=OLDPRN
IF(IUNRMD .LT. 0) THEN
C
C If no previous basis is read
C
IF(PRNLEV.GE.2) WRITE(OUTU,502) NPAR
502 FORMAT(/' NMDIMB: Calculating initial basis from block ',
1 'diagonals'/' NMDIMB: The number of blocks is ',I5/)
NFRET = 6
DO I=1,NPAR
IS1=ATMPAR(1,I)
IS2=ATMPAR(2,I)
NDIM=(IS2-IS1+1)*3
NFRE=NDIM
IF(NFRE.GT.NFREG6) NFRE=NFREG6
IF(NFREG6.EQ.0) NFRE=1
CALL FILUPT(HEAP(IUPD),NDIM)
CALL MAKDDU(DD1BLK,DD1CMP,INBCMP,JNBCMP,HEAP(IUPD),
1 IS1,IS2,NATOM)
IF(PRNLEV.GE.9) CALL PRINTE(OUTU,EPROP,ETERM,'VIBR',
1 'ENR',.TRUE.,1,ZERO,ZERO)
C
C Generate the lower section of the matrix and diagonalize
C
C..##IF EISPACK
C..##ENDIF
IH1=1
NATP=NDIM+1
IH2=IH1+NATP
IH3=IH2+NATP
IH4=IH3+NATP
IH5=IH4+NATP
IH6=IH5+NATP
IH7=IH6+NATP
IH8=IH7+NATP
CALL DIAGQ(NDIM,NFRE,DD1BLK,PARDDV,DDS(IH2),DDS(IH3),
1 DDS(IH4),DDS(IH5),DDS,DDS(IH6),DDS(IH7),DDS(IH8),NADD)
C..##IF EISPACK
C..##ENDIF
C
C Put the PARDDV vectors into DDV and replace the elements which do
C not belong to the considered partitioned region by zeros.
C
CALL ADJNME(DDV,PARDDV,NAT3,NDIM,NFRE,NFRET,IS1,IS2)
IF(LSCI) THEN
DO J=1,NFRE
PARDDF(J)=CNVFRQ*SQRT(ABS(PARDDE(J)))
IF(PARDDE(J) .LT. 0.0) PARDDF(J)=-PARDDF(J)
ENDDO
ELSE
DO J=1,NFRE
PARDDE(J)=DDS(J)
PARDDF(J)=CNVFRQ*SQRT(ABS(PARDDE(J)))
IF(PARDDE(J) .LT. 0.0) PARDDF(J)=-PARDDF(J)
ENDDO
ENDIF
IF(PRNLEV.GE.2) THEN
WRITE(OUTU,512) I
WRITE(OUTU,514)
WRITE(OUTU,516) (J,PARDDF(J),J=1,NFRE)
ENDIF
NFRET=NFRET+NFRE
IF(NFRET .GE. NFREG) GOTO 10
ENDDO
512 FORMAT(/' NMDIMB: Diagonalization of part',I5,' completed')
514 FORMAT(' NMDIMB: Frequencies'/)
516 FORMAT(5(I4,F12.6))
10 CONTINUE
C
C Orthonormalize the eigenvectors
C
OLDPRN=PRNLEV
PRNLEV=1
CALL ORTHNM(1,NFRET,NFRET,DDV,NAT3,LPURG,TOLER)
PRNLEV=OLDPRN
C
C Do reduced basis diagonalization using the DDV vectors
C and get eigenvectors of zero iteration
C
IF(PRNLEV.GE.2) THEN
WRITE(OUTU,521) ITER
WRITE(OUTU,523) NFRET
ENDIF
521 FORMAT(/' NMDIMB: Iteration number = ',I5)
523 FORMAT(' NMDIMB: Dimension of the reduced basis set = ',I5)
IF(LBIG) THEN
IF(PRNLEV.GE.2) WRITE(OUTU,585) NFRET,IUNMOD
525 FORMAT(' NMDIMB: ',I5,' basis vectors are saved in unit',I5)
REWIND (UNIT=IUNMOD)
LCARD=.FALSE.
CALL WRTNMD(LCARD,1,NFRET,NAT3,DDV,DDSCR,DDEV,IUNMOD,AMASS)
CALL SAVEIT(IUNMOD)
ELSE
CALL CPARAY(HEAP(DDVBAS),DDV,NAT3,1,NFRET,1)
ENDIF
CALL RBDG(X,Y,Z,NAT3,NDIM,NFRET,DDV,DDF,DDEV,
1 DDSCR,HEAP(DD5),HEAP(DDSS),HEAP(DDV2),NADD,
2 INBCMP,JNBCMP,HEAP(DDVBAS),DD1CMP,QMIX,0,0,IS3,IS4,
3 CUTF1,NFCUT1,NFREG,HEAP(IUPD),DD1BLL,HEAP(SCIFV1),
4 HEAP(SCIFV2),HEAP(SCIFV3),HEAP(SCIFV4),HEAP(SCIFV6),
5 HEAP(DRATQ),HEAP(ERATQ),HEAP(E2RATQ),
6 HEAP(BDRATQ),HEAP(INRATQ),LSCI,LBIG,IUNMOD)
C
C DO-THE-DIAGONALISATIONS-WITH-RESIDUALS
C
ASSIGN 621 TO I620 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 620
621 CONTINUE
C SAVE-MODES
ASSIGN 701 TO I700 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 700
701 CONTINUE
IF(ITER.EQ.ITMX) THEN
CALL CLEANHP(NAT3,NFREG,NPARD,NSUBP,PARDIM,DDV2,DDSS,DDVBAS,
1 DDVAL,JSPACE,TRAROT,
2 SCIFV1,SCIFV2,SCIFV3,SCIFV4,SCIFV6,
3 DRATQ,ERATQ,E2RATQ,BDRATQ,INRATQ,IUPD,ATMPAF,
4 ATMCOR,SUBLIS,LSCI,QDW,LBIG)
RETURN
ENDIF
ELSE
C
C Read in existing basis
C
IF(PRNLEV.GE.2) THEN
WRITE(OUTU,531)
531 FORMAT(/' NMDIMB: Calculations restarted')
ENDIF
C READ-MODES
ISTRT=1
ISTOP=99999999
LCARD=.FALSE.
LAPPE=.FALSE.
CALL RDNMD(LCARD,NFRET,NFREG,NAT3,NDIM,
1 DDV,DDSCR,DDF,DDEV,
2 IUNRMD,LAPPE,ISTRT,ISTOP)
NFRET=NDIM
IF(NFRET.GT.NFREG) THEN
NFRET=NFREG
CALL WRNDIE(-1,'<NMDIMB>',
1 'Not enough space to hold the basis. Increase NMODes')
ENDIF
C PRINT-MODES
IF(PRNLEV.GE.2) THEN
WRITE(OUTU,533) NFRET,IUNRMD
WRITE(OUTU,514)
WRITE(OUTU,516) (J,DDF(J),J=1,NFRET)
ENDIF
533 FORMAT(/' NMDIMB: ',I5,' restart modes read from unit ',I5)
NFRRES=NFRET
ENDIF
C
C -------------------------------------------------
C Here starts the mixed-basis diagonalization part.
C -------------------------------------------------
C
C
C Check cut-off frequency
C
CALL SELNMD(DDF,NFRET,CUTF1,NFCUT1)
C TEST-NFCUT1
IF(IUNRMD.LT.0) THEN
IF(NFCUT1*2-6.GT.NFREG) THEN
IF(PRNLEV.GE.2) WRITE(OUTU,537) DDF(NFRRES)
NFCUT1=NFRRES
CUTF1=DDF(NFRRES)
ENDIF
ELSE
CUTF1=DDF(NFRRES)
ENDIF
537 FORMAT(/' NMDIMB: Too many vectors for the given cutoff frequency'
1 /' Cutoff frequency is decreased to',F9.3)
C
C Compute the new partioning of the molecule
C
CALL PARTIC(NAT3,NFREG,NFCUT1,NPARMX,NPARC,ATMPAR,NFRRES,
1 PARDIM)
NPARS=NPARC
DO I=1,NPARC
ATMPAS(1,I)=ATMPAR(1,I)
ATMPAS(2,I)=ATMPAR(2,I)
ENDDO
IF(QDW) THEN
IF(IPAR1.EQ.0.OR.IPAR2.EQ.0) LWDINI=.TRUE.
IF(IPAR1.GE.IPAR2) LWDINI=.TRUE.
IF(IABS(IPAR1).GT.NPARC*2) LWDINI=.TRUE.
IF(IABS(IPAR2).GT.NPARC*2) LWDINI=.TRUE.
IF(ITER.EQ.0) LWDINI=.TRUE.
ENDIF
ITMX=ITMX+ITER
IF(PRNLEV.GE.2) THEN
WRITE(OUTU,543) ITER,ITMX
IF(QDW) WRITE(OUTU,545) IPAR1,IPAR2
ENDIF
543 FORMAT(/' NMDIMB: Previous iteration number = ',I8/
1 ' NMDIMB: Iteration number to reach = ',I8)
545 FORMAT(' NMDIMB: Previous sub-blocks = ',I5,2X,I5)
C
IF(SAVF.LE.0) SAVF=NPARC
IF(PRNLEV.GE.2) WRITE(OUTU,547) SAVF
547 FORMAT(' NMDIMB: Eigenvectors will be saved every',I5,
1 ' iterations')
C
C If double windowing is defined, the original block sizes are divided
C in two.
C
IF(QDW) THEN
NSUBP=1
CALL PARTID(NPARC,ATMPAR,NPARD,ATMPAD,NPARMX)
ATMPAF=ALLHP(INTEG4(NPARD*NPARD))
ATMCOR=ALLHP(INTEG4(NATOM))
DDVAL=ALLHP(IREAL8(NPARD*NPARD))
CALL CORARR(ATMPAD,NPARD,HEAP(ATMCOR),NATOM)
CALL PARLIS(HEAP(ATMCOR),HEAP(ATMPAF),INBCMP,JNBCMP,NPARD,
2 NSUBP,NATOM,X,Y,Z,NBOND,IB,JB,DD1CMP,HEAP(DDVAL),DDVALM)
SUBLIS=ALLHP(INTEG4(NSUBP*2))
CALL PARINT(HEAP(ATMPAF),NPARD,HEAP(SUBLIS),NSUBP)
CALL INIPAF(HEAP(ATMPAF),NPARD)
C
C Find out with which block to continue (double window method only)
C
IPA1=IPAR1
IPA2=IPAR2
IRESF=0
IF(LWDINI) THEN
ITER=0
LWDINI=.FALSE.
GOTO 500
ENDIF
DO II=1,NSUBP
CALL IPART(HEAP(SUBLIS),II,IPAR1,IPAR2,HEAP(ATMPAF),
1 NPARD,QCALC)
IF((IPAR1.EQ.IPA1).AND.(IPAR2.EQ.IPA2)) GOTO 500
ENDDO
ENDIF
500 CONTINUE
C
C Main loop.
C
DO WHILE((CVGMX.GT.TOLDIM).AND.(ITER.LT.ITMX))
IF(.NOT.QDW) THEN
ITER=ITER+1
IF(PRNLEV.GE.2) WRITE(OUTU,553) ITER
553 FORMAT(/' NMDIMB: Iteration number = ',I8)
IF(INIDS.EQ.0) THEN
INIDS=1
ELSE
INIDS=0
ENDIF
CALL PARTDS(NAT3,NPARC,ATMPAR,NPARS,ATMPAS,INIDS,NPARMX,
1 DDF,NFREG,CUTF1,PARDIM,NFCUT1)
C DO-THE-DIAGONALISATIONS
ASSIGN 641 to I640 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 640
641 CONTINUE
QDIAG=.FALSE.
C DO-THE-DIAGONALISATIONS-WITH-RESIDUALS
ASSIGN 622 TO I620 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 620
622 CONTINUE
QDIAG=.TRUE.
C SAVE-MODES
ASSIGN 702 TO I700 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 700
702 CONTINUE
C
ELSE
DO II=1,NSUBP
CALL IPART(HEAP(SUBLIS),II,IPAR1,IPAR2,HEAP(ATMPAF),
1 NPARD,QCALC)
IF(QCALC) THEN
IRESF=IRESF+1
ITER=ITER+1
IF(PRNLEV.GE.2) WRITE(OUTU,553) ITER
C DO-THE-DWIN-DIAGONALISATIONS
ASSIGN 661 TO I660 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 660
661 CONTINUE
ENDIF
IF((IRESF.EQ.SAVF).OR.(ITER.EQ.ITMX)) THEN
IRESF=0
QDIAG=.FALSE.
C DO-THE-DIAGONALISATIONS-WITH-RESIDUALS
ASSIGN 623 TO I620 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 620
623 CONTINUE
QDIAG=.TRUE.
IF((CVGMX.LE.TOLDIM).OR.(ITER.EQ.ITMX)) GOTO 600
C SAVE-MODES
ASSIGN 703 TO I700 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 700
703 CONTINUE
ENDIF
ENDDO
ENDIF
ENDDO
600 CONTINUE
C
C SAVE-MODES
ASSIGN 704 TO I700 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" }
GOTO 700
704 CONTINUE
CALL CLEANHP(NAT3,NFREG,NPARD,NSUBP,PARDIM,DDV2,DDSS,DDVBAS,
1 DDVAL,JSPACE,TRAROT,
2 SCIFV1,SCIFV2,SCIFV3,SCIFV4,SCIFV6,
3 DRATQ,ERATQ,E2RATQ,BDRATQ,INRATQ,IUPD,ATMPAF,
4 ATMCOR,SUBLIS,LSCI,QDW,LBIG)
RETURN
C-----------------------------------------------------------------------
C INTERNAL PROCEDURES
C-----------------------------------------------------------------------
C TO DO-THE-DIAGONALISATIONS-WITH-RESIDUALS
620 CONTINUE
IF(IUNRMD.LT.0) THEN
CALL SELNMD(DDF,NFRET,CUTF1,NFC)
N1=NFCUT1
N2=(NFRET+6)/2
NFCUT=MAX(N1,N2)
IF(NFCUT*2-6 .GT. NFREG) THEN
NFCUT=(NFREG+6)/2
CUTF1=DDF(NFCUT)
IF(PRNLEV.GE.2) THEN
WRITE(OUTU,562) ITER
WRITE(OUTU,564) CUTF1
ENDIF
ENDIF
ELSE
NFCUT=NFRET
NFC=NFRET
ENDIF
562 FORMAT(/' NMDIMB: Not enough space to hold the residual vectors'/
1 ' into DDV array during iteration ',I5)
564 FORMAT(' Cutoff frequency is changed to ',F9.3)
C
C do reduced diagonalization with preceding eigenvectors plus
C residual vectors
C
ISTRT=1
ISTOP=NFCUT
CALL CLETR(DDV,HEAP(TRAROT),NAT3,ISTRT,ISTOP,NFCUT,DDEV,DDF)
CALL RNMTST(DDV,HEAP(DDVBAS),NAT3,DDSCR,DD1CMP,INBCMP,JNBCMP,
2 7,NFCUT,CVGMX,NFCUT,NFC,QDIAG,LBIG,IUNMOD)
NFSAV=NFCUT
IF(QDIAG) THEN
NFRET=NFCUT*2-6
IF(PRNLEV.GE.2) WRITE(OUTU,566) NFRET
566 FORMAT(/' NMDIMB: Diagonalization with residual vectors. '/
1 ' Dimension of the reduced basis set'/
2 ' before orthonormalization = ',I5)
NFCUT=NFRET
OLDPRN=PRNLEV
PRNLEV=1
CALL ORTHNM(1,NFRET,NFCUT,DDV,NAT3,LPURG,TOLER)
PRNLEV=OLDPRN
NFRET=NFCUT
IF(PRNLEV.GE.2) WRITE(OUTU,568) NFRET
568 FORMAT(' after orthonormalization = ',I5)
IF(LBIG) THEN
IF(PRNLEV.GE.2) WRITE(OUTU,570) NFCUT,IUNMOD
570 FORMAT(' NMDIMB: ',I5,' basis vectors are saved in unit',I5)
REWIND (UNIT=IUNMOD)
LCARD=.FALSE.
CALL WRTNMD(LCARD,1,NFCUT,NAT3,DDV,DDSCR,DDEV,IUNMOD,AMASS)
CALL SAVEIT(IUNMOD)
ELSE
CALL CPARAY(HEAP(DDVBAS),DDV,NAT3,1,NFCUT,1)
ENDIF
QMIX=.FALSE.
CALL RBDG(X,Y,Z,NAT3,NDIM,NFRET,DDV,DDF,DDEV,
1 DDSCR,HEAP(DD5),HEAP(DDSS),HEAP(DDV2),NADD,
2 INBCMP,JNBCMP,HEAP(DDVBAS),DD1CMP,QMIX,0,0,IS3,IS4,
3 CUTF1,NFCUT1,NFREG,HEAP(IUPD),DD1BLL,HEAP(SCIFV1),
4 HEAP(SCIFV2),HEAP(SCIFV3),HEAP(SCIFV4),HEAP(SCIFV6),
5 HEAP(DRATQ),HEAP(ERATQ),HEAP(E2RATQ),
6 HEAP(BDRATQ),HEAP(INRATQ),LSCI,LBIG,IUNMOD)
CALL SELNMD(DDF,NFRET,CUTF1,NFCUT1)
ENDIF
GOTO I620 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C
C-----------------------------------------------------------------------
C TO DO-THE-DIAGONALISATIONS
640 CONTINUE
DO I=1,NPARC
NFCUT1=NFRRES
IS1=ATMPAR(1,I)
IS2=ATMPAR(2,I)
NDIM=(IS2-IS1+1)*3
IF(PRNLEV.GE.2) WRITE(OUTU,573) I,IS1,IS2
573 FORMAT(/' NMDIMB: Mixed diagonalization, part ',I5/
1 ' NMDIMB: Block limits: ',I5,2X,I5)
IF(NDIM+NFCUT1.GT.PARDIM) CALL WRNDIE(-3,'<NMDIMB>',
1 'Error in dimension of block')
NFRET=NFCUT1
IF(NFRET.GT.NFREG) NFRET=NFREG
CALL CLETR(DDV,HEAP(TRAROT),NAT3,1,NFCUT1,NFCUT,DDEV,DDF)
NFCUT1=NFCUT
CALL ADZER(DDV,1,NFCUT1,NAT3,IS1,IS2)
NFSAV=NFCUT1
OLDPRN=PRNLEV
PRNLEV=1
CALL ORTHNM(1,NFCUT1,NFCUT,DDV,NAT3,LPURG,TOLER)
PRNLEV=OLDPRN
CALL CPARAY(HEAP(DDVBAS),DDV,NAT3,1,NFCUT,1)
NFRET=NDIM+NFCUT
QMIX=.TRUE.
CALL RBDG(X,Y,Z,NAT3,NDIM,NFRET,DDV,DDF,DDEV,
1 DDSCR,HEAP(DD5),HEAP(DDSS),HEAP(DDV2),NADD,
2 INBCMP,JNBCMP,HEAP(DDVBAS),DD1CMP,QMIX,IS1,IS2,IS3,IS4,
3 CUTF1,NFCUT,NFREG,HEAP(IUPD),DD1BLL,HEAP(SCIFV1),
4 HEAP(SCIFV2),HEAP(SCIFV3),HEAP(SCIFV4),HEAP(SCIFV6),
5 HEAP(DRATQ),HEAP(ERATQ),HEAP(E2RATQ),
6 HEAP(BDRATQ),HEAP(INRATQ),LSCI,LBIG,IUNMOD)
QMIX=.FALSE.
IF(NFCUT.GT.NFRRES) NFCUT=NFRRES
NFCUT1=NFCUT
NFRET=NFCUT
ENDDO
GOTO I640 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C
C-----------------------------------------------------------------------
C TO DO-THE-DWIN-DIAGONALISATIONS
660 CONTINUE
C
C Store the DDV vectors into DDVBAS
C
NFCUT1=NFRRES
IS1=ATMPAD(1,IPAR1)
IS2=ATMPAD(2,IPAR1)
IS3=ATMPAD(1,IPAR2)
IS4=ATMPAD(2,IPAR2)
NDIM=(IS2-IS1+IS4-IS3+2)*3
IF(PRNLEV.GE.2) WRITE(OUTU,577) IPAR1,IPAR2,IS1,IS2,IS3,IS4
577 FORMAT(/' NMDIMB: Mixed double window diagonalization, parts ',
1 2I5/
2 ' NMDIMB: Block limits: ',I5,2X,I5,4X,I5,2X,I5)
IF(NDIM+NFCUT1.GT.PARDIM) CALL WRNDIE(-3,'<NMDIMB>',
1 'Error in dimension of block')
NFRET=NFCUT1
IF(NFRET.GT.NFREG) NFRET=NFREG
C
C Prepare the DDV vectors consisting of 6 translations-rotations
C + eigenvectors from 7 to NFCUT1 + cartesian displacements vectors
C spanning the atoms from IS1 to IS2
C
CALL CLETR(DDV,HEAP(TRAROT),NAT3,1,NFCUT1,NFCUT,DDEV,DDF)
NFCUT1=NFCUT
NFSAV=NFCUT1
CALL ADZERD(DDV,1,NFCUT1,NAT3,IS1,IS2,IS3,IS4)
OLDPRN=PRNLEV
PRNLEV=1
CALL ORTHNM(1,NFCUT1,NFCUT,DDV,NAT3,LPURG,TOLER)
PRNLEV=OLDPRN
CALL CPARAY(HEAP(DDVBAS),DDV,NAT3,1,NFCUT,1)
C
NFRET=NDIM+NFCUT
QMIX=.TRUE.
CALL RBDG(X,Y,Z,NAT3,NDIM,NFRET,DDV,DDF,DDEV,
1 DDSCR,HEAP(DD5),HEAP(DDSS),HEAP(DDV2),NADD,
2 INBCMP,JNBCMP,HEAP(DDVBAS),DD1CMP,QMIX,IS1,IS2,IS3,IS4,
3 CUTF1,NFCUT,NFREG,HEAP(IUPD),DD1BLL,HEAP(SCIFV1),
4 HEAP(SCIFV2),HEAP(SCIFV3),HEAP(SCIFV4),HEAP(SCIFV6),
5 HEAP(DRATQ),HEAP(ERATQ),HEAP(E2RATQ),
6 HEAP(BDRATQ),HEAP(INRATQ),LSCI,LBIG,IUNMOD)
QMIX=.FALSE.
C
IF(NFCUT.GT.NFRRES) NFCUT=NFRRES
NFCUT1=NFCUT
NFRET=NFCUT
GOTO I660 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C
C-----------------------------------------------------------------------
C TO SAVE-MODES
700 CONTINUE
IF(PRNLEV.GE.2) WRITE(OUTU,583) IUNMOD
583 FORMAT(/' NMDIMB: Saving the eigenvalues and eigenvectors to unit'
1 ,I4)
REWIND (UNIT=IUNMOD)
ISTRT=1
ISTOP=NFSAV
LCARD=.FALSE.
IF(PRNLEV.GE.2) WRITE(OUTU,585) NFSAV,IUNMOD
585 FORMAT(' NMDIMB: ',I5,' modes are saved in unit',I5)
CALL WRTNMD(LCARD,ISTRT,ISTOP,NAT3,DDV,DDSCR,DDEV,IUNMOD,
1 AMASS)
CALL SAVEIT(IUNMOD)
GOTO I700 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C
C-----------------------------------------------------------------------
C TO ALLOCATE-SPACE-FOR-DIAGONALIZATION
720 CONTINUE
DDV2=ALLHP(IREAL8((PARDIM+3)*(PARDIM+3)))
JSPACE=IREAL8((PARDIM+4))*8
JSP=IREAL8(((PARDIM+3)*(PARDIM+4))/2)
JSPACE=JSPACE+JSP
DDSS=ALLHP(JSPACE)
DD5=DDSS+JSPACE-JSP
GOTO I720 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C
C-----------------------------------------------------------------------
C TO ALLOCATE-SPACE-FOR-REDUCED-BASIS
760 CONTINUE
IF(LBIG) THEN
DDVBAS=ALLHP(IREAL8(NAT3))
ELSE
DDVBAS=ALLHP(IREAL8(NFREG*NAT3))
ENDIF
GOTO I760 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C
C-----------------------------------------------------------------------
C TO ALLOCATE-SPACE-FOR-TRANSROT-VECTORS
800 CONTINUE
TRAROT=ALLHP(IREAL8(6*NAT3))
GOTO I800 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C
C-----------------------------------------------------------------------
C TO ALLOCATE-SPACE-FOR-LSCI
840 CONTINUE
SCIFV1=ALLHP(IREAL8(PARDIM+3))
SCIFV2=ALLHP(IREAL8(PARDIM+3))
SCIFV3=ALLHP(IREAL8(PARDIM+3))
SCIFV4=ALLHP(IREAL8(PARDIM+3))
SCIFV6=ALLHP(IREAL8(PARDIM+3))
DRATQ=ALLHP(IREAL8(PARDIM+3))
ERATQ=ALLHP(IREAL8(PARDIM+3))
E2RATQ=ALLHP(IREAL8(PARDIM+3))
BDRATQ=ALLHP(IREAL8(PARDIM+3))
INRATQ=ALLHP(INTEG4(PARDIM+3))
GOTO I840 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C
C-----------------------------------------------------------------------
C TO ALLOCATE-DUMMY-SPACE-FOR-LSCI
880 CONTINUE
SCIFV1=ALLHP(IREAL8(2))
SCIFV2=ALLHP(IREAL8(2))
SCIFV3=ALLHP(IREAL8(2))
SCIFV4=ALLHP(IREAL8(2))
SCIFV6=ALLHP(IREAL8(2))
DRATQ=ALLHP(IREAL8(2))
ERATQ=ALLHP(IREAL8(2))
E2RATQ=ALLHP(IREAL8(2))
BDRATQ=ALLHP(IREAL8(2))
INRATQ=ALLHP(INTEG4(2))
GOTO I880 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C
C-----------------------------------------------------------------------
C TO ALLOCATE-SPACE-FOR-OTHER-ARRAYS
920 CONTINUE
IUPD=ALLHP(INTEG4(PARDIM+3))
GOTO I920 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" }
C.##ELSE
C.##ENDIF
END
| gpl-2.0 |
luca-penasa/mtspec-python3 | mtspec/src/programs/coherence.f90 | 2 | 26568 | module cohe_variables
!
! Module: define some global variables, that can be accesed and
! changed, modified by any function, program or subroutine
! that USES the specific module. The command is:
! use module_name
!
!
! For the scan subroutine
!
integer, parameter :: inmx = 500
character (len=100), dimension(inmx) :: input
character (len=100) :: output
character (len=20) :: type
integer :: iecho, nin
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Put here any global variables
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
real :: xbar, varx
integer :: nx,nf
real :: dt
real, dimension(:), allocatable :: t
real, dimension(:,:), allocatable :: x
real(4) :: fact, tbp, p
integer :: ntap, ntimes, kspec
real(4), dimension(:), allocatable :: freq
real(4), dimension(:), allocatable :: cohe, phase, conf
integer, dimension(:), allocatable :: kopt
real(4), dimension(:), allocatable :: spec1, spec2
real(4), dimension(:,:), allocatable :: cohe_ci, phase_ci
integer, parameter :: mxx=200000
end module cohe_variables
!----------------------------------------------------------------
program coherence
!
! Multitaper Power Spectral Density code
! See subroutine scan for synopsis of commands.
!
!
! Last modified 15 Sept 2005
!
!$$$$ calls getdat getone getint scan mtspec
!********************************************************************
use cohe_variables
use spectra
use mvspectra
use plot
implicit none
integer :: ignor, kwit, i
character (len = 100) :: output2
!********************************************************************
!
! Initializing two of the variables of the module,
! "Don't echo command lines when read"
!
iecho = -1
nin = 0
!
! Read in the commands
!
do
call scan
call getint('quit',ignor, kwit)
if (kwit >= 0) then
dt = 0.0
write(6,'(/a)') 'Normal Termination'
stop
endif
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Put here the call to your subroutines
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
if (allocated(x)) then
deallocate(x)
endif
if (allocated(t)) then
deallocate(t)
endif
call getdat
! Spectral parameters
call getint('ntap',ntap,kwit)
if (kwit .ne. 1) then
ntap = 0
endif
call getint('ntimes',ntimes,kwit)
if (kwit .ne. 1) then
ntimes = 2
endif
call getone('fact',fact,kwit)
if (kwit .ne. 1) then
fact = 1.
endif
call getone('tbnw',tbp,kwit)
if (kwit .ne. 1) then
tbp = 4.
endif
call getint('kspec',kspec,kwit)
if (kwit .ne. 1) then
kspec = 7
endif
call getone('conf',p,kwit)
if (kwit .ne. 1) then
p = 0.95
endif
nf = nx/2 + 1
if (allocated(freq)) then
deallocate(freq)
endif
if (allocated(spec1)) then
deallocate(spec1)
endif
if (allocated(spec2)) then
deallocate(spec2)
endif
if (allocated(cohe)) then
deallocate(cohe)
endif
if (allocated(phase)) then
deallocate(phase)
endif
if (allocated(kopt)) then
deallocate(kopt)
endif
if (allocated(conf)) then
deallocate(conf)
endif
if (allocated(cohe_ci)) then
deallocate(cohe_ci)
endif
if (allocated(phase_ci)) then
deallocate(phase_ci)
endif
allocate(freq(nf))
allocate(spec1(nf))
allocate(spec2(nf))
allocate(cohe(nf))
allocate(phase(nf))
allocate(kopt(nf))
allocate(conf(nf))
allocate(cohe_ci(nf,2))
allocate(phase_ci(nf,2))
kopt = kspec ! Set all freq to same # of tapers
call getchr('method',type,kwit)
if (kwit>0) then
if (0 .eq. index('sine para ',type(1:4))) then
call mt_cohe (nx,dt,x(:,1),x(:,2),tbp,kspec,nf,p, &
freq,cohe,phase,spec1, spec2,conf,cohe_ci, phase_ci )
else
call sine_cohe (nx,dt,x(:,1),x(:,2),ntap,ntimes,fact,nf,p, &
freq,cohe,phase,spec1,spec2,kopt,conf,cohe_ci,phase_ci)
endif
else ! Standard is Thomson method
call mt_cohe (nx,dt,x(:,1),x(:,2),tbp,kspec,nf,p, &
freq,cohe,phase,spec1, spec2,conf,cohe_ci, phase_ci )
endif
call getchr('save',output,kwit)
if (kwit>0) then
output2 = trim(adjustl(output))
open(12,file=output2,form='formatted')
write(6,'(2a)') &
'Output contains: freq, spec1, spec2, cohe, phase, # tapers, ', &
'conf, cohe_ci, phase_ci'
do i=1,nf
write(12,'(5E16.7,i5,5E16.7)') &
freq(i), spec1(i), spec2(i), cohe(i), phase(i), kopt(i), &
conf(i), cohe_ci(i,1), cohe_ci(i,2),phase_ci(i,1), phase_ci(i,2)
enddo
close(12)
endif
call getint('plot',ignor, kwit)
if (kwit>=0) then
if (ignor == 1) then
allocate(t(nx))
t = real( (/(i-1, i=1,nx)/) )*dt
call gplot(t,x(:,1),'plot',ylimit='4',xlimit='5', &
frame=' ')
call gplot(t,x(:,2),ylimit='4',xlimit='5', &
frame='frame on top right -xaxis',output='ts.ps')
deallocate(t)
endif
call gplot(freq,conf,'hold',color='2',xlabel='Frequency (Hz)', &
ylabel='Coherence')
call gplot(freq,cohe,'plot',color='1',frame=' ',&
ylimit='4 0. 1.',xlimit='5')
call gplot(freq,phase,frame='frame on top right -xaxis', &
ylimit='4 -200 200',xlimit='5',color='black', &
ylabel='Phase',output='coh_plot.ps')
endif
write(6,'(/a)')'Enter further commands or "quit" to terminate run'
enddo
end program coherence
!_______________________________________________________________
!
! Contains
!
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Put here your subroutines
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
!_______________________________________________________________________
!=======================================================================
! Unit K: Decoding routines for command kit
!=======================================================================
subroutine scan
!$$$$ calls clear getchr icheck
! Input routine for commands
! Reads from the standard input until eof or code "execute " or "quit".
! Saves lines in the input in cohe_variables for later retrieval by
! getarr, getone or getchr.
! Prints a glossary upon request
!********************************************************************
use cohe_variables
implicit none
integer :: n1, ignor, i, ios, l
character *80 line, code*4
!********************************************************************
if (nin .eq. 0) then
write(6,'(a)') ' ', &
'Enter commands for coherence estimation (? for help)'
endif
do l=nin+1, inmx
read(*,'(80a)', iostat = ios) line
if (ios<0) then
stop
endif
call ljust(line,line) ! Remove leading blanks
if (line(1:4) == 'exec') then
exit
endif
!
! List a glossary of codes
!
if (line(1:1) .eq. '?') then
write(6,'(a/(2x,a))') &
'Enter commands from the following list:', &
'?: Remind me of the command list again', &
'execute: With given parameters start coherence program', &
'file file1 [file2]: Enter filename(s) of data (mandatory)', &
'method type: Enter the method to use (Thomson (def) - Sine )', &
'interval dt: Sampling interval of data', &
'nterms n: Number of data points to be read', &
'skip k: Skip over k lines before reading data', &
'column k n: Read data from columns k [and n] in a table', &
'kspec k: Number of taper for Slepian tapers (Default = 7)', &
'tbnw nw: Time-bandwidth product for Thomson method (def=4.)', &
'ntap ntap: Number of tapers to be used (constant number)', &
'ntimes ntimes: # Iterations adaptive spectrum (overrides ntap)', &
'fact factor: The spectral smoothing for derivative estimates', &
'conf p: Probability that the coherence exceeds 0 (def 0.95)', &
'save file: The file to save the coherence spectrum ', &
'review: Display current command stack', &
'clear command: Delete most recent occurrence of the command', &
'plot i: Make plots of cohe/phase (to plot data set i=1)', &
' '
!
! Review the command stack
!
elseif (line(1:4) .eq. 'revi') then
write(6,'(5x,a)')' ', '=================== ', &
(input(i)(1:60),i=1,nin),'=================== '
elseif (line(1:1) .ne. ' ') then
! Translate homonyms
if (line(1:4) .eq. 'echo') then
iecho=-iecho
endif
nin=nin + 1
if (nin > inmx) then
write(6,'(a)') '>>>> Too many commands - memory full'
stop
endif
call icheck(line)
input(nin)=line
if (line(1:4) .eq. 'quit') then
return
endif
!
! Clear a command and clear clear itself
!
if (line(1:4) .eq. 'clea') then
call getchr('clear', code, ignor)
call clear (code)
nin=nin - 1
endif
endif
enddo
n1=max(1, nin-24)
write(6,'(5x,a)')' ', '=================== ', &
(input(i)(1:60),i=n1,nin),'=================== '
return
end subroutine scan
!______________________________________________________________________
subroutine icheck(line)
!$$$$ calls nothing
! Checks the command fragment com against the catalog; appends a
! warning if com is not present in the list.
!********************************************************************
use cohe_variables
implicit none
character*80 line, com*4
!********************************************************************
com=line(1:4)
if (0 .eq. &
index('clea colu detr file inte ',com) &
+index('nter outp skip save ',com) &
+index('ntap ntim fact quit ', com) &
+index('kspe tbnw meth conf plot ', com)) then
line=line(1:20)//' %<<<<<<< Unrecognized command'
endif
return
end subroutine icheck
!______________________________________________________________________
subroutine getarr(code, values, nwant, nfound)
!$$$$ calls ljust
! Extracts an array of numbers from input in the cohe_variables module.
! It is a large array in the cohe_variables module at the end of the
! file, which has been filled earlier.
! code A 4-byte identifying code. Only lines in the input store
! beginning with this code are scanned for numbers.
! values the real output array of values found.
! nwant the maximum number of numbers expected .
! nfound the number of numbers actually found in the input.
! If the line contains fewer than nwant values, this is the
! value returned in nfound. If an error is discovered
! nfound=-n, where n is the number of numbers properly
! decoded. If there are no numbers after the codeword
! nfound=0. Finally, if the code is absent from the store
! nfound=-99 and the array is left undisturbed.
!********************************************************************
use cohe_variables
implicit none
integer :: l, ios, lbl, n, n1, n2, lin, nwant, nfound
real :: values
character *80 line,local,char, code*4
dimension values(*)
!********************************************************************
!
! Read the store in reverse order (Thus last entry is obeyed)
!
do lin=nin, 1, -1
line=input(lin)
!
! Check for code
!
if (code == line(1:4)) then
if (iecho .ge. 1) then
write(6,'(2a)')'==> ',line
endif
n1=index(line, ' ')+1
n2=index(line, '%')
n2=80 + min(n2,1)*(n2 - 81)
char=line(n1:n2)
do n=1, nwant
call ljust(char, local)
lbl=index(local, ' ')
if (lbl .eq. 1) then
nfound = n -1
return
endif
read (local, *, iostat=ios) values(n)
if (ios > 0) then
print '(a)',' ', &
'>>> Unreadable numbers in this input line:',line
nfound = l - n
return
endif
char=local(lbl:80)
enddo
n=nwant+1
nfound = n - 1
return
endif
enddo
!
! Code word not found
!
nfound=-99
return
end subroutine getarr
!______________________________________________________________
subroutine getone(code, value, nfound)
!$$$$ calls getarr
! Extracts a single number from the input store. That store is
! a large array in the cohe_variables module at the end of the
! file, which has been filled earlier.
! code A 4-bye identifying code. Only lines in the input store
! beginning with this code are scanned for numbers.
! value the real output variable containing the desired number.
! nfound is 1 if a number is successfully read in; it is zero
! the number is absent or unreadable. nfound = -99 if the
! code is absent from the input store.
!********************************************************************
use cohe_variables
implicit none
character*4 code
real, dimension(1) :: v
real :: value
integer :: nfound
!********************************************************************
call getarr(code, v, 1, nfound)
if (nfound .eq. 1) then
value=v(1)
endif
return
end subroutine getone
!______________________________________________________________
subroutine getint(code, number, nfound)
!$$$$ calls getarr
! Extracts a single integer from the input store.
! See getone for details.
!
!********************************************************************
use cohe_variables
implicit none
character*4 code
real, dimension(1) :: v
integer :: number, nfound
!********************************************************************
call getarr(code, v, 1, nfound)
if (nfound .eq. 1) then
number=nint(v(1))
if (number .ne. v(1)) then
write(6,'(4a,1p,g16.8/a,i10)') &
'>>> Warning: ',code,' expects an integer argument, but', &
' found: ',v(1),' Returns: ',number,' '
endif
endif
return
end subroutine getint
!______________________________________________________________
subroutine getchr(code, char, nbytes)
! $$$$ calls ljust
! Extracts a single character variable from the input store. That
! store is a large array in the cohe_variables module at the end
! of the file, which has been filled earlier.
!
! code A 4-byte identifying code. Only lines in the input store
! beginning with this code are scanned.
! char the character output variable containing the desired string.
! nbytes is the length of the string read; it is zero if
! the line is blank after the code. nbytes = -99 if the
! code is absent from the input store.
!
!********************************************************************
use cohe_variables
implicit none
integer :: k, nn, n1, n2, lin, nbytes
character *80 line, char*(*), code*4
!********************************************************************
!
! Inspect the store in reverse order (thus reading latest entry)
!
do lin=nin, 1, -1
line=input(lin)
!
! Check for code word
!
if (code == line(1:4)) then
if (iecho >= 1) then
write(6,'(2a)')'==> ',line
endif
n1=index(line, ' ')+1
n2=index(line, '%')
n2=80 + min(n2,1)*(n2 - 81)
!
! Check for blank string
!
nbytes=0
if (line(n1:n2) == ' ') then
return
endif
!
! Save in char everything from 1st non-blank to last non-blank
!
call ljust(line(n1:n2), char)
nn=min(n2-n1+1, len(char))
do k=nn, 1, -1
if (char(k:k) .ne. ' ') then
exit
endif
enddo
nbytes= k
return
endif
enddo
!
! Code word not found
!
nbytes=-99
return
end subroutine getchr
!______________________________________________________________
subroutine clear(code)
!$$$$ calls nothing
!
! Removes the last command entry identified by code.
! code A 4-byte identifying code. Only lines in the input store
! beginning with this code are scanned.
!
!********************************************************************
use cohe_variables
implicit none
integer :: lin
character *80 line, code*4
!********************************************************************
!
! Inspect the store in normal order
!
do lin= nin, 1, -1
line=input(lin)
!
! Check code and clear the line if present, but only once
!
if (code .eq. line(1:4)) then
input(lin)=' --'
return
endif
enddo
return
end subroutine clear
!______________________________________________________________
subroutine ljust(str1, str2)
!$$$$ calls nothing
! Left justify: input character string str1 (up to 80 bytes in length)
! is left justified, removing leading blanks, and returned in str2.
! str1 and str2 may be set to the same variable in the call.
!********************************************************************
use cohe_variables
implicit none
integer :: j, l1
character*(*) str1, str2, str3*80
!********************************************************************
str2=str1
if (str1 == ' ') then
return
endif
l1=len(str1)
str3=str1
do j=1, l1
if (str1(j:j) .ne. ' ') then
str2=str3(j:l1)
return
endif
enddo
return
end subroutine ljust
!______________________________________________________________________
function later(code1, code2)
!$$$$ calls nothing
! Returns the difference in order number in the stack of the
! most recent occurrence of the commands code1, code2. If the
! command isn't present assigns it the order number zero.
! Thus later > 0 if code1 occurs after code 2, < 0 if before,
! and later=0 if both are absent and code1 and code2 are different.
!********************************************************************
use cohe_variables
implicit none
integer :: lin, kode2, kode1, later
character *80 line, code1*4,code2*4
!********************************************************************
!
! Inspect the store
!
kode1=0
kode2=0
do lin=1, nin
line=input(lin)
if (code1 .eq. line(1:4)) then
kode1=lin
endif
if (code2 .eq. line(1:4)) then
kode2=lin
endif
enddo
later=kode1 - kode2
return
end function later
!=======================================================================
! Unit D: Get the Data
!=======================================================================
subroutine getdat
!$$$$ calls getarr getchr getone getint
!
! Gets the file name and reads data into vector x().
! I define a y() vector, just in this program, to be
! able to allocate the x() vector with the size of the
! data series.
!
! Issues error messages.
!
!********************************************************************
use cohe_variables
implicit none
character (len=64) :: name, temp
character (len=64), dimension(2) :: name1
real, dimension(40) :: tab
real, dimension(mxx,2) :: y
real :: dum
real, dimension(2) :: column, rskip
integer :: l, koln, kols, intdt, nte, j, nt, none
integer :: nterm, ios, itwas, koln2
integer :: kbl, nfiles, i1, i2, nfl, nskip
integer, dimension(2) :: iskip
data nterm/mxx/
save nterm
!********************************************************************
name(1:1) = ' ' ! Assign a default name.
column = 1 ! If no column assigned, use column = 1
iskip = 0 ! If no skipping assigned, do not skip
call getchr('file', name, itwas)
if (itwas == 0) then
write(6,'(a)')'>>> Psd cannot continue without a file name'
stop
endif
if (itwas == -99) then
write(6,'(a)')'>>> Command file is mandatory'
stop
endif
kbl = index(name(1:itwas), ' ')
nfiles = min(2,kbl+1)
if (kbl == 0) then
kbl = itwas
endif
!
! If there are two files, squeeze out excess blanks in name
if (nfiles .eq. 2) then
call ljust(name(kbl:itwas), temp)
name(kbl+1:itwas)=temp
write(6,'(a)') 'Data will be read from two separate files:',name
column(2)=1
endif
i1=1
i2=kbl
!
! Number of terms to skip
!
nskip = 0
call getarr('skip', rskip, 2, nskip)
if (nskip > 1) then
iskip(1) = rskip(1)
iskip(2) = rskip(2)
elseif (nskip == 1) then
iskip = rskip(1)
else
iskip = 0
endif
if (nfiles == 2 ) then
name1(1) = name(i1:i2)
name1(2) = name(i2+1:itwas)
else
name1(1) = name
endif
!
! Skip records before reading
!
do nfl = 1,nfiles
open(11,file=name1(nfl), status='OLD', iostat=ios)
if( ios/=0) then
write (6,'(2a)') 'Unable to open file: ', name1(nfl)
stop
endif
if (none >= 1 .and. iskip(nfl) > 0) then
do j=1, iskip(nfl)
read (11,*, iostat = ios) dum
if (ios<0) then
write(6,'(2a)') '>>> End of file encountered', &
' while skipping'
stop
endif
enddo
write(6,'(a,i7)')' Skipped records before data:',iskip(nfl)
endif
!
! Get number of terms to be read
!
nt=mxx
call getint('nterms', nterm, nte)
if (nte > 0) then
nt=min(mxx, nterm)
endif
!
! Get the sampling interval
!
call getone('interval', dt, intdt)
if (intdt < 0) then
dt = 1.0
endif
!
! Get column(s) to be read
!
call getarr('column', column, 2, kols)
if (kols > 1) then
koln = column(1)
koln2 = column(2)
elseif (kols == 1) then
koln = column(1)
koln2 = koln
else
write(6,'(a)') 'Column has to be either 1 or two values'
stop
endif
!
! Read from two columns in same file, given by user
!
if (nfiles == 1) then
write(6,'(a,2i4)')'Series read from columns ',koln,koln2
do j=1, nt
read (11,*, iostat = ios) (tab(l),l=1,max(koln,koln2))
if (ios > 0) then
write(6,'(2a,i7)') '>>> Unreadable number in ', &
'data file at point ', j
stop
endif
if (ios<0) then
nx = j-1
write(6,'(a)') ' EOF detected in data file'
rewind(unit=11)
write(6,'(a,i7)')' Number of terms read:',nx
allocate(x(nx,2))
x(:,1) = y(1:nx,1)
x(:,2) = y(1:nx,2)
exit
endif
y(j,1) = tab(koln)
y(j,2) = tab(koln2)
enddo
!
! Read from 2 files.
!
else
koln = nint(column(nfl))
write(6,'(2(a,i3))')'Reading file number',nfl,', column ',koln
do j = 1,nt
read (11, *, iostat=ios) (tab(l),l=1, koln)
if (ios>0) then
write(6,'(2a,i7)')'>>> Unreadable number in data', &
'file at point',j
stop
elseif(ios<0) then
nx = j-1
write(6,'(a)') ' EOF detected in data file'
rewind(unit=11)
write(6,'(a,i7)')' Number of terms read:',nx
if (allocated(x)) then
write(6,'(a,i7)')' Already allocated array:', nx
else
allocate(x(nx,2))
endif
x(:,nfl) = y(1:nx,nfl)
exit
endif
y(j,nfl) = tab(koln)
enddo
endif
enddo
if (ios >= 0) then
if (nt == mxx) then
write(6,'(2a,i7,a)') &
'>>> Array space filled:', &
' series truncated to',mxx,' terms'
nx=nt
allocate(x(nx,2))
x(:,1) = y(1:nx,1)
x(:,2) = y(1:nx,2)
else
nx = nt
allocate(x(nx,2))
x(:,1) = y(1:nx,1)
x(:,2) = y(1:nx,2)
endif
endif
write(6,'(a,i7)')' Number of terms read:',nx
if (nx == 0) then
allocate(x(mxx,2)) ! If nx is zero, need to allocate x()
endif
close(11)
return
end subroutine getdat
!___________________________________________________________________
| gpl-2.0 |
embecosm/avr32-gcc | gcc/testsuite/gfortran.dg/c_kind_params.f90 | 8 | 3141 | ! { dg-do run }
! { dg-require-effective-target stdint_types }
! { dg-additional-sources c_kinds.c }
! { dg-options "-w -std=c99" }
! the -w option is needed to make f951 not report a warning for
! the -std=c99 option that the C file needs.
!
! Note: int_fast*_t currently not supported, cf. PR 448.
module c_kind_params
use, intrinsic :: iso_c_binding
implicit none
contains
subroutine param_test(my_short, my_int, my_long, my_long_long, &
my_int8_t, my_int_least8_t, my_int16_t, &
my_int_least16_t, my_int32_t, my_int_least32_t, &
my_int64_t, my_int_least64_t, &
my_intmax_t, my_intptr_t, my_float, my_double, my_long_double, &
my_char, my_bool) bind(c)
integer(c_short), value :: my_short
integer(c_int), value :: my_int
integer(c_long), value :: my_long
integer(c_long_long), value :: my_long_long
integer(c_int8_t), value :: my_int8_t
integer(c_int_least8_t), value :: my_int_least8_t
! integer(c_int_fast8_t), value :: my_int_fast8_t
integer(c_int16_t), value :: my_int16_t
integer(c_int_least16_t), value :: my_int_least16_t
! integer(c_int_fast16_t), value :: my_int_fast16_t
integer(c_int32_t), value :: my_int32_t
integer(c_int_least32_t), value :: my_int_least32_t
! integer(c_int_fast32_t), value :: my_int_fast32_t
integer(c_int64_t), value :: my_int64_t
integer(c_int_least64_t), value :: my_int_least64_t
! integer(c_int_fast64_t), value :: my_int_fast64_t
integer(c_intmax_t), value :: my_intmax_t
integer(c_intptr_t), value :: my_intptr_t
real(c_float), value :: my_float
real(c_double), value :: my_double
real(c_long_double), value :: my_long_double
character(c_char), value :: my_char
logical(c_bool), value :: my_bool
if(my_short /= 1_c_short) call abort()
if(my_int /= 2_c_int) call abort()
if(my_long /= 3_c_long) call abort()
if(my_long_long /= 4_c_long_long) call abort()
if(my_int8_t /= 1_c_int8_t) call abort()
if(my_int_least8_t /= 2_c_int_least8_t ) call abort()
print *, 'c_int_fast8_t is: ', c_int_fast8_t
if(my_int16_t /= 1_c_int16_t) call abort()
if(my_int_least16_t /= 2_c_int_least16_t) call abort()
print *, 'c_int_fast16_t is: ', c_int_fast16_t
if(my_int32_t /= 1_c_int32_t) call abort()
if(my_int_least32_t /= 2_c_int_least32_t) call abort()
print *, 'c_int_fast32_t is: ', c_int_fast32_t
if(my_int64_t /= 1_c_int64_t) call abort()
if(my_int_least64_t /= 2_c_int_least64_t) call abort()
print *, 'c_int_fast64_t is: ', c_int_fast64_t
if(my_intmax_t /= 1_c_intmax_t) call abort()
if(my_intptr_t /= 0_c_intptr_t) call abort()
if(my_float /= 1.0_c_float) call abort()
if(my_double /= 2.0_c_double) call abort()
if(my_long_double /= 3.0_c_long_double) call abort()
if(my_char /= c_char_'y') call abort()
if(my_bool .neqv. .true._c_bool) call abort()
end subroutine param_test
end module c_kind_params
! { dg-final { cleanup-modules "c_kind_params" } }
| gpl-2.0 |
SaberMod/GCC_SaberMod | gcc/testsuite/gfortran.fortran-torture/execute/entry_7.f90 | 190 | 2079 | ! Test alternate entry points for functions when the result types
! of all entry points match
function f1 (a)
integer a, b
integer, pointer :: f1, e1
allocate (f1)
f1 = 15 + a
return
entry e1 (b)
allocate (e1)
e1 = 42 + b
end function
function f2 ()
real, pointer :: f2, e2
entry e2 ()
allocate (e2)
e2 = 45
end function
function f3 ()
double precision, pointer :: f3, e3
entry e3 ()
allocate (f3)
f3 = 47
end function
function f4 (a) result (r)
double precision a, b
double precision, pointer :: r, s
allocate (r)
r = 15 + a
return
entry e4 (b) result (s)
allocate (s)
s = 42 + b
end function
function f5 () result (r)
integer, pointer :: r, s
entry e5 () result (s)
allocate (r)
r = 45
end function
function f6 () result (r)
real, pointer :: r, s
entry e6 () result (s)
allocate (s)
s = 47
end function
program entrytest
interface
function f1 (a)
integer a
integer, pointer :: f1
end function
function e1 (b)
integer b
integer, pointer :: e1
end function
function f2 ()
real, pointer :: f2
end function
function e2 ()
real, pointer :: e2
end function
function f3 ()
double precision, pointer :: f3
end function
function e3 ()
double precision, pointer :: e3
end function
function f4 (a)
double precision a
double precision, pointer :: f4
end function
function e4 (b)
double precision b
double precision, pointer :: e4
end function
function f5 ()
integer, pointer :: f5
end function
function e5 ()
integer, pointer :: e5
end function
function f6 ()
real, pointer :: f6
end function
function e6 ()
real, pointer :: e6
end function
end interface
double precision d
if (f1 (6) .ne. 21) call abort ()
if (e1 (7) .ne. 49) call abort ()
if (f2 () .ne. 45) call abort ()
if (e2 () .ne. 45) call abort ()
if (f3 () .ne. 47) call abort ()
if (e3 () .ne. 47) call abort ()
d = 17
if (f4 (d) .ne. 32) call abort ()
if (e4 (d) .ne. 59) call abort ()
if (f5 () .ne. 45) call abort ()
if (e5 () .ne. 45) call abort ()
if (f6 () .ne. 47) call abort ()
if (e6 () .ne. 47) call abort ()
end
| gpl-2.0 |
embecosm/avr32-gcc | gcc/testsuite/gfortran.dg/proc_decl_3.f90 | 193 | 1304 | ! { dg-do compile }
! Some tests for PROCEDURE declarations inside of interfaces.
! Contributed by Janus Weil <jaydub66@gmail.com>
module m
interface
subroutine a()
end subroutine a
end interface
procedure(c) :: f
interface bar
procedure a,d
end interface bar
interface foo
procedure c
end interface foo
abstract interface
procedure f ! { dg-error "must be in a generic interface" }
end interface
interface
function opfoo(a)
integer,intent(in) :: a
integer :: opfoo
end function opfoo
end interface
interface operator(.op.)
procedure opfoo
end interface
external ex ! { dg-error "has no explicit interface" }
procedure():: ip ! { dg-error "has no explicit interface" }
procedure(real):: pip ! { dg-error "has no explicit interface" }
interface nn1
procedure ex
procedure a, a ! { dg-error "already present in the interface" }
end interface
interface nn2
procedure ip
end interface
interface nn3
procedure pip
end interface
contains
subroutine d(x)
interface
subroutine x()
end subroutine x
end interface
interface gen
procedure x
end interface
end subroutine d
function c(x)
integer :: x
real :: c
c = 3.4*x
end function c
end module m
| gpl-2.0 |
pbosler/LPPM | AdvectMovingVortsRefineVorticity.f90 | 2 | 24238 | program MovingVorticesAdvectionAMRVorticity
use NumberKindsModule
use OutputWriterModule
use LoggerModule
use SphereGeomModule
use SphereMeshModule
use AdvectionModule
use ParticlesModule
use PanelsModule
use SphereMeshModule
use TracerSetupModule
use VTKOutputModule
use BVESetupModule
use SphereRemeshModule
implicit none
include 'mpif.h'
!
! mesh variables
!
type(SphereMesh) :: sphere
integer(kint) :: panelKind, initNest, AMR, nTracer
type(Particles), pointer :: sphereParticles
type(Panels), pointer :: spherePanels
integer(kint), allocatable :: amrN(:)
!
! tracer variables
!
type(TracerSetup) :: testCaseTracer
integer(kint) :: tracerID
real(kreal) :: vortStartLon, vortStartLat
!
! vorticity placeholder
!
type(BVESetup) :: nullVort
real(kreal) :: maxCircTol, vortVarTol
!
! remeshing / refinement variables
!
type(RemeshSetup) :: remesh
integer(kint) :: remeshInterval, resetAlphaInterval, amrLimit, remeshCounter
real(kreal) :: tracerMassTol, tracerVarTol, lagVarTol
type(ReferenceSphere), pointer :: reference
!
! time stepping variables
!
type(AdvRK4Data) :: timekeeper
real(kreal) :: t, tfinal, dt
integer(kint) :: timesteps, timeJ
!
! output variables
!
type(VTKSource) :: vtkOut, vtkMeshOut
character(len = MAX_STRING_LENGTH) :: vtkRoot, vtkFile, vtkMeshFile, outputDir, jobPrefix, dataFile, summaryFile
character(len = 56) :: amrString
integer(kint) :: frameCounter, frameOut, readWriteStat
type(OutputWriter) :: writer
!
! test case variables
!
real(kreal), allocatable :: totalMasstestCaseTracer(:), sphereL1(:), sphereL2(:), sphereLinf(:), panelsLinf(:),&
particlesLinf(:), phiMax(:), phiMin(:), tracerVar(:), surfArea(:)
real(kreal) :: deltaPhi, phimax0, phimin0
real(kreal) :: mass0, var0
!
! logging
!
type(Logger) :: exeLog
character(len=28) :: logkey
character(len=MAX_STRING_LENGTH) :: logstring
!
! mpi / computing environment / general variables
!
integer(kint) :: errCode
real(kreal) :: wallclock
integer(kint) :: j
!
! namelists and user input
!
character(len=MAX_STRING_LENGTH) :: namelistFile = 'MovingVortices2.namelist'
namelist /meshDefine/ initNest, AMR, panelKind, amrLimit, maxCircTol, vortVarTol, tracerMassTol, tracerVarTol, lagVarTol
namelist /timestepping/ tfinal, dt, remeshInterval, resetAlphaInterval
namelist /fileIO/ outputDir, jobPrefix, frameOut
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! INITIALIZE COMPUTER, MESH, TEST CASE
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
call MPI_INIT(errCode)
call MPI_COMM_SIZE(MPI_COMM_WORLD, numProcs, errCode)
call MPI_COMM_RANK(MPI_COMM_WORLD, procRank, errCode)
call InitLogger(exeLog, procRank)
wallclock = MPI_WTIME()
nTracer = 3
!
! get user input
!
call ReadNamelistFile(procRank)
!
! define tracer
!
tracerID = 1
vortStartLon = 0.0_kreal
vortStartLat = 0.0_kreal
call New(testCaseTracer, 1, 2)
call InitMovingVortsTracer(testCaseTracer, vortStartLon, vortStartLat, tracerID)
!
! build initial mesh
!
call New(sphere, panelKind, initNest, AMR, nTracer, BVE_SOLVER)
sphereParticles => sphere%particles
spherePanels => sphere%panels
call SetTestCaseVorticityOnMesh(sphere, nullVort, 0.0_kreal)
call SetMovingVortsTracerOnMesh(sphere, testCaseTracer)
!
! initialize remeshing and refinement
!
call ConvertFromRelativeTolerances(sphere, maxCircTol, vortVarTol, tracerMassTol, &
tracerVarTol, tracerID, lagVarTol)
call LogMessage(exeLog, TRACE_LOGGING_LEVEL, 'maxCircTol = ', maxCircTol )
call LogMessage(exeLog, TRACE_LOGGING_LEVEL, 'vortVarTol = ', vortVarTol )
call LogMessage(exeLog, TRACE_LOGGING_LEVEL, 'tracerMassTol = ', tracerMassTol )
call LogMessage(exeLog, TRACE_LOGGING_LEVEL, 'tracerVarTol = ', tracerVarTol )
call LogMessage(exeLog, TRACE_LOGGING_LEVEL, ' lagVarTol = ', lagVarTol )
if ( procRank == 0 ) then
print *, "maxCircTol = ", maxCircTol
print *, "lagVarTol = ", lagVarTol
endif
call New(remesh, maxCircTol, vortVarTol, lagVarTol, tracerID, tracerMassTol, tracerVarTol, amrLimit)
nullify(reference)
if ( AMR > 0 ) then
call InitialRefinement(sphere, remesh, SetMovingVortsTracerOnMesh, testCaseTracer, &
SetTestCaseVorticityOnMesh, nullvort, 0.0_kreal)
if ( panelKind == QUAD_PANEL ) &
write(amrstring,'(A,I1,A,I0.2,A)') 'quadAMR_', initNest, 'to', initNest+amrLimit, '_'
if ( panelKind == TRI_PANEL ) &
write(amrstring,'(A,I1,A,I0.2,A)') 'triAMR_', initNest, 'to', initNest+amrLimit, '_'
print *, "rel surf area error = ", (sum(spherePanels%area) - (4.0_kreal * PI * EARTH_RADIUS * EARTH_RADIUS)) / &
((4.0_kreal * PI * EARTH_RADIUS * EARTH_RADIUS))
!call ResetSphereArea(sphere)
!print *, "rel surf area error = ", (sum(spherePanels%area) - (4.0_kreal * PI * EARTH_RADIUS * EARTH_RADIUS)) / &
! (4.0_kreal * PI * EARTH_RADIUS * EARTH_RADIUS)
else
if ( panelKind == QUAD_PANEL ) &
write(amrstring,'(A,I1,A)') 'quadUnif_', initNest, '_'
if ( panelKind == TRI_PANEL ) &
write(amrstring,'(A,I1,A)') 'triUnif_', initNest, '_'
endif
do j = 1, sphereParticles%N
sphereParticles%tracer(j,3) = testCaseTracerExact(sphereParticles%x(:,j), 0.0_kreal,testCaseTracer)
enddo
do j = 1, spherePanels%N
if ( spherePanels%hasChildren(j) ) then
spherePanels%tracer(j,3) = 0.0_kreal
else
spherePanels%tracer(j,3) = testCaseTracerExact( spherePanels%x(:,j), 0.0_kreal,testCaseTracer)
endif
enddo
!
! initialize output
!
if ( procrank == 0 ) then
call LogStats( sphere, exeLog)
write(vtkRoot,'(A,A,A,A,A)') trim(outputDir), 'vtkOut/',trim(jobPrefix),trim(amrString),'_'
write(vtkFile,'(A,I0.4,A)') trim(vtkRoot),0,'.vtk'
write(vtkMeshFile,'(A,A,I0.4,A)') trim(vtkRoot), '_mesh_',0,'.vtk'
write(summaryFile,'(A,A,A,A)') trim(outputDir), trim(jobPrefix), trim(amrString), '_summary.txt'
write(datafile,'(A,A,A,A)') trim(outputDir), trim(jobPrefix), trim(amrstring), '_calculatedData.m'
call New(vtkOut, sphere, vtkFile, 'moving vortices')
call New(vtkMeshOut, sphere, vtkMeshFile, 'moving vortices')
call VTKOutput(vtkOut, sphere)
call VTKOutputMidpointRule(vtkMeshOut,sphere)
endif
!
! initialize time stepping
!
call New(timekeeper, sphere, numProcs)
timesteps = floor(tfinal / dt)
t = 0.0_kreal
remeshCounter = 0
frameCounter = 1
allocate(totalMasstestCaseTracer(0:timesteps))
totalMasstestCaseTracer = 0.0_kreal
mass0 = TotalMass(sphere, tracerID)
allocate(sphereL2(0:timesteps))
sphereL2 = 0.0_kreal
allocate(sphereLinf(0:timesteps))
sphereLinf = 0.0_kreal
allocate(particlesLinf(0:timesteps))
particlesLinf = 0.0_kreal
allocate(panelsLinf(0:timesteps))
panelsLinf = 0.0_kreal
allocate(phiMax(0:timesteps))
phiMax = 0.0_kreal
allocate(phiMin(0:timesteps))
phiMin = 0.0_kreal
allocate(tracerVar(0:timesteps))
tracerVar = 0.0_kreal
var0 = TracerVariance(sphere, tracerID)
allocate(sphereL1(0:timesteps))
sphereL1 = 0.0_kreal
allocate(amrN(0:timesteps))
amrN(0) = spherePanels%N_Active
allocate(surfArea(0:timesteps))
surfArea(0) = sum(spherePanels%area)
phimax0 = max( maxval(sphereParticles%tracer(1:sphereParticles%N,1)), maxval(spherePanels%tracer(1:spherePanels%N,1)) )
phimin0 = 0.0_kreal
deltaPhi = phimax0 - phimin0
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! RUN THE PROBLEM
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
do timeJ = 0, timesteps - 1
if ( mod( timeJ+1, remeshInterval) == 0 ) then
!
! remesh before timestep
!
remeshCounter = remeshCounter + 1
!
! choose appropriate remeshing procedure
!
if ( remeshCounter < resetAlphaInterval ) then
!
! remesh to t = 0
!
call LagrangianRemeshToInitialTime(sphere, remesh, SetTestCaseVorticityOnMesh, &
nullVort, SetMovingVortsTracerOnMesh, testCaseTracer,t)
elseif ( remeshCounter == resetAlphaInterval ) then
!
! remesh to t = 0, create reference mesh to current time
!
call LagrangianRemeshToInitialTime(sphere, remesh, SetTestCaseVorticityOnMesh, &
nullVort, SetMovingVortsTracerOnMesh, testCaseTracer,t)
allocate(reference)
call New(reference, sphere)
call ResetLagrangianParameter(sphere)
elseif ( remeshCounter > resetAlphaInterval .AND. mod(remeshCounter, resetAlphaInterval) == 0 ) then
!
! remesh to existing reference, then create new reference to current time
!
call LagrangianRemeshToReference( sphere, reference, remesh, SetTestCaseVorticityOnMesh, nullVort, t)
call Delete(reference)
call New( reference, sphere)
call ResetLagrangianParameter(sphere)
else
!
! remesh to existing reference
!
call LagrangianRemeshToReference(sphere, reference, remesh)
endif
!
! delete objects associated with old mesh
!
call Delete(timekeeper)
if ( procrank == 0 ) then
call Delete(vtkOUt)
call Delete(vtkMeshOut)
endif
!
! create new associated objects for new mesh
!
call New(timekeeper, sphere, numProcs)
if ( procRank == 0 ) then
call New(vtkOut, sphere, vtkFile, 'moving vortices')
call New(vtkMeshOut, sphere, vtkMeshFile, 'moving vortices')
endif
sphereParticles => sphere%particles
spherePanels => sphere%panels
print *, "rel surf area error = ", (sum(spherePanels%area) - (4.0_kreal * PI * EARTH_RADIUS * EARTH_RADIUS)) / &
(4.0_kreal * PI * EARTH_RADIUS * EARTH_RADIUS)
!call ResetSphereArea(sphere)
!print *, "rel surf area error = ", (sum(spherePanels%area) - (4.0_kreal * PI * EARTH_RADIUS * EARTH_RADIUS)) / &
! (4.0_kreal * PI * EARTH_RADIUS * EARTH_RADIUS)
endif ! remesh
!
! advance time
!
call AdvectionRK4Timestep(timekeeper, sphere, dt, t, procRank, numProcs, MovingVorticesVelocity)
t = real( timeJ+1, kreal) * dt
call SetTestCaseVorticityOnMesh(sphere, nullVort, t)
do j = 1, sphereParticles%N
sphereParticles%tracer(j,3) = testCaseTracerExact(sphereParticles%x(:,j), t, testCaseTracer)
enddo
do j = 1, spherePanels%N
if ( spherePanels%hasChildren(j) ) then
spherePanels%tracer(j,3) = 0.0_kreal
else
spherePanels%tracer(j,3) = testCaseTracerExact( spherePanels%x(:,j), t, testCaseTracer)
endif
enddo
!
! calculate error
!
do j = 1, sphereParticles%N
sphereParticles%tracer(j,2) = (sphereParticles%tracer(j,1) - sphereParticles%tracer(j,3)) /&
maxval(abs(sphereParticles%tracer(1:sphereParticles%N,1)))
enddo
do j = 1, spherePanels%N
if ( spherePanels%hasChildren(j) ) then
spherePanels%tracer(j,2) = 0.0_kreal
else
spherePanels%tracer(j,2) = (spherePanels%tracer(j,1) - spherePanels%tracer(j,3))/ &
maxval(abs(sphereParticles%tracer(1:sphereParticles%N,1)))
endif
enddo
totalMasstestCaseTracer(timeJ+1) = ( TotalMass(sphere, tracerID) - mass0 ) / mass0
tracerVar(timeJ+1) = ( TracerVariance(sphere, tracerID) - var0 ) / var0
particlesLinf(timeJ+1) = maxval(sphereParticles%tracer(1:sphereParticles%N,2)) / &
maxval(abs(sphereParticles%tracer(1:sphereParticles%N,1)))
panelsLinf(timeJ+1) = maxval( spherePanels%tracer(1:spherePanels%N,2) ) / &
maxval( abs(spherePanels%tracer(1:spherePanels%N,1) ))
sphereLinf(timeJ+1) = max( particlesLinf(timeJ+1), panelsLinf(timeJ+1) )
sphereL2(timeJ+1) = sum( spherePanels%tracer(1:spherePanels%N,2) *&
spherePanels%tracer(1:spherePanels%N,2) * spherePanels%area(1:spherePanels%N) )
sphereL2(timeJ+1) = sphereL2(timeJ+1) / sum( spherePanels%tracer(1:spherePanels%N,1) * &
spherePanels%tracer(1:spherePanels%N,1) * spherePanels%area(1:spherePanels%N) )
sphereL2(timeJ+1) = sqrt(sphereL2(timeJ+1))
sphereL1(timeJ+1) = sum( abs(spherePanels%tracer(1:spherePanels%N,2)) * spherePanels%area(1:spherePanels%N) )
sphereL1(timeJ+1) = sphereL1(timeJ+1) / &
sum( abs(spherePanels%tracer(1:spherePanels%N,1)) * spherePanels%area(1:spherePanels%N) )
phimax(timeJ+1) = ( max( maxval(sphereParticles%tracer(1:sphereParticles%N,1)),&
maxval( spherePanels%tracer(1:spherePanels%N,1)) ) - phimax0) / deltaPhi
phimin(timeJ+1) = ( min( minval(sphereParticles%tracer(1:sphereParticles%N,1)), &
minval( spherePanels%tracer(1:spherePanels%N,1)) ) - phimin0)/ deltaPhi
amrN(timeJ+1) = spherePanels%N_Active
surfArea(timeJ+1) = sum(spherePanels%area)
!
! output data
!
if ( procRank == 0 .AND. mod( timeJ+1, frameOut) == 0 ) then
call LogMessage(exelog, TRACE_LOGGING_LEVEL, 'day = ', t/ONE_DAY)
write(vtkFile, '(A,I0.4,A)') trim(vtkRoot), frameCounter, '.vtk'
write(vtkMeshFile, '(A,A,I0.4,A)') trim(vtkRoot),'_mesh_',frameCounter,'.vtk'
call UpdateFilename(vtkOut, vtkFile)
call UpdateFilename(vtkMeshOut,vtkMeshFile)
call VTKOutput(vtkOut, sphere)
call VTKOutputMidpointRule(vtkMeshOut,sphere)
frameCounter = frameCounter + 1
endif
enddo
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! OUTPUT FINAL DATA
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( procRank == 0 ) then
open( unit = WRITE_UNIT_1, file = datafile, status = 'REPLACE', action = 'WRITE', iostat = readwritestat)
if ( readwritestat /= 0 ) then
call LogMessage(exeLog, ERROR_LOGGING_LEVEL, 'data file ERROR : ', ' failed to open data file.')
else
write(WRITE_UNIT_1,'(A,F24.15,A)') 'passiveLinf = [', particlesLinf(0), ' ;'
do j = 1, timesteps -1
write(WRITE_UNIT_1,'(F24.15,A)') particlesLinf(j), ' ;'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') particlesLinf(timesteps), ' ];'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'activeLinf = [', panelsLinf(0), ' ;'
do j = 1, timesteps -1
write(WRITE_UNIT_1,'(F24.15,A)') panelsLinf(j), ' ;'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') panelsLinf(timesteps), ' ];'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'sphereLinf = [', sphereLinf(0), ' ;'
do j = 1, timesteps -1
write(WRITE_UNIT_1,'(F24.15,A)') sphereLinf(j), ' ;'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') sphereLinf(timesteps), ' ];'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'sphereL2 = [', sphereL2(0), ' ;'
do j = 1, timesteps -1
write(WRITE_UNIT_1,'(F24.15,A)') sphereL2(j), ' ;'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') sphereL2(timesteps), ' ];'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'sphereL1 = [', sphereL1(0), ' ;'
do j = 1, timesteps -1
write(WRITE_UNIT_1,'(F24.15,A)') sphereL1(j), ' ;'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') sphereL1(timesteps), ' ];'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'phi_max = [', phimax(0), ' ;'
do j = 1, timesteps -1
write(WRITE_UNIT_1,'(F24.15,A)') phimax(j), ' ;'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') phimax(timesteps), ' ];'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'phi_min = [', phimin(0), ' ;'
do j = 1, timesteps -1
write(WRITE_UNIT_1,'(F24.15,A)') phimin(j), ' ;'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') phimin(timesteps), ' ];'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'dt_day = ', dt / ONE_DAY, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'tfinal_day = ', tfinal / ONE_DAY, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'mass = [ ', totalMasstestCaseTracer(0), ' ; ...'
do j = 1, timesteps-1
write(WRITE_UNIT_1,'(F24.15,A)') totalMasstestCaseTracer(j), ' ; ...'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') totalMasstestCaseTracer(timesteps), ' ] ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'tracerVar = [ ', tracerVar(0), ' ; ...'
do j = 1, timesteps-1
write(WRITE_UNIT_1,'(F24.15,A)') tracerVar(j), ' ; ...'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') tracerVar(timesteps), ' ] ;'
if ( AMR > 0 ) then
write(WRITE_UNIT_1,'(A,I8,A)') 'amrN = [ ', amrN(0), '; ...'
do j = 1, timesteps - 1
write(WRITE_UNIT_1,'(I8,A)') amrN(j), ' ; ...'
enddo
write(WRITE_UNIT_1,'(I8,A)') amrN(timesteps), '];'
write(WRITE_UNIT_1,*) 'surfArea = [ ', surfArea(0), '; ...'
do j = 1, timesteps - 1
write(WRITE_UNIT_1,*) surfArea(j), ' ; ...'
enddo
write(WRITE_UNIT_1,*) surfArea(timesteps), '];'
endif
endif
close(WRITE_UNIT_1)
write(logstring,'(A, F8.2,A)') 'elapsed time = ', (MPI_WTIME() - wallClock)/60.0, ' minutes.'
call LogMessage(exelog,TRACE_LOGGING_LEVEL,'PROGRAM COMPLETE : ',trim(logstring))
endif
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! FREE MEMORY, CLEAN UP, FINALIZE
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (associated(reference)) then
call Delete(reference)
deallocate(reference)
endif
deallocate(totalMasstestCaseTracer)
deallocate(tracerVar)
deallocate(sphereL1)
deallocate(sphereL2)
deallocate(sphereLinf)
deallocate(particlesLinf)
deallocate(panelsLinf)
deallocate(phiMax)
deallocate(phiMin)
call Delete(timekeeper)
call Delete(remesh)
if ( procrank == 0 ) then
call Delete(vtkOut)
call Delete(vtkMeshOUt)
endif
call Delete(sphere)
call Delete(testCaseTracer)
call Delete(exeLog)
call MPI_FINALIZE(errCode)
contains
function testCaseTracerExact(xyz, t, mvTracer)
real(kreal) :: testCaseTracerExact
real(kreal), intent(in) :: xyz(3), t
type(TracerSetup), intent(in) :: mvTracer
!
real(kreal) :: lat, lon, wr, rho, vortCenterLon, vortCenterLat, vortStartingLon, vortStartingLat
real(kreal) :: lonPrime, latPrime
real(kreal), parameter :: u0 = 2.0_kreal * PI * EARTH_RADIUS / (12.0_kreal * ONE_DAY)
lat = Latitude(xyz)
lon = Longitude(xyz)
vortStartingLon = mvTracer%reals(1)
vortStartingLat = mvTracer%reals(2)
!
! find position of vortex center at time t
!
vortCenterLon = 1.5_kreal*PI + OMEGA * t / 12.0_kreal
vortCenterLat = 0.0_kreal
!
! Find coordinates of xyz in a coordinate system whose north pole is at the vortex location
!
lonPrime = atan4( cos(lat)*sin( lon - vortCenterLon), &
cos(lat)*sin(vortCenterLat)*cos( lon - vortCenterLon) - cos(vortCenterLat)*sin(lat) )
latPrime = asin( sin(lat)*sin(vortCenterLat) + cos(lat)*cos(vortCenterLat)*cos( lon - vortCenterLon ) )
!
! Determine angular tangential velocity induced by vortex about its center
!
rho = 3.0_kreal * cos( latPrime )
wr = u0 * 1.5_kreal * sqrt(3.0_kreal) * tanh(rho) * rho /&
( EARTH_RADIUS * cosh(rho) * cosh(rho) * (rho * rho + ZERO_TOL*ZERO_TOL))
testCaseTracerExact = 1.0_kreal - tanh( 0.2_kreal * rho * sin(lonPrime - wr*t) )
end function
function MovingVortsVorticity(xyz, t)
real(kreal) :: MovingVortsVorticity
real(kreal), intent(in) :: xyz(3), t
!
real(kreal) :: lat, lon, rho, omg, rhoDenom, rho_lam, rho_theta, omg_rho, v_lam, ucostheta_theta
real(kreal) :: cosDenom
real(kreal), parameter :: u0 = 2.0_kreal * PI * EARTH_RADIUS / (12.0_kreal * ONE_DAY)
lat = Latitude(xyz)
lon = Longitude(xyz)
if ( abs(lat) < ZERO_TOL .and. abs(abs(xyz(2))/EARTH_RADIUS - 1.0_kreal ) < ZERO_TOL ) then
lon = lon + 1.0e-7
lat = lat - ZERO_TOL
endif
rho = 3.0_kreal*sqrt( 1.0_kreal - cos(lat)*cos(lat)*&
sin(lon - u0 * t / EARTH_RADIUS) * sin(lon - OMEGA*t/12.0_kreal) )
rhoDenom = rho / (rho*rho + ZERO_TOL*ZERO_TOL)
omg = u0 * 1.5_kreal * sqrt(3.0_kreal) * tanh( rho ) * rhoDenom / cosh(rho) /cosh(rho)
omg_rho = u0 * 1.5_kreal * sqrt(3.0_kreal) * &
( rho - tanh(rho)*(cosh(rho)*cosh(rho) + 2.0_kreal*rho*cosh(rho)*sinh(rho))) * &
rhoDenom*rhoDenom / (cosh(rho)**4)
rho_lam = -3.0_kreal*cos(lat)*cos(lat)*sin(lon-u0 * t / EARTH_RADIUS)*cos(lon-u0 * t / EARTH_RADIUS) * rhoDenom
rho_theta = 3.0_kreal*cos(lat)*sin(lat)*sin(lon-u0 * t / EARTH_RADIUS)*sin(lon-u0 * t / EARTH_RADIUS) * rhoDenom
v_lam = omg_rho * rho_lam * cos(lon-u0 * t / EARTH_RADIUS) - omg * sin(lon-OMEGA*t/12.0_kreal)
ucostheta_theta = -omg * sin(lat)*sin(lat)*sin(lon-u0 * t / EARTH_RADIUS) + &
omg_rho*rho_theta*sin(lat)*sin(lon-u0 * t / EARTH_RADIUS) + omg*cos(lat)*sin(lon-u0 * t / EARTH_RADIUS)
cosDenom = cos(lat)/( cos(lat)*cos(lat) + ZERO_TOL * ZERO_TOL)
MovingVortsVorticity = v_lam * cosDenom / EARTH_RADIUS - ucostheta_theta * cosDenom / EARTH_RADIUS
! if ( abs(abs(xyz(2))/EARTH_RADIUS - 1.0_kreal) < ZERO_TOL ) then
! print *, "*** at lat = ", lat, ", lon = ", lon, " ****"
! print *, "rho = ", rho, ", rhoDenom = ", rhoDenom, ", omg = ", omg, ", omg_rho = "
! print *, "rho_lam = ", rho_lam, ", rho_theta = ", rho_theta, ", v_lam = ", v_lam, ", ucostheta_theta = ", ucostheta_theta
! print *, "cosDenom = ", cosDenom, ", vorticity = ", MovingVortsVorticity
! endif
end function
subroutine StoreVorticityInTracer(aMesh, t, tracerID)
type(SphereMesh), intent(inout) :: aMesh
real(kreal), intent(in) :: t
integer(kint), intent(in) :: tracerID
!
integer(kint) :: j
type(Particles), pointer :: aParticles
type(Panels), pointer :: aPanels
aParticles => aMesh%particles
aPanels => aMesh%panels
do j = 1, aParticles%N
aParticles%tracer(j,tracerID) = MovingVortsVorticity(aParticles%x(:,j), t)
enddo
do j = 1, aPanels%N
if ( aPanels%hasCHildren(j) ) then
aPanels%tracer(j,tracerID) = 0.0_kreal
else
aPanels%tracer(j,tracerID) = MovingVortsVorticity(aPanels%x(:,j), t)
endif
enddo
end subroutine
subroutine SetTestCaseVorticityOnMesh(aMesh, aVorticity, time)
type(SphereMesh), intent(inout) :: aMesh
type(BVESetup), intent(in) :: aVorticity
real(kreal), intent(in) :: time
!
integer(kint) :: j
type(Particles), pointer :: aParticles
type(Panels), pointer :: aPanels
aParticles => aMesh%particles
aPanels => aMesh%panels
do j = 1, aParticles%N
aParticles%absVort(j) = 0.0_kreal
aParticles%relvort(j) = MovingVortsVorticity(aParticles%x(:,j), time)
enddo
do j = 1, aPanels%N
if ( aPanels%hasCHildren(j) ) then
aPanels%relvort(j) = 0.0_kreal
aPanels%absVort(j) = 0.0_kreal
else
aPanels%relvort(j) = MovingVortsVorticity(aPanels%x(:,j), time)
aPanels%absVort(j) = 0.0_kreal
endif
enddo
end subroutine
subroutine ConvertFromRelativeTolerances(aMesh, maxCircTol, &
vortVarTol, tracerMassTol, tracerVarTol, tracerID, lagVarTol)
type(SphereMesh), intent(in) :: amesh
real(kreal), intent(inout) :: maxCircTol, vortVarTol, tracerMassTol, tracerVarTol, lagVarTol
integer(kint), intent(in) :: tracerID
maxCircTol = maxCircTol * MaximumCirculation(aMesh)
vortVarTol = vortVarTol * MaximumVorticityVariation(aMesh)
tracerMassTol = tracerMassTol * MaximumTracerMass(aMesh, tracerID)
tracerVarTol = tracerVarTol * MaximumTracerVariation(aMesh, tracerID)
lagVarTol = lagVarTol * MaximumLagrangianParameterVariation(aMesh)
end subroutine
subroutine ReadNamelistFile(rank)
integer(kint), intent(in) :: rank
integer(kint), parameter :: BCAST_INT_SIZE = 6, BCAST_REAL_SIZE= 7
integer(kint) :: broadcastIntegers(BCAST_INT_SIZE)
real(kreal) :: broadcastReals(BCAST_REAL_SIZE)
if ( rank == 0 ) then
open(unit=READ_UNIT, file=namelistfile, status='OLD', action='READ', iostat=readWriteStat)
if ( readWriteStat /= 0 ) stop 'cannot read namelist file.'
read(READ_UNIT, nml=meshDefine)
rewind(READ_UNIT)
read(READ_UNIT, nml=timestepping)
rewind(READ_UNIT)
read(READ_UNIT, nml=fileIO)
rewind(READ_UNIT)
close(READ_UNIT)
broadcastIntegers(1) = panelKind
broadcastIntegers(2) = initNest
broadcastIntegers(3) = AMR
broadcastIntegers(4) = amrLimit
broadcastIntegers(5) = remeshInterval
broadcastIntegers(6) = resetAlphaInterval
broadcastReals(1) = tracerMassTol
broadcastReals(2) = tracerVarTol
broadcastReals(3) = dt
broadcastReals(4) = tfinal
broadcastReals(5) = lagVarTol
broadcastReals(6) = maxCircTol
broadcastReals(7) = vortVarTol
endif
call MPI_BCAST(broadcastIntegers, BCAST_INT_SIZE, MPI_INTEGER, 0, MPI_COMM_WORLD, errCode)
panelKind = broadcastIntegers(1)
initNest = broadcastIntegers(2)
AMR = broadcastIntegers(3)
amrLimit = broadcastIntegers(4)
remeshInterval = broadcastIntegers(5)
resetAlphaInterval = broadcastIntegers(6)
call MPI_BCAST(broadcastReals, BCAST_REAL_SIZE, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, errCode)
tracerMassTol = broadcastReals(1)
tracerVarTol = broadcastReals(2)
dt = broadcastReals(3) * ONE_DAY ! convert time to seconds
tfinal = broadcastReals(4) * ONE_DAY ! convert time to seconds
lagVarTol = broadcastReals(5)
maxCircTol = broadcastReals(6)
vortVarTol = broadcastReals(7)
end subroutine
subroutine InitLogger(alog,rank)
type(Logger), intent(out) :: aLog
integer(kint), intent(in) :: rank
if ( rank == 0 ) then
call New(aLog,DEBUG_LOGGING_LEVEL)
else
call New(aLog,WARNING_LOGGING_LEVEL)
endif
write(logKey,'(A,I0.2,A)') 'EXE_LOG',rank,' : '
end subroutine
end program
| mit |
pbosler/LPPM | stripack.f | 4 | 208886 | SUBROUTINE ADDNOD (NST,K,X,Y,Z, LIST,LPTR,LEND,
. LNEW, IER)
INTEGER NST, K, LIST(*), LPTR(*), LEND(K), LNEW, IER
REAL(kind=8) X(K), Y(K), Z(K)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/08/99
C
C This subroutine adds node K to a triangulation of the
C convex hull of nodes 1,...,K-1, producing a triangulation
C of the convex hull of nodes 1,...,K.
C
C The algorithm consists of the following steps: node K
C is located relative to the triangulation (TRFIND), its
C index is added to the data structure (INTADD or BDYADD),
C and a sequence of swaps (SWPTST and SWAP) are applied to
C the arcs opposite K so that all arcs incident on node K
C and opposite node K are locally optimal (satisfy the cir-
C cumcircle test). Thus, if a Delaunay triangulation is
C input, a Delaunay triangulation will result.
C
C
C On input:
C
C NST = Index of a node at which TRFIND begins its
C search. Search time depends on the proximity
C of this node to K. If NST < 1, the search is
C begun at node K-1.
C
C K = Nodal index (index for X, Y, Z, and LEND) of the
C new node to be added. K .GE. 4.
C
C X,Y,Z = Arrays of length .GE. K containing Car-
C tesian coordinates of the nodes.
C (X(I),Y(I),Z(I)) defines node I for
C I = 1,...,K.
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR,LEND,LNEW = Data structure associated with
C the triangulation of nodes 1
C to K-1. The array lengths are
C assumed to be large enough to
C add node K. Refer to Subrou-
C tine TRMESH.
C
C On output:
C
C LIST,LPTR,LEND,LNEW = Data structure updated with
C the addition of node K as the
C last entry unless IER .NE. 0
C and IER .NE. -3, in which case
C the arrays are not altered.
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = -1 if K is outside its valid range
C on input.
C IER = -2 if all nodes (including K) are col-
C linear (lie on a common geodesic).
C IER = L if nodes L and K coincide for some
C L < K.
C
C Modules required by ADDNOD: BDYADD, COVSPH, INSERT,
C INTADD, JRAND, LSTPTR,
C STORE, SWAP, SWPTST,
C TRFIND
C
C Intrinsic function called by ADDNOD: ABS
C
C***********************************************************
C
INTEGER LSTPTR
INTEGER I1, I2, I3, IO1, IO2, IN1, IST, KK, KM1, L,
. LP, LPF, LPO1, LPO1S
LOGICAL SWPTST
REAL(kind=8) B1, B2, B3, P(3)
C
C Local parameters:
C
C B1,B2,B3 = Unnormalized barycentric coordinates returned
C by TRFIND.
C I1,I2,I3 = Vertex indexes of a triangle containing K
C IN1 = Vertex opposite K: first neighbor of IO2
C that precedes IO1. IN1,IO1,IO2 are in
C counterclockwise order.
C IO1,IO2 = Adjacent neighbors of K defining an arc to
C be tested for a swap
C IST = Index of node at which TRFIND begins its search
C KK = Local copy of K
C KM1 = K-1
C L = Vertex index (I1, I2, or I3) returned in IER
C if node K coincides with a vertex
C LP = LIST pointer
C LPF = LIST pointer to the first neighbor of K
C LPO1 = LIST pointer to IO1
C LPO1S = Saved value of LPO1
C P = Cartesian coordinates of node K
C
KK = K
IF (KK .LT. 4) GO TO 3
C
C Initialization:
C
KM1 = KK - 1
IST = NST
IF (IST .LT. 1) IST = KM1
P(1) = X(KK)
P(2) = Y(KK)
P(3) = Z(KK)
C
C Find a triangle (I1,I2,I3) containing K or the rightmost
C (I1) and leftmost (I2) visible boundary nodes as viewed
C from node K.
C
CALL TRFIND (IST,P,KM1,X,Y,Z,LIST,LPTR,LEND, B1,B2,B3,
. I1,I2,I3)
C
C Test for collinear or duplicate nodes.
C
IF (I1 .EQ. 0) GO TO 4
IF (I3 .NE. 0) THEN
L = I1
IF (P(1) .EQ. X(L) .AND. P(2) .EQ. Y(L) .AND.
. P(3) .EQ. Z(L)) THEN ! GO TO 5
PRINT '(A,I6,A,I6,A)', 'NODES ',KK,' AND ',L,'ARE DUPLICATES.'
GO TO 5
ENDIF
L = I2
IF (P(1) .EQ. X(L) .AND. P(2) .EQ. Y(L) .AND.
. P(3) .EQ. Z(L)) THEN !GO TO 5
PRINT '(A,I6,A,I6,A)', 'NODES ',KK,' AND ',L,'ARE DUPLICATES.'
GO TO 5
ENDIF
L = I3
IF (P(1) .EQ. X(L) .AND. P(2) .EQ. Y(L) .AND.
. P(3) .EQ. Z(L)) THEN !GO TO 5
PRINT '(A,I6,A,I6,A)', 'NODES ',KK,' AND ',L,'ARE DUPLICATES.'
GO TO 5
ENDIF
CALL INTADD (KK,I1,I2,I3, LIST,LPTR,LEND,LNEW )
ELSE
IF (I1 .NE. I2) THEN
CALL BDYADD (KK,I1,I2, LIST,LPTR,LEND,LNEW )
ELSE
CALL COVSPH (KK,I1, LIST,LPTR,LEND,LNEW )
ENDIF
ENDIF
IER = 0
C
C Initialize variables for optimization of the
C triangulation.
C
LP = LEND(KK)
LPF = LPTR(LP)
IO2 = LIST(LPF)
LPO1 = LPTR(LPF)
IO1 = ABS(LIST(LPO1))
C
C Begin loop: find the node opposite K.
C
1 LP = LSTPTR(LEND(IO1),IO2,LIST,LPTR)
IF (LIST(LP) .LT. 0) GO TO 2
LP = LPTR(LP)
IN1 = ABS(LIST(LP))
C
C Swap test: if a swap occurs, two new arcs are
C opposite K and must be tested.
C
LPO1S = LPO1
IF ( .NOT. SWPTST(IN1,KK,IO1,IO2,X,Y,Z) ) GO TO 2
CALL SWAP (IN1,KK,IO1,IO2, LIST,LPTR,LEND, LPO1)
IF (LPO1 .EQ. 0) THEN
C
C A swap is not possible because KK and IN1 are already
C adjacent. This error in SWPTST only occurs in the
C neutral case and when there are nearly duplicate
C nodes.
C
LPO1 = LPO1S
GO TO 2
ENDIF
IO1 = IN1
GO TO 1
C
C No swap occurred. Test for termination and reset
C IO2 and IO1.
C
2 IF (LPO1 .EQ. LPF .OR. LIST(LPO1) .LT. 0) RETURN
IO2 = IO1
LPO1 = LPTR(LPO1)
IO1 = ABS(LIST(LPO1))
GO TO 1
C
C KK < 4.
C
3 IER = -1
RETURN
C
C All nodes are collinear.
C
4 IER = -2
RETURN
C
C Nodes L and K coincide.
C
5 IER = L
RETURN
END
REAL(kind=8) FUNCTION AREAS (V1,V2,V3)
REAL(kind=8) V1(3), V2(3), V3(3)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 09/18/90
C
C This function returns the area of a spherical triangle
C on the unit sphere.
C
C
C On input:
C
C V1,V2,V3 = Arrays of length 3 containing the Carte-
C sian coordinates of unit vectors (the
C three triangle vertices in any order).
C These vectors, if nonzero, are implicitly
C scaled to have length 1.
C
C Input parameters are not altered by this function.
C
C On output:
C
C AREAS = Area of the spherical triangle defined by
C V1, V2, and V3 in the range 0 to 2*PI (the
C area of a hemisphere). AREAS = 0 (or 2*PI)
C if and only if V1, V2, and V3 lie in (or
C close to) a plane containing the origin.
C
C Modules required by AREAS: None
C
C Intrinsic functions called by AREAS: ACOS, DBLE, REAL,
C SQRT
C
C***********************************************************
C
DOUBLE PRECISION A1, A2, A3, CA1, CA2, CA3, DV1(3),
. DV2(3), DV3(3), S12, S23, S31,
. U12(3), U23(3), U31(3)
INTEGER I
C
C Local parameters:
C
C A1,A2,A3 = Interior angles of the spherical triangle
C CA1,CA2,CA3 = cos(A1), cos(A2), and cos(A3), respectively
C DV1,DV2,DV3 = Double Precision copies of V1, V2, and V3
C I = DO-loop index and index for Uij
C S12,S23,S31 = Sum of squared components of U12, U23, U31
C U12,U23,U31 = Unit normal vectors to the planes defined by
C pairs of triangle vertices
C
DO 1 I = 1,3
DV1(I) = DBLE(V1(I))
DV2(I) = DBLE(V2(I))
DV3(I) = DBLE(V3(I))
1 CONTINUE
C
C Compute cross products Uij = Vi X Vj.
C
U12(1) = DV1(2)*DV2(3) - DV1(3)*DV2(2)
U12(2) = DV1(3)*DV2(1) - DV1(1)*DV2(3)
U12(3) = DV1(1)*DV2(2) - DV1(2)*DV2(1)
C
U23(1) = DV2(2)*DV3(3) - DV2(3)*DV3(2)
U23(2) = DV2(3)*DV3(1) - DV2(1)*DV3(3)
U23(3) = DV2(1)*DV3(2) - DV2(2)*DV3(1)
C
U31(1) = DV3(2)*DV1(3) - DV3(3)*DV1(2)
U31(2) = DV3(3)*DV1(1) - DV3(1)*DV1(3)
U31(3) = DV3(1)*DV1(2) - DV3(2)*DV1(1)
C
C Normalize Uij to unit vectors.
C
S12 = 0.D0
S23 = 0.D0
S31 = 0.D0
DO 2 I = 1,3
S12 = S12 + U12(I)*U12(I)
S23 = S23 + U23(I)*U23(I)
S31 = S31 + U31(I)*U31(I)
2 CONTINUE
C
C Test for a degenerate triangle associated with collinear
C vertices.
C
IF (S12 .EQ. 0.D0 .OR. S23 .EQ. 0.D0 .OR.
. S31 .EQ. 0.D0) THEN
AREAS = 0.
RETURN
ENDIF
S12 = SQRT(S12)
S23 = SQRT(S23)
S31 = SQRT(S31)
DO 3 I = 1,3
U12(I) = U12(I)/S12
U23(I) = U23(I)/S23
U31(I) = U31(I)/S31
3 CONTINUE
C
C Compute interior angles Ai as the dihedral angles between
C planes:
C CA1 = cos(A1) = -<U12,U31>
C CA2 = cos(A2) = -<U23,U12>
C CA3 = cos(A3) = -<U31,U23>
C
CA1 = -U12(1)*U31(1)-U12(2)*U31(2)-U12(3)*U31(3)
CA2 = -U23(1)*U12(1)-U23(2)*U12(2)-U23(3)*U12(3)
CA3 = -U31(1)*U23(1)-U31(2)*U23(2)-U31(3)*U23(3)
IF (CA1 .LT. -1.D0) CA1 = -1.D0
IF (CA1 .GT. 1.D0) CA1 = 1.D0
IF (CA2 .LT. -1.D0) CA2 = -1.D0
IF (CA2 .GT. 1.D0) CA2 = 1.D0
IF (CA3 .LT. -1.D0) CA3 = -1.D0
IF (CA3 .GT. 1.D0) CA3 = 1.D0
A1 = ACOS(CA1)
A2 = ACOS(CA2)
A3 = ACOS(CA3)
C
C Compute AREAS = A1 + A2 + A3 - PI.
C
AREAS = REAL(A1 + A2 + A3 - ACOS(-1.D0),8)
IF (AREAS .LT. 0.) AREAS = 0.
RETURN
END
SUBROUTINE BDYADD (KK,I1,I2, LIST,LPTR,LEND,LNEW )
INTEGER KK, I1, I2, LIST(*), LPTR(*), LEND(*), LNEW
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/11/96
C
C This subroutine adds a boundary node to a triangulation
C of a set of KK-1 points on the unit sphere. The data
C structure is updated with the insertion of node KK, but no
C optimization is performed.
C
C This routine is identical to the similarly named routine
C in TRIPACK.
C
C
C On input:
C
C KK = Index of a node to be connected to the sequence
C of all visible boundary nodes. KK .GE. 1 and
C KK must not be equal to I1 or I2.
C
C I1 = First (rightmost as viewed from KK) boundary
C node in the triangulation that is visible from
C node KK (the line segment KK-I1 intersects no
C arcs.
C
C I2 = Last (leftmost) boundary node that is visible
C from node KK. I1 and I2 may be determined by
C Subroutine TRFIND.
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR,LEND,LNEW = Triangulation data structure
C created by Subroutine TRMESH.
C Nodes I1 and I2 must be in-
C cluded in the triangulation.
C
C On output:
C
C LIST,LPTR,LEND,LNEW = Data structure updated with
C the addition of node KK. Node
C KK is connected to I1, I2, and
C all boundary nodes in between.
C
C Module required by BDYADD: INSERT
C
C***********************************************************
C
INTEGER K, LP, LSAV, N1, N2, NEXT, NSAV
C
C Local parameters:
C
C K = Local copy of KK
C LP = LIST pointer
C LSAV = LIST pointer
C N1,N2 = Local copies of I1 and I2, respectively
C NEXT = Boundary node visible from K
C NSAV = Boundary node visible from K
C
K = KK
N1 = I1
N2 = I2
C
C Add K as the last neighbor of N1.
C
LP = LEND(N1)
LSAV = LPTR(LP)
LPTR(LP) = LNEW
LIST(LNEW) = -K
LPTR(LNEW) = LSAV
LEND(N1) = LNEW
LNEW = LNEW + 1
NEXT = -LIST(LP)
LIST(LP) = NEXT
NSAV = NEXT
C
C Loop on the remaining boundary nodes between N1 and N2,
C adding K as the first neighbor.
C
1 LP = LEND(NEXT)
CALL INSERT (K,LP, LIST,LPTR,LNEW )
IF (NEXT .EQ. N2) GO TO 2
NEXT = -LIST(LP)
LIST(LP) = NEXT
GO TO 1
C
C Add the boundary nodes between N1 and N2 as neighbors
C of node K.
C
2 LSAV = LNEW
LIST(LNEW) = N1
LPTR(LNEW) = LNEW + 1
LNEW = LNEW + 1
NEXT = NSAV
C
3 IF (NEXT .EQ. N2) GO TO 4
LIST(LNEW) = NEXT
LPTR(LNEW) = LNEW + 1
LNEW = LNEW + 1
LP = LEND(NEXT)
NEXT = LIST(LP)
GO TO 3
C
4 LIST(LNEW) = -N2
LPTR(LNEW) = LSAV
LEND(K) = LNEW
LNEW = LNEW + 1
RETURN
END
SUBROUTINE BNODES (N,LIST,LPTR,LEND, NODES,NB,NA,NT)
INTEGER N, LIST(*), LPTR(*), LEND(N), NODES(*), NB,
. NA, NT
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 06/26/96
C
C Given a triangulation of N nodes on the unit sphere
C created by Subroutine TRMESH, this subroutine returns an
C array containing the indexes (if any) of the counterclock-
C wise-ordered sequence of boundary nodes -- the nodes on
C the boundary of the convex hull of the set of nodes. (The
C boundary is empty if the nodes do not lie in a single
C hemisphere.) The numbers of boundary nodes, arcs, and
C triangles are also returned.
C
C
C On input:
C
C N = Number of nodes in the triangulation. N .GE. 3.
C
C LIST,LPTR,LEND = Data structure defining the trian-
C gulation. Refer to Subroutine
C TRMESH.
C
C The above parameters are not altered by this routine.
C
C NODES = Integer array of length at least NB
C (NB .LE. N).
C
C On output:
C
C NODES = Ordered sequence of boundary node indexes
C in the range 1 to N (in the first NB loca-
C tions).
C
C NB = Number of boundary nodes.
C
C NA,NT = Number of arcs and triangles, respectively,
C in the triangulation.
C
C Modules required by BNODES: None
C
C***********************************************************
C
INTEGER K, LP, N0, NN, NST
C
C Local parameters:
C
C K = NODES index
C LP = LIST pointer
C N0 = Boundary node to be added to NODES
C NN = Local copy of N
C NST = First element of nodes (arbitrarily chosen to be
C the one with smallest index)
C
NN = N
C
C Search for a boundary node.
C
DO 1 NST = 1,NN
LP = LEND(NST)
IF (LIST(LP) .LT. 0) GO TO 2
1 CONTINUE
C
C The triangulation contains no boundary nodes.
C
NB = 0
NA = 3*(NN-2)
NT = 2*(NN-2)
RETURN
C
C NST is the first boundary node encountered. Initialize
C for traversal of the boundary.
C
2 NODES(1) = NST
K = 1
N0 = NST
C
C Traverse the boundary in counterclockwise order.
C
3 LP = LEND(N0)
LP = LPTR(LP)
N0 = LIST(LP)
IF (N0 .EQ. NST) GO TO 4
K = K + 1
NODES(K) = N0
GO TO 3
C
C Store the counts.
C
4 NB = K
NT = 2*N - NB - 2
NA = NT + N - 1
RETURN
END
SUBROUTINE CIRCUM (V1,V2,V3, C,IER)
INTEGER IER
REAL(kind=8) V1(3), V2(3), V3(3), C(3)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 06/29/95
C
C This subroutine returns the circumcenter of a spherical
C triangle on the unit sphere: the point on the sphere sur-
C face that is equally distant from the three triangle
C vertices and lies in the same hemisphere, where distance
C is taken to be arc-length on the sphere surface.
C
C
C On input:
C
C V1,V2,V3 = Arrays of length 3 containing the Carte-
C sian coordinates of the three triangle
C vertices (unit vectors) in CCW order.
C
C The above parameters are not altered by this routine.
C
C C = Array of length 3.
C
C On output:
C
C C = Cartesian coordinates of the circumcenter unless
C IER > 0, in which case C is not defined. C =
C (V2-V1) X (V3-V1) normalized to a unit vector.
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if V1, V2, and V3 lie on a common
C line: (V2-V1) X (V3-V1) = 0.
C (The vertices are not tested for validity.)
C
C Modules required by CIRCUM: None
C
C Intrinsic function called by CIRCUM: SQRT
C
C***********************************************************
C
INTEGER I
REAL(kind=8) CNORM, CU(3), E1(3), E2(3)
C
C Local parameters:
C
C CNORM = Norm of CU: used to compute C
C CU = Scalar multiple of C: E1 X E2
C E1,E2 = Edges of the underlying planar triangle:
C V2-V1 and V3-V1, respectively
C I = DO-loop index
C
DO 1 I = 1,3
E1(I) = V2(I) - V1(I)
E2(I) = V3(I) - V1(I)
1 CONTINUE
C
C Compute CU = E1 X E2 and CNORM**2.
C
CU(1) = E1(2)*E2(3) - E1(3)*E2(2)
CU(2) = E1(3)*E2(1) - E1(1)*E2(3)
CU(3) = E1(1)*E2(2) - E1(2)*E2(1)
CNORM = CU(1)*CU(1) + CU(2)*CU(2) + CU(3)*CU(3)
C
C The vertices lie on a common line if and only if CU is
C the zero vector.
C
IF (CNORM .NE. 0.) THEN
C
C No error: compute C.
C
CNORM = SQRT(CNORM)
DO 2 I = 1,3
C(I) = CU(I)/CNORM
2 CONTINUE
IER = 0
ELSE
C
C CU = 0.
C
IER = 1
ENDIF
RETURN
END
SUBROUTINE COVSPH (KK,N0, LIST,LPTR,LEND,LNEW )
INTEGER KK, N0, LIST(*), LPTR(*), LEND(*), LNEW
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/17/96
C
C This subroutine connects an exterior node KK to all
C boundary nodes of a triangulation of KK-1 points on the
C unit sphere, producing a triangulation that covers the
C sphere. The data structure is updated with the addition
C of node KK, but no optimization is performed. All boun-
C dary nodes must be visible from node KK.
C
C
C On input:
C
C KK = Index of the node to be connected to the set of
C all boundary nodes. KK .GE. 4.
C
C N0 = Index of a boundary node (in the range 1 to
C KK-1). N0 may be determined by Subroutine
C TRFIND.
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR,LEND,LNEW = Triangulation data structure
C created by Subroutine TRMESH.
C Node N0 must be included in
C the triangulation.
C
C On output:
C
C LIST,LPTR,LEND,LNEW = Data structure updated with
C the addition of node KK as the
C last entry. The updated
C triangulation contains no
C boundary nodes.
C
C Module required by COVSPH: INSERT
C
C***********************************************************
C
INTEGER K, LP, LSAV, NEXT, NST
C
C Local parameters:
C
C K = Local copy of KK
C LP = LIST pointer
C LSAV = LIST pointer
C NEXT = Boundary node visible from K
C NST = Local copy of N0
C
K = KK
NST = N0
C
C Traverse the boundary in clockwise order, inserting K as
C the first neighbor of each boundary node, and converting
C the boundary node to an interior node.
C
NEXT = NST
1 LP = LEND(NEXT)
CALL INSERT (K,LP, LIST,LPTR,LNEW )
NEXT = -LIST(LP)
LIST(LP) = NEXT
IF (NEXT .NE. NST) GO TO 1
C
C Traverse the boundary again, adding each node to K's
C adjacency list.
C
LSAV = LNEW
2 LP = LEND(NEXT)
LIST(LNEW) = NEXT
LPTR(LNEW) = LNEW + 1
LNEW = LNEW + 1
NEXT = LIST(LP)
IF (NEXT .NE. NST) GO TO 2
C
LPTR(LNEW-1) = LSAV
LEND(K) = LNEW - 1
RETURN
END
SUBROUTINE CRLIST (N,NCOL,X,Y,Z,LIST,LEND, LPTR,LNEW,
. LTRI, LISTC,NB,XC,YC,ZC,RC,IER)
INTEGER N, NCOL, LIST(*), LEND(N), LPTR(*), LNEW,
. LTRI(6,NCOL), LISTC(*), NB, IER
REAL(kind=8) X(N), Y(N), Z(N), XC(*), YC(*), ZC(*), RC(*)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/05/98
C
C Given a Delaunay triangulation of nodes on the surface
C of the unit sphere, this subroutine returns the set of
C triangle circumcenters corresponding to Voronoi vertices,
C along with the circumradii and a list of triangle indexes
C LISTC stored in one-to-one correspondence with LIST/LPTR
C entries.
C
C A triangle circumcenter is the point (unit vector) lying
C at the same angular distance from the three vertices and
C contained in the same hemisphere as the vertices. (Note
C that the negative of a circumcenter is also equidistant
C from the vertices.) If the triangulation covers the sur-
C face, the Voronoi vertices are the circumcenters of the
C triangles in the Delaunay triangulation. LPTR, LEND, and
C LNEW are not altered in this case.
C
C On the other hand, if the nodes are contained in a sin-
C gle hemisphere, the triangulation is implicitly extended
C to the entire surface by adding pseudo-arcs (of length
C greater than 180 degrees) between boundary nodes forming
C pseudo-triangles whose 'circumcenters' are included in the
C list. This extension to the triangulation actually con-
C sists of a triangulation of the set of boundary nodes in
C which the swap test is reversed (a non-empty circumcircle
C test). The negative circumcenters are stored as the
C pseudo-triangle 'circumcenters'. LISTC, LPTR, LEND, and
C LNEW contain a data structure corresponding to the ex-
C tended triangulation (Voronoi diagram), but LIST is not
C altered in this case. Thus, if it is necessary to retain
C the original (unextended) triangulation data structure,
C copies of LPTR and LNEW must be saved before calling this
C routine.
C
C
C On input:
C
C N = Number of nodes in the triangulation. N .GE. 3.
C Note that, if N = 3, there are only two Voronoi
C vertices separated by 180 degrees, and the
C Voronoi regions are not well defined.
C
C NCOL = Number of columns reserved for LTRI. This
C must be at least NB-2, where NB is the number
C of boundary nodes.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes (unit vectors).
C
C LIST = Integer array containing the set of adjacency
C lists. Refer to Subroutine TRMESH.
C
C LEND = Set of pointers to ends of adjacency lists.
C Refer to Subroutine TRMESH.
C
C The above parameters are not altered by this routine.
C
C LPTR = Array of pointers associated with LIST. Re-
C fer to Subroutine TRMESH.
C
C LNEW = Pointer to the first empty location in LIST
C and LPTR (list length plus one).
C
C LTRI = Integer work space array dimensioned 6 by
C NCOL, or unused dummy parameter if NB = 0.
C
C LISTC = Integer array of length at least 3*NT, where
C NT = 2*N-4 is the number of triangles in the
C triangulation (after extending it to cover
C the entire surface if necessary).
C
C XC,YC,ZC,RC = Arrays of length NT = 2*N-4.
C
C On output:
C
C LPTR = Array of pointers associated with LISTC:
C updated for the addition of pseudo-triangles
C if the original triangulation contains
C boundary nodes (NB > 0).
C
C LNEW = Pointer to the first empty location in LISTC
C and LPTR (list length plus one). LNEW is not
C altered if NB = 0.
C
C LTRI = Triangle list whose first NB-2 columns con-
C tain the indexes of a clockwise-ordered
C sequence of vertices (first three rows)
C followed by the LTRI column indexes of the
C triangles opposite the vertices (or 0
C denoting the exterior region) in the last
C three rows. This array is not generally of
C any use.
C
C LISTC = Array containing triangle indexes (indexes
C to XC, YC, ZC, and RC) stored in 1-1 corres-
C pondence with LIST/LPTR entries (or entries
C that would be stored in LIST for the
C extended triangulation): the index of tri-
C angle (N1,N2,N3) is stored in LISTC(K),
C LISTC(L), and LISTC(M), where LIST(K),
C LIST(L), and LIST(M) are the indexes of N2
C as a neighbor of N1, N3 as a neighbor of N2,
C and N1 as a neighbor of N3. The Voronoi
C region associated with a node is defined by
C the CCW-ordered sequence of circumcenters in
C one-to-one correspondence with its adjacency
C list (in the extended triangulation).
C
C NB = Number of boundary nodes unless IER = 1.
C
C XC,YC,ZC = Arrays containing the Cartesian coordi-
C nates of the triangle circumcenters
C (Voronoi vertices). XC(I)**2 + YC(I)**2
C + ZC(I)**2 = 1. The first NB-2 entries
C correspond to pseudo-triangles if NB > 0.
C
C RC = Array containing circumradii (the arc lengths
C or angles between the circumcenters and associ-
C ated triangle vertices) in 1-1 correspondence
C with circumcenters.
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if N < 3.
C IER = 2 if NCOL < NB-2.
C IER = 3 if a triangle is degenerate (has ver-
C tices lying on a common geodesic).
C
C Modules required by CRLIST: CIRCUM, LSTPTR, SWPTST
C
C Intrinsic functions called by CRLIST: ABS, ACOS
C
C***********************************************************
C
INTEGER LSTPTR
INTEGER I1, I2, I3, I4, IERR, KT, KT1, KT2, KT11,
. KT12, KT21, KT22, LP, LPL, LPN, N0, N1, N2,
. N3, N4, NM2, NN, NT
LOGICAL SWPTST
LOGICAL SWP
REAL(kind=8) C(3), T, V1(3), V2(3), V3(3)
C
C Local parameters:
C
C C = Circumcenter returned by Subroutine CIRCUM
C I1,I2,I3 = Permutation of (1,2,3): LTRI row indexes
C I4 = LTRI row index in the range 1 to 3
C IERR = Error flag for calls to CIRCUM
C KT = Triangle index
C KT1,KT2 = Indexes of a pair of adjacent pseudo-triangles
C KT11,KT12 = Indexes of the pseudo-triangles opposite N1
C and N2 as vertices of KT1
C KT21,KT22 = Indexes of the pseudo-triangles opposite N1
C and N2 as vertices of KT2
C LP,LPN = LIST pointers
C LPL = LIST pointer of the last neighbor of N1
C N0 = Index of the first boundary node (initial
C value of N1) in the loop on boundary nodes
C used to store the pseudo-triangle indexes
C in LISTC
C N1,N2,N3 = Nodal indexes defining a triangle (CCW order)
C or pseudo-triangle (clockwise order)
C N4 = Index of the node opposite N2 -> N1
C NM2 = N-2
C NN = Local copy of N
C NT = Number of pseudo-triangles: NB-2
C SWP = Logical variable set to TRUE in each optimiza-
C tion loop (loop on pseudo-arcs) iff a swap
C is performed
C V1,V2,V3 = Vertices of triangle KT = (N1,N2,N3) sent to
C Subroutine CIRCUM
C
NN = N
NB = 0
NT = 0
IF (NN .LT. 3) GO TO 21
C
C Search for a boundary node N1.
C
DO 1 N1 = 1,NN
LP = LEND(N1)
IF (LIST(LP) .LT. 0) GO TO 2
1 CONTINUE
C
C The triangulation already covers the sphere.
C
GO TO 9
C
C There are NB .GE. 3 boundary nodes. Add NB-2 pseudo-
C triangles (N1,N2,N3) by connecting N3 to the NB-3
C boundary nodes to which it is not already adjacent.
C
C Set N3 and N2 to the first and last neighbors,
C respectively, of N1.
C
2 N2 = -LIST(LP)
LP = LPTR(LP)
N3 = LIST(LP)
C
C Loop on boundary arcs N1 -> N2 in clockwise order,
C storing triangles (N1,N2,N3) in column NT of LTRI
C along with the indexes of the triangles opposite
C the vertices.
C
3 NT = NT + 1
IF (NT .LE. NCOL) THEN
LTRI(1,NT) = N1
LTRI(2,NT) = N2
LTRI(3,NT) = N3
LTRI(4,NT) = NT + 1
LTRI(5,NT) = NT - 1
LTRI(6,NT) = 0
ENDIF
N1 = N2
LP = LEND(N1)
N2 = -LIST(LP)
IF (N2 .NE. N3) GO TO 3
C
NB = NT + 2
IF (NCOL .LT. NT) GO TO 22
LTRI(4,NT) = 0
IF (NT .EQ. 1) GO TO 7
C
C Optimize the exterior triangulation (set of pseudo-
C triangles) by applying swaps to the pseudo-arcs N1-N2
C (pairs of adjacent pseudo-triangles KT1 and KT2 > KT1).
C The loop on pseudo-arcs is repeated until no swaps are
C performed.
C
4 SWP = .FALSE.
DO 6 KT1 = 1,NT-1
DO 5 I3 = 1,3
KT2 = LTRI(I3+3,KT1)
IF (KT2 .LE. KT1) GO TO 5
C
C The LTRI row indexes (I1,I2,I3) of triangle KT1 =
C (N1,N2,N3) are a cyclical permutation of (1,2,3).
C
IF (I3 .EQ. 1) THEN
I1 = 2
I2 = 3
ELSEIF (I3 .EQ. 2) THEN
I1 = 3
I2 = 1
ELSE
I1 = 1
I2 = 2
ENDIF
N1 = LTRI(I1,KT1)
N2 = LTRI(I2,KT1)
N3 = LTRI(I3,KT1)
C
C KT2 = (N2,N1,N4) for N4 = LTRI(I,KT2), where
C LTRI(I+3,KT2) = KT1.
C
IF (LTRI(4,KT2) .EQ. KT1) THEN
I4 = 1
ELSEIF (LTRI(5,KT2) .EQ. KT1) THEN
I4 = 2
ELSE
I4 = 3
ENDIF
N4 = LTRI(I4,KT2)
C
C The empty circumcircle test is reversed for the pseudo-
C triangles. The reversal is implicit in the clockwise
C ordering of the vertices.
C
IF ( .NOT. SWPTST(N1,N2,N3,N4,X,Y,Z) ) GO TO 5
C
C Swap arc N1-N2 for N3-N4. KTij is the triangle opposite
C Nj as a vertex of KTi.
C
SWP = .TRUE.
KT11 = LTRI(I1+3,KT1)
KT12 = LTRI(I2+3,KT1)
IF (I4 .EQ. 1) THEN
I2 = 2
I1 = 3
ELSEIF (I4 .EQ. 2) THEN
I2 = 3
I1 = 1
ELSE
I2 = 1
I1 = 2
ENDIF
KT21 = LTRI(I1+3,KT2)
KT22 = LTRI(I2+3,KT2)
LTRI(1,KT1) = N4
LTRI(2,KT1) = N3
LTRI(3,KT1) = N1
LTRI(4,KT1) = KT12
LTRI(5,KT1) = KT22
LTRI(6,KT1) = KT2
LTRI(1,KT2) = N3
LTRI(2,KT2) = N4
LTRI(3,KT2) = N2
LTRI(4,KT2) = KT21
LTRI(5,KT2) = KT11
LTRI(6,KT2) = KT1
C
C Correct the KT11 and KT22 entries that changed.
C
IF (KT11 .NE. 0) THEN
I4 = 4
IF (LTRI(4,KT11) .NE. KT1) THEN
I4 = 5
IF (LTRI(5,KT11) .NE. KT1) I4 = 6
ENDIF
LTRI(I4,KT11) = KT2
ENDIF
IF (KT22 .NE. 0) THEN
I4 = 4
IF (LTRI(4,KT22) .NE. KT2) THEN
I4 = 5
IF (LTRI(5,KT22) .NE. KT2) I4 = 6
ENDIF
LTRI(I4,KT22) = KT1
ENDIF
5 CONTINUE
6 CONTINUE
IF (SWP) GO TO 4
C
C Compute and store the negative circumcenters and radii of
C the pseudo-triangles in the first NT positions.
C
7 DO 8 KT = 1,NT
N1 = LTRI(1,KT)
N2 = LTRI(2,KT)
N3 = LTRI(3,KT)
V1(1) = X(N1)
V1(2) = Y(N1)
V1(3) = Z(N1)
V2(1) = X(N2)
V2(2) = Y(N2)
V2(3) = Z(N2)
V3(1) = X(N3)
V3(2) = Y(N3)
V3(3) = Z(N3)
CALL CIRCUM (V1,V2,V3, C,IERR)
IF (IERR .NE. 0) GO TO 23
C
C Store the negative circumcenter and radius (computed
C from <V1,C>).
C
XC(KT) = C(1)
YC(KT) = C(2)
ZC(KT) = C(3)
T = V1(1)*C(1) + V1(2)*C(2) + V1(3)*C(3)
IF (T .LT. -1.0) T = -1.0
IF (T .GT. 1.0) T = 1.0
RC(KT) = ACOS(T)
8 CONTINUE
C
C Compute and store the circumcenters and radii of the
C actual triangles in positions KT = NT+1, NT+2, ...
C Also, store the triangle indexes KT in the appropriate
C LISTC positions.
C
9 KT = NT
C
C Loop on nodes N1.
C
NM2 = NN - 2
DO 12 N1 = 1,NM2
LPL = LEND(N1)
LP = LPL
N3 = LIST(LP)
C
C Loop on adjacent neighbors N2,N3 of N1 for which N2 > N1
C and N3 > N1.
C
10 LP = LPTR(LP)
N2 = N3
N3 = ABS(LIST(LP))
IF (N2 .LE. N1 .OR. N3 .LE. N1) GO TO 11
KT = KT + 1
C
C Compute the circumcenter C of triangle KT = (N1,N2,N3).
C
V1(1) = X(N1)
V1(2) = Y(N1)
V1(3) = Z(N1)
V2(1) = X(N2)
V2(2) = Y(N2)
V2(3) = Z(N2)
V3(1) = X(N3)
V3(2) = Y(N3)
V3(3) = Z(N3)
CALL CIRCUM (V1,V2,V3, C,IERR)
IF (IERR .NE. 0) GO TO 23
C
C Store the circumcenter, radius and triangle index.
C
XC(KT) = C(1)
YC(KT) = C(2)
ZC(KT) = C(3)
T = V1(1)*C(1) + V1(2)*C(2) + V1(3)*C(3)
IF (T .LT. -1.0) T = -1.0
IF (T .GT. 1.0) T = 1.0
RC(KT) = ACOS(T)
C
C Store KT in LISTC(LPN), where Abs(LIST(LPN)) is the
C index of N2 as a neighbor of N1, N3 as a neighbor
C of N2, and N1 as a neighbor of N3.
C
LPN = LSTPTR(LPL,N2,LIST,LPTR)
LISTC(LPN) = KT
LPN = LSTPTR(LEND(N2),N3,LIST,LPTR)
LISTC(LPN) = KT
LPN = LSTPTR(LEND(N3),N1,LIST,LPTR)
LISTC(LPN) = KT
11 IF (LP .NE. LPL) GO TO 10
12 CONTINUE
IF (NT .EQ. 0) GO TO 20
C
C Store the first NT triangle indexes in LISTC.
C
C Find a boundary triangle KT1 = (N1,N2,N3) with a
C boundary arc opposite N3.
C
KT1 = 0
13 KT1 = KT1 + 1
IF (LTRI(4,KT1) .EQ. 0) THEN
I1 = 2
I2 = 3
I3 = 1
GO TO 14
ELSEIF (LTRI(5,KT1) .EQ. 0) THEN
I1 = 3
I2 = 1
I3 = 2
GO TO 14
ELSEIF (LTRI(6,KT1) .EQ. 0) THEN
I1 = 1
I2 = 2
I3 = 3
GO TO 14
ENDIF
GO TO 13
14 N1 = LTRI(I1,KT1)
N0 = N1
C
C Loop on boundary nodes N1 in CCW order, storing the
C indexes of the clockwise-ordered sequence of triangles
C that contain N1. The first triangle overwrites the
C last neighbor position, and the remaining triangles,
C if any, are appended to N1's adjacency list.
C
C A pointer to the first neighbor of N1 is saved in LPN.
C
15 LP = LEND(N1)
LPN = LPTR(LP)
LISTC(LP) = KT1
C
C Loop on triangles KT2 containing N1.
C
16 KT2 = LTRI(I2+3,KT1)
IF (KT2 .NE. 0) THEN
C
C Append KT2 to N1's triangle list.
C
LPTR(LP) = LNEW
LP = LNEW
LISTC(LP) = KT2
LNEW = LNEW + 1
C
C Set KT1 to KT2 and update (I1,I2,I3) such that
C LTRI(I1,KT1) = N1.
C
KT1 = KT2
IF (LTRI(1,KT1) .EQ. N1) THEN
I1 = 1
I2 = 2
I3 = 3
ELSEIF (LTRI(2,KT1) .EQ. N1) THEN
I1 = 2
I2 = 3
I3 = 1
ELSE
I1 = 3
I2 = 1
I3 = 2
ENDIF
GO TO 16
ENDIF
C
C Store the saved first-triangle pointer in LPTR(LP), set
C N1 to the next boundary node, test for termination,
C and permute the indexes: the last triangle containing
C a boundary node is the first triangle containing the
C next boundary node.
C
LPTR(LP) = LPN
N1 = LTRI(I3,KT1)
IF (N1 .NE. N0) THEN
I4 = I3
I3 = I2
I2 = I1
I1 = I4
GO TO 15
ENDIF
C
C No errors encountered.
C
20 IER = 0
RETURN
C
C N < 3.
C
21 IER = 1
RETURN
C
C Insufficient space reserved for LTRI.
C
22 IER = 2
RETURN
C
C Error flag returned by CIRCUM: KT indexes a null triangle.
C
23 IER = 3
RETURN
END
SUBROUTINE DELARC (N,IO1,IO2, LIST,LPTR,LEND,
. LNEW, IER)
INTEGER N, IO1, IO2, LIST(*), LPTR(*), LEND(N), LNEW,
. IER
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/17/96
C
C This subroutine deletes a boundary arc from a triangula-
C tion. It may be used to remove a null triangle from the
C convex hull boundary. Note, however, that if the union of
C triangles is rendered nonconvex, Subroutines DELNOD, EDGE,
C and TRFIND (and hence ADDNOD) may fail. Also, Function
C NEARND should not be called following an arc deletion.
C
C This routine is identical to the similarly named routine
C in TRIPACK.
C
C
C On input:
C
C N = Number of nodes in the triangulation. N .GE. 4.
C
C IO1,IO2 = Indexes (in the range 1 to N) of a pair of
C adjacent boundary nodes defining the arc
C to be removed.
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR,LEND,LNEW = Triangulation data structure
C created by Subroutine TRMESH.
C
C On output:
C
C LIST,LPTR,LEND,LNEW = Data structure updated with
C the removal of arc IO1-IO2
C unless IER > 0.
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if N, IO1, or IO2 is outside its valid
C range, or IO1 = IO2.
C IER = 2 if IO1-IO2 is not a boundary arc.
C IER = 3 if the node opposite IO1-IO2 is al-
C ready a boundary node, and thus IO1
C or IO2 has only two neighbors or a
C deletion would result in two triangu-
C lations sharing a single node.
C IER = 4 if one of the nodes is a neighbor of
C the other, but not vice versa, imply-
C ing an invalid triangulation data
C structure.
C
C Module required by DELARC: DELNB, LSTPTR
C
C Intrinsic function called by DELARC: ABS
C
C***********************************************************
C
INTEGER LSTPTR
INTEGER LP, LPH, LPL, N1, N2, N3
C
C Local parameters:
C
C LP = LIST pointer
C LPH = LIST pointer or flag returned by DELNB
C LPL = Pointer to the last neighbor of N1, N2, or N3
C N1,N2,N3 = Nodal indexes of a triangle such that N1->N2
C is the directed boundary edge associated
C with IO1-IO2
C
N1 = IO1
N2 = IO2
C
C Test for errors, and set N1->N2 to the directed boundary
C edge associated with IO1-IO2: (N1,N2,N3) is a triangle
C for some N3.
C
IF (N .LT. 4 .OR. N1 .LT. 1 .OR. N1 .GT. N .OR.
. N2 .LT. 1 .OR. N2 .GT. N .OR. N1 .EQ. N2) THEN
IER = 1
RETURN
ENDIF
C
LPL = LEND(N2)
IF (-LIST(LPL) .NE. N1) THEN
N1 = N2
N2 = IO1
LPL = LEND(N2)
IF (-LIST(LPL) .NE. N1) THEN
IER = 2
RETURN
ENDIF
ENDIF
C
C Set N3 to the node opposite N1->N2 (the second neighbor
C of N1), and test for error 3 (N3 already a boundary
C node).
C
LPL = LEND(N1)
LP = LPTR(LPL)
LP = LPTR(LP)
N3 = ABS(LIST(LP))
LPL = LEND(N3)
IF (LIST(LPL) .LE. 0) THEN
IER = 3
RETURN
ENDIF
C
C Delete N2 as a neighbor of N1, making N3 the first
C neighbor, and test for error 4 (N2 not a neighbor
C of N1). Note that previously computed pointers may
C no longer be valid following the call to DELNB.
C
CALL DELNB (N1,N2,N, LIST,LPTR,LEND,LNEW, LPH)
IF (LPH .LT. 0) THEN
IER = 4
RETURN
ENDIF
C
C Delete N1 as a neighbor of N2, making N3 the new last
C neighbor.
C
CALL DELNB (N2,N1,N, LIST,LPTR,LEND,LNEW, LPH)
C
C Make N3 a boundary node with first neighbor N2 and last
C neighbor N1.
C
LP = LSTPTR(LEND(N3),N1,LIST,LPTR)
LEND(N3) = LP
LIST(LP) = -N1
C
C No errors encountered.
C
IER = 0
RETURN
END
SUBROUTINE DELNB (N0,NB,N, LIST,LPTR,LEND,LNEW, LPH)
INTEGER N0, NB, N, LIST(*), LPTR(*), LEND(N), LNEW,
. LPH
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/29/98
C
C This subroutine deletes a neighbor NB from the adjacency
C list of node N0 (but N0 is not deleted from the adjacency
C list of NB) and, if NB is a boundary node, makes N0 a
C boundary node. For pointer (LIST index) LPH to NB as a
C neighbor of N0, the empty LIST,LPTR location LPH is filled
C in with the values at LNEW-1, pointer LNEW-1 (in LPTR and
C possibly in LEND) is changed to LPH, and LNEW is decremen-
C ted. This requires a search of LEND and LPTR entailing an
C expected operation count of O(N).
C
C This routine is identical to the similarly named routine
C in TRIPACK.
C
C
C On input:
C
C N0,NB = Indexes, in the range 1 to N, of a pair of
C nodes such that NB is a neighbor of N0.
C (N0 need not be a neighbor of NB.)
C
C N = Number of nodes in the triangulation. N .GE. 3.
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR,LEND,LNEW = Data structure defining the
C triangulation.
C
C On output:
C
C LIST,LPTR,LEND,LNEW = Data structure updated with
C the removal of NB from the ad-
C jacency list of N0 unless
C LPH < 0.
C
C LPH = List pointer to the hole (NB as a neighbor of
C N0) filled in by the values at LNEW-1 or error
C indicator:
C LPH > 0 if no errors were encountered.
C LPH = -1 if N0, NB, or N is outside its valid
C range.
C LPH = -2 if NB is not a neighbor of N0.
C
C Modules required by DELNB: None
C
C Intrinsic function called by DELNB: ABS
C
C***********************************************************
C
INTEGER I, LNW, LP, LPB, LPL, LPP, NN
C
C Local parameters:
C
C I = DO-loop index
C LNW = LNEW-1 (output value of LNEW)
C LP = LIST pointer of the last neighbor of NB
C LPB = Pointer to NB as a neighbor of N0
C LPL = Pointer to the last neighbor of N0
C LPP = Pointer to the neighbor of N0 that precedes NB
C NN = Local copy of N
C
NN = N
C
C Test for error 1.
C
IF (N0 .LT. 1 .OR. N0 .GT. NN .OR. NB .LT. 1 .OR.
. NB .GT. NN .OR. NN .LT. 3) THEN
LPH = -1
RETURN
ENDIF
C
C Find pointers to neighbors of N0:
C
C LPL points to the last neighbor,
C LPP points to the neighbor NP preceding NB, and
C LPB points to NB.
C
LPL = LEND(N0)
LPP = LPL
LPB = LPTR(LPP)
1 IF (LIST(LPB) .EQ. NB) GO TO 2
LPP = LPB
LPB = LPTR(LPP)
IF (LPB .NE. LPL) GO TO 1
C
C Test for error 2 (NB not found).
C
IF (ABS(LIST(LPB)) .NE. NB) THEN
LPH = -2
RETURN
ENDIF
C
C NB is the last neighbor of N0. Make NP the new last
C neighbor and, if NB is a boundary node, then make N0
C a boundary node.
C
LEND(N0) = LPP
LP = LEND(NB)
IF (LIST(LP) .LT. 0) LIST(LPP) = -LIST(LPP)
GO TO 3
C
C NB is not the last neighbor of N0. If NB is a boundary
C node and N0 is not, then make N0 a boundary node with
C last neighbor NP.
C
2 LP = LEND(NB)
IF (LIST(LP) .LT. 0 .AND. LIST(LPL) .GT. 0) THEN
LEND(N0) = LPP
LIST(LPP) = -LIST(LPP)
ENDIF
C
C Update LPTR so that the neighbor following NB now fol-
C lows NP, and fill in the hole at location LPB.
C
3 LPTR(LPP) = LPTR(LPB)
LNW = LNEW-1
LIST(LPB) = LIST(LNW)
LPTR(LPB) = LPTR(LNW)
DO 4 I = NN,1,-1
IF (LEND(I) .EQ. LNW) THEN
LEND(I) = LPB
GO TO 5
ENDIF
4 CONTINUE
C
5 DO 6 I = 1,LNW-1
IF (LPTR(I) .EQ. LNW) THEN
LPTR(I) = LPB
ENDIF
6 CONTINUE
C
C No errors encountered.
C
LNEW = LNW
LPH = LPB
RETURN
END
SUBROUTINE DELNOD (K, N,X,Y,Z,LIST,LPTR,LEND,LNEW,LWK,
. IWK, IER)
INTEGER K, N, LIST(*), LPTR(*), LEND(*), LNEW, LWK,
. IWK(2,*), IER
REAL(kind=8) X(*), Y(*), Z(*)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 11/30/99
C
C This subroutine deletes node K (along with all arcs
C incident on node K) from a triangulation of N nodes on the
C unit sphere, and inserts arcs as necessary to produce a
C triangulation of the remaining N-1 nodes. If a Delaunay
C triangulation is input, a Delaunay triangulation will
C result, and thus, DELNOD reverses the effect of a call to
C Subroutine ADDNOD.
C
C
C On input:
C
C K = Index (for X, Y, and Z) of the node to be
C deleted. 1 .LE. K .LE. N.
C
C K is not altered by this routine.
C
C N = Number of nodes in the triangulation on input.
C N .GE. 4. Note that N will be decremented
C following the deletion.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes in the triangula-
C tion.
C
C LIST,LPTR,LEND,LNEW = Data structure defining the
C triangulation. Refer to Sub-
C routine TRMESH.
C
C LWK = Number of columns reserved for IWK. LWK must
C be at least NNB-3, where NNB is the number of
C neighbors of node K, including an extra
C pseudo-node if K is a boundary node.
C
C IWK = Integer work array dimensioned 2 by LWK (or
C array of length .GE. 2*LWK).
C
C On output:
C
C N = Number of nodes in the triangulation on output.
C The input value is decremented unless 1 .LE. IER
C .LE. 4.
C
C X,Y,Z = Updated arrays containing nodal coordinates
C (with elements K+1,...,N+1 shifted up one
C position, thus overwriting element K) unless
C 1 .LE. IER .LE. 4.
C
C LIST,LPTR,LEND,LNEW = Updated triangulation data
C structure reflecting the dele-
C tion unless 1 .LE. IER .LE. 4.
C Note that the data structure
C may have been altered if IER >
C 3.
C
C LWK = Number of IWK columns required unless IER = 1
C or IER = 3.
C
C IWK = Indexes of the endpoints of the new arcs added
C unless LWK = 0 or 1 .LE. IER .LE. 4. (Arcs
C are associated with columns, or pairs of
C adjacent elements if IWK is declared as a
C singly-subscripted array.)
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if K or N is outside its valid range
C or LWK < 0 on input.
C IER = 2 if more space is required in IWK.
C Refer to LWK.
C IER = 3 if the triangulation data structure is
C invalid on input.
C IER = 4 if K indexes an interior node with
C four or more neighbors, none of which
C can be swapped out due to collineari-
C ty, and K cannot therefore be deleted.
C IER = 5 if an error flag (other than IER = 1)
C was returned by OPTIM. An error
C message is written to the standard
C output unit in this case.
C IER = 6 if error flag 1 was returned by OPTIM.
C This is not necessarily an error, but
C the arcs may not be optimal.
C
C Note that the deletion may result in all remaining nodes
C being collinear. This situation is not flagged.
C
C Modules required by DELNOD: DELNB, LEFT, LSTPTR, NBCNT,
C OPTIM, SWAP, SWPTST
C
C Intrinsic function called by DELNOD: ABS
C
C***********************************************************
C
INTEGER LSTPTR, NBCNT
INTEGER I, IERR, IWL, J, LNW, LP, LP21, LPF, LPH, LPL,
. LPL2, LPN, LWKL, N1, N2, NFRST, NIT, NL, NN,
. NNB, NR
LOGICAL LEFT
LOGICAL BDRY
REAL(kind=8) X1, X2, XL, XR, Y1, Y2, YL, YR, Z1, Z2, ZL, ZR
C
C Local parameters:
C
C BDRY = Logical variable with value TRUE iff N1 is a
C boundary node
C I,J = DO-loop indexes
C IERR = Error flag returned by OPTIM
C IWL = Number of IWK columns containing arcs
C LNW = Local copy of LNEW
C LP = LIST pointer
C LP21 = LIST pointer returned by SWAP
C LPF,LPL = Pointers to the first and last neighbors of N1
C LPH = Pointer (or flag) returned by DELNB
C LPL2 = Pointer to the last neighbor of N2
C LPN = Pointer to a neighbor of N1
C LWKL = Input value of LWK
C N1 = Local copy of K
C N2 = Neighbor of N1
C NFRST = First neighbor of N1: LIST(LPF)
C NIT = Number of iterations in OPTIM
C NR,NL = Neighbors of N1 preceding (to the right of) and
C following (to the left of) N2, respectively
C NN = Number of nodes in the triangulation
C NNB = Number of neighbors of N1 (including a pseudo-
C node representing the boundary if N1 is a
C boundary node)
C X1,Y1,Z1 = Coordinates of N1
C X2,Y2,Z2 = Coordinates of N2
C XL,YL,ZL = Coordinates of NL
C XR,YR,ZR = Coordinates of NR
C
C
C Set N1 to K and NNB to the number of neighbors of N1 (plus
C one if N1 is a boundary node), and test for errors. LPF
C and LPL are LIST indexes of the first and last neighbors
C of N1, IWL is the number of IWK columns containing arcs,
C and BDRY is TRUE iff N1 is a boundary node.
C
N1 = K
NN = N
IF (N1 .LT. 1 .OR. N1 .GT. NN .OR. NN .LT. 4 .OR.
. LWK .LT. 0) GO TO 21
LPL = LEND(N1)
LPF = LPTR(LPL)
NNB = NBCNT(LPL,LPTR)
BDRY = LIST(LPL) .LT. 0
IF (BDRY) NNB = NNB + 1
IF (NNB .LT. 3) GO TO 23
LWKL = LWK
LWK = NNB - 3
IF (LWKL .LT. LWK) GO TO 22
IWL = 0
IF (NNB .EQ. 3) GO TO 3
C
C Initialize for loop on arcs N1-N2 for neighbors N2 of N1,
C beginning with the second neighbor. NR and NL are the
C neighbors preceding and following N2, respectively, and
C LP indexes NL. The loop is exited when all possible
C swaps have been applied to arcs incident on N1.
C
X1 = X(N1)
Y1 = Y(N1)
Z1 = Z(N1)
NFRST = LIST(LPF)
NR = NFRST
XR = X(NR)
YR = Y(NR)
ZR = Z(NR)
LP = LPTR(LPF)
N2 = LIST(LP)
X2 = X(N2)
Y2 = Y(N2)
Z2 = Z(N2)
LP = LPTR(LP)
C
C Top of loop: set NL to the neighbor following N2.
C
1 NL = ABS(LIST(LP))
IF (NL .EQ. NFRST .AND. BDRY) GO TO 3
XL = X(NL)
YL = Y(NL)
ZL = Z(NL)
C
C Test for a convex quadrilateral. To avoid an incorrect
C test caused by collinearity, use the fact that if N1
C is a boundary node, then N1 LEFT NR->NL and if N2 is
C a boundary node, then N2 LEFT NL->NR.
C
LPL2 = LEND(N2)
IF ( .NOT. ((BDRY .OR. LEFT(XR,YR,ZR,XL,YL,ZL,X1,Y1,
. Z1)) .AND. (LIST(LPL2) .LT. 0 .OR.
. LEFT(XL,YL,ZL,XR,YR,ZR,X2,Y2,Z2))) ) THEN
C
C Nonconvex quadrilateral -- no swap is possible.
C
NR = N2
XR = X2
YR = Y2
ZR = Z2
GO TO 2
ENDIF
C
C The quadrilateral defined by adjacent triangles
C (N1,N2,NL) and (N2,N1,NR) is convex. Swap in
C NL-NR and store it in IWK unless NL and NR are
C already adjacent, in which case the swap is not
C possible. Indexes larger than N1 must be decremented
C since N1 will be deleted from X, Y, and Z.
C
CALL SWAP (NL,NR,N1,N2, LIST,LPTR,LEND, LP21)
IF (LP21 .EQ. 0) THEN
NR = N2
XR = X2
YR = Y2
ZR = Z2
GO TO 2
ENDIF
IWL = IWL + 1
IF (NL .LE. N1) THEN
IWK(1,IWL) = NL
ELSE
IWK(1,IWL) = NL - 1
ENDIF
IF (NR .LE. N1) THEN
IWK(2,IWL) = NR
ELSE
IWK(2,IWL) = NR - 1
ENDIF
C
C Recompute the LIST indexes and NFRST, and decrement NNB.
C
LPL = LEND(N1)
NNB = NNB - 1
IF (NNB .EQ. 3) GO TO 3
LPF = LPTR(LPL)
NFRST = LIST(LPF)
LP = LSTPTR(LPL,NL,LIST,LPTR)
IF (NR .EQ. NFRST) GO TO 2
C
C NR is not the first neighbor of N1.
C Back up and test N1-NR for a swap again: Set N2 to
C NR and NR to the previous neighbor of N1 -- the
C neighbor of NR which follows N1. LP21 points to NL
C as a neighbor of NR.
C
N2 = NR
X2 = XR
Y2 = YR
Z2 = ZR
LP21 = LPTR(LP21)
LP21 = LPTR(LP21)
NR = ABS(LIST(LP21))
XR = X(NR)
YR = Y(NR)
ZR = Z(NR)
GO TO 1
C
C Bottom of loop -- test for termination of loop.
C
2 IF (N2 .EQ. NFRST) GO TO 3
N2 = NL
X2 = XL
Y2 = YL
Z2 = ZL
LP = LPTR(LP)
GO TO 1
C
C Delete N1 and all its incident arcs. If N1 is an interior
C node and either NNB > 3 or NNB = 3 and N2 LEFT NR->NL,
C then N1 must be separated from its neighbors by a plane
C containing the origin -- its removal reverses the effect
C of a call to COVSPH, and all its neighbors become
C boundary nodes. This is achieved by treating it as if
C it were a boundary node (setting BDRY to TRUE, changing
C a sign in LIST, and incrementing NNB).
C
3 IF (.NOT. BDRY) THEN
IF (NNB .GT. 3) THEN
BDRY = .TRUE.
ELSE
LPF = LPTR(LPL)
NR = LIST(LPF)
LP = LPTR(LPF)
N2 = LIST(LP)
NL = LIST(LPL)
BDRY = LEFT(X(NR),Y(NR),Z(NR),X(NL),Y(NL),Z(NL),
. X(N2),Y(N2),Z(N2))
ENDIF
IF (BDRY) THEN
C
C IF a boundary node already exists, then N1 and its
C neighbors cannot be converted to boundary nodes.
C (They must be collinear.) This is a problem if
C NNB > 3.
C
DO 4 I = 1,NN
IF (LIST(LEND(I)) .LT. 0) THEN
BDRY = .FALSE.
GO TO 5
ENDIF
4 CONTINUE
LIST(LPL) = -LIST(LPL)
NNB = NNB + 1
ENDIF
ENDIF
5 IF (.NOT. BDRY .AND. NNB .GT. 3) GO TO 24
C
C Initialize for loop on neighbors. LPL points to the last
C neighbor of N1. LNEW is stored in local variable LNW.
C
LP = LPL
LNW = LNEW
C
C Loop on neighbors N2 of N1, beginning with the first.
C
6 LP = LPTR(LP)
N2 = ABS(LIST(LP))
CALL DELNB (N2,N1,N, LIST,LPTR,LEND,LNW, LPH)
IF (LPH .LT. 0) GO TO 23
C
C LP and LPL may require alteration.
C
IF (LPL .EQ. LNW) LPL = LPH
IF (LP .EQ. LNW) LP = LPH
IF (LP .NE. LPL) GO TO 6
C
C Delete N1 from X, Y, Z, and LEND, and remove its adjacency
C list from LIST and LPTR. LIST entries (nodal indexes)
C which are larger than N1 must be decremented.
C
NN = NN - 1
IF (N1 .GT. NN) GO TO 9
DO 7 I = N1,NN
X(I) = X(I+1)
Y(I) = Y(I+1)
Z(I) = Z(I+1)
LEND(I) = LEND(I+1)
7 CONTINUE
C
DO 8 I = 1,LNW-1
IF (LIST(I) .GT. N1) LIST(I) = LIST(I) - 1
IF (LIST(I) .LT. -N1) LIST(I) = LIST(I) + 1
8 CONTINUE
C
C For LPN = first to last neighbors of N1, delete the
C preceding neighbor (indexed by LP).
C
C Each empty LIST,LPTR location LP is filled in with the
C values at LNW-1, and LNW is decremented. All pointers
C (including those in LPTR and LEND) with value LNW-1
C must be changed to LP.
C
C LPL points to the last neighbor of N1.
C
9 IF (BDRY) NNB = NNB - 1
LPN = LPL
DO 13 J = 1,NNB
LNW = LNW - 1
LP = LPN
LPN = LPTR(LP)
LIST(LP) = LIST(LNW)
LPTR(LP) = LPTR(LNW)
IF (LPTR(LPN) .EQ. LNW) LPTR(LPN) = LP
IF (LPN .EQ. LNW) LPN = LP
DO 10 I = NN,1,-1
IF (LEND(I) .EQ. LNW) THEN
LEND(I) = LP
GO TO 11
ENDIF
10 CONTINUE
C
11 DO 12 I = LNW-1,1,-1
IF (LPTR(I) .EQ. LNW) LPTR(I) = LP
12 CONTINUE
13 CONTINUE
C
C Update N and LNEW, and optimize the patch of triangles
C containing K (on input) by applying swaps to the arcs
C in IWK.
C
N = NN
LNEW = LNW
IF (IWL .GT. 0) THEN
NIT = 4*IWL
CALL OPTIM (X,Y,Z,IWL, LIST,LPTR,LEND,NIT,IWK, IERR)
IF (IERR .NE. 0 .AND. IERR .NE. 1) GO TO 25
IF (IERR .EQ. 1) GO TO 26
ENDIF
C
C Successful termination.
C
IER = 0
RETURN
C
C Invalid input parameter.
C
21 IER = 1
RETURN
C
C Insufficient space reserved for IWK.
C
22 IER = 2
RETURN
C
C Invalid triangulation data structure. NNB < 3 on input or
C N2 is a neighbor of N1 but N1 is not a neighbor of N2.
C
23 IER = 3
RETURN
C
C N1 is interior but NNB could not be reduced to 3.
C
24 IER = 4
RETURN
C
C Error flag (other than 1) returned by OPTIM.
C
25 IER = 5
WRITE (*,100) NIT, IERR
100 FORMAT (//5X,'*** Error in OPTIM (called from ',
. 'DELNOD): NIT = ',I4,', IER = ',I1,' ***'/)
RETURN
C
C Error flag 1 returned by OPTIM.
C
26 IER = 6
RETURN
END
SUBROUTINE EDGE (IN1,IN2,X,Y,Z, LWK,IWK,LIST,LPTR,
. LEND, IER)
INTEGER IN1, IN2, LWK, IWK(2,*), LIST(*), LPTR(*),
. LEND(*), IER
REAL(kind=8) X(*), Y(*), Z(*)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/30/98
C
C Given a triangulation of N nodes and a pair of nodal
C indexes IN1 and IN2, this routine swaps arcs as necessary
C to force IN1 and IN2 to be adjacent. Only arcs which
C intersect IN1-IN2 are swapped out. If a Delaunay triangu-
C lation is input, the resulting triangulation is as close
C as possible to a Delaunay triangulation in the sense that
C all arcs other than IN1-IN2 are locally optimal.
C
C A sequence of calls to EDGE may be used to force the
C presence of a set of edges defining the boundary of a non-
C convex and/or multiply connected region, or to introduce
C barriers into the triangulation. Note that Subroutine
C GETNP will not necessarily return closest nodes if the
C triangulation has been constrained by a call to EDGE.
C However, this is appropriate in some applications, such
C as triangle-based interpolation on a nonconvex domain.
C
C
C On input:
C
C IN1,IN2 = Indexes (of X, Y, and Z) in the range 1 to
C N defining a pair of nodes to be connected
C by an arc.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes.
C
C The above parameters are not altered by this routine.
C
C LWK = Number of columns reserved for IWK. This must
C be at least NI -- the number of arcs that
C intersect IN1-IN2. (NI is bounded by N-3.)
C
C IWK = Integer work array of length at least 2*LWK.
C
C LIST,LPTR,LEND = Data structure defining the trian-
C gulation. Refer to Subroutine
C TRMESH.
C
C On output:
C
C LWK = Number of arcs which intersect IN1-IN2 (but
C not more than the input value of LWK) unless
C IER = 1 or IER = 3. LWK = 0 if and only if
C IN1 and IN2 were adjacent (or LWK=0) on input.
C
C IWK = Array containing the indexes of the endpoints
C of the new arcs other than IN1-IN2 unless
C IER > 0 or LWK = 0. New arcs to the left of
C IN1->IN2 are stored in the first K-1 columns
C (left portion of IWK), column K contains
C zeros, and new arcs to the right of IN1->IN2
C occupy columns K+1,...,LWK. (K can be deter-
C mined by searching IWK for the zeros.)
C
C LIST,LPTR,LEND = Data structure updated if necessary
C to reflect the presence of an arc
C connecting IN1 and IN2 unless IER >
C 0. The data structure has been
C altered if IER >= 4.
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if IN1 < 1, IN2 < 1, IN1 = IN2,
C or LWK < 0 on input.
C IER = 2 if more space is required in IWK.
C Refer to LWK.
C IER = 3 if IN1 and IN2 could not be connected
C due to either an invalid data struc-
C ture or collinear nodes (and floating
C point error).
C IER = 4 if an error flag other than IER = 1
C was returned by OPTIM.
C IER = 5 if error flag 1 was returned by OPTIM.
C This is not necessarily an error, but
C the arcs other than IN1-IN2 may not
C be optimal.
C
C An error message is written to the standard output unit
C in the case of IER = 3 or IER = 4.
C
C Modules required by EDGE: LEFT, LSTPTR, OPTIM, SWAP,
C SWPTST
C
C Intrinsic function called by EDGE: ABS
C
C***********************************************************
C
LOGICAL LEFT
INTEGER I, IERR, IWC, IWCP1, IWEND, IWF, IWL, LFT, LP,
. LP21, LPL, N0, N1, N1FRST, N1LST, N2, NEXT,
. NIT, NL, NR
REAL(kind=8) DP12, DP1L, DP1R, DP2L, DP2R, X0, X1, X2, Y0,
. Y1, Y2, Z0, Z1, Z2
C
C Local parameters:
C
C DPij = Dot product <Ni,Nj>
C I = DO-loop index and column index for IWK
C IERR = Error flag returned by Subroutine OPTIM
C IWC = IWK index between IWF and IWL -- NL->NR is
C stored in IWK(1,IWC)->IWK(2,IWC)
C IWCP1 = IWC + 1
C IWEND = Input or output value of LWK
C IWF = IWK (column) index of the first (leftmost) arc
C which intersects IN1->IN2
C IWL = IWK (column) index of the last (rightmost) are
C which intersects IN1->IN2
C LFT = Flag used to determine if a swap results in the
C new arc intersecting IN1-IN2 -- LFT = 0 iff
C N0 = IN1, LFT = -1 implies N0 LEFT IN1->IN2,
C and LFT = 1 implies N0 LEFT IN2->IN1
C LP = List pointer (index for LIST and LPTR)
C LP21 = Unused parameter returned by SWAP
C LPL = Pointer to the last neighbor of IN1 or NL
C N0 = Neighbor of N1 or node opposite NR->NL
C N1,N2 = Local copies of IN1 and IN2
C N1FRST = First neighbor of IN1
C N1LST = (Signed) last neighbor of IN1
C NEXT = Node opposite NL->NR
C NIT = Flag or number of iterations employed by OPTIM
C NL,NR = Endpoints of an arc which intersects IN1-IN2
C with NL LEFT IN1->IN2
C X0,Y0,Z0 = Coordinates of N0
C X1,Y1,Z1 = Coordinates of IN1
C X2,Y2,Z2 = Coordinates of IN2
C
C
C Store IN1, IN2, and LWK in local variables and test for
C errors.
C
N1 = IN1
N2 = IN2
IWEND = LWK
IF (N1 .LT. 1 .OR. N2 .LT. 1 .OR. N1 .EQ. N2 .OR.
. IWEND .LT. 0) GO TO 31
C
C Test for N2 as a neighbor of N1. LPL points to the last
C neighbor of N1.
C
LPL = LEND(N1)
N0 = ABS(LIST(LPL))
LP = LPL
1 IF (N0 .EQ. N2) GO TO 30
LP = LPTR(LP)
N0 = LIST(LP)
IF (LP .NE. LPL) GO TO 1
C
C Initialize parameters.
C
IWL = 0
NIT = 0
C
C Store the coordinates of N1 and N2.
C
2 X1 = X(N1)
Y1 = Y(N1)
Z1 = Z(N1)
X2 = X(N2)
Y2 = Y(N2)
Z2 = Z(N2)
C
C Set NR and NL to adjacent neighbors of N1 such that
C NR LEFT N2->N1 and NL LEFT N1->N2,
C (NR Forward N1->N2 or NL Forward N1->N2), and
C (NR Forward N2->N1 or NL Forward N2->N1).
C
C Initialization: Set N1FRST and N1LST to the first and
C (signed) last neighbors of N1, respectively, and
C initialize NL to N1FRST.
C
LPL = LEND(N1)
N1LST = LIST(LPL)
LP = LPTR(LPL)
N1FRST = LIST(LP)
NL = N1FRST
IF (N1LST .LT. 0) GO TO 4
C
C N1 is an interior node. Set NL to the first candidate
C for NR (NL LEFT N2->N1).
C
3 IF (LEFT(X2,Y2,Z2,X1,Y1,Z1,X(NL),Y(NL),Z(NL))) GO TO 4
LP = LPTR(LP)
NL = LIST(LP)
IF (NL .NE. N1FRST) GO TO 3
C
C All neighbors of N1 are strictly left of N1->N2.
C
GO TO 5
C
C NL = LIST(LP) LEFT N2->N1. Set NR to NL and NL to the
C following neighbor of N1.
C
4 NR = NL
LP = LPTR(LP)
NL = ABS(LIST(LP))
IF (LEFT(X1,Y1,Z1,X2,Y2,Z2,X(NL),Y(NL),Z(NL)) ) THEN
C
C NL LEFT N1->N2 and NR LEFT N2->N1. The Forward tests
C are employed to avoid an error associated with
C collinear nodes.
C
DP12 = X1*X2 + Y1*Y2 + Z1*Z2
DP1L = X1*X(NL) + Y1*Y(NL) + Z1*Z(NL)
DP2L = X2*X(NL) + Y2*Y(NL) + Z2*Z(NL)
DP1R = X1*X(NR) + Y1*Y(NR) + Z1*Z(NR)
DP2R = X2*X(NR) + Y2*Y(NR) + Z2*Z(NR)
IF ( (DP2L-DP12*DP1L .GE. 0. .OR.
. DP2R-DP12*DP1R .GE. 0.) .AND.
. (DP1L-DP12*DP2L .GE. 0. .OR.
. DP1R-DP12*DP2R .GE. 0.) ) GO TO 6
C
C NL-NR does not intersect N1-N2. However, there is
C another candidate for the first arc if NL lies on
C the line N1-N2.
C
IF ( .NOT. LEFT(X2,Y2,Z2,X1,Y1,Z1,X(NL),Y(NL),
. Z(NL)) ) GO TO 5
ENDIF
C
C Bottom of loop.
C
IF (NL .NE. N1FRST) GO TO 4
C
C Either the triangulation is invalid or N1-N2 lies on the
C convex hull boundary and an edge NR->NL (opposite N1 and
C intersecting N1-N2) was not found due to floating point
C error. Try interchanging N1 and N2 -- NIT > 0 iff this
C has already been done.
C
5 IF (NIT .GT. 0) GO TO 33
NIT = 1
N1 = N2
N2 = IN1
GO TO 2
C
C Store the ordered sequence of intersecting edges NL->NR in
C IWK(1,IWL)->IWK(2,IWL).
C
6 IWL = IWL + 1
IF (IWL .GT. IWEND) GO TO 32
IWK(1,IWL) = NL
IWK(2,IWL) = NR
C
C Set NEXT to the neighbor of NL which follows NR.
C
LPL = LEND(NL)
LP = LPTR(LPL)
C
C Find NR as a neighbor of NL. The search begins with
C the first neighbor.
C
7 IF (LIST(LP) .EQ. NR) GO TO 8
LP = LPTR(LP)
IF (LP .NE. LPL) GO TO 7
C
C NR must be the last neighbor, and NL->NR cannot be a
C boundary edge.
C
IF (LIST(LP) .NE. NR) GO TO 33
C
C Set NEXT to the neighbor following NR, and test for
C termination of the store loop.
C
8 LP = LPTR(LP)
NEXT = ABS(LIST(LP))
IF (NEXT .EQ. N2) GO TO 9
C
C Set NL or NR to NEXT.
C
IF ( LEFT(X1,Y1,Z1,X2,Y2,Z2,X(NEXT),Y(NEXT),Z(NEXT)) )
. THEN
NL = NEXT
ELSE
NR = NEXT
ENDIF
GO TO 6
C
C IWL is the number of arcs which intersect N1-N2.
C Store LWK.
C
9 LWK = IWL
IWEND = IWL
C
C Initialize for edge swapping loop -- all possible swaps
C are applied (even if the new arc again intersects
C N1-N2), arcs to the left of N1->N2 are stored in the
C left portion of IWK, and arcs to the right are stored in
C the right portion. IWF and IWL index the first and last
C intersecting arcs.
C
IWF = 1
C
C Top of loop -- set N0 to N1 and NL->NR to the first edge.
C IWC points to the arc currently being processed. LFT
C .LE. 0 iff N0 LEFT N1->N2.
C
10 LFT = 0
N0 = N1
X0 = X1
Y0 = Y1
Z0 = Z1
NL = IWK(1,IWF)
NR = IWK(2,IWF)
IWC = IWF
C
C Set NEXT to the node opposite NL->NR unless IWC is the
C last arc.
C
11 IF (IWC .EQ. IWL) GO TO 21
IWCP1 = IWC + 1
NEXT = IWK(1,IWCP1)
IF (NEXT .NE. NL) GO TO 16
NEXT = IWK(2,IWCP1)
C
C NEXT RIGHT N1->N2 and IWC .LT. IWL. Test for a possible
C swap.
C
IF ( .NOT. LEFT(X0,Y0,Z0,X(NR),Y(NR),Z(NR),X(NEXT),
. Y(NEXT),Z(NEXT)) ) GO TO 14
IF (LFT .GE. 0) GO TO 12
IF ( .NOT. LEFT(X(NL),Y(NL),Z(NL),X0,Y0,Z0,X(NEXT),
. Y(NEXT),Z(NEXT)) ) GO TO 14
C
C Replace NL->NR with N0->NEXT.
C
CALL SWAP (NEXT,N0,NL,NR, LIST,LPTR,LEND, LP21)
IWK(1,IWC) = N0
IWK(2,IWC) = NEXT
GO TO 15
C
C Swap NL-NR for N0-NEXT, shift columns IWC+1,...,IWL to
C the left, and store N0-NEXT in the right portion of
C IWK.
C
12 CALL SWAP (NEXT,N0,NL,NR, LIST,LPTR,LEND, LP21)
DO 13 I = IWCP1,IWL
IWK(1,I-1) = IWK(1,I)
IWK(2,I-1) = IWK(2,I)
13 CONTINUE
IWK(1,IWL) = N0
IWK(2,IWL) = NEXT
IWL = IWL - 1
NR = NEXT
GO TO 11
C
C A swap is not possible. Set N0 to NR.
C
14 N0 = NR
X0 = X(N0)
Y0 = Y(N0)
Z0 = Z(N0)
LFT = 1
C
C Advance to the next arc.
C
15 NR = NEXT
IWC = IWC + 1
GO TO 11
C
C NEXT LEFT N1->N2, NEXT .NE. N2, and IWC .LT. IWL.
C Test for a possible swap.
C
16 IF ( .NOT. LEFT(X(NL),Y(NL),Z(NL),X0,Y0,Z0,X(NEXT),
. Y(NEXT),Z(NEXT)) ) GO TO 19
IF (LFT .LE. 0) GO TO 17
IF ( .NOT. LEFT(X0,Y0,Z0,X(NR),Y(NR),Z(NR),X(NEXT),
. Y(NEXT),Z(NEXT)) ) GO TO 19
C
C Replace NL->NR with NEXT->N0.
C
CALL SWAP (NEXT,N0,NL,NR, LIST,LPTR,LEND, LP21)
IWK(1,IWC) = NEXT
IWK(2,IWC) = N0
GO TO 20
C
C Swap NL-NR for N0-NEXT, shift columns IWF,...,IWC-1 to
C the right, and store N0-NEXT in the left portion of
C IWK.
C
17 CALL SWAP (NEXT,N0,NL,NR, LIST,LPTR,LEND, LP21)
DO 18 I = IWC-1,IWF,-1
IWK(1,I+1) = IWK(1,I)
IWK(2,I+1) = IWK(2,I)
18 CONTINUE
IWK(1,IWF) = N0
IWK(2,IWF) = NEXT
IWF = IWF + 1
GO TO 20
C
C A swap is not possible. Set N0 to NL.
C
19 N0 = NL
X0 = X(N0)
Y0 = Y(N0)
Z0 = Z(N0)
LFT = -1
C
C Advance to the next arc.
C
20 NL = NEXT
IWC = IWC + 1
GO TO 11
C
C N2 is opposite NL->NR (IWC = IWL).
C
21 IF (N0 .EQ. N1) GO TO 24
IF (LFT .LT. 0) GO TO 22
C
C N0 RIGHT N1->N2. Test for a possible swap.
C
IF ( .NOT. LEFT(X0,Y0,Z0,X(NR),Y(NR),Z(NR),X2,Y2,Z2) )
. GO TO 10
C
C Swap NL-NR for N0-N2 and store N0-N2 in the right
C portion of IWK.
C
CALL SWAP (N2,N0,NL,NR, LIST,LPTR,LEND, LP21)
IWK(1,IWL) = N0
IWK(2,IWL) = N2
IWL = IWL - 1
GO TO 10
C
C N0 LEFT N1->N2. Test for a possible swap.
C
22 IF ( .NOT. LEFT(X(NL),Y(NL),Z(NL),X0,Y0,Z0,X2,Y2,Z2) )
. GO TO 10
C
C Swap NL-NR for N0-N2, shift columns IWF,...,IWL-1 to the
C right, and store N0-N2 in the left portion of IWK.
C
CALL SWAP (N2,N0,NL,NR, LIST,LPTR,LEND, LP21)
I = IWL
23 IWK(1,I) = IWK(1,I-1)
IWK(2,I) = IWK(2,I-1)
I = I - 1
IF (I .GT. IWF) GO TO 23
IWK(1,IWF) = N0
IWK(2,IWF) = N2
IWF = IWF + 1
GO TO 10
C
C IWF = IWC = IWL. Swap out the last arc for N1-N2 and
C store zeros in IWK.
C
24 CALL SWAP (N2,N1,NL,NR, LIST,LPTR,LEND, LP21)
IWK(1,IWC) = 0
IWK(2,IWC) = 0
C
C Optimization procedure --
C
IER = 0
IF (IWC .GT. 1) THEN
C
C Optimize the set of new arcs to the left of IN1->IN2.
C
NIT = 4*(IWC-1)
CALL OPTIM (X,Y,Z,IWC-1, LIST,LPTR,LEND,NIT,
. IWK, IERR)
IF (IERR .NE. 0 .AND. IERR .NE. 1) GO TO 34
IF (IERR .EQ. 1) IER = 5
ENDIF
IF (IWC .LT. IWEND) THEN
C
C Optimize the set of new arcs to the right of IN1->IN2.
C
NIT = 4*(IWEND-IWC)
CALL OPTIM (X,Y,Z,IWEND-IWC, LIST,LPTR,LEND,NIT,
. IWK(1,IWC+1), IERR)
IF (IERR .NE. 0 .AND. IERR .NE. 1) GO TO 34
IF (IERR .EQ. 1) GO TO 35
ENDIF
IF (IER .EQ. 5) GO TO 35
C
C Successful termination (IER = 0).
C
RETURN
C
C IN1 and IN2 were adjacent on input.
C
30 IER = 0
RETURN
C
C Invalid input parameter.
C
31 IER = 1
RETURN
C
C Insufficient space reserved for IWK.
C
32 IER = 2
RETURN
C
C Invalid triangulation data structure or collinear nodes
C on convex hull boundary.
C
33 IER = 3
WRITE (*,130) IN1, IN2
130 FORMAT (//5X,'*** Error in EDGE: Invalid triangula',
. 'tion or null triangles on boundary'/
. 9X,'IN1 =',I4,', IN2=',I4/)
RETURN
C
C Error flag (other than 1) returned by OPTIM.
C
34 IER = 4
WRITE (*,140) NIT, IERR
140 FORMAT (//5X,'*** Error in OPTIM (called from EDGE):',
. ' NIT = ',I4,', IER = ',I1,' ***'/)
RETURN
C
C Error flag 1 returned by OPTIM.
C
35 IER = 5
RETURN
END
SUBROUTINE GETNP (X,Y,Z,LIST,LPTR,LEND,L, NPTS, DF,
. IER)
INTEGER LIST(*), LPTR(*), LEND(*), L, NPTS(L), IER
REAL(kind=8) X(*), Y(*), Z(*), DF
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/28/98
C
C Given a Delaunay triangulation of N nodes on the unit
C sphere and an array NPTS containing the indexes of L-1
C nodes ordered by angular distance from NPTS(1), this sub-
C routine sets NPTS(L) to the index of the next node in the
C sequence -- the node, other than NPTS(1),...,NPTS(L-1),
C that is closest to NPTS(1). Thus, the ordered sequence
C of K closest nodes to N1 (including N1) may be determined
C by K-1 calls to GETNP with NPTS(1) = N1 and L = 2,3,...,K
C for K .GE. 2.
C
C The algorithm uses the property of a Delaunay triangula-
C tion that the K-th closest node to N1 is a neighbor of one
C of the K-1 closest nodes to N1.
C
C
C On input:
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes.
C
C LIST,LPTR,LEND = Triangulation data structure. Re-
C fer to Subroutine TRMESH.
C
C L = Number of nodes in the sequence on output. 2
C .LE. L .LE. N.
C
C The above parameters are not altered by this routine.
C
C NPTS = Array of length .GE. L containing the indexes
C of the L-1 closest nodes to NPTS(1) in the
C first L-1 locations.
C
C On output:
C
C NPTS = Array updated with the index of the L-th
C closest node to NPTS(1) in position L unless
C IER = 1.
C
C DF = Value of an increasing function (negative cos-
C ine) of the angular distance between NPTS(1)
C and NPTS(L) unless IER = 1.
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if L < 2.
C
C Modules required by GETNP: None
C
C Intrinsic function called by GETNP: ABS
C
C***********************************************************
C
INTEGER I, LM1, LP, LPL, N1, NB, NI, NP
REAL(kind=8) DNB, DNP, X1, Y1, Z1
C
C Local parameters:
C
C DNB,DNP = Negative cosines of the angular distances from
C N1 to NB and to NP, respectively
C I = NPTS index and DO-loop index
C LM1 = L-1
C LP = LIST pointer of a neighbor of NI
C LPL = Pointer to the last neighbor of NI
C N1 = NPTS(1)
C NB = Neighbor of NI and candidate for NP
C NI = NPTS(I)
C NP = Candidate for NPTS(L)
C X1,Y1,Z1 = Coordinates of N1
C
LM1 = L - 1
IF (LM1 .LT. 1) GO TO 6
IER = 0
C
C Store N1 = NPTS(1) and mark the elements of NPTS.
C
N1 = NPTS(1)
X1 = X(N1)
Y1 = Y(N1)
Z1 = Z(N1)
DO 1 I = 1,LM1
NI = NPTS(I)
LEND(NI) = -LEND(NI)
1 CONTINUE
C
C Candidates for NP = NPTS(L) are the unmarked neighbors
C of nodes in NPTS. DNP is initially greater than -cos(PI)
C (the maximum distance).
C
DNP = 2.
C
C Loop on nodes NI in NPTS.
C
DO 4 I = 1,LM1
NI = NPTS(I)
LPL = -LEND(NI)
LP = LPL
C
C Loop on neighbors NB of NI.
C
2 NB = ABS(LIST(LP))
IF (LEND(NB) .LT. 0) GO TO 3
C
C NB is an unmarked neighbor of NI. Replace NP if NB is
C closer to N1.
C
DNB = -(X(NB)*X1 + Y(NB)*Y1 + Z(NB)*Z1)
IF (DNB .GE. DNP) GO TO 3
NP = NB
DNP = DNB
3 LP = LPTR(LP)
IF (LP .NE. LPL) GO TO 2
4 CONTINUE
NPTS(L) = NP
DF = DNP
C
C Unmark the elements of NPTS.
C
DO 5 I = 1,LM1
NI = NPTS(I)
LEND(NI) = -LEND(NI)
5 CONTINUE
RETURN
C
C L is outside its valid range.
C
6 IER = 1
RETURN
END
SUBROUTINE INSERT (K,LP, LIST,LPTR,LNEW )
INTEGER K, LP, LIST(*), LPTR(*), LNEW
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/17/96
C
C This subroutine inserts K as a neighbor of N1 following
C N2, where LP is the LIST pointer of N2 as a neighbor of
C N1. Note that, if N2 is the last neighbor of N1, K will
C become the first neighbor (even if N1 is a boundary node).
C
C This routine is identical to the similarly named routine
C in TRIPACK.
C
C
C On input:
C
C K = Index of the node to be inserted.
C
C LP = LIST pointer of N2 as a neighbor of N1.
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR,LNEW = Data structure defining the trian-
C gulation. Refer to Subroutine
C TRMESH.
C
C On output:
C
C LIST,LPTR,LNEW = Data structure updated with the
C addition of node K.
C
C Modules required by INSERT: None
C
C***********************************************************
C
INTEGER LSAV
C
LSAV = LPTR(LP)
LPTR(LP) = LNEW
LIST(LNEW) = K
LPTR(LNEW) = LSAV
LNEW = LNEW + 1
RETURN
END
LOGICAL FUNCTION INSIDE (P,LV,XV,YV,ZV,NV,LISTV, IER)
INTEGER LV, NV, LISTV(NV), IER
REAL(kind=8) P(3), XV(LV), YV(LV), ZV(LV)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 12/27/93
C
C This function locates a point P relative to a polygonal
C region R on the surface of the unit sphere, returning
C INSIDE = TRUE if and only if P is contained in R. R is
C defined by a cyclically ordered sequence of vertices which
C form a positively-oriented simple closed curve. Adjacent
C vertices need not be distinct but the curve must not be
C self-intersecting. Also, while polygon edges are by defi-
C nition restricted to a single hemisphere, R is not so
C restricted. Its interior is the region to the left as the
C vertices are traversed in order.
C
C The algorithm consists of selecting a point Q in R and
C then finding all points at which the great circle defined
C by P and Q intersects the boundary of R. P lies inside R
C if and only if there is an even number of intersection
C points between Q and P. Q is taken to be a point immedi-
C ately to the left of a directed boundary edge -- the first
C one that results in no consistency-check failures.
C
C If P is close to the polygon boundary, the problem is
C ill-conditioned and the decision may be incorrect. Also,
C an incorrect decision may result from a poor choice of Q
C (if, for example, a boundary edge lies on the great cir-
C cle defined by P and Q). A more reliable result could be
C obtained by a sequence of calls to INSIDE with the ver-
C tices cyclically permuted before each call (to alter the
C choice of Q).
C
C
C On input:
C
C P = Array of length 3 containing the Cartesian
C coordinates of the point (unit vector) to be
C located.
C
C LV = Length of arrays XV, YV, and ZV.
C
C XV,YV,ZV = Arrays of length LV containing the Carte-
C sian coordinates of unit vectors (points
C on the unit sphere). These values are
C not tested for validity.
C
C NV = Number of vertices in the polygon. 3 .LE. NV
C .LE. LV.
C
C LISTV = Array of length NV containing the indexes
C (for XV, YV, and ZV) of a cyclically-ordered
C (and CCW-ordered) sequence of vertices that
C define R. The last vertex (indexed by
C LISTV(NV)) is followed by the first (indexed
C by LISTV(1)). LISTV entries must be in the
C range 1 to LV.
C
C Input parameters are not altered by this function.
C
C On output:
C
C INSIDE = TRUE if and only if P lies inside R unless
C IER .NE. 0, in which case the value is not
C altered.
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if LV or NV is outside its valid
C range.
C IER = 2 if a LISTV entry is outside its valid
C range.
C IER = 3 if the polygon boundary was found to
C be self-intersecting. This error will
C not necessarily be detected.
C IER = 4 if every choice of Q (one for each
C boundary edge) led to failure of some
C internal consistency check. The most
C likely cause of this error is invalid
C input: P = (0,0,0), a null or self-
C intersecting polygon, etc.
C
C Module required by INSIDE: INTRSC
C
C Intrinsic function called by INSIDE: SQRT
C
C***********************************************************
C
INTEGER I1, I2, IERR, IMX, K, K0, N, NI
LOGICAL EVEN, LFT1, LFT2, PINR, QINR
REAL(kind=8) B(3), BP, BQ, CN(3), D, EPS, PN(3), Q(3),
. QN(3), QNRM, V1(3), V2(3), VN(3), VNRM
C
C Local parameters:
C
C B = Intersection point between the boundary and
C the great circle defined by P and Q
C BP,BQ = <B,P> and <B,Q>, respectively, maximized over
C intersection points B that lie between P and
C Q (on the shorter arc) -- used to find the
C closest intersection points to P and Q
C CN = Q X P = normal to the plane of P and Q
C D = Dot product <B,P> or <B,Q>
C EPS = Parameter used to define Q as the point whose
C orthogonal distance to (the midpoint of)
C boundary edge V1->V2 is approximately EPS/
C (2*Cos(A/2)), where <V1,V2> = Cos(A).
C EVEN = TRUE iff an even number of intersection points
C lie between P and Q (on the shorter arc)
C I1,I2 = Indexes (LISTV elements) of a pair of adjacent
C boundary vertices (endpoints of a boundary
C edge)
C IERR = Error flag for calls to INTRSC (not tested)
C IMX = Local copy of LV and maximum value of I1 and
C I2
C K = DO-loop index and LISTV index
C K0 = LISTV index of the first endpoint of the
C boundary edge used to compute Q
C LFT1,LFT2 = Logical variables associated with I1 and I2 in
C the boundary traversal: TRUE iff the vertex
C is strictly to the left of Q->P (<V,CN> > 0)
C N = Local copy of NV
C NI = Number of intersections (between the boundary
C curve and the great circle P-Q) encountered
C PINR = TRUE iff P is to the left of the directed
C boundary edge associated with the closest
C intersection point to P that lies between P
C and Q (a left-to-right intersection as
C viewed from Q), or there is no intersection
C between P and Q (on the shorter arc)
C PN,QN = P X CN and CN X Q, respectively: used to
C locate intersections B relative to arc Q->P
C Q = (V1 + V2 + EPS*VN/VNRM)/QNRM, where V1->V2 is
C the boundary edge indexed by LISTV(K0) ->
C LISTV(K0+1)
C QINR = TRUE iff Q is to the left of the directed
C boundary edge associated with the closest
C intersection point to Q that lies between P
C and Q (a right-to-left intersection as
C viewed from Q), or there is no intersection
C between P and Q (on the shorter arc)
C QNRM = Euclidean norm of V1+V2+EPS*VN/VNRM used to
C compute (normalize) Q
C V1,V2 = Vertices indexed by I1 and I2 in the boundary
C traversal
C VN = V1 X V2, where V1->V2 is the boundary edge
C indexed by LISTV(K0) -> LISTV(K0+1)
C VNRM = Euclidean norm of VN
C
DATA EPS/1.E-3/
C
C Store local parameters, test for error 1, and initialize
C K0.
C
IMX = LV
N = NV
IF (N .LT. 3 .OR. N .GT. IMX) GO TO 11
K0 = 0
I1 = LISTV(1)
IF (I1 .LT. 1 .OR. I1 .GT. IMX) GO TO 12
C
C Increment K0 and set Q to a point immediately to the left
C of the midpoint of edge V1->V2 = LISTV(K0)->LISTV(K0+1):
C Q = (V1 + V2 + EPS*VN/VNRM)/QNRM, where VN = V1 X V2.
C
1 K0 = K0 + 1
IF (K0 .GT. N) GO TO 14
I1 = LISTV(K0)
IF (K0 .LT. N) THEN
I2 = LISTV(K0+1)
ELSE
I2 = LISTV(1)
ENDIF
IF (I2 .LT. 1 .OR. I2 .GT. IMX) GO TO 12
VN(1) = YV(I1)*ZV(I2) - ZV(I1)*YV(I2)
VN(2) = ZV(I1)*XV(I2) - XV(I1)*ZV(I2)
VN(3) = XV(I1)*YV(I2) - YV(I1)*XV(I2)
VNRM = SQRT(VN(1)*VN(1) + VN(2)*VN(2) + VN(3)*VN(3))
IF (VNRM .EQ. 0.) GO TO 1
Q(1) = XV(I1) + XV(I2) + EPS*VN(1)/VNRM
Q(2) = YV(I1) + YV(I2) + EPS*VN(2)/VNRM
Q(3) = ZV(I1) + ZV(I2) + EPS*VN(3)/VNRM
QNRM = SQRT(Q(1)*Q(1) + Q(2)*Q(2) + Q(3)*Q(3))
Q(1) = Q(1)/QNRM
Q(2) = Q(2)/QNRM
Q(3) = Q(3)/QNRM
C
C Compute CN = Q X P, PN = P X CN, and QN = CN X Q.
C
CN(1) = Q(2)*P(3) - Q(3)*P(2)
CN(2) = Q(3)*P(1) - Q(1)*P(3)
CN(3) = Q(1)*P(2) - Q(2)*P(1)
IF (CN(1) .EQ. 0. .AND. CN(2) .EQ. 0. .AND.
. CN(3) .EQ. 0.) GO TO 1
PN(1) = P(2)*CN(3) - P(3)*CN(2)
PN(2) = P(3)*CN(1) - P(1)*CN(3)
PN(3) = P(1)*CN(2) - P(2)*CN(1)
QN(1) = CN(2)*Q(3) - CN(3)*Q(2)
QN(2) = CN(3)*Q(1) - CN(1)*Q(3)
QN(3) = CN(1)*Q(2) - CN(2)*Q(1)
C
C Initialize parameters for the boundary traversal.
C
NI = 0
EVEN = .TRUE.
BP = -2.
BQ = -2.
PINR = .TRUE.
QINR = .TRUE.
I2 = LISTV(N)
IF (I2 .LT. 1 .OR. I2 .GT. IMX) GO TO 12
LFT2 = CN(1)*XV(I2) + CN(2)*YV(I2) +
. CN(3)*ZV(I2) .GT. 0.
C
C Loop on boundary arcs I1->I2.
C
DO 2 K = 1,N
I1 = I2
LFT1 = LFT2
I2 = LISTV(K)
IF (I2 .LT. 1 .OR. I2 .GT. IMX) GO TO 12
LFT2 = CN(1)*XV(I2) + CN(2)*YV(I2) +
. CN(3)*ZV(I2) .GT. 0.
IF (LFT1 .EQV. LFT2) GO TO 2
C
C I1 and I2 are on opposite sides of Q->P. Compute the
C point of intersection B.
C
NI = NI + 1
V1(1) = XV(I1)
V1(2) = YV(I1)
V1(3) = ZV(I1)
V2(1) = XV(I2)
V2(2) = YV(I2)
V2(3) = ZV(I2)
CALL INTRSC (V1,V2,CN, B,IERR)
C
C B is between Q and P (on the shorter arc) iff
C B Forward Q->P and B Forward P->Q iff
C <B,QN> > 0 and <B,PN> > 0.
C
IF (B(1)*QN(1) + B(2)*QN(2) + B(3)*QN(3) .GT. 0.
. .AND.
. B(1)*PN(1) + B(2)*PN(2) + B(3)*PN(3) .GT. 0.)
. THEN
C
C Update EVEN, BQ, QINR, BP, and PINR.
C
EVEN = .NOT. EVEN
D = B(1)*Q(1) + B(2)*Q(2) + B(3)*Q(3)
IF (D .GT. BQ) THEN
BQ = D
QINR = LFT2
ENDIF
D = B(1)*P(1) + B(2)*P(2) + B(3)*P(3)
IF (D .GT. BP) THEN
BP = D
PINR = LFT1
ENDIF
ENDIF
2 CONTINUE
C
C Test for consistency: NI must be even and QINR must be
C TRUE.
C
IF (NI .NE. 2*(NI/2) .OR. .NOT. QINR) GO TO 1
C
C Test for error 3: different values of PINR and EVEN.
C
IF (PINR .NEQV. EVEN) GO TO 13
C
C No error encountered.
C
IER = 0
INSIDE = EVEN
RETURN
C
C LV or NV is outside its valid range.
C
11 IER = 1
RETURN
C
C A LISTV entry is outside its valid range.
C
12 IER = 2
RETURN
C
C The polygon boundary is self-intersecting.
C
13 IER = 3
RETURN
C
C Consistency tests failed for all values of Q.
C
14 IER = 4
RETURN
END
SUBROUTINE INTADD (KK,I1,I2,I3, LIST,LPTR,LEND,LNEW )
INTEGER KK, I1, I2, I3, LIST(*), LPTR(*), LEND(*),
. LNEW
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/17/96
C
C This subroutine adds an interior node to a triangulation
C of a set of points on the unit sphere. The data structure
C is updated with the insertion of node KK into the triangle
C whose vertices are I1, I2, and I3. No optimization of the
C triangulation is performed.
C
C This routine is identical to the similarly named routine
C in TRIPACK.
C
C
C On input:
C
C KK = Index of the node to be inserted. KK .GE. 1
C and KK must not be equal to I1, I2, or I3.
C
C I1,I2,I3 = Indexes of the counterclockwise-ordered
C sequence of vertices of a triangle which
C contains node KK.
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR,LEND,LNEW = Data structure defining the
C triangulation. Refer to Sub-
C routine TRMESH. Triangle
C (I1,I2,I3) must be included
C in the triangulation.
C
C On output:
C
C LIST,LPTR,LEND,LNEW = Data structure updated with
C the addition of node KK. KK
C will be connected to nodes I1,
C I2, and I3.
C
C Modules required by INTADD: INSERT, LSTPTR
C
C***********************************************************
C
INTEGER LSTPTR
INTEGER K, LP, N1, N2, N3
C
C Local parameters:
C
C K = Local copy of KK
C LP = LIST pointer
C N1,N2,N3 = Local copies of I1, I2, and I3
C
K = KK
C
C Initialization.
C
N1 = I1
N2 = I2
N3 = I3
C
C Add K as a neighbor of I1, I2, and I3.
C
LP = LSTPTR(LEND(N1),N2,LIST,LPTR)
CALL INSERT (K,LP, LIST,LPTR,LNEW )
LP = LSTPTR(LEND(N2),N3,LIST,LPTR)
CALL INSERT (K,LP, LIST,LPTR,LNEW )
LP = LSTPTR(LEND(N3),N1,LIST,LPTR)
CALL INSERT (K,LP, LIST,LPTR,LNEW )
C
C Add I1, I2, and I3 as neighbors of K.
C
LIST(LNEW) = N1
LIST(LNEW+1) = N2
LIST(LNEW+2) = N3
LPTR(LNEW) = LNEW + 1
LPTR(LNEW+1) = LNEW + 2
LPTR(LNEW+2) = LNEW
LEND(K) = LNEW + 2
LNEW = LNEW + 3
RETURN
END
SUBROUTINE INTRSC (P1,P2,CN, P,IER)
INTEGER IER
REAL(kind=8) P1(3), P2(3), CN(3), P(3)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/19/90
C
C Given a great circle C and points P1 and P2 defining an
C arc A on the surface of the unit sphere, where A is the
C shorter of the two portions of the great circle C12 assoc-
C iated with P1 and P2, this subroutine returns the point
C of intersection P between C and C12 that is closer to A.
C Thus, if P1 and P2 lie in opposite hemispheres defined by
C C, P is the point of intersection of C with A.
C
C
C On input:
C
C P1,P2 = Arrays of length 3 containing the Cartesian
C coordinates of unit vectors.
C
C CN = Array of length 3 containing the Cartesian
C coordinates of a nonzero vector which defines C
C as the intersection of the plane whose normal
C is CN with the unit sphere. Thus, if C is to
C be the great circle defined by P and Q, CN
C should be P X Q.
C
C The above parameters are not altered by this routine.
C
C P = Array of length 3.
C
C On output:
C
C P = Point of intersection defined above unless IER
C .NE. 0, in which case P is not altered.
C
C IER = Error indicator.
C IER = 0 if no errors were encountered.
C IER = 1 if <CN,P1> = <CN,P2>. This occurs
C iff P1 = P2 or CN = 0 or there are
C two intersection points at the same
C distance from A.
C IER = 2 if P2 = -P1 and the definition of A is
C therefore ambiguous.
C
C Modules required by INTRSC: None
C
C Intrinsic function called by INTRSC: SQRT
C
C***********************************************************
C
INTEGER I
REAL(kind=8) D1, D2, PP(3), PPN, T
C
C Local parameters:
C
C D1 = <CN,P1>
C D2 = <CN,P2>
C I = DO-loop index
C PP = P1 + T*(P2-P1) = Parametric representation of the
C line defined by P1 and P2
C PPN = Norm of PP
C T = D1/(D1-D2) = Parameter value chosen so that PP lies
C in the plane of C
C
D1 = CN(1)*P1(1) + CN(2)*P1(2) + CN(3)*P1(3)
D2 = CN(1)*P2(1) + CN(2)*P2(2) + CN(3)*P2(3)
C
IF (D1 .EQ. D2) THEN
IER = 1
RETURN
ENDIF
C
C Solve for T such that <PP,CN> = 0 and compute PP and PPN.
C
T = D1/(D1-D2)
PPN = 0.
DO 1 I = 1,3
PP(I) = P1(I) + T*(P2(I)-P1(I))
PPN = PPN + PP(I)*PP(I)
1 CONTINUE
C
C PPN = 0 iff PP = 0 iff P2 = -P1 (and T = .5).
C
IF (PPN .EQ. 0.) THEN
IER = 2
RETURN
ENDIF
PPN = SQRT(PPN)
C
C Compute P = PP/PPN.
C
DO 2 I = 1,3
P(I) = PP(I)/PPN
2 CONTINUE
IER = 0
RETURN
END
INTEGER FUNCTION JRAND (N, IX,IY,IZ )
INTEGER N, IX, IY, IZ
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/28/98
C
C This function returns a uniformly distributed pseudo-
C random integer in the range 1 to N.
C
C
C On input:
C
C N = Maximum value to be returned.
C
C N is not altered by this function.
C
C IX,IY,IZ = Integer seeds initialized to values in
C the range 1 to 30,000 before the first
C call to JRAND, and not altered between
C subsequent calls (unless a sequence of
C random numbers is to be repeated by
C reinitializing the seeds).
C
C On output:
C
C IX,IY,IZ = Updated integer seeds.
C
C JRAND = Random integer in the range 1 to N.
C
C Reference: B. A. Wichmann and I. D. Hill, "An Efficient
C and Portable Pseudo-random Number Generator",
C Applied Statistics, Vol. 31, No. 2, 1982,
C pp. 188-190.
C
C Modules required by JRAND: None
C
C Intrinsic functions called by JRAND: INT, MOD, REAL
C
C***********************************************************
C
REAL(kind=8) U, X
C
C Local parameters:
C
C U = Pseudo-random number uniformly distributed in the
C interval (0,1).
C X = Pseudo-random number in the range 0 to 3 whose frac-
C tional part is U.
C
IX = MOD(171*IX,30269)
IY = MOD(172*IY,30307)
IZ = MOD(170*IZ,30323)
X = (REAL(IX,8)/30269.) + (REAL(IY,8)/30307.) +
. (REAL(IZ,8)/30323.)
U = X - INT(X)
JRAND = REAL(N,8)*U + 1.
RETURN
END
LOGICAL FUNCTION LEFT (X1,Y1,Z1,X2,Y2,Z2,X0,Y0,Z0)
REAL(kind=8) X1, Y1, Z1, X2, Y2, Z2, X0, Y0, Z0
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/15/96
C
C This function determines whether node N0 is in the
C (closed) left hemisphere defined by the plane containing
C N1, N2, and the origin, where left is defined relative to
C an observer at N1 facing N2.
C
C
C On input:
C
C X1,Y1,Z1 = Coordinates of N1.
C
C X2,Y2,Z2 = Coordinates of N2.
C
C X0,Y0,Z0 = Coordinates of N0.
C
C Input parameters are not altered by this function.
C
C On output:
C
C LEFT = TRUE if and only if N0 is in the closed
C left hemisphere.
C
C Modules required by LEFT: None
C
C***********************************************************
C
C LEFT = TRUE iff <N0,N1 X N2> = det(N0,N1,N2) .GE. 0.
C
LEFT = X0*(Y1*Z2-Y2*Z1) - Y0*(X1*Z2-X2*Z1) +
. Z0*(X1*Y2-X2*Y1) .GE. 0.
RETURN
END
INTEGER FUNCTION LSTPTR (LPL,NB,LIST,LPTR)
INTEGER LPL, NB, LIST(*), LPTR(*)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/15/96
C
C This function returns the index (LIST pointer) of NB in
C the adjacency list for N0, where LPL = LEND(N0).
C
C This function is identical to the similarly named
C function in TRIPACK.
C
C
C On input:
C
C LPL = LEND(N0)
C
C NB = Index of the node whose pointer is to be re-
C turned. NB must be connected to N0.
C
C LIST,LPTR = Data structure defining the triangula-
C tion. Refer to Subroutine TRMESH.
C
C Input parameters are not altered by this function.
C
C On output:
C
C LSTPTR = Pointer such that LIST(LSTPTR) = NB or
C LIST(LSTPTR) = -NB, unless NB is not a
C neighbor of N0, in which case LSTPTR = LPL.
C
C Modules required by LSTPTR: None
C
C***********************************************************
C
INTEGER LP, ND
C
C Local parameters:
C
C LP = LIST pointer
C ND = Nodal index
C
LP = LPTR(LPL)
1 ND = LIST(LP)
IF (ND .EQ. NB) GO TO 2
LP = LPTR(LP)
IF (LP .NE. LPL) GO TO 1
C
2 LSTPTR = LP
RETURN
END
INTEGER FUNCTION NBCNT (LPL,LPTR)
INTEGER LPL, LPTR(*)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/15/96
C
C This function returns the number of neighbors of a node
C N0 in a triangulation created by Subroutine TRMESH.
C
C This function is identical to the similarly named
C function in TRIPACK.
C
C
C On input:
C
C LPL = LIST pointer to the last neighbor of N0 --
C LPL = LEND(N0).
C
C LPTR = Array of pointers associated with LIST.
C
C Input parameters are not altered by this function.
C
C On output:
C
C NBCNT = Number of neighbors of N0.
C
C Modules required by NBCNT: None
C
C***********************************************************
C
INTEGER K, LP
C
C Local parameters:
C
C K = Counter for computing the number of neighbors
C LP = LIST pointer
C
LP = LPL
K = 1
C
1 LP = LPTR(LP)
IF (LP .EQ. LPL) GO TO 2
K = K + 1
GO TO 1
C
2 NBCNT = K
RETURN
END
INTEGER FUNCTION NEARND (P,IST,N,X,Y,Z,LIST,LPTR,
. LEND, AL)
INTEGER IST, N, LIST(*), LPTR(*), LEND(N)
REAL(kind=8) P(3), X(N), Y(N), Z(N), AL
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/28/98
C
C Given a point P on the surface of the unit sphere and a
C Delaunay triangulation created by Subroutine TRMESH, this
C function returns the index of the nearest triangulation
C node to P.
C
C The algorithm consists of implicitly adding P to the
C triangulation, finding the nearest neighbor to P, and
C implicitly deleting P from the triangulation. Thus, it
C is based on the fact that, if P is a node in a Delaunay
C triangulation, the nearest node to P is a neighbor of P.
C
C
C On input:
C
C P = Array of length 3 containing the Cartesian coor-
C dinates of the point P to be located relative to
C the triangulation. It is assumed without a test
C that P(1)**2 + P(2)**2 + P(3)**2 = 1.
C
C IST = Index of a node at which TRFIND begins the
C search. Search time depends on the proximity
C of this node to P.
C
C N = Number of nodes in the triangulation. N .GE. 3.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes.
C
C LIST,LPTR,LEND = Data structure defining the trian-
C gulation. Refer to TRMESH.
C
C Input parameters are not altered by this function.
C
C On output:
C
C NEARND = Nodal index of the nearest node to P, or 0
C if N < 3 or the triangulation data struc-
C ture is invalid.
C
C AL = Arc length (angular distance in radians) be-
C tween P and NEARND unless NEARND = 0.
C
C Note that the number of candidates for NEARND
C (neighbors of P) is limited to LMAX defined in
C the PARAMETER statement below.
C
C Modules required by NEARND: JRAND, LSTPTR, TRFIND, STORE
C
C Intrinsic functions called by NEARND: ABS, ACOS
C
C***********************************************************
C
INTEGER LSTPTR
INTEGER LMAX
PARAMETER (LMAX=25)
INTEGER I1, I2, I3, L, LISTP(LMAX), LP, LP1, LP2,
. LPL, LPTRP(LMAX), N1, N2, N3, NN, NR, NST
REAL(kind=8) B1, B2, B3, DS1, DSR, DX1, DX2, DX3, DY1,
. DY2, DY3, DZ1, DZ2, DZ3
C
C Local parameters:
C
C B1,B2,B3 = Unnormalized barycentric coordinates returned
C by TRFIND
C DS1 = (Negative cosine of the) distance from P to N1
C DSR = (Negative cosine of the) distance from P to NR
C DX1,..DZ3 = Components of vectors used by the swap test
C I1,I2,I3 = Nodal indexes of a triangle containing P, or
C the rightmost (I1) and leftmost (I2) visible
C boundary nodes as viewed from P
C L = Length of LISTP/LPTRP and number of neighbors
C of P
C LMAX = Maximum value of L
C LISTP = Indexes of the neighbors of P
C LPTRP = Array of pointers in 1-1 correspondence with
C LISTP elements
C LP = LIST pointer to a neighbor of N1 and LISTP
C pointer
C LP1,LP2 = LISTP indexes (pointers)
C LPL = Pointer to the last neighbor of N1
C N1 = Index of a node visible from P
C N2 = Index of an endpoint of an arc opposite P
C N3 = Index of the node opposite N1->N2
C NN = Local copy of N
C NR = Index of a candidate for the nearest node to P
C NST = Index of the node at which TRFIND begins the
C search
C
C
C Store local parameters and test for N invalid.
C
NN = N
IF (NN .LT. 3) GO TO 6
NST = IST
IF (NST .LT. 1 .OR. NST .GT. NN) NST = 1
C
C Find a triangle (I1,I2,I3) containing P, or the rightmost
C (I1) and leftmost (I2) visible boundary nodes as viewed
C from P.
C
CALL TRFIND (NST,P,N,X,Y,Z,LIST,LPTR,LEND, B1,B2,B3,
. I1,I2,I3)
C
C Test for collinear nodes.
C
IF (I1 .EQ. 0) GO TO 6
C
C Store the linked list of 'neighbors' of P in LISTP and
C LPTRP. I1 is the first neighbor, and 0 is stored as
C the last neighbor if P is not contained in a triangle.
C L is the length of LISTP and LPTRP, and is limited to
C LMAX.
C
IF (I3 .NE. 0) THEN
LISTP(1) = I1
LPTRP(1) = 2
LISTP(2) = I2
LPTRP(2) = 3
LISTP(3) = I3
LPTRP(3) = 1
L = 3
ELSE
N1 = I1
L = 1
LP1 = 2
LISTP(L) = N1
LPTRP(L) = LP1
C
C Loop on the ordered sequence of visible boundary nodes
C N1 from I1 to I2.
C
1 LPL = LEND(N1)
N1 = -LIST(LPL)
L = LP1
LP1 = L+1
LISTP(L) = N1
LPTRP(L) = LP1
IF (N1 .NE. I2 .AND. LP1 .LT. LMAX) GO TO 1
L = LP1
LISTP(L) = 0
LPTRP(L) = 1
ENDIF
C
C Initialize variables for a loop on arcs N1-N2 opposite P
C in which new 'neighbors' are 'swapped' in. N1 follows
C N2 as a neighbor of P, and LP1 and LP2 are the LISTP
C indexes of N1 and N2.
C
LP2 = 1
N2 = I1
LP1 = LPTRP(1)
N1 = LISTP(LP1)
C
C Begin loop: find the node N3 opposite N1->N2.
C
2 LP = LSTPTR(LEND(N1),N2,LIST,LPTR)
IF (LIST(LP) .LT. 0) GO TO 3
LP = LPTR(LP)
N3 = ABS(LIST(LP))
C
C Swap test: Exit the loop if L = LMAX.
C
IF (L .EQ. LMAX) GO TO 4
DX1 = X(N1) - P(1)
DY1 = Y(N1) - P(2)
DZ1 = Z(N1) - P(3)
C
DX2 = X(N2) - P(1)
DY2 = Y(N2) - P(2)
DZ2 = Z(N2) - P(3)
C
DX3 = X(N3) - P(1)
DY3 = Y(N3) - P(2)
DZ3 = Z(N3) - P(3)
IF ( DX3*(DY2*DZ1 - DY1*DZ2) -
. DY3*(DX2*DZ1 - DX1*DZ2) +
. DZ3*(DX2*DY1 - DX1*DY2) .LE. 0. ) GO TO 3
C
C Swap: Insert N3 following N2 in the adjacency list for P.
C The two new arcs opposite P must be tested.
C
L = L+1
LPTRP(LP2) = L
LISTP(L) = N3
LPTRP(L) = LP1
LP1 = L
N1 = N3
GO TO 2
C
C No swap: Advance to the next arc and test for termination
C on N1 = I1 (LP1 = 1) or N1 followed by 0.
C
3 IF (LP1 .EQ. 1) GO TO 4
LP2 = LP1
N2 = N1
LP1 = LPTRP(LP1)
N1 = LISTP(LP1)
IF (N1 .EQ. 0) GO TO 4
GO TO 2
C
C Set NR and DSR to the index of the nearest node to P and
C an increasing function (negative cosine) of its distance
C from P, respectively.
C
4 NR = I1
DSR = -(X(NR)*P(1) + Y(NR)*P(2) + Z(NR)*P(3))
DO 5 LP = 2,L
N1 = LISTP(LP)
IF (N1 .EQ. 0) GO TO 5
DS1 = -(X(N1)*P(1) + Y(N1)*P(2) + Z(N1)*P(3))
IF (DS1 .LT. DSR) THEN
NR = N1
DSR = DS1
ENDIF
5 CONTINUE
DSR = -DSR
IF (DSR .GT. 1.0) DSR = 1.0
AL = ACOS(DSR)
NEARND = NR
RETURN
C
C Invalid input.
C
6 NEARND = 0
RETURN
END
SUBROUTINE OPTIM (X,Y,Z,NA, LIST,LPTR,LEND,NIT,
. IWK, IER)
INTEGER NA, LIST(*), LPTR(*), LEND(*), NIT, IWK(2,NA),
. IER
REAL(kind=8) X(*), Y(*), Z(*)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/30/98
C
C Given a set of NA triangulation arcs, this subroutine
C optimizes the portion of the triangulation consisting of
C the quadrilaterals (pairs of adjacent triangles) which
C have the arcs as diagonals by applying the circumcircle
C test and appropriate swaps to the arcs.
C
C An iteration consists of applying the swap test and
C swaps to all NA arcs in the order in which they are
C stored. The iteration is repeated until no swap occurs
C or NIT iterations have been performed. The bound on the
C number of iterations may be necessary to prevent an
C infinite loop caused by cycling (reversing the effect of a
C previous swap) due to floating point inaccuracy when four
C or more nodes are nearly cocircular.
C
C
C On input:
C
C X,Y,Z = Arrays containing the nodal coordinates.
C
C NA = Number of arcs in the set. NA .GE. 0.
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR,LEND = Data structure defining the trian-
C gulation. Refer to Subroutine
C TRMESH.
C
C NIT = Maximum number of iterations to be performed.
C NIT = 4*NA should be sufficient. NIT .GE. 1.
C
C IWK = Integer array dimensioned 2 by NA containing
C the nodal indexes of the arc endpoints (pairs
C of endpoints are stored in columns).
C
C On output:
C
C LIST,LPTR,LEND = Updated triangulation data struc-
C ture reflecting the swaps.
C
C NIT = Number of iterations performed.
C
C IWK = Endpoint indexes of the new set of arcs
C reflecting the swaps.
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if a swap occurred on the last of
C MAXIT iterations, where MAXIT is the
C value of NIT on input. The new set
C of arcs is not necessarily optimal
C in this case.
C IER = 2 if NA < 0 or NIT < 1 on input.
C IER = 3 if IWK(2,I) is not a neighbor of
C IWK(1,I) for some I in the range 1
C to NA. A swap may have occurred in
C this case.
C IER = 4 if a zero pointer was returned by
C Subroutine SWAP.
C
C Modules required by OPTIM: LSTPTR, SWAP, SWPTST
C
C Intrinsic function called by OPTIM: ABS
C
C***********************************************************
C
INTEGER I, IO1, IO2, ITER, LP, LP21, LPL, LPP, MAXIT,
. N1, N2, NNA
LOGICAL SWPTST
LOGICAL SWP
C
C Local parameters:
C
C I = Column index for IWK
C IO1,IO2 = Nodal indexes of the endpoints of an arc in IWK
C ITER = Iteration count
C LP = LIST pointer
C LP21 = Parameter returned by SWAP (not used)
C LPL = Pointer to the last neighbor of IO1
C LPP = Pointer to the node preceding IO2 as a neighbor
C of IO1
C MAXIT = Input value of NIT
C N1,N2 = Nodes opposite IO1->IO2 and IO2->IO1,
C respectively
C NNA = Local copy of NA
C SWP = Flag set to TRUE iff a swap occurs in the
C optimization loop
C
NNA = NA
MAXIT = NIT
IF (NNA .LT. 0 .OR. MAXIT .LT. 1) GO TO 7
C
C Initialize iteration count ITER and test for NA = 0.
C
ITER = 0
IF (NNA .EQ. 0) GO TO 5
C
C Top of loop --
C SWP = TRUE iff a swap occurred in the current iteration.
C
1 IF (ITER .EQ. MAXIT) GO TO 6
ITER = ITER + 1
SWP = .FALSE.
C
C Inner loop on arcs IO1-IO2 --
C
DO 4 I = 1,NNA
IO1 = IWK(1,I)
IO2 = IWK(2,I)
C
C Set N1 and N2 to the nodes opposite IO1->IO2 and
C IO2->IO1, respectively. Determine the following:
C
C LPL = pointer to the last neighbor of IO1,
C LP = pointer to IO2 as a neighbor of IO1, and
C LPP = pointer to the node N2 preceding IO2.
C
LPL = LEND(IO1)
LPP = LPL
LP = LPTR(LPP)
2 IF (LIST(LP) .EQ. IO2) GO TO 3
LPP = LP
LP = LPTR(LPP)
IF (LP .NE. LPL) GO TO 2
C
C IO2 should be the last neighbor of IO1. Test for no
C arc and bypass the swap test if IO1 is a boundary
C node.
C
IF (ABS(LIST(LP)) .NE. IO2) GO TO 8
IF (LIST(LP) .LT. 0) GO TO 4
C
C Store N1 and N2, or bypass the swap test if IO1 is a
C boundary node and IO2 is its first neighbor.
C
3 N2 = LIST(LPP)
IF (N2 .LT. 0) GO TO 4
LP = LPTR(LP)
N1 = ABS(LIST(LP))
C
C Test IO1-IO2 for a swap, and update IWK if necessary.
C
IF ( .NOT. SWPTST(N1,N2,IO1,IO2,X,Y,Z) ) GO TO 4
CALL SWAP (N1,N2,IO1,IO2, LIST,LPTR,LEND, LP21)
IF (LP21 .EQ. 0) GO TO 9
SWP = .TRUE.
IWK(1,I) = N1
IWK(2,I) = N2
4 CONTINUE
IF (SWP) GO TO 1
C
C Successful termination.
C
5 NIT = ITER
IER = 0
RETURN
C
C MAXIT iterations performed without convergence.
C
6 NIT = MAXIT
IER = 1
RETURN
C
C Invalid input parameter.
C
7 NIT = 0
IER = 2
RETURN
C
C IO2 is not a neighbor of IO1.
C
8 NIT = ITER
IER = 3
RETURN
C
C Zero pointer returned by SWAP.
C
9 NIT = ITER
IER = 4
RETURN
END
SUBROUTINE SCOORD (PX,PY,PZ, PLAT,PLON,PNRM)
REAL(kind=8) PX, PY, PZ, PLAT, PLON, PNRM
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 08/27/90
C
C This subroutine converts a point P from Cartesian coor-
C dinates to spherical coordinates.
C
C
C On input:
C
C PX,PY,PZ = Cartesian coordinates of P.
C
C Input parameters are not altered by this routine.
C
C On output:
C
C PLAT = Latitude of P in the range -PI/2 to PI/2, or
C 0 if PNRM = 0. PLAT should be scaled by
C 180/PI to obtain the value in degrees.
C
C PLON = Longitude of P in the range -PI to PI, or 0
C if P lies on the Z-axis. PLON should be
C scaled by 180/PI to obtain the value in
C degrees.
C
C PNRM = Magnitude (Euclidean norm) of P.
C
C Modules required by SCOORD: None
C
C Intrinsic functions called by SCOORD: ASIN, ATAN2, SQRT
C
C***********************************************************
C
PNRM = SQRT(PX*PX + PY*PY + PZ*PZ)
IF (PX .NE. 0. .OR. PY .NE. 0.) THEN
PLON = ATAN2(PY,PX)
ELSE
PLON = 0.
ENDIF
IF (PNRM .NE. 0.) THEN
PLAT = ASIN(PZ/PNRM)
ELSE
PLAT = 0.
ENDIF
RETURN
END
REAL(kind=8) FUNCTION STORE (X)
REAL(kind=8) X
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 05/09/92
C
C This function forces its argument X to be stored in a
C memory location, thus providing a means of determining
C floating point number characteristics (such as the machine
C precision) when it is necessary to avoid computation in
C high precision registers.
C
C
C On input:
C
C X = Value to be stored.
C
C X is not altered by this function.
C
C On output:
C
C STORE = Value of X after it has been stored and
C possibly truncated or rounded to the single
C precision word length.
C
C Modules required by STORE: None
C
C***********************************************************
C
REAL(kind=8) Y
COMMON/STCOM/Y
Y = X
STORE = Y
RETURN
END
SUBROUTINE SWAP (IN1,IN2,IO1,IO2, LIST,LPTR,
. LEND, LP21)
INTEGER IN1, IN2, IO1, IO2, LIST(*), LPTR(*), LEND(*),
. LP21
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 06/22/98
C
C Given a triangulation of a set of points on the unit
C sphere, this subroutine replaces a diagonal arc in a
C strictly convex quadrilateral (defined by a pair of adja-
C cent triangles) with the other diagonal. Equivalently, a
C pair of adjacent triangles is replaced by another pair
C having the same union.
C
C
C On input:
C
C IN1,IN2,IO1,IO2 = Nodal indexes of the vertices of
C the quadrilateral. IO1-IO2 is re-
C placed by IN1-IN2. (IO1,IO2,IN1)
C and (IO2,IO1,IN2) must be trian-
C gles on input.
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR,LEND = Data structure defining the trian-
C gulation. Refer to Subroutine
C TRMESH.
C
C On output:
C
C LIST,LPTR,LEND = Data structure updated with the
C swap -- triangles (IO1,IO2,IN1) and
C (IO2,IO1,IN2) are replaced by
C (IN1,IN2,IO2) and (IN2,IN1,IO1)
C unless LP21 = 0.
C
C LP21 = Index of IN1 as a neighbor of IN2 after the
C swap is performed unless IN1 and IN2 are
C adjacent on input, in which case LP21 = 0.
C
C Module required by SWAP: LSTPTR
C
C Intrinsic function called by SWAP: ABS
C
C***********************************************************
C
INTEGER LSTPTR
INTEGER LP, LPH, LPSAV
C
C Local parameters:
C
C LP,LPH,LPSAV = LIST pointers
C
C
C Test for IN1 and IN2 adjacent.
C
LP = LSTPTR(LEND(IN1),IN2,LIST,LPTR)
IF (ABS(LIST(LP)) .EQ. IN2) THEN
LP21 = 0
RETURN
ENDIF
C
C Delete IO2 as a neighbor of IO1.
C
LP = LSTPTR(LEND(IO1),IN2,LIST,LPTR)
LPH = LPTR(LP)
LPTR(LP) = LPTR(LPH)
C
C If IO2 is the last neighbor of IO1, make IN2 the
C last neighbor.
C
IF (LEND(IO1) .EQ. LPH) LEND(IO1) = LP
C
C Insert IN2 as a neighbor of IN1 following IO1
C using the hole created above.
C
LP = LSTPTR(LEND(IN1),IO1,LIST,LPTR)
LPSAV = LPTR(LP)
LPTR(LP) = LPH
LIST(LPH) = IN2
LPTR(LPH) = LPSAV
C
C Delete IO1 as a neighbor of IO2.
C
LP = LSTPTR(LEND(IO2),IN1,LIST,LPTR)
LPH = LPTR(LP)
LPTR(LP) = LPTR(LPH)
C
C If IO1 is the last neighbor of IO2, make IN1 the
C last neighbor.
C
IF (LEND(IO2) .EQ. LPH) LEND(IO2) = LP
C
C Insert IN1 as a neighbor of IN2 following IO2.
C
LP = LSTPTR(LEND(IN2),IO2,LIST,LPTR)
LPSAV = LPTR(LP)
LPTR(LP) = LPH
LIST(LPH) = IN1
LPTR(LPH) = LPSAV
LP21 = LPH
RETURN
END
LOGICAL FUNCTION SWPTST (N1,N2,N3,N4,X,Y,Z)
INTEGER N1, N2, N3, N4
REAL(kind=8) X(*), Y(*), Z(*)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 03/29/91
C
C This function decides whether or not to replace a
C diagonal arc in a quadrilateral with the other diagonal.
C The decision will be to swap (SWPTST = TRUE) if and only
C if N4 lies above the plane (in the half-space not contain-
C ing the origin) defined by (N1,N2,N3), or equivalently, if
C the projection of N4 onto this plane is interior to the
C circumcircle of (N1,N2,N3). The decision will be for no
C swap if the quadrilateral is not strictly convex.
C
C
C On input:
C
C N1,N2,N3,N4 = Indexes of the four nodes defining the
C quadrilateral with N1 adjacent to N2,
C and (N1,N2,N3) in counterclockwise
C order. The arc connecting N1 to N2
C should be replaced by an arc connec-
C ting N3 to N4 if SWPTST = TRUE. Refer
C to Subroutine SWAP.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes. (X(I),Y(I),Z(I))
C define node I for I = N1, N2, N3, and N4.
C
C Input parameters are not altered by this routine.
C
C On output:
C
C SWPTST = TRUE if and only if the arc connecting N1
C and N2 should be swapped for an arc con-
C necting N3 and N4.
C
C Modules required by SWPTST: None
C
C***********************************************************
C
REAL(kind=8) DX1, DX2, DX3, DY1, DY2, DY3, DZ1, DZ2, DZ3,
. X4, Y4, Z4
C
C Local parameters:
C
C DX1,DY1,DZ1 = Coordinates of N4->N1
C DX2,DY2,DZ2 = Coordinates of N4->N2
C DX3,DY3,DZ3 = Coordinates of N4->N3
C X4,Y4,Z4 = Coordinates of N4
C
X4 = X(N4)
Y4 = Y(N4)
Z4 = Z(N4)
DX1 = X(N1) - X4
DX2 = X(N2) - X4
DX3 = X(N3) - X4
DY1 = Y(N1) - Y4
DY2 = Y(N2) - Y4
DY3 = Y(N3) - Y4
DZ1 = Z(N1) - Z4
DZ2 = Z(N2) - Z4
DZ3 = Z(N3) - Z4
C
C N4 lies above the plane of (N1,N2,N3) iff N3 lies above
C the plane of (N2,N1,N4) iff Det(N3-N4,N2-N4,N1-N4) =
C (N3-N4,N2-N4 X N1-N4) > 0.
C
SWPTST = DX3*(DY2*DZ1 - DY1*DZ2)
. -DY3*(DX2*DZ1 - DX1*DZ2)
. +DZ3*(DX2*DY1 - DX1*DY2) .GT. 0.
RETURN
END
SUBROUTINE TRANS (N,RLAT,RLON, X,Y,Z)
INTEGER N
REAL(kind=8) RLAT(N), RLON(N), X(N), Y(N), Z(N)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 04/08/90
C
C This subroutine transforms spherical coordinates into
C Cartesian coordinates on the unit sphere for input to
C Subroutine TRMESH. Storage for X and Y may coincide with
C storage for RLAT and RLON if the latter need not be saved.
C
C
C On input:
C
C N = Number of nodes (points on the unit sphere)
C whose coordinates are to be transformed.
C
C RLAT = Array of length N containing latitudinal
C coordinates of the nodes in radians.
C
C RLON = Array of length N containing longitudinal
C coordinates of the nodes in radians.
C
C The above parameters are not altered by this routine.
C
C X,Y,Z = Arrays of length at least N.
C
C On output:
C
C X,Y,Z = Cartesian coordinates in the range -1 to 1.
C X(I)**2 + Y(I)**2 + Z(I)**2 = 1 for I = 1
C to N.
C
C Modules required by TRANS: None
C
C Intrinsic functions called by TRANS: COS, SIN
C
C***********************************************************
C
INTEGER I, NN
REAL(kind=8) COSPHI, PHI, THETA
C
C Local parameters:
C
C COSPHI = cos(PHI)
C I = DO-loop index
C NN = Local copy of N
C PHI = Latitude
C THETA = Longitude
C
NN = N
DO 1 I = 1,NN
PHI = RLAT(I)
THETA = RLON(I)
COSPHI = COS(PHI)
X(I) = COSPHI*COS(THETA)
Y(I) = COSPHI*SIN(THETA)
Z(I) = SIN(PHI)
1 CONTINUE
RETURN
END
SUBROUTINE TRFIND (NST,P,N,X,Y,Z,LIST,LPTR,LEND, B1,
. B2,B3,I1,I2,I3)
INTEGER NST, N, LIST(*), LPTR(*), LEND(N), I1, I2, I3
REAL(kind=8) P(3), X(N), Y(N), Z(N), B1, B2, B3
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 11/30/99
C
C This subroutine locates a point P relative to a triangu-
C lation created by Subroutine TRMESH. If P is contained in
C a triangle, the three vertex indexes and barycentric coor-
C dinates are returned. Otherwise, the indexes of the
C visible boundary nodes are returned.
C
C
C On input:
C
C NST = Index of a node at which TRFIND begins its
C search. Search time depends on the proximity
C of this node to P.
C
C P = Array of length 3 containing the x, y, and z
C coordinates (in that order) of the point P to be
C located.
C
C N = Number of nodes in the triangulation. N .GE. 3.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the triangulation nodes (unit
C vectors). (X(I),Y(I),Z(I)) defines node I
C for I = 1 to N.
C
C LIST,LPTR,LEND = Data structure defining the trian-
C gulation. Refer to Subroutine
C TRMESH.
C
C Input parameters are not altered by this routine.
C
C On output:
C
C B1,B2,B3 = Unnormalized barycentric coordinates of
C the central projection of P onto the un-
C derlying planar triangle if P is in the
C convex hull of the nodes. These parame-
C ters are not altered if I1 = 0.
C
C I1,I2,I3 = Counterclockwise-ordered vertex indexes
C of a triangle containing P if P is con-
C tained in a triangle. If P is not in the
C convex hull of the nodes, I1 and I2 are
C the rightmost and leftmost (boundary)
C nodes that are visible from P, and
C I3 = 0. (If all boundary nodes are vis-
C ible from P, then I1 and I2 coincide.)
C I1 = I2 = I3 = 0 if P and all of the
C nodes are coplanar (lie on a common great
C circle.
C
C Modules required by TRFIND: JRAND, LSTPTR, STORE
C
C Intrinsic function called by TRFIND: ABS
C
C***********************************************************
C
INTEGER JRAND, LSTPTR
INTEGER IX, IY, IZ, LP, N0, N1, N1S, N2, N2S, N3, N4,
. NEXT, NF, NL
REAL(kind=8) STORE
REAL(kind=8) DET, EPS, PTN1, PTN2, Q(3), S12, TOL, XP, YP,
. ZP
REAL(kind=8) X0, X1, X2, Y0, Y1, Y2, Z0, Z1, Z2
C
SAVE IX, IY, IZ
DATA IX/1/, IY/2/, IZ/3/
C
C Local parameters:
C
C EPS = Machine precision
C IX,IY,IZ = Integer seeds for JRAND
C LP = LIST pointer
C N0,N1,N2 = Nodes in counterclockwise order defining a
C cone (with vertex N0) containing P, or end-
C points of a boundary edge such that P Right
C N1->N2
C N1S,N2S = Initially-determined values of N1 and N2
C N3,N4 = Nodes opposite N1->N2 and N2->N1, respectively
C NEXT = Candidate for I1 or I2 when P is exterior
C NF,NL = First and last neighbors of N0, or first
C (rightmost) and last (leftmost) nodes
C visible from P when P is exterior to the
C triangulation
C PTN1 = Scalar product <P,N1>
C PTN2 = Scalar product <P,N2>
C Q = (N2 X N1) X N2 or N1 X (N2 X N1) -- used in
C the boundary traversal when P is exterior
C S12 = Scalar product <N1,N2>
C TOL = Tolerance (multiple of EPS) defining an upper
C bound on the magnitude of a negative bary-
C centric coordinate (B1 or B2) for P in a
C triangle -- used to avoid an infinite number
C of restarts with 0 <= B3 < EPS and B1 < 0 or
C B2 < 0 but small in magnitude
C XP,YP,ZP = Local variables containing P(1), P(2), and P(3)
C X0,Y0,Z0 = Dummy arguments for DET
C X1,Y1,Z1 = Dummy arguments for DET
C X2,Y2,Z2 = Dummy arguments for DET
C
C Statement function:
C
C DET(X1,...,Z0) .GE. 0 if and only if (X0,Y0,Z0) is in the
C (closed) left hemisphere defined by
C the plane containing (0,0,0),
C (X1,Y1,Z1), and (X2,Y2,Z2), where
C left is defined relative to an ob-
C server at (X1,Y1,Z1) facing
C (X2,Y2,Z2).
C
DET (X1,Y1,Z1,X2,Y2,Z2,X0,Y0,Z0) = X0*(Y1*Z2-Y2*Z1)
. - Y0*(X1*Z2-X2*Z1) + Z0*(X1*Y2-X2*Y1)
C
C Initialize variables.
C
XP = P(1)
YP = P(2)
ZP = P(3)
N0 = NST
IF (N0 .LT. 1 .OR. N0 .GT. N)
. N0 = JRAND(N, IX,IY,IZ )
C
C Compute the relative machine precision EPS and TOL.
C
EPS = 1.E0
1 EPS = EPS/2.E0
IF (STORE(EPS+1.E0) .GT. 1.E0) GO TO 1
EPS = 2.E0*EPS
TOL = 100.E0*EPS
C
C Set NF and NL to the first and last neighbors of N0, and
C initialize N1 = NF.
C
2 LP = LEND(N0)
NL = LIST(LP)
LP = LPTR(LP)
NF = LIST(LP)
N1 = NF
C
C Find a pair of adjacent neighbors N1,N2 of N0 that define
C a wedge containing P: P LEFT N0->N1 and P RIGHT N0->N2.
C
IF (NL .GT. 0) THEN
C
C N0 is an interior node. Find N1.
C
3 IF ( DET(X(N0),Y(N0),Z(N0),X(N1),Y(N1),Z(N1),
. XP,YP,ZP) .LT. 0. ) THEN
LP = LPTR(LP)
N1 = LIST(LP)
IF (N1 .EQ. NL) GO TO 6
GO TO 3
ENDIF
ELSE
C
C N0 is a boundary node. Test for P exterior.
C
NL = -NL
IF ( DET(X(N0),Y(N0),Z(N0),X(NF),Y(NF),Z(NF),
. XP,YP,ZP) .LT. 0. ) THEN
C
C P is to the right of the boundary edge N0->NF.
C
N1 = N0
N2 = NF
GO TO 9
ENDIF
IF ( DET(X(NL),Y(NL),Z(NL),X(N0),Y(N0),Z(N0),
. XP,YP,ZP) .LT. 0. ) THEN
C
C P is to the right of the boundary edge NL->N0.
C
N1 = NL
N2 = N0
GO TO 9
ENDIF
ENDIF
C
C P is to the left of arcs N0->N1 and NL->N0. Set N2 to the
C next neighbor of N0 (following N1).
C
4 LP = LPTR(LP)
N2 = ABS(LIST(LP))
IF ( DET(X(N0),Y(N0),Z(N0),X(N2),Y(N2),Z(N2),
. XP,YP,ZP) .LT. 0. ) GO TO 7
N1 = N2
IF (N1 .NE. NL) GO TO 4
IF ( DET(X(N0),Y(N0),Z(N0),X(NF),Y(NF),Z(NF),
. XP,YP,ZP) .LT. 0. ) GO TO 6
C
C P is left of or on arcs N0->NB for all neighbors NB
C of N0. Test for P = +/-N0.
C
IF (STORE(ABS(X(N0)*XP + Y(N0)*YP + Z(N0)*ZP))
. .LT. 1.0-4.0*EPS) THEN
C
C All points are collinear iff P Left NB->N0 for all
C neighbors NB of N0. Search the neighbors of N0.
C Note: N1 = NL and LP points to NL.
C
5 IF ( DET(X(N1),Y(N1),Z(N1),X(N0),Y(N0),Z(N0),
. XP,YP,ZP) .GE. 0. ) THEN
LP = LPTR(LP)
N1 = ABS(LIST(LP))
IF (N1 .EQ. NL) GO TO 14
GO TO 5
ENDIF
ENDIF
C
C P is to the right of N1->N0, or P = +/-N0. Set N0 to N1
C and start over.
C
N0 = N1
GO TO 2
C
C P is between arcs N0->N1 and N0->NF.
C
6 N2 = NF
C
C P is contained in a wedge defined by geodesics N0-N1 and
C N0-N2, where N1 is adjacent to N2. Save N1 and N2 to
C test for cycling.
C
7 N3 = N0
N1S = N1
N2S = N2
C
C Top of edge-hopping loop:
C
8 B3 = DET(X(N1),Y(N1),Z(N1),X(N2),Y(N2),Z(N2),XP,YP,ZP)
IF (B3 .LT. 0.) THEN
C
C Set N4 to the first neighbor of N2 following N1 (the
C node opposite N2->N1) unless N1->N2 is a boundary arc.
C
LP = LSTPTR(LEND(N2),N1,LIST,LPTR)
IF (LIST(LP) .LT. 0) GO TO 9
LP = LPTR(LP)
N4 = ABS(LIST(LP))
C
C Define a new arc N1->N2 which intersects the geodesic
C N0-P.
C
IF ( DET(X(N0),Y(N0),Z(N0),X(N4),Y(N4),Z(N4),
. XP,YP,ZP) .LT. 0. ) THEN
N3 = N2
N2 = N4
N1S = N1
IF (N2 .NE. N2S .AND. N2 .NE. N0) GO TO 8
ELSE
N3 = N1
N1 = N4
N2S = N2
IF (N1 .NE. N1S .AND. N1 .NE. N0) GO TO 8
ENDIF
C
C The starting node N0 or edge N1-N2 was encountered
C again, implying a cycle (infinite loop). Restart
C with N0 randomly selected.
C
N0 = JRAND(N, IX,IY,IZ )
GO TO 2
ENDIF
C
C P is in (N1,N2,N3) unless N0, N1, N2, and P are collinear
C or P is close to -N0.
C
IF (B3 .GE. EPS) THEN
C
C B3 .NE. 0.
C
B1 = DET(X(N2),Y(N2),Z(N2),X(N3),Y(N3),Z(N3),
. XP,YP,ZP)
B2 = DET(X(N3),Y(N3),Z(N3),X(N1),Y(N1),Z(N1),
. XP,YP,ZP)
IF (B1 .LT. -TOL .OR. B2 .LT. -TOL) THEN
C
C Restart with N0 randomly selected.
C
N0 = JRAND(N, IX,IY,IZ )
GO TO 2
ENDIF
ELSE
C
C B3 = 0 and thus P lies on N1->N2. Compute
C B1 = Det(P,N2 X N1,N2) and B2 = Det(P,N1,N2 X N1).
C
B3 = 0.
S12 = X(N1)*X(N2) + Y(N1)*Y(N2) + Z(N1)*Z(N2)
PTN1 = XP*X(N1) + YP*Y(N1) + ZP*Z(N1)
PTN2 = XP*X(N2) + YP*Y(N2) + ZP*Z(N2)
B1 = PTN1 - S12*PTN2
B2 = PTN2 - S12*PTN1
IF (B1 .LT. -TOL .OR. B2 .LT. -TOL) THEN
C
C Restart with N0 randomly selected.
C
N0 = JRAND(N, IX,IY,IZ )
GO TO 2
ENDIF
ENDIF
C
C P is in (N1,N2,N3).
C
I1 = N1
I2 = N2
I3 = N3
IF (B1 .LT. 0.0) B1 = 0.0
IF (B2 .LT. 0.0) B2 = 0.0
RETURN
C
C P Right N1->N2, where N1->N2 is a boundary edge.
C Save N1 and N2, and set NL = 0 to indicate that
C NL has not yet been found.
C
9 N1S = N1
N2S = N2
NL = 0
C
C Counterclockwise Boundary Traversal:
C
10 LP = LEND(N2)
LP = LPTR(LP)
NEXT = LIST(LP)
IF ( DET(X(N2),Y(N2),Z(N2),X(NEXT),Y(NEXT),Z(NEXT),
. XP,YP,ZP) .GE. 0. ) THEN
C
C N2 is the rightmost visible node if P Forward N2->N1
C or NEXT Forward N2->N1. Set Q to (N2 X N1) X N2.
C
S12 = X(N1)*X(N2) + Y(N1)*Y(N2) + Z(N1)*Z(N2)
Q(1) = X(N1) - S12*X(N2)
Q(2) = Y(N1) - S12*Y(N2)
Q(3) = Z(N1) - S12*Z(N2)
IF (XP*Q(1) + YP*Q(2) + ZP*Q(3) .GE. 0.) GO TO 11
IF (X(NEXT)*Q(1) + Y(NEXT)*Q(2) + Z(NEXT)*Q(3)
. .GE. 0.) GO TO 11
C
C N1, N2, NEXT, and P are nearly collinear, and N2 is
C the leftmost visible node.
C
NL = N2
ENDIF
C
C Bottom of counterclockwise loop:
C
N1 = N2
N2 = NEXT
IF (N2 .NE. N1S) GO TO 10
C
C All boundary nodes are visible from P.
C
I1 = N1S
I2 = N1S
I3 = 0
RETURN
C
C N2 is the rightmost visible node.
C
11 NF = N2
IF (NL .EQ. 0) THEN
C
C Restore initial values of N1 and N2, and begin the search
C for the leftmost visible node.
C
N2 = N2S
N1 = N1S
C
C Clockwise Boundary Traversal:
C
12 LP = LEND(N1)
NEXT = -LIST(LP)
IF ( DET(X(NEXT),Y(NEXT),Z(NEXT),X(N1),Y(N1),Z(N1),
. XP,YP,ZP) .GE. 0. ) THEN
C
C N1 is the leftmost visible node if P or NEXT is
C forward of N1->N2. Compute Q = N1 X (N2 X N1).
C
S12 = X(N1)*X(N2) + Y(N1)*Y(N2) + Z(N1)*Z(N2)
Q(1) = X(N2) - S12*X(N1)
Q(2) = Y(N2) - S12*Y(N1)
Q(3) = Z(N2) - S12*Z(N1)
IF (XP*Q(1) + YP*Q(2) + ZP*Q(3) .GE. 0.) GO TO 13
IF (X(NEXT)*Q(1) + Y(NEXT)*Q(2) + Z(NEXT)*Q(3)
. .GE. 0.) GO TO 13
C
C P, NEXT, N1, and N2 are nearly collinear and N1 is the
C rightmost visible node.
C
NF = N1
ENDIF
C
C Bottom of clockwise loop:
C
N2 = N1
N1 = NEXT
IF (N1 .NE. N1S) GO TO 12
C
C All boundary nodes are visible from P.
C
I1 = N1
I2 = N1
I3 = 0
RETURN
C
C N1 is the leftmost visible node.
C
13 NL = N1
ENDIF
C
C NF and NL have been found.
C
I1 = NF
I2 = NL
I3 = 0
RETURN
C
C All points are collinear (coplanar).
C
14 I1 = 0
I2 = 0
I3 = 0
RETURN
END
SUBROUTINE TRLIST (N,LIST,LPTR,LEND,NROW, NT,LTRI,IER)
INTEGER N, LIST(*), LPTR(*), LEND(N), NROW, NT,
. LTRI(NROW,*), IER
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/20/96
C
C This subroutine converts a triangulation data structure
C from the linked list created by Subroutine TRMESH to a
C triangle list.
C
C On input:
C
C N = Number of nodes in the triangulation. N .GE. 3.
C
C LIST,LPTR,LEND = Linked list data structure defin-
C ing the triangulation. Refer to
C Subroutine TRMESH.
C
C NROW = Number of rows (entries per triangle) re-
C served for the triangle list LTRI. The value
C must be 6 if only the vertex indexes and
C neighboring triangle indexes are to be
C stored, or 9 if arc indexes are also to be
C assigned and stored. Refer to LTRI.
C
C The above parameters are not altered by this routine.
C
C LTRI = Integer array of length at least NROW*NT,
C where NT is at most 2N-4. (A sufficient
C length is 12N if NROW=6 or 18N if NROW=9.)
C
C On output:
C
C NT = Number of triangles in the triangulation unless
C IER .NE. 0, in which case NT = 0. NT = 2N-NB-2
C if NB .GE. 3 or 2N-4 if NB = 0, where NB is the
C number of boundary nodes.
C
C LTRI = NROW by NT array whose J-th column contains
C the vertex nodal indexes (first three rows),
C neighboring triangle indexes (second three
C rows), and, if NROW = 9, arc indexes (last
C three rows) associated with triangle J for
C J = 1,...,NT. The vertices are ordered
C counterclockwise with the first vertex taken
C to be the one with smallest index. Thus,
C LTRI(2,J) and LTRI(3,J) are larger than
C LTRI(1,J) and index adjacent neighbors of
C node LTRI(1,J). For I = 1,2,3, LTRI(I+3,J)
C and LTRI(I+6,J) index the triangle and arc,
C respectively, which are opposite (not shared
C by) node LTRI(I,J), with LTRI(I+3,J) = 0 if
C LTRI(I+6,J) indexes a boundary arc. Vertex
C indexes range from 1 to N, triangle indexes
C from 0 to NT, and, if included, arc indexes
C from 1 to NA, where NA = 3N-NB-3 if NB .GE. 3
C or 3N-6 if NB = 0. The triangles are or-
C dered on first (smallest) vertex indexes.
C
C IER = Error indicator.
C IER = 0 if no errors were encountered.
C IER = 1 if N or NROW is outside its valid
C range on input.
C IER = 2 if the triangulation data structure
C (LIST,LPTR,LEND) is invalid. Note,
C however, that these arrays are not
C completely tested for validity.
C
C Modules required by TRLIST: None
C
C Intrinsic function called by TRLIST: ABS
C
C***********************************************************
C
INTEGER I, I1, I2, I3, ISV, J, KA, KN, KT, LP, LP2,
. LPL, LPLN1, N1, N2, N3, NM2
LOGICAL ARCS
C
C Local parameters:
C
C ARCS = Logical variable with value TRUE iff are
C indexes are to be stored
C I,J = LTRI row indexes (1 to 3) associated with
C triangles KT and KN, respectively
C I1,I2,I3 = Nodal indexes of triangle KN
C ISV = Variable used to permute indexes I1,I2,I3
C KA = Arc index and number of currently stored arcs
C KN = Index of the triangle that shares arc I1-I2
C with KT
C KT = Triangle index and number of currently stored
C triangles
C LP = LIST pointer
C LP2 = Pointer to N2 as a neighbor of N1
C LPL = Pointer to the last neighbor of I1
C LPLN1 = Pointer to the last neighbor of N1
C N1,N2,N3 = Nodal indexes of triangle KT
C NM2 = N-2
C
C
C Test for invalid input parameters.
C
IF (N .LT. 3 .OR. (NROW .NE. 6 .AND. NROW .NE. 9))
. GO TO 11
C
C Initialize parameters for loop on triangles KT = (N1,N2,
C N3), where N1 < N2 and N1 < N3.
C
C ARCS = TRUE iff arc indexes are to be stored.
C KA,KT = Numbers of currently stored arcs and triangles.
C NM2 = Upper bound on candidates for N1.
C
ARCS = NROW .EQ. 9
KA = 0
KT = 0
NM2 = N-2
C
C Loop on nodes N1.
C
DO 9 N1 = 1,NM2
C
C Loop on pairs of adjacent neighbors (N2,N3). LPLN1 points
C to the last neighbor of N1, and LP2 points to N2.
C
LPLN1 = LEND(N1)
LP2 = LPLN1
1 LP2 = LPTR(LP2)
N2 = LIST(LP2)
LP = LPTR(LP2)
N3 = ABS(LIST(LP))
IF (N2 .LT. N1 .OR. N3 .LT. N1) GO TO 8
C
C Add a new triangle KT = (N1,N2,N3).
C
KT = KT + 1
LTRI(1,KT) = N1
LTRI(2,KT) = N2
LTRI(3,KT) = N3
C
C Loop on triangle sides (I2,I1) with neighboring triangles
C KN = (I1,I2,I3).
C
DO 7 I = 1,3
IF (I .EQ. 1) THEN
I1 = N3
I2 = N2
ELSEIF (I .EQ. 2) THEN
I1 = N1
I2 = N3
ELSE
I1 = N2
I2 = N1
ENDIF
C
C Set I3 to the neighbor of I1 that follows I2 unless
C I2->I1 is a boundary arc.
C
LPL = LEND(I1)
LP = LPTR(LPL)
2 IF (LIST(LP) .EQ. I2) GO TO 3
LP = LPTR(LP)
IF (LP .NE. LPL) GO TO 2
C
C I2 is the last neighbor of I1 unless the data structure
C is invalid. Bypass the search for a neighboring
C triangle if I2->I1 is a boundary arc.
C
IF (ABS(LIST(LP)) .NE. I2) GO TO 12
KN = 0
IF (LIST(LP) .LT. 0) GO TO 6
C
C I2->I1 is not a boundary arc, and LP points to I2 as
C a neighbor of I1.
C
3 LP = LPTR(LP)
I3 = ABS(LIST(LP))
C
C Find J such that LTRI(J,KN) = I3 (not used if KN > KT),
C and permute the vertex indexes of KN so that I1 is
C smallest.
C
IF (I1 .LT. I2 .AND. I1 .LT. I3) THEN
J = 3
ELSEIF (I2 .LT. I3) THEN
J = 2
ISV = I1
I1 = I2
I2 = I3
I3 = ISV
ELSE
J = 1
ISV = I1
I1 = I3
I3 = I2
I2 = ISV
ENDIF
C
C Test for KN > KT (triangle index not yet assigned).
C
IF (I1 .GT. N1) GO TO 7
C
C Find KN, if it exists, by searching the triangle list in
C reverse order.
C
DO 4 KN = KT-1,1,-1
IF (LTRI(1,KN) .EQ. I1 .AND. LTRI(2,KN) .EQ.
. I2 .AND. LTRI(3,KN) .EQ. I3) GO TO 5
4 CONTINUE
GO TO 7
C
C Store KT as a neighbor of KN.
C
5 LTRI(J+3,KN) = KT
C
C Store KN as a neighbor of KT, and add a new arc KA.
C
6 LTRI(I+3,KT) = KN
IF (ARCS) THEN
KA = KA + 1
LTRI(I+6,KT) = KA
IF (KN .NE. 0) LTRI(J+6,KN) = KA
ENDIF
7 CONTINUE
C
C Bottom of loop on triangles.
C
8 IF (LP2 .NE. LPLN1) GO TO 1
9 CONTINUE
C
C No errors encountered.
C
NT = KT
IER = 0
RETURN
C
C Invalid input parameter.
C
11 NT = 0
IER = 1
RETURN
C
C Invalid triangulation data structure: I1 is a neighbor of
C I2, but I2 is not a neighbor of I1.
C
12 NT = 0
IER = 2
RETURN
END
SUBROUTINE TRLPRT (N,X,Y,Z,IFLAG,NROW,NT,LTRI,LOUT)
INTEGER N, IFLAG, NROW, NT, LTRI(NROW,NT), LOUT
REAL(kind=8) X(N), Y(N), Z(N)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/02/98
C
C This subroutine prints the triangle list created by Sub-
C routine TRLIST and, optionally, the nodal coordinates
C (either latitude and longitude or Cartesian coordinates)
C on logical unit LOUT. The numbers of boundary nodes,
C triangles, and arcs are also printed.
C
C
C On input:
C
C N = Number of nodes in the triangulation.
C 3 .LE. N .LE. 9999.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes if IFLAG = 0, or
C (X and Y only) arrays of length N containing
C longitude and latitude, respectively, if
C IFLAG > 0, or unused dummy parameters if
C IFLAG < 0.
C
C IFLAG = Nodal coordinate option indicator:
C IFLAG = 0 if X, Y, and Z (assumed to contain
C Cartesian coordinates) are to be
C printed (to 6 decimal places).
C IFLAG > 0 if only X and Y (assumed to con-
C tain longitude and latitude) are
C to be printed (to 6 decimal
C places).
C IFLAG < 0 if only the adjacency lists are to
C be printed.
C
C NROW = Number of rows (entries per triangle) re-
C served for the triangle list LTRI. The value
C must be 6 if only the vertex indexes and
C neighboring triangle indexes are stored, or 9
C if arc indexes are also stored.
C
C NT = Number of triangles in the triangulation.
C 1 .LE. NT .LE. 9999.
C
C LTRI = NROW by NT array whose J-th column contains
C the vertex nodal indexes (first three rows),
C neighboring triangle indexes (second three
C rows), and, if NROW = 9, arc indexes (last
C three rows) associated with triangle J for
C J = 1,...,NT.
C
C LOUT = Logical unit number for output. If LOUT is
C not in the range 0 to 99, output is written
C to unit 6.
C
C Input parameters are not altered by this routine.
C
C On output:
C
C The triangle list and nodal coordinates (as specified by
C IFLAG) are written to unit LOUT.
C
C Modules required by TRLPRT: None
C
C***********************************************************
C
INTEGER I, K, LUN, NA, NB, NL, NLMAX, NMAX
DATA NMAX/9999/, NLMAX/58/
C
C Local parameters:
C
C I = DO-loop, nodal index, and row index for LTRI
C K = DO-loop and triangle index
C LUN = Logical unit number for output
C NA = Number of triangulation arcs
C NB = Number of boundary nodes
C NL = Number of lines printed on the current page
C NLMAX = Maximum number of print lines per page (except
C for the last page which may have two addi-
C tional lines)
C NMAX = Maximum value of N and NT (4-digit format)
C
LUN = LOUT
IF (LUN .LT. 0 .OR. LUN .GT. 99) LUN = 6
C
C Print a heading and test for invalid input.
C
WRITE (LUN,100) N
NL = 3
IF (N .LT. 3 .OR. N .GT. NMAX .OR.
. (NROW .NE. 6 .AND. NROW .NE. 9) .OR.
. NT .LT. 1 .OR. NT .GT. NMAX) THEN
C
C Print an error message and exit.
C
WRITE (LUN,110) N, NROW, NT
RETURN
ENDIF
IF (IFLAG .EQ. 0) THEN
C
C Print X, Y, and Z.
C
WRITE (LUN,101)
NL = 6
DO 1 I = 1,N
IF (NL .GE. NLMAX) THEN
WRITE (LUN,108)
NL = 0
ENDIF
WRITE (LUN,103) I, X(I), Y(I), Z(I)
NL = NL + 1
1 CONTINUE
ELSEIF (IFLAG .GT. 0) THEN
C
C Print X (longitude) and Y (latitude).
C
WRITE (LUN,102)
NL = 6
DO 2 I = 1,N
IF (NL .GE. NLMAX) THEN
WRITE (LUN,108)
NL = 0
ENDIF
WRITE (LUN,104) I, X(I), Y(I)
NL = NL + 1
2 CONTINUE
ENDIF
C
C Print the triangulation LTRI.
C
IF (NL .GT. NLMAX/2) THEN
WRITE (LUN,108)
NL = 0
ENDIF
IF (NROW .EQ. 6) THEN
WRITE (LUN,105)
ELSE
WRITE (LUN,106)
ENDIF
NL = NL + 5
DO 3 K = 1,NT
IF (NL .GE. NLMAX) THEN
WRITE (LUN,108)
NL = 0
ENDIF
WRITE (LUN,107) K, (LTRI(I,K), I = 1,NROW)
NL = NL + 1
3 CONTINUE
C
C Print NB, NA, and NT (boundary nodes, arcs, and
C triangles).
C
NB = 2*N - NT - 2
IF (NB .LT. 3) THEN
NB = 0
NA = 3*N - 6
ELSE
NA = NT + N - 1
ENDIF
WRITE (LUN,109) NB, NA, NT
RETURN
C
C Print formats:
C
100 FORMAT (///18X,'STRIPACK (TRLIST) Output, N = ',I4)
101 FORMAT (//8X,'Node',10X,'X(Node)',10X,'Y(Node)',10X,
. 'Z(Node)'//)
102 FORMAT (//16X,'Node',8X,'Longitude',9X,'Latitude'//)
103 FORMAT (8X,I4,3E17.6)
104 FORMAT (16X,I4,2E17.6)
105 FORMAT (//1X,'Triangle',8X,'Vertices',12X,'Neighbors'/
. 4X,'KT',7X,'N1',5X,'N2',5X,'N3',4X,'KT1',4X,
. 'KT2',4X,'KT3'/)
106 FORMAT (//1X,'Triangle',8X,'Vertices',12X,'Neighbors',
. 14X,'Arcs'/
. 4X,'KT',7X,'N1',5X,'N2',5X,'N3',4X,'KT1',4X,
. 'KT2',4X,'KT3',4X,'KA1',4X,'KA2',4X,'KA3'/)
107 FORMAT (2X,I4,2X,6(3X,I4),3(2X,I5))
108 FORMAT (///)
109 FORMAT (/1X,'NB = ',I4,' Boundary Nodes',5X,
. 'NA = ',I5,' Arcs',5X,'NT = ',I5,
. ' Triangles')
110 FORMAT (//1X,10X,'*** Invalid Parameter: N =',I5,
. ', NROW =',I5,', NT =',I5,' ***')
END
SUBROUTINE TRMESH (N,X,Y,Z, LIST,LPTR,LEND,LNEW,NEAR,
. NEXT,DIST,IER)
INTEGER N, LIST(*), LPTR(*), LEND(N), LNEW, NEAR(N),
. NEXT(N), IER
REAL(kind=8) X(N), Y(N), Z(N), DIST(N)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/08/99
C
C This subroutine creates a Delaunay triangulation of a
C set of N arbitrarily distributed points, referred to as
C nodes, on the surface of the unit sphere. The Delaunay
C triangulation is defined as a set of (spherical) triangles
C with the following five properties:
C
C 1) The triangle vertices are nodes.
C 2) No triangle contains a node other than its vertices.
C 3) The interiors of the triangles are pairwise disjoint.
C 4) The union of triangles is the convex hull of the set
C of nodes (the smallest convex set that contains
C the nodes). If the nodes are not contained in a
C single hemisphere, their convex hull is the en-
C tire sphere and there are no boundary nodes.
C Otherwise, there are at least three boundary nodes.
C 5) The interior of the circumcircle of each triangle
C contains no node.
C
C The first four properties define a triangulation, and the
C last property results in a triangulation which is as close
C as possible to equiangular in a certain sense and which is
C uniquely defined unless four or more nodes lie in a common
C plane. This property makes the triangulation well-suited
C for solving closest-point problems and for triangle-based
C interpolation.
C
C Provided the nodes are randomly ordered, the algorithm
C has expected time complexity O(N*log(N)) for most nodal
C distributions. Note, however, that the complexity may be
C as high as O(N**2) if, for example, the nodes are ordered
C on increasing latitude.
C
C Spherical coordinates (latitude and longitude) may be
C converted to Cartesian coordinates by Subroutine TRANS.
C
C The following is a list of the software package modules
C which a user may wish to call directly:
C
C ADDNOD - Updates the triangulation by appending a new
C node.
C
C AREAS - Returns the area of a spherical triangle.
C
C BNODES - Returns an array containing the indexes of the
C boundary nodes (if any) in counterclockwise
C order. Counts of boundary nodes, triangles,
C and arcs are also returned.
C
C CIRCUM - Returns the circumcenter of a spherical trian-
C gle.
C
C CRLIST - Returns the set of triangle circumcenters
C (Voronoi vertices) and circumradii associated
C with a triangulation.
C
C DELARC - Deletes a boundary arc from a triangulation.
C
C DELNOD - Updates the triangulation with a nodal deletion.
C
C EDGE - Forces an arbitrary pair of nodes to be connec-
C ted by an arc in the triangulation.
C
C GETNP - Determines the ordered sequence of L closest
C nodes to a given node, along with the associ-
C ated distances.
C
C INSIDE - Locates a point relative to a polygon on the
C surface of the sphere.
C
C INTRSC - Returns the point of intersection between a
C pair of great circle arcs.
C
C JRAND - Generates a uniformly distributed pseudo-random
C integer.
C
C LEFT - Locates a point relative to a great circle.
C
C NEARND - Returns the index of the nearest node to an
C arbitrary point, along with its squared
C distance.
C
C SCOORD - Converts a point from Cartesian coordinates to
C spherical coordinates.
C
C STORE - Forces a value to be stored in main memory so
C that the precision of floating point numbers
C in memory locations rather than registers is
C computed.
C
C TRANS - Transforms spherical coordinates into Cartesian
C coordinates on the unit sphere for input to
C Subroutine TRMESH.
C
C TRLIST - Converts the triangulation data structure to a
C triangle list more suitable for use in a fin-
C ite element code.
C
C TRLPRT - Prints the triangle list created by Subroutine
C TRLIST.
C
C TRMESH - Creates a Delaunay triangulation of a set of
C nodes.
C
C TRPLOT - Creates a level-2 Encapsulated Postscript (EPS)
C file containing a triangulation plot.
C
C TRPRNT - Prints the triangulation data structure and,
C optionally, the nodal coordinates.
C
C VRPLOT - Creates a level-2 Encapsulated Postscript (EPS)
C file containing a Voronoi diagram plot.
C
C
C On input:
C
C N = Number of nodes in the triangulation. N .GE. 3.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of distinct nodes. (X(K),Y(K),
C Z(K)) is referred to as node K, and K is re-
C ferred to as a nodal index. It is required
C that X(K)**2 + Y(K)**2 + Z(K)**2 = 1 for all
C K. The first three nodes must not be col-
C linear (lie on a common great circle).
C
C The above parameters are not altered by this routine.
C
C LIST,LPTR = Arrays of length at least 6N-12.
C
C LEND = Array of length at least N.
C
C NEAR,NEXT,DIST = Work space arrays of length at
C least N. The space is used to
C efficiently determine the nearest
C triangulation node to each un-
C processed node for use by ADDNOD.
C
C On output:
C
C LIST = Set of nodal indexes which, along with LPTR,
C LEND, and LNEW, define the triangulation as a
C set of N adjacency lists -- counterclockwise-
C ordered sequences of neighboring nodes such
C that the first and last neighbors of a bound-
C ary node are boundary nodes (the first neigh-
C bor of an interior node is arbitrary). In
C order to distinguish between interior and
C boundary nodes, the last neighbor of each
C boundary node is represented by the negative
C of its index.
C
C LPTR = Set of pointers (LIST indexes) in one-to-one
C correspondence with the elements of LIST.
C LIST(LPTR(I)) indexes the node which follows
C LIST(I) in cyclical counterclockwise order
C (the first neighbor follows the last neigh-
C bor).
C
C LEND = Set of pointers to adjacency lists. LEND(K)
C points to the last neighbor of node K for
C K = 1,...,N. Thus, LIST(LEND(K)) < 0 if and
C only if K is a boundary node.
C
C LNEW = Pointer to the first empty location in LIST
C and LPTR (list length plus one). LIST, LPTR,
C LEND, and LNEW are not altered if IER < 0,
C and are incomplete if IER > 0.
C
C NEAR,NEXT,DIST = Garbage.
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = -1 if N < 3 on input.
C IER = -2 if the first three nodes are
C collinear.
C IER = L if nodes L and M coincide for some
C M > L. The data structure represents
C a triangulation of nodes 1 to M-1 in
C this case.
C
C Modules required by TRMESH: ADDNOD, BDYADD, COVSPH,
C INSERT, INTADD, JRAND,
C LEFT, LSTPTR, STORE, SWAP,
C SWPTST, TRFIND
C
C Intrinsic function called by TRMESH: ABS
C
C***********************************************************
C
INTEGER I, I0, J, K, LP, LPL, NEXTI, NN
LOGICAL LEFT
REAL(kind=8) D, D1, D2, D3
C
C Local parameters:
C
C D = (Negative cosine of) distance from node K to
C node I
C D1,D2,D3 = Distances from node K to nodes 1, 2, and 3,
C respectively
C I,J = Nodal indexes
C I0 = Index of the node preceding I in a sequence of
C unprocessed nodes: I = NEXT(I0)
C K = Index of node to be added and DO-loop index:
C K > 3
C LP = LIST index (pointer) of a neighbor of K
C LPL = Pointer to the last neighbor of K
C NEXTI = NEXT(I)
C NN = Local copy of N
C
NN = N
IF (NN .LT. 3) THEN
IER = -1
RETURN
ENDIF
C
C Store the first triangle in the linked list.
C
IF ( .NOT. LEFT (X(1),Y(1),Z(1),X(2),Y(2),Z(2),
. X(3),Y(3),Z(3)) ) THEN
C
C The first triangle is (3,2,1) = (2,1,3) = (1,3,2).
C
LIST(1) = 3
LPTR(1) = 2
LIST(2) = -2
LPTR(2) = 1
LEND(1) = 2
C
LIST(3) = 1
LPTR(3) = 4
LIST(4) = -3
LPTR(4) = 3
LEND(2) = 4
C
LIST(5) = 2
LPTR(5) = 6
LIST(6) = -1
LPTR(6) = 5
LEND(3) = 6
C
ELSEIF ( .NOT. LEFT(X(2),Y(2),Z(2),X(1),Y(1),Z(1),
. X(3),Y(3),Z(3)) )
. THEN
C
C The first triangle is (1,2,3): 3 Strictly Left 1->2,
C i.e., node 3 lies in the left hemisphere defined by
C arc 1->2.
C
LIST(1) = 2
LPTR(1) = 2
LIST(2) = -3
LPTR(2) = 1
LEND(1) = 2
C
LIST(3) = 3
LPTR(3) = 4
LIST(4) = -1
LPTR(4) = 3
LEND(2) = 4
C
LIST(5) = 1
LPTR(5) = 6
LIST(6) = -2
LPTR(6) = 5
LEND(3) = 6
C
ELSE
C
C The first three nodes are collinear.
C
IER = -2
RETURN
ENDIF
C
C Initialize LNEW and test for N = 3.
C
LNEW = 7
IF (NN .EQ. 3) THEN
IER = 0
RETURN
ENDIF
C
C A nearest-node data structure (NEAR, NEXT, and DIST) is
C used to obtain an expected-time (N*log(N)) incremental
C algorithm by enabling constant search time for locating
C each new node in the triangulation.
C
C For each unprocessed node K, NEAR(K) is the index of the
C triangulation node closest to K (used as the starting
C point for the search in Subroutine TRFIND) and DIST(K)
C is an increasing function of the arc length (angular
C distance) between nodes K and NEAR(K): -Cos(a) for arc
C length a.
C
C Since it is necessary to efficiently find the subset of
C unprocessed nodes associated with each triangulation
C node J (those that have J as their NEAR entries), the
C subsets are stored in NEAR and NEXT as follows: for
C each node J in the triangulation, I = NEAR(J) is the
C first unprocessed node in J's set (with I = 0 if the
C set is empty), L = NEXT(I) (if I > 0) is the second,
C NEXT(L) (if L > 0) is the third, etc. The nodes in each
C set are initially ordered by increasing indexes (which
C maximizes efficiency) but that ordering is not main-
C tained as the data structure is updated.
C
C Initialize the data structure for the single triangle.
C
NEAR(1) = 0
NEAR(2) = 0
NEAR(3) = 0
DO 1 K = NN,4,-1
D1 = -(X(K)*X(1) + Y(K)*Y(1) + Z(K)*Z(1))
D2 = -(X(K)*X(2) + Y(K)*Y(2) + Z(K)*Z(2))
D3 = -(X(K)*X(3) + Y(K)*Y(3) + Z(K)*Z(3))
IF (D1 .LE. D2 .AND. D1 .LE. D3) THEN
NEAR(K) = 1
DIST(K) = D1
NEXT(K) = NEAR(1)
NEAR(1) = K
ELSEIF (D2 .LE. D1 .AND. D2 .LE. D3) THEN
NEAR(K) = 2
DIST(K) = D2
NEXT(K) = NEAR(2)
NEAR(2) = K
ELSE
NEAR(K) = 3
DIST(K) = D3
NEXT(K) = NEAR(3)
NEAR(3) = K
ENDIF
1 CONTINUE
C
C Add the remaining nodes
C
DO 6 K = 4,NN
CALL ADDNOD (NEAR(K),K,X,Y,Z, LIST,LPTR,LEND,
. LNEW, IER)
IF (IER .NE. 0) RETURN
C
C Remove K from the set of unprocessed nodes associated
C with NEAR(K).
C
I = NEAR(K)
IF (NEAR(I) .EQ. K) THEN
NEAR(I) = NEXT(K)
ELSE
I = NEAR(I)
2 I0 = I
I = NEXT(I0)
IF (I .NE. K) GO TO 2
NEXT(I0) = NEXT(K)
ENDIF
NEAR(K) = 0
C
C Loop on neighbors J of node K.
C
LPL = LEND(K)
LP = LPL
3 LP = LPTR(LP)
J = ABS(LIST(LP))
C
C Loop on elements I in the sequence of unprocessed nodes
C associated with J: K is a candidate for replacing J
C as the nearest triangulation node to I. The next value
C of I in the sequence, NEXT(I), must be saved before I
C is moved because it is altered by adding I to K's set.
C
I = NEAR(J)
4 IF (I .EQ. 0) GO TO 5
NEXTI = NEXT(I)
C
C Test for the distance from I to K less than the distance
C from I to J.
C
D = -(X(I)*X(K) + Y(I)*Y(K) + Z(I)*Z(K))
IF (D .LT. DIST(I)) THEN
C
C Replace J by K as the nearest triangulation node to I:
C update NEAR(I) and DIST(I), and remove I from J's set
C of unprocessed nodes and add it to K's set.
C
NEAR(I) = K
DIST(I) = D
IF (I .EQ. NEAR(J)) THEN
NEAR(J) = NEXTI
ELSE
NEXT(I0) = NEXTI
ENDIF
NEXT(I) = NEAR(K)
NEAR(K) = I
ELSE
I0 = I
ENDIF
C
C Bottom of loop on I.
C
I = NEXTI
GO TO 4
C
C Bottom of loop on neighbors J.
C
5 IF (LP .NE. LPL) GO TO 3
6 CONTINUE
RETURN
END
SUBROUTINE TRPLOT (LUN,PLTSIZ,ELAT,ELON,A,N,X,Y,Z,
. LIST,LPTR,LEND,TITLE,NUMBR, IER)
CHARACTER*(*) TITLE
INTEGER LUN, N, LIST(*), LPTR(*), LEND(N), IER
LOGICAL NUMBR
REAL(kind=8) PLTSIZ, ELAT, ELON, A, X(N), Y(N), Z(N)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/16/98
C
C This subroutine creates a level-2 Encapsulated Post-
C script (EPS) file containing a graphical display of a
C triangulation of a set of nodes on the unit sphere. The
C visible nodes are projected onto the plane that contains
C the origin and has normal defined by a user-specified eye-
C position. Projections of adjacent (visible) nodes are
C connected by line segments.
C
C
C On input:
C
C LUN = Logical unit number in the range 0 to 99.
C The unit should be opened with an appropriate
C file name before the call to this routine.
C
C PLTSIZ = Plot size in inches. A circular window in
C the projection plane is mapped to a circu-
C lar viewport with diameter equal to .88*
C PLTSIZ (leaving room for labels outside the
C viewport). The viewport is centered on the
C 8.5 by 11 inch page, and its boundary is
C drawn. 1.0 .LE. PLTSIZ .LE. 8.5.
C
C ELAT,ELON = Latitude and longitude (in degrees) of
C the center of projection E (the center
C of the plot). The projection plane is
C the plane that contains the origin and
C has E as unit normal. In a rotated
C coordinate system for which E is the
C north pole, the projection plane con-
C tains the equator, and only northern
C hemisphere nodes are visible (from the
C point at infinity in the direction E).
C These are projected orthogonally onto
C the projection plane (by zeroing the z-
C component in the rotated coordinate
C system). ELAT and ELON must be in the
C range -90 to 90 and -180 to 180, respec-
C tively.
C
C A = Angular distance in degrees from E to the boun-
C dary of a circular window against which the
C triangulation is clipped. The projected window
C is a disk of radius r = Sin(A) centered at the
C origin, and only visible nodes whose projections
C are within distance r of the origin are included
C in the plot. Thus, if A = 90, the plot includes
C the entire hemisphere centered at E. 0 .LT. A
C .LE. 90.
C
C N = Number of nodes in the triangulation. N .GE. 3.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes (unit vectors).
C
C LIST,LPTR,LEND = Data structure defining the trian-
C gulation. Refer to Subroutine
C TRMESH.
C
C TITLE = Type CHARACTER variable or constant contain-
C ing a string to be centered above the plot.
C The string must be enclosed in parentheses;
C i.e., the first and last characters must be
C '(' and ')', respectively, but these are not
C displayed. TITLE may have at most 80 char-
C acters including the parentheses.
C
C NUMBR = Option indicator: If NUMBR = TRUE, the
C nodal indexes are plotted next to the nodes.
C
C Input parameters are not altered by this routine.
C
C On output:
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if LUN, PLTSIZ, or N is outside its
C valid range.
C IER = 2 if ELAT, ELON, or A is outside its
C valid range.
C IER = 3 if an error was encountered in writing
C to unit LUN.
C
C The values in the data statement below may be altered
C in order to modify various plotting options.
C
C Modules required by TRPLOT: None
C
C Intrinsic functions called by TRPLOT: ABS, ATAN, COS,
C NINT, REAL, SIN,
C SQRT
C
C***********************************************************
C
INTEGER IPX1, IPX2, IPY1, IPY2, IR, LP, LPL, N0, N1
LOGICAL ANNOT
REAL(kind=8) CF, CT, EX, EY, EZ, FSIZN, FSIZT, R11, R12,
. R21, R22, R23, SF, T, TX, TY, WR, WRS, X0, X1,
. Y0, Y1, Z0, Z1
C
DATA ANNOT/.TRUE./, FSIZN/10.0/, FSIZT/16.0/
C
C Local parameters:
C
C ANNOT = Logical variable with value TRUE iff the plot
C is to be annotated with the values of ELAT,
C ELON, and A
C CF = Conversion factor for degrees to radians
C CT = Cos(ELAT)
C EX,EY,EZ = Cartesian coordinates of the eye-position E
C FSIZN = Font size in points for labeling nodes with
C their indexes if NUMBR = TRUE
C FSIZT = Font size in points for the title (and
C annotation if ANNOT = TRUE)
C IPX1,IPY1 = X and y coordinates (in points) of the lower
C left corner of the bounding box or viewport
C box
C IPX2,IPY2 = X and y coordinates (in points) of the upper
C right corner of the bounding box or viewport
C box
C IR = Half the width (height) of the bounding box or
C viewport box in points -- viewport radius
C LP = LIST index (pointer)
C LPL = Pointer to the last neighbor of N0
C N0 = Index of a node whose incident arcs are to be
C drawn
C N1 = Neighbor of N0
C R11...R23 = Components of the first two rows of a rotation
C that maps E to the north pole (0,0,1)
C SF = Scale factor for mapping world coordinates
C (window coordinates in [-WR,WR] X [-WR,WR])
C to viewport coordinates in [IPX1,IPX2] X
C [IPY1,IPY2]
C T = Temporary variable
C TX,TY = Translation vector for mapping world coordi-
C nates to viewport coordinates
C WR = Window radius r = Sin(A)
C WRS = WR**2
C X0,Y0,Z0 = Coordinates of N0 in the rotated coordinate
C system or label location (X0,Y0)
C X1,Y1,Z1 = Coordinates of N1 in the rotated coordinate
C system or intersection of edge N0-N1 with
C the equator (in the rotated coordinate
C system)
C
C
C Test for invalid parameters.
C
IF ( ( (LUN .LT. 0) .OR. (LUN .GT. 99)) .OR.
. ( (PLTSIZ .LT. 1.0) .OR. ( PLTSIZ .GT. 8.5 )) .OR.
. (N .LT. 3)) THEN
GO TO 11
ENDIF
IF (ABS(ELAT) .GT. 90.0 .OR. ABS(ELON) .GT. 180.0
. .OR. A .GT. 90.0) GO TO 12
C
C Compute a conversion factor CF for degrees to radians
C and compute the window radius WR.
C
CF = ATAN(1.0)/45.0
WR = SIN(CF*A)
WRS = WR*WR
C
C Compute the lower left (IPX1,IPY1) and upper right
C (IPX2,IPY2) corner coordinates of the bounding box.
C The coordinates, specified in default user space units
C (points, at 72 points/inch with origin at the lower
C left corner of the page), are chosen to preserve the
C square aspect ratio, and to center the plot on the 8.5
C by 11 inch page. The center of the page is (306,396),
C and IR = PLTSIZ/2 in points.
C
IR = NINT(36.0*PLTSIZ)
IPX1 = 306 - IR
IPX2 = 306 + IR
IPY1 = 396 - IR
IPY2 = 396 + IR
C
C Output header comments.
C
WRITE (LUN,100,ERR=13) IPX1, IPY1, IPX2, IPY2
100 FORMAT ('%!PS-Adobe-3.0 EPSF-3.0'/
. '%%BoundingBox:',4I4/
. '%%Title: Triangulation'/
. '%%Creator: STRIPACK'/
. '%%EndComments')
C
C Set (IPX1,IPY1) and (IPX2,IPY2) to the corner coordinates
C of a viewport box obtained by shrinking the bounding box
C by 12% in each dimension.
C
IR = NINT(0.88*REAL(IR,8))
IPX1 = 306 - IR
IPX2 = 306 + IR
IPY1 = 396 - IR
IPY2 = 396 + IR
C
C Set the line thickness to 2 points, and draw the
C viewport boundary.
C
T = 2.0
WRITE (LUN,110,ERR=13) T
WRITE (LUN,120,ERR=13) IR
WRITE (LUN,130,ERR=13)
110 FORMAT (F12.6,' setlinewidth')
120 FORMAT ('306 396 ',I3,' 0 360 arc')
130 FORMAT ('stroke')
C
C Set up an affine mapping from the window box [-WR,WR] X
C [-WR,WR] to the viewport box.
C
SF = REAL(IR,8)/WR
TX = IPX1 + SF*WR
TY = IPY1 + SF*WR
WRITE (LUN,140,ERR=13) TX, TY, SF, SF
140 FORMAT (2F12.6,' translate'/
. 2F12.6,' scale')
C
C The line thickness must be changed to reflect the new
C scaling which is applied to all subsequent output.
C Set it to 1.0 point.
C
T = 1.0/SF
WRITE (LUN,110,ERR=13) T
C
C Save the current graphics state, and set the clip path to
C the boundary of the window.
C
WRITE (LUN,150,ERR=13)
WRITE (LUN,160,ERR=13) WR
WRITE (LUN,170,ERR=13)
150 FORMAT ('gsave')
160 FORMAT ('0 0 ',F12.6,' 0 360 arc')
170 FORMAT ('clip newpath')
C
C Compute the Cartesian coordinates of E and the components
C of a rotation R which maps E to the north pole (0,0,1).
C R is taken to be a rotation about the z-axis (into the
C yz-plane) followed by a rotation about the x-axis chosen
C so that the view-up direction is (0,0,1), or (-1,0,0) if
C E is the north or south pole.
C
C ( R11 R12 0 )
C R = ( R21 R22 R23 )
C ( EX EY EZ )
C
T = CF*ELON
CT = COS(CF*ELAT)
EX = CT*COS(T)
EY = CT*SIN(T)
EZ = SIN(CF*ELAT)
IF (CT .NE. 0.0) THEN
R11 = -EY/CT
R12 = EX/CT
ELSE
R11 = 0.0
R12 = 1.0
ENDIF
R21 = -EZ*R12
R22 = EZ*R11
R23 = CT
C
C Loop on visible nodes N0 that project to points (X0,Y0) in
C the window.
C
DO 3 N0 = 1,N
Z0 = EX*X(N0) + EY*Y(N0) + EZ*Z(N0)
IF (Z0 .LT. 0.) GO TO 3
X0 = R11*X(N0) + R12*Y(N0)
Y0 = R21*X(N0) + R22*Y(N0) + R23*Z(N0)
IF (X0*X0 + Y0*Y0 .GT. WRS) GO TO 3
LPL = LEND(N0)
LP = LPL
C
C Loop on neighbors N1 of N0. LPL points to the last
C neighbor of N0. Copy the components of N1 into P.
C
1 LP = LPTR(LP)
N1 = ABS(LIST(LP))
X1 = R11*X(N1) + R12*Y(N1)
Y1 = R21*X(N1) + R22*Y(N1) + R23*Z(N1)
Z1 = EX*X(N1) + EY*Y(N1) + EZ*Z(N1)
IF (Z1 .LT. 0.) THEN
C
C N1 is a 'southern hemisphere' point. Move it to the
C intersection of edge N0-N1 with the equator so that
C the edge is clipped properly. Z1 is implicitly set
C to 0.
C
X1 = Z0*X1 - Z1*X0
Y1 = Z0*Y1 - Z1*Y0
T = SQRT(X1*X1+Y1*Y1)
X1 = X1/T
Y1 = Y1/T
ENDIF
C
C If node N1 is in the window and N1 < N0, bypass edge
C N0->N1 (since edge N1->N0 has already been drawn).
C
IF ( Z1 .GE. 0.0 .AND. X1*X1 + Y1*Y1 .LE. WRS
. .AND. N1 .LT. N0 ) GO TO 2
C
C Add the edge to the path.
C
WRITE (LUN,180,ERR=13) X0, Y0, X1, Y1
180 FORMAT (2F12.6,' moveto',2F12.6,' lineto')
C
C Bottom of loops.
C
2 IF (LP .NE. LPL) GO TO 1
3 CONTINUE
C
C Paint the path and restore the saved graphics state (with
C no clip path).
C
WRITE (LUN,130,ERR=13)
WRITE (LUN,190,ERR=13)
190 FORMAT ('grestore')
IF (NUMBR) THEN
C
C Nodes in the window are to be labeled with their indexes.
C Convert FSIZN from points to world coordinates, and
C output the commands to select a font and scale it.
C
T = FSIZN/SF
WRITE (LUN,200,ERR=13) T
200 FORMAT ('/Helvetica findfont'/
. F12.6,' scalefont setfont')
C
C Loop on visible nodes N0 that project to points (X0,Y0) in
C the window.
C
DO 4 N0 = 1,N
IF (EX*X(N0) + EY*Y(N0) + EZ*Z(N0) .LT. 0.)
. GO TO 4
X0 = R11*X(N0) + R12*Y(N0)
Y0 = R21*X(N0) + R22*Y(N0) + R23*Z(N0)
IF (X0*X0 + Y0*Y0 .GT. WRS) GO TO 4
C
C Move to (X0,Y0) and draw the label N0. The first char-
C acter will will have its lower left corner about one
C character width to the right of the nodal position.
C
WRITE (LUN,210,ERR=13) X0, Y0
WRITE (LUN,220,ERR=13) N0
210 FORMAT (2F12.6,' moveto')
220 FORMAT ('(',I3,') show')
4 CONTINUE
ENDIF
C
C Convert FSIZT from points to world coordinates, and output
C the commands to select a font and scale it.
C
T = FSIZT/SF
WRITE (LUN,200,ERR=13) T
C
C Display TITLE centered above the plot:
C
Y0 = WR + 3.0*T
WRITE (LUN,230,ERR=13) TITLE, Y0
230 FORMAT (A80/' stringwidth pop 2 div neg ',F12.6,
. ' moveto')
WRITE (LUN,240,ERR=13) TITLE
240 FORMAT (A80/' show')
IF (ANNOT) THEN
C
C Display the window center and radius below the plot.
C
X0 = -WR
Y0 = -WR - 50.0/SF
WRITE (LUN,210,ERR=13) X0, Y0
WRITE (LUN,250,ERR=13) ELAT, ELON
Y0 = Y0 - 2.0*T
WRITE (LUN,210,ERR=13) X0, Y0
WRITE (LUN,260,ERR=13) A
250 FORMAT ('(Window center: ELAT = ',F7.2,
. ', ELON = ',F8.2,') show')
260 FORMAT ('(Angular extent: A = ',F5.2,') show')
ENDIF
C
C Paint the path and output the showpage command and
C end-of-file indicator.
C
WRITE (LUN,270,ERR=13)
270 FORMAT ('stroke'/
. 'showpage'/
. '%%EOF')
C
C HP's interpreters require a one-byte End-of-PostScript-Job
C indicator (to eliminate a timeout error message):
C ASCII 4.
C
WRITE (LUN,280,ERR=13) CHAR(4)
280 FORMAT (A1)
C
C No error encountered.
C
IER = 0
RETURN
C
C Invalid input parameter LUN, PLTSIZ, or N.
C
11 IER = 1
RETURN
C
C Invalid input parameter ELAT, ELON, or A.
C
12 IER = 2
RETURN
C
C Error writing to unit LUN.
C
13 IER = 3
RETURN
END
SUBROUTINE TRPRNT (N,X,Y,Z,IFLAG,LIST,LPTR,LEND,LOUT)
INTEGER N, IFLAG, LIST(*), LPTR(*), LEND(N), LOUT
REAL(kind=8) X(N), Y(N), Z(N)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/25/98
C
C This subroutine prints the triangulation adjacency lists
C created by Subroutine TRMESH and, optionally, the nodal
C coordinates (either latitude and longitude or Cartesian
C coordinates) on logical unit LOUT. The list of neighbors
C of a boundary node is followed by index 0. The numbers of
C boundary nodes, triangles, and arcs are also printed.
C
C
C On input:
C
C N = Number of nodes in the triangulation. N .GE. 3
C and N .LE. 9999.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes if IFLAG = 0, or
C (X and Y only) arrays of length N containing
C longitude and latitude, respectively, if
C IFLAG > 0, or unused dummy parameters if
C IFLAG < 0.
C
C IFLAG = Nodal coordinate option indicator:
C IFLAG = 0 if X, Y, and Z (assumed to contain
C Cartesian coordinates) are to be
C printed (to 6 decimal places).
C IFLAG > 0 if only X and Y (assumed to con-
C tain longitude and latitude) are
C to be printed (to 6 decimal
C places).
C IFLAG < 0 if only the adjacency lists are to
C be printed.
C
C LIST,LPTR,LEND = Data structure defining the trian-
C gulation. Refer to Subroutine
C TRMESH.
C
C LOUT = Logical unit for output. If LOUT is not in
C the range 0 to 99, output is written to
C logical unit 6.
C
C Input parameters are not altered by this routine.
C
C On output:
C
C The adjacency lists and nodal coordinates (as specified
C by IFLAG) are written to unit LOUT.
C
C Modules required by TRPRNT: None
C
C***********************************************************
C
INTEGER I, INC, K, LP, LPL, LUN, NA, NABOR(400), NB,
. ND, NL, NLMAX, NMAX, NODE, NN, NT
DATA NMAX/9999/, NLMAX/58/
C
C Local parameters:
C
C I = NABOR index (1 to K)
C INC = Increment for NL associated with an adjacency list
C K = Counter and number of neighbors of NODE
C LP = LIST pointer of a neighbor of NODE
C LPL = Pointer to the last neighbor of NODE
C LUN = Logical unit for output (copy of LOUT)
C NA = Number of arcs in the triangulation
C NABOR = Array containing the adjacency list associated
C with NODE, with zero appended if NODE is a
C boundary node
C NB = Number of boundary nodes encountered
C ND = Index of a neighbor of NODE (or negative index)
C NL = Number of lines that have been printed on the
C current page
C NLMAX = Maximum number of print lines per page (except
C for the last page which may have two addi-
C tional lines)
C NMAX = Upper bound on N (allows 4-digit indexes)
C NODE = Index of a node and DO-loop index (1 to N)
C NN = Local copy of N
C NT = Number of triangles in the triangulation
C
NN = N
LUN = LOUT
IF (LUN .LT. 0 .OR. LUN .GT. 99) LUN = 6
C
C Print a heading and test the range of N.
C
WRITE (LUN,100) NN
IF (NN .LT. 3 .OR. NN .GT. NMAX) THEN
C
C N is outside its valid range.
C
WRITE (LUN,110)
RETURN
ENDIF
C
C Initialize NL (the number of lines printed on the current
C page) and NB (the number of boundary nodes encountered).
C
NL = 6
NB = 0
IF (IFLAG .LT. 0) THEN
C
C Print LIST only. K is the number of neighbors of NODE
C that have been stored in NABOR.
C
WRITE (LUN,101)
DO 2 NODE = 1,NN
LPL = LEND(NODE)
LP = LPL
K = 0
C
1 K = K + 1
LP = LPTR(LP)
ND = LIST(LP)
NABOR(K) = ND
IF (LP .NE. LPL) GO TO 1
IF (ND .LE. 0) THEN
C
C NODE is a boundary node. Correct the sign of the last
C neighbor, add 0 to the end of the list, and increment
C NB.
C
NABOR(K) = -ND
K = K + 1
NABOR(K) = 0
NB = NB + 1
ENDIF
C
C Increment NL and print the list of neighbors.
C
INC = (K-1)/14 + 2
NL = NL + INC
IF (NL .GT. NLMAX) THEN
WRITE (LUN,108)
NL = INC
ENDIF
WRITE (LUN,104) NODE, (NABOR(I), I = 1,K)
IF (K .NE. 14) WRITE (LUN,107)
2 CONTINUE
ELSEIF (IFLAG .GT. 0) THEN
C
C Print X (longitude), Y (latitude), and LIST.
C
WRITE (LUN,102)
DO 4 NODE = 1,NN
LPL = LEND(NODE)
LP = LPL
K = 0
C
3 K = K + 1
LP = LPTR(LP)
ND = LIST(LP)
NABOR(K) = ND
IF (LP .NE. LPL) GO TO 3
IF (ND .LE. 0) THEN
C
C NODE is a boundary node.
C
NABOR(K) = -ND
K = K + 1
NABOR(K) = 0
NB = NB + 1
ENDIF
C
C Increment NL and print X, Y, and NABOR.
C
INC = (K-1)/8 + 2
NL = NL + INC
IF (NL .GT. NLMAX) THEN
WRITE (LUN,108)
NL = INC
ENDIF
WRITE (LUN,105) NODE, X(NODE), Y(NODE),
. (NABOR(I), I = 1,K)
IF (K .NE. 8) WRITE (LUN,107)
4 CONTINUE
ELSE
C
C Print X, Y, Z, and LIST.
C
WRITE (LUN,103)
DO 6 NODE = 1,NN
LPL = LEND(NODE)
LP = LPL
K = 0
C
5 K = K + 1
LP = LPTR(LP)
ND = LIST(LP)
NABOR(K) = ND
IF (LP .NE. LPL) GO TO 5
IF (ND .LE. 0) THEN
C
C NODE is a boundary node.
C
NABOR(K) = -ND
K = K + 1
NABOR(K) = 0
NB = NB + 1
ENDIF
C
C Increment NL and print X, Y, Z, and NABOR.
C
INC = (K-1)/5 + 2
NL = NL + INC
IF (NL .GT. NLMAX) THEN
WRITE (LUN,108)
NL = INC
ENDIF
WRITE (LUN,106) NODE, X(NODE), Y(NODE),
. Z(NODE), (NABOR(I), I = 1,K)
IF (K .NE. 5) WRITE (LUN,107)
6 CONTINUE
ENDIF
C
C Print NB, NA, and NT (boundary nodes, arcs, and
C triangles).
C
IF (NB .NE. 0) THEN
NA = 3*NN - NB - 3
NT = 2*NN - NB - 2
ELSE
NA = 3*NN - 6
NT = 2*NN - 4
ENDIF
WRITE (LUN,109) NB, NA, NT
RETURN
C
C Print formats:
C
100 FORMAT (///15X,'STRIPACK Triangulation Data ',
. 'Structure, N = ',I5//)
101 FORMAT (1X,'Node',31X,'Neighbors of Node'//)
102 FORMAT (1X,'Node',5X,'Longitude',6X,'Latitude',
. 18X,'Neighbors of Node'//)
103 FORMAT (1X,'Node',5X,'X(Node)',8X,'Y(Node)',8X,
. 'Z(Node)',11X,'Neighbors of Node'//)
104 FORMAT (1X,I4,4X,14I5/(1X,8X,14I5))
105 FORMAT (1X,I4,2E15.6,4X,8I5/(1X,38X,8I5))
106 FORMAT (1X,I4,3E15.6,4X,5I5/(1X,53X,5I5))
107 FORMAT (1X)
108 FORMAT (///)
109 FORMAT (/1X,'NB = ',I4,' Boundary Nodes',5X,
. 'NA = ',I5,' Arcs',5X,'NT = ',I5,
. ' Triangles')
110 FORMAT (1X,10X,'*** N is outside its valid',
. ' range ***')
END
SUBROUTINE VRPLOT (LUN,PLTSIZ,ELAT,ELON,A,N,X,Y,Z,
. NT,LISTC,LPTR,LEND,XC,YC,ZC,TITLE,
. NUMBR, IER)
CHARACTER*(*) TITLE
INTEGER LUN, N, NT, LISTC(*), LPTR(*), LEND(N), IER
LOGICAL NUMBR
REAL(kind=8) PLTSIZ, ELAT, ELON, A, X(N), Y(N), Z(N),
. XC(NT), YC(NT), ZC(NT)
C
C***********************************************************
C
C From STRIPACK
C Robert J. Renka
C Dept. of Computer Science
C Univ. of North Texas
C renka@cs.unt.edu
C 07/16/98
C
C This subroutine creates a level-2 Encapsulated Post-
C script (EPS) file containing a graphical depiction of a
C Voronoi diagram of a set of nodes on the unit sphere.
C The visible vertices are projected onto the plane that
C contains the origin and has normal defined by a user-
C specified eye-position. Projections of adjacent (visible)
C Voronoi vertices are connected by line segments.
C
C The parameters defining the Voronoi diagram may be com-
C puted by Subroutine CRLIST.
C
C
C On input:
C
C LUN = Logical unit number in the range 0 to 99.
C The unit should be opened with an appropriate
C file name before the call to this routine.
C
C PLTSIZ = Plot size in inches. A circular window in
C the projection plane is mapped to a circu-
C lar viewport with diameter equal to .88*
C PLTSIZ (leaving room for labels outside the
C viewport). The viewport is centered on the
C 8.5 by 11 inch page, and its boundary is
C drawn. 1.0 .LE. PLTSIZ .LE. 8.5.
C
C ELAT,ELON = Latitude and longitude (in degrees) of
C the center of projection E (the center
C of the plot). The projection plane is
C the plane that contains the origin and
C has E as unit normal. In a rotated
C coordinate system for which E is the
C north pole, the projection plane con-
C tains the equator, and only northern
C hemisphere points are visible (from the
C point at infinity in the direction E).
C These are projected orthogonally onto
C the projection plane (by zeroing the z-
C component in the rotated coordinate
C system). ELAT and ELON must be in the
C range -90 to 90 and -180 to 180, respec-
C tively.
C
C A = Angular distance in degrees from E to the boun-
C dary of a circular window against which the
C Voronoi diagram is clipped. The projected win-
C dow is a disk of radius r = Sin(A) centered at
C the origin, and only visible vertices whose
C projections are within distance r of the origin
C are included in the plot. Thus, if A = 90, the
C plot includes the entire hemisphere centered at
C E. 0 .LT. A .LE. 90.
C
C N = Number of nodes (Voronoi centers) and Voronoi
C regions. N .GE. 3.
C
C X,Y,Z = Arrays of length N containing the Cartesian
C coordinates of the nodes (unit vectors).
C
C NT = Number of Voronoi region vertices (triangles,
C including those in the extended triangulation
C if the number of boundary nodes NB is nonzero):
C NT = 2*N-4.
C
C LISTC = Array of length 3*NT containing triangle
C indexes (indexes to XC, YC, and ZC) stored
C in 1-1 correspondence with LIST/LPTR entries
C (or entries that would be stored in LIST for
C the extended triangulation): the index of
C triangle (N1,N2,N3) is stored in LISTC(K),
C LISTC(L), and LISTC(M), where LIST(K),
C LIST(L), and LIST(M) are the indexes of N2
C as a neighbor of N1, N3 as a neighbor of N2,
C and N1 as a neighbor of N3. The Voronoi
C region associated with a node is defined by
C the CCW-ordered sequence of circumcenters in
C one-to-one correspondence with its adjacency
C list (in the extended triangulation).
C
C LPTR = Array of length 3*NT = 6*N-12 containing a
C set of pointers (LISTC indexes) in one-to-one
C correspondence with the elements of LISTC.
C LISTC(LPTR(I)) indexes the triangle which
C follows LISTC(I) in cyclical counterclockwise
C order (the first neighbor follows the last
C neighbor).
C
C LEND = Array of length N containing a set of
C pointers to triangle lists. LP = LEND(K)
C points to a triangle (indexed by LISTC(LP))
C containing node K for K = 1 to N.
C
C XC,YC,ZC = Arrays of length NT containing the
C Cartesian coordinates of the triangle
C circumcenters (Voronoi vertices).
C XC(I)**2 + YC(I)**2 + ZC(I)**2 = 1.
C
C TITLE = Type CHARACTER variable or constant contain-
C ing a string to be centered above the plot.
C The string must be enclosed in parentheses;
C i.e., the first and last characters must be
C '(' and ')', respectively, but these are not
C displayed. TITLE may have at most 80 char-
C acters including the parentheses.
C
C NUMBR = Option indicator: If NUMBR = TRUE, the
C nodal indexes are plotted at the Voronoi
C region centers.
C
C Input parameters are not altered by this routine.
C
C On output:
C
C IER = Error indicator:
C IER = 0 if no errors were encountered.
C IER = 1 if LUN, PLTSIZ, N, or NT is outside
C its valid range.
C IER = 2 if ELAT, ELON, or A is outside its
C valid range.
C IER = 3 if an error was encountered in writing
C to unit LUN.
C
C Modules required by VRPLOT: None
C
C Intrinsic functions called by VRPLOT: ABS, ATAN, COS,
C NINT, REAL, SIN,
C SQRT
C
C***********************************************************
C
INTEGER IPX1, IPX2, IPY1, IPY2, IR, KV1, KV2, LP, LPL,
. N0
LOGICAL ANNOT, IN1, IN2
REAL(kind=8) CF, CT, EX, EY, EZ, FSIZN, FSIZT, R11, R12,
. R21, R22, R23, SF, T, TX, TY, WR, WRS, X0, X1,
. X2, Y0, Y1, Y2, Z1, Z2
C
DATA ANNOT/.TRUE./, FSIZN/10.0/, FSIZT/16.0/
C
C Local parameters:
C
C ANNOT = Logical variable with value TRUE iff the plot
C is to be annotated with the values of ELAT,
C ELON, and A
C CF = Conversion factor for degrees to radians
C CT = Cos(ELAT)
C EX,EY,EZ = Cartesian coordinates of the eye-position E
C FSIZN = Font size in points for labeling nodes with
C their indexes if NUMBR = TRUE
C FSIZT = Font size in points for the title (and
C annotation if ANNOT = TRUE)
C IN1,IN2 = Logical variables with value TRUE iff the
C projections of vertices KV1 and KV2, respec-
C tively, are inside the window
C IPX1,IPY1 = X and y coordinates (in points) of the lower
C left corner of the bounding box or viewport
C box
C IPX2,IPY2 = X and y coordinates (in points) of the upper
C right corner of the bounding box or viewport
C box
C IR = Half the width (height) of the bounding box or
C viewport box in points -- viewport radius
C KV1,KV2 = Endpoint indexes of a Voronoi edge
C LP = LIST index (pointer)
C LPL = Pointer to the last neighbor of N0
C N0 = Index of a node
C R11...R23 = Components of the first two rows of a rotation
C that maps E to the north pole (0,0,1)
C SF = Scale factor for mapping world coordinates
C (window coordinates in [-WR,WR] X [-WR,WR])
C to viewport coordinates in [IPX1,IPX2] X
C [IPY1,IPY2]
C T = Temporary variable
C TX,TY = Translation vector for mapping world coordi-
C nates to viewport coordinates
C WR = Window radius r = Sin(A)
C WRS = WR**2
C X0,Y0 = Projection plane coordinates of node N0 or
C label location
C X1,Y1,Z1 = Coordinates of vertex KV1 in the rotated
C coordinate system
C X2,Y2,Z2 = Coordinates of vertex KV2 in the rotated
C coordinate system or intersection of edge
C KV1-KV2 with the equator (in the rotated
C coordinate system)
C
C
C Test for invalid parameters.
C
IF (LUN .LT. 0 .OR. LUN .GT. 99 .OR.
. PLTSIZ .LT. 1.0 .OR. PLTSIZ .GT. 8.5 .OR.
. N .LT. 3 .OR. NT .NE. 2*N-4)
. GO TO 11
IF (ABS(ELAT) .GT. 90.0 .OR. ABS(ELON) .GT. 180.0
. .OR. A .GT. 90.0) GO TO 12
C
C Compute a conversion factor CF for degrees to radians
C and compute the window radius WR.
C
CF = ATAN(1.0)/45.0
WR = SIN(CF*A)
WRS = WR*WR
C
C Compute the lower left (IPX1,IPY1) and upper right
C (IPX2,IPY2) corner coordinates of the bounding box.
C The coordinates, specified in default user space units
C (points, at 72 points/inch with origin at the lower
C left corner of the page), are chosen to preserve the
C square aspect ratio, and to center the plot on the 8.5
C by 11 inch page. The center of the page is (306,396),
C and IR = PLTSIZ/2 in points.
C
IR = NINT(36.0*PLTSIZ)
IPX1 = 306 - IR
IPX2 = 306 + IR
IPY1 = 396 - IR
IPY2 = 396 + IR
C
C Output header comments.
C
WRITE (LUN,100,ERR=13) IPX1, IPY1, IPX2, IPY2
100 FORMAT ('%!PS-Adobe-3.0 EPSF-3.0'/
. '%%BoundingBox:',4I4/
. '%%Title: Voronoi diagram'/
. '%%Creator: STRIPACK'/
. '%%EndComments')
C
C Set (IPX1,IPY1) and (IPX2,IPY2) to the corner coordinates
C of a viewport box obtained by shrinking the bounding box
C by 12% in each dimension.
C
IR = NINT(0.88*REAL(IR,8))
IPX1 = 306 - IR
IPX2 = 306 + IR
IPY1 = 396 - IR
IPY2 = 396 + IR
C
C Set the line thickness to 2 points, and draw the
C viewport boundary.
C
T = 2.0
WRITE (LUN,110,ERR=13) T
WRITE (LUN,120,ERR=13) IR
WRITE (LUN,130,ERR=13)
110 FORMAT (F12.6,' setlinewidth')
120 FORMAT ('306 396 ',I3,' 0 360 arc')
130 FORMAT ('stroke')
C
C Set up an affine mapping from the window box [-WR,WR] X
C [-WR,WR] to the viewport box.
C
SF = REAL(IR,8)/WR
TX = IPX1 + SF*WR
TY = IPY1 + SF*WR
WRITE (LUN,140,ERR=13) TX, TY, SF, SF
140 FORMAT (2F12.6,' translate'/
. 2F12.6,' scale')
C
C The line thickness must be changed to reflect the new
C scaling which is applied to all subsequent output.
C Set it to 1.0 point.
C
T = 1.0/SF
WRITE (LUN,110,ERR=13) T
C
C Save the current graphics state, and set the clip path to
C the boundary of the window.
C
WRITE (LUN,150,ERR=13)
WRITE (LUN,160,ERR=13) WR
WRITE (LUN,170,ERR=13)
150 FORMAT ('gsave')
160 FORMAT ('0 0 ',F12.6,' 0 360 arc')
170 FORMAT ('clip newpath')
C
C Compute the Cartesian coordinates of E and the components
C of a rotation R which maps E to the north pole (0,0,1).
C R is taken to be a rotation about the z-axis (into the
C yz-plane) followed by a rotation about the x-axis chosen
C so that the view-up direction is (0,0,1), or (-1,0,0) if
C E is the north or south pole.
C
C ( R11 R12 0 )
C R = ( R21 R22 R23 )
C ( EX EY EZ )
C
T = CF*ELON
CT = COS(CF*ELAT)
EX = CT*COS(T)
EY = CT*SIN(T)
EZ = SIN(CF*ELAT)
IF (CT .NE. 0.0) THEN
R11 = -EY/CT
R12 = EX/CT
ELSE
R11 = 0.0
R12 = 1.0
ENDIF
R21 = -EZ*R12
R22 = EZ*R11
R23 = CT
C
C Loop on nodes (Voronoi centers) N0.
C LPL indexes the last neighbor of N0.
C
DO 3 N0 = 1,N
LPL = LEND(N0)
C
C Set KV2 to the first (and last) vertex index and compute
C its coordinates (X2,Y2,Z2) in the rotated coordinate
C system.
C
KV2 = LISTC(LPL)
X2 = R11*XC(KV2) + R12*YC(KV2)
Y2 = R21*XC(KV2) + R22*YC(KV2) + R23*ZC(KV2)
Z2 = EX*XC(KV2) + EY*YC(KV2) + EZ*ZC(KV2)
C
C IN2 = TRUE iff KV2 is in the window.
C
IN2 = Z2 .GE. 0. .AND. X2*X2 + Y2*Y2 .LE. WRS
C
C Loop on neighbors N1 of N0. For each triangulation edge
C N0-N1, KV1-KV2 is the corresponding Voronoi edge.
C
LP = LPL
1 LP = LPTR(LP)
KV1 = KV2
X1 = X2
Y1 = Y2
Z1 = Z2
IN1 = IN2
KV2 = LISTC(LP)
C
C Compute the new values of (X2,Y2,Z2) and IN2.
C
X2 = R11*XC(KV2) + R12*YC(KV2)
Y2 = R21*XC(KV2) + R22*YC(KV2) + R23*ZC(KV2)
Z2 = EX*XC(KV2) + EY*YC(KV2) + EZ*ZC(KV2)
IN2 = Z2 .GE. 0. .AND. X2*X2 + Y2*Y2 .LE. WRS
C
C Add edge KV1-KV2 to the path iff both endpoints are inside
C the window and KV2 > KV1, or KV1 is inside and KV2 is
C outside (so that the edge is drawn only once).
C
IF (.NOT. IN1 .OR. (IN2 .AND. KV2 .LE. KV1))
. GO TO 2
IF (Z2 .LT. 0.) THEN
C
C KV2 is a 'southern hemisphere' point. Move it to the
C intersection of edge KV1-KV2 with the equator so that
C the edge is clipped properly. Z2 is implicitly set
C to 0.
C
X2 = Z1*X2 - Z2*X1
Y2 = Z1*Y2 - Z2*Y1
T = SQRT(X2*X2+Y2*Y2)
X2 = X2/T
Y2 = Y2/T
ENDIF
WRITE (LUN,180,ERR=13) X1, Y1, X2, Y2
180 FORMAT (2F12.6,' moveto',2F12.6,' lineto')
C
C Bottom of loops.
C
2 IF (LP .NE. LPL) GO TO 1
3 CONTINUE
C
C Paint the path and restore the saved graphics state (with
C no clip path).
C
WRITE (LUN,130,ERR=13)
WRITE (LUN,190,ERR=13)
190 FORMAT ('grestore')
IF (NUMBR) THEN
C
C Nodes in the window are to be labeled with their indexes.
C Convert FSIZN from points to world coordinates, and
C output the commands to select a font and scale it.
C
T = FSIZN/SF
WRITE (LUN,200,ERR=13) T
200 FORMAT ('/Helvetica findfont'/
. F12.6,' scalefont setfont')
C
C Loop on visible nodes N0 that project to points (X0,Y0) in
C the window.
C
DO 4 N0 = 1,N
IF (EX*X(N0) + EY*Y(N0) + EZ*Z(N0) .LT. 0.)
. GO TO 4
X0 = R11*X(N0) + R12*Y(N0)
Y0 = R21*X(N0) + R22*Y(N0) + R23*Z(N0)
IF (X0*X0 + Y0*Y0 .GT. WRS) GO TO 4
C
C Move to (X0,Y0), and draw the label N0 with the origin
C of the first character at (X0,Y0).
C
WRITE (LUN,210,ERR=13) X0, Y0
WRITE (LUN,220,ERR=13) N0
210 FORMAT (2F12.6,' moveto')
220 FORMAT ('(',I3,') show')
4 CONTINUE
ENDIF
C
C Convert FSIZT from points to world coordinates, and output
C the commands to select a font and scale it.
C
T = FSIZT/SF
WRITE (LUN,200,ERR=13) T
C
C Display TITLE centered above the plot:
C
Y0 = WR + 3.0*T
WRITE (LUN,230,ERR=13) TITLE, Y0
230 FORMAT (A80/' stringwidth pop 2 div neg ',F12.6,
. ' moveto')
WRITE (LUN,240,ERR=13) TITLE
240 FORMAT (A80/' show')
IF (ANNOT) THEN
C
C Display the window center and radius below the plot.
C
X0 = -WR
Y0 = -WR - 50.0/SF
WRITE (LUN,210,ERR=13) X0, Y0
WRITE (LUN,250,ERR=13) ELAT, ELON
Y0 = Y0 - 2.0*T
WRITE (LUN,210,ERR=13) X0, Y0
WRITE (LUN,260,ERR=13) A
250 FORMAT ('(Window center: ELAT = ',F7.2,
. ', ELON = ',F8.2,') show')
260 FORMAT ('(Angular extent: A = ',F5.2,') show')
ENDIF
C
C Paint the path and output the showpage command and
C end-of-file indicator.
C
WRITE (LUN,270,ERR=13)
270 FORMAT ('stroke'/
. 'showpage'/
. '%%EOF')
C
C HP's interpreters require a one-byte End-of-PostScript-Job
C indicator (to eliminate a timeout error message):
C ASCII 4.
C
WRITE (LUN,280,ERR=13) CHAR(4)
280 FORMAT (A1)
C
C No error encountered.
C
IER = 0
RETURN
C
C Invalid input parameter LUN, PLTSIZ, N, or NT.
C
11 IER = 1
RETURN
C
C Invalid input parameter ELAT, ELON, or A.
C
12 IER = 2
RETURN
C
C Error writing to unit LUN.
C
13 IER = 3
RETURN
END
| mit |
davidho95/WaveEqCurvedSpacetime | CurvedSEM2d/src/gll_library.f90 | 4 | 13139 |
!=======================================================================
!
! Library to compute the Gauss-Lobatto-Legendre points and weights
! Based on Gauss-Lobatto routines from M.I.T.
! Department of Mechanical Engineering
!
!=======================================================================
double precision function endw1(n,alpha,beta)
implicit none
integer n
double precision alpha,beta
double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0,three=3.d0,four=4.d0
double precision apb,f1,fint1,fint2,f2,di,abn,abnn,a1,a2,a3,f3
double precision, external :: gammaf
integer i
f3 = zero
apb = alpha+beta
if(n == 0) then
endw1 = zero
return
endif
f1 = gammaf(alpha+two)*gammaf(beta+one)/gammaf(apb+three)
f1 = f1*(apb+two)*two**(apb+two)/two
if(n == 1) then
endw1 = f1
return
endif
fint1 = gammaf(alpha+two)*gammaf(beta+one)/gammaf(apb+three)
fint1 = fint1*two**(apb+two)
fint2 = gammaf(alpha+two)*gammaf(beta+two)/gammaf(apb+four)
fint2 = fint2*two**(apb+three)
f2 = (-two*(beta+two)*fint1 + (apb+four)*fint2) * (apb+three)/four
if(n == 2) then
endw1 = f2
return
endif
do i=3,n
di = dble(i-1)
abn = alpha+beta+di
abnn = abn+di
a1 = -(two*(di+alpha)*(di+beta))/(abn*abnn*(abnn+one))
a2 = (two*(alpha-beta))/(abnn*(abnn+two))
a3 = (two*(abn+one))/((abnn+two)*(abnn+one))
f3 = -(a2*f2+a1*f1)/a3
f1 = f2
f2 = f3
enddo
endw1 = f3
end function endw1
!
!=======================================================================
!
double precision function endw2(n,alpha,beta)
implicit none
integer n
double precision alpha,beta
double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0,three=3.d0,four=4.d0
double precision apb,f1,fint1,fint2,f2,di,abn,abnn,a1,a2,a3,f3
double precision, external :: gammaf
integer i
apb = alpha+beta
f3 = zero
if (n == 0) then
endw2 = zero
return
endif
f1 = gammaf(alpha+one)*gammaf(beta+two)/gammaf(apb+three)
f1 = f1*(apb+two)*two**(apb+two)/two
if (n == 1) then
endw2 = f1
return
endif
fint1 = gammaf(alpha+one)*gammaf(beta+two)/gammaf(apb+three)
fint1 = fint1*two**(apb+two)
fint2 = gammaf(alpha+two)*gammaf(beta+two)/gammaf(apb+four)
fint2 = fint2*two**(apb+three)
f2 = (two*(alpha+two)*fint1 - (apb+four)*fint2) * (apb+three)/four
if (n == 2) then
endw2 = f2
return
endif
do i=3,n
di = dble(i-1)
abn = alpha+beta+di
abnn = abn+di
a1 = -(two*(di+alpha)*(di+beta))/(abn*abnn*(abnn+one))
a2 = (two*(alpha-beta))/(abnn*(abnn+two))
a3 = (two*(abn+one))/((abnn+two)*(abnn+one))
f3 = -(a2*f2+a1*f1)/a3
f1 = f2
f2 = f3
enddo
endw2 = f3
end function endw2
!
!=======================================================================
!
double precision function gammaf (x)
implicit none
double precision, parameter :: pi = 3.141592653589793d0
double precision x
double precision, parameter :: half=0.5d0,one=1.d0,two=2.d0
gammaf = one
if (x == -half) gammaf = -two*sqrt(pi)
if (x == half) gammaf = sqrt(pi)
if (x == one ) gammaf = one
if (x == two ) gammaf = one
if (x == 1.5d0) gammaf = sqrt(pi)/2.d0
if (x == 2.5d0) gammaf = 1.5d0*sqrt(pi)/2.d0
if (x == 3.5d0) gammaf = 2.5d0*1.5d0*sqrt(pi)/2.d0
if (x == 3.d0 ) gammaf = 2.d0
if (x == 4.d0 ) gammaf = 6.d0
if (x == 5.d0 ) gammaf = 24.d0
if (x == 6.d0 ) gammaf = 120.d0
end function gammaf
!
!=====================================================================
!
subroutine jacg (xjac,np,alpha,beta)
!=======================================================================
!
! computes np Gauss points, which are the zeros of the
! Jacobi polynomial with parameters alpha and beta
!
! .alpha = beta = 0.0 -> Legendre points
! .alpha = beta = -0.5 -> Chebyshev points
!
!=======================================================================
implicit none
integer np
double precision alpha,beta
double precision xjac(np)
integer k,j,i,jmin,jm,n
double precision xlast,dth,x,x1,x2,recsum,delx,xmin,swap
double precision p,pd,pm1,pdm1,pm2,pdm2
integer, parameter :: K_MAX_ITER = 10
double precision, parameter :: zero = 0.d0, eps = 1.0d-12
pm1 = zero
pm2 = zero
pdm1 = zero
pdm2 = zero
xlast = 0.d0
n = np-1
dth = 4.d0*atan(1.d0)/(2.d0*dble(n)+2.d0)
p = 0.d0
pd = 0.d0
jmin = 0
do j=1,np
if(j == 1) then
x = cos((2.d0*(dble(j)-1.d0)+1.d0)*dth)
else
x1 = cos((2.d0*(dble(j)-1.d0)+1.d0)*dth)
x2 = xlast
x = (x1+x2)/2.d0
endif
do k=1,K_MAX_ITER
call jacobf (p,pd,pm1,pdm1,pm2,pdm2,np,alpha,beta,x)
recsum = 0.d0
jm = j-1
do i=1,jm
recsum = recsum+1.d0/(x-xjac(np-i+1))
enddo
delx = -p/(pd-recsum*p)
x = x+delx
if(abs(delx) < eps) goto 31
enddo
31 continue
xjac(np-j+1) = x
xlast = x
enddo
do i=1,np
xmin = 2.d0
do j=i,np
if(xjac(j) < xmin) then
xmin = xjac(j)
jmin = j
endif
enddo
if(jmin /= i) then
swap = xjac(i)
xjac(i) = xjac(jmin)
xjac(jmin) = swap
endif
enddo
end subroutine jacg
!
!=====================================================================
!
subroutine jacobf (poly,pder,polym1,pderm1,polym2,pderm2,n,alp,bet,x)
!=======================================================================
!
! Computes the Jacobi polynomial of degree n and its derivative at x
!
!=======================================================================
implicit none
double precision poly,pder,polym1,pderm1,polym2,pderm2,alp,bet,x
integer n
double precision apb,polyl,pderl,dk,a1,a2,b3,a3,a4,polyn,pdern,psave,pdsave
integer k
apb = alp+bet
poly = 1.d0
pder = 0.d0
psave = 0.d0
pdsave = 0.d0
if (n == 0) return
polyl = poly
pderl = pder
poly = (alp-bet+(apb+2.d0)*x)/2.d0
pder = (apb+2.d0)/2.d0
if (n == 1) return
do k=2,n
dk = dble(k)
a1 = 2.d0*dk*(dk+apb)*(2.d0*dk+apb-2.d0)
a2 = (2.d0*dk+apb-1.d0)*(alp**2-bet**2)
b3 = (2.d0*dk+apb-2.d0)
a3 = b3*(b3+1.d0)*(b3+2.d0)
a4 = 2.d0*(dk+alp-1.d0)*(dk+bet-1.d0)*(2.d0*dk+apb)
polyn = ((a2+a3*x)*poly-a4*polyl)/a1
pdern = ((a2+a3*x)*pder-a4*pderl+a3*poly)/a1
psave = polyl
pdsave = pderl
polyl = poly
poly = polyn
pderl = pder
pder = pdern
enddo
polym1 = polyl
pderm1 = pderl
polym2 = psave
pderm2 = pdsave
end subroutine jacobf
!
!------------------------------------------------------------------------
!
double precision FUNCTION PNDLEG (Z,N)
!------------------------------------------------------------------------
!
! Compute the derivative of the Nth order Legendre polynomial at Z.
! Based on the recursion formula for the Legendre polynomials.
!
!------------------------------------------------------------------------
implicit none
double precision z
integer n
double precision P1,P2,P1D,P2D,P3D,FK,P3
integer k
P1 = 1.d0
P2 = Z
P1D = 0.d0
P2D = 1.d0
P3D = 1.d0
do K = 1, N-1
FK = dble(K)
P3 = ((2.d0*FK+1.d0)*Z*P2 - FK*P1)/(FK+1.d0)
P3D = ((2.d0*FK+1.d0)*P2 + (2.d0*FK+1.d0)*Z*P2D - FK*P1D) / (FK+1.d0)
P1 = P2
P2 = P3
P1D = P2D
P2D = P3D
enddo
PNDLEG = P3D
end function pndleg
!
!------------------------------------------------------------------------
!
double precision FUNCTION PNLEG (Z,N)
!------------------------------------------------------------------------
!
! Compute the value of the Nth order Legendre polynomial at Z.
! Based on the recursion formula for the Legendre polynomials.
!
!------------------------------------------------------------------------
implicit none
double precision z
integer n
double precision P1,P2,P3,FK
integer k
P1 = 1.d0
P2 = Z
P3 = P2
do K = 1, N-1
FK = dble(K)
P3 = ((2.d0*FK+1.d0)*Z*P2 - FK*P1)/(FK+1.d0)
P1 = P2
P2 = P3
enddo
PNLEG = P3
end function pnleg
!
!------------------------------------------------------------------------
!
double precision function pnglj(z,n)
!------------------------------------------------------------------------
!
! Compute the value of the Nth order polynomial of the
! Gauss-Lobatto-Jacobi (0,1) at Z. from Legendre polynomials.
!
!------------------------------------------------------------------------
implicit none
double precision z
integer n
double precision, external :: pnleg
double precision, parameter :: TINYVAL = 1.d-15
double precision, parameter :: ONE = 1.d0
if (abs(z+1.d0) > TINYVAL) then ! if (z /= -1.d0)
pnglj = (pnleg(z,n)+pnleg(z,n+1))/(ONE+z)
else
pnglj = (dble(n)+ONE)*(-1)**n
endif
end function pnglj
!
!------------------------------------------------------------------------
!
double precision function pnormj (n,alpha,beta)
implicit none
double precision alpha,beta
integer n
double precision one,two,dn,const,prod,dindx,frac
double precision, external :: gammaf
integer i
one = 1.d0
two = 2.d0
dn = dble(n)
const = alpha+beta+one
if (n <= 1) then
prod = gammaf(dn+alpha)*gammaf(dn+beta)
prod = prod/(gammaf(dn)*gammaf(dn+alpha+beta))
pnormj = prod * two**const/(two*dn+const)
return
endif
prod = gammaf(alpha+one)*gammaf(beta+one)
prod = prod/(two*(one+const)*gammaf(const+one))
prod = prod*(one+alpha)*(two+alpha)
prod = prod*(one+beta)*(two+beta)
do i=3,n
dindx = dble(i)
frac = (dindx+alpha)*(dindx+beta)/(dindx*(dindx+alpha+beta))
prod = prod*frac
enddo
pnormj = prod * two**const/(two*dn+const)
end function pnormj
!
!------------------------------------------------------------------------
!
subroutine zwgjd(z,w,np,alpha,beta)
!=======================================================================
!
! Z w g j d : Generate np Gauss-Jacobi points and weights
! associated with Jacobi polynomial of degree n = np-1
!
! Note : Coefficients alpha and beta must be greater than -1.
! ----
!=======================================================================
implicit none
double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0
integer np
double precision z(np),w(np)
double precision alpha,beta
integer n,np1,np2,i
double precision p,pd,pm1,pdm1,pm2,pdm2
double precision apb,dnp1,dnp2,fac1,fac2,fac3,fnorm,rcoef
double precision, external :: gammaf,pnormj
pd = zero
pm1 = zero
pm2 = zero
pdm1 = zero
pdm2 = zero
n = np-1
apb = alpha+beta
p = zero
pdm1 = zero
if (np <= 0) stop 'minimum number of Gauss points is 1'
if ((alpha <= -one) .or. (beta <= -one)) stop 'alpha and beta must be greater than -1'
if (np == 1) then
z(1) = (beta-alpha)/(apb+two)
w(1) = gammaf(alpha+one)*gammaf(beta+one)/gammaf(apb+two) * two**(apb+one)
return
endif
call jacg(z,np,alpha,beta)
np1 = n+1
np2 = n+2
dnp1 = dble(np1)
dnp2 = dble(np2)
fac1 = dnp1+alpha+beta+one
fac2 = fac1+dnp1
fac3 = fac2+one
fnorm = pnormj(np1,alpha,beta)
rcoef = (fnorm*fac2*fac3)/(two*fac1*dnp2)
do i=1,np
call jacobf(p,pd,pm1,pdm1,pm2,pdm2,np2,alpha,beta,z(i))
w(i) = -rcoef/(p*pdm1)
enddo
end subroutine zwgjd
!
!------------------------------------------------------------------------
!
subroutine zwgljd(z,w,np,alpha,beta)
!=======================================================================
!
! Z w g l j d : Generate np Gauss-Lobatto-Jacobi points and the
! ----------- weights associated with Jacobi polynomials of degree
! n = np-1.
!
! Note : alpha and beta coefficients must be greater than -1.
! Legendre polynomials are special case of Jacobi polynomials
! just by setting alpha and beta to 0.
!
!=======================================================================
implicit none
double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0
integer np
double precision alpha,beta
double precision z(np), w(np)
integer n,nm1,i
double precision p,pd,pm1,pdm1,pm2,pdm2
double precision alpg,betg
double precision, external :: endw1,endw2
p = zero
pm1 = zero
pm2 = zero
pdm1 = zero
pdm2 = zero
n = np-1
nm1 = n-1
pd = zero
if (np <= 1) stop 'minimum number of Gauss-Lobatto points is 2'
! with spectral elements, use at least 3 points
if (np <= 2) stop 'minimum number of Gauss-Lobatto points for the SEM is 3'
if ((alpha <= -one) .or. (beta <= -one)) stop 'alpha and beta must be greater than -1'
if (nm1 > 0) then
alpg = alpha+one
betg = beta+one
call zwgjd(z(2),w(2),nm1,alpg,betg)
endif
z(1) = - one
z(np) = one
do i=2,np-1
w(i) = w(i)/(one-z(i)**2)
enddo
call jacobf(p,pd,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(1))
w(1) = endw1(n,alpha,beta)/(two*pd)
call jacobf(p,pd,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(np))
w(np) = endw2(n,alpha,beta)/(two*pd)
end subroutine zwgljd
| gpl-3.0 |
SaberMod/GCC_SaberMod | libgfortran/generated/_sinh_r4.F90 | 35 | 1473 | ! Copyright (C) 2002-2014 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_4)
#ifdef HAVE_SINHF
elemental function _gfortran_specific__sinh_r4 (parm)
real (kind=4), intent (in) :: parm
real (kind=4) :: _gfortran_specific__sinh_r4
_gfortran_specific__sinh_r4 = sinh (parm)
end function
#endif
#endif
| gpl-2.0 |
ARTED/ARTED_noc | src/PSE_hpsi_DFT.f90 | 1 | 2318 | !
! Copyright 2016 ARTED developers
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
subroutine PSE_hpsi_DFT(ik)
use global_variables
use PSE_variables
implicit none
integer :: ik
integer :: i,ix,iy,iz
real(8) :: kAc2_2
integer :: ilma,ia,j
complex(8) :: uVpsi
kAc2_2=sum(kAc_Cvec(:,ik)**2)*0.5
do i=1,NL
zft2(iLx(1,i),iLx(2,i),iLx(3,i))=tpsi(i)
end do
do ix=0,NL1-1
do iy=0,NL2-1
do iz=0,NL3-1
zft1(ix,iy,iz)=sum(cexp_x3(:,iz)*zft2(ix,iy,:))
end do
end do
end do
do ix=0,NL1-1
do iy=0,NL2-1
do iz=0,NL3-1
zft2(ix,iy,iz)=sum(cexp_x2(:,iy)*zft1(ix,:,iz))
end do
end do
end do
do ix=0,NL1-1
do iy=0,NL2-1
do iz=0,NL3-1
zft1(ix,iy,iz)=sum(cexp_x1(:,ix)*zft2(:,iy,iz))
end do
end do
end do
zft1(:,:,:)=(-0.5d0*Lap_k(:,:,:) &
-kAc_Cvec(1,ik)*Grad_x_zI(:,:,:) &
-kAc_Cvec(2,ik)*Grad_y_zI(:,:,:) &
-kAc_Cvec(3,ik)*Grad_z_zI(:,:,:) &
)*zft1(:,:,:)/dble(NL1*NL2*NL3)
do ix=0,NL1-1
do iy=0,NL2-1
do iz=0,NL3-1
zft2(ix,iy,iz)=sum(exp_x3(:,iz)*zft1(ix,iy,:))
end do
end do
end do
do ix=0,NL1-1
do iy=0,NL2-1
do iz=0,NL3-1
zft1(ix,iy,iz)=sum(exp_x2(:,iy)*zft2(ix,:,iz))
end do
end do
end do
do ix=0,NL1-1
do iy=0,NL2-1
do iz=0,NL3-1
zft2(ix,iy,iz)=sum(exp_x1(:,ix)*zft1(:,iy,iz))
end do
end do
end do
do i=1,NL
htpsi(i)=zft2(iLx(1,i),iLx(2,i),iLx(3,i))
end do
htpsi=htpsi+(Vloc+kAc2_2)*tpsi
! return
!Calculating nonlocal part
do ilma=1,Nlma
ia=a_tbl(ilma)
uVpsi=0.d0
do j=1,Mps(ia)
i=Jxyz(j,ia)
uVpsi=uVpsi+uV(j,ilma)*ekr(j,ia,ik)*tpsi(i)
enddo
uVpsi=uVpsi*H123*iuV(ilma)
do j=1,Mps(ia)
i=Jxyz(j,ia)
htpsi(i)=htpsi(i)+conjg(ekr(j,ia,ik))*uVpsi*uV(j,ilma)
enddo
enddo
return
end subroutine PSE_hpsi_DFT
| apache-2.0 |
jag1g13/lammps | lib/linalg/dgesvd.f | 52 | 134919 | *> \brief <b> DGESVD computes the singular value decomposition (SVD) for GE matrices</b>
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download DGESVD + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgesvd.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgesvd.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgesvd.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE DGESVD( JOBU, JOBVT, M, N, A, LDA, S, U, LDU, VT, LDVT,
* WORK, LWORK, INFO )
*
* .. Scalar Arguments ..
* CHARACTER JOBU, JOBVT
* INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
* ..
* .. Array Arguments ..
* DOUBLE PRECISION A( LDA, * ), S( * ), U( LDU, * ),
* $ VT( LDVT, * ), WORK( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DGESVD computes the singular value decomposition (SVD) of a real
*> M-by-N matrix A, optionally computing the left and/or right singular
*> vectors. The SVD is written
*>
*> A = U * SIGMA * transpose(V)
*>
*> where SIGMA is an M-by-N matrix which is zero except for its
*> min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and
*> V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA
*> are the singular values of A; they are real and non-negative, and
*> are returned in descending order. The first min(m,n) columns of
*> U and V are the left and right singular vectors of A.
*>
*> Note that the routine returns V**T, not V.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] JOBU
*> \verbatim
*> JOBU is CHARACTER*1
*> Specifies options for computing all or part of the matrix U:
*> = 'A': all M columns of U are returned in array U:
*> = 'S': the first min(m,n) columns of U (the left singular
*> vectors) are returned in the array U;
*> = 'O': the first min(m,n) columns of U (the left singular
*> vectors) are overwritten on the array A;
*> = 'N': no columns of U (no left singular vectors) are
*> computed.
*> \endverbatim
*>
*> \param[in] JOBVT
*> \verbatim
*> JOBVT is CHARACTER*1
*> Specifies options for computing all or part of the matrix
*> V**T:
*> = 'A': all N rows of V**T are returned in the array VT;
*> = 'S': the first min(m,n) rows of V**T (the right singular
*> vectors) are returned in the array VT;
*> = 'O': the first min(m,n) rows of V**T (the right singular
*> vectors) are overwritten on the array A;
*> = 'N': no rows of V**T (no right singular vectors) are
*> computed.
*>
*> JOBVT and JOBU cannot both be 'O'.
*> \endverbatim
*>
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> The number of rows of the input matrix A. M >= 0.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of columns of the input matrix A. N >= 0.
*> \endverbatim
*>
*> \param[in,out] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (LDA,N)
*> On entry, the M-by-N matrix A.
*> On exit,
*> if JOBU = 'O', A is overwritten with the first min(m,n)
*> columns of U (the left singular vectors,
*> stored columnwise);
*> if JOBVT = 'O', A is overwritten with the first min(m,n)
*> rows of V**T (the right singular vectors,
*> stored rowwise);
*> if JOBU .ne. 'O' and JOBVT .ne. 'O', the contents of A
*> are destroyed.
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of the array A. LDA >= max(1,M).
*> \endverbatim
*>
*> \param[out] S
*> \verbatim
*> S is DOUBLE PRECISION array, dimension (min(M,N))
*> The singular values of A, sorted so that S(i) >= S(i+1).
*> \endverbatim
*>
*> \param[out] U
*> \verbatim
*> U is DOUBLE PRECISION array, dimension (LDU,UCOL)
*> (LDU,M) if JOBU = 'A' or (LDU,min(M,N)) if JOBU = 'S'.
*> If JOBU = 'A', U contains the M-by-M orthogonal matrix U;
*> if JOBU = 'S', U contains the first min(m,n) columns of U
*> (the left singular vectors, stored columnwise);
*> if JOBU = 'N' or 'O', U is not referenced.
*> \endverbatim
*>
*> \param[in] LDU
*> \verbatim
*> LDU is INTEGER
*> The leading dimension of the array U. LDU >= 1; if
*> JOBU = 'S' or 'A', LDU >= M.
*> \endverbatim
*>
*> \param[out] VT
*> \verbatim
*> VT is DOUBLE PRECISION array, dimension (LDVT,N)
*> If JOBVT = 'A', VT contains the N-by-N orthogonal matrix
*> V**T;
*> if JOBVT = 'S', VT contains the first min(m,n) rows of
*> V**T (the right singular vectors, stored rowwise);
*> if JOBVT = 'N' or 'O', VT is not referenced.
*> \endverbatim
*>
*> \param[in] LDVT
*> \verbatim
*> LDVT is INTEGER
*> The leading dimension of the array VT. LDVT >= 1; if
*> JOBVT = 'A', LDVT >= N; if JOBVT = 'S', LDVT >= min(M,N).
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK;
*> if INFO > 0, WORK(2:MIN(M,N)) contains the unconverged
*> superdiagonal elements of an upper bidiagonal matrix B
*> whose diagonal is in S (not necessarily sorted). B
*> satisfies A = U * B * VT, so it has the same singular values
*> as A, and singular vectors related by U and VT.
*> \endverbatim
*>
*> \param[in] LWORK
*> \verbatim
*> LWORK is INTEGER
*> The dimension of the array WORK.
*> LWORK >= MAX(1,5*MIN(M,N)) for the paths (see comments inside code):
*> - PATH 1 (M much larger than N, JOBU='N')
*> - PATH 1t (N much larger than M, JOBVT='N')
*> LWORK >= MAX(1,3*MIN(M,N)+MAX(M,N),5*MIN(M,N)) for the other paths
*> For good performance, LWORK should generally be larger.
*>
*> 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] INFO
*> \verbatim
*> INFO is INTEGER
*> = 0: successful exit.
*> < 0: if INFO = -i, the i-th argument had an illegal value.
*> > 0: if DBDSQR did not converge, INFO specifies how many
*> superdiagonals of an intermediate bidiagonal form B
*> did not converge to zero. See the description of WORK
*> above for details.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date April 2012
*
*> \ingroup doubleGEsing
*
* =====================================================================
SUBROUTINE DGESVD( JOBU, JOBVT, M, N, A, LDA, S, U, LDU,
$ VT, LDVT, WORK, LWORK, 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 JOBU, JOBVT
INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
* ..
* .. Array Arguments ..
DOUBLE PRECISION A( LDA, * ), S( * ), U( LDU, * ),
$ VT( LDVT, * ), WORK( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
* ..
* .. Local Scalars ..
LOGICAL LQUERY, WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS,
$ WNTVA, WNTVAS, WNTVN, WNTVO, WNTVS
INTEGER BDSPAC, BLK, CHUNK, I, IE, IERR, IR, ISCL,
$ ITAU, ITAUP, ITAUQ, IU, IWORK, LDWRKR, LDWRKU,
$ MAXWRK, MINMN, MINWRK, MNTHR, NCU, NCVT, NRU,
$ NRVT, WRKBL
INTEGER LWORK_DGEQRF, LWORK_DORGQR_N, LWORK_DORGQR_M,
$ LWORK_DGEBRD, LWORK_DORGBR_P, LWORK_DORGBR_Q,
$ LWORK_DGELQF, LWORK_DORGLQ_N, LWORK_DORGLQ_M
DOUBLE PRECISION ANRM, BIGNUM, EPS, SMLNUM
* ..
* .. Local Arrays ..
DOUBLE PRECISION DUM( 1 )
* ..
* .. External Subroutines ..
EXTERNAL DBDSQR, DGEBRD, DGELQF, DGEMM, DGEQRF, DLACPY,
$ DLASCL, DLASET, DORGBR, DORGLQ, DORGQR, DORMBR,
$ XERBLA
* ..
* .. External Functions ..
LOGICAL LSAME
INTEGER ILAENV
DOUBLE PRECISION DLAMCH, DLANGE
EXTERNAL LSAME, ILAENV, DLAMCH, DLANGE
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN, SQRT
* ..
* .. Executable Statements ..
*
* Test the input arguments
*
INFO = 0
MINMN = MIN( M, N )
WNTUA = LSAME( JOBU, 'A' )
WNTUS = LSAME( JOBU, 'S' )
WNTUAS = WNTUA .OR. WNTUS
WNTUO = LSAME( JOBU, 'O' )
WNTUN = LSAME( JOBU, 'N' )
WNTVA = LSAME( JOBVT, 'A' )
WNTVS = LSAME( JOBVT, 'S' )
WNTVAS = WNTVA .OR. WNTVS
WNTVO = LSAME( JOBVT, 'O' )
WNTVN = LSAME( JOBVT, 'N' )
LQUERY = ( LWORK.EQ.-1 )
*
IF( .NOT.( WNTUA .OR. WNTUS .OR. WNTUO .OR. WNTUN ) ) THEN
INFO = -1
ELSE IF( .NOT.( WNTVA .OR. WNTVS .OR. WNTVO .OR. WNTVN ) .OR.
$ ( WNTVO .AND. WNTUO ) ) THEN
INFO = -2
ELSE IF( M.LT.0 ) THEN
INFO = -3
ELSE IF( N.LT.0 ) THEN
INFO = -4
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
INFO = -6
ELSE IF( LDU.LT.1 .OR. ( WNTUAS .AND. LDU.LT.M ) ) THEN
INFO = -9
ELSE IF( LDVT.LT.1 .OR. ( WNTVA .AND. LDVT.LT.N ) .OR.
$ ( WNTVS .AND. LDVT.LT.MINMN ) ) THEN
INFO = -11
END IF
*
* Compute workspace
* (Note: Comments in the code beginning "Workspace:" describe the
* minimal amount of workspace needed at that point in the code,
* as well as the preferred amount for good performance.
* NB refers to the optimal block size for the immediately
* following subroutine, as returned by ILAENV.)
*
IF( INFO.EQ.0 ) THEN
MINWRK = 1
MAXWRK = 1
IF( M.GE.N .AND. MINMN.GT.0 ) THEN
*
* Compute space needed for DBDSQR
*
MNTHR = ILAENV( 6, 'DGESVD', JOBU // JOBVT, M, N, 0, 0 )
BDSPAC = 5*N
* Compute space needed for DGEQRF
CALL DGEQRF( M, N, A, LDA, DUM(1), DUM(1), -1, IERR )
LWORK_DGEQRF=DUM(1)
* Compute space needed for DORGQR
CALL DORGQR( M, N, N, A, LDA, DUM(1), DUM(1), -1, IERR )
LWORK_DORGQR_N=DUM(1)
CALL DORGQR( M, M, N, A, LDA, DUM(1), DUM(1), -1, IERR )
LWORK_DORGQR_M=DUM(1)
* Compute space needed for DGEBRD
CALL DGEBRD( N, N, A, LDA, S, DUM(1), DUM(1),
$ DUM(1), DUM(1), -1, IERR )
LWORK_DGEBRD=DUM(1)
* Compute space needed for DORGBR P
CALL DORGBR( 'P', N, N, N, A, LDA, DUM(1),
$ DUM(1), -1, IERR )
LWORK_DORGBR_P=DUM(1)
* Compute space needed for DORGBR Q
CALL DORGBR( 'Q', N, N, N, A, LDA, DUM(1),
$ DUM(1), -1, IERR )
LWORK_DORGBR_Q=DUM(1)
*
IF( M.GE.MNTHR ) THEN
IF( WNTUN ) THEN
*
* Path 1 (M much larger than N, JOBU='N')
*
MAXWRK = N + LWORK_DGEQRF
MAXWRK = MAX( MAXWRK, 3*N+LWORK_DGEBRD )
IF( WNTVO .OR. WNTVAS )
$ MAXWRK = MAX( MAXWRK, 3*N+LWORK_DORGBR_P )
MAXWRK = MAX( MAXWRK, BDSPAC )
MINWRK = MAX( 4*N, BDSPAC )
ELSE IF( WNTUO .AND. WNTVN ) THEN
*
* Path 2 (M much larger than N, JOBU='O', JOBVT='N')
*
WRKBL = N + LWORK_DGEQRF
WRKBL = MAX( WRKBL, N+LWORK_DORGQR_N )
WRKBL = MAX( WRKBL, 3*N+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = MAX( N*N+WRKBL, N*N+M*N+N )
MINWRK = MAX( 3*N+M, BDSPAC )
ELSE IF( WNTUO .AND. WNTVAS ) THEN
*
* Path 3 (M much larger than N, JOBU='O', JOBVT='S' or
* 'A')
*
WRKBL = N + LWORK_DGEQRF
WRKBL = MAX( WRKBL, N+LWORK_DORGQR_N )
WRKBL = MAX( WRKBL, 3*N+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = MAX( N*N+WRKBL, N*N+M*N+N )
MINWRK = MAX( 3*N+M, BDSPAC )
ELSE IF( WNTUS .AND. WNTVN ) THEN
*
* Path 4 (M much larger than N, JOBU='S', JOBVT='N')
*
WRKBL = N + LWORK_DGEQRF
WRKBL = MAX( WRKBL, N+LWORK_DORGQR_N )
WRKBL = MAX( WRKBL, 3*N+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = N*N + WRKBL
MINWRK = MAX( 3*N+M, BDSPAC )
ELSE IF( WNTUS .AND. WNTVO ) THEN
*
* Path 5 (M much larger than N, JOBU='S', JOBVT='O')
*
WRKBL = N + LWORK_DGEQRF
WRKBL = MAX( WRKBL, N+LWORK_DORGQR_N )
WRKBL = MAX( WRKBL, 3*N+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = 2*N*N + WRKBL
MINWRK = MAX( 3*N+M, BDSPAC )
ELSE IF( WNTUS .AND. WNTVAS ) THEN
*
* Path 6 (M much larger than N, JOBU='S', JOBVT='S' or
* 'A')
*
WRKBL = N + LWORK_DGEQRF
WRKBL = MAX( WRKBL, N+LWORK_DORGQR_N )
WRKBL = MAX( WRKBL, 3*N+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = N*N + WRKBL
MINWRK = MAX( 3*N+M, BDSPAC )
ELSE IF( WNTUA .AND. WNTVN ) THEN
*
* Path 7 (M much larger than N, JOBU='A', JOBVT='N')
*
WRKBL = N + LWORK_DGEQRF
WRKBL = MAX( WRKBL, N+LWORK_DORGQR_M )
WRKBL = MAX( WRKBL, 3*N+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = N*N + WRKBL
MINWRK = MAX( 3*N+M, BDSPAC )
ELSE IF( WNTUA .AND. WNTVO ) THEN
*
* Path 8 (M much larger than N, JOBU='A', JOBVT='O')
*
WRKBL = N + LWORK_DGEQRF
WRKBL = MAX( WRKBL, N+LWORK_DORGQR_M )
WRKBL = MAX( WRKBL, 3*N+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = 2*N*N + WRKBL
MINWRK = MAX( 3*N+M, BDSPAC )
ELSE IF( WNTUA .AND. WNTVAS ) THEN
*
* Path 9 (M much larger than N, JOBU='A', JOBVT='S' or
* 'A')
*
WRKBL = N + LWORK_DGEQRF
WRKBL = MAX( WRKBL, N+LWORK_DORGQR_M )
WRKBL = MAX( WRKBL, 3*N+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, 3*N+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = N*N + WRKBL
MINWRK = MAX( 3*N+M, BDSPAC )
END IF
ELSE
*
* Path 10 (M at least N, but not much larger)
*
CALL DGEBRD( M, N, A, LDA, S, DUM(1), DUM(1),
$ DUM(1), DUM(1), -1, IERR )
LWORK_DGEBRD=DUM(1)
MAXWRK = 3*N + LWORK_DGEBRD
IF( WNTUS .OR. WNTUO ) THEN
CALL DORGBR( 'Q', M, N, N, A, LDA, DUM(1),
$ DUM(1), -1, IERR )
LWORK_DORGBR_Q=DUM(1)
MAXWRK = MAX( MAXWRK, 3*N+LWORK_DORGBR_Q )
END IF
IF( WNTUA ) THEN
CALL DORGBR( 'Q', M, M, N, A, LDA, DUM(1),
$ DUM(1), -1, IERR )
LWORK_DORGBR_Q=DUM(1)
MAXWRK = MAX( MAXWRK, 3*N+LWORK_DORGBR_Q )
END IF
IF( .NOT.WNTVN ) THEN
MAXWRK = MAX( MAXWRK, 3*N+LWORK_DORGBR_P )
END IF
MAXWRK = MAX( MAXWRK, BDSPAC )
MINWRK = MAX( 3*N+M, BDSPAC )
END IF
ELSE IF( MINMN.GT.0 ) THEN
*
* Compute space needed for DBDSQR
*
MNTHR = ILAENV( 6, 'DGESVD', JOBU // JOBVT, M, N, 0, 0 )
BDSPAC = 5*M
* Compute space needed for DGELQF
CALL DGELQF( M, N, A, LDA, DUM(1), DUM(1), -1, IERR )
LWORK_DGELQF=DUM(1)
* Compute space needed for DORGLQ
CALL DORGLQ( N, N, M, DUM(1), N, DUM(1), DUM(1), -1, IERR )
LWORK_DORGLQ_N=DUM(1)
CALL DORGLQ( M, N, M, A, LDA, DUM(1), DUM(1), -1, IERR )
LWORK_DORGLQ_M=DUM(1)
* Compute space needed for DGEBRD
CALL DGEBRD( M, M, A, LDA, S, DUM(1), DUM(1),
$ DUM(1), DUM(1), -1, IERR )
LWORK_DGEBRD=DUM(1)
* Compute space needed for DORGBR P
CALL DORGBR( 'P', M, M, M, A, N, DUM(1),
$ DUM(1), -1, IERR )
LWORK_DORGBR_P=DUM(1)
* Compute space needed for DORGBR Q
CALL DORGBR( 'Q', M, M, M, A, N, DUM(1),
$ DUM(1), -1, IERR )
LWORK_DORGBR_Q=DUM(1)
IF( N.GE.MNTHR ) THEN
IF( WNTVN ) THEN
*
* Path 1t(N much larger than M, JOBVT='N')
*
MAXWRK = M + LWORK_DGELQF
MAXWRK = MAX( MAXWRK, 3*M+LWORK_DGEBRD )
IF( WNTUO .OR. WNTUAS )
$ MAXWRK = MAX( MAXWRK, 3*M+LWORK_DORGBR_Q )
MAXWRK = MAX( MAXWRK, BDSPAC )
MINWRK = MAX( 4*M, BDSPAC )
ELSE IF( WNTVO .AND. WNTUN ) THEN
*
* Path 2t(N much larger than M, JOBU='N', JOBVT='O')
*
WRKBL = M + LWORK_DGELQF
WRKBL = MAX( WRKBL, M+LWORK_DORGLQ_M )
WRKBL = MAX( WRKBL, 3*M+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = MAX( M*M+WRKBL, M*M+M*N+M )
MINWRK = MAX( 3*M+N, BDSPAC )
ELSE IF( WNTVO .AND. WNTUAS ) THEN
*
* Path 3t(N much larger than M, JOBU='S' or 'A',
* JOBVT='O')
*
WRKBL = M + LWORK_DGELQF
WRKBL = MAX( WRKBL, M+LWORK_DORGLQ_M )
WRKBL = MAX( WRKBL, 3*M+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = MAX( M*M+WRKBL, M*M+M*N+M )
MINWRK = MAX( 3*M+N, BDSPAC )
ELSE IF( WNTVS .AND. WNTUN ) THEN
*
* Path 4t(N much larger than M, JOBU='N', JOBVT='S')
*
WRKBL = M + LWORK_DGELQF
WRKBL = MAX( WRKBL, M+LWORK_DORGLQ_M )
WRKBL = MAX( WRKBL, 3*M+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = M*M + WRKBL
MINWRK = MAX( 3*M+N, BDSPAC )
ELSE IF( WNTVS .AND. WNTUO ) THEN
*
* Path 5t(N much larger than M, JOBU='O', JOBVT='S')
*
WRKBL = M + LWORK_DGELQF
WRKBL = MAX( WRKBL, M+LWORK_DORGLQ_M )
WRKBL = MAX( WRKBL, 3*M+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = 2*M*M + WRKBL
MINWRK = MAX( 3*M+N, BDSPAC )
ELSE IF( WNTVS .AND. WNTUAS ) THEN
*
* Path 6t(N much larger than M, JOBU='S' or 'A',
* JOBVT='S')
*
WRKBL = M + LWORK_DGELQF
WRKBL = MAX( WRKBL, M+LWORK_DORGLQ_M )
WRKBL = MAX( WRKBL, 3*M+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = M*M + WRKBL
MINWRK = MAX( 3*M+N, BDSPAC )
ELSE IF( WNTVA .AND. WNTUN ) THEN
*
* Path 7t(N much larger than M, JOBU='N', JOBVT='A')
*
WRKBL = M + LWORK_DGELQF
WRKBL = MAX( WRKBL, M+LWORK_DORGLQ_N )
WRKBL = MAX( WRKBL, 3*M+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = M*M + WRKBL
MINWRK = MAX( 3*M+N, BDSPAC )
ELSE IF( WNTVA .AND. WNTUO ) THEN
*
* Path 8t(N much larger than M, JOBU='O', JOBVT='A')
*
WRKBL = M + LWORK_DGELQF
WRKBL = MAX( WRKBL, M+LWORK_DORGLQ_N )
WRKBL = MAX( WRKBL, 3*M+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = 2*M*M + WRKBL
MINWRK = MAX( 3*M+N, BDSPAC )
ELSE IF( WNTVA .AND. WNTUAS ) THEN
*
* Path 9t(N much larger than M, JOBU='S' or 'A',
* JOBVT='A')
*
WRKBL = M + LWORK_DGELQF
WRKBL = MAX( WRKBL, M+LWORK_DORGLQ_N )
WRKBL = MAX( WRKBL, 3*M+LWORK_DGEBRD )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_P )
WRKBL = MAX( WRKBL, 3*M+LWORK_DORGBR_Q )
WRKBL = MAX( WRKBL, BDSPAC )
MAXWRK = M*M + WRKBL
MINWRK = MAX( 3*M+N, BDSPAC )
END IF
ELSE
*
* Path 10t(N greater than M, but not much larger)
*
CALL DGEBRD( M, N, A, LDA, S, DUM(1), DUM(1),
$ DUM(1), DUM(1), -1, IERR )
LWORK_DGEBRD=DUM(1)
MAXWRK = 3*M + LWORK_DGEBRD
IF( WNTVS .OR. WNTVO ) THEN
* Compute space needed for DORGBR P
CALL DORGBR( 'P', M, N, M, A, N, DUM(1),
$ DUM(1), -1, IERR )
LWORK_DORGBR_P=DUM(1)
MAXWRK = MAX( MAXWRK, 3*M+LWORK_DORGBR_P )
END IF
IF( WNTVA ) THEN
CALL DORGBR( 'P', N, N, M, A, N, DUM(1),
$ DUM(1), -1, IERR )
LWORK_DORGBR_P=DUM(1)
MAXWRK = MAX( MAXWRK, 3*M+LWORK_DORGBR_P )
END IF
IF( .NOT.WNTUN ) THEN
MAXWRK = MAX( MAXWRK, 3*M+LWORK_DORGBR_Q )
END IF
MAXWRK = MAX( MAXWRK, BDSPAC )
MINWRK = MAX( 3*M+N, BDSPAC )
END IF
END IF
MAXWRK = MAX( MAXWRK, MINWRK )
WORK( 1 ) = MAXWRK
*
IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
INFO = -13
END IF
END IF
*
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'DGESVD', -INFO )
RETURN
ELSE IF( LQUERY ) THEN
RETURN
END IF
*
* Quick return if possible
*
IF( M.EQ.0 .OR. N.EQ.0 ) THEN
RETURN
END IF
*
* Get machine constants
*
EPS = DLAMCH( 'P' )
SMLNUM = SQRT( DLAMCH( 'S' ) ) / EPS
BIGNUM = ONE / SMLNUM
*
* Scale A if max element outside range [SMLNUM,BIGNUM]
*
ANRM = DLANGE( 'M', M, N, A, LDA, DUM )
ISCL = 0
IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THEN
ISCL = 1
CALL DLASCL( 'G', 0, 0, ANRM, SMLNUM, M, N, A, LDA, IERR )
ELSE IF( ANRM.GT.BIGNUM ) THEN
ISCL = 1
CALL DLASCL( 'G', 0, 0, ANRM, BIGNUM, M, N, A, LDA, IERR )
END IF
*
IF( M.GE.N ) THEN
*
* A has at least as many rows as columns. If A has sufficiently
* more rows than columns, first reduce using the QR
* decomposition (if sufficient workspace available)
*
IF( M.GE.MNTHR ) THEN
*
IF( WNTUN ) THEN
*
* Path 1 (M much larger than N, JOBU='N')
* No left singular vectors to be computed
*
ITAU = 1
IWORK = ITAU + N
*
* Compute A=Q*R
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Zero out below R
*
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO, A( 2, 1 ), LDA )
IE = 1
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in A
* (Workspace: need 4*N, prefer 3*N+2*N*NB)
*
CALL DGEBRD( N, N, A, LDA, S, WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ), LWORK-IWORK+1,
$ IERR )
NCVT = 0
IF( WNTVO .OR. WNTVAS ) THEN
*
* If right singular vectors desired, generate P'.
* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, A, LDA, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
NCVT = N
END IF
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing right
* singular vectors of A in A if desired
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, NCVT, 0, 0, S, WORK( IE ), A, LDA,
$ DUM, 1, DUM, 1, WORK( IWORK ), INFO )
*
* If right singular vectors desired in VT, copy them there
*
IF( WNTVAS )
$ CALL DLACPY( 'F', N, N, A, LDA, VT, LDVT )
*
ELSE IF( WNTUO .AND. WNTVN ) THEN
*
* Path 2 (M much larger than N, JOBU='O', JOBVT='N')
* N left singular vectors to be overwritten on A and
* no right singular vectors to be computed
*
IF( LWORK.GE.N*N+MAX( 4*N, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IR = 1
IF( LWORK.GE.MAX( WRKBL, LDA*N+N )+LDA*N ) THEN
*
* WORK(IU) is LDA by N, WORK(IR) is LDA by N
*
LDWRKU = LDA
LDWRKR = LDA
ELSE IF( LWORK.GE.MAX( WRKBL, LDA*N+N )+N*N ) THEN
*
* WORK(IU) is LDA by N, WORK(IR) is N by N
*
LDWRKU = LDA
LDWRKR = N
ELSE
*
* WORK(IU) is LDWRKU by N, WORK(IR) is N by N
*
LDWRKU = ( LWORK-N*N-N ) / N
LDWRKR = N
END IF
ITAU = IR + LDWRKR*N
IWORK = ITAU + N
*
* Compute A=Q*R
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R to WORK(IR) and zero out below it
*
CALL DLACPY( 'U', N, N, A, LDA, WORK( IR ), LDWRKR )
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO, WORK( IR+1 ),
$ LDWRKR )
*
* Generate Q in A
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DORGQR( M, N, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in WORK(IR)
* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB)
*
CALL DGEBRD( N, N, WORK( IR ), LDWRKR, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Generate left vectors bidiagonalizing R
* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB)
*
CALL DORGBR( 'Q', N, N, N, WORK( IR ), LDWRKR,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of R in WORK(IR)
* (Workspace: need N*N+BDSPAC)
*
CALL DBDSQR( 'U', N, 0, N, 0, S, WORK( IE ), DUM, 1,
$ WORK( IR ), LDWRKR, DUM, 1,
$ WORK( IWORK ), INFO )
IU = IE + N
*
* Multiply Q in A by left singular vectors of R in
* WORK(IR), storing result in WORK(IU) and copying to A
* (Workspace: need N*N+2*N, prefer N*N+M*N+N)
*
DO 10 I = 1, M, LDWRKU
CHUNK = MIN( M-I+1, LDWRKU )
CALL DGEMM( 'N', 'N', CHUNK, N, N, ONE, A( I, 1 ),
$ LDA, WORK( IR ), LDWRKR, ZERO,
$ WORK( IU ), LDWRKU )
CALL DLACPY( 'F', CHUNK, N, WORK( IU ), LDWRKU,
$ A( I, 1 ), LDA )
10 CONTINUE
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
IE = 1
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize A
* (Workspace: need 3*N+M, prefer 3*N+(M+N)*NB)
*
CALL DGEBRD( M, N, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Generate left vectors bidiagonalizing A
* (Workspace: need 4*N, prefer 3*N+N*NB)
*
CALL DORGBR( 'Q', M, N, N, A, LDA, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in A
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, 0, M, 0, S, WORK( IE ), DUM, 1,
$ A, LDA, DUM, 1, WORK( IWORK ), INFO )
*
END IF
*
ELSE IF( WNTUO .AND. WNTVAS ) THEN
*
* Path 3 (M much larger than N, JOBU='O', JOBVT='S' or 'A')
* N left singular vectors to be overwritten on A and
* N right singular vectors to be computed in VT
*
IF( LWORK.GE.N*N+MAX( 4*N, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IR = 1
IF( LWORK.GE.MAX( WRKBL, LDA*N+N )+LDA*N ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is LDA by N
*
LDWRKU = LDA
LDWRKR = LDA
ELSE IF( LWORK.GE.MAX( WRKBL, LDA*N+N )+N*N ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is N by N
*
LDWRKU = LDA
LDWRKR = N
ELSE
*
* WORK(IU) is LDWRKU by N and WORK(IR) is N by N
*
LDWRKU = ( LWORK-N*N-N ) / N
LDWRKR = N
END IF
ITAU = IR + LDWRKR*N
IWORK = ITAU + N
*
* Compute A=Q*R
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R to VT, zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, VT, LDVT )
IF( N.GT.1 )
$ CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ VT( 2, 1 ), LDVT )
*
* Generate Q in A
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DORGQR( M, N, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in VT, copying result to WORK(IR)
* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB)
*
CALL DGEBRD( N, N, VT, LDVT, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', N, N, VT, LDVT, WORK( IR ), LDWRKR )
*
* Generate left vectors bidiagonalizing R in WORK(IR)
* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB)
*
CALL DORGBR( 'Q', N, N, N, WORK( IR ), LDWRKR,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right vectors bidiagonalizing R in VT
* (Workspace: need N*N+4*N-1, prefer N*N+3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of R in WORK(IR) and computing right
* singular vectors of R in VT
* (Workspace: need N*N+BDSPAC)
*
CALL DBDSQR( 'U', N, N, N, 0, S, WORK( IE ), VT, LDVT,
$ WORK( IR ), LDWRKR, DUM, 1,
$ WORK( IWORK ), INFO )
IU = IE + N
*
* Multiply Q in A by left singular vectors of R in
* WORK(IR), storing result in WORK(IU) and copying to A
* (Workspace: need N*N+2*N, prefer N*N+M*N+N)
*
DO 20 I = 1, M, LDWRKU
CHUNK = MIN( M-I+1, LDWRKU )
CALL DGEMM( 'N', 'N', CHUNK, N, N, ONE, A( I, 1 ),
$ LDA, WORK( IR ), LDWRKR, ZERO,
$ WORK( IU ), LDWRKU )
CALL DLACPY( 'F', CHUNK, N, WORK( IU ), LDWRKU,
$ A( I, 1 ), LDA )
20 CONTINUE
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + N
*
* Compute A=Q*R
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R to VT, zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, VT, LDVT )
IF( N.GT.1 )
$ CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ VT( 2, 1 ), LDVT )
*
* Generate Q in A
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DORGQR( M, N, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in VT
* (Workspace: need 4*N, prefer 3*N+2*N*NB)
*
CALL DGEBRD( N, N, VT, LDVT, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply Q in A by left vectors bidiagonalizing R
* (Workspace: need 3*N+M, prefer 3*N+M*NB)
*
CALL DORMBR( 'Q', 'R', 'N', M, N, N, VT, LDVT,
$ WORK( ITAUQ ), A, LDA, WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right vectors bidiagonalizing R in VT
* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in A and computing right
* singular vectors of A in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, N, M, 0, S, WORK( IE ), VT, LDVT,
$ A, LDA, DUM, 1, WORK( IWORK ), INFO )
*
END IF
*
ELSE IF( WNTUS ) THEN
*
IF( WNTVN ) THEN
*
* Path 4 (M much larger than N, JOBU='S', JOBVT='N')
* N left singular vectors to be computed in U and
* no right singular vectors to be computed
*
IF( LWORK.GE.N*N+MAX( 4*N, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IR = 1
IF( LWORK.GE.WRKBL+LDA*N ) THEN
*
* WORK(IR) is LDA by N
*
LDWRKR = LDA
ELSE
*
* WORK(IR) is N by N
*
LDWRKR = N
END IF
ITAU = IR + LDWRKR*N
IWORK = ITAU + N
*
* Compute A=Q*R
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R to WORK(IR), zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, WORK( IR ),
$ LDWRKR )
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ WORK( IR+1 ), LDWRKR )
*
* Generate Q in A
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DORGQR( M, N, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in WORK(IR)
* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB)
*
CALL DGEBRD( N, N, WORK( IR ), LDWRKR, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate left vectors bidiagonalizing R in WORK(IR)
* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB)
*
CALL DORGBR( 'Q', N, N, N, WORK( IR ), LDWRKR,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of R in WORK(IR)
* (Workspace: need N*N+BDSPAC)
*
CALL DBDSQR( 'U', N, 0, N, 0, S, WORK( IE ), DUM,
$ 1, WORK( IR ), LDWRKR, DUM, 1,
$ WORK( IWORK ), INFO )
*
* Multiply Q in A by left singular vectors of R in
* WORK(IR), storing result in U
* (Workspace: need N*N)
*
CALL DGEMM( 'N', 'N', M, N, N, ONE, A, LDA,
$ WORK( IR ), LDWRKR, ZERO, U, LDU )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + N
*
* Compute A=Q*R, copying result to U
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
* Generate Q in U
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DORGQR( M, N, N, U, LDU, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Zero out below R in A
*
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO, A( 2, 1 ),
$ LDA )
*
* Bidiagonalize R in A
* (Workspace: need 4*N, prefer 3*N+2*N*NB)
*
CALL DGEBRD( N, N, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply Q in U by left vectors bidiagonalizing R
* (Workspace: need 3*N+M, prefer 3*N+M*NB)
*
CALL DORMBR( 'Q', 'R', 'N', M, N, N, A, LDA,
$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in U
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, 0, M, 0, S, WORK( IE ), DUM,
$ 1, U, LDU, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
ELSE IF( WNTVO ) THEN
*
* Path 5 (M much larger than N, JOBU='S', JOBVT='O')
* N left singular vectors to be computed in U and
* N right singular vectors to be overwritten on A
*
IF( LWORK.GE.2*N*N+MAX( 4*N, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IU = 1
IF( LWORK.GE.WRKBL+2*LDA*N ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is LDA by N
*
LDWRKU = LDA
IR = IU + LDWRKU*N
LDWRKR = LDA
ELSE IF( LWORK.GE.WRKBL+( LDA+N )*N ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is N by N
*
LDWRKU = LDA
IR = IU + LDWRKU*N
LDWRKR = N
ELSE
*
* WORK(IU) is N by N and WORK(IR) is N by N
*
LDWRKU = N
IR = IU + LDWRKU*N
LDWRKR = N
END IF
ITAU = IR + LDWRKR*N
IWORK = ITAU + N
*
* Compute A=Q*R
* (Workspace: need 2*N*N+2*N, prefer 2*N*N+N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R to WORK(IU), zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, WORK( IU ),
$ LDWRKU )
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ WORK( IU+1 ), LDWRKU )
*
* Generate Q in A
* (Workspace: need 2*N*N+2*N, prefer 2*N*N+N+N*NB)
*
CALL DORGQR( M, N, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in WORK(IU), copying result to
* WORK(IR)
* (Workspace: need 2*N*N+4*N,
* prefer 2*N*N+3*N+2*N*NB)
*
CALL DGEBRD( N, N, WORK( IU ), LDWRKU, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', N, N, WORK( IU ), LDWRKU,
$ WORK( IR ), LDWRKR )
*
* Generate left bidiagonalizing vectors in WORK(IU)
* (Workspace: need 2*N*N+4*N, prefer 2*N*N+3*N+N*NB)
*
CALL DORGBR( 'Q', N, N, N, WORK( IU ), LDWRKU,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right bidiagonalizing vectors in WORK(IR)
* (Workspace: need 2*N*N+4*N-1,
* prefer 2*N*N+3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, WORK( IR ), LDWRKR,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of R in WORK(IU) and computing
* right singular vectors of R in WORK(IR)
* (Workspace: need 2*N*N+BDSPAC)
*
CALL DBDSQR( 'U', N, N, N, 0, S, WORK( IE ),
$ WORK( IR ), LDWRKR, WORK( IU ),
$ LDWRKU, DUM, 1, WORK( IWORK ), INFO )
*
* Multiply Q in A by left singular vectors of R in
* WORK(IU), storing result in U
* (Workspace: need N*N)
*
CALL DGEMM( 'N', 'N', M, N, N, ONE, A, LDA,
$ WORK( IU ), LDWRKU, ZERO, U, LDU )
*
* Copy right singular vectors of R to A
* (Workspace: need N*N)
*
CALL DLACPY( 'F', N, N, WORK( IR ), LDWRKR, A,
$ LDA )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + N
*
* Compute A=Q*R, copying result to U
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
* Generate Q in U
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DORGQR( M, N, N, U, LDU, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Zero out below R in A
*
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO, A( 2, 1 ),
$ LDA )
*
* Bidiagonalize R in A
* (Workspace: need 4*N, prefer 3*N+2*N*NB)
*
CALL DGEBRD( N, N, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply Q in U by left vectors bidiagonalizing R
* (Workspace: need 3*N+M, prefer 3*N+M*NB)
*
CALL DORMBR( 'Q', 'R', 'N', M, N, N, A, LDA,
$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right vectors bidiagonalizing R in A
* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, A, LDA, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in U and computing right
* singular vectors of A in A
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, N, M, 0, S, WORK( IE ), A,
$ LDA, U, LDU, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
ELSE IF( WNTVAS ) THEN
*
* Path 6 (M much larger than N, JOBU='S', JOBVT='S'
* or 'A')
* N left singular vectors to be computed in U and
* N right singular vectors to be computed in VT
*
IF( LWORK.GE.N*N+MAX( 4*N, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IU = 1
IF( LWORK.GE.WRKBL+LDA*N ) THEN
*
* WORK(IU) is LDA by N
*
LDWRKU = LDA
ELSE
*
* WORK(IU) is N by N
*
LDWRKU = N
END IF
ITAU = IU + LDWRKU*N
IWORK = ITAU + N
*
* Compute A=Q*R
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R to WORK(IU), zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, WORK( IU ),
$ LDWRKU )
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ WORK( IU+1 ), LDWRKU )
*
* Generate Q in A
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DORGQR( M, N, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in WORK(IU), copying result to VT
* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB)
*
CALL DGEBRD( N, N, WORK( IU ), LDWRKU, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', N, N, WORK( IU ), LDWRKU, VT,
$ LDVT )
*
* Generate left bidiagonalizing vectors in WORK(IU)
* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB)
*
CALL DORGBR( 'Q', N, N, N, WORK( IU ), LDWRKU,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right bidiagonalizing vectors in VT
* (Workspace: need N*N+4*N-1,
* prefer N*N+3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of R in WORK(IU) and computing
* right singular vectors of R in VT
* (Workspace: need N*N+BDSPAC)
*
CALL DBDSQR( 'U', N, N, N, 0, S, WORK( IE ), VT,
$ LDVT, WORK( IU ), LDWRKU, DUM, 1,
$ WORK( IWORK ), INFO )
*
* Multiply Q in A by left singular vectors of R in
* WORK(IU), storing result in U
* (Workspace: need N*N)
*
CALL DGEMM( 'N', 'N', M, N, N, ONE, A, LDA,
$ WORK( IU ), LDWRKU, ZERO, U, LDU )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + N
*
* Compute A=Q*R, copying result to U
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
* Generate Q in U
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DORGQR( M, N, N, U, LDU, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R to VT, zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, VT, LDVT )
IF( N.GT.1 )
$ CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ VT( 2, 1 ), LDVT )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in VT
* (Workspace: need 4*N, prefer 3*N+2*N*NB)
*
CALL DGEBRD( N, N, VT, LDVT, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply Q in U by left bidiagonalizing vectors
* in VT
* (Workspace: need 3*N+M, prefer 3*N+M*NB)
*
CALL DORMBR( 'Q', 'R', 'N', M, N, N, VT, LDVT,
$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right bidiagonalizing vectors in VT
* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in U and computing right
* singular vectors of A in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, N, M, 0, S, WORK( IE ), VT,
$ LDVT, U, LDU, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
END IF
*
ELSE IF( WNTUA ) THEN
*
IF( WNTVN ) THEN
*
* Path 7 (M much larger than N, JOBU='A', JOBVT='N')
* M left singular vectors to be computed in U and
* no right singular vectors to be computed
*
IF( LWORK.GE.N*N+MAX( N+M, 4*N, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IR = 1
IF( LWORK.GE.WRKBL+LDA*N ) THEN
*
* WORK(IR) is LDA by N
*
LDWRKR = LDA
ELSE
*
* WORK(IR) is N by N
*
LDWRKR = N
END IF
ITAU = IR + LDWRKR*N
IWORK = ITAU + N
*
* Compute A=Q*R, copying result to U
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
* Copy R to WORK(IR), zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, WORK( IR ),
$ LDWRKR )
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ WORK( IR+1 ), LDWRKR )
*
* Generate Q in U
* (Workspace: need N*N+N+M, prefer N*N+N+M*NB)
*
CALL DORGQR( M, M, N, U, LDU, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in WORK(IR)
* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB)
*
CALL DGEBRD( N, N, WORK( IR ), LDWRKR, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate left bidiagonalizing vectors in WORK(IR)
* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB)
*
CALL DORGBR( 'Q', N, N, N, WORK( IR ), LDWRKR,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of R in WORK(IR)
* (Workspace: need N*N+BDSPAC)
*
CALL DBDSQR( 'U', N, 0, N, 0, S, WORK( IE ), DUM,
$ 1, WORK( IR ), LDWRKR, DUM, 1,
$ WORK( IWORK ), INFO )
*
* Multiply Q in U by left singular vectors of R in
* WORK(IR), storing result in A
* (Workspace: need N*N)
*
CALL DGEMM( 'N', 'N', M, N, N, ONE, U, LDU,
$ WORK( IR ), LDWRKR, ZERO, A, LDA )
*
* Copy left singular vectors of A from A to U
*
CALL DLACPY( 'F', M, N, A, LDA, U, LDU )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + N
*
* Compute A=Q*R, copying result to U
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
* Generate Q in U
* (Workspace: need N+M, prefer N+M*NB)
*
CALL DORGQR( M, M, N, U, LDU, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Zero out below R in A
*
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO, A( 2, 1 ),
$ LDA )
*
* Bidiagonalize R in A
* (Workspace: need 4*N, prefer 3*N+2*N*NB)
*
CALL DGEBRD( N, N, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply Q in U by left bidiagonalizing vectors
* in A
* (Workspace: need 3*N+M, prefer 3*N+M*NB)
*
CALL DORMBR( 'Q', 'R', 'N', M, N, N, A, LDA,
$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in U
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, 0, M, 0, S, WORK( IE ), DUM,
$ 1, U, LDU, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
ELSE IF( WNTVO ) THEN
*
* Path 8 (M much larger than N, JOBU='A', JOBVT='O')
* M left singular vectors to be computed in U and
* N right singular vectors to be overwritten on A
*
IF( LWORK.GE.2*N*N+MAX( N+M, 4*N, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IU = 1
IF( LWORK.GE.WRKBL+2*LDA*N ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is LDA by N
*
LDWRKU = LDA
IR = IU + LDWRKU*N
LDWRKR = LDA
ELSE IF( LWORK.GE.WRKBL+( LDA+N )*N ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is N by N
*
LDWRKU = LDA
IR = IU + LDWRKU*N
LDWRKR = N
ELSE
*
* WORK(IU) is N by N and WORK(IR) is N by N
*
LDWRKU = N
IR = IU + LDWRKU*N
LDWRKR = N
END IF
ITAU = IR + LDWRKR*N
IWORK = ITAU + N
*
* Compute A=Q*R, copying result to U
* (Workspace: need 2*N*N+2*N, prefer 2*N*N+N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
* Generate Q in U
* (Workspace: need 2*N*N+N+M, prefer 2*N*N+N+M*NB)
*
CALL DORGQR( M, M, N, U, LDU, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R to WORK(IU), zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, WORK( IU ),
$ LDWRKU )
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ WORK( IU+1 ), LDWRKU )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in WORK(IU), copying result to
* WORK(IR)
* (Workspace: need 2*N*N+4*N,
* prefer 2*N*N+3*N+2*N*NB)
*
CALL DGEBRD( N, N, WORK( IU ), LDWRKU, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', N, N, WORK( IU ), LDWRKU,
$ WORK( IR ), LDWRKR )
*
* Generate left bidiagonalizing vectors in WORK(IU)
* (Workspace: need 2*N*N+4*N, prefer 2*N*N+3*N+N*NB)
*
CALL DORGBR( 'Q', N, N, N, WORK( IU ), LDWRKU,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right bidiagonalizing vectors in WORK(IR)
* (Workspace: need 2*N*N+4*N-1,
* prefer 2*N*N+3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, WORK( IR ), LDWRKR,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of R in WORK(IU) and computing
* right singular vectors of R in WORK(IR)
* (Workspace: need 2*N*N+BDSPAC)
*
CALL DBDSQR( 'U', N, N, N, 0, S, WORK( IE ),
$ WORK( IR ), LDWRKR, WORK( IU ),
$ LDWRKU, DUM, 1, WORK( IWORK ), INFO )
*
* Multiply Q in U by left singular vectors of R in
* WORK(IU), storing result in A
* (Workspace: need N*N)
*
CALL DGEMM( 'N', 'N', M, N, N, ONE, U, LDU,
$ WORK( IU ), LDWRKU, ZERO, A, LDA )
*
* Copy left singular vectors of A from A to U
*
CALL DLACPY( 'F', M, N, A, LDA, U, LDU )
*
* Copy right singular vectors of R from WORK(IR) to A
*
CALL DLACPY( 'F', N, N, WORK( IR ), LDWRKR, A,
$ LDA )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + N
*
* Compute A=Q*R, copying result to U
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
* Generate Q in U
* (Workspace: need N+M, prefer N+M*NB)
*
CALL DORGQR( M, M, N, U, LDU, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Zero out below R in A
*
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO, A( 2, 1 ),
$ LDA )
*
* Bidiagonalize R in A
* (Workspace: need 4*N, prefer 3*N+2*N*NB)
*
CALL DGEBRD( N, N, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply Q in U by left bidiagonalizing vectors
* in A
* (Workspace: need 3*N+M, prefer 3*N+M*NB)
*
CALL DORMBR( 'Q', 'R', 'N', M, N, N, A, LDA,
$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right bidiagonalizing vectors in A
* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, A, LDA, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in U and computing right
* singular vectors of A in A
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, N, M, 0, S, WORK( IE ), A,
$ LDA, U, LDU, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
ELSE IF( WNTVAS ) THEN
*
* Path 9 (M much larger than N, JOBU='A', JOBVT='S'
* or 'A')
* M left singular vectors to be computed in U and
* N right singular vectors to be computed in VT
*
IF( LWORK.GE.N*N+MAX( N+M, 4*N, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IU = 1
IF( LWORK.GE.WRKBL+LDA*N ) THEN
*
* WORK(IU) is LDA by N
*
LDWRKU = LDA
ELSE
*
* WORK(IU) is N by N
*
LDWRKU = N
END IF
ITAU = IU + LDWRKU*N
IWORK = ITAU + N
*
* Compute A=Q*R, copying result to U
* (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
* Generate Q in U
* (Workspace: need N*N+N+M, prefer N*N+N+M*NB)
*
CALL DORGQR( M, M, N, U, LDU, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R to WORK(IU), zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, WORK( IU ),
$ LDWRKU )
CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ WORK( IU+1 ), LDWRKU )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in WORK(IU), copying result to VT
* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB)
*
CALL DGEBRD( N, N, WORK( IU ), LDWRKU, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', N, N, WORK( IU ), LDWRKU, VT,
$ LDVT )
*
* Generate left bidiagonalizing vectors in WORK(IU)
* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB)
*
CALL DORGBR( 'Q', N, N, N, WORK( IU ), LDWRKU,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right bidiagonalizing vectors in VT
* (Workspace: need N*N+4*N-1,
* prefer N*N+3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of R in WORK(IU) and computing
* right singular vectors of R in VT
* (Workspace: need N*N+BDSPAC)
*
CALL DBDSQR( 'U', N, N, N, 0, S, WORK( IE ), VT,
$ LDVT, WORK( IU ), LDWRKU, DUM, 1,
$ WORK( IWORK ), INFO )
*
* Multiply Q in U by left singular vectors of R in
* WORK(IU), storing result in A
* (Workspace: need N*N)
*
CALL DGEMM( 'N', 'N', M, N, N, ONE, U, LDU,
$ WORK( IU ), LDWRKU, ZERO, A, LDA )
*
* Copy left singular vectors of A from A to U
*
CALL DLACPY( 'F', M, N, A, LDA, U, LDU )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + N
*
* Compute A=Q*R, copying result to U
* (Workspace: need 2*N, prefer N+N*NB)
*
CALL DGEQRF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
* Generate Q in U
* (Workspace: need N+M, prefer N+M*NB)
*
CALL DORGQR( M, M, N, U, LDU, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy R from A to VT, zeroing out below it
*
CALL DLACPY( 'U', N, N, A, LDA, VT, LDVT )
IF( N.GT.1 )
$ CALL DLASET( 'L', N-1, N-1, ZERO, ZERO,
$ VT( 2, 1 ), LDVT )
IE = ITAU
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize R in VT
* (Workspace: need 4*N, prefer 3*N+2*N*NB)
*
CALL DGEBRD( N, N, VT, LDVT, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply Q in U by left bidiagonalizing vectors
* in VT
* (Workspace: need 3*N+M, prefer 3*N+M*NB)
*
CALL DORMBR( 'Q', 'R', 'N', M, N, N, VT, LDVT,
$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right bidiagonalizing vectors in VT
* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + N
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in U and computing right
* singular vectors of A in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, N, M, 0, S, WORK( IE ), VT,
$ LDVT, U, LDU, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
END IF
*
END IF
*
ELSE
*
* M .LT. MNTHR
*
* Path 10 (M at least N, but not much larger)
* Reduce to bidiagonal form without QR decomposition
*
IE = 1
ITAUQ = IE + N
ITAUP = ITAUQ + N
IWORK = ITAUP + N
*
* Bidiagonalize A
* (Workspace: need 3*N+M, prefer 3*N+(M+N)*NB)
*
CALL DGEBRD( M, N, A, LDA, S, WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ), LWORK-IWORK+1,
$ IERR )
IF( WNTUAS ) THEN
*
* If left singular vectors desired in U, copy result to U
* and generate left bidiagonalizing vectors in U
* (Workspace: need 3*N+NCU, prefer 3*N+NCU*NB)
*
CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
IF( WNTUS )
$ NCU = N
IF( WNTUA )
$ NCU = M
CALL DORGBR( 'Q', M, NCU, N, U, LDU, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
END IF
IF( WNTVAS ) THEN
*
* If right singular vectors desired in VT, copy result to
* VT and generate right bidiagonalizing vectors in VT
* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB)
*
CALL DLACPY( 'U', N, N, A, LDA, VT, LDVT )
CALL DORGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
END IF
IF( WNTUO ) THEN
*
* If left singular vectors desired in A, generate left
* bidiagonalizing vectors in A
* (Workspace: need 4*N, prefer 3*N+N*NB)
*
CALL DORGBR( 'Q', M, N, N, A, LDA, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
END IF
IF( WNTVO ) THEN
*
* If right singular vectors desired in A, generate right
* bidiagonalizing vectors in A
* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB)
*
CALL DORGBR( 'P', N, N, N, A, LDA, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
END IF
IWORK = IE + N
IF( WNTUAS .OR. WNTUO )
$ NRU = M
IF( WNTUN )
$ NRU = 0
IF( WNTVAS .OR. WNTVO )
$ NCVT = N
IF( WNTVN )
$ NCVT = 0
IF( ( .NOT.WNTUO ) .AND. ( .NOT.WNTVO ) ) THEN
*
* Perform bidiagonal QR iteration, if desired, computing
* left singular vectors in U and computing right singular
* vectors in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, NCVT, NRU, 0, S, WORK( IE ), VT,
$ LDVT, U, LDU, DUM, 1, WORK( IWORK ), INFO )
ELSE IF( ( .NOT.WNTUO ) .AND. WNTVO ) THEN
*
* Perform bidiagonal QR iteration, if desired, computing
* left singular vectors in U and computing right singular
* vectors in A
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, NCVT, NRU, 0, S, WORK( IE ), A, LDA,
$ U, LDU, DUM, 1, WORK( IWORK ), INFO )
ELSE
*
* Perform bidiagonal QR iteration, if desired, computing
* left singular vectors in A and computing right singular
* vectors in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', N, NCVT, NRU, 0, S, WORK( IE ), VT,
$ LDVT, A, LDA, DUM, 1, WORK( IWORK ), INFO )
END IF
*
END IF
*
ELSE
*
* A has more columns than rows. If A has sufficiently more
* columns than rows, first reduce using the LQ decomposition (if
* sufficient workspace available)
*
IF( N.GE.MNTHR ) THEN
*
IF( WNTVN ) THEN
*
* Path 1t(N much larger than M, JOBVT='N')
* No right singular vectors to be computed
*
ITAU = 1
IWORK = ITAU + M
*
* Compute A=L*Q
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Zero out above L
*
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO, A( 1, 2 ), LDA )
IE = 1
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in A
* (Workspace: need 4*M, prefer 3*M+2*M*NB)
*
CALL DGEBRD( M, M, A, LDA, S, WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ), LWORK-IWORK+1,
$ IERR )
IF( WNTUO .OR. WNTUAS ) THEN
*
* If left singular vectors desired, generate Q
* (Workspace: need 4*M, prefer 3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, A, LDA, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
END IF
IWORK = IE + M
NRU = 0
IF( WNTUO .OR. WNTUAS )
$ NRU = M
*
* Perform bidiagonal QR iteration, computing left singular
* vectors of A in A if desired
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', M, 0, NRU, 0, S, WORK( IE ), DUM, 1, A,
$ LDA, DUM, 1, WORK( IWORK ), INFO )
*
* If left singular vectors desired in U, copy them there
*
IF( WNTUAS )
$ CALL DLACPY( 'F', M, M, A, LDA, U, LDU )
*
ELSE IF( WNTVO .AND. WNTUN ) THEN
*
* Path 2t(N much larger than M, JOBU='N', JOBVT='O')
* M right singular vectors to be overwritten on A and
* no left singular vectors to be computed
*
IF( LWORK.GE.M*M+MAX( 4*M, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IR = 1
IF( LWORK.GE.MAX( WRKBL, LDA*N+M )+LDA*M ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is LDA by M
*
LDWRKU = LDA
CHUNK = N
LDWRKR = LDA
ELSE IF( LWORK.GE.MAX( WRKBL, LDA*N+M )+M*M ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is M by M
*
LDWRKU = LDA
CHUNK = N
LDWRKR = M
ELSE
*
* WORK(IU) is M by CHUNK and WORK(IR) is M by M
*
LDWRKU = M
CHUNK = ( LWORK-M*M-M ) / M
LDWRKR = M
END IF
ITAU = IR + LDWRKR*M
IWORK = ITAU + M
*
* Compute A=L*Q
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to WORK(IR) and zero out above it
*
CALL DLACPY( 'L', M, M, A, LDA, WORK( IR ), LDWRKR )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO,
$ WORK( IR+LDWRKR ), LDWRKR )
*
* Generate Q in A
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DORGLQ( M, N, M, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in WORK(IR)
* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB)
*
CALL DGEBRD( M, M, WORK( IR ), LDWRKR, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Generate right vectors bidiagonalizing L
* (Workspace: need M*M+4*M-1, prefer M*M+3*M+(M-1)*NB)
*
CALL DORGBR( 'P', M, M, M, WORK( IR ), LDWRKR,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing right
* singular vectors of L in WORK(IR)
* (Workspace: need M*M+BDSPAC)
*
CALL DBDSQR( 'U', M, M, 0, 0, S, WORK( IE ),
$ WORK( IR ), LDWRKR, DUM, 1, DUM, 1,
$ WORK( IWORK ), INFO )
IU = IE + M
*
* Multiply right singular vectors of L in WORK(IR) by Q
* in A, storing result in WORK(IU) and copying to A
* (Workspace: need M*M+2*M, prefer M*M+M*N+M)
*
DO 30 I = 1, N, CHUNK
BLK = MIN( N-I+1, CHUNK )
CALL DGEMM( 'N', 'N', M, BLK, M, ONE, WORK( IR ),
$ LDWRKR, A( 1, I ), LDA, ZERO,
$ WORK( IU ), LDWRKU )
CALL DLACPY( 'F', M, BLK, WORK( IU ), LDWRKU,
$ A( 1, I ), LDA )
30 CONTINUE
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
IE = 1
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize A
* (Workspace: need 3*M+N, prefer 3*M+(M+N)*NB)
*
CALL DGEBRD( M, N, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Generate right vectors bidiagonalizing A
* (Workspace: need 4*M, prefer 3*M+M*NB)
*
CALL DORGBR( 'P', M, N, M, A, LDA, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing right
* singular vectors of A in A
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'L', M, N, 0, 0, S, WORK( IE ), A, LDA,
$ DUM, 1, DUM, 1, WORK( IWORK ), INFO )
*
END IF
*
ELSE IF( WNTVO .AND. WNTUAS ) THEN
*
* Path 3t(N much larger than M, JOBU='S' or 'A', JOBVT='O')
* M right singular vectors to be overwritten on A and
* M left singular vectors to be computed in U
*
IF( LWORK.GE.M*M+MAX( 4*M, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IR = 1
IF( LWORK.GE.MAX( WRKBL, LDA*N+M )+LDA*M ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is LDA by M
*
LDWRKU = LDA
CHUNK = N
LDWRKR = LDA
ELSE IF( LWORK.GE.MAX( WRKBL, LDA*N+M )+M*M ) THEN
*
* WORK(IU) is LDA by N and WORK(IR) is M by M
*
LDWRKU = LDA
CHUNK = N
LDWRKR = M
ELSE
*
* WORK(IU) is M by CHUNK and WORK(IR) is M by M
*
LDWRKU = M
CHUNK = ( LWORK-M*M-M ) / M
LDWRKR = M
END IF
ITAU = IR + LDWRKR*M
IWORK = ITAU + M
*
* Compute A=L*Q
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to U, zeroing about above it
*
CALL DLACPY( 'L', M, M, A, LDA, U, LDU )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO, U( 1, 2 ),
$ LDU )
*
* Generate Q in A
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DORGLQ( M, N, M, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in U, copying result to WORK(IR)
* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB)
*
CALL DGEBRD( M, M, U, LDU, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', M, M, U, LDU, WORK( IR ), LDWRKR )
*
* Generate right vectors bidiagonalizing L in WORK(IR)
* (Workspace: need M*M+4*M-1, prefer M*M+3*M+(M-1)*NB)
*
CALL DORGBR( 'P', M, M, M, WORK( IR ), LDWRKR,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate left vectors bidiagonalizing L in U
* (Workspace: need M*M+4*M, prefer M*M+3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of L in U, and computing right
* singular vectors of L in WORK(IR)
* (Workspace: need M*M+BDSPAC)
*
CALL DBDSQR( 'U', M, M, M, 0, S, WORK( IE ),
$ WORK( IR ), LDWRKR, U, LDU, DUM, 1,
$ WORK( IWORK ), INFO )
IU = IE + M
*
* Multiply right singular vectors of L in WORK(IR) by Q
* in A, storing result in WORK(IU) and copying to A
* (Workspace: need M*M+2*M, prefer M*M+M*N+M))
*
DO 40 I = 1, N, CHUNK
BLK = MIN( N-I+1, CHUNK )
CALL DGEMM( 'N', 'N', M, BLK, M, ONE, WORK( IR ),
$ LDWRKR, A( 1, I ), LDA, ZERO,
$ WORK( IU ), LDWRKU )
CALL DLACPY( 'F', M, BLK, WORK( IU ), LDWRKU,
$ A( 1, I ), LDA )
40 CONTINUE
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + M
*
* Compute A=L*Q
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to U, zeroing out above it
*
CALL DLACPY( 'L', M, M, A, LDA, U, LDU )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO, U( 1, 2 ),
$ LDU )
*
* Generate Q in A
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DORGLQ( M, N, M, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in U
* (Workspace: need 4*M, prefer 3*M+2*M*NB)
*
CALL DGEBRD( M, M, U, LDU, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply right vectors bidiagonalizing L by Q in A
* (Workspace: need 3*M+N, prefer 3*M+N*NB)
*
CALL DORMBR( 'P', 'L', 'T', M, N, M, U, LDU,
$ WORK( ITAUP ), A, LDA, WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate left vectors bidiagonalizing L in U
* (Workspace: need 4*M, prefer 3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in U and computing right
* singular vectors of A in A
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', M, N, M, 0, S, WORK( IE ), A, LDA,
$ U, LDU, DUM, 1, WORK( IWORK ), INFO )
*
END IF
*
ELSE IF( WNTVS ) THEN
*
IF( WNTUN ) THEN
*
* Path 4t(N much larger than M, JOBU='N', JOBVT='S')
* M right singular vectors to be computed in VT and
* no left singular vectors to be computed
*
IF( LWORK.GE.M*M+MAX( 4*M, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IR = 1
IF( LWORK.GE.WRKBL+LDA*M ) THEN
*
* WORK(IR) is LDA by M
*
LDWRKR = LDA
ELSE
*
* WORK(IR) is M by M
*
LDWRKR = M
END IF
ITAU = IR + LDWRKR*M
IWORK = ITAU + M
*
* Compute A=L*Q
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to WORK(IR), zeroing out above it
*
CALL DLACPY( 'L', M, M, A, LDA, WORK( IR ),
$ LDWRKR )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO,
$ WORK( IR+LDWRKR ), LDWRKR )
*
* Generate Q in A
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DORGLQ( M, N, M, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in WORK(IR)
* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB)
*
CALL DGEBRD( M, M, WORK( IR ), LDWRKR, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right vectors bidiagonalizing L in
* WORK(IR)
* (Workspace: need M*M+4*M, prefer M*M+3*M+(M-1)*NB)
*
CALL DORGBR( 'P', M, M, M, WORK( IR ), LDWRKR,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing right
* singular vectors of L in WORK(IR)
* (Workspace: need M*M+BDSPAC)
*
CALL DBDSQR( 'U', M, M, 0, 0, S, WORK( IE ),
$ WORK( IR ), LDWRKR, DUM, 1, DUM, 1,
$ WORK( IWORK ), INFO )
*
* Multiply right singular vectors of L in WORK(IR) by
* Q in A, storing result in VT
* (Workspace: need M*M)
*
CALL DGEMM( 'N', 'N', M, N, M, ONE, WORK( IR ),
$ LDWRKR, A, LDA, ZERO, VT, LDVT )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + M
*
* Compute A=L*Q
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy result to VT
*
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
* Generate Q in VT
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DORGLQ( M, N, M, VT, LDVT, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Zero out above L in A
*
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO, A( 1, 2 ),
$ LDA )
*
* Bidiagonalize L in A
* (Workspace: need 4*M, prefer 3*M+2*M*NB)
*
CALL DGEBRD( M, M, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply right vectors bidiagonalizing L by Q in VT
* (Workspace: need 3*M+N, prefer 3*M+N*NB)
*
CALL DORMBR( 'P', 'L', 'T', M, N, M, A, LDA,
$ WORK( ITAUP ), VT, LDVT,
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing right
* singular vectors of A in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', M, N, 0, 0, S, WORK( IE ), VT,
$ LDVT, DUM, 1, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
ELSE IF( WNTUO ) THEN
*
* Path 5t(N much larger than M, JOBU='O', JOBVT='S')
* M right singular vectors to be computed in VT and
* M left singular vectors to be overwritten on A
*
IF( LWORK.GE.2*M*M+MAX( 4*M, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IU = 1
IF( LWORK.GE.WRKBL+2*LDA*M ) THEN
*
* WORK(IU) is LDA by M and WORK(IR) is LDA by M
*
LDWRKU = LDA
IR = IU + LDWRKU*M
LDWRKR = LDA
ELSE IF( LWORK.GE.WRKBL+( LDA+M )*M ) THEN
*
* WORK(IU) is LDA by M and WORK(IR) is M by M
*
LDWRKU = LDA
IR = IU + LDWRKU*M
LDWRKR = M
ELSE
*
* WORK(IU) is M by M and WORK(IR) is M by M
*
LDWRKU = M
IR = IU + LDWRKU*M
LDWRKR = M
END IF
ITAU = IR + LDWRKR*M
IWORK = ITAU + M
*
* Compute A=L*Q
* (Workspace: need 2*M*M+2*M, prefer 2*M*M+M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to WORK(IU), zeroing out below it
*
CALL DLACPY( 'L', M, M, A, LDA, WORK( IU ),
$ LDWRKU )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO,
$ WORK( IU+LDWRKU ), LDWRKU )
*
* Generate Q in A
* (Workspace: need 2*M*M+2*M, prefer 2*M*M+M+M*NB)
*
CALL DORGLQ( M, N, M, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in WORK(IU), copying result to
* WORK(IR)
* (Workspace: need 2*M*M+4*M,
* prefer 2*M*M+3*M+2*M*NB)
*
CALL DGEBRD( M, M, WORK( IU ), LDWRKU, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, M, WORK( IU ), LDWRKU,
$ WORK( IR ), LDWRKR )
*
* Generate right bidiagonalizing vectors in WORK(IU)
* (Workspace: need 2*M*M+4*M-1,
* prefer 2*M*M+3*M+(M-1)*NB)
*
CALL DORGBR( 'P', M, M, M, WORK( IU ), LDWRKU,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate left bidiagonalizing vectors in WORK(IR)
* (Workspace: need 2*M*M+4*M, prefer 2*M*M+3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, WORK( IR ), LDWRKR,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of L in WORK(IR) and computing
* right singular vectors of L in WORK(IU)
* (Workspace: need 2*M*M+BDSPAC)
*
CALL DBDSQR( 'U', M, M, M, 0, S, WORK( IE ),
$ WORK( IU ), LDWRKU, WORK( IR ),
$ LDWRKR, DUM, 1, WORK( IWORK ), INFO )
*
* Multiply right singular vectors of L in WORK(IU) by
* Q in A, storing result in VT
* (Workspace: need M*M)
*
CALL DGEMM( 'N', 'N', M, N, M, ONE, WORK( IU ),
$ LDWRKU, A, LDA, ZERO, VT, LDVT )
*
* Copy left singular vectors of L to A
* (Workspace: need M*M)
*
CALL DLACPY( 'F', M, M, WORK( IR ), LDWRKR, A,
$ LDA )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + M
*
* Compute A=L*Q, copying result to VT
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
* Generate Q in VT
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DORGLQ( M, N, M, VT, LDVT, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Zero out above L in A
*
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO, A( 1, 2 ),
$ LDA )
*
* Bidiagonalize L in A
* (Workspace: need 4*M, prefer 3*M+2*M*NB)
*
CALL DGEBRD( M, M, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply right vectors bidiagonalizing L by Q in VT
* (Workspace: need 3*M+N, prefer 3*M+N*NB)
*
CALL DORMBR( 'P', 'L', 'T', M, N, M, A, LDA,
$ WORK( ITAUP ), VT, LDVT,
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Generate left bidiagonalizing vectors of L in A
* (Workspace: need 4*M, prefer 3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, A, LDA, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, compute left
* singular vectors of A in A and compute right
* singular vectors of A in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', M, N, M, 0, S, WORK( IE ), VT,
$ LDVT, A, LDA, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
ELSE IF( WNTUAS ) THEN
*
* Path 6t(N much larger than M, JOBU='S' or 'A',
* JOBVT='S')
* M right singular vectors to be computed in VT and
* M left singular vectors to be computed in U
*
IF( LWORK.GE.M*M+MAX( 4*M, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IU = 1
IF( LWORK.GE.WRKBL+LDA*M ) THEN
*
* WORK(IU) is LDA by N
*
LDWRKU = LDA
ELSE
*
* WORK(IU) is LDA by M
*
LDWRKU = M
END IF
ITAU = IU + LDWRKU*M
IWORK = ITAU + M
*
* Compute A=L*Q
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to WORK(IU), zeroing out above it
*
CALL DLACPY( 'L', M, M, A, LDA, WORK( IU ),
$ LDWRKU )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO,
$ WORK( IU+LDWRKU ), LDWRKU )
*
* Generate Q in A
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DORGLQ( M, N, M, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in WORK(IU), copying result to U
* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB)
*
CALL DGEBRD( M, M, WORK( IU ), LDWRKU, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, M, WORK( IU ), LDWRKU, U,
$ LDU )
*
* Generate right bidiagonalizing vectors in WORK(IU)
* (Workspace: need M*M+4*M-1,
* prefer M*M+3*M+(M-1)*NB)
*
CALL DORGBR( 'P', M, M, M, WORK( IU ), LDWRKU,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate left bidiagonalizing vectors in U
* (Workspace: need M*M+4*M, prefer M*M+3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of L in U and computing right
* singular vectors of L in WORK(IU)
* (Workspace: need M*M+BDSPAC)
*
CALL DBDSQR( 'U', M, M, M, 0, S, WORK( IE ),
$ WORK( IU ), LDWRKU, U, LDU, DUM, 1,
$ WORK( IWORK ), INFO )
*
* Multiply right singular vectors of L in WORK(IU) by
* Q in A, storing result in VT
* (Workspace: need M*M)
*
CALL DGEMM( 'N', 'N', M, N, M, ONE, WORK( IU ),
$ LDWRKU, A, LDA, ZERO, VT, LDVT )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + M
*
* Compute A=L*Q, copying result to VT
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
* Generate Q in VT
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DORGLQ( M, N, M, VT, LDVT, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to U, zeroing out above it
*
CALL DLACPY( 'L', M, M, A, LDA, U, LDU )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO, U( 1, 2 ),
$ LDU )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in U
* (Workspace: need 4*M, prefer 3*M+2*M*NB)
*
CALL DGEBRD( M, M, U, LDU, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply right bidiagonalizing vectors in U by Q
* in VT
* (Workspace: need 3*M+N, prefer 3*M+N*NB)
*
CALL DORMBR( 'P', 'L', 'T', M, N, M, U, LDU,
$ WORK( ITAUP ), VT, LDVT,
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Generate left bidiagonalizing vectors in U
* (Workspace: need 4*M, prefer 3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in U and computing right
* singular vectors of A in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', M, N, M, 0, S, WORK( IE ), VT,
$ LDVT, U, LDU, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
END IF
*
ELSE IF( WNTVA ) THEN
*
IF( WNTUN ) THEN
*
* Path 7t(N much larger than M, JOBU='N', JOBVT='A')
* N right singular vectors to be computed in VT and
* no left singular vectors to be computed
*
IF( LWORK.GE.M*M+MAX( N+M, 4*M, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IR = 1
IF( LWORK.GE.WRKBL+LDA*M ) THEN
*
* WORK(IR) is LDA by M
*
LDWRKR = LDA
ELSE
*
* WORK(IR) is M by M
*
LDWRKR = M
END IF
ITAU = IR + LDWRKR*M
IWORK = ITAU + M
*
* Compute A=L*Q, copying result to VT
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
* Copy L to WORK(IR), zeroing out above it
*
CALL DLACPY( 'L', M, M, A, LDA, WORK( IR ),
$ LDWRKR )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO,
$ WORK( IR+LDWRKR ), LDWRKR )
*
* Generate Q in VT
* (Workspace: need M*M+M+N, prefer M*M+M+N*NB)
*
CALL DORGLQ( N, N, M, VT, LDVT, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in WORK(IR)
* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB)
*
CALL DGEBRD( M, M, WORK( IR ), LDWRKR, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate right bidiagonalizing vectors in WORK(IR)
* (Workspace: need M*M+4*M-1,
* prefer M*M+3*M+(M-1)*NB)
*
CALL DORGBR( 'P', M, M, M, WORK( IR ), LDWRKR,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing right
* singular vectors of L in WORK(IR)
* (Workspace: need M*M+BDSPAC)
*
CALL DBDSQR( 'U', M, M, 0, 0, S, WORK( IE ),
$ WORK( IR ), LDWRKR, DUM, 1, DUM, 1,
$ WORK( IWORK ), INFO )
*
* Multiply right singular vectors of L in WORK(IR) by
* Q in VT, storing result in A
* (Workspace: need M*M)
*
CALL DGEMM( 'N', 'N', M, N, M, ONE, WORK( IR ),
$ LDWRKR, VT, LDVT, ZERO, A, LDA )
*
* Copy right singular vectors of A from A to VT
*
CALL DLACPY( 'F', M, N, A, LDA, VT, LDVT )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + M
*
* Compute A=L*Q, copying result to VT
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
* Generate Q in VT
* (Workspace: need M+N, prefer M+N*NB)
*
CALL DORGLQ( N, N, M, VT, LDVT, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Zero out above L in A
*
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO, A( 1, 2 ),
$ LDA )
*
* Bidiagonalize L in A
* (Workspace: need 4*M, prefer 3*M+2*M*NB)
*
CALL DGEBRD( M, M, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply right bidiagonalizing vectors in A by Q
* in VT
* (Workspace: need 3*M+N, prefer 3*M+N*NB)
*
CALL DORMBR( 'P', 'L', 'T', M, N, M, A, LDA,
$ WORK( ITAUP ), VT, LDVT,
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing right
* singular vectors of A in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', M, N, 0, 0, S, WORK( IE ), VT,
$ LDVT, DUM, 1, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
ELSE IF( WNTUO ) THEN
*
* Path 8t(N much larger than M, JOBU='O', JOBVT='A')
* N right singular vectors to be computed in VT and
* M left singular vectors to be overwritten on A
*
IF( LWORK.GE.2*M*M+MAX( N+M, 4*M, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IU = 1
IF( LWORK.GE.WRKBL+2*LDA*M ) THEN
*
* WORK(IU) is LDA by M and WORK(IR) is LDA by M
*
LDWRKU = LDA
IR = IU + LDWRKU*M
LDWRKR = LDA
ELSE IF( LWORK.GE.WRKBL+( LDA+M )*M ) THEN
*
* WORK(IU) is LDA by M and WORK(IR) is M by M
*
LDWRKU = LDA
IR = IU + LDWRKU*M
LDWRKR = M
ELSE
*
* WORK(IU) is M by M and WORK(IR) is M by M
*
LDWRKU = M
IR = IU + LDWRKU*M
LDWRKR = M
END IF
ITAU = IR + LDWRKR*M
IWORK = ITAU + M
*
* Compute A=L*Q, copying result to VT
* (Workspace: need 2*M*M+2*M, prefer 2*M*M+M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
* Generate Q in VT
* (Workspace: need 2*M*M+M+N, prefer 2*M*M+M+N*NB)
*
CALL DORGLQ( N, N, M, VT, LDVT, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to WORK(IU), zeroing out above it
*
CALL DLACPY( 'L', M, M, A, LDA, WORK( IU ),
$ LDWRKU )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO,
$ WORK( IU+LDWRKU ), LDWRKU )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in WORK(IU), copying result to
* WORK(IR)
* (Workspace: need 2*M*M+4*M,
* prefer 2*M*M+3*M+2*M*NB)
*
CALL DGEBRD( M, M, WORK( IU ), LDWRKU, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, M, WORK( IU ), LDWRKU,
$ WORK( IR ), LDWRKR )
*
* Generate right bidiagonalizing vectors in WORK(IU)
* (Workspace: need 2*M*M+4*M-1,
* prefer 2*M*M+3*M+(M-1)*NB)
*
CALL DORGBR( 'P', M, M, M, WORK( IU ), LDWRKU,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate left bidiagonalizing vectors in WORK(IR)
* (Workspace: need 2*M*M+4*M, prefer 2*M*M+3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, WORK( IR ), LDWRKR,
$ WORK( ITAUQ ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of L in WORK(IR) and computing
* right singular vectors of L in WORK(IU)
* (Workspace: need 2*M*M+BDSPAC)
*
CALL DBDSQR( 'U', M, M, M, 0, S, WORK( IE ),
$ WORK( IU ), LDWRKU, WORK( IR ),
$ LDWRKR, DUM, 1, WORK( IWORK ), INFO )
*
* Multiply right singular vectors of L in WORK(IU) by
* Q in VT, storing result in A
* (Workspace: need M*M)
*
CALL DGEMM( 'N', 'N', M, N, M, ONE, WORK( IU ),
$ LDWRKU, VT, LDVT, ZERO, A, LDA )
*
* Copy right singular vectors of A from A to VT
*
CALL DLACPY( 'F', M, N, A, LDA, VT, LDVT )
*
* Copy left singular vectors of A from WORK(IR) to A
*
CALL DLACPY( 'F', M, M, WORK( IR ), LDWRKR, A,
$ LDA )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + M
*
* Compute A=L*Q, copying result to VT
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
* Generate Q in VT
* (Workspace: need M+N, prefer M+N*NB)
*
CALL DORGLQ( N, N, M, VT, LDVT, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Zero out above L in A
*
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO, A( 1, 2 ),
$ LDA )
*
* Bidiagonalize L in A
* (Workspace: need 4*M, prefer 3*M+2*M*NB)
*
CALL DGEBRD( M, M, A, LDA, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply right bidiagonalizing vectors in A by Q
* in VT
* (Workspace: need 3*M+N, prefer 3*M+N*NB)
*
CALL DORMBR( 'P', 'L', 'T', M, N, M, A, LDA,
$ WORK( ITAUP ), VT, LDVT,
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Generate left bidiagonalizing vectors in A
* (Workspace: need 4*M, prefer 3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, A, LDA, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in A and computing right
* singular vectors of A in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', M, N, M, 0, S, WORK( IE ), VT,
$ LDVT, A, LDA, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
ELSE IF( WNTUAS ) THEN
*
* Path 9t(N much larger than M, JOBU='S' or 'A',
* JOBVT='A')
* N right singular vectors to be computed in VT and
* M left singular vectors to be computed in U
*
IF( LWORK.GE.M*M+MAX( N+M, 4*M, BDSPAC ) ) THEN
*
* Sufficient workspace for a fast algorithm
*
IU = 1
IF( LWORK.GE.WRKBL+LDA*M ) THEN
*
* WORK(IU) is LDA by M
*
LDWRKU = LDA
ELSE
*
* WORK(IU) is M by M
*
LDWRKU = M
END IF
ITAU = IU + LDWRKU*M
IWORK = ITAU + M
*
* Compute A=L*Q, copying result to VT
* (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
* Generate Q in VT
* (Workspace: need M*M+M+N, prefer M*M+M+N*NB)
*
CALL DORGLQ( N, N, M, VT, LDVT, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to WORK(IU), zeroing out above it
*
CALL DLACPY( 'L', M, M, A, LDA, WORK( IU ),
$ LDWRKU )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO,
$ WORK( IU+LDWRKU ), LDWRKU )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in WORK(IU), copying result to U
* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB)
*
CALL DGEBRD( M, M, WORK( IU ), LDWRKU, S,
$ WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
CALL DLACPY( 'L', M, M, WORK( IU ), LDWRKU, U,
$ LDU )
*
* Generate right bidiagonalizing vectors in WORK(IU)
* (Workspace: need M*M+4*M, prefer M*M+3*M+(M-1)*NB)
*
CALL DORGBR( 'P', M, M, M, WORK( IU ), LDWRKU,
$ WORK( ITAUP ), WORK( IWORK ),
$ LWORK-IWORK+1, IERR )
*
* Generate left bidiagonalizing vectors in U
* (Workspace: need M*M+4*M, prefer M*M+3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of L in U and computing right
* singular vectors of L in WORK(IU)
* (Workspace: need M*M+BDSPAC)
*
CALL DBDSQR( 'U', M, M, M, 0, S, WORK( IE ),
$ WORK( IU ), LDWRKU, U, LDU, DUM, 1,
$ WORK( IWORK ), INFO )
*
* Multiply right singular vectors of L in WORK(IU) by
* Q in VT, storing result in A
* (Workspace: need M*M)
*
CALL DGEMM( 'N', 'N', M, N, M, ONE, WORK( IU ),
$ LDWRKU, VT, LDVT, ZERO, A, LDA )
*
* Copy right singular vectors of A from A to VT
*
CALL DLACPY( 'F', M, N, A, LDA, VT, LDVT )
*
ELSE
*
* Insufficient workspace for a fast algorithm
*
ITAU = 1
IWORK = ITAU + M
*
* Compute A=L*Q, copying result to VT
* (Workspace: need 2*M, prefer M+M*NB)
*
CALL DGELQF( M, N, A, LDA, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
* Generate Q in VT
* (Workspace: need M+N, prefer M+N*NB)
*
CALL DORGLQ( N, N, M, VT, LDVT, WORK( ITAU ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Copy L to U, zeroing out above it
*
CALL DLACPY( 'L', M, M, A, LDA, U, LDU )
CALL DLASET( 'U', M-1, M-1, ZERO, ZERO, U( 1, 2 ),
$ LDU )
IE = ITAU
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize L in U
* (Workspace: need 4*M, prefer 3*M+2*M*NB)
*
CALL DGEBRD( M, M, U, LDU, S, WORK( IE ),
$ WORK( ITAUQ ), WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Multiply right bidiagonalizing vectors in U by Q
* in VT
* (Workspace: need 3*M+N, prefer 3*M+N*NB)
*
CALL DORMBR( 'P', 'L', 'T', M, N, M, U, LDU,
$ WORK( ITAUP ), VT, LDVT,
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
*
* Generate left bidiagonalizing vectors in U
* (Workspace: need 4*M, prefer 3*M+M*NB)
*
CALL DORGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
IWORK = IE + M
*
* Perform bidiagonal QR iteration, computing left
* singular vectors of A in U and computing right
* singular vectors of A in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'U', M, N, M, 0, S, WORK( IE ), VT,
$ LDVT, U, LDU, DUM, 1, WORK( IWORK ),
$ INFO )
*
END IF
*
END IF
*
END IF
*
ELSE
*
* N .LT. MNTHR
*
* Path 10t(N greater than M, but not much larger)
* Reduce to bidiagonal form without LQ decomposition
*
IE = 1
ITAUQ = IE + M
ITAUP = ITAUQ + M
IWORK = ITAUP + M
*
* Bidiagonalize A
* (Workspace: need 3*M+N, prefer 3*M+(M+N)*NB)
*
CALL DGEBRD( M, N, A, LDA, S, WORK( IE ), WORK( ITAUQ ),
$ WORK( ITAUP ), WORK( IWORK ), LWORK-IWORK+1,
$ IERR )
IF( WNTUAS ) THEN
*
* If left singular vectors desired in U, copy result to U
* and generate left bidiagonalizing vectors in U
* (Workspace: need 4*M-1, prefer 3*M+(M-1)*NB)
*
CALL DLACPY( 'L', M, M, A, LDA, U, LDU )
CALL DORGBR( 'Q', M, M, N, U, LDU, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
END IF
IF( WNTVAS ) THEN
*
* If right singular vectors desired in VT, copy result to
* VT and generate right bidiagonalizing vectors in VT
* (Workspace: need 3*M+NRVT, prefer 3*M+NRVT*NB)
*
CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
IF( WNTVA )
$ NRVT = N
IF( WNTVS )
$ NRVT = M
CALL DORGBR( 'P', NRVT, N, M, VT, LDVT, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
END IF
IF( WNTUO ) THEN
*
* If left singular vectors desired in A, generate left
* bidiagonalizing vectors in A
* (Workspace: need 4*M-1, prefer 3*M+(M-1)*NB)
*
CALL DORGBR( 'Q', M, M, N, A, LDA, WORK( ITAUQ ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
END IF
IF( WNTVO ) THEN
*
* If right singular vectors desired in A, generate right
* bidiagonalizing vectors in A
* (Workspace: need 4*M, prefer 3*M+M*NB)
*
CALL DORGBR( 'P', M, N, M, A, LDA, WORK( ITAUP ),
$ WORK( IWORK ), LWORK-IWORK+1, IERR )
END IF
IWORK = IE + M
IF( WNTUAS .OR. WNTUO )
$ NRU = M
IF( WNTUN )
$ NRU = 0
IF( WNTVAS .OR. WNTVO )
$ NCVT = N
IF( WNTVN )
$ NCVT = 0
IF( ( .NOT.WNTUO ) .AND. ( .NOT.WNTVO ) ) THEN
*
* Perform bidiagonal QR iteration, if desired, computing
* left singular vectors in U and computing right singular
* vectors in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'L', M, NCVT, NRU, 0, S, WORK( IE ), VT,
$ LDVT, U, LDU, DUM, 1, WORK( IWORK ), INFO )
ELSE IF( ( .NOT.WNTUO ) .AND. WNTVO ) THEN
*
* Perform bidiagonal QR iteration, if desired, computing
* left singular vectors in U and computing right singular
* vectors in A
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'L', M, NCVT, NRU, 0, S, WORK( IE ), A, LDA,
$ U, LDU, DUM, 1, WORK( IWORK ), INFO )
ELSE
*
* Perform bidiagonal QR iteration, if desired, computing
* left singular vectors in A and computing right singular
* vectors in VT
* (Workspace: need BDSPAC)
*
CALL DBDSQR( 'L', M, NCVT, NRU, 0, S, WORK( IE ), VT,
$ LDVT, A, LDA, DUM, 1, WORK( IWORK ), INFO )
END IF
*
END IF
*
END IF
*
* If DBDSQR failed to converge, copy unconverged superdiagonals
* to WORK( 2:MINMN )
*
IF( INFO.NE.0 ) THEN
IF( IE.GT.2 ) THEN
DO 50 I = 1, MINMN - 1
WORK( I+1 ) = WORK( I+IE-1 )
50 CONTINUE
END IF
IF( IE.LT.2 ) THEN
DO 60 I = MINMN - 1, 1, -1
WORK( I+1 ) = WORK( I+IE-1 )
60 CONTINUE
END IF
END IF
*
* Undo scaling if necessary
*
IF( ISCL.EQ.1 ) THEN
IF( ANRM.GT.BIGNUM )
$ CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN, 1, S, MINMN,
$ IERR )
IF( INFO.NE.0 .AND. ANRM.GT.BIGNUM )
$ CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN-1, 1, WORK( 2 ),
$ MINMN, IERR )
IF( ANRM.LT.SMLNUM )
$ CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN, 1, S, MINMN,
$ IERR )
IF( INFO.NE.0 .AND. ANRM.LT.SMLNUM )
$ CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN-1, 1, WORK( 2 ),
$ MINMN, IERR )
END IF
*
* Return optimal workspace in WORK(1)
*
WORK( 1 ) = MAXWRK
*
RETURN
*
* End of DGESVD
*
END
| gpl-2.0 |
eligere/eligere | FAHPcore/eigen/lapack/iladlc.f | 272 | 2952 | *> \brief \b ILADLC
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download ILADLC + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/iladlc.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/iladlc.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/iladlc.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* INTEGER FUNCTION ILADLC( M, N, A, LDA )
*
* .. Scalar Arguments ..
* INTEGER M, N, LDA
* ..
* .. Array Arguments ..
* DOUBLE PRECISION A( LDA, * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ILADLC scans A for its last non-zero column.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> The number of rows of the matrix A.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of columns of the matrix A.
*> \endverbatim
*>
*> \param[in] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (LDA,N)
*> The m by n matrix A.
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of the array A. LDA >= max(1,M).
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup auxOTHERauxiliary
*
* =====================================================================
INTEGER FUNCTION ILADLC( M, N, A, LDA )
*
* -- 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 ..
INTEGER M, N, LDA
* ..
* .. Array Arguments ..
DOUBLE PRECISION A( LDA, * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO
PARAMETER ( ZERO = 0.0D+0 )
* ..
* .. Local Scalars ..
INTEGER I
* ..
* .. Executable Statements ..
*
* Quick test for the common case where one corner is non-zero.
IF( N.EQ.0 ) THEN
ILADLC = N
ELSE IF( A(1, N).NE.ZERO .OR. A(M, N).NE.ZERO ) THEN
ILADLC = N
ELSE
* Now scan each column from the end, returning with the first non-zero.
DO ILADLC = N, 1, -1
DO I = 1, M
IF( A(I, ILADLC).NE.ZERO ) RETURN
END DO
END DO
END IF
RETURN
END
| gpl-3.0 |
jag1g13/lammps | lib/linalg/dlaeda.f | 50 | 9906 | *> \brief \b DLAEDA used by sstedc. Computes the Z vector determining the rank-one modification of the diagonal matrix. Used when the original matrix is dense.
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download DLAEDA + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaeda.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaeda.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaeda.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE DLAEDA( N, TLVLS, CURLVL, CURPBM, PRMPTR, PERM, GIVPTR,
* GIVCOL, GIVNUM, Q, QPTR, Z, ZTEMP, INFO )
*
* .. Scalar Arguments ..
* INTEGER CURLVL, CURPBM, INFO, N, TLVLS
* ..
* .. Array Arguments ..
* INTEGER GIVCOL( 2, * ), GIVPTR( * ), PERM( * ),
* $ PRMPTR( * ), QPTR( * )
* DOUBLE PRECISION GIVNUM( 2, * ), Q( * ), Z( * ), ZTEMP( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DLAEDA computes the Z vector corresponding to the merge step in the
*> CURLVLth step of the merge process with TLVLS steps for the CURPBMth
*> problem.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The dimension of the symmetric tridiagonal matrix. N >= 0.
*> \endverbatim
*>
*> \param[in] TLVLS
*> \verbatim
*> TLVLS is INTEGER
*> The total number of merging levels in the overall divide and
*> conquer tree.
*> \endverbatim
*>
*> \param[in] CURLVL
*> \verbatim
*> CURLVL is INTEGER
*> The current level in the overall merge routine,
*> 0 <= curlvl <= tlvls.
*> \endverbatim
*>
*> \param[in] CURPBM
*> \verbatim
*> CURPBM is INTEGER
*> The current problem in the current level in the overall
*> merge routine (counting from upper left to lower right).
*> \endverbatim
*>
*> \param[in] PRMPTR
*> \verbatim
*> PRMPTR is INTEGER array, dimension (N lg N)
*> Contains a list of pointers which indicate where in PERM a
*> level's permutation is stored. PRMPTR(i+1) - PRMPTR(i)
*> indicates the size of the permutation and incidentally the
*> size of the full, non-deflated problem.
*> \endverbatim
*>
*> \param[in] PERM
*> \verbatim
*> PERM is INTEGER array, dimension (N lg N)
*> Contains the permutations (from deflation and sorting) to be
*> applied to each eigenblock.
*> \endverbatim
*>
*> \param[in] GIVPTR
*> \verbatim
*> GIVPTR is INTEGER array, dimension (N lg N)
*> Contains a list of pointers which indicate where in GIVCOL a
*> level's Givens rotations are stored. GIVPTR(i+1) - GIVPTR(i)
*> indicates the number of Givens rotations.
*> \endverbatim
*>
*> \param[in] GIVCOL
*> \verbatim
*> GIVCOL is INTEGER array, dimension (2, N lg N)
*> Each pair of numbers indicates a pair of columns to take place
*> in a Givens rotation.
*> \endverbatim
*>
*> \param[in] GIVNUM
*> \verbatim
*> GIVNUM is DOUBLE PRECISION array, dimension (2, N lg N)
*> Each number indicates the S value to be used in the
*> corresponding Givens rotation.
*> \endverbatim
*>
*> \param[in] Q
*> \verbatim
*> Q is DOUBLE PRECISION array, dimension (N**2)
*> Contains the square eigenblocks from previous levels, the
*> starting positions for blocks are given by QPTR.
*> \endverbatim
*>
*> \param[in] QPTR
*> \verbatim
*> QPTR is INTEGER array, dimension (N+2)
*> Contains a list of pointers which indicate where in Q an
*> eigenblock is stored. SQRT( QPTR(i+1) - QPTR(i) ) indicates
*> the size of the block.
*> \endverbatim
*>
*> \param[out] Z
*> \verbatim
*> Z is DOUBLE PRECISION array, dimension (N)
*> On output this vector contains the updating vector (the last
*> row of the first sub-eigenvector matrix and the first row of
*> the second sub-eigenvector matrix).
*> \endverbatim
*>
*> \param[out] ZTEMP
*> \verbatim
*> ZTEMP is DOUBLE PRECISION 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.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date September 2012
*
*> \ingroup auxOTHERcomputational
*
*> \par Contributors:
* ==================
*>
*> Jeff Rutter, Computer Science Division, University of California
*> at Berkeley, USA
*
* =====================================================================
SUBROUTINE DLAEDA( N, TLVLS, CURLVL, CURPBM, PRMPTR, PERM, GIVPTR,
$ GIVCOL, GIVNUM, Q, QPTR, Z, ZTEMP, 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 CURLVL, CURPBM, INFO, N, TLVLS
* ..
* .. Array Arguments ..
INTEGER GIVCOL( 2, * ), GIVPTR( * ), PERM( * ),
$ PRMPTR( * ), QPTR( * )
DOUBLE PRECISION GIVNUM( 2, * ), Q( * ), Z( * ), ZTEMP( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO, HALF, ONE
PARAMETER ( ZERO = 0.0D0, HALF = 0.5D0, ONE = 1.0D0 )
* ..
* .. Local Scalars ..
INTEGER BSIZ1, BSIZ2, CURR, I, K, MID, PSIZ1, PSIZ2,
$ PTR, ZPTR1
* ..
* .. External Subroutines ..
EXTERNAL DCOPY, DGEMV, DROT, XERBLA
* ..
* .. Intrinsic Functions ..
INTRINSIC DBLE, INT, SQRT
* ..
* .. Executable Statements ..
*
* Test the input parameters.
*
INFO = 0
*
IF( N.LT.0 ) THEN
INFO = -1
END IF
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'DLAEDA', -INFO )
RETURN
END IF
*
* Quick return if possible
*
IF( N.EQ.0 )
$ RETURN
*
* Determine location of first number in second half.
*
MID = N / 2 + 1
*
* Gather last/first rows of appropriate eigenblocks into center of Z
*
PTR = 1
*
* Determine location of lowest level subproblem in the full storage
* scheme
*
CURR = PTR + CURPBM*2**CURLVL + 2**( CURLVL-1 ) - 1
*
* Determine size of these matrices. We add HALF to the value of
* the SQRT in case the machine underestimates one of these square
* roots.
*
BSIZ1 = INT( HALF+SQRT( DBLE( QPTR( CURR+1 )-QPTR( CURR ) ) ) )
BSIZ2 = INT( HALF+SQRT( DBLE( QPTR( CURR+2 )-QPTR( CURR+1 ) ) ) )
DO 10 K = 1, MID - BSIZ1 - 1
Z( K ) = ZERO
10 CONTINUE
CALL DCOPY( BSIZ1, Q( QPTR( CURR )+BSIZ1-1 ), BSIZ1,
$ Z( MID-BSIZ1 ), 1 )
CALL DCOPY( BSIZ2, Q( QPTR( CURR+1 ) ), BSIZ2, Z( MID ), 1 )
DO 20 K = MID + BSIZ2, N
Z( K ) = ZERO
20 CONTINUE
*
* Loop through remaining levels 1 -> CURLVL applying the Givens
* rotations and permutation and then multiplying the center matrices
* against the current Z.
*
PTR = 2**TLVLS + 1
DO 70 K = 1, CURLVL - 1
CURR = PTR + CURPBM*2**( CURLVL-K ) + 2**( CURLVL-K-1 ) - 1
PSIZ1 = PRMPTR( CURR+1 ) - PRMPTR( CURR )
PSIZ2 = PRMPTR( CURR+2 ) - PRMPTR( CURR+1 )
ZPTR1 = MID - PSIZ1
*
* Apply Givens at CURR and CURR+1
*
DO 30 I = GIVPTR( CURR ), GIVPTR( CURR+1 ) - 1
CALL DROT( 1, Z( ZPTR1+GIVCOL( 1, I )-1 ), 1,
$ Z( ZPTR1+GIVCOL( 2, I )-1 ), 1, GIVNUM( 1, I ),
$ GIVNUM( 2, I ) )
30 CONTINUE
DO 40 I = GIVPTR( CURR+1 ), GIVPTR( CURR+2 ) - 1
CALL DROT( 1, Z( MID-1+GIVCOL( 1, I ) ), 1,
$ Z( MID-1+GIVCOL( 2, I ) ), 1, GIVNUM( 1, I ),
$ GIVNUM( 2, I ) )
40 CONTINUE
PSIZ1 = PRMPTR( CURR+1 ) - PRMPTR( CURR )
PSIZ2 = PRMPTR( CURR+2 ) - PRMPTR( CURR+1 )
DO 50 I = 0, PSIZ1 - 1
ZTEMP( I+1 ) = Z( ZPTR1+PERM( PRMPTR( CURR )+I )-1 )
50 CONTINUE
DO 60 I = 0, PSIZ2 - 1
ZTEMP( PSIZ1+I+1 ) = Z( MID+PERM( PRMPTR( CURR+1 )+I )-1 )
60 CONTINUE
*
* Multiply Blocks at CURR and CURR+1
*
* Determine size of these matrices. We add HALF to the value of
* the SQRT in case the machine underestimates one of these
* square roots.
*
BSIZ1 = INT( HALF+SQRT( DBLE( QPTR( CURR+1 )-QPTR( CURR ) ) ) )
BSIZ2 = INT( HALF+SQRT( DBLE( QPTR( CURR+2 )-QPTR( CURR+
$ 1 ) ) ) )
IF( BSIZ1.GT.0 ) THEN
CALL DGEMV( 'T', BSIZ1, BSIZ1, ONE, Q( QPTR( CURR ) ),
$ BSIZ1, ZTEMP( 1 ), 1, ZERO, Z( ZPTR1 ), 1 )
END IF
CALL DCOPY( PSIZ1-BSIZ1, ZTEMP( BSIZ1+1 ), 1, Z( ZPTR1+BSIZ1 ),
$ 1 )
IF( BSIZ2.GT.0 ) THEN
CALL DGEMV( 'T', BSIZ2, BSIZ2, ONE, Q( QPTR( CURR+1 ) ),
$ BSIZ2, ZTEMP( PSIZ1+1 ), 1, ZERO, Z( MID ), 1 )
END IF
CALL DCOPY( PSIZ2-BSIZ2, ZTEMP( PSIZ1+BSIZ2+1 ), 1,
$ Z( MID+BSIZ2 ), 1 )
*
PTR = PTR + 2**( TLVLS-K )
70 CONTINUE
*
RETURN
*
* End of DLAEDA
*
END
| gpl-2.0 |
SaberMod/GCC_SaberMod | libgfortran/intrinsics/selected_real_kind.f90 | 35 | 3245 | ! Copyright (C) 2003-2014 Free Software Foundation, Inc.
! Contributed by Kejia Zhao <kejia_zh@yahoo.com.cn>
!
!This file is part of the GNU Fortran runtime library (libgfortran).
!
!Libgfortran is free software; you can redistribute it and/or
!modify it under the terms of the GNU General Public
!License as published by the Free Software Foundation; either
!version 3 of the License, or (at your option) any later version.
!
!Libgfortran is distributed in the hope that it will be useful,
!but WITHOUT ANY WARRANTY; without even the implied warranty of
!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!GNU General Public License for more details.
!
!Under Section 7 of GPL version 3, you are granted additional
!permissions described in the GCC Runtime Library Exception, version
!3.1, as published by the Free Software Foundation.
!
!You should have received a copy of the GNU General Public License and
!a copy of the GCC Runtime Library Exception along with this program;
!see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
!<http://www.gnu.org/licenses/>.
function _gfortran_selected_real_kind2008 (p, r, rdx)
implicit none
integer, optional, intent (in) :: p, r, rdx
integer :: _gfortran_selected_real_kind2008
integer :: i, p2, r2, radix2
logical :: found_p, found_r, found_radix
! Real kind_precision_range table
type :: real_info
integer :: kind
integer :: precision
integer :: range
integer :: radix
end type real_info
include "selected_real_kind.inc"
_gfortran_selected_real_kind2008 = 0
p2 = 0
r2 = 0
radix2 = 0
found_p = .false.
found_r = .false.
found_radix = .false.
if (present (p)) p2 = p
if (present (r)) r2 = r
if (present (rdx)) radix2 = rdx
! Assumes each type has a greater precision and range than previous one.
do i = 1, c
if (p2 <= real_infos (i) % precision) found_p = .true.
if (r2 <= real_infos (i) % range) found_r = .true.
if (radix2 <= real_infos (i) % radix) found_radix = .true.
if (p2 <= real_infos (i) % precision &
.and. r2 <= real_infos (i) % range &
.and. radix2 <= real_infos (i) % radix) then
_gfortran_selected_real_kind2008 = real_infos (i) % kind
return
end if
end do
if (found_radix .and. found_r .and. .not. found_p) then
_gfortran_selected_real_kind2008 = -1
elseif (found_radix .and. found_p .and. .not. found_r) then
_gfortran_selected_real_kind2008 = -2
elseif (found_radix .and. .not. found_p .and. .not. found_r) then
_gfortran_selected_real_kind2008 = -3
elseif (found_radix) then
_gfortran_selected_real_kind2008 = -4
else
_gfortran_selected_real_kind2008 = -5
end if
end function _gfortran_selected_real_kind2008
function _gfortran_selected_real_kind (p, r)
implicit none
integer, optional, intent (in) :: p, r
integer :: _gfortran_selected_real_kind
interface
function _gfortran_selected_real_kind2008 (p, r, rdx)
implicit none
integer, optional, intent (in) :: p, r, rdx
integer :: _gfortran_selected_real_kind2008
end function _gfortran_selected_real_kind2008
end interface
_gfortran_selected_real_kind = _gfortran_selected_real_kind2008 (p, r)
end function
| gpl-2.0 |
SaberMod/GCC_SaberMod | libgfortran/generated/_acosh_r10.F90 | 35 | 1484 | ! Copyright (C) 2002-2014 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_ACOSHL
elemental function _gfortran_specific__acosh_r10 (parm)
real (kind=10), intent (in) :: parm
real (kind=10) :: _gfortran_specific__acosh_r10
_gfortran_specific__acosh_r10 = acosh (parm)
end function
#endif
#endif
| gpl-2.0 |
OpenVnmrJ/OpenVnmrJ | src/ib/port3/dv2nrm.f | 3 | 1501 | DOUBLE PRECISION FUNCTION DV2NRM(P, X)
C
C *** RETURN THE 2-NORM OF THE P-VECTOR X, TAKING ***
C *** CARE TO AVOID THE MOST LIKELY UNDERFLOWS. ***
C
INTEGER P
DOUBLE PRECISION X(P)
C
INTEGER I, J
DOUBLE PRECISION ONE, R, SCALE, SQTETA, T, XI, ZERO
C/+
DOUBLE PRECISION DSQRT
C/
DOUBLE PRECISION DR7MDC
EXTERNAL DR7MDC
C
C/6
C DATA ONE/1.D+0/, ZERO/0.D+0/
C/7
PARAMETER (ONE=1.D+0, ZERO=0.D+0)
SAVE SQTETA
C/
DATA SQTETA/0.D+0/
C
IF (P .GT. 0) GO TO 10
DV2NRM = ZERO
GO TO 999
10 DO 20 I = 1, P
IF (X(I) .NE. ZERO) GO TO 30
20 CONTINUE
DV2NRM = ZERO
GO TO 999
C
30 SCALE = DABS(X(I))
IF (I .LT. P) GO TO 40
DV2NRM = SCALE
GO TO 999
40 T = ONE
IF (SQTETA .EQ. ZERO) SQTETA = DR7MDC(2)
C
C *** SQTETA IS (SLIGHTLY LARGER THAN) THE SQUARE ROOT OF THE
C *** SMALLEST POSITIVE FLOATING POINT NUMBER ON THE MACHINE.
C *** THE TESTS INVOLVING SQTETA ARE DONE TO PREVENT UNDERFLOWS.
C
J = I + 1
DO 60 I = J, P
XI = DABS(X(I))
IF (XI .GT. SCALE) GO TO 50
R = XI / SCALE
IF (R .GT. SQTETA) T = T + R*R
GO TO 60
50 R = SCALE / XI
IF (R .LE. SQTETA) R = ZERO
T = ONE + T * R*R
SCALE = XI
60 CONTINUE
C
DV2NRM = SCALE * DSQRT(T)
999 RETURN
C *** LAST LINE OF DV2NRM FOLLOWS ***
END
| apache-2.0 |
eligere/eligere | FAHPcore-network/eigen/lapack/ilazlr.f | 271 | 3010 | *> \brief \b ILAZLR
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download ILAZLR + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ilazlr.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ilazlr.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ilazlr.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* INTEGER FUNCTION ILAZLR( M, N, A, LDA )
*
* .. Scalar Arguments ..
* INTEGER M, N, LDA
* ..
* .. Array Arguments ..
* COMPLEX*16 A( LDA, * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ILAZLR scans A for its last non-zero row.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> The number of rows of the matrix A.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of columns of the matrix A.
*> \endverbatim
*>
*> \param[in] A
*> \verbatim
*> A is COMPLEX*16 array, dimension (LDA,N)
*> The m by n matrix A.
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of the array A. LDA >= max(1,M).
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date April 2012
*
*> \ingroup complex16OTHERauxiliary
*
* =====================================================================
INTEGER FUNCTION ILAZLR( M, N, A, LDA )
*
* -- LAPACK auxiliary 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 ..
INTEGER M, N, LDA
* ..
* .. Array Arguments ..
COMPLEX*16 A( LDA, * )
* ..
*
* =====================================================================
*
* .. Parameters ..
COMPLEX*16 ZERO
PARAMETER ( ZERO = (0.0D+0, 0.0D+0) )
* ..
* .. Local Scalars ..
INTEGER I, J
* ..
* .. Executable Statements ..
*
* Quick test for the common case where one corner is non-zero.
IF( M.EQ.0 ) THEN
ILAZLR = M
ELSE IF( A(M, 1).NE.ZERO .OR. A(M, N).NE.ZERO ) THEN
ILAZLR = M
ELSE
* Scan up each column tracking the last zero row seen.
ILAZLR = 0
DO J = 1, N
I=M
DO WHILE((A(MAX(I,1),J).EQ.ZERO).AND.(I.GE.1))
I=I-1
ENDDO
ILAZLR = MAX( ILAZLR, I )
END DO
END IF
RETURN
END
| gpl-3.0 |
OpenVnmrJ/OpenVnmrJ | src/ib/port3/dg7qts.f | 1 | 21907 | SUBROUTINE DG7QTS(D, DIG, DIHDI, KA, L, P, STEP, V, W)
C
C *** COMPUTE GOLDFELD-QUANDT-TROTTER STEP BY MORE-HEBDEN TECHNIQUE ***
C *** (NL2SOL VERSION 2.2), MODIFIED A LA MORE AND SORENSEN ***
C
C *** PARAMETER DECLARATIONS ***
C
INTEGER KA, P
DOUBLE PRECISION D(P), DIG(P), DIHDI(1), L(1), V(21), STEP(P),
1 W(1)
C DIMENSION DIHDI(P*(P+1)/2), L(P*(P+1)/2), W(4*P+7)
C
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C *** PURPOSE ***
C
C GIVEN THE (COMPACTLY STORED) LOWER TRIANGLE OF A SCALED
C HESSIAN (APPROXIMATION) AND A NONZERO SCALED GRADIENT VECTOR,
C THIS SUBROUTINE COMPUTES A GOLDFELD-QUANDT-TROTTER STEP OF
C APPROXIMATE LENGTH V(RADIUS) BY THE MORE-HEBDEN TECHNIQUE. IN
C OTHER WORDS, STEP IS COMPUTED TO (APPROXIMATELY) MINIMIZE
C PSI(STEP) = (G**T)*STEP + 0.5*(STEP**T)*H*STEP SUCH THAT THE
C 2-NORM OF D*STEP IS AT MOST (APPROXIMATELY) V(RADIUS), WHERE
C G IS THE GRADIENT, H IS THE HESSIAN, AND D IS A DIAGONAL
C SCALE MATRIX WHOSE DIAGONAL IS STORED IN THE PARAMETER D.
C (DG7QTS ASSUMES DIG = D**-1 * G AND DIHDI = D**-1 * H * D**-1.)
C
C *** PARAMETER DESCRIPTION ***
C
C D (IN) = THE SCALE VECTOR, I.E. THE DIAGONAL OF THE SCALE
C MATRIX D MENTIONED ABOVE UNDER PURPOSE.
C DIG (IN) = THE SCALED GRADIENT VECTOR, D**-1 * G. IF G = 0, THEN
C STEP = 0 AND V(STPPAR) = 0 ARE RETURNED.
C DIHDI (IN) = LOWER TRIANGLE OF THE SCALED HESSIAN (APPROXIMATION),
C I.E., D**-1 * H * D**-1, STORED COMPACTLY BY ROWS., I.E.,
C IN THE ORDER (1,1), (2,1), (2,2), (3,1), (3,2), ETC.
C KA (I/O) = THE NUMBER OF HEBDEN ITERATIONS (SO FAR) TAKEN TO DETER-
C MINE STEP. KA .LT. 0 ON INPUT MEANS THIS IS THE FIRST
C ATTEMPT TO DETERMINE STEP (FOR THE PRESENT DIG AND DIHDI)
C -- KA IS INITIALIZED TO 0 IN THIS CASE. OUTPUT WITH
C KA = 0 (OR V(STPPAR) = 0) MEANS STEP = -(H**-1)*G.
C L (I/O) = WORKSPACE OF LENGTH P*(P+1)/2 FOR CHOLESKY FACTORS.
C P (IN) = NUMBER OF PARAMETERS -- THE HESSIAN IS A P X P MATRIX.
C STEP (I/O) = THE STEP COMPUTED.
C V (I/O) CONTAINS VARIOUS CONSTANTS AND VARIABLES DESCRIBED BELOW.
C W (I/O) = WORKSPACE OF LENGTH 4*P + 6.
C
C *** ENTRIES IN V ***
C
C V(DGNORM) (I/O) = 2-NORM OF (D**-1)*G.
C V(DSTNRM) (OUTPUT) = 2-NORM OF D*STEP.
C V(DST0) (I/O) = 2-NORM OF D*(H**-1)*G (FOR POS. DEF. H ONLY), OR
C OVERESTIMATE OF SMALLEST EIGENVALUE OF (D**-1)*H*(D**-1).
C V(EPSLON) (IN) = MAX. REL. ERROR ALLOWED FOR PSI(STEP). FOR THE
C STEP RETURNED, PSI(STEP) WILL EXCEED ITS OPTIMAL VALUE
C BY LESS THAN -V(EPSLON)*PSI(STEP). SUGGESTED VALUE = 0.1.
C V(GTSTEP) (OUT) = INNER PRODUCT BETWEEN G AND STEP.
C V(NREDUC) (OUT) = PSI(-(H**-1)*G) = PSI(NEWTON STEP) (FOR POS. DEF.
C H ONLY -- V(NREDUC) IS SET TO ZERO OTHERWISE).
C V(PHMNFC) (IN) = TOL. (TOGETHER WITH V(PHMXFC)) FOR ACCEPTING STEP
C (MORE*S SIGMA). THE ERROR V(DSTNRM) - V(RADIUS) MUST LIE
C BETWEEN V(PHMNFC)*V(RADIUS) AND V(PHMXFC)*V(RADIUS).
C V(PHMXFC) (IN) (SEE V(PHMNFC).)
C SUGGESTED VALUES -- V(PHMNFC) = -0.25, V(PHMXFC) = 0.5.
C V(PREDUC) (OUT) = PSI(STEP) = PREDICTED OBJ. FUNC. REDUCTION FOR STEP.
C V(RADIUS) (IN) = RADIUS OF CURRENT (SCALED) TRUST REGION.
C V(RAD0) (I/O) = VALUE OF V(RADIUS) FROM PREVIOUS CALL.
C V(STPPAR) (I/O) IS NORMALLY THE MARQUARDT PARAMETER, I.E. THE ALPHA
C DESCRIBED BELOW UNDER ALGORITHM NOTES. IF H + ALPHA*D**2
C (SEE ALGORITHM NOTES) IS (NEARLY) SINGULAR, HOWEVER,
C THEN V(STPPAR) = -ALPHA.
C
C *** USAGE NOTES ***
C
C IF IT IS DESIRED TO RECOMPUTE STEP USING A DIFFERENT VALUE OF
C V(RADIUS), THEN THIS ROUTINE MAY BE RESTARTED BY CALLING IT
C WITH ALL PARAMETERS UNCHANGED EXCEPT V(RADIUS). (THIS EXPLAINS
C WHY STEP AND W ARE LISTED AS I/O). ON AN INITIAL CALL (ONE WITH
C KA .LT. 0), STEP AND W NEED NOT BE INITIALIZED AND ONLY COMPO-
C NENTS V(EPSLON), V(STPPAR), V(PHMNFC), V(PHMXFC), V(RADIUS), AND
C V(RAD0) OF V MUST BE INITIALIZED.
C
C *** ALGORITHM NOTES ***
C
C THE DESIRED G-Q-T STEP (REF. 2, 3, 4, 6) SATISFIES
C (H + ALPHA*D**2)*STEP = -G FOR SOME NONNEGATIVE ALPHA SUCH THAT
C H + ALPHA*D**2 IS POSITIVE SEMIDEFINITE. ALPHA AND STEP ARE
C COMPUTED BY A SCHEME ANALOGOUS TO THE ONE DESCRIBED IN REF. 5.
C ESTIMATES OF THE SMALLEST AND LARGEST EIGENVALUES OF THE HESSIAN
C ARE OBTAINED FROM THE GERSCHGORIN CIRCLE THEOREM ENHANCED BY A
C SIMPLE FORM OF THE SCALING DESCRIBED IN REF. 7. CASES IN WHICH
C H + ALPHA*D**2 IS NEARLY (OR EXACTLY) SINGULAR ARE HANDLED BY
C THE TECHNIQUE DISCUSSED IN REF. 2. IN THESE CASES, A STEP OF
C (EXACT) LENGTH V(RADIUS) IS RETURNED FOR WHICH PSI(STEP) EXCEEDS
C ITS OPTIMAL VALUE BY LESS THAN -V(EPSLON)*PSI(STEP). THE TEST
C SUGGESTED IN REF. 6 FOR DETECTING THE SPECIAL CASE IS PERFORMED
C ONCE TWO MATRIX FACTORIZATIONS HAVE BEEN DONE -- DOING SO SOONER
C SEEMS TO DEGRADE THE PERFORMANCE OF OPTIMIZATION ROUTINES THAT
C CALL THIS ROUTINE.
C
C *** FUNCTIONS AND SUBROUTINES CALLED ***
C
C DD7TPR - RETURNS INNER PRODUCT OF TWO VECTORS.
C DL7ITV - APPLIES INVERSE-TRANSPOSE OF COMPACT LOWER TRIANG. MATRIX.
C DL7IVM - APPLIES INVERSE OF COMPACT LOWER TRIANG. MATRIX.
C DL7SRT - FINDS CHOLESKY FACTOR (OF COMPACTLY STORED LOWER TRIANG.).
C DL7SVN - RETURNS APPROX. TO MIN. SING. VALUE OF LOWER TRIANG. MATRIX.
C DR7MDC - RETURNS MACHINE-DEPENDENT CONSTANTS.
C DV2NRM - RETURNS 2-NORM OF A VECTOR.
C
C *** REFERENCES ***
C
C 1. DENNIS, J.E., GAY, D.M., AND WELSCH, R.E. (1981), AN ADAPTIVE
C NONLINEAR LEAST-SQUARES ALGORITHM, ACM TRANS. MATH.
C SOFTWARE, VOL. 7, NO. 3.
C 2. GAY, D.M. (1981), COMPUTING OPTIMAL LOCALLY CONSTRAINED STEPS,
C SIAM J. SCI. STATIST. COMPUTING, VOL. 2, NO. 2, PP.
C 186-197.
C 3. GOLDFELD, S.M., QUANDT, R.E., AND TROTTER, H.F. (1966),
C MAXIMIZATION BY QUADRATIC HILL-CLIMBING, ECONOMETRICA 34,
C PP. 541-551.
C 4. HEBDEN, M.D. (1973), AN ALGORITHM FOR MINIMIZATION USING EXACT
C SECOND DERIVATIVES, REPORT T.P. 515, THEORETICAL PHYSICS
C DIV., A.E.R.E. HARWELL, OXON., ENGLAND.
C 5. MORE, J.J. (1978), THE LEVENBERG-MARQUARDT ALGORITHM, IMPLEMEN-
C TATION AND THEORY, PP.105-116 OF SPRINGER LECTURE NOTES
C IN MATHEMATICS NO. 630, EDITED BY G.A. WATSON, SPRINGER-
C VERLAG, BERLIN AND NEW YORK.
C 6. MORE, J.J., AND SORENSEN, D.C. (1981), COMPUTING A TRUST REGION
C STEP, TECHNICAL REPORT ANL-81-83, ARGONNE NATIONAL LAB.
C 7. VARGA, R.S. (1965), MINIMAL GERSCHGORIN SETS, PACIFIC J. MATH. 15,
C PP. 719-729.
C
C *** GENERAL ***
C
C CODED BY DAVID M. GAY.
C THIS SUBROUTINE WAS WRITTEN IN CONNECTION WITH RESEARCH
C SUPPORTED BY THE NATIONAL SCIENCE FOUNDATION UNDER GRANTS
C MCS-7600324, DCR75-10143, 76-14311DSS, MCS76-11989, AND
C MCS-7906671.
C
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C *** LOCAL VARIABLES ***
C
LOGICAL RESTRT
INTEGER DGGDMX, DIAG, DIAG0, DSTSAV, EMAX, EMIN, I, IM1, INC, IRC,
1 J, K, KALIM, KAMIN, K1, LK0, PHIPIN, Q, Q0, UK0, X
DOUBLE PRECISION ALPHAK, AKI, AKK, DELTA, DST, EPS, GTSTA, LK,
1 OLDPHI, PHI, PHIMAX, PHIMIN, PSIFAC, RAD, RADSQ,
2 ROOT, SI, SK, SW, T, TWOPSI, T1, T2, UK, WI
C
C *** CONSTANTS ***
DOUBLE PRECISION BIG, DGXFAC, EPSFAC, FOUR, HALF, KAPPA, NEGONE,
1 ONE, P001, SIX, THREE, TWO, ZERO
C
C *** INTRINSIC FUNCTIONS ***
C/+
DOUBLE PRECISION DSQRT
C/
C *** EXTERNAL FUNCTIONS AND SUBROUTINES ***
C
DOUBLE PRECISION DD7TPR, DL7SVN, DR7MDC, DV2NRM
EXTERNAL DD7TPR, DL7ITV, DL7IVM,DL7SRT, DL7SVN, DR7MDC, DV2NRM
C
C *** SUBSCRIPTS FOR V ***
C
INTEGER DGNORM, DSTNRM, DST0, EPSLON, GTSTEP, STPPAR, NREDUC,
1 PHMNFC, PHMXFC, PREDUC, RADIUS, RAD0
C/6
C DATA DGNORM/1/, DSTNRM/2/, DST0/3/, EPSLON/19/, GTSTEP/4/,
C 1 NREDUC/6/, PHMNFC/20/, PHMXFC/21/, PREDUC/7/, RADIUS/8/,
C 2 RAD0/9/, STPPAR/5/
C/7
PARAMETER (DGNORM=1, DSTNRM=2, DST0=3, EPSLON=19, GTSTEP=4,
1 NREDUC=6, PHMNFC=20, PHMXFC=21, PREDUC=7, RADIUS=8,
2 RAD0=9, STPPAR=5)
C/
C
C/6
C DATA EPSFAC/50.0D+0/, FOUR/4.0D+0/, HALF/0.5D+0/,
C 1 KAPPA/2.0D+0/, NEGONE/-1.0D+0/, ONE/1.0D+0/, P001/1.0D-3/,
C 2 SIX/6.0D+0/, THREE/3.0D+0/, TWO/2.0D+0/, ZERO/0.0D+0/
C/7
PARAMETER (EPSFAC=50.0D+0, FOUR=4.0D+0, HALF=0.5D+0,
1 KAPPA=2.0D+0, NEGONE=-1.0D+0, ONE=1.0D+0, P001=1.0D-3,
2 SIX=6.0D+0, THREE=3.0D+0, TWO=2.0D+0, ZERO=0.0D+0)
SAVE DGXFAC
C/
DATA BIG/0.D+0/, DGXFAC/0.D+0/
C
C *** BODY ***
C
IF (BIG .LE. ZERO) BIG = DR7MDC(6)
C
C *** STORE LARGEST ABS. ENTRY IN (D**-1)*H*(D**-1) AT W(DGGDMX).
DGGDMX = P + 1
C *** STORE GERSCHGORIN OVER- AND UNDERESTIMATES OF THE LARGEST
C *** AND SMALLEST EIGENVALUES OF (D**-1)*H*(D**-1) AT W(EMAX)
C *** AND W(EMIN) RESPECTIVELY.
EMAX = DGGDMX + 1
EMIN = EMAX + 1
C *** FOR USE IN RECOMPUTING STEP, THE FINAL VALUES OF LK, UK, DST,
C *** AND THE INVERSE DERIVATIVE OF MORE*S PHI AT 0 (FOR POS. DEF.
C *** H) ARE STORED IN W(LK0), W(UK0), W(DSTSAV), AND W(PHIPIN)
C *** RESPECTIVELY.
LK0 = EMIN + 1
PHIPIN = LK0 + 1
UK0 = PHIPIN + 1
DSTSAV = UK0 + 1
C *** STORE DIAG OF (D**-1)*H*(D**-1) IN W(DIAG),...,W(DIAG0+P).
DIAG0 = DSTSAV
DIAG = DIAG0 + 1
C *** STORE -D*STEP IN W(Q),...,W(Q0+P).
Q0 = DIAG0 + P
Q = Q0 + 1
C *** ALLOCATE STORAGE FOR SCRATCH VECTOR X ***
X = Q + P
RAD = V(RADIUS)
RADSQ = RAD**2
C *** PHITOL = MAX. ERROR ALLOWED IN DST = V(DSTNRM) = 2-NORM OF
C *** D*STEP.
PHIMAX = V(PHMXFC) * RAD
PHIMIN = V(PHMNFC) * RAD
PSIFAC = BIG
T1 = TWO * V(EPSLON) / (THREE * (FOUR * (V(PHMNFC) + ONE) *
1 (KAPPA + ONE) + KAPPA + TWO) * RAD)
IF (T1 .LT. BIG*DMIN1(RAD,ONE)) PSIFAC = T1 / RAD
C *** OLDPHI IS USED TO DETECT LIMITS OF NUMERICAL ACCURACY. IF
C *** WE RECOMPUTE STEP AND IT DOES NOT CHANGE, THEN WE ACCEPT IT.
OLDPHI = ZERO
EPS = V(EPSLON)
IRC = 0
RESTRT = .FALSE.
KALIM = KA + 50
C
C *** START OR RESTART, DEPENDING ON KA ***
C
IF (KA .GE. 0) GO TO 290
C
C *** FRESH START ***
C
K = 0
UK = NEGONE
KA = 0
KALIM = 50
V(DGNORM) = DV2NRM(P, DIG)
V(NREDUC) = ZERO
V(DST0) = ZERO
KAMIN = 3
IF (V(DGNORM) .EQ. ZERO) KAMIN = 0
C
C *** STORE DIAG(DIHDI) IN W(DIAG0+1),...,W(DIAG0+P) ***
C
J = 0
DO 10 I = 1, P
J = J + I
K1 = DIAG0 + I
W(K1) = DIHDI(J)
10 CONTINUE
C
C *** DETERMINE W(DGGDMX), THE LARGEST ELEMENT OF DIHDI ***
C
T1 = ZERO
J = P * (P + 1) / 2
DO 20 I = 1, J
T = DABS(DIHDI(I))
IF (T1 .LT. T) T1 = T
20 CONTINUE
W(DGGDMX) = T1
C
C *** TRY ALPHA = 0 ***
C
30 CALL DL7SRT(1, P, L, DIHDI, IRC)
IF (IRC .EQ. 0) GO TO 50
C *** INDEF. H -- UNDERESTIMATE SMALLEST EIGENVALUE, USE THIS
C *** ESTIMATE TO INITIALIZE LOWER BOUND LK ON ALPHA.
J = IRC*(IRC+1)/2
T = L(J)
L(J) = ONE
DO 40 I = 1, IRC
40 W(I) = ZERO
W(IRC) = ONE
CALL DL7ITV(IRC, W, L, W)
T1 = DV2NRM(IRC, W)
LK = -T / T1 / T1
V(DST0) = -LK
IF (RESTRT) GO TO 210
GO TO 70
C
C *** POSITIVE DEFINITE H -- COMPUTE UNMODIFIED NEWTON STEP. ***
50 LK = ZERO
T = DL7SVN(P, L, W(Q), W(Q))
IF (T .GE. ONE) GO TO 60
IF (V(DGNORM) .GE. T*T*BIG) GO TO 70
60 CALL DL7IVM(P, W(Q), L, DIG)
GTSTA = DD7TPR(P, W(Q), W(Q))
V(NREDUC) = HALF * GTSTA
CALL DL7ITV(P, W(Q), L, W(Q))
DST = DV2NRM(P, W(Q))
V(DST0) = DST
PHI = DST - RAD
IF (PHI .LE. PHIMAX) GO TO 260
IF (RESTRT) GO TO 210
C
C *** PREPARE TO COMPUTE GERSCHGORIN ESTIMATES OF LARGEST (AND
C *** SMALLEST) EIGENVALUES. ***
C
70 K = 0
DO 100 I = 1, P
WI = ZERO
IF (I .EQ. 1) GO TO 90
IM1 = I - 1
DO 80 J = 1, IM1
K = K + 1
T = DABS(DIHDI(K))
WI = WI + T
W(J) = W(J) + T
80 CONTINUE
90 W(I) = WI
K = K + 1
100 CONTINUE
C
C *** (UNDER-)ESTIMATE SMALLEST EIGENVALUE OF (D**-1)*H*(D**-1) ***
C
K = 1
T1 = W(DIAG) - W(1)
IF (P .LE. 1) GO TO 120
DO 110 I = 2, P
J = DIAG0 + I
T = W(J) - W(I)
IF (T .GE. T1) GO TO 110
T1 = T
K = I
110 CONTINUE
C
120 SK = W(K)
J = DIAG0 + K
AKK = W(J)
K1 = K*(K-1)/2 + 1
INC = 1
T = ZERO
DO 150 I = 1, P
IF (I .EQ. K) GO TO 130
AKI = DABS(DIHDI(K1))
SI = W(I)
J = DIAG0 + I
T1 = HALF * (AKK - W(J) + SI - AKI)
T1 = T1 + DSQRT(T1*T1 + SK*AKI)
IF (T .LT. T1) T = T1
IF (I .LT. K) GO TO 140
130 INC = I
140 K1 = K1 + INC
150 CONTINUE
C
W(EMIN) = AKK - T
UK = V(DGNORM)/RAD - W(EMIN)
IF (V(DGNORM) .EQ. ZERO) UK = UK + P001 + P001*UK
IF (UK .LE. ZERO) UK = P001
C
C *** COMPUTE GERSCHGORIN (OVER-)ESTIMATE OF LARGEST EIGENVALUE ***
C
K = 1
T1 = W(DIAG) + W(1)
IF (P .LE. 1) GO TO 170
DO 160 I = 2, P
J = DIAG0 + I
T = W(J) + W(I)
IF (T .LE. T1) GO TO 160
T1 = T
K = I
160 CONTINUE
C
170 SK = W(K)
J = DIAG0 + K
AKK = W(J)
K1 = K*(K-1)/2 + 1
INC = 1
T = ZERO
DO 200 I = 1, P
IF (I .EQ. K) GO TO 180
AKI = DABS(DIHDI(K1))
SI = W(I)
J = DIAG0 + I
T1 = HALF * (W(J) + SI - AKI - AKK)
T1 = T1 + DSQRT(T1*T1 + SK*AKI)
IF (T .LT. T1) T = T1
IF (I .LT. K) GO TO 190
180 INC = I
190 K1 = K1 + INC
200 CONTINUE
C
W(EMAX) = AKK + T
LK = DMAX1(LK, V(DGNORM)/RAD - W(EMAX))
C
C *** ALPHAK = CURRENT VALUE OF ALPHA (SEE ALG. NOTES ABOVE). WE
C *** USE MORE*S SCHEME FOR INITIALIZING IT.
ALPHAK = DABS(V(STPPAR)) * V(RAD0)/RAD
ALPHAK = DMIN1(UK, DMAX1(ALPHAK, LK))
C
IF (IRC .NE. 0) GO TO 210
C
C *** COMPUTE L0 FOR POSITIVE DEFINITE H ***
C
CALL DL7IVM(P, W, L, W(Q))
T = DV2NRM(P, W)
W(PHIPIN) = RAD / T / T
LK = DMAX1(LK, PHI*W(PHIPIN))
C
C *** SAFEGUARD ALPHAK AND ADD ALPHAK*I TO (D**-1)*H*(D**-1) ***
C
210 KA = KA + 1
IF (-V(DST0) .GE. ALPHAK .OR. ALPHAK .LT. LK .OR. ALPHAK .GE. UK)
1 ALPHAK = UK * DMAX1(P001, DSQRT(LK/UK))
IF (ALPHAK .LE. ZERO) ALPHAK = HALF * UK
IF (ALPHAK .LE. ZERO) ALPHAK = UK
K = 0
DO 220 I = 1, P
K = K + I
J = DIAG0 + I
DIHDI(K) = W(J) + ALPHAK
220 CONTINUE
C
C *** TRY COMPUTING CHOLESKY DECOMPOSITION ***
C
CALL DL7SRT(1, P, L, DIHDI, IRC)
IF (IRC .EQ. 0) GO TO 240
C
C *** (D**-1)*H*(D**-1) + ALPHAK*I IS INDEFINITE -- OVERESTIMATE
C *** SMALLEST EIGENVALUE FOR USE IN UPDATING LK ***
C
J = (IRC*(IRC+1))/2
T = L(J)
L(J) = ONE
DO 230 I = 1, IRC
230 W(I) = ZERO
W(IRC) = ONE
CALL DL7ITV(IRC, W, L, W)
T1 = DV2NRM(IRC, W)
LK = ALPHAK - T/T1/T1
V(DST0) = -LK
IF (UK .LT. LK) UK = LK
IF (ALPHAK .LT. LK) GO TO 210
C
C *** NASTY CASE -- EXACT GERSCHGORIN BOUNDS. FUDGE LK, UK...
C
T = P001 * ALPHAK
IF (T .LE. ZERO) T = P001
LK = ALPHAK + T
IF (UK .LE. LK) UK = LK + T
GO TO 210
C
C *** ALPHAK MAKES (D**-1)*H*(D**-1) POSITIVE DEFINITE.
C *** COMPUTE Q = -D*STEP, CHECK FOR CONVERGENCE. ***
C
240 CALL DL7IVM(P, W(Q), L, DIG)
GTSTA = DD7TPR(P, W(Q), W(Q))
CALL DL7ITV(P, W(Q), L, W(Q))
DST = DV2NRM(P, W(Q))
PHI = DST - RAD
IF (PHI .LE. PHIMAX .AND. PHI .GE. PHIMIN) GO TO 270
IF (PHI .EQ. OLDPHI) GO TO 270
OLDPHI = PHI
IF (PHI .LT. ZERO) GO TO 330
C
C *** UNACCEPTABLE ALPHAK -- UPDATE LK, UK, ALPHAK ***
C
250 IF (KA .GE. KALIM) GO TO 270
C *** THE FOLLOWING DMIN1 IS NECESSARY BECAUSE OF RESTARTS ***
IF (PHI .LT. ZERO) UK = DMIN1(UK, ALPHAK)
C *** KAMIN = 0 ONLY IFF THE GRADIENT VANISHES ***
IF (KAMIN .EQ. 0) GO TO 210
CALL DL7IVM(P, W, L, W(Q))
C *** THE FOLLOWING, COMMENTED CALCULATION OF ALPHAK IS SOMETIMES
C *** SAFER BUT WORSE IN PERFORMANCE...
C T1 = DST / DV2NRM(P, W)
C ALPHAK = ALPHAK + T1 * (PHI/RAD) * T1
T1 = DV2NRM(P, W)
ALPHAK = ALPHAK + (PHI/T1) * (DST/T1) * (DST/RAD)
LK = DMAX1(LK, ALPHAK)
ALPHAK = LK
GO TO 210
C
C *** ACCEPTABLE STEP ON FIRST TRY ***
C
260 ALPHAK = ZERO
C
C *** SUCCESSFUL STEP IN GENERAL. COMPUTE STEP = -(D**-1)*Q ***
C
270 DO 280 I = 1, P
J = Q0 + I
STEP(I) = -W(J)/D(I)
280 CONTINUE
V(GTSTEP) = -GTSTA
V(PREDUC) = HALF * (DABS(ALPHAK)*DST*DST + GTSTA)
GO TO 410
C
C
C *** RESTART WITH NEW RADIUS ***
C
290 IF (V(DST0) .LE. ZERO .OR. V(DST0) - RAD .GT. PHIMAX) GO TO 310
C
C *** PREPARE TO RETURN NEWTON STEP ***
C
RESTRT = .TRUE.
KA = KA + 1
K = 0
DO 300 I = 1, P
K = K + I
J = DIAG0 + I
DIHDI(K) = W(J)
300 CONTINUE
UK = NEGONE
GO TO 30
C
310 KAMIN = KA + 3
IF (V(DGNORM) .EQ. ZERO) KAMIN = 0
IF (KA .EQ. 0) GO TO 50
C
DST = W(DSTSAV)
ALPHAK = DABS(V(STPPAR))
PHI = DST - RAD
T = V(DGNORM)/RAD
UK = T - W(EMIN)
IF (V(DGNORM) .EQ. ZERO) UK = UK + P001 + P001*UK
IF (UK .LE. ZERO) UK = P001
IF (RAD .GT. V(RAD0)) GO TO 320
C
C *** SMALLER RADIUS ***
LK = ZERO
IF (ALPHAK .GT. ZERO) LK = W(LK0)
LK = DMAX1(LK, T - W(EMAX))
IF (V(DST0) .GT. ZERO) LK = DMAX1(LK, (V(DST0)-RAD)*W(PHIPIN))
GO TO 250
C
C *** BIGGER RADIUS ***
320 IF (ALPHAK .GT. ZERO) UK = DMIN1(UK, W(UK0))
LK = DMAX1(ZERO, -V(DST0), T - W(EMAX))
IF (V(DST0) .GT. ZERO) LK = DMAX1(LK, (V(DST0)-RAD)*W(PHIPIN))
GO TO 250
C
C *** DECIDE WHETHER TO CHECK FOR SPECIAL CASE... IN PRACTICE (FROM
C *** THE STANDPOINT OF THE CALLING OPTIMIZATION CODE) IT SEEMS BEST
C *** NOT TO CHECK UNTIL A FEW ITERATIONS HAVE FAILED -- HENCE THE
C *** TEST ON KAMIN BELOW.
C
330 DELTA = ALPHAK + DMIN1(ZERO, V(DST0))
TWOPSI = ALPHAK*DST*DST + GTSTA
IF (KA .GE. KAMIN) GO TO 340
C *** IF THE TEST IN REF. 2 IS SATISFIED, FALL THROUGH TO HANDLE
C *** THE SPECIAL CASE (AS SOON AS THE MORE-SORENSEN TEST DETECTS
C *** IT).
IF (PSIFAC .GE. BIG) GO TO 340
IF (DELTA .GE. PSIFAC*TWOPSI) GO TO 370
C
C *** CHECK FOR THE SPECIAL CASE OF H + ALPHA*D**2 (NEARLY)
C *** SINGULAR. USE ONE STEP OF INVERSE POWER METHOD WITH START
C *** FROM DL7SVN TO OBTAIN APPROXIMATE EIGENVECTOR CORRESPONDING
C *** TO SMALLEST EIGENVALUE OF (D**-1)*H*(D**-1). DL7SVN RETURNS
C *** X AND W WITH L*W = X.
C
340 T = DL7SVN(P, L, W(X), W)
C
C *** NORMALIZE W ***
DO 350 I = 1, P
350 W(I) = T*W(I)
C *** COMPLETE CURRENT INV. POWER ITER. -- REPLACE W BY (L**-T)*W.
CALL DL7ITV(P, W, L, W)
T2 = ONE/DV2NRM(P, W)
DO 360 I = 1, P
360 W(I) = T2*W(I)
T = T2 * T
C
C *** NOW W IS THE DESIRED APPROXIMATE (UNIT) EIGENVECTOR AND
C *** T*X = ((D**-1)*H*(D**-1) + ALPHAK*I)*W.
C
SW = DD7TPR(P, W(Q), W)
T1 = (RAD + DST) * (RAD - DST)
ROOT = DSQRT(SW*SW + T1)
IF (SW .LT. ZERO) ROOT = -ROOT
SI = T1 / (SW + ROOT)
C
C *** THE ACTUAL TEST FOR THE SPECIAL CASE...
C
IF ((T2*SI)**2 .LE. EPS*(DST**2 + ALPHAK*RADSQ)) GO TO 380
C
C *** UPDATE UPPER BOUND ON SMALLEST EIGENVALUE (WHEN NOT POSITIVE)
C *** (AS RECOMMENDED BY MORE AND SORENSEN) AND CONTINUE...
C
IF (V(DST0) .LE. ZERO) V(DST0) = DMIN1(V(DST0), T2**2 - ALPHAK)
LK = DMAX1(LK, -V(DST0))
C
C *** CHECK WHETHER WE CAN HOPE TO DETECT THE SPECIAL CASE IN
C *** THE AVAILABLE ARITHMETIC. ACCEPT STEP AS IT IS IF NOT.
C
C *** IF NOT YET AVAILABLE, OBTAIN MACHINE DEPENDENT VALUE DGXFAC.
370 IF (DGXFAC .EQ. ZERO) DGXFAC = EPSFAC * DR7MDC(3)
C
IF (DELTA .GT. DGXFAC*W(DGGDMX)) GO TO 250
GO TO 270
C
C *** SPECIAL CASE DETECTED... NEGATE ALPHAK TO INDICATE SPECIAL CASE
C
380 ALPHAK = -ALPHAK
V(PREDUC) = HALF * TWOPSI
C
C *** ACCEPT CURRENT STEP IF ADDING SI*W WOULD LEAD TO A
C *** FURTHER RELATIVE REDUCTION IN PSI OF LESS THAN V(EPSLON)/3.
C
T1 = ZERO
T = SI*(ALPHAK*SW - HALF*SI*(ALPHAK + T*DD7TPR(P,W(X),W)))
IF (T .LT. EPS*TWOPSI/SIX) GO TO 390
V(PREDUC) = V(PREDUC) + T
DST = RAD
T1 = -SI
390 DO 400 I = 1, P
J = Q0 + I
W(J) = T1*W(I) - W(J)
STEP(I) = W(J) / D(I)
400 CONTINUE
V(GTSTEP) = DD7TPR(P, DIG, W(Q))
C
C *** SAVE VALUES FOR USE IN A POSSIBLE RESTART ***
C
410 V(DSTNRM) = DST
V(STPPAR) = ALPHAK
W(LK0) = LK
W(UK0) = UK
V(RAD0) = RAD
W(DSTSAV) = DST
C
C *** RESTORE DIAGONAL OF DIHDI ***
C
J = 0
DO 420 I = 1, P
J = J + I
K = DIAG0 + I
DIHDI(J) = W(K)
420 CONTINUE
C
999 RETURN
C
C *** LAST CARD OF DG7QTS FOLLOWS ***
END
| apache-2.0 |
lendle/KernSmooth.jl | deps/rlbin.f | 3 | 1471 | c Part of R package KernSmooth
c Copyright (C) 1995 M. P. Wand
c
c Unlimited use and distribution (see LICENCE).
cccccccccc FORTRAN subroutine rlbin.f cccccccccc
c Obtains bin counts for univariate regression data
c via the linear binning strategy. If "trun=0" then
c weight from end observations is given to corresponding
c end grid points. If "trun=1" then end observations
c are truncated.
c Last changed: 26 MAR 2009
subroutine rlbin(X,Y,n,a,b,M,trun,xcnts,ycnts)
double precision X(*),Y(*),a,b,xcnts(*),ycnts(*),lxi,delta,rem
integer n,M,i,li,trun
c Initialize grid counts to zero
do 10 i=1,M
xcnts(i) = dble(0)
ycnts(i) = dble(0)
10 continue
delta = (b-a)/(M-1)
do 20 i=1,n
lxi = ((X(i)-a)/delta) + 1
c Find integer part of "lxi"
li = int(lxi)
rem = lxi - li
if (li.ge.1.and.li.lt.M) then
xcnts(li) = xcnts(li) + (1-rem)
xcnts(li+1) = xcnts(li+1) + rem
ycnts(li) = ycnts(li) + (1-rem)*y(i)
ycnts(li+1) = ycnts(li+1) + rem*y(i)
endif
if (li.lt.1.and.trun.eq.0) then
xcnts(1) = xcnts(1) + 1
ycnts(1) = ycnts(1) + y(i)
endif
if (li.ge.M.and.trun.eq.0) then
xcnts(M) = xcnts(M) + 1
ycnts(M) = ycnts(M) + y(i)
endif
20 continue
return
end
cccccccccc End of rlbin.f cccccccccc
| mit |
embecosm/avr32-gcc | gcc/testsuite/gfortran.dg/transfer_simplify_2.f90 | 8 | 5134 | ! { dg-do run }
! { dg-options "-O2" }
! { dg-options "-O2 -mieee" { target alpha*-*-* } }
! Tests the fix for the meta-bug PR31237 (TRANSFER intrinsic)
! Exercises gfc_simplify_transfer a random walk through types and shapes
! and compares its results with the middle-end version that operates on
! variables.
!
implicit none
call integer4_to_real4
call real4_to_integer8
call integer4_to_integer8
call logical4_to_real8
call real8_to_integer4
call integer8_to_real4
call integer8_to_complex4
call character16_to_complex8
call character16_to_real8
call real8_to_character2
call dt_to_integer1
call character16_to_dt
contains
subroutine integer4_to_real4
integer(4), parameter :: i1 = 11111_4
integer(4) :: i2 = i1
real(4), parameter :: r1 = transfer (i1, 1.0_4)
real(4) :: r2
r2 = transfer (i2, r2);
if (r1 .ne. r2) call abort ()
end subroutine integer4_to_real4
subroutine real4_to_integer8
real(4), parameter :: r1(2) = (/3.14159_4, 0.0_4/)
real(4) :: r2(2) = r1
integer(8), parameter :: i1 = transfer (r1, 1_8)
integer(8) :: i2
i2 = transfer (r2, 1_8);
if (i1 .ne. i2) call abort ()
end subroutine real4_to_integer8
subroutine integer4_to_integer8
integer(4), parameter :: i1(2) = (/11111_4, 22222_4/)
integer(4) :: i2(2) = i1
integer(8), parameter :: i3 = transfer (i1, 1_8)
integer(8) :: i4
i4 = transfer (i2, 1_8);
if (i3 .ne. i4) call abort ()
end subroutine integer4_to_integer8
subroutine logical4_to_real8
logical(4), parameter :: l1(2) = (/.false., .true./)
logical(4) :: l2(2) = l1
real(8), parameter :: r1 = transfer (l1, 1_8)
real(8) :: r2
r2 = transfer (l2, 1_8);
if (r1 .ne. r2) call abort ()
end subroutine logical4_to_real8
subroutine real8_to_integer4
real(8), parameter :: r1 = 3.14159_8
real(8) :: r2 = r1
integer(4), parameter :: i1(2) = transfer (r1, 1_4, 2)
integer(4) :: i2(2)
i2 = transfer (r2, i2, 2);
if (any (i1 .ne. i2)) call abort ()
end subroutine real8_to_integer4
subroutine integer8_to_real4
integer :: k
integer(8), parameter :: i1(2) = transfer ((/asin (1.0_8), log (1.0_8)/), 0_8)
integer(8) :: i2(2) = i1
real(4), parameter :: r1(4) = transfer (i1, (/(1.0_4,k=1,4)/))
real(4) :: r2(4)
r2 = transfer (i2, r2);
if (any (r1 .ne. r2)) call abort ()
end subroutine integer8_to_real4
subroutine integer8_to_complex4
integer :: k
integer(8), parameter :: i1(2) = transfer ((/asin (1.0_8), log (1.0_8)/), 0_8)
integer(8) :: i2(2) = i1
complex(4), parameter :: z1(2) = transfer (i1, (/((1.0_4,2.0_4),k=1,2)/))
complex(4) :: z2(2)
z2 = transfer (i2, z2);
if (any (z1 .ne. z2)) call abort ()
end subroutine integer8_to_complex4
subroutine character16_to_complex8
character(16), parameter :: c1(2) = (/"abcdefghijklmnop","qrstuvwxyz123456"/)
character(16) :: c2(2) = c1
complex(8), parameter :: z1(2) = transfer (c1, (1.0_8,1.0_8), 2)
complex(8) :: z2(2)
z2 = transfer (c2, z2, 2);
if (any (z1 .ne. z2)) call abort ()
end subroutine character16_to_complex8
subroutine character16_to_real8
character(16), parameter :: c1 = "abcdefghijklmnop"
character(16) :: c2 = c1
real(8), parameter :: r1(2) = transfer (c1, 1.0_8, 2)
real(8) :: r2(2)
r2 = transfer (c2, r2, 2);
if (any (r1 .ne. r2)) call abort ()
end subroutine character16_to_real8
subroutine real8_to_character2
real(8), parameter :: r1 = 3.14159_8
real(8) :: r2 = r1
character(2), parameter :: c1(4) = transfer (r1, "ab", 4)
character(2) :: c2(4)
c2 = transfer (r2, "ab", 4);
if (any (c1 .ne. c2)) call abort ()
end subroutine real8_to_character2
subroutine dt_to_integer1
integer, parameter :: i1(4) = (/1_4,2_4,3_4,4_4/)
real, parameter :: r1(4) = (/1.0_4,2.0_4,3.0_4,4.0_4/)
type :: mytype
integer(4) :: i(4)
real(4) :: x(4)
end type mytype
type (mytype), parameter :: dt1 = mytype (i1, r1)
type (mytype) :: dt2 = dt1
integer(1), parameter :: i2(32) = transfer (dt1, 1_1, 32)
integer(1) :: i3(32)
i3 = transfer (dt2, 1_1, 32);
if (any (i2 .ne. i3)) call abort ()
end subroutine dt_to_integer1
subroutine character16_to_dt
character(16), parameter :: c1 = "abcdefghijklmnop"
character(16) :: c2 = c1
type :: mytype
real(4) :: x(2)
end type mytype
type (mytype), parameter :: dt1(2) = transfer (c1, mytype ((/1.0,2.0,3.0,4.0/)), 2)
type (mytype) :: dt2(2)
dt2 = transfer (c2, dt2);
if (any (dt1(1)%x .ne. dt2(1)%x)) call abort ()
if (any (dt1(2)%x .ne. dt2(2)%x)) call abort ()
end subroutine character16_to_dt
end
| gpl-2.0 |
embecosm/avr32-gcc | gcc/testsuite/gfortran.dg/boz_1.f90 | 174 | 1156 | ! { dg-do run }
! { dg-options "-std=gnu" }
! Test the boz handling
program boz
implicit none
integer(1), parameter :: b1 = b'00000001'
integer(2), parameter :: b2 = b'0101010110101010'
integer(4), parameter :: b4 = b'01110000111100001111000011110000'
integer(8), parameter :: &
& b8 = b'0111000011110000111100001111000011110000111100001111000011110000'
integer(1), parameter :: o1 = o'12'
integer(2), parameter :: o2 = o'4321'
integer(4), parameter :: o4 = o'43210765'
integer(8), parameter :: o8 = o'1234567076543210'
integer(1), parameter :: z1 = z'a'
integer(2), parameter :: z2 = z'ab'
integer(4), parameter :: z4 = z'dead'
integer(8), parameter :: z8 = z'deadbeef'
if (z1 /= 10_1) call abort
if (z2 /= 171_2) call abort
if (z4 /= 57005_4) call abort
if (z8 /= 3735928559_8) call abort
if (b1 /= 1_1) call abort
if (b2 /= 21930_2) call abort
if (b4 /= 1894838512_4) call abort
if (b8 /= 8138269444283625712_8) call abort
if (o1 /= 10_1) call abort
if (o2 /= 2257_2) call abort
if (o4 /= 9245173_4) call abort
if (o8 /= 45954958542472_8) call abort
end program boz
| gpl-2.0 |
lapesd/libgomp | src/libgomp/testsuite/libgomp.fortran/simd2.f90 | 103 | 2682 | ! { dg-do run }
! { dg-additional-options "-msse2" { target sse2_runtime } }
! { dg-additional-options "-mavx" { target avx_runtime } }
integer :: a(1024), b(1024), k, m, i, s, t
k = 4
m = 2
t = 1
do i = 1, 1024
a(i) = i - 513
b(i) = modulo (i - 52, 39)
if (i.lt.52.and.b(i).ne.0) b(i) = b(i) - 39
end do
s = foo (b)
do i = 1, 1024
if (a(i).ne.((i - 513) * b(i))) call abort
if (i.lt.52.and.modulo (i - 52, 39).ne.0) then
if (b(i).ne.(modulo (i - 52, 39) - 39)) call abort
else
if (b(i).ne.(modulo (i - 52, 39))) call abort
end if
a(i) = i - 513
end do
if (k.ne.(4 + 3 * 1024).or.s.ne.1596127) call abort
k = 4
m = 2
t = 1
s = bar (b)
do i = 1, 1024
if (a(i).ne.((i - 513) * b(i))) call abort
if (i.lt.52.and.modulo (i - 52, 39).ne.0) then
if (b(i).ne.(modulo (i - 52, 39) - 39)) call abort
else
if (b(i).ne.(modulo (i - 52, 39))) call abort
end if
a(i) = i - 513
end do
if (k.ne.(4 + 3 * 1024).or.s.ne.1596127) call abort
k = 4
m = 2
t = 1
s = baz (b)
do i = 1, 1024
if (a(i).ne.((i - 513) * b(i))) call abort
if (i.lt.52.and.modulo (i - 52, 39).ne.0) then
if (b(i).ne.(modulo (i - 52, 39) - 39)) call abort
else
if (b(i).ne.(modulo (i - 52, 39))) call abort
end if
end do
if (k.ne.(4 + 3 * 1024).or.s.ne.1596127) call abort
contains
function foo (p)
integer :: p(1024), u, v, i, s, foo
s = 0
!$omp simd linear(k : m + 1) reduction(+: s) lastprivate(u, v)
do i = 1, 1024
a(i) = a(i) * p(i)
u = p(i) + k
k = k + m + 1
v = p(i) + k
s = s + p(i) + k
end do
!$omp end simd
if (i.ne.1025) call abort
if (u.ne.(36 + 4 + 3 * 1023).or.v.ne.(36 + 4 + 3 * 1024)) call abort
foo = s
end function foo
function bar (p)
integer :: p(1024), u, v, i, s, bar
s = 0
!$omp simd linear(k : m + 1) reduction(+: s) lastprivate(u, v)
do i = 1, 1024, t
a(i) = a(i) * p(i)
u = p(i) + k
k = k + m + 1
v = p(i) + k
s = s + p(i) + k
end do
!$omp end simd
if (i.ne.1025) call abort
if (u.ne.(36 + 4 + 3 * 1023).or.v.ne.(36 + 4 + 3 * 1024)) call abort
bar = s
end function bar
function baz (p)
integer :: p(1024), u, v, i, s, baz
s = 0
!$omp simd linear(k : m + 1) reduction(+: s) lastprivate(u, v) &
!$omp & linear(i : t)
do i = 1, 1024, t
a(i) = a(i) * p(i)
u = p(i) + k
k = k + m + 1
v = p(i) + k
s = s + p(i) + k
end do
if (i.ne.1025) call abort
if (u.ne.(36 + 4 + 3 * 1023).or.v.ne.(36 + 4 + 3 * 1024)) call abort
baz = s
end function baz
end
| gpl-3.0 |
embecosm/avr32-gcc | gcc/testsuite/gfortran.dg/interface_24.f90 | 38 | 1241 | ! { dg-do compile }
!
! This tests the fix for PR36361: If a function was declared in an INTERFACE
! statement, no attributes may be declared outside of the INTERFACE body.
!
! Contributed by Janus Weil <janus@gcc.gnu.org>
module m1
interface
real function f1()
end function
end interface
dimension :: f1(4) ! { dg-error "outside its INTERFACE body" }
end module
module m2
dimension :: f2(4)
interface
real function f2() ! { dg-error "outside its INTERFACE body" }
!end function
end interface
end module
! valid
module m3
interface
real function f3()
dimension :: f3(4)
end function
end interface
end module
module m4
interface
function f4() ! { dg-error "cannot have a deferred shape" }
real :: f4(:)
end function
end interface
allocatable :: f4 ! { dg-error "outside of INTERFACE body" }
end module
module m5
allocatable :: f5(:)
interface
function f5() ! { dg-error "outside its INTERFACE body" }
!real f5(:)
!end function
end interface
end module
!valid
module m6
interface
function f6()
real f6(:)
allocatable :: f6
end function
end interface
end module
! { dg-final { cleanup-modules "m1 m2 m3 m4 m5 m6" } }
| gpl-2.0 |
jag1g13/lammps | lib/linalg/dtrsv.f | 72 | 10138 | *> \brief \b DTRSV
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE DTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
*
* .. Scalar Arguments ..
* INTEGER INCX,LDA,N
* CHARACTER DIAG,TRANS,UPLO
* ..
* .. Array Arguments ..
* DOUBLE PRECISION A(LDA,*),X(*)
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DTRSV solves one of the systems of equations
*>
*> A*x = b, or A**T*x = b,
*>
*> where b and x are n element vectors and A is an n by n unit, or
*> non-unit, upper or lower triangular matrix.
*>
*> No test for singularity or near-singularity is included in this
*> routine. Such tests must be performed before calling this routine.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] UPLO
*> \verbatim
*> UPLO is 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.
*> \endverbatim
*>
*> \param[in] TRANS
*> \verbatim
*> TRANS is CHARACTER*1
*> On entry, TRANS specifies the equations to be solved as
*> follows:
*>
*> TRANS = 'N' or 'n' A*x = b.
*>
*> TRANS = 'T' or 't' A**T*x = b.
*>
*> TRANS = 'C' or 'c' A**T*x = b.
*> \endverbatim
*>
*> \param[in] DIAG
*> \verbatim
*> DIAG is 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.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> On entry, N specifies the order of the matrix A.
*> N must be at least zero.
*> \endverbatim
*>
*> \param[in] A
*> \verbatim
*> A is DOUBLE PRECISION 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.
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is 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 ).
*> \endverbatim
*>
*> \param[in,out] X
*> \verbatim
*> X is DOUBLE PRECISION array of dimension at least
*> ( 1 + ( n - 1 )*abs( INCX ) ).
*> Before entry, the incremented array X must contain the n
*> element right-hand side vector b. On exit, X is overwritten
*> with the solution vector x.
*> \endverbatim
*>
*> \param[in] INCX
*> \verbatim
*> INCX is INTEGER
*> On entry, INCX specifies the increment for the elements of
*> X. INCX must not be zero.
*>
*> Level 2 Blas routine.
*>
*> -- 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.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup double_blas_level1
*
* =====================================================================
SUBROUTINE DTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
*
* -- 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,LDA,N
CHARACTER DIAG,TRANS,UPLO
* ..
* .. Array Arguments ..
DOUBLE PRECISION A(LDA,*),X(*)
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO
PARAMETER (ZERO=0.0D+0)
* ..
* .. Local Scalars ..
DOUBLE PRECISION 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('DTRSV ',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 := inv( A )*x.
*
IF (LSAME(UPLO,'U')) THEN
IF (INCX.EQ.1) THEN
DO 20 J = N,1,-1
IF (X(J).NE.ZERO) THEN
IF (NOUNIT) X(J) = X(J)/A(J,J)
TEMP = X(J)
DO 10 I = J - 1,1,-1
X(I) = X(I) - TEMP*A(I,J)
10 CONTINUE
END IF
20 CONTINUE
ELSE
JX = KX + (N-1)*INCX
DO 40 J = N,1,-1
IF (X(JX).NE.ZERO) THEN
IF (NOUNIT) X(JX) = X(JX)/A(J,J)
TEMP = X(JX)
IX = JX
DO 30 I = J - 1,1,-1
IX = IX - INCX
X(IX) = X(IX) - TEMP*A(I,J)
30 CONTINUE
END IF
JX = JX - INCX
40 CONTINUE
END IF
ELSE
IF (INCX.EQ.1) THEN
DO 60 J = 1,N
IF (X(J).NE.ZERO) THEN
IF (NOUNIT) X(J) = X(J)/A(J,J)
TEMP = X(J)
DO 50 I = J + 1,N
X(I) = X(I) - TEMP*A(I,J)
50 CONTINUE
END IF
60 CONTINUE
ELSE
JX = KX
DO 80 J = 1,N
IF (X(JX).NE.ZERO) THEN
IF (NOUNIT) X(JX) = X(JX)/A(J,J)
TEMP = X(JX)
IX = JX
DO 70 I = J + 1,N
IX = IX + INCX
X(IX) = X(IX) - TEMP*A(I,J)
70 CONTINUE
END IF
JX = JX + INCX
80 CONTINUE
END IF
END IF
ELSE
*
* Form x := inv( A**T )*x.
*
IF (LSAME(UPLO,'U')) THEN
IF (INCX.EQ.1) THEN
DO 100 J = 1,N
TEMP = X(J)
DO 90 I = 1,J - 1
TEMP = TEMP - A(I,J)*X(I)
90 CONTINUE
IF (NOUNIT) TEMP = TEMP/A(J,J)
X(J) = TEMP
100 CONTINUE
ELSE
JX = KX
DO 120 J = 1,N
TEMP = X(JX)
IX = KX
DO 110 I = 1,J - 1
TEMP = TEMP - A(I,J)*X(IX)
IX = IX + INCX
110 CONTINUE
IF (NOUNIT) TEMP = TEMP/A(J,J)
X(JX) = TEMP
JX = JX + INCX
120 CONTINUE
END IF
ELSE
IF (INCX.EQ.1) THEN
DO 140 J = N,1,-1
TEMP = X(J)
DO 130 I = N,J + 1,-1
TEMP = TEMP - A(I,J)*X(I)
130 CONTINUE
IF (NOUNIT) TEMP = TEMP/A(J,J)
X(J) = TEMP
140 CONTINUE
ELSE
KX = KX + (N-1)*INCX
JX = KX
DO 160 J = N,1,-1
TEMP = X(JX)
IX = KX
DO 150 I = N,J + 1,-1
TEMP = TEMP - A(I,J)*X(IX)
IX = IX - INCX
150 CONTINUE
IF (NOUNIT) TEMP = TEMP/A(J,J)
X(JX) = TEMP
JX = JX - INCX
160 CONTINUE
END IF
END IF
END IF
*
RETURN
*
* End of DTRSV .
*
END
| gpl-2.0 |
SaberMod/GCC_SaberMod | libgfortran/generated/_asinh_r10.F90 | 35 | 1484 | ! Copyright (C) 2002-2014 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_ASINHL
elemental function _gfortran_specific__asinh_r10 (parm)
real (kind=10), intent (in) :: parm
real (kind=10) :: _gfortran_specific__asinh_r10
_gfortran_specific__asinh_r10 = asinh (parm)
end function
#endif
#endif
| gpl-2.0 |
luca-penasa/mtspec-python3 | mtspec/src/examples/src/fig4_5.f90 | 2 | 3502 | program fig4_5
!
! Simple code to generate Figure 4 and 5 of
! Prieto, G. A., R. L. Parker, and F. L. Vernon (2008)
! A Fortran 90 library formultitaper spectrum analysis
!
! Additional editing of the figure was performed for publication.
! An additional on-the-fly plotting library is used for the
! plotting of the data, available at
! pangea.stanford.edu/~gprieto/software.html
!
! Written by
! G. A. Prieto
! January 2nd, 2008
!
! Comments, questions, bugs?
! Please email gprieto@stanford.edu
!
! Calls: mt_transfer, gplot
! Modules: mvspectra.mod, plot.mod
!
!********************************************************************
use mvspectra
use plot
implicit none
integer, parameter :: npts=4458, nfft = 4*8916, nf = 4*8916/2+1
integer :: kspec, i, iadapt
real(4) :: tbnw, dt, junk
real(4), dimension(npts) :: ext1, int1, t
real(4), dimension(nf) :: freq, spec, cohe, wt
complex(4), dimension(nfft) :: trf
complex(4), dimension(nf-1) :: Qi
real(4), dimension(nf-1) :: per, lper
! Band averging
real(4), dimension(10) :: avper, crvar, civar
complex(4), dimension(10) :: c, cavg, travg
real(4) :: swt, l
complex(4) :: Q2c
integer :: fcnt, j, iloc1, iloc2
integer, dimension(1) :: i1, i2
!********************************************************************
dt = 3600.
kspec = 12
tbnw = 7.5
iadapt = 1 ! Adaptive multitaper
! Load the data, already resampled
open(12,file='../data/asc_akima.dat')
do i = 1,npts
read(12,*) junk, ext1(i), int1(i)
t(i) = real(i)*dt
enddo
close(12)
! Plot time series
call gplot(t/1.e6,int1,ylimit='5 -120 20')
call gplot(t/1.e6,ext1,ylimit='5 -120 20')
! Demean the two series (maybe not needed, result does not change)
int1 = int1 - sum(int1)/real(npts)
ext1 = ext1 - sum(ext1)/real(npts)
! Call transfer function subroutine
call mt_transfer (npts,nfft,dt,int1,ext1,tbnw,kspec,nf, &
freq=freq,cohe=cohe,trf=trf,iadapt=iadapt)
call gplot(freq*86400.,cohe) ! cycles per day
! Compute Qi
do i = 2,nf
if (cohe(i) >= 0.6) then
wt(i) = 1./sqrt(1. - cohe(i))
else
wt(i) = 0.
endif
Qi(i) = trf(i)
enddo
! Band averaging (same periods as Constable and Constable (2004)
per = 1./freq(2:nf)
lper = log10(per)
avper(1) = 21330.
avper(2) = 41410.
avper(3) = 74400.
avper(4) = 185100.
avper(5) = 348000.
avper(6) = 697800.
avper(7) = 1428000.
avper(8) = 2674000.
avper(9) = 4593000.
avper(10) = 11810000.
avper = log10(avper)
cavg = 0.
do i = 1,10
fcnt = count(lper<=avper(i)+0.1 .and. lper>=avper(i)-0.1)
if (fcnt > 1) then
i1 = minloc(lper, lper >= avper(i)-0.1)
i2 = maxloc(lper, lper <= avper(i)+0.1)
iloc2 = i1(1)
iloc1 = i2(1)
! Weighted mean
swt = 0.
do j = 0,fcnt-1
travg(i) = travg(i) + wt(iloc1+j)*Qi(iloc1+j)
swt = swt + wt(iloc1+j)
enddo
travg(i) = travg(i)/swt
elseif (fcnt == 1) then
travg(i) = Qi(iloc1)
endif
enddo
cavg = 6378. * (1. - 2.*travg) / (2.*(1.+travg))
call gplot(avper,real(cavg),'hold',xlimit='5 4. 7.5')
call gplot(avper,imag(cavg),xlimit='5 4. 7.5',ylimit='4 -750 1500')
end program fig4_5
| gpl-2.0 |
eligere/eligere | FAHPcore/eigen/blas/testing/zblat1.f | 245 | 31188 | PROGRAM ZBLAT1
* Test program for the COMPLEX*16 Level 1 BLAS.
* Based upon the original BLAS test routine together with:
* F06GAF Example Program Text
* .. Parameters ..
INTEGER NOUT
PARAMETER (NOUT=6)
* .. Scalars in Common ..
INTEGER ICASE, INCX, INCY, MODE, N
LOGICAL PASS
* .. Local Scalars ..
DOUBLE PRECISION SFAC
INTEGER IC
* .. External Subroutines ..
EXTERNAL CHECK1, CHECK2, HEADER
* .. Common blocks ..
COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS
* .. Data statements ..
DATA SFAC/9.765625D-4/
* .. Executable Statements ..
WRITE (NOUT,99999)
DO 20 IC = 1, 10
ICASE = IC
CALL HEADER
*
* Initialize PASS, INCX, INCY, and MODE for a new case.
* The value 9999 for INCX, INCY or MODE will appear in the
* detailed output, if any, for cases that do not involve
* these parameters.
*
PASS = .TRUE.
INCX = 9999
INCY = 9999
MODE = 9999
IF (ICASE.LE.5) THEN
CALL CHECK2(SFAC)
ELSE IF (ICASE.GE.6) THEN
CALL CHECK1(SFAC)
END IF
* -- Print
IF (PASS) WRITE (NOUT,99998)
20 CONTINUE
STOP
*
99999 FORMAT (' Complex BLAS Test Program Results',/1X)
99998 FORMAT (' ----- PASS -----')
END
SUBROUTINE HEADER
* .. Parameters ..
INTEGER NOUT
PARAMETER (NOUT=6)
* .. Scalars in Common ..
INTEGER ICASE, INCX, INCY, MODE, N
LOGICAL PASS
* .. Local Arrays ..
CHARACTER*6 L(10)
* .. Common blocks ..
COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS
* .. Data statements ..
DATA L(1)/'ZDOTC '/
DATA L(2)/'ZDOTU '/
DATA L(3)/'ZAXPY '/
DATA L(4)/'ZCOPY '/
DATA L(5)/'ZSWAP '/
DATA L(6)/'DZNRM2'/
DATA L(7)/'DZASUM'/
DATA L(8)/'ZSCAL '/
DATA L(9)/'ZDSCAL'/
DATA L(10)/'IZAMAX'/
* .. Executable Statements ..
WRITE (NOUT,99999) ICASE, L(ICASE)
RETURN
*
99999 FORMAT (/' Test of subprogram number',I3,12X,A6)
END
SUBROUTINE CHECK1(SFAC)
* .. Parameters ..
INTEGER NOUT
PARAMETER (NOUT=6)
* .. Scalar Arguments ..
DOUBLE PRECISION SFAC
* .. Scalars in Common ..
INTEGER ICASE, INCX, INCY, MODE, N
LOGICAL PASS
* .. Local Scalars ..
COMPLEX*16 CA
DOUBLE PRECISION SA
INTEGER I, J, LEN, NP1
* .. Local Arrays ..
COMPLEX*16 CTRUE5(8,5,2), CTRUE6(8,5,2), CV(8,5,2), CX(8),
+ MWPCS(5), MWPCT(5)
DOUBLE PRECISION STRUE2(5), STRUE4(5)
INTEGER ITRUE3(5)
* .. External Functions ..
DOUBLE PRECISION DZASUM, DZNRM2
INTEGER IZAMAX
EXTERNAL DZASUM, DZNRM2, IZAMAX
* .. External Subroutines ..
EXTERNAL ZSCAL, ZDSCAL, CTEST, ITEST1, STEST1
* .. Intrinsic Functions ..
INTRINSIC MAX
* .. Common blocks ..
COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS
* .. Data statements ..
DATA SA, CA/0.3D0, (0.4D0,-0.7D0)/
DATA ((CV(I,J,1),I=1,8),J=1,5)/(0.1D0,0.1D0),
+ (1.0D0,2.0D0), (1.0D0,2.0D0), (1.0D0,2.0D0),
+ (1.0D0,2.0D0), (1.0D0,2.0D0), (1.0D0,2.0D0),
+ (1.0D0,2.0D0), (0.3D0,-0.4D0), (3.0D0,4.0D0),
+ (3.0D0,4.0D0), (3.0D0,4.0D0), (3.0D0,4.0D0),
+ (3.0D0,4.0D0), (3.0D0,4.0D0), (3.0D0,4.0D0),
+ (0.1D0,-0.3D0), (0.5D0,-0.1D0), (5.0D0,6.0D0),
+ (5.0D0,6.0D0), (5.0D0,6.0D0), (5.0D0,6.0D0),
+ (5.0D0,6.0D0), (5.0D0,6.0D0), (0.1D0,0.1D0),
+ (-0.6D0,0.1D0), (0.1D0,-0.3D0), (7.0D0,8.0D0),
+ (7.0D0,8.0D0), (7.0D0,8.0D0), (7.0D0,8.0D0),
+ (7.0D0,8.0D0), (0.3D0,0.1D0), (0.1D0,0.4D0),
+ (0.4D0,0.1D0), (0.1D0,0.2D0), (2.0D0,3.0D0),
+ (2.0D0,3.0D0), (2.0D0,3.0D0), (2.0D0,3.0D0)/
DATA ((CV(I,J,2),I=1,8),J=1,5)/(0.1D0,0.1D0),
+ (4.0D0,5.0D0), (4.0D0,5.0D0), (4.0D0,5.0D0),
+ (4.0D0,5.0D0), (4.0D0,5.0D0), (4.0D0,5.0D0),
+ (4.0D0,5.0D0), (0.3D0,-0.4D0), (6.0D0,7.0D0),
+ (6.0D0,7.0D0), (6.0D0,7.0D0), (6.0D0,7.0D0),
+ (6.0D0,7.0D0), (6.0D0,7.0D0), (6.0D0,7.0D0),
+ (0.1D0,-0.3D0), (8.0D0,9.0D0), (0.5D0,-0.1D0),
+ (2.0D0,5.0D0), (2.0D0,5.0D0), (2.0D0,5.0D0),
+ (2.0D0,5.0D0), (2.0D0,5.0D0), (0.1D0,0.1D0),
+ (3.0D0,6.0D0), (-0.6D0,0.1D0), (4.0D0,7.0D0),
+ (0.1D0,-0.3D0), (7.0D0,2.0D0), (7.0D0,2.0D0),
+ (7.0D0,2.0D0), (0.3D0,0.1D0), (5.0D0,8.0D0),
+ (0.1D0,0.4D0), (6.0D0,9.0D0), (0.4D0,0.1D0),
+ (8.0D0,3.0D0), (0.1D0,0.2D0), (9.0D0,4.0D0)/
DATA STRUE2/0.0D0, 0.5D0, 0.6D0, 0.7D0, 0.7D0/
DATA STRUE4/0.0D0, 0.7D0, 1.0D0, 1.3D0, 1.7D0/
DATA ((CTRUE5(I,J,1),I=1,8),J=1,5)/(0.1D0,0.1D0),
+ (1.0D0,2.0D0), (1.0D0,2.0D0), (1.0D0,2.0D0),
+ (1.0D0,2.0D0), (1.0D0,2.0D0), (1.0D0,2.0D0),
+ (1.0D0,2.0D0), (-0.16D0,-0.37D0), (3.0D0,4.0D0),
+ (3.0D0,4.0D0), (3.0D0,4.0D0), (3.0D0,4.0D0),
+ (3.0D0,4.0D0), (3.0D0,4.0D0), (3.0D0,4.0D0),
+ (-0.17D0,-0.19D0), (0.13D0,-0.39D0),
+ (5.0D0,6.0D0), (5.0D0,6.0D0), (5.0D0,6.0D0),
+ (5.0D0,6.0D0), (5.0D0,6.0D0), (5.0D0,6.0D0),
+ (0.11D0,-0.03D0), (-0.17D0,0.46D0),
+ (-0.17D0,-0.19D0), (7.0D0,8.0D0), (7.0D0,8.0D0),
+ (7.0D0,8.0D0), (7.0D0,8.0D0), (7.0D0,8.0D0),
+ (0.19D0,-0.17D0), (0.32D0,0.09D0),
+ (0.23D0,-0.24D0), (0.18D0,0.01D0),
+ (2.0D0,3.0D0), (2.0D0,3.0D0), (2.0D0,3.0D0),
+ (2.0D0,3.0D0)/
DATA ((CTRUE5(I,J,2),I=1,8),J=1,5)/(0.1D0,0.1D0),
+ (4.0D0,5.0D0), (4.0D0,5.0D0), (4.0D0,5.0D0),
+ (4.0D0,5.0D0), (4.0D0,5.0D0), (4.0D0,5.0D0),
+ (4.0D0,5.0D0), (-0.16D0,-0.37D0), (6.0D0,7.0D0),
+ (6.0D0,7.0D0), (6.0D0,7.0D0), (6.0D0,7.0D0),
+ (6.0D0,7.0D0), (6.0D0,7.0D0), (6.0D0,7.0D0),
+ (-0.17D0,-0.19D0), (8.0D0,9.0D0),
+ (0.13D0,-0.39D0), (2.0D0,5.0D0), (2.0D0,5.0D0),
+ (2.0D0,5.0D0), (2.0D0,5.0D0), (2.0D0,5.0D0),
+ (0.11D0,-0.03D0), (3.0D0,6.0D0),
+ (-0.17D0,0.46D0), (4.0D0,7.0D0),
+ (-0.17D0,-0.19D0), (7.0D0,2.0D0), (7.0D0,2.0D0),
+ (7.0D0,2.0D0), (0.19D0,-0.17D0), (5.0D0,8.0D0),
+ (0.32D0,0.09D0), (6.0D0,9.0D0),
+ (0.23D0,-0.24D0), (8.0D0,3.0D0),
+ (0.18D0,0.01D0), (9.0D0,4.0D0)/
DATA ((CTRUE6(I,J,1),I=1,8),J=1,5)/(0.1D0,0.1D0),
+ (1.0D0,2.0D0), (1.0D0,2.0D0), (1.0D0,2.0D0),
+ (1.0D0,2.0D0), (1.0D0,2.0D0), (1.0D0,2.0D0),
+ (1.0D0,2.0D0), (0.09D0,-0.12D0), (3.0D0,4.0D0),
+ (3.0D0,4.0D0), (3.0D0,4.0D0), (3.0D0,4.0D0),
+ (3.0D0,4.0D0), (3.0D0,4.0D0), (3.0D0,4.0D0),
+ (0.03D0,-0.09D0), (0.15D0,-0.03D0),
+ (5.0D0,6.0D0), (5.0D0,6.0D0), (5.0D0,6.0D0),
+ (5.0D0,6.0D0), (5.0D0,6.0D0), (5.0D0,6.0D0),
+ (0.03D0,0.03D0), (-0.18D0,0.03D0),
+ (0.03D0,-0.09D0), (7.0D0,8.0D0), (7.0D0,8.0D0),
+ (7.0D0,8.0D0), (7.0D0,8.0D0), (7.0D0,8.0D0),
+ (0.09D0,0.03D0), (0.03D0,0.12D0),
+ (0.12D0,0.03D0), (0.03D0,0.06D0), (2.0D0,3.0D0),
+ (2.0D0,3.0D0), (2.0D0,3.0D0), (2.0D0,3.0D0)/
DATA ((CTRUE6(I,J,2),I=1,8),J=1,5)/(0.1D0,0.1D0),
+ (4.0D0,5.0D0), (4.0D0,5.0D0), (4.0D0,5.0D0),
+ (4.0D0,5.0D0), (4.0D0,5.0D0), (4.0D0,5.0D0),
+ (4.0D0,5.0D0), (0.09D0,-0.12D0), (6.0D0,7.0D0),
+ (6.0D0,7.0D0), (6.0D0,7.0D0), (6.0D0,7.0D0),
+ (6.0D0,7.0D0), (6.0D0,7.0D0), (6.0D0,7.0D0),
+ (0.03D0,-0.09D0), (8.0D0,9.0D0),
+ (0.15D0,-0.03D0), (2.0D0,5.0D0), (2.0D0,5.0D0),
+ (2.0D0,5.0D0), (2.0D0,5.0D0), (2.0D0,5.0D0),
+ (0.03D0,0.03D0), (3.0D0,6.0D0),
+ (-0.18D0,0.03D0), (4.0D0,7.0D0),
+ (0.03D0,-0.09D0), (7.0D0,2.0D0), (7.0D0,2.0D0),
+ (7.0D0,2.0D0), (0.09D0,0.03D0), (5.0D0,8.0D0),
+ (0.03D0,0.12D0), (6.0D0,9.0D0), (0.12D0,0.03D0),
+ (8.0D0,3.0D0), (0.03D0,0.06D0), (9.0D0,4.0D0)/
DATA ITRUE3/0, 1, 2, 2, 2/
* .. Executable Statements ..
DO 60 INCX = 1, 2
DO 40 NP1 = 1, 5
N = NP1 - 1
LEN = 2*MAX(N,1)
* .. Set vector arguments ..
DO 20 I = 1, LEN
CX(I) = CV(I,NP1,INCX)
20 CONTINUE
IF (ICASE.EQ.6) THEN
* .. DZNRM2 ..
CALL STEST1(DZNRM2(N,CX,INCX),STRUE2(NP1),STRUE2(NP1),
+ SFAC)
ELSE IF (ICASE.EQ.7) THEN
* .. DZASUM ..
CALL STEST1(DZASUM(N,CX,INCX),STRUE4(NP1),STRUE4(NP1),
+ SFAC)
ELSE IF (ICASE.EQ.8) THEN
* .. ZSCAL ..
CALL ZSCAL(N,CA,CX,INCX)
CALL CTEST(LEN,CX,CTRUE5(1,NP1,INCX),CTRUE5(1,NP1,INCX),
+ SFAC)
ELSE IF (ICASE.EQ.9) THEN
* .. ZDSCAL ..
CALL ZDSCAL(N,SA,CX,INCX)
CALL CTEST(LEN,CX,CTRUE6(1,NP1,INCX),CTRUE6(1,NP1,INCX),
+ SFAC)
ELSE IF (ICASE.EQ.10) THEN
* .. IZAMAX ..
CALL ITEST1(IZAMAX(N,CX,INCX),ITRUE3(NP1))
ELSE
WRITE (NOUT,*) ' Shouldn''t be here in CHECK1'
STOP
END IF
*
40 CONTINUE
60 CONTINUE
*
INCX = 1
IF (ICASE.EQ.8) THEN
* ZSCAL
* Add a test for alpha equal to zero.
CA = (0.0D0,0.0D0)
DO 80 I = 1, 5
MWPCT(I) = (0.0D0,0.0D0)
MWPCS(I) = (1.0D0,1.0D0)
80 CONTINUE
CALL ZSCAL(5,CA,CX,INCX)
CALL CTEST(5,CX,MWPCT,MWPCS,SFAC)
ELSE IF (ICASE.EQ.9) THEN
* ZDSCAL
* Add a test for alpha equal to zero.
SA = 0.0D0
DO 100 I = 1, 5
MWPCT(I) = (0.0D0,0.0D0)
MWPCS(I) = (1.0D0,1.0D0)
100 CONTINUE
CALL ZDSCAL(5,SA,CX,INCX)
CALL CTEST(5,CX,MWPCT,MWPCS,SFAC)
* Add a test for alpha equal to one.
SA = 1.0D0
DO 120 I = 1, 5
MWPCT(I) = CX(I)
MWPCS(I) = CX(I)
120 CONTINUE
CALL ZDSCAL(5,SA,CX,INCX)
CALL CTEST(5,CX,MWPCT,MWPCS,SFAC)
* Add a test for alpha equal to minus one.
SA = -1.0D0
DO 140 I = 1, 5
MWPCT(I) = -CX(I)
MWPCS(I) = -CX(I)
140 CONTINUE
CALL ZDSCAL(5,SA,CX,INCX)
CALL CTEST(5,CX,MWPCT,MWPCS,SFAC)
END IF
RETURN
END
SUBROUTINE CHECK2(SFAC)
* .. Parameters ..
INTEGER NOUT
PARAMETER (NOUT=6)
* .. Scalar Arguments ..
DOUBLE PRECISION SFAC
* .. Scalars in Common ..
INTEGER ICASE, INCX, INCY, MODE, N
LOGICAL PASS
* .. Local Scalars ..
COMPLEX*16 CA
INTEGER I, J, KI, KN, KSIZE, LENX, LENY, MX, MY
* .. Local Arrays ..
COMPLEX*16 CDOT(1), CSIZE1(4), CSIZE2(7,2), CSIZE3(14),
+ CT10X(7,4,4), CT10Y(7,4,4), CT6(4,4), CT7(4,4),
+ CT8(7,4,4), CX(7), CX1(7), CY(7), CY1(7)
INTEGER INCXS(4), INCYS(4), LENS(4,2), NS(4)
* .. External Functions ..
COMPLEX*16 ZDOTC, ZDOTU
EXTERNAL ZDOTC, ZDOTU
* .. External Subroutines ..
EXTERNAL ZAXPY, ZCOPY, ZSWAP, CTEST
* .. Intrinsic Functions ..
INTRINSIC ABS, MIN
* .. Common blocks ..
COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS
* .. Data statements ..
DATA CA/(0.4D0,-0.7D0)/
DATA INCXS/1, 2, -2, -1/
DATA INCYS/1, -2, 1, -2/
DATA LENS/1, 1, 2, 4, 1, 1, 3, 7/
DATA NS/0, 1, 2, 4/
DATA CX1/(0.7D0,-0.8D0), (-0.4D0,-0.7D0),
+ (-0.1D0,-0.9D0), (0.2D0,-0.8D0),
+ (-0.9D0,-0.4D0), (0.1D0,0.4D0), (-0.6D0,0.6D0)/
DATA CY1/(0.6D0,-0.6D0), (-0.9D0,0.5D0),
+ (0.7D0,-0.6D0), (0.1D0,-0.5D0), (-0.1D0,-0.2D0),
+ (-0.5D0,-0.3D0), (0.8D0,-0.7D0)/
DATA ((CT8(I,J,1),I=1,7),J=1,4)/(0.6D0,-0.6D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.32D0,-1.41D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.32D0,-1.41D0),
+ (-1.55D0,0.5D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.32D0,-1.41D0), (-1.55D0,0.5D0),
+ (0.03D0,-0.89D0), (-0.38D0,-0.96D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0)/
DATA ((CT8(I,J,2),I=1,7),J=1,4)/(0.6D0,-0.6D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.32D0,-1.41D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (-0.07D0,-0.89D0),
+ (-0.9D0,0.5D0), (0.42D0,-1.41D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.78D0,0.06D0), (-0.9D0,0.5D0),
+ (0.06D0,-0.13D0), (0.1D0,-0.5D0),
+ (-0.77D0,-0.49D0), (-0.5D0,-0.3D0),
+ (0.52D0,-1.51D0)/
DATA ((CT8(I,J,3),I=1,7),J=1,4)/(0.6D0,-0.6D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.32D0,-1.41D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (-0.07D0,-0.89D0),
+ (-1.18D0,-0.31D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.78D0,0.06D0), (-1.54D0,0.97D0),
+ (0.03D0,-0.89D0), (-0.18D0,-1.31D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0)/
DATA ((CT8(I,J,4),I=1,7),J=1,4)/(0.6D0,-0.6D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.32D0,-1.41D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.32D0,-1.41D0), (-0.9D0,0.5D0),
+ (0.05D0,-0.6D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.32D0,-1.41D0),
+ (-0.9D0,0.5D0), (0.05D0,-0.6D0), (0.1D0,-0.5D0),
+ (-0.77D0,-0.49D0), (-0.5D0,-0.3D0),
+ (0.32D0,-1.16D0)/
DATA CT7/(0.0D0,0.0D0), (-0.06D0,-0.90D0),
+ (0.65D0,-0.47D0), (-0.34D0,-1.22D0),
+ (0.0D0,0.0D0), (-0.06D0,-0.90D0),
+ (-0.59D0,-1.46D0), (-1.04D0,-0.04D0),
+ (0.0D0,0.0D0), (-0.06D0,-0.90D0),
+ (-0.83D0,0.59D0), (0.07D0,-0.37D0),
+ (0.0D0,0.0D0), (-0.06D0,-0.90D0),
+ (-0.76D0,-1.15D0), (-1.33D0,-1.82D0)/
DATA CT6/(0.0D0,0.0D0), (0.90D0,0.06D0),
+ (0.91D0,-0.77D0), (1.80D0,-0.10D0),
+ (0.0D0,0.0D0), (0.90D0,0.06D0), (1.45D0,0.74D0),
+ (0.20D0,0.90D0), (0.0D0,0.0D0), (0.90D0,0.06D0),
+ (-0.55D0,0.23D0), (0.83D0,-0.39D0),
+ (0.0D0,0.0D0), (0.90D0,0.06D0), (1.04D0,0.79D0),
+ (1.95D0,1.22D0)/
DATA ((CT10X(I,J,1),I=1,7),J=1,4)/(0.7D0,-0.8D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.6D0,-0.6D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.6D0,-0.6D0), (-0.9D0,0.5D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.6D0,-0.6D0),
+ (-0.9D0,0.5D0), (0.7D0,-0.6D0), (0.1D0,-0.5D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0)/
DATA ((CT10X(I,J,2),I=1,7),J=1,4)/(0.7D0,-0.8D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.6D0,-0.6D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.7D0,-0.6D0), (-0.4D0,-0.7D0),
+ (0.6D0,-0.6D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.8D0,-0.7D0),
+ (-0.4D0,-0.7D0), (-0.1D0,-0.2D0),
+ (0.2D0,-0.8D0), (0.7D0,-0.6D0), (0.1D0,0.4D0),
+ (0.6D0,-0.6D0)/
DATA ((CT10X(I,J,3),I=1,7),J=1,4)/(0.7D0,-0.8D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.6D0,-0.6D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (-0.9D0,0.5D0), (-0.4D0,-0.7D0),
+ (0.6D0,-0.6D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.1D0,-0.5D0),
+ (-0.4D0,-0.7D0), (0.7D0,-0.6D0), (0.2D0,-0.8D0),
+ (-0.9D0,0.5D0), (0.1D0,0.4D0), (0.6D0,-0.6D0)/
DATA ((CT10X(I,J,4),I=1,7),J=1,4)/(0.7D0,-0.8D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.6D0,-0.6D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.6D0,-0.6D0), (0.7D0,-0.6D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.6D0,-0.6D0),
+ (0.7D0,-0.6D0), (-0.1D0,-0.2D0), (0.8D0,-0.7D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0)/
DATA ((CT10Y(I,J,1),I=1,7),J=1,4)/(0.6D0,-0.6D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.7D0,-0.8D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.7D0,-0.8D0), (-0.4D0,-0.7D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.7D0,-0.8D0),
+ (-0.4D0,-0.7D0), (-0.1D0,-0.9D0),
+ (0.2D0,-0.8D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0)/
DATA ((CT10Y(I,J,2),I=1,7),J=1,4)/(0.6D0,-0.6D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.7D0,-0.8D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (-0.1D0,-0.9D0), (-0.9D0,0.5D0),
+ (0.7D0,-0.8D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (-0.6D0,0.6D0),
+ (-0.9D0,0.5D0), (-0.9D0,-0.4D0), (0.1D0,-0.5D0),
+ (-0.1D0,-0.9D0), (-0.5D0,-0.3D0),
+ (0.7D0,-0.8D0)/
DATA ((CT10Y(I,J,3),I=1,7),J=1,4)/(0.6D0,-0.6D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.7D0,-0.8D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (-0.1D0,-0.9D0), (0.7D0,-0.8D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (-0.6D0,0.6D0),
+ (-0.9D0,-0.4D0), (-0.1D0,-0.9D0),
+ (0.7D0,-0.8D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0)/
DATA ((CT10Y(I,J,4),I=1,7),J=1,4)/(0.6D0,-0.6D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.7D0,-0.8D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.7D0,-0.8D0), (-0.9D0,0.5D0),
+ (-0.4D0,-0.7D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.7D0,-0.8D0),
+ (-0.9D0,0.5D0), (-0.4D0,-0.7D0), (0.1D0,-0.5D0),
+ (-0.1D0,-0.9D0), (-0.5D0,-0.3D0),
+ (0.2D0,-0.8D0)/
DATA CSIZE1/(0.0D0,0.0D0), (0.9D0,0.9D0),
+ (1.63D0,1.73D0), (2.90D0,2.78D0)/
DATA CSIZE3/(0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (1.17D0,1.17D0),
+ (1.17D0,1.17D0), (1.17D0,1.17D0),
+ (1.17D0,1.17D0), (1.17D0,1.17D0),
+ (1.17D0,1.17D0), (1.17D0,1.17D0)/
DATA CSIZE2/(0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (0.0D0,0.0D0),
+ (0.0D0,0.0D0), (0.0D0,0.0D0), (1.54D0,1.54D0),
+ (1.54D0,1.54D0), (1.54D0,1.54D0),
+ (1.54D0,1.54D0), (1.54D0,1.54D0),
+ (1.54D0,1.54D0), (1.54D0,1.54D0)/
* .. Executable Statements ..
DO 60 KI = 1, 4
INCX = INCXS(KI)
INCY = INCYS(KI)
MX = ABS(INCX)
MY = ABS(INCY)
*
DO 40 KN = 1, 4
N = NS(KN)
KSIZE = MIN(2,KN)
LENX = LENS(KN,MX)
LENY = LENS(KN,MY)
* .. initialize all argument arrays ..
DO 20 I = 1, 7
CX(I) = CX1(I)
CY(I) = CY1(I)
20 CONTINUE
IF (ICASE.EQ.1) THEN
* .. ZDOTC ..
CDOT(1) = ZDOTC(N,CX,INCX,CY,INCY)
CALL CTEST(1,CDOT,CT6(KN,KI),CSIZE1(KN),SFAC)
ELSE IF (ICASE.EQ.2) THEN
* .. ZDOTU ..
CDOT(1) = ZDOTU(N,CX,INCX,CY,INCY)
CALL CTEST(1,CDOT,CT7(KN,KI),CSIZE1(KN),SFAC)
ELSE IF (ICASE.EQ.3) THEN
* .. ZAXPY ..
CALL ZAXPY(N,CA,CX,INCX,CY,INCY)
CALL CTEST(LENY,CY,CT8(1,KN,KI),CSIZE2(1,KSIZE),SFAC)
ELSE IF (ICASE.EQ.4) THEN
* .. ZCOPY ..
CALL ZCOPY(N,CX,INCX,CY,INCY)
CALL CTEST(LENY,CY,CT10Y(1,KN,KI),CSIZE3,1.0D0)
ELSE IF (ICASE.EQ.5) THEN
* .. ZSWAP ..
CALL ZSWAP(N,CX,INCX,CY,INCY)
CALL CTEST(LENX,CX,CT10X(1,KN,KI),CSIZE3,1.0D0)
CALL CTEST(LENY,CY,CT10Y(1,KN,KI),CSIZE3,1.0D0)
ELSE
WRITE (NOUT,*) ' Shouldn''t be here in CHECK2'
STOP
END IF
*
40 CONTINUE
60 CONTINUE
RETURN
END
SUBROUTINE STEST(LEN,SCOMP,STRUE,SSIZE,SFAC)
* ********************************* STEST **************************
*
* THIS SUBR COMPARES ARRAYS SCOMP() AND STRUE() OF LENGTH LEN TO
* SEE IF THE TERM BY TERM DIFFERENCES, MULTIPLIED BY SFAC, ARE
* NEGLIGIBLE.
*
* C. L. LAWSON, JPL, 1974 DEC 10
*
* .. Parameters ..
INTEGER NOUT
PARAMETER (NOUT=6)
* .. Scalar Arguments ..
DOUBLE PRECISION SFAC
INTEGER LEN
* .. Array Arguments ..
DOUBLE PRECISION SCOMP(LEN), SSIZE(LEN), STRUE(LEN)
* .. Scalars in Common ..
INTEGER ICASE, INCX, INCY, MODE, N
LOGICAL PASS
* .. Local Scalars ..
DOUBLE PRECISION SD
INTEGER I
* .. External Functions ..
DOUBLE PRECISION SDIFF
EXTERNAL SDIFF
* .. Intrinsic Functions ..
INTRINSIC ABS
* .. Common blocks ..
COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS
* .. Executable Statements ..
*
DO 40 I = 1, LEN
SD = SCOMP(I) - STRUE(I)
IF (SDIFF(ABS(SSIZE(I))+ABS(SFAC*SD),ABS(SSIZE(I))).EQ.0.0D0)
+ GO TO 40
*
* HERE SCOMP(I) IS NOT CLOSE TO STRUE(I).
*
IF ( .NOT. PASS) GO TO 20
* PRINT FAIL MESSAGE AND HEADER.
PASS = .FALSE.
WRITE (NOUT,99999)
WRITE (NOUT,99998)
20 WRITE (NOUT,99997) ICASE, N, INCX, INCY, MODE, I, SCOMP(I),
+ STRUE(I), SD, SSIZE(I)
40 CONTINUE
RETURN
*
99999 FORMAT (' FAIL')
99998 FORMAT (/' CASE N INCX INCY MODE I ',
+ ' COMP(I) TRUE(I) DIFFERENCE',
+ ' SIZE(I)',/1X)
99997 FORMAT (1X,I4,I3,3I5,I3,2D36.8,2D12.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 ..
DOUBLE PRECISION SCOMP1, SFAC, STRUE1
* .. Array Arguments ..
DOUBLE PRECISION SSIZE(*)
* .. Local Arrays ..
DOUBLE PRECISION 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
DOUBLE PRECISION FUNCTION SDIFF(SA,SB)
* ********************************* SDIFF **************************
* COMPUTES DIFFERENCE OF TWO NUMBERS. C. L. LAWSON, JPL 1974 FEB 15
*
* .. Scalar Arguments ..
DOUBLE PRECISION SA, SB
* .. Executable Statements ..
SDIFF = SA - SB
RETURN
END
SUBROUTINE CTEST(LEN,CCOMP,CTRUE,CSIZE,SFAC)
* **************************** CTEST *****************************
*
* C.L. LAWSON, JPL, 1978 DEC 6
*
* .. Scalar Arguments ..
DOUBLE PRECISION SFAC
INTEGER LEN
* .. Array Arguments ..
COMPLEX*16 CCOMP(LEN), CSIZE(LEN), CTRUE(LEN)
* .. Local Scalars ..
INTEGER I
* .. Local Arrays ..
DOUBLE PRECISION SCOMP(20), SSIZE(20), STRUE(20)
* .. External Subroutines ..
EXTERNAL STEST
* .. Intrinsic Functions ..
INTRINSIC DIMAG, DBLE
* .. Executable Statements ..
DO 20 I = 1, LEN
SCOMP(2*I-1) = DBLE(CCOMP(I))
SCOMP(2*I) = DIMAG(CCOMP(I))
STRUE(2*I-1) = DBLE(CTRUE(I))
STRUE(2*I) = DIMAG(CTRUE(I))
SSIZE(2*I-1) = DBLE(CSIZE(I))
SSIZE(2*I) = DIMAG(CSIZE(I))
20 CONTINUE
*
CALL STEST(2*LEN,SCOMP,STRUE,SSIZE,SFAC)
RETURN
END
SUBROUTINE ITEST1(ICOMP,ITRUE)
* ********************************* ITEST1 *************************
*
* THIS SUBROUTINE COMPARES THE VARIABLES ICOMP AND ITRUE FOR
* EQUALITY.
* C. L. LAWSON, JPL, 1974 DEC 10
*
* .. Parameters ..
INTEGER NOUT
PARAMETER (NOUT=6)
* .. Scalar Arguments ..
INTEGER ICOMP, ITRUE
* .. Scalars in Common ..
INTEGER ICASE, INCX, INCY, MODE, N
LOGICAL PASS
* .. Local Scalars ..
INTEGER ID
* .. Common blocks ..
COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS
* .. Executable Statements ..
IF (ICOMP.EQ.ITRUE) GO TO 40
*
* HERE ICOMP IS NOT EQUAL TO ITRUE.
*
IF ( .NOT. PASS) GO TO 20
* PRINT FAIL MESSAGE AND HEADER.
PASS = .FALSE.
WRITE (NOUT,99999)
WRITE (NOUT,99998)
20 ID = ICOMP - ITRUE
WRITE (NOUT,99997) ICASE, N, INCX, INCY, MODE, ICOMP, ITRUE, ID
40 CONTINUE
RETURN
*
99999 FORMAT (' FAIL')
99998 FORMAT (/' CASE N INCX INCY MODE ',
+ ' COMP TRUE DIFFERENCE',
+ /1X)
99997 FORMAT (1X,I4,I3,3I5,2I36,I12)
END
| gpl-3.0 |
SaberMod/GCC_SaberMod | gcc/testsuite/gfortran.dg/default_initialization_5.f90 | 63 | 1460 | ! { dg-do run }
! { dg-options "-fdump-tree-original" }
!
! PR fortran/51435
!
! Contributed by darmar.xxl@gmail.com
!
module arr_m
type arr_t
real(8), dimension(:), allocatable :: rsk
end type
type arr_t2
integer :: a = 77
end type
end module arr_m
!*********************
module list_m
use arr_m
implicit none
type(arr_t2), target :: tgt
type my_list
type(arr_t), pointer :: head => null()
end type my_list
type my_list2
type(arr_t2), pointer :: head => tgt
end type my_list2
end module list_m
!***********************
module worker_mod
use list_m
implicit none
type data_all_t
type(my_list) :: my_data
end type data_all_t
type data_all_t2
type(my_list2) :: my_data
end type data_all_t2
contains
subroutine do_job()
type(data_all_t) :: dum
type(data_all_t2) :: dum2
if (associated(dum%my_data%head)) then
call abort()
else
print *, 'OK: do_job my_data%head is NOT associated'
end if
if (dum2%my_data%head%a /= 77) &
call abort()
end subroutine
end module
!***************
program hello
use worker_mod
implicit none
call do_job()
end program
! { dg-final { scan-tree-dump-times "my_data.head = 0B" 1 "original" } }
! { dg-final { scan-tree-dump-times "my_data.head = &tgt" 1 "original" } }
! { dg-final { cleanup-tree-dump "original" } }
| gpl-2.0 |
pbosler/LPPM | AdvectGaussHillsDirect.f90 | 2 | 14227 | program GaussianHillsAdvectionDirect
use NumberKindsModule
use OutputWriterModule
use LoggerModule
use SphereMeshModule
use AdvectionModule
use ParticlesModule
use PanelsModule
use SphereMeshModule
use TracerSetupModule
use VTKOutputModule
use BVESetupModule
use SphereRemeshModule
implicit none
include 'mpif.h'
!
! mesh variables
!
type(SphereMesh) :: sphere
integer(kint) :: panelKind, initNest, AMR, nTracer
type(Particles), pointer :: sphereParticles
type(Panels), pointer :: spherePanels
!
! tracer variables
!
type(TracerSetup) :: gHills
integer(kint) :: tracerID
real(kreal) :: hmax, beta
!
! vorticity placeholder
!
type(BVESetup) :: nullVort
!
! remeshing / refinement variables
!
type(RemeshSetup) :: remesh
integer(kint) :: remeshInterval, resetAlphaInterval, amrLimit, remeshCounter
real(kreal) :: tracerMassTol, tracerVarTol
type(ReferenceSphere), pointer :: reference
!
! time stepping variables
!
type(AdvRK4Data) :: timekeeper
real(kreal) :: t, tfinal, dt
integer(kint) :: timesteps, timeJ
!
! output variables
!
type(VTKSource) :: vtkOut
character(len = MAX_STRING_LENGTH) :: vtkRoot, vtkFile, outputDir, jobPrefix, dataFile, summaryFile
character(len = 56) :: amrString
integer(kint) :: frameCounter, frameOut, readWriteStat
type(OutputWriter) :: writer
!
! test case variables
!
real(kreal), allocatable :: totalMassGHills(:), tracerVar(:)
real(kreal) :: sphereL2, sphereLinf, panelsLinf, particlesLinf, phiMax, phiMin, deltaPhi, phimax0, phimin0
real(kreal) :: mass0, var0
!
! logging
!
type(Logger) :: exeLog
character(len=28) :: logkey
character(len=MAX_STRING_LENGTH) :: logstring
!
! mpi / computing environment / general variables
!
integer(kint) :: errCode
real(kreal) :: wallclock
integer(kint) :: j
!
! namelists and user input
!
character(len=MAX_STRING_LENGTH) :: namelistFile = 'AdvectGaussHillsDirect.namelist'
namelist /meshDefine/ initNest, AMR, panelKind, amrLimit, tracerMassTol, tracerVarTol
namelist /timestepping/ tfinal, dt, remeshInterval, resetAlphaInterval
namelist /fileIO/ outputDir, jobPrefix, frameOut
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! INITIALIZE COMPUTER, MESH, TEST CASE
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
call MPI_INIT(errCode)
call MPI_COMM_SIZE(MPI_COMM_WORLD, numProcs, errCode)
call MPI_COMM_RANK(MPI_COMM_WORLD, procRank, errCode)
call InitLogger(exeLog, procRank)
wallclock = MPI_WTIME()
nTracer = 2
tracerID = 1
hmax = 0.95_kreal
beta = 5.0_kreal
!
! get user input
!
call ReadNamelistFile(procRank)
!
! define tracer
!
call New(gHills, GAUSS_HILLS_N_INT, GAUSS_HILLS_N_REAL)
call InitGaussianHillsTracer(gHills, hmax, beta, tracerID)
!call New(gHills, 0, 4)
!call InitCosineBellTracer(gHills, 0.0_kreal, 0.0_kreal, EARTH_RADIUS/3.0_kreal, 1000.0_kreal, tracerID)
!
! build initial mesh
!
call New(sphere, panelKind, initNest, AMR, nTracer, ADVECTION_SOLVER)
call SetGaussianHillsTracerOnMesh(sphere, gHills)
!call SetCosineBellTracerOnMesh(sphere, gHills)
!
! initialize remeshing and refinement
!
call ConvertFromRelativeTolerances(sphere, tracerMassTol, tracerVarTol, tracerID)
call LogMessage(exeLog, TRACE_LOGGING_LEVEL, 'tracerMassTol = ', tracerMassTol )
call LogMessage(exeLog, TRACE_LOGGING_LEVEL, 'tracerVarTol = ', tracerVarTol )
call New(remesh, tracerID, tracerMassTol, tracerVarTol, amrLimit)
nullify(reference)
if ( AMR > 0 ) then
call InitialRefinement(sphere, remesh, SetGaussianHillsTracerOnMesh, gHills, NullVorticity, nullvort)
if ( panelKind == QUAD_PANEL ) &
write(amrstring,'(A,I1,A,I0.2,A)') 'quadAMR_', initNest, 'to', initNest+amrLimit, '_'
if ( panelKind == TRI_PANEL ) &
write(amrstring,'(A,I1,A,I0.2,A)') 'triAMR_', initNest, 'to', initNest+amrLimit, '_'
else
if ( panelKind == QUAD_PANEL ) &
write(amrstring,'(A,I1,A)') 'quadUnif_', initNest, '_'
if ( panelKind == TRI_PANEL ) &
write(amrstring,'(A,I1,A)') 'triUnif_', initNest, '_'
endif
!
! initialize output
!
if ( procrank == 0 ) then
call LogStats( sphere, exeLog)
write(vtkRoot,'(A,A,A,A,A)') trim(outputDir), '/vtkOut/',trim(jobPrefix),trim(amrString),'_'
write(vtkFile,'(A,I0.4,A)') trim(vtkRoot),0,'.vtk'
write(summaryFile,'(A,A,A,A)') trim(outputDir), trim(jobPrefix), trim(amrString), '_summary.txt'
write(datafile,'(A,A,A,A)') trim(outputDir), trim(jobPrefix), trim(amrstring), '_calculatedData.m'
call New(vtkOut, sphere, vtkFile, 'Gaussian hills advection')
call VTKOutput(vtkOut, sphere)
endif
!
! initialize time stepping
!
call New(timekeeper, sphere, numProcs)
timesteps = floor(tfinal / dt)
t = 0.0_kreal
remeshCounter = 0
frameCounter = 1
allocate(totalMassGHills(0:timesteps))
totalMassGHills = 0.0_kreal
mass0 = TotalMass(sphere, tracerID)
allocate(tracerVar(0:timesteps))
tracerVar = 0.0_kreal
var0 = TracerVariance(sphere, tracerID)
sphereParticles => sphere%particles
spherePanels => sphere%panels
!phimax0 = max( maxval(sphereParticles%tracer(1:sphereParticles%N,1)), maxval(spherePanels%tracer(1:spherePanels%N,1)) )
!phimin0 = min( minval(sphereParticles%tracer(1:sphereParticles%N,1)), minval(spherePanels%tracer(1:spherePanels%N,1)) )
phimax0 = hmax
phimin0 = hmax
do j = 1, sphereParticles%N
if ( sphereParticles%tracer(j,1) > phimax0 ) phiMax0 = sphereParticles%tracer(j,1)
if ( sphereParticles%tracer(j,1) < phimin0 ) phimin0 = sphereParticles%tracer(j,1)
enddo
do j = 1, spherePanels%N
if ( .NOT. spherePanels%hasChildren(j) ) then
if ( spherePanels%tracer(j,1) > phimax0 ) phimax0 = spherePanels%tracer(j,1)
if ( spherePanels%tracer(j,1) < phimin0 ) phimin0 = spherePanels%tracer(j,1)
endif
enddo
deltaPhi = phimax0 - phimin0
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! RUN THE PROBLEM
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
do timeJ = 0, timesteps - 1
if ( mod( timeJ+1, remeshInterval) == 0 ) then
!
! remesh before timestep
!
remeshCounter = remeshCounter + 1
call DirectRemesh(sphere, remesh)
!
! delete objects associated with old mesh
!
call Delete(timekeeper)
if ( procrank == 0 ) call Delete(vtkOUt)
!
! create new associated objects for new mesh
!
call New(timekeeper, sphere, numProcs)
if ( procRank == 0 ) then
call New(vtkOut, sphere, vtkFile, 'Gaussian hills advection')
call LogStats( sphere, exeLog)
endif
sphereParticles => sphere%particles
spherePanels => sphere%panels
endif ! remesh
!
! advance time
!
call AdvectionRK4Timestep(timekeeper, sphere, dt, t, procRank, numProcs, LauritzenEtAlNonDivergentWind)
totalMassGHills(timeJ+1) = ( TotalMass(sphere, tracerID) - mass0 ) / mass0
tracerVar(timeJ+1) = ( TracerVariance(sphere, tracerID) - var0 ) / var0
t = real( timeJ+1, kreal) * dt
if ( procRank == 0 .AND. mod( timeJ+1, frameOut) == 0 ) then
call LogMessage(exelog, TRACE_LOGGING_LEVEL, 'day = ', t/ONE_DAY)
write(vtkFile, '(A,I0.4,A)') trim(vtkRoot), frameCounter, '.vtk'
call UpdateFilename(vtkOut, vtkFile)
call VTKOutput(vtkOut, sphere)
frameCounter = frameCounter + 1
endif
enddo
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! OUTPUT FINAL DATA
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
! calculate error : exact solution at final time should equal exact tracer from initial distribution
!
sphereParticles => sphere%particles
spherePanels => sphere%panels
do j = 1, sphereParticles%N
sphereParticles%tracer(j,2) = abs( GHillsExact(sphereParticles%x(:,j)/EARTH_RADIUS, hmax, beta) &
- sphereParticles%tracer(j,1))
enddo
do j = 1, spherePanels%N
if ( spherePanels%hasChildren(j) ) then
spherePanels%tracer(j,2) = 0.0_kreal
else
spherePanels%tracer(j,2) = abs( GHillsExact(spherePanels%x(:,j)/EARTH_RADIUS, hmax, beta) &
- spherePanels%tracer(j,1) )
endif
enddo
particlesLinf = maxval(sphereParticles%tracer(1:sphereParticles%N,2)) /&
maxval(sphereParticles%tracer(1:sphereParticles%N,1))
panelsLinf = maxval( spherePanels%tracer(1:spherePanels%N,2) ) /&
maxval( spherePanels%tracer(1:spherePanels%N,1) )
sphereLinf = max( particlesLinf, panelsLinf )
sphereL2 = sum( spherePanels%tracer(1:spherePanels%N,2) * &
spherePanels%tracer(1:spherePanels%N,2) * spherePanels%area(1:spherePanels%N) )
sphereL2 = sphereL2 / sum( spherePanels%tracer(1:spherePanels%N,1) *&
spherePanels%tracer(1:spherePanels%N,1) * spherePanels%area(1:spherePanels%N) )
sphereL2 = sqrt(sphereL2)
! phimax = ( max( maxval(sphereParticles%tracer(1:sphereParticles%N,1)),&
! maxval( spherePanels%tracer(1:spherePanels%N,1)) ) - phimax0) / deltaPhi
! phimin = ( min( minval(sphereParticles%tracer(1:sphereParticles%N,1)), &
! minval( spherePanels%tracer(1:spherePanels%N,1)) ) - phimin0)/ deltaPhi
phimax = maxval(sphereParticles%tracer(1:sphereParticles%N,1))
phimin = minval(sphereParticles%tracer(1:sphereParticles%N,1))
do j = 1, spherePanels%N
if ( .NOT. spherePanels%hasChildren(j) ) then
if ( spherePanels%tracer(j,1) > phiMax) phiMax = spherePanels%tracer(j,1)
if ( spherePanels%tracer(j,1) < phimin) phiMin = spherePanels%tracer(j,1)
endif
enddo
phimax = (phimax - phimax0)/deltaPhi
phimin = (phimin - phimin0)/deltaPhi
print *, "direct N = ", spherePanels%N_Active, ": phi_max = ", phimax,", phi_min = ", phimin
if ( procRank == 0 ) then
open( unit = WRITE_UNIT_1, file = datafile, status = 'REPLACE', action = 'WRITE', iostat = readwritestat)
if ( readwritestat /= 0 ) then
call LogMessage(exeLog, ERROR_LOGGING_LEVEL, 'data file ERROR : ', ' failed to open data file.')
else
write(WRITE_UNIT_1,'(A,F24.15,A)') 'passiveLinf = ', particlesLinf, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'activeLinf = ', panelsLinf, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'sphereLinf = ', sphereLinf, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'sphereL2 = ', sphereL2, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'phi_max = ', phimax, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'phi_min = ', phimin, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'dt_day = ', dt / ONE_DAY, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'tfinal_day = ', tfinal / ONE_DAY, ' ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'mass = [ ', totalMassGHills(0), ' ; ...'
do j = 1, timesteps-1
write(WRITE_UNIT_1,'(F24.15,A)') totalMassGHills(j), ' ; ...'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') totalMassGHills(timesteps), ' ] ;'
write(WRITE_UNIT_1,'(A,F24.15,A)') 'tracerVar = [ ', tracerVar(0), ' ; ...'
do j = 1, timesteps-1
write(WRITE_UNIT_1,'(F24.15,A)') tracerVar(j), ' ; ...'
enddo
write(WRITE_UNIT_1,'(F24.15,A)') tracerVar(timesteps), ' ] ;'
endif
close(WRITE_UNIT_1)
write(logstring,'(A, F8.2,A)') 'elapsed time = ', (MPI_WTIME() - wallClock)/60.0, ' minutes.'
call LogMessage(exelog,TRACE_LOGGING_LEVEL,'PROGRAM COMPLETE : ',trim(logstring))
endif
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! FREE MEMORY, CLEAN UP, FINALIZE
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (associated(reference)) then
call Delete(reference)
deallocate(reference)
endif
deallocate(totalMassGHills)
deallocate(tracerVar)
call Delete(timekeeper)
call Delete(remesh)
if ( procrank == 0 ) call Delete(vtkOut)
call Delete(sphere)
call Delete(gHills)
call Delete(exeLog)
call MPI_FINALIZE(errCode)
contains
function GHillsExact(xyz, hmax, beta)
real(kreal) :: GHillsExact
real(kreal), intent(in) :: xyz(3), hmax, beta
!
real(kreal) :: xc1(3), xc2(3), h1, h2
xC1 = [ cos(5.0_kreal * PI / 6.0_kreal), sin( 5.0_kreal * PI / 6.0_kreal ), 0.0_kreal ]
xC2 = [ cos(7.0_kreal * PI / 6.0_kreal), sin( 7.0_kreal * PI / 6.0_kreal ), 0.0_kreal ]
h1 = hmax * exp( -beta * ( sum( (xyz-xc1) * (xyz-xc1) ) ) )
h2 = hmax * exp( -beta * ( sum( (xyz-xc2) * (xyz-xc2) ) ) )
GHillsExact = h1 + h2
end function
subroutine ConvertFromRelativeTolerances(aMesh, tracerMassTol, tracerVarTol, tracerID)
type(SphereMesh), intent(in) :: amesh
real(kreal), intent(inout) :: tracerMassTol, tracerVarTol
integer(kint), intent(in) :: tracerID
tracerMassTol = tracerMassTol * MaximumTracerMass(aMesh, tracerID)
tracerVarTol = tracerVarTol * MaximumTracerVariation(aMesh, tracerID)
end subroutine
subroutine ReadNamelistFile(rank)
integer(kint), intent(in) :: rank
integer(kint), parameter :: BCAST_INT_SIZE = 6, BCAST_REAL_SIZE= 4
integer(kint) :: broadcastIntegers(BCAST_INT_SIZE)
real(kreal) :: broadcastReals(BCAST_REAL_SIZE)
if ( rank == 0 ) then
open(unit=READ_UNIT, file=namelistfile, status='OLD', action='READ', iostat=readWriteStat)
if ( readWriteStat /= 0 ) stop 'cannot read namelist file.'
read(READ_UNIT, nml=meshDefine)
rewind(READ_UNIT)
read(READ_UNIT, nml=timestepping)
rewind(READ_UNIT)
read(READ_UNIT, nml=fileIO)
rewind(READ_UNIT)
close(READ_UNIT)
broadcastIntegers(1) = panelKind
broadcastIntegers(2) = initNest
broadcastIntegers(3) = AMR
broadcastIntegers(4) = amrLimit
broadcastIntegers(5) = remeshInterval
broadcastIntegers(6) = resetAlphaInterval
broadcastReals(1) = tracerMassTol
broadcastReals(2) = tracerVarTol
broadcastReals(3) = dt
broadcastReals(4) = tfinal
endif
call MPI_BCAST(broadcastIntegers, BCAST_INT_SIZE, MPI_INTEGER, 0, MPI_COMM_WORLD, errCode)
panelKind = broadcastIntegers(1)
initNest = broadcastIntegers(2)
AMR = broadcastIntegers(3)
amrLimit = broadcastIntegers(4)
remeshInterval = broadcastIntegers(5)
resetAlphaInterval = broadcastIntegers(6)
call MPI_BCAST(broadcastReals, BCAST_REAL_SIZE, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, errCode)
tracerMassTol = broadcastReals(1)
tracerVarTol = broadcastReals(2)
dt = broadcastReals(3) * ONE_DAY ! convert time to seconds
tfinal = broadcastReals(4) * ONE_DAY ! convert time to seconds
end subroutine
subroutine InitLogger(alog,rank)
type(Logger), intent(out) :: aLog
integer(kint), intent(in) :: rank
if ( rank == 0 ) then
call New(aLog,DEBUG_LOGGING_LEVEL)
else
call New(aLog,WARNING_LOGGING_LEVEL)
endif
write(logKey,'(A,I0.2,A)') 'EXE_LOG',rank,' : '
end subroutine
end program
| mit |
eligere/eligere | FAHPcore-network/eigen/blas/sspmv.f | 184 | 7974 | SUBROUTINE SSPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
* .. Scalar Arguments ..
REAL ALPHA,BETA
INTEGER INCX,INCY,N
CHARACTER UPLO
* ..
* .. Array Arguments ..
REAL AP(*),X(*),Y(*)
* ..
*
* Purpose
* =======
*
* SSPMV 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 matrix, supplied in packed form.
*
* Arguments
* ==========
*
* UPLO - CHARACTER*1.
* On entry, UPLO specifies whether the upper or lower
* triangular part of the matrix A is supplied in the packed
* array AP as follows:
*
* UPLO = 'U' or 'u' The upper triangular part of A is
* supplied in AP.
*
* UPLO = 'L' or 'l' The lower triangular part of A is
* supplied in AP.
*
* Unchanged on exit.
*
* N - INTEGER.
* On entry, N specifies the order of the matrix A.
* N must be at least zero.
* Unchanged on exit.
*
* ALPHA - REAL .
* On entry, ALPHA specifies the scalar alpha.
* Unchanged on exit.
*
* AP - REAL array of DIMENSION at least
* ( ( n*( n + 1 ) )/2 ).
* Before entry with UPLO = 'U' or 'u', the array AP must
* contain the upper triangular part of the symmetric matrix
* packed sequentially, column by column, so that AP( 1 )
* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 )
* and a( 2, 2 ) respectively, and so on.
* Before entry with UPLO = 'L' or 'l', the array AP must
* contain the lower triangular part of the symmetric matrix
* packed sequentially, column by column, so that AP( 1 )
* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 )
* and a( 3, 1 ) respectively, and so on.
* 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.
* 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 - REAL .
* On entry, BETA specifies the scalar beta. When BETA is
* supplied as zero then Y need not be set on input.
* Unchanged on exit.
*
* Y - REAL array of dimension at least
* ( 1 + ( n - 1 )*abs( INCY ) ).
* Before entry, the incremented array Y must contain the n
* element 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.
*
* Further Details
* ===============
*
* Level 2 Blas routine.
*
* -- 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 ONE,ZERO
PARAMETER (ONE=1.0E+0,ZERO=0.0E+0)
* ..
* .. Local Scalars ..
REAL TEMP1,TEMP2
INTEGER I,INFO,IX,IY,J,JX,JY,K,KK,KX,KY
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. External Subroutines ..
EXTERNAL XERBLA
* ..
*
* 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 (INCX.EQ.0) THEN
INFO = 6
ELSE IF (INCY.EQ.0) THEN
INFO = 9
END IF
IF (INFO.NE.0) THEN
CALL XERBLA('SSPMV ',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 AP
* are accessed sequentially with one pass through AP.
*
* 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
KK = 1
IF (LSAME(UPLO,'U')) THEN
*
* Form y when AP contains the upper triangle.
*
IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
DO 60 J = 1,N
TEMP1 = ALPHA*X(J)
TEMP2 = ZERO
K = KK
DO 50 I = 1,J - 1
Y(I) = Y(I) + TEMP1*AP(K)
TEMP2 = TEMP2 + AP(K)*X(I)
K = K + 1
50 CONTINUE
Y(J) = Y(J) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2
KK = KK + J
60 CONTINUE
ELSE
JX = KX
JY = KY
DO 80 J = 1,N
TEMP1 = ALPHA*X(JX)
TEMP2 = ZERO
IX = KX
IY = KY
DO 70 K = KK,KK + J - 2
Y(IY) = Y(IY) + TEMP1*AP(K)
TEMP2 = TEMP2 + AP(K)*X(IX)
IX = IX + INCX
IY = IY + INCY
70 CONTINUE
Y(JY) = Y(JY) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2
JX = JX + INCX
JY = JY + INCY
KK = KK + J
80 CONTINUE
END IF
ELSE
*
* Form y when AP contains the lower triangle.
*
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*AP(KK)
K = KK + 1
DO 90 I = J + 1,N
Y(I) = Y(I) + TEMP1*AP(K)
TEMP2 = TEMP2 + AP(K)*X(I)
K = K + 1
90 CONTINUE
Y(J) = Y(J) + ALPHA*TEMP2
KK = KK + (N-J+1)
100 CONTINUE
ELSE
JX = KX
JY = KY
DO 120 J = 1,N
TEMP1 = ALPHA*X(JX)
TEMP2 = ZERO
Y(JY) = Y(JY) + TEMP1*AP(KK)
IX = JX
IY = JY
DO 110 K = KK + 1,KK + N - J
IX = IX + INCX
IY = IY + INCY
Y(IY) = Y(IY) + TEMP1*AP(K)
TEMP2 = TEMP2 + AP(K)*X(IX)
110 CONTINUE
Y(JY) = Y(JY) + ALPHA*TEMP2
JX = JX + INCX
JY = JY + INCY
KK = KK + (N-J+1)
120 CONTINUE
END IF
END IF
*
RETURN
*
* End of SSPMV .
*
END
| gpl-3.0 |
SaberMod/GCC_SaberMod | libgomp/testsuite/libgomp.fortran/alloc-comp-1.f90 | 102 | 13864 | ! { dg-do run }
! Don't cycle by default through all options, just test -O0 and -O2,
! as this is quite large test.
! { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } }
module m
type dl
integer :: a, b
integer, allocatable :: c(:,:)
integer :: d, e
integer, allocatable :: f
end type
type dt
integer :: g
type (dl), allocatable :: h(:)
integer :: i
type (dl) :: j(2, 2)
type (dl), allocatable :: k
end type
contains
subroutine ver_dl (obj, val, c, cl1, cu1, cl2, cu2, f)
type (dl), intent (in) :: obj
integer, intent (in) :: val, cl1, cu1, cl2, cu2
logical, intent (in) :: c, f
if ((c .neqv. allocated (obj%c)) .or. (f .neqv. allocated (obj%f))) call abort
if (c) then
if (lbound (obj%c, 1) /= cl1 .or. ubound (obj%c, 1) /= cu1) call abort
if (lbound (obj%c, 2) /= cl2 .or. ubound (obj%c, 2) /= cu2) call abort
end if
if (val /= 0) then
if (obj%a /= val .or. obj%b /= val) call abort
if (obj%d /= val .or. obj%e /= val) call abort
if (c) then
if (any (obj%c /= val)) call abort
end if
if (f) then
if (obj%f /= val) call abort
end if
end if
end subroutine ver_dl
subroutine ver_dt (obj, val, h, hl, hu, k, c, cl1, cu1, cl2, cu2, f)
type (dt), intent (in) :: obj
integer, intent (in) :: val, hl, hu, cl1, cu1, cl2, cu2
logical, intent (in) :: h, k, c, f
integer :: i, j
if ((h .neqv. allocated (obj%h)) .or. (k .neqv. allocated (obj%k))) call abort
if (h) then
if (lbound (obj%h, 1) /= hl .or. ubound (obj%h, 1) /= hu) call abort
do i = hl, hu
call ver_dl (obj%h(i), val, c, cl1, cu1, cl2, cu2, f)
end do
end if
do i = 1, 2
do j = 1, 2
call ver_dl (obj%j(i, j), val, c, cl1, cu1, cl2, cu2, f)
end do
end do
if (k) call ver_dl (obj%k, val, c, cl1, cu1, cl2, cu2, f)
if (val /= 0) then
if (obj%g /= val .or. obj%i /= val) call abort
end if
end subroutine ver_dt
subroutine alloc_dl (obj, val, c, cl1, cu1, cl2, cu2, f)
type (dl), intent (inout) :: obj
integer, intent (in) :: val, cl1, cu1, cl2, cu2
logical, intent (in) :: c, f
if (val /= 0) then
obj%a = val
obj%b = val
obj%d = val
obj%e = val
end if
if (allocated (obj%c)) deallocate (obj%c)
if (c) then
allocate (obj%c(cl1:cu1, cl2:cu2))
if (val /= 0) obj%c = val
end if
if (f) then
if (.not.allocated (obj%f)) allocate (obj%f)
if (val /= 0) obj%f = val
else
if (allocated (obj%f)) deallocate (obj%f)
end if
end subroutine alloc_dl
subroutine alloc_dt (obj, val, h, hl, hu, k, c, cl1, cu1, cl2, cu2, f)
type (dt), intent (inout) :: obj
integer, intent (in) :: val, hl, hu, cl1, cu1, cl2, cu2
logical, intent (in) :: h, k, c, f
integer :: i, j
if (val /= 0) then
obj%g = val
obj%i = val
end if
if (allocated (obj%h)) deallocate (obj%h)
if (h) then
allocate (obj%h(hl:hu))
do i = hl, hu
call alloc_dl (obj%h(i), val, c, cl1, cu1, cl2, cu2, f)
end do
end if
do i = 1, 2
do j = 1, 2
call alloc_dl (obj%j(i, j), val, c, cl1, cu1, cl2, cu2, f)
end do
end do
if (k) then
if (.not.allocated (obj%k)) allocate (obj%k)
call alloc_dl (obj%k, val, c, cl1, cu1, cl2, cu2, f)
else
if (allocated (obj%k)) deallocate (obj%k)
end if
end subroutine alloc_dt
end module m
use m
type (dt) :: y
call foo (y)
contains
subroutine foo (y)
use m
type (dt) :: x, y, z(-3:-3,2:3)
logical, parameter :: F = .false.
logical, parameter :: T = .true.
logical :: l
call ver_dt (x, 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (y, 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (z(-3,2), 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (z(-3,3), 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
!$omp parallel private (x, y, z)
call ver_dt (x, 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (x, 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (x, 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (y, 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (y, 14, T, 3, 4, F, T, 1, 1, 2, 4, T)
call ver_dt (y, 14, T, 3, 4, F, T, 1, 1, 2, 4, T)
call ver_dt (z(-3,2), 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (z(-3,2), 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (z(-3,2), 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (z(-3,3), 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (z(-3,3), 14, T, 3, 4, F, T, 1, 1, 2, 4, T)
call ver_dt (z(-3,3), 14, T, 3, 4, F, T, 1, 1, 2, 4, T)
!$omp end parallel
call ver_dt (x, 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (x, 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (y, 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (y, 14, T, 3, 4, F, T, 1, 1, 2, 4, T)
call ver_dt (z(-3,2), 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (z(-3,2), 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (z(-3,3), 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (z(-3,3), 14, T, 3, 4, F, T, 1, 1, 2, 4, T)
!$omp parallel private (x, y, z)
call ver_dt (x, 0, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (y, 0, T, 3, 4, F, T, 1, 1, 2, 4, T)
deallocate (x%h, x%k)
deallocate (y%h)
allocate (y%k)
call ver_dt (z(-3,2), 0, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (z(-3,3), 0, T, 3, 4, F, T, 1, 1, 2, 4, T)
deallocate (z(-3,2)%h, z(-3,2)%k)
deallocate (z(-3,3)%h)
allocate (z(-3,3)%k)
!$omp end parallel
call alloc_dt (x, 5, T, 1, 2, F, T, 2, 3, -2, -2, F)
call alloc_dt (y, 15, F, 0, 0, T, T, 2, 2, 2, 2, T)
call alloc_dt (z(-3,2), 5, T, 1, 2, F, T, 2, 3, -2, -2, F)
call alloc_dt (z(-3,3), 15, F, 0, 0, T, T, 2, 2, 2, 2, T)
!$omp parallel firstprivate (x, y, z)
call ver_dt (x, 5, T, 1, 2, F, T, 2, 3, -2, -2, F)
call alloc_dt (x, 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (x, 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (y, 15, F, 0, 0, T, T, 2, 2, 2, 2, T)
call alloc_dt (y, 4, T, 3, 4, T, T, 1, 1, 2, 4, T)
call ver_dt (y, 4, T, 3, 4, T, T, 1, 1, 2, 4, T)
call ver_dt (z(-3,2), 5, T, 1, 2, F, T, 2, 3, -2, -2, F)
call alloc_dt (z(-3,2), 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (z(-3,2), 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (z(-3,3), 15, F, 0, 0, T, T, 2, 2, 2, 2, T)
call alloc_dt (z(-3,3), 4, T, 3, 4, T, T, 1, 1, 2, 4, T)
call ver_dt (z(-3,3), 4, T, 3, 4, T, T, 1, 1, 2, 4, T)
!$omp end parallel
call ver_dt (x, 5, T, 1, 2, F, T, 2, 3, -2, -2, F)
call alloc_dt (x, 4, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (y, 15, F, 0, 0, T, T, 2, 2, 2, 2, T)
call alloc_dt (y, 16, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (z(-3,2), 5, T, 1, 2, F, T, 2, 3, -2, -2, F)
call alloc_dt (z(-3,2), 4, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (z(-3,3), 15, F, 0, 0, T, T, 2, 2, 2, 2, T)
call alloc_dt (z(-3,3), 16, F, 0, 0, F, F, 0, 0, 0, 0, F)
!$omp parallel firstprivate (x, y, z)
call ver_dt (x, 4, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (x, 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (x, 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (y, 16, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (y, 17, T, 1, 2, F, T, 2, 2, 3, 3, F)
call ver_dt (y, 17, T, 1, 2, F, T, 2, 2, 3, 3, F)
call ver_dt (z(-3,2), 4, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (z(-3,2), 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (z(-3,2), 4, T, -3, -1, T, T, -1, -1, 2, 3, T)
call ver_dt (z(-3,3), 16, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (z(-3,3), 17, T, 1, 2, F, T, 2, 2, 3, 3, F)
call ver_dt (z(-3,3), 17, T, 1, 2, F, T, 2, 2, 3, 3, F)
!$omp end parallel
call ver_dt (x, 4, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (y, 16, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (y, 18, T, 0, 1, T, T, 0, 1, 0, 1, T)
call ver_dt (z(-3,2), 4, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (z(-3,3), 16, F, 0, 0, F, F, 0, 0, 0, 0, F)
call alloc_dt (z(-3,3), 18, T, 0, 1, T, T, 0, 1, 0, 1, T)
l = F
!$omp parallel sections lastprivate (x, y, z) firstprivate (l)
!$omp section
if (l) then
call ver_dt (x, 9, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (y, 21, F, 0, 0, T, T, 1, 2, 3, 4, T)
call ver_dt (z(-3,2), 9, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (z(-3,3), 21, F, 0, 0, T, T, 1, 2, 3, 4, T)
else
call ver_dt (x, 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (y, 0, T, 0, 1, T, T, 0, 1, 0, 1, T)
call ver_dt (z(-3,2), 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (z(-3,3), 0, T, 0, 1, T, T, 0, 1, 0, 1, T)
end if
l = T
call alloc_dt (x, 7, T, 1, 1, T, T, 1, 2, 3, 3, T)
call ver_dt (x, 7, T, 1, 1, T, T, 1, 2, 3, 3, T)
call alloc_dt (y, 20, T, 0, 0, F, T, 2, 2, 3, 4, F)
call ver_dt (y, 20, T, 0, 0, F, T, 2, 2, 3, 4, F)
call alloc_dt (z(-3,2), 7, T, 1, 1, T, T, 1, 2, 3, 3, T)
call ver_dt (z(-3,2), 7, T, 1, 1, T, T, 1, 2, 3, 3, T)
call alloc_dt (z(-3,3), 20, T, 0, 0, F, T, 2, 2, 3, 4, F)
call ver_dt (z(-3,3), 20, T, 0, 0, F, T, 2, 2, 3, 4, F)
!$omp section
if (l) then
call ver_dt (x, 7, T, 1, 1, T, T, 1, 2, 3, 3, T)
call ver_dt (y, 20, T, 0, 0, F, T, 2, 2, 3, 4, F)
call ver_dt (z(-3,2), 7, T, 1, 1, T, T, 1, 2, 3, 3, T)
call ver_dt (z(-3,3), 20, T, 0, 0, F, T, 2, 2, 3, 4, F)
else
call ver_dt (x, 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (y, 0, T, 0, 1, T, T, 0, 1, 0, 1, T)
call ver_dt (z(-3,2), 0, F, 0, 0, F, F, 0, 0, 0, 0, F)
call ver_dt (z(-3,3), 0, T, 0, 1, T, T, 0, 1, 0, 1, T)
end if
l = T
call alloc_dt (x, 9, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (x, 9, T, 1, 1, F, F, 0, 0, 0, 0, T)
call alloc_dt (y, 21, F, 0, 0, T, T, 1, 2, 3, 4, T)
call ver_dt (y, 21, F, 0, 0, T, T, 1, 2, 3, 4, T)
call alloc_dt (z(-3,2), 9, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (z(-3,2), 9, T, 1, 1, F, F, 0, 0, 0, 0, T)
call alloc_dt (z(-3,3), 21, F, 0, 0, T, T, 1, 2, 3, 4, T)
call ver_dt (z(-3,3), 21, F, 0, 0, T, T, 1, 2, 3, 4, T)
!$omp section
!$omp end parallel sections
call ver_dt (x, 9, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (y, 21, F, 0, 0, T, T, 1, 2, 3, 4, T)
call ver_dt (z(-3,2), 9, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (z(-3,3), 21, F, 0, 0, T, T, 1, 2, 3, 4, T)
!$omp parallel sections lastprivate (x, y, z) firstprivate (l)
!$omp section
if (l) then
call ver_dt (x, 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (y, 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
call ver_dt (z(-3,2), 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (z(-3,3), 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
else
call ver_dt (x, 0, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (y, 0, F, 0, 0, T, T, 1, 2, 3, 4, T)
call ver_dt (z(-3,2), 0, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (z(-3,3), 0, F, 0, 0, T, T, 1, 2, 3, 4, T)
end if
l = T
call alloc_dt (x, 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call ver_dt (x, 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call alloc_dt (y, 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
call ver_dt (y, 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
call alloc_dt (z(-3,2), 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call ver_dt (z(-3,2), 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call alloc_dt (z(-3,3), 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
call ver_dt (z(-3,3), 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
!$omp section
if (l) then
call ver_dt (x, 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call ver_dt (y, 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
call ver_dt (z(-3,2), 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call ver_dt (z(-3,3), 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
else
call ver_dt (x, 0, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (y, 0, F, 0, 0, T, T, 1, 2, 3, 4, T)
call ver_dt (z(-3,2), 0, T, 1, 1, F, F, 0, 0, 0, 0, T)
call ver_dt (z(-3,3), 0, F, 0, 0, T, T, 1, 2, 3, 4, T)
end if
l = T
call alloc_dt (x, 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (x, 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call alloc_dt (y, 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
call ver_dt (y, 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
call alloc_dt (z(-3,2), 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (z(-3,2), 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call alloc_dt (z(-3,3), 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
call ver_dt (z(-3,3), 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
!$omp section
!$omp end parallel sections
call ver_dt (x, 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (y, 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
call ver_dt (z(-3,2), 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (z(-3,3), 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
!$omp parallel private (x, y, z)
call ver_dt (x, 0, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (y, 0, T, 0, 1, T, T, 2, 2, 2, 2, F)
call ver_dt (z(-3,2), 0, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (z(-3,3), 0, T, 0, 1, T, T, 2, 2, 2, 2, F)
!$omp single
call alloc_dt (x, 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call alloc_dt (y, 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
call alloc_dt (z(-3,2), 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call alloc_dt (z(-3,3), 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
!$omp end single copyprivate (x, y, z)
call ver_dt (x, 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call ver_dt (y, 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
call ver_dt (z(-3,2), 3, F, 0, 0, T, T, 0, 1, 0, 1, F)
call ver_dt (z(-3,3), 22, T, 5, 5, F, T, 2, 3, 2, 2, T)
!$omp end parallel
call ver_dt (x, 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (y, 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
call ver_dt (z(-3,2), 5, F, 0, 0, T, T, -1, -1, -1, -1, T)
call ver_dt (z(-3,3), 23, T, 0, 1, T, T, 2, 2, 2, 2, F)
end subroutine foo
end
| gpl-2.0 |
SaberMod/GCC_SaberMod | libgfortran/generated/_abs_i16.F90 | 35 | 1461 | ! Copyright (C) 2002-2014 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_INTEGER_16)
elemental function _gfortran_specific__abs_i16 (parm)
integer (kind=16), intent (in) :: parm
integer (kind=16) :: _gfortran_specific__abs_i16
_gfortran_specific__abs_i16 = abs (parm)
end function
#endif
| gpl-2.0 |
mtitze/madx-cf | madx-5.02.07-util.f90 | 1 | 78823 | module Inf_NaN_Detection
!! Inf_NaN_Detection module
!! Copyright(c) 2003, Lahey Computer Systems, Inc.
!! Copies of this source code, or standalone compiled files
!! derived from this source may not be sold without permission
!! from Lahey Computers Systems. All or part of this module may be
!! freely incorporated into executable programs which are offered
!! for sale. Otherwise, distribution of all or part of this file is
!! permitted, provided this copyright notice and header are included.
!! This module exposes four elemental functions:
!!
!! isnan(x) - test for a "not a number" value
!!
!! isinf(x) - test for either a positive or negative "infinite" value
!!
!! isposinf(x) - test for a positive "infinite" value
!!
!! isneginf(x) - test for a negative "infinite" value
!!
!! Each function accepts a single or double precision real argument, and
!! returns a true or false value to indicate the presence of the value
!! being tested for. If the argument is array valued, the function returns
!! a conformable logical array, suitable for use with the ANY function, or
!! as a logical mask.
!!
!! Each function operates by transferring the bit pattern from a real
!! variable to an integer container. Unless testing for + or - infinity,
!! the sign bit is cleared to zero. The value is exclusive ORed with
!! the value being tested for. The integer result of the IEOR function is
!! converted to a logical result by comparing it to zero.
!!
implicit none
private
public :: isnan, isinf, isposinf, isneginf, sp, dp
! Order set-up
integer,parameter::sp=kind(1.e0)
integer,parameter::dp=selected_real_kind(2*precision(1.e0))
! Kind numbers for single and double precision integer containers
integer, parameter :: Single = selected_int_kind(precision(1.e0))
integer, parameter :: Double = selected_int_kind(2*precision(1.e0))
!VK20070611: The below lines are not accepted by NAG-compiler with <Makefile_nag>
! Single precision IEEE values
integer(Single), parameter :: sNaN = Z"7FC00000"
integer(Single), parameter :: sPosInf = Z"7F800000"
integer(Single), parameter :: sNegInf = Z"FF800000"
! Double precision IEEE values
integer(Double), parameter :: dNaN = Z"7FF8000000000000"
integer(Double), parameter :: dPosInf = Z"7FF0000000000000"
integer(Double), parameter :: dNegInf = Z"FFF0000000000000"
! Locatation of single and double precision sign bit (Intel)
! Subtract one because bit numbering starts at zero
integer, parameter :: SPSB = bit_size(sNaN) - 1
integer, parameter :: DPSB = bit_size(dNaN) - 1
interface isnan
module procedure sisnan
module procedure disnan
end interface isnan
interface isinf
module procedure sisinf
module procedure disinf
end interface isinf
interface isposinf
module procedure sisposinf
module procedure disposinf
end interface isposinf
interface isneginf
module procedure sisneginf
module procedure disneginf
end interface isneginf
contains
! Single precision test for NaN
elemental function sisnan(x) result(res)
implicit none
real(sp), intent(in) :: x
logical :: res
res = ieor(ibclr(transfer(x,sNan),SPSB), sNaN) == 0
end function sisnan
! Double precision test for NaN
!DEC$ ATTRIBUTES FORCEINLINE :: disnan
elemental function disnan(d) result(res)
implicit none
real(dp), intent(in) :: d
logical :: res
res = ieor(ibclr(transfer(d,dNaN),DPSB), dNaN) == 0
end function disnan
! Single precision test for Inf
elemental function sisinf(x) result(res)
implicit none
real(sp), intent(in) :: x
logical :: res
res = ieor(ibclr(transfer(x,sPosInf),SPSB), sPosInf) == 0
end function sisinf
! Double precision test for Inf
elemental function disinf(d) result(res)
implicit none
real(dp), intent(in) :: d
logical :: res
res = ieor(ibclr(transfer(d,dPosInf),DPSB), dPosInf) == 0
end function disinf
! Single precision test for +Inf
elemental function sisposinf(x) result(res)
implicit none
real(sp), intent(in) :: x
logical :: res
res = ieor(transfer(x,sPosInf), sPosInf) == 0
end function sisposinf
! Double precision test for +Inf
elemental function disposinf(d) result(res)
implicit none
real(dp), intent(in) :: d
logical :: res
res = ieor(transfer(d,dPosInf), dPosInf) == 0
end function disposinf
! Single precision test for -Inf
elemental function sisneginf(x) result(res)
implicit none
real(sp), intent(in) :: x
logical :: res
res = ieor(transfer(x,sNegInf), sNegInf) == 0
end function sisneginf
! Double precision test for -Inf
elemental function disneginf(d) result(res)
implicit none
real(dp), intent(in) :: d
logical :: res
res = ieor(transfer(d,dNegInf), dNegInf) == 0
end function disneginf
end module Inf_NaN_Detection
module bbfi
implicit none
public
integer bbd_max
parameter(bbd_max=100000)
integer :: bbd_loc(bbd_max)=0,bbd_cnt=0,bbd_flag=0,bbd_pos=0
double precision :: bb_kick(2,bbd_max)=0.d0
end module bbfi
module deltrafi
implicit none
public
logical :: dorad=.false.,dodamp=.false.,dorand=.false.,fastune=.false.
double precision :: deltax=0.d0
end module deltrafi
module dyntabfi
implicit none
public
double precision :: dynapfrac=0.d0,dktrturns=0.d0,xend=0.d0,pxend=0.d0,&
yend=0.d0,pyend=0.d0,tend=0.d0,ptend=0.d0,smear=0.d0,yapunov=0.d0
end module dyntabfi
module wmaxmin0fi
implicit none
public
double precision :: wxmax=0.d0,wxmin=0.d0,wymax=0.d0,wymin=0.d0,&
wxymax=0.d0,wxymin=0.d0
end module wmaxmin0fi
module tunesfi
implicit none
public
double precision :: x0=0.d0,y0=0.d0,tunx=0.d0,tuny=0.d0,dtune=0.d0
end module tunesfi
module twiss0fi
implicit none
public
integer align_max,fundim
parameter(align_max=14,fundim = 74)
end module twiss0fi
module twissafi
implicit none
public
character(48) :: table_name=' ',sectorTableName=' '
logical :: match_is_on=.false.
end module twissafi
module twisslfi
implicit none
public
logical :: centre=.false.,centre_cptk=.false.,centre_bttk=.false.,first,&
rmatrix=.false.,sectormap=.false.,ripken=.false.
end module twisslfi
module twisscfi
use twiss0fi
implicit none
public
double precision :: opt_fun0(fundim)=0.d0,opt_fun(fundim)=0.d0,disp(6)=0.d0,&
ddisp(6)=0.d0,rmat(2,2)=0.d0,betx=0.d0,alfx=0.d0,amux=0.d0,bety=0.d0,&
alfy=0.d0,amuy=0.d0,bxmax=0.d0,dxmax=0.d0,bymax=0.d0,dymax=0.d0,&
xcomax=0.d0,ycomax=0.d0,sigxco=0.d0,sigyco=0.d0,sigdx=0.d0,sigdy=0.d0,&
wgt=0.d0,cosmux=0.d0,cosmuy=0.d0,wx=0.d0,phix=0.d0,dmux=0.d0,wy=0.d0,&
phiy=0.d0,dmuy=0.d0,synch_1=0.d0,synch_2=0.d0,synch_3=0.d0,synch_4=0.d0,&
synch_5=0.d0,suml=0.d0,circ=0.d0,eta=0.d0,alfa=0.d0,gamtr=0.d0,qx=0.d0,&
qy=0.d0,sinmux=0.d0,sinmuy=0.d0,xix=0.d0,xiy=0.d0,currpos=0.d0
end module twisscfi
module twissotmfi
implicit none
public
double precision :: rotm(6,6)=0.d0,rw(6,6)=0.d0,skick(6)=0.d0,sorb(6)=0.d0,&
srmat(6,6)=0.d0,stmat(6,6,6)=0.d0
end module twissotmfi
module max_iterate
implicit none
public
integer MAXITER
parameter(MAXITER=150)
end module max_iterate
module twiss_elpfi
implicit none
public
!---fixed positions for element parameters-----------------------------*
double precision :: g_elpar(50)=0.d0
!-general--------------------------------------------------------------*
integer g_el, g_kmax, g_kmin, g_calib, g_polarity
parameter (g_el = 2, g_kmax = 3, g_kmin = 4, g_calib = 5, g_polarity = 6)
!-bend-----------------------------------------------------------------*
integer b_angle , b_tilt , b_k0 , b_k0s , &
b_k1 , b_k1s , b_e1 , b_e2 , b_k2 , &
b_k2s , b_h1 , b_h2 , b_hgap , &
b_fint , b_fintx , b_k3 , b_k3s
parameter (b_angle = 7, b_tilt = 8, b_k0 = 9, b_k0s = 10, &
b_k1 = 11, b_k1s = 12, b_e1 = 13 , b_e2 = 14, b_k2 =15,&
b_k2s = 16, b_h1 = 17, b_h2 = 18, b_hgap = 19, &
b_fint = 20, b_fintx = 21, b_k3 = 22, b_k3s = 23)
!-quad-----------------------------------------------------------------*
integer q_tilt, q_k1 , q_k1s
parameter (q_tilt = 7, q_k1 = 8, q_k1s = 9)
!-sext-----------------------------------------------------------------*
integer s_tilt, s_k2 , s_k2s
parameter (s_tilt = 7, s_k2 = 8, s_k2s = 9)
!-oct------------------------------------------------------------------*
integer o_tilt, o_k3 , o_k3s
parameter (o_tilt = 7, o_k3 = 8, o_k3s = 9)
!-mult-----------------------------------------------------------------*
integer m_tilt, m_lrad
parameter (m_tilt = 7, m_lrad = 8)
!-sol------------------------------------------------------------------*
integer so_lrad, so_ks, so_ksi
parameter (so_lrad = 7, so_ks = 8, so_ksi = 9)
!-rfc------------------------------------------------------------------*
integer r_volt, r_lag , r_freq
parameter (r_volt = 7, r_lag = 8, r_freq = 9)
!-elsep----------------------------------------------------------------*
integer e_tilt, e_ex , e_ey
parameter (e_tilt = 7, e_ex = 8, e_ey = 9)
!-hkick----------------------------------------------------------------*
integer h_tilt, h_lrad , h_kick, h_hkick, h_chkick
parameter (h_tilt = 7, h_lrad = 8, h_kick = 9, h_hkick = 10, &
h_chkick = 11)
!-vkick----------------------------------------------------------------*
integer v_tilt, v_lrad , v_kick, v_vkick, v_cvkick
parameter (v_tilt = 7, v_lrad = 8, v_kick = 9, v_vkick = 10, &
v_cvkick = 11)
!-kick-----------------------------------------------------------------*
integer k_tilt, k_lrad , k_hkick, k_vkick, k_chkick, k_cvkick
parameter (k_tilt = 7, k_lrad = 8, k_hkick = 9, k_vkick = 10, &
k_chkick = 11, k_cvkick = 12)
end module twiss_elpfi
module emitfi
implicit none
public
double precision :: qx=0.d0,qy=0.d0,qs=0.d0,cg=0.d0,sum(3)=0.d0,sumu0=0.d0
save qx, qy, qs, cg,sum,sumu0
end module emitfi
module twtrrfi
implicit none
public
!---- maxmul is the maximum multipole order both in twiss and trrun
integer maxmul,maxferr,maxnaper
parameter(maxmul=20,maxferr=50,maxnaper=100)
end module twtrrfi
module ibsdbfi
implicit none
public
integer :: bunch=0
double precision :: circ=0.d0,clight=0.d0,arad=0.d0,freq0=0.d0,alpha=0.d0,&
amass=0.d0,charge=0.d0,en0=0.d0,gammas=0.d0,gamma=0.d0,ex=0.d0,ey=0.d0,&
et=0.d0,sigt=0.d0,sige=0.d0,betas=0.d0,beta=0.d0,parnum=0.d0,&
currnt=0.d0,sigx=0.d0,sigy=0.d0,alfa=0.d0
end module ibsdbfi
module matchfi
implicit none
public
integer :: icovar=0,ilevel=0
double precision :: edm=0.d0,fmin=0.d0
end module matchfi
module name_lenfi
implicit none
public
integer name_len
parameter(name_len=48)
end module name_lenfi
module physconsfi
implicit none
public
double precision :: amu0=0.d0,elamda=0.d0,emass=0.d0,eps0=0.d0,erad=0.d0,&
hbar=0.d0,plamda=0.d0,pmass=0.d0,prad=0.d0,qelect=0.d0,mumass=0.d0
end module physconsfi
module touschekfi
implicit none
public
integer :: bunch=0
double precision :: circ=0.d0,clight=0.d0,arad=0.d0,freq0=0.d0,amass=0.d0,&
charge=0.d0,en0=0.d0,gammas=0.d0,gamma=0.d0,ex=0.d0,ey=0.d0,et=0.d0,&
sigt=0.d0,sige=0.d0,betas=0.d0,beta=0.d0,parnum=0.d0,currnt=0.d0,&
alfa=0.d0,um1=0.d0,deltap=0.d0,fb1=0.d0,fb2=0.d0
end module touschekfi
module trackfi
implicit none
public
double precision :: arad=0.d0,betas=0.d0,beti=0.d0,gammas=0.d0,dtbyds=0.d0,&
deltas=0.d0,bet0=0.d0,bet0i=0.d0,t_max=1.d20,pt_max=1.d20
logical :: dodamp=.false.,dorad=.false.,dorand=.false.,fsecarb=.false.
save arad,betas,beti,gammas,dtbyds,bet0,bet0i
end module trackfi
module time_varfi
use twtrrfi
use name_lenfi
implicit none
public
logical time_var_m,time_var_p,time_var_c
integer n_time_var
parameter (n_time_var = 10000)
integer time_var_m_cnt,time_var_p_cnt,time_var_c_cnt, &
time_var_m_lnt,time_var_p_lnt,time_var_c_lnt, &
trrun_nt
double precision myfield(n_time_var,2,0:maxmul), &
phase_tromb(n_time_var,36),cav_volt(n_time_var), &
time_var_m_ind(n_time_var),time_var_p_ind(n_time_var), &
time_var_c_ind(n_time_var), &
time_var_m_nt(n_time_var),time_var_p_nt(n_time_var), &
time_var_c_nt(n_time_var)
character*(name_len) time_var_m_ch(n_time_var), &
time_var_p_ch(n_time_var),time_var_c_ch(n_time_var)
save time_var_m_cnt,time_var_p_cnt,time_var_c_cnt, &
time_var_m_lnt,time_var_p_lnt,time_var_c_lnt,trrun_nt, &
myfield,phase_tromb,cav_volt,time_var_m_ind, &
time_var_p_ind,time_var_c_ind,time_var_m_nt,time_var_p_nt, &
time_var_c_nt,time_var_m_ch,time_var_p_ch,time_var_c_ch
end module time_varfi
module spch_bbfi
use name_lenfi
use bbfi
implicit none
public
logical :: lost_in_turn = .false., is_lost = .false.
integer i_turn, N_macro_surv, N_for_I, N_macro_max, N_spch, i_spch
parameter(N_macro_max=16000)
double precision Ex_rms, Ey_rms, sigma_p, sigma_z
double precision Ix_array(N_macro_max), Iy_array(N_macro_max), &
dpi_array(N_macro_max), &
z_part_array(N_macro_max)
double precision alpha, I_div_E_sum_max
! parameter(alpha=0.0, I_div_E_sum_max=7.0)
double precision betx_bb(bbd_max), bety_bb(bbd_max), &
alfx_bb(bbd_max), alfy_bb(bbd_max), &
gamx_bb(bbd_max), gamy_bb(bbd_max), &
dx_bb(bbd_max), dy_bb(bbd_max)
double precision rat_bb_n_ions
double precision :: sigma_t=0.d0, mean_t=0.d0 ! calculate and transfer to BB
character*(name_len) spch_bb_name(bbd_max)
save i_turn,N_macro_surv,N_for_I,N_spch,i_spch, &
Ex_rms,Ey_rms,sigma_p,sigma_z, &
Ix_array,Iy_array,dpi_array, z_part_array, &
betx_bb,bety_bb,alfx_bb,alfy_bb,gamx_bb,gamy_bb,dx_bb,dy_bb, &
rat_bb_n_ions,sigma_t, mean_t,spch_bb_name
data rat_bb_n_ions / 1d0 /
end module spch_bbfi
module plotfi
implicit none
public
!--- m_adble is the number of different types of elements
integer mtype, m_adble
parameter (mtype = 50, m_adble = 20)
!--- mcnam adjusted to NAME_L
integer mcnam, maxpnt
parameter (mcnam = 48, maxpnt = 500)
!--- szcompar is the size of the arrays returned by the routine comm_para
integer szcompar
parameter (szcompar = 100)
!--- szchara is the size of the character strings char_a & version in
!--- the routine pesopt
integer szchara
parameter (szchara = 400)
!--- character sizes:
! MLSIZE label character height
! MTSIZE text - " -
! MASIZE annotation - " -
integer mlsize, mtsize, masize
parameter (mlsize = 13,mtsize = 13,masize = 20)
!--- parameters used in the routine pegacn in file plot.F
integer mposx, mposy, mpost
parameter (mposx = 8, mposy = 3, mpost = mposx * mposy)
!--- parameters used in the routine peschm in file plot.F
integer mobj, msize
parameter (mobj = 14, msize = 88)
integer mtitl, mxlabl, mnvar, mxdep, mqadd, mntmax, mksmax, mplred, mplout
parameter (mtitl = 128, mxlabl = 160)
parameter (mnvar = 74, mxdep = 2)
parameter (mqadd = 100000)
parameter (mntmax = 20, mksmax = 10)
parameter (mplred = 46, mplout = 47)
integer maxseql, mtwcol, mpparm, mxcurv, mopt, mfile, marg, maxarg, mxdp, mxplot
parameter (maxseql = 50000, mtwcol = 46, mpparm = 10, &
mxcurv = 10, mopt = 60, mfile = 120, marg = 60, maxarg = 1000, &
mxdp = 25, mxplot = 100)
integer mintpl
parameter (mintpl = 18)
!--- Definition of common / peaddi /
!--- itbv set in routine pesopt, used in routines pemima, peplot
!--- and pesopt.
!--- nivvar set in routine pesopt, used in routines pefill, peintp,
!--- pemima, peplot and pesopt.
!--- nelmach set in routine pefill, used in routines pefill, peplot.
!--- numax set in routine pemima, used in routines pemima, peplot.
!--- interf set in routine pesopt, used in routines pecurv, pefill.
!--- noline set in routine pesopt, used in routines pefill, pesopt.
!--- nqval set in routine pefill and peintp, used in routines pefill,
!--- peintp, pemima and peplot.
!--- nvvar set in routine pesopt and pemima, used in routine pemima.
!--- nrrang set in routine pefill, used in routine pesopt and pefill.
!--- proc_flag set in routine pesopt, used in routine pefill, peintp
!--- and pesopt.
!--- ipparm set in routine peintp and pesopt, used in routine peplot
!--- and pesopt.
!--- naxref set in routine pemima and pesopt, used in routine pemima
!--- and pesopt.
!--- ieltyp set in routine pefill, used in routine psplot.
integer :: itbv=0,nivvar=0,nelmach=0,numax=0,interf=0,noline=0, &
nqval(mxcurv)=0,nvvar(4)=0,nrrang(2)=0, &
proc_flag(2,mxcurv)=0,ipparm(mpparm,mxcurv)=0, &
naxref(mxcurv)=0,ieltyp(maxseql)=0
!--- Definition of common / peaddr /
!--- qascl set in routine pesopt, used in routine peplot.
!--- qlscl set in routine pesopt, used in routine peplot.
!--- qsscl set in routine pesopt, used in routine peplot.
!--- qtscl set in routine pesopt, used in routine peplot.
!--- hrange set in routine pesopt, used in routines pefill, peplot.
!--- vrange set in routine pesopt, used in routine peplot.
!--- hmima set in routines pesopt and pemima,
!--- used in routines peplot, pesopt and pemima.
!--- vmima set in routines pesopt and pemima,
!--- used in routines peplot and pemima.
!--- qhval set in routines pefill and peintp,
!--- used in routines peplot, pefill and pemima.
!--- qvval set in routines pefill and peintp,
!--- used in routines peplot, pefill and pemima.
!--- estart set in routine pefill, and peintp,
!--- used in routines peplot and pefill.
!--- eend set in routine pefill, used in routine peplot.
real :: qascl=0.,qlscl=0.,qsscl=0.,qtscl=0., &
hrange(2)=0.,vrange(2,4)=0.,hmima(2)=0.,vmima(2,4)=0., &
qhval(maxseql,mxcurv)=0.,qvval(maxseql,mxcurv)=0., &
estart(maxseql)=0.,eend(maxseql)=0.
!--- Definition of common / peaddc /
!--- horname set in routine pesopt,
!--- used in routines pefill, peplot and pesopt.
!--- tabname set in routine pesopt,
!--- used in routines pefill, peintp, pelfill and pesopt.
!--- toptitle set in routine pesopt, used in routine peplot.
!--- plfnam set in routine plginit, used in routines plotit and plginit.
!--- axlabel set in routine pemima, used in routine peplot.
!--- sname set in routine pesopt,
!--- used in routines pefill and pesopt.
!--- slabl set in routine pesplit,
!--- used in routines peplot, pemima and pesopt.
character(mfile) :: plfnam=' '
character(mcnam) :: horname=' ',tabname=' ',sname(mxcurv)=' ',slabl(mxcurv)=' '
character(mxlabl) :: axlabel(4)=' '
character(mtitl) :: toptitle=' '
save itbv,nivvar,nelmach,numax,interf,noline,nqval,nvvar,nrrang,proc_flag,&
ipparm,naxref,ieltyp,qascl,qlscl,qsscl,qtscl,hrange,vrange,hmima,&
vmima,qhval,qvval,estart,eend,horname,tabname,toptitle,plfnam,axlabel,&
sname,slabl
end module plotfi
module plot_bfi
implicit none
public
!--- Definition of common / peotcl /
!--- fpmach set in routines pesopt and pefill, used in routine peplot
!--- ddp_flag set in routine pefill, used in routine peplot
!--- ptc_flag set in routines pesopt, used in routine pefill
logical :: fpmach=.false.,dpp_flag=.false.,ptc_flag=.false.
save fpmach,dpp_flag,ptc_flag
end module plot_bfi
module plot_cfi
implicit none
public
!--- Definition of common / e2save /
!--- e2s initialised in routine pefill, used in routine peelma
double precision :: e2s=0.d0
end module plot_cfi
module plot_mathfi
implicit none
public
!--- Definitions of mathematical constants
double precision pi, zero, eps, one, two, twopi, half
parameter (pi = 3.1415926535898d0)
parameter (zero = 0.d0, half = 0.5d0, eps = 1.d-5)
parameter (one = 1.d0, two = 2.d0, twopi = two * pi)
end module plot_mathfi
module resindexfi
implicit none
public
integer mnres,mymorder
parameter (mnres=1000,mymorder=20)
end module resindexfi
module gxx11_common
implicit none
public
!
integer madim1,madim2,maxset,mconid,merrun,metaun,miunit,mmetat,&
normt,mounit,mpaxs,mpcurv,mtermt,mtick,mtmeta,mtterm,mxaxs,mxpix,&
mxsize,myaxs,mypix,mysize,mnormt,mx11pr,mx11tf,mxxpix,mxypix,&
mcolor,mpspro,meppro,mdict,mlpro,&
mpsep,mepep,mhead,mline,msfact,mlbb1,mlbb2,mubb1,mubb2,mtfont,&
mwid1,mwid2
real toleps,versio
parameter (mxaxs = 4, myaxs = 4, mpaxs = 23, mpcurv = 10,&
maxset = 20, mtterm = 1, mmetat = 4,&
mtermt = 101, mtmeta = 2, mconid = 7, mtick = 10, metaun = 11,&
mxpix = 1000, mypix = 1000, mxsize = 27, mysize = 19,&
madim1 = 500, toleps = 1.e-5,&
merrun = 10, miunit = 5, mounit = 6, versio = 1.50,&
mx11pr = 10, mx11tf = 10, mxxpix = 1200, mxypix = 1000,&
mcolor = 6, mpspro = 8, meppro = 8, mdict = 24, mlpro = 68,&
mpsep = 3, mepep = 2, mhead = 4, mline = 72, msfact = 4,&
mlbb1 = 17, mlbb2 = 30, mubb1 = 573, mubb2 = 790, mtfont = 12,&
mwid1 = mubb1 - mlbb1, mwid2 = mubb2 - mlbb2 )
parameter (mnormt = 2, madim2 = 100)
!
integer :: &
itermt=0, interm=0, inmeta=0, ierrun=0, imetun=0, inunit=0, iounit=0, ipage=0,&
isfflg=0, isqflg=0, iwtflg=0, iclflg=0, inormt=0, ipseps=0, iepsop=0, itseop=0,&
iepscf=0, imetps=0, ipctct=0, iczebr=0, idinit=0, ipstyp=0, iclear=0, istotx=0,&
lmpict=0, ltermt=0, lnterm=0, lnmeta=0, lerrun=0, lmetun=0, lnunit=0, lounit=0,&
lsfflg=0, lsqflg=0, lwtflg=0, lclflg=0, lnormt=0, lmetax=0, lmetay=0, lmetnm=0,&
lerrnm=0, ldefnl=0, lerrop=0, lmetop=0, ltotin=0, lacttm=0, lpseps=0, lundef=0,&
lttime=0, ldinit=0, ltseop=0,&
ixapar(mpaxs,mxaxs)=0, iyapar(mpaxs,myaxs)=0, icvpar(mpcurv ,maxset)=0
!
integer :: &
nxpix=0, nypix=0, lxpix=0, lypix=0, icucol=0, iorips=0, &
iutlps=0, ibbox(4)=0, ix11pr(mx11pr)=0, ix11tf(mx11tf)=0, ix11op(mx11tf)=0 !
!
real :: &
fxpix=0., fypix=0., rx11pr(mx11pr)=0., rgbcol(3,mcolor)=0.
!
real :: &
xmetaf=0., ymetaf=0., xsterm=0., ysterm=0., wfact=0., wttime=0., wxfact=0., wyfact=0.,&
vpfacx=0., vpfacy=0.,&
vptdef(4)=0., vploc(4)=0., actwnd(4)=0., rangex(2,mxaxs)=0., rangey(2 ,myaxs)=0.,&
cvwnwd(4,maxset)=0., axwndx(2,maxset), axwndy(2,maxset)=0.
!
character :: &
smetnm*256=" ", serrnm*256=" ", sxtext(mxaxs)*300=" ", sytext(myaxs)*300=" ",&
sxform(mxaxs)*20=" ", syform(myaxs)*20=" ", splotc*(maxset)=" ", stortx * 20=" ",&
sdefnl*1=" ",spsnam * 256=" ", colour(mcolor) * 16=" ", pshead(mhead) * 60=" "
!
real :: xp(madim2+1)=0.,xvp(madim2+1)=0,yp(madim2+1)=0.,yvp(madim2+1)=0
!
real :: p(madim1,2)=0.,s(madim1)=0.,yy1d(madim1,2)=0.,yy2d(madim1,2)=0.
end module gxx11_common
module gxx11_aux
implicit none
public
!
character(100) strloc
integer, dimension(14) :: ivals=(/ 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 1, 1, 0 /)
! ivals(1) marker type
! (2) fill area interior style
! (3) horizontal text alignment
! (4) vertical text alignment
! (5) text font
! (6) text precision
! (7) marker colour index
! (8) metafile status (0 closed, 1 open)
! (9) text colour index
! (10) free
! (11) polyline colour index
! (12) polyline style
! (13) current normalisation transformation number
! (14) last call type: 0 undef., 1 line, 2 text, 3 marker
real, dimension(14) :: rvals=(/ 0., 1., 0.01, 0., 1., 0., 1., 0., 1., 0., 1., 1., 1., 1. /)
! rvals(1-2) chup vector
! 3 character height
! 4-7 window
! 8-11 viewport
! 12 character expansion factor
! 13 line width scale factor
! 14 marker scale factor
save ivals, rvals
end module gxx11_aux
module fasterror
implicit none
logical :: fasterror_on = .false.
integer idim,nx,ny,kstep
double precision hrecip,wtimag,wtreal
parameter ( nx = 490, ny = 470 )
parameter ( idim = (nx+2)*(ny+2) )
public
common /wzcom1/ hrecip, kstep
common /wzcom2/ wtreal(idim), wtimag(idim)
end module fasterror
subroutine fort_info(t1, t2)
implicit none
character(*) t1, t2
integer get_option
if (get_option('info ') .ne. 0 .and. get_option('warn ') .ne. 0) &
print '(a,1x,a,1x,a)', '++++++ info:', t1, t2
end subroutine fort_info
subroutine fort_warn(t1, t2)
implicit none
character(*) t1, t2
integer get_option
if (get_option('warn ') .ne. 0) then
print '(a,1x,a,1x,a)', '++++++ warning:', t1, t2
call augmentfwarn()
endif
end subroutine fort_warn
subroutine getclor(orbit0, rt, tt, error)
!----------------------------------------------------------------------*
! Purpose:
! Get periodic closed orbit (e.g. at start of Twiss),
! first + second order one-turn map
! Input:
! orbit0(6) (real) initial guess
! Output:
! rt(6,6) (real) one-turn matrix
! tt(6,6,6) (real) one-turn second-order map
! error (int) error flag (0: OK, else != 0)
!----------------------------------------------------------------------*
use twiss0fi
implicit none
double precision orbit0(6), rt(6,6), tt(6,6,6)
double precision opt(fundim)
integer error
call m66one(rt)
call dzero(opt,fundim)
call tmclor(orbit0, .true., .true., opt, rt, tt, error)
end subroutine getclor
subroutine m66add(term1,term2,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Add two matrices.
! Input:
! TERM1(6,6) (real) First term.
! TERM2(6,6) (real) Second term.
! Output:
! TARGET(6,6) (real) Sum: TARGET = TERM1 + TERM2.
!----------------------------------------------------------------------*
integer i,j
double precision target(6,6),term1(6,6),term2(6,6)
do i = 1, 6
do j = 1, 6
target(i,j) = term1(i,j) + term2(i,j)
enddo
enddo
end subroutine m66add
subroutine m66byv(amat,avec,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Multiply matrix times vector.
! Input:
! AMAT(6,6) (real) Input matrix.
! AVEC(6) (real) Input vector.
! Output:
! TARGET(6) (real) Output vector: TARGET = AMAT * AVEC.
!----------------------------------------------------------------------*
integer i,j
double precision amat(6,6),avec(6),target(6),temp(6)
call dzero(temp,6)
do i = 1, 6
do j = 1, 6
temp(i) = temp(i) + amat(i,j) * avec(j)
enddo
enddo
call dcopy(temp,target,6)
end subroutine m66byv
subroutine m66cpy(source,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Copy matrix.
! Input:
! SOURCE(6,6) (real) Input matrix.
! Output:
! TARGET(6,6) (real) Output matrix: TARGET = SOURCE.
!----------------------------------------------------------------------*
integer i,j
double precision source(6,6),target(6,6)
do i = 1, 6
do j = 1, 6
target(i,j) = source(i,j)
enddo
enddo
end subroutine m66cpy
subroutine m66div(anum,aden,target,eflag)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! "Divide" matrices, i. e. postmultiply with inverse of denominator.
! Input:
! ANUM(6,6) (real) "Numerator" matrix.
! ADEN(6,6) (real) "Denominator" matrix.
! Output:
! TARGET(6,6) (real) "Quotient" matrix: TARGET = ANUM * ADEN**(-1).
! EFLAG (logical) Error flag.
!----------------------------------------------------------------------*
logical eflag
integer i,irank,j
double precision aden(6,6),anum(6,6),augmat(6,12),target(6,6)
!---- Copy input to local array.
do i = 1, 6
do j = 1, 6
augmat(i,j) = aden(i,j)
augmat(i,j+6) = anum(i,j)
enddo
enddo
!---- Solve resulting system.
call solver(augmat,6,6,irank)
if (irank .lt. 6) then
eflag = .true.
!---- Copy result.
else
eflag = .false.
do i = 1, 6
do j = 1, 6
target(i,j) = augmat(i,j+6)
enddo
enddo
endif
end subroutine m66div
subroutine m66exp(source,target,eflag)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! "Exponentiate" matrix.
! Original author: Liam Healy.
! Input:
! SOURCE(6,6) (real) Input matrix.
! Output:
! TARGET(6,6) (real) Output matrix: TARGET = exp(SOURCE).
! EFLAG (logical) Error flag.
!----------------------------------------------------------------------*
logical eflag
integer i,j
double precision b(6,6),c(6,6),source(6,6),target(6,6),one,two,twelve
parameter(one=1d0,two=2d0,twelve=12d0)
call m66mpy(source,source,b)
call m66mpy(source,b,c)
do j = 1, 6
do i = 1, 6
b(i,j) = (source(i,j) - c(i,j) / twelve) / two
c(i,j) = - b(i,j)
enddo
b(j,j) = b(j,j) + one
c(j,j) = c(j,j) + one
enddo
call m66div(b,c,target,eflag)
end subroutine m66exp
subroutine m66inv(source,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Invert symplectic matrix.
! Input:
! SOURCE(6,6) (real) Input matrix.
! Output:
! TARGET(6,6) (real) Output matrix: TARGET = tr(J) * tr(SOURCE) * J.
!----------------------------------------------------------------------*
integer i
double precision source(6,6),target(6,6),temp(6,6)
!---- TEMP = transpose(SOURCE) * J.
do i = 1, 6
temp(i,1) = - source(2,i)
temp(i,2) = + source(1,i)
temp(i,3) = - source(4,i)
temp(i,4) = + source(3,i)
temp(i,5) = - source(6,i)
temp(i,6) = + source(5,i)
enddo
!---- TARGET = transpose(J) * TEMP.
do i = 1, 6
target(1,i) = - temp(2,i)
target(2,i) = + temp(1,i)
target(3,i) = - temp(4,i)
target(4,i) = + temp(3,i)
target(5,i) = - temp(6,i)
target(6,i) = + temp(5,i)
enddo
end subroutine m66inv
subroutine m66symp(r,nrm)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Check if a 6 by 6 matrix R is symplectic.
! Input:
! r(6,6) (double) Matrix R to check
! Output:
! nrm (double) The column norm of R'*J*R-J
!----------------------------------------------------------------------*
double precision R(6,6),J(6,6),T(6,6),nrm,z,o,n
parameter(z=0d0,o=1d0,n=-1d0)
J = reshape((/ z, o, z, z, z, z, &
& n, z, z, z, z, z, &
& z, z, z, o, z, z, &
& z, z, n, z, z, z, &
& z, z, z, z, z, o, &
& z, z, z, z, n, z /), shape(J))
call m66trm(R,J,T)
call m66mpy(T,R,T)
call m66sub(T,J,T)
call m66nrm(T,nrm)
end subroutine m66symp
subroutine m66mak(f2,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Compute matrix TARGET corresponding to Lie polynomial F2.
! Original author: Liam Healy.
! Input:
! F2 (poly) Polynomial of order 2.
! Output:
! TARGET(6,6) (real) Output matrix: TARGET * v = - [J,v].
!----------------------------------------------------------------------*
double precision f2(*),target(6,6),two
parameter(two=2d0)
target(1,1) = - f2(8)
target(1,2) = - two * f2(13)
target(1,3) = - f2(14)
target(1,4) = - f2(15)
target(1,5) = - f2(16)
target(1,6) = - f2(17)
target(2,1) = two * f2(7)
target(2,2) = f2(8)
target(2,3) = f2(9)
target(2,4) = f2(10)
target(2,5) = f2(11)
target(2,6) = f2(12)
target(3,1) = - f2(10)
target(3,2) = - f2(15)
target(3,3) = - f2(19)
target(3,4) = - two * f2(22)
target(3,5) = - f2(23)
target(3,6) = - f2(24)
target(4,1) = f2(9)
target(4,2) = f2(14)
target(4,3) = two * f2(18)
target(4,4) = f2(19)
target(4,5) = f2(20)
target(4,6) = f2(21)
target(5,1) = - f2(12)
target(5,2) = - f2(17)
target(5,3) = - f2(21)
target(5,4) = - f2(24)
target(5,5) = - f2(26)
target(5,6) = - two * f2(27)
target(6,1) = f2(11)
target(6,2) = f2(16)
target(6,3) = f2(20)
target(6,4) = f2(23)
target(6,5) = two * f2(25)
target(6,6) = f2(26)
end subroutine m66mak
subroutine m66mpy(fact1,fact2,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Multiply two matrices.
! TARGET may coincide with one of the factors.
! Input:
! FACT1(6,6) (real) First factor.
! FACT2(6,6) (real) Second factor.
! Output:
! TARGET(6,6) (real) Product matrix: TARGET = FACT1 * FACT2.
!----------------------------------------------------------------------*
integer i,j,k
double precision fact1(6,6),fact2(6,6),target(6,6),temp(6,6)
call dzero(temp,36)
do k = 1, 6
do j = 1, 6
do i = 1, 6
temp(i,k) = temp(i,k) + fact1(i,j) * fact2(j,k)
enddo
enddo
enddo
call dcopy(temp,target,36)
end subroutine m66mpy
subroutine m66mtr(fact1,fact2,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Multiply a matrix with the transpose of another matrix.
! TARGET must not coincide with either factor.
! Input:
! FACT1(6,6) (real) First factor.
! FACT2(6,6) (real) Second factor (will be transposed).
! Output:
! TARGET(6,6) (real) Product: TARGET = FACT1 * tr(FACT2).
!----------------------------------------------------------------------*
integer i,j,k
double precision fact1(6,6),fact2(6,6),target(6,6)
call dzero(target,36)
do j = 1, 6
do k = 1, 6
do i = 1, 6
target(i,j) = target(i,j) + fact1(i,k) * fact2(j,k)
enddo
enddo
enddo
end subroutine m66mtr
subroutine m66nrm(fm,res)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Computes the norm of a matrix.
! Reference: L. Collatz,
! Functional Analysis & Numerical Mathematics.
! Source: MARYLIE, Version 3.0.
! Input:
! FM(6,6) (real) Input matrix.
! Output:
! RES (real) Norm of FM: RES = max abs column sum.
!----------------------------------------------------------------------*
integer i,j
double precision fm(6,6),res,sum,zero
parameter(zero=0d0)
res = zero
do j = 1, 6
sum = zero
do i = 1, 6
sum = sum + abs(fm(i,j))
enddo
res = max(res,sum)
enddo
end subroutine m66nrm
subroutine m66one(target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Set matrix to unity.
! Output:
! TARGET(6,6) (real) Unit matrix: TARGET = I.
!----------------------------------------------------------------------*
integer j
double precision target(6,6),one
parameter(one=1d0)
call dzero(target,36)
do j = 1, 6
target(j,j) = one
enddo
end subroutine m66one
subroutine m66ref(source,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Reflect symplectic first order transform.
! Input:
! SOURCE(6,6) (real) Input matrix.
! Output:
! TARGET(6,6) (real) Reflected matrix.
!----------------------------------------------------------------------*
integer i
double precision source(6,6),target(6,6),temp(6,6)
!---- TEMP = transpose(SOURCE) * J * signs.
do i = 1, 6
temp(i,1) = source(2,i)
temp(i,2) = source(1,i)
temp(i,3) = source(4,i)
temp(i,4) = source(3,i)
temp(i,5) = - source(6,i)
temp(i,6) = - source(5,i)
enddo
!---- TARGET = signs * transpose(J) * TEMP.
do i = 1, 6
target(1,i) = temp(2,i)
target(2,i) = temp(1,i)
target(3,i) = temp(4,i)
target(4,i) = temp(3,i)
target(5,i) = - temp(6,i)
target(6,i) = - temp(5,i)
enddo
end subroutine m66ref
subroutine m66scl(scalar,source,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Multiply matrix by scalar.
! Input:
! SCALAR (real) Scale factor.
! SOURCE(6,6) (real) Input matrix.
! Output:
! TARGET(6,6) (real) Scaled matrix: TARGET = SCALAR * SOURCE.
!----------------------------------------------------------------------*
integer i,j
double precision scalar,source(6,6),target(6,6)
do i = 1, 6
do j = 1, 6
target(i,j) = scalar * source(i,j)
enddo
enddo
end subroutine m66scl
logical function m66sta(amat)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Check effect of a matrix on momentum.
! Input:
! AMAT(6,6) (real) Input matrix.
! Result:
! .TRUE. For static case (constant p).
! .FALSE. For dynamic case (variable p).
!----------------------------------------------------------------------*
integer j
double precision amat(6,6),tol,one
parameter(one=1d0,tol=1d-12)
m66sta = abs(amat(6,6) - one) .le. tol
do j = 1, 5
m66sta = m66sta .and. abs(amat(6,j)) .le. tol
enddo
end function m66sta
subroutine m66sub(term1,term2,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Subtract two matrices.
! Input:
! TERM1(6,6) (real) Minuend matrix.
! TERM2(6,6) (real) Subtrahend matrix.
! Output:
! TARGET(6,6) (real) Difference matrix: TARGET = TERM1 - TERM2.
!----------------------------------------------------------------------*
integer i,j
double precision target(6,6),term1(6,6),term2(6,6)
do j = 1, 6
do i = 1, 6
target(i,j) = term1(i,j) - term2(i,j)
enddo
enddo
end subroutine m66sub
subroutine m66trm(fact1,fact2,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Multiply the transpose of a matrix with another matrix.
! TARGET must not coincide with either factor.
! Input:
! FACT1(6,6) (real) First factor (will be transposed).
! FACT2(6,6) (real) Second factor.
! Output:
! TARGET(6,6) (real) Product: TARGET = tr(FACT1) * FACT2.
!----------------------------------------------------------------------*
integer i,j,k
double precision fact1(6,6),fact2(6,6),target(6,6)
call dzero(target,36)
do j = 1, 6
do k = 1, 6
do i = 1, 6
target(i,j) = target(i,j) + fact1(k,i) * fact2(k,j)
enddo
enddo
enddo
end subroutine m66trm
subroutine m66tp(source,target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Transpose a matrix.
! TARGET and SOURCE may overlap.
! Input:
! SOURCE(6,6) (real) Input matrix.
! Output:
! TARGET(6,6) (real) Transposed matrix: TARGET = tr(SOURCE).
!----------------------------------------------------------------------*
integer i,j
double precision source(6,6),target(6,6),temp(6,6)
do i = 1, 6
do j = 1, 6
temp(j,i) = source(i,j)
enddo
enddo
call m66cpy(temp,target)
end subroutine m66tp
subroutine m66zro(target)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Clear a matrix to zero.
! Output:
! TARGET(6,6) (real) Zero matrix: TARGET = 0.
!----------------------------------------------------------------------*
double precision target(6,6)
call dzero(target,36)
end subroutine m66zro
subroutine solver(augmat,ndim,mdim,irank)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Solve the linear equation A * X = B.
! Input:
! AUGMAT(n,n+m) A(n,n), augmented by B(n,m).
! NDIM, MDIM n, m.
! Output:
! AUGMAT(n,n+m) Identity(n,n), augmented by X(n,m).
! IRANK Rank of A.
!----------------------------------------------------------------------*
integer ic,ip,ir,irank,it,mdim,nc,ndim,nr
double precision augmat(ndim,ndim+mdim),h,pivot,zero
parameter(zero=0d0)
nr = ndim
nc = ndim + mdim
irank = 0
do it = 1, nr
pivot = zero
ip = 0
do ir = it, nr
if (abs(augmat(ir,it)) .ge. abs(pivot)) then
pivot = augmat(ir,it)
ip = ir
endif
enddo
if (pivot .eq. zero) go to 9999
irank = it
do ic = 1, nc
augmat(ip,ic) = augmat(ip,ic) / pivot
enddo
if (ip .ne. it) then
do ic = 1, nc
h = augmat(ip,ic)
augmat(ip,ic) = augmat(it,ic)
augmat(it,ic) = h
enddo
endif
do ir = 1, nr
if (ir .ne. it) then
h = augmat(ir,it)
do ic = 1, nc
augmat(ir,ic) = augmat(ir,ic) - h * augmat(it,ic)
enddo
endif
enddo
enddo
irank = ndim
9999 end subroutine solver
subroutine symsol(a,n,eflag,work_1,work_2,work_3)
implicit none
!----------------------------------------------------------------------*
! Purpose:
! Invert symmetric matrix.
! Input:
! A(*,*) (real) Matrix to be inverted.
! N (integer) Actual size of A.
! Output:
! A(*,*) (real) Inverted matrix.
! EFLAG (logical) Error flag.
!----------------------------------------------------------------------*
logical eflag
integer i,j,k,n
double precision a(n,n),si,work_1(n),work_2(n),work_3(n),zero,one
parameter(zero=0d0,one=1d0)
!---- Scale upper triangle.
eflag = .true.
do i = 1, n
si = a(i,i)
if (si .le. zero) go to 100
work_1(i) = one / sqrt(si)
enddo
do i = 1, n
do j = i, n
a(i,j) = a(i,j) * work_1(i) * work_1(j)
enddo
enddo
!---- Invert upper triangle.
do i = 1, n
if (a(i,i) .eq. zero) go to 100
work_2(i) = one
work_3(i) = one / a(i,i)
a(i,i) = zero
do j = 1, n
if (j .lt. i) then
work_2(j) = a(j,i)
work_3(j) = work_2(j) * work_3(i)
a(j,i) = zero
else if (j .gt. i) then
work_2(j) = a(i,j)
work_3(j) = - work_2(j) * work_3(i)
a(i,j) = zero
endif
enddo
do j = 1, n
do k = j, n
a(j,k) = a(j,k) + work_2(j) * work_3(k)
enddo
enddo
enddo
!---- Rescale upper triangle and symmetrize.
do i = 1, n
do j = i, n
a(i,j) = a(i,j) * work_1(i) * work_1(j)
a(j,i) = a(i,j)
enddo
enddo
eflag = .false.
100 continue
end subroutine symsol
subroutine symeig(a,nd,n,eigen,nval,work)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Eigenvalues of a real symmetric matrix in ascending order. *
! Input: *
! A(ND,ND) (real) Symmetric input matrix; destroyed by call. *
! N (integer) Rank of matrix. *
! Output: *
! EIGEN(*) (real) Eigenvalues of A in descending order. *
! NVAL (integer) Number of eigenvalues found. *
!----------------------------------------------------------------------*
integer i,it,j,k,l,m,n,nd,nval,itmax
parameter(itmax=15)
double precision b,c,f,g,h,p,r,s,work(nd),a(nd,nd),eigen(nd),zero,&
one,two,four,big,eps
parameter(zero=0d0,one=1d0,two=2d0,four=4d0,big=1d10,eps=1d-20)
!---- Matrix is 1 * 1.
nval = n
if (n .le. 0) go to 300
if (n .eq. 1) then
eigen(1) = a(1,1)
go to 300
endif
!---- Matrix is 2 * 2.
if (n .eq. 2) then
f = a(1,1) + a(2,2)
g = sqrt((a(1,1) - a(2,2))**2 + four * a(2,1)**2)
eigen(1) = (f - g) / two
eigen(2) = (f + g) / two
go to 300
endif
!---- N is at least 3, reduce to tridiagonal form.
do i = n, 3, -1
g = zero
do k = 1, i-2
g = g + a(i,k)**2
enddo
eigen(i) = a(i,i)
if (g .eq. zero) then
work(i) = a(i,i-1)
else
h = g + a(i,i-1)**2
work(i) = sign(sqrt(h),a(i,i-1))
h = h + a(i,i-1) * work(i)
a(i,i-1) = a(i,i-1) + work(i)
f = zero
do j = 1, i-1
g = zero
do k = 1, i-1
if (k .le. j) then
g = g + a(j,k) * a(i,k)
else
g = g + a(k,j) * a(i,k)
endif
enddo
work(j) = g / h
f = f + work(j) * a(i,j)
enddo
do j = 1, i-1
work(j) = work(j) - (f / (h + h)) * a(i,j)
do k = 1, j
a(j,k) = a(j,k) - a(i,j) * work(k) - work(j) * a(i,k)
enddo
enddo
endif
enddo
work(2) = a(2,1)
work(1) = zero
eigen(2) = a(2,2)
eigen(1) = a(1,1)
!---- Iterate on tridiagonal matrix.
do i = 2, n
work(i-1) = work(i)
enddo
work(n) = zero
f = zero
b = zero
do l = 1, n
b = max(eps*(abs(eigen(l))+abs(work(l))),b)
do m = l, n
if (abs(work(m)) .le. b) go to 130
enddo
m = n
130 if (m .ne. l) then
do it = 1, itmax
p = (eigen(l+1) - eigen(l)) / (two * work(l))
if (abs(p) .gt. big) then
r = abs(p)
else
r = sqrt(p*p+one)
endif
h = eigen(l) - work(l) / (p + sign(r,p))
do i = l, n
eigen(i) = eigen(i) - h
enddo
f = f + h
p = eigen(m)
c = one
s = zero
do i = m-1, l, -1
g = c * work(i)
h = c * p
r = sqrt(work(i)**2+p**2)
work(i+1) = s * r
s = work(i) / r
c = p / r
p = c * eigen(i) - s * g
eigen(i+1) = h + s * (c * g + s * eigen(i))
enddo
work(l) = s * p
eigen(l) = c * p
if (abs(work(l)) .le. b) go to 170
enddo
nval = l - 1
go to 300
endif
170 p = eigen(l) + f
do i = l, 2, -1
if (p .ge. eigen(i-1)) go to 190
eigen(i) = eigen(i-1)
enddo
i = 1
190 eigen(i) = p
enddo
300 continue
end subroutine symeig
subroutine dcopy(in,out,n)
!----------------------------------------------------------------------*
! Purpose: *
! Copy arrays. *
! Input: *
! in (double) array to be copied. *
! n (integer) array length. *
! Output: *
! out (double) target array. *
!----------------------------------------------------------------------*
implicit none
integer n, i
double precision in(*), out(*)
do i = 1, n
out(i) = in(i)
enddo
end subroutine dcopy
subroutine dzero(vector,n)
!----------------------------------------------------------------------*
! Purpose: *
! Zero an array. *
! Input: *
! n (integer) array length. *
! Input/output: *
! vector (double) array to be zeroed. *
!----------------------------------------------------------------------*
implicit none
integer n, i
double precision vector(*),zero
parameter(zero=0d0)
do i = 1, n
vector(i) = zero
enddo
end subroutine dzero
subroutine aawarn(rout,text)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Print warning message. *
! Input: *
! ROUT (char) Calling routine name. *
! TEXT (char) Message. *
!----------------------------------------------------------------------*
character(*) rout,text
print *, '++++++ warning: ',rout,text
call augmentfwarn()
end subroutine aawarn
subroutine aafail(rout,text)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Print fatal error message. *
! Input: *
! ROUT (char) Calling routine name. *
! TEXT (char) Message. *
!----------------------------------------------------------------------*
character(*) rout,text
print *,' '
print *, '+-+-+- fatal: ',rout,text
print *,' '
print *,' '
stop 1
end subroutine aafail
double precision function proxim(x,y)
!----------------------------------------------------------------------*
! Proximity function of x and y. *
! If angle is larger than pi between vector x and y, 2pi is added to *
! to this angle *
!----------------------------------------------------------------------*
implicit none
double precision x,y,twopi,get_variable
twopi=get_variable('twopi ')
proxim = x+twopi*anint((y-x)/twopi)
end function proxim
character(48) function charconv(tint)
!----------------------------------------------------------------------*
! purpose: *
! converts integer array to string (based on ascii) *
! input: *
! tint (int array) 1 = length, rest = string *
!----------------------------------------------------------------------*
implicit none
integer tint(*)
integer i, j, m, n
parameter (m = 128)
character(m) letter
data letter / &
' !"#$%&''()*+,-./0123456789:;<=>?@&
&ABCDEFGHIJKLMNOPQRSTUVWXYZ[ ]^_`abcdefghijklmnopqrstuvwxyz{|}~'/
charconv = ' '
n = tint(1)
do i = 1, n
j = tint(i+1)
if (j .lt. m) charconv(i:i) = letter(j:j)
enddo
end function charconv
subroutine laseig(fm,reeig,aieig,am)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Return eigenvalues and eigenvectors of a 4x4 matrix. *
! Input: *
! FM(6,6) (real) Matrix to be transformed. *
! Output: *
! REEIG(6) (real) Real parts of eigenvalues. *
! AIEIG(6) (real) Imaginary parts of eigenvalues. *
! AM(6,6) (real) Transforming matrix, contains eigenvectors. *
!----------------------------------------------------------------------*
integer i,ihi,ilo,info,ipind,iqind,j,k,mdim,nn,kpnt(6)
double precision fm(6,6),reeig(6),aieig(6),am(6,6),aival(6),big,c,&
d(6),dx,dy,pb,reval(6),s,tm(6,6),zero,one
parameter(zero=0d0,one=1d0,ilo=1,ihi=4,mdim=6,nn=4)
!---- Compute eigenvalues and vectors.
call m66cpy(fm,tm)
call m66one(am)
call orthes(mdim,nn,ilo,ihi,tm,d)
call ortran(mdim,nn,ilo,ihi,tm,d,am)
call hqr2(mdim,nn,ilo,ihi,tm,reval,aival,am,info)
if (info .ne. 0) then
write (6, 910) ((fm(i,k), k = 1, 6), i = 1, 6)
910 format('Unable to find eigenvalues for matrix:'/(6f12.6))
call aafail('LASEIG',' Unable to find eigenvalues for matrix')
go to 999
endif
!---- Normalize the eigenvectors.
do k = 1, 5, 2
pb = zero
do ipind = 2, 6, 2
iqind = ipind - 1
pb = pb + am(iqind,k) * am(ipind,k+1) - am(ipind,k) * am(iqind,k+1)
enddo
s = sqrt(abs(pb))
if (pb .lt. zero) then
aival(k) = - aival(k)
aival(k+1) = - aival(k+1)
endif
do i = 1, 6
am(i,k) = am(i,k) / s
am(i,k+1) = am(i,k+1) * (s / pb)
enddo
enddo
!---- Sort these eigenvectors.
call m66cpy(am,tm)
!---- Find the eigenvectors with the largest vertical component.
big = zero
kpnt(3) = 1
do i = 1, 3, 2
c = tm(3,i)**2 + tm(3,i+1)**2 + tm(4,i)**2 + tm(4,i+1)**2
if (c .gt. big) then
big = c
kpnt(3) = i
endif
enddo
!---- Find the remaining vector.
do i = 1, 3, 2
if (i .ne. kpnt(3)) kpnt(1) = i
enddo
!---- Reorder vectors.
do i = 1, 3, 2
k = kpnt(i)
reeig(i) = reval(k)
aieig(i) = aival(k)
reeig(i+1) = reval(k+1)
aieig(i+1) = aival(k+1)
do j = 1, 6
am(j,i) = tm(j,k)
am(j,i+1) = tm(j,k+1)
enddo
enddo
reeig(5) = one
aieig(5) = zero
reeig(6) = one
aieig(6) = zero
!---- Rephase the result.
call m66one(tm)
dx = sqrt(am(1,1)**2 + am(1,2)**2)
tm(1,1) = am(1,1) / dx
tm(2,1) = am(1,2) / dx
tm(1,2) = - tm(2,1)
tm(2,2) = tm(1,1)
dy = sqrt(am(3,3)**2 + am(3,4)**2)
tm(3,3) = am(3,3) / dy
tm(4,3) = am(3,4) / dy
tm(3,4) = - tm(4,3)
tm(4,4) = tm(3,3)
call m66mpy(am,tm,am)
999 end subroutine laseig
subroutine ladeig(fm,reeig,aieig,am)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Return eigenvalues and eigenvectors of a 6x6 matrix. *
! Input: *
! FM(6,6) (real) Matrix to be transformed. *
! Output: *
! REEIG(6) (real) Real parts of eigenvalues. *
! AIEIG(6) (real) Imaginary parts of eigenvalues. *
! AM(6,6) (real) Transforming matrix, contains eigenvectors. *
!----------------------------------------------------------------------*
integer i,ihi,ilo,info,j,k,mdim,nn,kpnt(6)
double precision fm(6,6),reeig(6),aieig(6),am(6,6),aival(6),big,c,&
d(6),dt,dx,dy,pb,reval(6),s,tm(6,6),zero
parameter(zero=0d0,ilo=1,ihi=6,mdim=6,nn=6)
!---- Compute eigenvalues and eigenvectors.
call m66cpy(fm,tm)
call orthes(mdim,nn,ilo,ihi,tm,d)
call ortran(mdim,nn,ilo,ihi,tm,d,am)
call hqr2(mdim,nn,ilo,ihi,tm,reval,aival,am,info)
if (info .ne. 0) then
write (6, 910) ((fm(i,k), k = 1, 6), i = 1, 6)
910 format('Unable to find eigenvalues for matrix:'/(6f12.6))
call aafail('LADEIG',' Unable to find eigenvalues for matrix')
go to 9999
endif
!---- Normalize the eigenvectors.
do k = 1, 5, 2
pb = zero
do i = 1, 5, 2
pb = pb + am(i,k) * am(i+1,k+1) - am(i+1,k) * am(i,k+1)
enddo
s = sqrt(abs(pb))
if (pb .lt. zero) then
aival(k) = - aival(k)
aival(k+1) = - aival(k+1)
endif
do i = 1, 6
am(i,k) = am(i,k) / s
am(i,k+1) = am(i,k+1) * (s / pb)
enddo
enddo
!---- Copy vectors to temporary array.
call m66cpy(am,tm)
!---- Find the vector with the largest vertical component.
big = zero
kpnt(3) = 1
do i = 1, 5, 2
c = tm(3,i)**2 + tm(3,i+1)**2 + tm(4,i)**2 + tm(4,i+1)**2
if (c .gt. big) then
big = c
kpnt(3) = i
endif
enddo
!---- Find the vector with the largest horizontal component.
kpnt(1) = 1
big = zero
do i = 1, 5, 2
if (i .ne. kpnt(3)) then
c = tm(1,i)**2 + tm(1,i+1)**2 + tm(2,i)**2 + tm(2,i+1)**2
if (c .gt. big) then
big = c
kpnt(1) = i
endif
endif
enddo
!---- Find the remaining vector.
do i = 1, 5, 2
if (i .ne. kpnt(3) .and. i .ne. kpnt(1)) kpnt(5) = i
enddo
!---- Reorder vectors.
do i = 1, 5, 2
k = kpnt(i)
reeig(i) = reval(k)
aieig(i) = aival(k)
reeig(i+1) = reval(k+1)
aieig(i+1) = aival(k+1)
do j = 1, 6
am(j,i) = tm(j,k)
am(j,i+1) = tm(j,k+1)
enddo
enddo
!---- Rephase the result.
call m66one(tm)
dx = sqrt(am(1,1)**2 + am(1,2)**2)
tm(1,1) = am(1,1) / dx
tm(2,1) = am(1,2) / dx
tm(1,2) = - tm(2,1)
tm(2,2) = tm(1,1)
dy = sqrt(am(3,3)**2 + am(3,4)**2)
tm(3,3) = am(3,3) / dy
tm(4,3) = am(3,4) / dy
tm(3,4) = - tm(4,3)
tm(4,4) = tm(3,3)
dt = sqrt(am(5,5)**2 + am(5,6)**2)
tm(5,5) = am(5,5) / dt
tm(6,5) = am(5,6) / dt
tm(5,6) = - tm(6,5)
tm(6,6) = tm(5,5)
call m66mpy(am,tm,am)
9999 end subroutine ladeig
subroutine orthes(ndim,n,ilow,iupp,a,d)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Converts an unsymmetric real matrix, A, to upper Hessenberg form *
! applying successive orthogonal transformations. *
! *
! Translation of the ALGOL procedure ORTHES in: *
! Handbook Series Linear Algebra, *
! Num. Math. 12, 349-368 (1968) by R. S. Martin and J. H. Wilkinson. *
! Input: *
! N (integer) Order of the matrix A. *
! ILOW,IUPP (integer) Determine a submatrix, set by BALANC. *
! May be set to 1 and N respectively. *
! A(NDIM,N) (real) Input matrix. *
! Output: *
! A(NDIM,N) (real) The matrix A, converted to upper Hessenberg. *
! The lower triangle contains information *
! about the orthogonal transformations. *
! D(N) (real) Further information. *
!----------------------------------------------------------------------*
integer i,ilow,iupp,j,m,n,ndim
double precision a(ndim,n),d(n),f,g,h,scale,zero
parameter(zero=0d0)
do m = ilow + 1, iupp - 1
h = zero
d(m) = zero
!---- Find scale factor.
scale = zero
do i = m, iupp
scale = scale + abs(a(i,m-1))
enddo
if (scale .ne. zero) then
do i = iupp, m, - 1
d(i) = a(i,m-1) / scale
h = h + d(i) * d(i)
enddo
g = sign(sqrt(h),d(m))
h = h + d(m) * g
d(m) = d(m) + g
!---- Form (I - (u*uT) / h) * A.
do j = m, n
f = zero
do i = iupp, m, - 1
f = f + d(i) * a(i,j)
enddo
f = f / h
do i = m, iupp
a(i,j) = a(i,j) - f * d(i)
enddo
enddo
!---- Form (I - (u*uT) / h) * A * (I - (u*uT) / h).
do i = 1, iupp
f = zero
do j = iupp, m, - 1
f = f + d(j) * a(i,j)
enddo
f = f / h
do j = m, iupp
a(i,j) = a(i,j) - f * d(j)
enddo
enddo
d(m) = scale * d(m)
a(m,m-1) = - scale * g
endif
enddo
end subroutine orthes
subroutine ortran(ndim,n,ilow,iupp,h,d,v)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Accumulate the orthogonal similarity transformation used by *
! ORTHES to reduce a general real matrix A to upper Hessenberg form. *
! *
! Translation of the ALGOL procedure ORTRANS in: *
! Handbook Series Linear Algebra, *
! Num. Math. 16, 181-204 (1970) by G. Peters and J. H. Wilkinson. *
! Input: *
! N (integer) Order of the matrices A and V. *
! ILOW,IUPP (integer) Determine a sub-matrix set by BALANC. *
! May be set to 1 and N respectively. *
! H(NDIM,N) (real) The matrix resulting from running ORTHES. *
! D(N) (real) Further information about the transformation. *
! Output: *
! V(NDIM,N) (real) The accumulated transformation. *
! D(N) (real) Destroyed. *
!----------------------------------------------------------------------*
integer i,ilow,iupp,j,k,m,n,ndim
double precision d(n),h(ndim,n),v(ndim,n),x,y,zero,one
parameter(zero=0d0,one=1d0)
!---- Initialize V to identity matrix.
do i = 1, n
do j = 1, n
v(i,j) = zero
enddo
v(i,i) = one
enddo
!---- Accumulate transformations.
do k = iupp - 2, ilow, - 1
m = k + 1
y = h(m,k)
if (y .ne. zero) then
y = y * d(m)
do i = k + 2, iupp
d(i) = h(i,k)
enddo
do j = m, iupp
x = zero
do i = m, iupp
x = x + d(i) * v(i,j)
enddo
x = x / y
do i = m, iupp
v(i,j) = v(i,j) + x * d(i)
enddo
enddo
endif
enddo
end subroutine ortran
subroutine hqr2(ndim,n,ilow,iupp,h,wr,wi,vecs,ierr)
use max_iterate
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Finds eigenvalues and eigenvectors of an unsymmetric real matrix, *
! A which has been reduced to upper Hessenberg form, H, by the *
! subroutine ORTHES. The orthogonal transformations must be placed *
! in the array VECS by subroutine ORTRAN. *
! *
! Translation of the ALGOL procedure HQR2 in: *
! Handbook Series Linear Algebra, *
! Num. Math. 16, 181 - 204 (1970) by G. Peters and J. H. Wilkinson. *
! Input: *
! N (integer) Order of the Hessenberg matrix H. *
! ILOW,IUPP (integer) *
! H(NDIM,N) (real) The Hessenberg matrix produced by ORTHES. *
! VECS(NDIM,N) (real) A square matrix of order N containing the *
! similarity transformation from A to H *
! Output: *
! H(NDIM,N) (real) Modified. *
! WR(N) (real) Real parts of eigenvalues of H (or A). *
! WI(N) (real) Imaginary parts of eigenvalues of H (or A). *
! VECS(NDIM,N) (real) The unnormalized eigenvectors of A. *
! Complex vectors are stored as pairs of reals. *
!----------------------------------------------------------------------*
integer i,ien,ierr,ilow,its,iupp,j,k,l,m,n,na,ndim
double precision den,h(ndim,n),hnorm,p,q,r,ra,s,sa,t,temp,tempi, &
tempr,vecs(ndim,n),vi,vr,w,wi(n),wr(n),x,y,z,epsmch,zero,one,two, &
triqua,fac1
parameter(epsmch=1d-16,zero=0d0,one=1d0,two=2d0,triqua=.75d0,fac1=.4375d0)
!Initialize
z=zero
s=zero
p=zero
q=zero
r=zero
ierr = 0
!---- Store isolated roots.
do i = 1, n
if (i .lt. ilow .or. i .gt. iupp) then
wr(i) = h(i,i)
wi(i) = zero
endif
enddo
ien = iupp
t = zero
!---- Next eigenvalue.
60 if (ien .ge. ilow) then
its = 0
na = ien - 1
!---- Next iteration; look for single small sub-diagonal element.
70 continue
do l = ien, ilow + 1, -1
if (abs(h(l,l-1)) .le. epsmch * (abs(h(l-1,l-1)) + abs(h(l,l)))) go to 100
enddo
l = ilow
100 continue
x = h(ien,ien)
if (l .eq. ien) go to 270
y = h(na,na)
w = h(ien,na) * h(na,ien)
if (l .eq. na) go to 280
if (its .eq. MAXITER) then
write(6,*) "Maximum Iteration exceeded in HQR2, increase MAXITER: ",MAXITER
ierr = ien
go to 9999
endif
!---- Form exceptional shift.
if (its .eq. 10 .or. its .eq. 20) then
t = t + x
do i = ilow, ien
h(i,i) = h(i,i) - x
enddo
s = abs(h(ien,na)) + abs(h(na,ien-2))
x = triqua * s
y = x
w = - fac1 * s * s
endif
its = its + 1
!---- Look for two consecutive small sub-diagonal elements.
do m = ien - 2, l, - 1
z = h(m,m)
r = x - z
s = y - z
p = (r * s - w) / h(m+1,m) + h(m,m+1)
q = h(m+1,m+1) - z - r - s
r = h(m+2,m+1)
s = abs(p) + abs(q) + abs(r)
p = p / s
q = q / s
r = r / s
if (m .eq. l) go to 150
if (abs(h(m,m-1)) * (abs(q) + abs(r)) .le. epsmch * abs(p) &
* (abs(h(m-1,m-1)) + abs(z) + abs(h(m+1,m+1)))) go to 150
enddo
150 continue
h(m+2,m) = zero
do i = m + 3, ien
h(i,i-2) = zero
h(i,i-3) = zero
enddo
!---- Double QR step involving rows L to IEN and columns M to IEN.
do k = m, na
if (k .ne. m) then
p = h(k,k-1)
q = h(k+1,k-1)
if (k .ne. na) then
r = h(k+2,k-1)
else
r = zero
endif
x = abs(p) + abs(q) + abs(r)
if (x .eq. zero) go to 260
p = p / x
q = q / x
r = r / x
endif
s = sign(sqrt(p**2+q**2+r**2),p)
if (k .ne. m) then
h(k,k-1) = - s * x
else if (l .ne. m) then
h(k,k-1) = - h(k,k-1)
endif
p = p + s
x = p / s
y = q / s
z = r / s
q = q / p
r = r / p
!---- Row modification.
do j = k, n
p = h(k,j) + q * h(k+1,j)
if (k .ne. na) then
p = p + r * h(k+2,j)
h(k+2,j) = h(k+2,j) - p * z
endif
h(k+1,j) = h(k+1,j) - p * y
h(k,j) = h(k,j) - p * x
enddo
!---- Column modification.
j = min(ien,k+3)
do i = 1, j
p = x * h(i,k) + y * h(i,k+1)
if (k .ne. na) then
p = p + z * h(i,k+2)
h(i,k+2) = h(i,k+2) - p * r
endif
h(i,k+1) = h(i,k+1) - p * q
h(i,k) = h(i,k) - p
enddo
!---- Accumulate transformations.
do i = ilow, iupp
p = x * vecs(i,k) + y * vecs(i,k+1)
if (k .ne. na) then
p = p + z * vecs(i,k+2)
vecs(i,k+2) = vecs(i,k+2) - p * r
endif
vecs(i,k+1) = vecs(i,k+1) - p * q
vecs(i,k) = vecs(i,k) - p
enddo
260 continue
enddo
!---- Go to next iteration.
go to 70
!==== One real root found.
270 h(ien,ien) = x + t
wr(ien) = h(ien,ien)
wi(ien) = zero
ien = na
go to 60
!==== Two roots (real pair or complex conjugate) found.
280 p = (y - x) / two
q = p**2 + w
z = sqrt(abs(q))
x = x + t
h(ien,ien) = x
h(na,na) = y + t
!---- Real pair.
if (q .gt. zero) then
z = p + sign(z,p)
wr(na) = x + z
wr(ien) = x - w / z
wi(na) = zero
wi(ien) = zero
x = h(ien,na)
r = sqrt(x**2+z**2)
p = x / r
q = z / r
!---- Row modification.
do j = na, n
z = h(na,j)
h(na,j) = q * z + p * h(ien,j)
h(ien,j) = q * h(ien,j) - p * z
enddo
!---- Column modification.
do i = 1, ien
z = h(i,na)
h(i,na) = q * z + p * h(i,ien)
h(i,ien) = q * h(i,ien) - p * z
enddo
!---- Accumulate transformations.
do i = ilow, iupp
z = vecs(i,na)
vecs(i,na) = q * z + p * vecs(i,ien)
vecs(i,ien) = q * vecs(i,ien) - p * z
enddo
!---- Complex pair.
else
wr(na) = x + p
wr(ien) = x + p
wi(na) = z
wi(ien) = -z
endif
!----- Go to next root.
ien = ien - 2
go to 60
endif
!==== Compute matrix norm.
hnorm = zero
k = 1
do i = 1, n
do j = k, n
hnorm = hnorm + abs(h(i,j))
enddo
k = i
enddo
!==== Back substitution.
do ien = n, 1, -1
p = wr(ien)
q = wi(ien)
na = ien - 1
!---- Real vector.
if (q .eq. zero) then
m = ien
h(ien,ien) = one
do i = na, 1, -1
w = h(i,i) - p
r = h(i,ien)
do j = m, na
r = r + h(i,j) * h(j,ien)
enddo
if (wi(i) .lt. zero) then
z = w
s = r
else
m = i
if (wi(i) .eq. zero) then
temp = w
if (w .eq. zero) temp = epsmch * hnorm
h(i,ien) = - r / temp
else
x = h(i,i+1)
y = h(i+1,i)
q = (wr(i) - p)**2 + wi(i)**2
t = (x * s - z * r) / q
h(i,ien) = t
if (abs(x) .gt. abs(z)) then
h(i+1,ien) = - (r + w * t) / x
else
h(i+1,ien) = - (s + y * t) / z
endif
endif
endif
enddo
!---- Complex vector associated with lamda = P - i * Q.
else if (q .lt. zero) then
m = na
if (abs(h(ien,na)) .gt. abs(h(na,ien))) then
h(na,na) = - (h(ien,ien) - p) / h(ien,na)
h(na,ien) = - q / h(ien,na)
else
den = (h(na,na) - p)**2 + q**2
h(na,na) = - h(na,ien) * (h(na,na) - p) / den
h(na,ien) = h(na,ien) * q / den
endif
h(ien,na) = one
h(ien,ien) = zero
do i = ien - 2, 1, - 1
w = h(i,i) - p
ra = h(i,ien)
sa = zero
do j = m, na
ra = ra + h(i,j) * h(j,na)
sa = sa + h(i,j) * h(j,ien)
enddo
if (wi(i) .lt. zero) then
z = w
r = ra
s = sa
else
m = i
if (wi(i) .eq. zero) then
den = w**2 + q**2
h(i,na) = - (ra * w + sa * q) / den
h(i,ien) = (ra * q - sa * w) / den
else
x = h(i,i+1)
y = h(i+1,i)
vr = (wr(i) - p)**2 + wi(i)**2 - q**2
vi = two * (wr(i) - p) * q
if (vr .eq. zero .and. vi .eq. zero) then
vr = epsmch * hnorm &
* (abs(w) + abs(q) + abs(x) + abs(y) + abs(z))
endif
tempr = x * r - z * ra + q * sa
tempi = x * s - z * sa - q * ra
den = vr**2 + vi**2
h(i,na) = (tempr * vr + tempi * vi) / den
h(i,ien) = (tempi * vr - tempr * vi) / den
if (abs(x) .gt. abs(z) + abs(q)) then
h(i+1,na) = (- ra - w * h(i,na) + q * h(i,ien)) / x
h(i+1,ien) = (- sa - w * h(i,ien) - q * h(i,na)) / x
else
tempr = - r - y * h(i,na)
tempi = - s - y * h(i,ien)
den = z**2 + q**2
h(i+1,na) = (tempr * z + tempi * q) / den
h(i+1,ien) = (tempi * z - tempr * q) / den
endif
endif
endif
enddo
endif
enddo
!==== Vectors of isolated roots.
do i = 1, n
if (i .lt. ilow .or. i .gt. iupp) then
do j = i, n
vecs(i,j) = h(i,j)
enddo
endif
enddo
!==== Multiply by transformation matrix to give eigenvectors of the
! original full matrix.
do j = n, ilow, - 1
m = min(j,iupp)
if (wi(j) .lt. zero) then
l = j - 1
do i = ilow, iupp
y = zero
z = zero
do k = ilow, m
y = y + vecs(i,k) * h(k,l)
z = z + vecs(i,k) * h(k,j)
enddo
vecs(i,l) = y
vecs(i,j) = z
enddo
else if (wi(j) .eq. zero) then
do i = ilow, iupp
z = zero
do k = ilow, m
z = z + vecs(i,k) * h(k,j)
enddo
vecs(i,j) = z
enddo
endif
enddo
9999 end subroutine hqr2
integer function lastnb(t)
!----------------------------------------------------------------------*
! Purpose:
! Find last non-blank in string
!
!----------------------------------------------------------------------*
implicit none
character(*) t
integer i
do i = len(t), 1, -1
if (t(i:i) .ne. ' ') goto 20
enddo
i = 1
20 lastnb = i
end function lastnb
subroutine tmfoc(el,sk1,c,s,d,f)
implicit none
!----------------------------------------------------------------------*
! Purpose: *
! Compute linear focussing functions. *
! Input: *
! el (double) element length. *
! sk1 (double) quadrupole strength. *
! Output: *
! c (double) cosine-like function. c(k,l) *
! s (double) sine-like function. s(k,l) *
! d (double) dispersion function. d(k,l) *
! f (double) integral of dispersion function. f(k,l) *
!----------------------------------------------------------------------*
double precision c,d,el,f,qk,qkl,qkl2,s,sk1,zero,one,two,six, &
twelve,twty,thty,foty2
parameter(zero=0d0,one=1d0,two=2d0,six=6d0,twelve=12d0,twty=20d0, &
thty=30d0,foty2=42d0)
!---- Initialize.
qk = sqrt(abs(sk1))
qkl = qk * el
qkl2 = sk1 * el**2
if (abs(qkl2) .le. 1e-2) then
c = (one - qkl2 * (one - qkl2 / twelve) / two)
s = (one - qkl2 * (one - qkl2 / twty) / six) * el
d = (one - qkl2 * (one - qkl2 / thty) / twelve) * el**2 / two
f = (one - qkl2 * (one - qkl2 / foty2) / twty) * el**3 / six
else
if (qkl2 .gt. zero) then
c = cos(qkl)
s = sin(qkl) / qk
else
c = cosh(qkl)
s = sinh(qkl) / qk
endif
d = (one - c) / sk1
f = (el - s) / sk1
endif
end subroutine tmfoc
subroutine f77flush(i,option)
implicit none
integer i,ios
real a
logical ostat, fexist,option
character(20) faccess,fform
character(255) fname
character(1) c
inquire(err=5,iostat=ios,unit=i,opened=ostat,exist=fexist)
if (.not.ostat.or..not.fexist) return
inquire(err=6,iostat=ios,unit=i,access=faccess,form=fform,name=fname)
close (unit=i,err=7,iostat=ios)
! write (*,*) 'Re-opening ',i,' ',faccess,fform,fname
open(err=8,iostat=ios,unit=i,access=faccess,form=fform,file=fname,status='old')
if (option) then
if (fform.eq.'FORMATTED') then
3 read (i,100,err=9,iostat=ios,end=4) c
go to 3
else
2 read (i,err=10,iostat=ios,end=1) a
go to 2
endif
4 backspace i
1 continue
endif
return
100 format (a1)
5 write (*,*) ' F77FLUSH 1st INQUIRE FAILED with IOSTAT ',ios,' on UNIT ',i
stop
6 write (*,*) ' F77FLUSH 2nd INQUIRE FAILED with IOSTAT ', ios,' on UNIT ',i
stop
7 write (*,*) ' F77FLUSH CLOSE FAILED with IOSTAT ',ios,' on UNIT ',i
stop
8 write (*,*) ' F77FLUSH RE-OPEN FAILED with IOSTAT ',ios,' on UNIT ',i
stop
9 write (*,*) ' F77FLUSH FORMATTED READ FAILED with IOSTAT ',ios,' on UNIT ',i
stop
10 write (*,*) ' F77FLUSH UNFORMATTED READ FAILED with IOSTAT ',ios,' on UNIT ',i
stop
end subroutine f77flush
subroutine seterrorflag(errorcode,from,descr)
!----------------------------------------------------------------------*
! Purpose: *
! Puts global error flag in c code. *
! Input: *
! errorcode *
! from - name of a routine where the error occured *
! descr - description of the error that has occured *
! Input/output: *
!----------------------------------------------------------------------*
implicit none
integer :: errorcode
character(*) :: from
character(*) :: descr
integer n,m
n = LEN(from)
m = LEN(descr)
call seterrorflagfort(errorcode,from,n,descr,m)
end subroutine seterrorflag
| gpl-3.0 |
embecosm/avr32-gcc | gcc/testsuite/gfortran.dg/namelist_11.f | 174 | 1620 | c { dg-do run { target fd_truncate } }
c This program tests: namelist comment, a blank line before the nameilist name, the namelist name,
c a scalar qualifier, various combinations of space, comma and lf delimiters, f-formats, e-formats
c a blank line within the data read, nulls, a range qualifier, a new object name before end of data
c and an integer read. It also tests that namelist output can be re-read by namelist input.
c provided by Paul Thomas - pault@gcc.gnu.org
program namelist_1
REAL x(10)
REAL(kind=8) xx
integer ier
namelist /mynml/ x, xx
do i = 1 , 10
x(i) = -1
end do
x(6) = 6.0
x(10) = 10.0
xx = 0d0
open (10,status="scratch")
write (10, *) "!mynml"
write (10, *) ""
write (10, *) "&gf /"
write (10, *) "&mynml x(7) =+99.0e0 x=1.0, 2.0 ,"
write (10, *) " 2*3.0, ,, 7.0e0,+0.08e+02 !comment"
write (10, *) ""
write (10, *) " 9000e-3 x(4:5)=4 ,5 "
write (10, *) " x=,,3.0, xx=10d0 /"
rewind (10)
read (10, nml=mynml, IOSTAT=ier)
if (ier.ne.0) call abort
rewind (10)
do i = 1 , 10
if ( abs( x(i) - real(i) ) .gt. 1e-8 ) call abort
end do
if ( abs( xx - 10d0 ) .gt. 1e-8 ) call abort
write (10, nml=mynml, iostat=ier)
if (ier.ne.0) call abort
rewind (10)
read (10, NML=mynml, IOSTAT=ier)
if (ier.ne.0) call abort
close (10)
do i = 1 , 10
if ( abs( x(i) - real(i) ) .gt. 1e-8 ) call abort
end do
if ( abs( xx - 10d0 ) .gt. 1e-8 ) call abort
end program
| gpl-2.0 |
cpatrick/ITK-RemoteIO | Modules/ThirdParty/VNL/src/vxl/v3p/netlib/lapack/double/dsptrs.f | 41 | 10858 | SUBROUTINE DSPTRS( UPLO, N, NRHS, AP, IPIV, B, LDB, INFO )
*
* -- LAPACK routine (version 2.0) --
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
* Courant Institute, Argonne National Lab, and Rice University
* March 31, 1993
*
* .. Scalar Arguments ..
CHARACTER UPLO
INTEGER INFO, LDB, N, NRHS
* ..
* .. Array Arguments ..
INTEGER IPIV( * )
DOUBLE PRECISION AP( * ), B( LDB, * )
* ..
*
* Purpose
* =======
*
* DSPTRS solves a system of linear equations A*X = B with a real
* symmetric matrix A stored in packed format using the factorization
* A = U*D*U**T or A = L*D*L**T computed by DSPTRF.
*
* Arguments
* =========
*
* UPLO (input) CHARACTER*1
* Specifies whether the details of the factorization are stored
* as an upper or lower triangular matrix.
* = 'U': Upper triangular, form is A = U*D*U**T;
* = 'L': Lower triangular, form is A = L*D*L**T.
*
* N (input) INTEGER
* The order of the matrix A. N >= 0.
*
* NRHS (input) INTEGER
* The number of right hand sides, i.e., the number of columns
* of the matrix B. NRHS >= 0.
*
* AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
* The block diagonal matrix D and the multipliers used to
* obtain the factor U or L as computed by DSPTRF, stored as a
* packed triangular matrix.
*
* IPIV (input) INTEGER array, dimension (N)
* Details of the interchanges and the block structure of D
* as determined by DSPTRF.
*
* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
* On entry, the right hand side matrix B.
* On exit, the solution matrix X.
*
* LDB (input) INTEGER
* The leading dimension of the array B. LDB >= max(1,N).
*
* INFO (output) INTEGER
* = 0: successful exit
* < 0: if INFO = -i, the i-th argument had an illegal value
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ONE
PARAMETER ( ONE = 1.0D+0 )
* ..
* .. Local Scalars ..
LOGICAL UPPER
INTEGER J, K, KC, KP
DOUBLE PRECISION AK, AKM1, AKM1K, BK, BKM1, DENOM
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. External Subroutines ..
EXTERNAL DGEMV, DGER, DSCAL, DSWAP, XERBLA
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX
* ..
* .. Executable Statements ..
*
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( 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( 'DSPTRS', -INFO )
RETURN
END IF
*
* Quick return if possible
*
IF( N.EQ.0 .OR. NRHS.EQ.0 )
$ RETURN
*
IF( UPPER ) THEN
*
* Solve A*X = B, where A = U*D*U'.
*
* First solve U*D*X = B, overwriting B with X.
*
* K is the main loop index, decreasing from N to 1 in steps of
* 1 or 2, depending on the size of the diagonal blocks.
*
K = N
KC = N*( N+1 ) / 2 + 1
10 CONTINUE
*
* If K < 1, exit from loop.
*
IF( K.LT.1 )
$ GO TO 30
*
KC = KC - K
IF( IPIV( K ).GT.0 ) THEN
*
* 1 x 1 diagonal block
*
* Interchange rows K and IPIV(K).
*
KP = IPIV( K )
IF( KP.NE.K )
$ CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
*
* Multiply by inv(U(K)), where U(K) is the transformation
* stored in column K of A.
*
CALL DGER( K-1, NRHS, -ONE, AP( KC ), 1, B( K, 1 ), LDB,
$ B( 1, 1 ), LDB )
*
* Multiply by the inverse of the diagonal block.
*
CALL DSCAL( NRHS, ONE / AP( KC+K-1 ), B( K, 1 ), LDB )
K = K - 1
ELSE
*
* 2 x 2 diagonal block
*
* Interchange rows K-1 and -IPIV(K).
*
KP = -IPIV( K )
IF( KP.NE.K-1 )
$ CALL DSWAP( NRHS, B( K-1, 1 ), LDB, B( KP, 1 ), LDB )
*
* Multiply by inv(U(K)), where U(K) is the transformation
* stored in columns K-1 and K of A.
*
CALL DGER( K-2, NRHS, -ONE, AP( KC ), 1, B( K, 1 ), LDB,
$ B( 1, 1 ), LDB )
CALL DGER( K-2, NRHS, -ONE, AP( KC-( K-1 ) ), 1,
$ B( K-1, 1 ), LDB, B( 1, 1 ), LDB )
*
* Multiply by the inverse of the diagonal block.
*
AKM1K = AP( KC+K-2 )
AKM1 = AP( KC-1 ) / AKM1K
AK = AP( KC+K-1 ) / AKM1K
DENOM = AKM1*AK - ONE
DO 20 J = 1, NRHS
BKM1 = B( K-1, J ) / AKM1K
BK = B( K, J ) / AKM1K
B( K-1, J ) = ( AK*BKM1-BK ) / DENOM
B( K, J ) = ( AKM1*BK-BKM1 ) / DENOM
20 CONTINUE
KC = KC - K + 1
K = K - 2
END IF
*
GO TO 10
30 CONTINUE
*
* Next solve U'*X = B, overwriting B with X.
*
* K is the main loop index, increasing from 1 to N in steps of
* 1 or 2, depending on the size of the diagonal blocks.
*
K = 1
KC = 1
40 CONTINUE
*
* If K > N, exit from loop.
*
IF( K.GT.N )
$ GO TO 50
*
IF( IPIV( K ).GT.0 ) THEN
*
* 1 x 1 diagonal block
*
* Multiply by inv(U'(K)), where U(K) is the transformation
* stored in column K of A.
*
CALL DGEMV( 'Transpose', K-1, NRHS, -ONE, B, LDB, AP( KC ),
$ 1, ONE, B( K, 1 ), LDB )
*
* Interchange rows K and IPIV(K).
*
KP = IPIV( K )
IF( KP.NE.K )
$ CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
KC = KC + K
K = K + 1
ELSE
*
* 2 x 2 diagonal block
*
* Multiply by inv(U'(K+1)), where U(K+1) is the transformation
* stored in columns K and K+1 of A.
*
CALL DGEMV( 'Transpose', K-1, NRHS, -ONE, B, LDB, AP( KC ),
$ 1, ONE, B( K, 1 ), LDB )
CALL DGEMV( 'Transpose', K-1, NRHS, -ONE, B, LDB,
$ AP( KC+K ), 1, ONE, B( K+1, 1 ), LDB )
*
* Interchange rows K and -IPIV(K).
*
KP = -IPIV( K )
IF( KP.NE.K )
$ CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
KC = KC + 2*K + 1
K = K + 2
END IF
*
GO TO 40
50 CONTINUE
*
ELSE
*
* Solve A*X = B, where A = L*D*L'.
*
* First solve L*D*X = B, overwriting B with X.
*
* K is the main loop index, increasing from 1 to N in steps of
* 1 or 2, depending on the size of the diagonal blocks.
*
K = 1
KC = 1
60 CONTINUE
*
* If K > N, exit from loop.
*
IF( K.GT.N )
$ GO TO 80
*
IF( IPIV( K ).GT.0 ) THEN
*
* 1 x 1 diagonal block
*
* Interchange rows K and IPIV(K).
*
KP = IPIV( K )
IF( KP.NE.K )
$ CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
*
* Multiply by inv(L(K)), where L(K) is the transformation
* stored in column K of A.
*
IF( K.LT.N )
$ CALL DGER( N-K, NRHS, -ONE, AP( KC+1 ), 1, B( K, 1 ),
$ LDB, B( K+1, 1 ), LDB )
*
* Multiply by the inverse of the diagonal block.
*
CALL DSCAL( NRHS, ONE / AP( KC ), B( K, 1 ), LDB )
KC = KC + N - K + 1
K = K + 1
ELSE
*
* 2 x 2 diagonal block
*
* Interchange rows K+1 and -IPIV(K).
*
KP = -IPIV( K )
IF( KP.NE.K+1 )
$ CALL DSWAP( NRHS, B( K+1, 1 ), LDB, B( KP, 1 ), LDB )
*
* Multiply by inv(L(K)), where L(K) is the transformation
* stored in columns K and K+1 of A.
*
IF( K.LT.N-1 ) THEN
CALL DGER( N-K-1, NRHS, -ONE, AP( KC+2 ), 1, B( K, 1 ),
$ LDB, B( K+2, 1 ), LDB )
CALL DGER( N-K-1, NRHS, -ONE, AP( KC+N-K+2 ), 1,
$ B( K+1, 1 ), LDB, B( K+2, 1 ), LDB )
END IF
*
* Multiply by the inverse of the diagonal block.
*
AKM1K = AP( KC+1 )
AKM1 = AP( KC ) / AKM1K
AK = AP( KC+N-K+1 ) / AKM1K
DENOM = AKM1*AK - ONE
DO 70 J = 1, NRHS
BKM1 = B( K, J ) / AKM1K
BK = B( K+1, J ) / AKM1K
B( K, J ) = ( AK*BKM1-BK ) / DENOM
B( K+1, J ) = ( AKM1*BK-BKM1 ) / DENOM
70 CONTINUE
KC = KC + 2*( N-K ) + 1
K = K + 2
END IF
*
GO TO 60
80 CONTINUE
*
* Next solve L'*X = B, overwriting B with X.
*
* K is the main loop index, decreasing from N to 1 in steps of
* 1 or 2, depending on the size of the diagonal blocks.
*
K = N
KC = N*( N+1 ) / 2 + 1
90 CONTINUE
*
* If K < 1, exit from loop.
*
IF( K.LT.1 )
$ GO TO 100
*
KC = KC - ( N-K+1 )
IF( IPIV( K ).GT.0 ) THEN
*
* 1 x 1 diagonal block
*
* Multiply by inv(L'(K)), where L(K) is the transformation
* stored in column K of A.
*
IF( K.LT.N )
$ CALL DGEMV( 'Transpose', N-K, NRHS, -ONE, B( K+1, 1 ),
$ LDB, AP( KC+1 ), 1, ONE, B( K, 1 ), LDB )
*
* Interchange rows K and IPIV(K).
*
KP = IPIV( K )
IF( KP.NE.K )
$ CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
K = K - 1
ELSE
*
* 2 x 2 diagonal block
*
* Multiply by inv(L'(K-1)), where L(K-1) is the transformation
* stored in columns K-1 and K of A.
*
IF( K.LT.N ) THEN
CALL DGEMV( 'Transpose', N-K, NRHS, -ONE, B( K+1, 1 ),
$ LDB, AP( KC+1 ), 1, ONE, B( K, 1 ), LDB )
CALL DGEMV( 'Transpose', N-K, NRHS, -ONE, B( K+1, 1 ),
$ LDB, AP( KC-( N-K ) ), 1, ONE, B( K-1, 1 ),
$ LDB )
END IF
*
* Interchange rows K and -IPIV(K).
*
KP = -IPIV( K )
IF( KP.NE.K )
$ CALL DSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
KC = KC - ( N-K+2 )
K = K - 2
END IF
*
GO TO 90
100 CONTINUE
END IF
*
RETURN
*
* End of DSPTRS
*
END
| apache-2.0 |
ggonzalezabad/OMI_SAO_Shared_VOCs | src/fitting_loops.f90 | 1 | 25411 | SUBROUTINE xtrack_radiance_wvl_calibration ( &
yn_radiance_reference, yn_solar_comp, &
first_pix, last_pix, n_max_rspec, n_comm_wvl_out, errstat )
USE OMSAO_precision_module
USE OMSAO_indices_module, ONLY: &
wvl_idx, spc_idx, sig_idx, max_calfit_idx, max_rs_idx, hwe_idx, asy_idx, &
shi_idx, squ_idx, oclo_idx, o2o2_idx, bro_idx, solar_idx, pge_bro_idx, &
pge_oclo_idx, ccd_idx, radcal_idx
USE OMSAO_parameters_module, ONLY: maxchlen, downweight, normweight
USE OMSAO_variables_module, ONLY: &
verb_thresh_lev, hw1e, e_asym, n_rad_wvl, curr_rad_spec, rad_spec_wavcal, &
sol_wav_avg, database, fitvar_cal, fitvar_cal_saved, &
fitvar_rad_init, pge_idx, rad_wght_wavcal, &
n_fitres_loop, fitres_range, yn_diagnostic_run
USE OMSAO_slitfunction_module, ONLY: saved_shift, saved_squeeze
USE OMSAO_omidata_module ! , exept_this_one => n_comm_wvl
USE OMSAO_errstat_module
USE EZspline_obj
USE EZspline
IMPLICIT NONE
! ---------------
! Input variables
! ---------------
INTEGER (KIND=i4), INTENT (IN) :: first_pix, last_pix, n_max_rspec
LOGICAL, INTENT (IN) :: yn_radiance_reference, yn_solar_comp
! ---------------
! Output variable
! ---------------
INTEGER (KIND=i4), INTENT (OUT) :: n_comm_wvl_out
! -----------------
! Modified variable
! -----------------
INTEGER (KIND=i4), INTENT (INOUT) :: errstat
! ---------------
! Local variables
! ---------------
INTEGER (KIND=i2) :: radcal_itnum
INTEGER (KIND=i4) :: locerrstat, ipix, radcal_exval, i, imax, n_ref_wvl !, nxtloc, xtr_add
REAL (KIND=r8) :: chisquav, rad_spec_avg
LOGICAL :: yn_skip_pix, yn_bad_pixel, yn_full_range
CHARACTER (LEN=maxchlen) :: addmsg
INTEGER (KIND=i4), DIMENSION (4) :: select_idx
INTEGER (KIND=i4), DIMENSION (2) :: exclud_idx
REAL (KIND=r8), DIMENSION (n_max_rspec) :: ref_wvl, ref_spc, ref_wgt, rad_wvl
! ------------------------------
! Name of this module/subroutine
! ------------------------------
CHARACTER (LEN=31), PARAMETER :: modulename = 'xtrack_radiance_wvl_calibration'
locerrstat = pge_errstat_ok
fitvar_cal_saved(1:max_calfit_idx) = fitvar_rad_init(1:max_calfit_idx)
! -------------------------------------------------
! Set the number of wavelengths for the common mode
! -------------------------------------------------
n_comm_wvl_out = MAXVAL ( omi_nwav_radref(first_pix:last_pix) )
IF ( MAXVAL(omi_nwav_rad(first_pix:last_pix,0)) > n_comm_wvl_out ) &
n_comm_wvl_out = MAXVAL(omi_nwav_rad(first_pix:last_pix,0))
! --------------------------------
! Loop over cross-track positions.
! --------------------------------
XTrackWavCal: DO ipix = first_pix, last_pix
locerrstat = pge_errstat_ok
curr_xtrack_pixnum = ipix
! ---------------------------------------------------------------------
! If we already determined that this cross track pixel position carries
! an error, we don't even have to start processing.
! ---------------------------------------------------------------------
IF ( omi_cross_track_skippix(ipix) ) CYCLE
! ---------------------------------------------------------------------------
! For each cross-track position we have to initialize the saved Shift&Squeeze
! ---------------------------------------------------------------------------
saved_shift = -1.0e+30_r8 ; saved_squeeze = -1.0e+30_r8
! ----------------------------------------------------
! Assign number of radiance and irradiance wavelengths
! ----------------------------------------------------
n_omi_irradwvl = omi_nwav_irrad(ipix )
n_omi_radwvl = omi_nwav_rad (ipix,0)
! -----------------------------------------------------------------
! tpk: Should the following be "> n_fitvar_rad"??? No, because that
! value is set only inside OMI_ADJUST_RADIANCE_DATA!!!
! -----------------------------------------------------------------
IF ( n_omi_irradwvl <= 0 .OR. n_omi_radwvl <= 0 ) CYCLE
! ---------------------------------------------------------------
! Restore solar fitting variables for across-track reference in
! Earthshine fitting. Use the Radiance References if appropriate.
! ---------------------------------------------------------------
sol_wav_avg = omi_sol_wav_avg(ipix)
hw1e = omi_solcal_pars(hwe_idx,ipix)
e_asym = omi_solcal_pars(asy_idx,ipix)
! -----------------------------------------------------
! Assign (hopefully predetermined) "reference" weights.
! -----------------------------------------------------
IF ( .NOT. yn_solar_comp ) THEN
n_omi_irradwvl = omi_nwav_irrad(ipix)
ref_wgt(1:n_omi_irradwvl) = omi_irradiance_wght(1:n_omi_irradwvl,ipix)
! -----------------------------------------------------
! Catch the possibility that N_OMI_RADWVL > N_OMI_IRRADWVL
! -----------------------------------------------------
IF ( n_omi_radwvl > n_omi_irradwvl ) THEN
i = n_omi_radwvl - n_omi_irradwvl
ref_wgt(n_omi_irradwvl+1:n_omi_irradwvl+i) = downweight
n_omi_irradwvl = n_omi_radwvl
END IF
ELSE
n_omi_irradwvl = n_omi_radwvl
ref_wgt(1:n_omi_radwvl) = normweight
END IF
! ---------------------------------------------------------------
! If a Radiance Reference is being used, then it must be calibrated
! rather than the swath line that has been read.
! ---------------------------------------------------------------
IF ( yn_radiance_reference ) THEN
omi_radiance_wavl(1:n_omi_radwvl,ipix,0) = omi_radref_wavl(1:n_omi_radwvl,ipix)
omi_radiance_spec(1:n_omi_radwvl,ipix,0) = omi_radref_spec(1:n_omi_radwvl,ipix)
omi_radiance_qflg(1:n_omi_radwvl,ipix,0) = omi_radref_qflg(1:n_omi_radwvl,ipix)
END IF
! ---------------------------------------------------------------------------
! Set up generic fitting arrays. Remember that OMI_RADIANCE_XXX arrays are
! 3-dim with the last dimension being the scan line numbers. For the radiance
! wavelength calibration we only have one scan line at index "0".
! ---------------------------------------------------------------------------
select_idx(1:4) = omi_ccdpix_selection(ipix,1:4)
exclud_idx(1:2) = omi_ccdpix_exclusion(ipix,1:2)
CALL omi_adjust_radiance_data ( & ! Set up generic fitting arrays
select_idx(1:4), exclud_idx(1:2), &
n_omi_radwvl, &
omi_radiance_wavl (1:n_omi_radwvl,ipix,0), &
omi_radiance_spec (1:n_omi_radwvl,ipix,0), &
omi_radiance_qflg (1:n_omi_radwvl,ipix,0), &
omi_radiance_ccdpix(1:n_omi_radwvl,ipix,0), &
n_omi_irradwvl, ref_wgt(1:n_omi_irradwvl), &
n_rad_wvl, curr_rad_spec(wvl_idx:ccd_idx,1:n_omi_radwvl), rad_spec_avg, &
yn_skip_pix )
! ------------------------------------------------------------------------------------
IF ( yn_skip_pix .OR. locerrstat >= pge_errstat_error ) THEN
errstat = MAX ( errstat, locerrstat )
omi_cross_track_skippix (ipix) = .TRUE.
addmsg = ''
WRITE (addmsg, '(A,I2)') 'SKIPPING cross track pixel #', ipix
CALL error_check ( 0, 1, pge_errstat_warning, OMSAO_W_SKIPPIX, &
modulename//f_sep//TRIM(ADJUSTL(addmsg)), vb_lev_default, &
locerrstat )
CYCLE
END IF
! -----------------------------------------------------
! Assign the solar average wavelength - the wavelength
! calibration will not converge without it!
! -----------------------------------------------------
sol_wav_avg = &
SUM ( curr_rad_spec(wvl_idx,1:n_omi_radwvl) ) / REAL(n_omi_radwvl,KIND=r8)
yn_bad_pixel = .FALSE.
CALL radiance_wavcal ( & ! Radiance wavelength calibration
ipix, n_fitres_loop(radcal_idx), fitres_range(radcal_idx), &
n_rad_wvl, curr_rad_spec(wvl_idx:ccd_idx,1:n_rad_wvl), &
radcal_exval, radcal_itnum, chisquav, yn_bad_pixel, locerrstat )
IF ( yn_bad_pixel .OR. locerrstat >= pge_errstat_error ) THEN
errstat = MAX ( errstat, locerrstat )
omi_cross_track_skippix (ipix) = .TRUE.
addmsg = ''
WRITE (addmsg, '(A,I2)') 'SKIPPING cross track pixel #', ipix
CALL error_check ( 0, 1, pge_errstat_warning, OMSAO_W_SKIPPIX, &
modulename//f_sep//TRIM(ADJUSTL(addmsg)), vb_lev_default, &
locerrstat )
CYCLE
END IF
! ------------------------------------------------------------------------------------
addmsg = ''
WRITE (addmsg, '(A,I2,4(A,1PE10.3),2(A,I5))') 'RADIANCE Wavcal #', ipix, &
': hw 1/e = ', hw1e, '; e_asy = ', e_asym, '; shift = ', &
fitvar_cal(shi_idx), '; squeeze = ', fitvar_cal(squ_idx), &
'; exit val = ', radcal_exval, '; iter num = ', radcal_itnum
CALL error_check ( &
0, 1, pge_errstat_ok, OMSAO_S_PROGRESS, TRIM(ADJUSTL(addmsg)), &
vb_lev_omidebug, locerrstat )
IF ( verb_thresh_lev >= vb_lev_screen ) WRITE (*, '(A)') TRIM(ADJUSTL(addmsg))
! ---------------------------------
! Save crucial variables for output
! ---------------------------------
omi_radcal_pars (1:max_calfit_idx,ipix) = fitvar_cal(1:max_calfit_idx)
omi_radcal_xflag(ipix) = INT (radcal_exval, KIND=i2)
omi_radcal_itnum(ipix) = INT (radcal_itnum, KIND=i2)
omi_radcal_chisq(ipix) = chisquav
! -----------------------------------------------------------------------
IF ( .NOT. (yn_radiance_reference) ) THEN
n_ref_wvl = n_omi_irradwvl
ref_wvl(1:n_ref_wvl) = omi_irradiance_wavl(1:n_ref_wvl,ipix)
ref_spc(1:n_ref_wvl) = omi_irradiance_spec(1:n_ref_wvl,ipix)
ref_wgt(1:n_ref_wvl) = omi_irradiance_wght(1:n_ref_wvl,ipix)
ELSE
n_ref_wvl = n_rad_wvl
ref_wvl(1:n_ref_wvl) = curr_rad_spec(wvl_idx,1:n_rad_wvl)
ref_spc(1:n_ref_wvl) = curr_rad_spec(spc_idx,1:n_rad_wvl)
ref_wgt(1:n_ref_wvl) = curr_rad_spec(sig_idx,1:n_rad_wvl)
omi_nwav_radref(ipix) = n_ref_wvl
omi_radref_wavl(1:n_ref_wvl,ipix) = curr_rad_spec(wvl_idx,1:n_rad_wvl)
omi_radref_spec(1:n_ref_wvl,ipix) = curr_rad_spec(spc_idx,1:n_rad_wvl)
omi_radref_wght(1:n_ref_wvl,ipix) = curr_rad_spec(sig_idx,1:n_rad_wvl)
END IF
! ----------------------------------------------------
! Spline reference spectra to current wavelength grid.
! ----------------------------------------------------
rad_wvl(1:n_rad_wvl) = curr_rad_spec(wvl_idx,1:n_rad_wvl)
Call prepare_databases ( &
ipix, n_ref_wvl, ref_wvl(1:n_ref_wvl), ref_spc(1:n_ref_wvl), &
n_rad_wvl, rad_wvl(1:n_rad_wvl), n_max_rspec, locerrstat )
! --------------------------------------------------------------------------------
IF ( locerrstat >= pge_errstat_error ) EXIT XTrackWavCal
! ---------------------------------------------------------
! Save DATABASE in OMI_DATABASE for radiance fitting loops.
! ---------------------------------------------------------
omi_database (1:max_rs_idx,1:n_rad_wvl,ipix) = database (1:max_rs_idx,1:n_rad_wvl)
n_omi_database_wvl(ipix) = n_rad_wvl
omi_database_wvl(1:n_rad_wvl, ipix) = curr_rad_spec(wvl_idx,1:n_rad_wvl)
! ----------------------------------------------------------------------
! Update the radiance reference with the wavelength calibrated values.
! ----------------------------------------------------------------------
IF ( yn_radiance_reference ) THEN
omi_radref_wavl(1:n_rad_wvl,ipix) = curr_rad_spec(wvl_idx,1:n_rad_wvl)
omi_radref_spec(1:n_rad_wvl,ipix) = curr_rad_spec(spc_idx,1:n_rad_wvl)
omi_radref_wght(n_rad_wvl+1:nwavel_max,ipix) = downweight
! --------------------------------------------------------
! Update the solar spectrum entry in OMI_DATABASE. First
! re-sample the solar reference spectrum to the OMI grid
! then assign to data base.
!
! We need to keep the irradiance spectrum because we still
! have to fit the radiance reference, and we can't really
! do that against itself. In a later module the irradiance
! is replaced by the radiance reference.
! --------------------------------------------------------
! ------------------------------------------------------------------
! Prevent failure of interpolation by finding the maximum wavelength
! of the irradiance wavelength array.
! ------------------------------------------------------------------
imax = MAXVAL ( MAXLOC ( omi_irradiance_wavl(1:n_omi_irradwvl,ipix) ) )
!imin = MINVAL ( MINLOC ( omi_irradiance_wavl(1:imax, ipix) ) )
CALL interpolation ( &
modulename, &
imax, omi_irradiance_wavl(1:imax,ipix), &
omi_irradiance_spec(1:imax,ipix), &
n_rad_wvl, omi_database_wvl(1:n_rad_wvl,ipix), &
omi_database(solar_idx,1:n_rad_wvl,ipix), &
'endpoints', 0.0_r8, yn_full_range, locerrstat )
IF ( locerrstat >= pge_errstat_error ) THEN
errstat = MAX ( errstat, locerrstat )
omi_cross_track_skippix (ipix) = .TRUE.
addmsg = ''
WRITE (addmsg, '(A,I2)') 'SKIPPING cross track pixel #', ipix
CALL error_check ( 0, 1, pge_errstat_warning, OMSAO_W_SKIPPIX, &
modulename//f_sep//TRIM(ADJUSTL(addmsg)), vb_lev_default, &
locerrstat )
CYCLE
END IF
END IF
END DO XTrackWavCal
! CCM Write splined/convolved databases if necessary
IF( yn_diagnostic_run ) THEN
! omi_database maybe omi_database_wvl?
CALL he5_write_omi_database(omi_database(1:max_rs_idx,1:n_rad_wvl,1:nxtrack_max), &
omi_database_wvl(1:n_rad_wvl, 1:nxtrack_max), &
max_rs_idx, n_rad_wvl, nxtrack_max, errstat)
ENDIF
errstat = MAX ( errstat, locerrstat )
RETURN
END SUBROUTINE xtrack_radiance_wvl_calibration
SUBROUTINE xtrack_radiance_fitting_loop ( &
n_max_rspec, first_pix, last_pix, pge_idx, iloop, &
ctr_maxcol, n_fitvar_rad, allfit_cols, allfit_errs, corr_matrix, &
target_var, errstat, fitspc_out, fitspc_out_dim0 )
USE OMSAO_precision_module
USE OMSAO_indices_module, ONLY: &
wvl_idx, spc_idx, sig_idx, o3_t1_idx, o3_t3_idx, hwe_idx, asy_idx, shi_idx, squ_idx, &
pge_o3_idx, pge_hcho_idx, n_max_fitpars, solar_idx, ccd_idx, radfit_idx, bro_idx, &
pge_gly_idx
USE OMSAO_parameters_module, ONLY: &
i2_missval, i4_missval, r4_missval, r8_missval, maxchlen, elsunc_less_is_noise
USE OMSAO_variables_module, ONLY: &
database, curr_sol_spec, n_rad_wvl, curr_rad_spec, sol_wav_avg, hw1e, e_asym, &
verb_thresh_lev, fitvar_rad_saved, fitvar_rad_init, n_database_wvl, &
fitvar_rad, rad_wght_wavcal, n_fitres_loop, fitres_range, refspecs_original, &
yn_solar_comp, max_itnum_rad, szamax, n_fincol_idx, ozone_idx, ozone_log
USE OMSAO_radiance_ref_module, ONLY: yn_radiance_reference, yn_reference_fit
USE OMSAO_slitfunction_module, ONLY: saved_shift, saved_squeeze
USE OMSAO_prefitcol_module, ONLY: &
yn_o3_prefit, o3_prefit_col, o3_prefit_dcol, &
yn_bro_prefit, bro_prefit_col, bro_prefit_dcol, &
yn_lqh2o_prefit, lqh2o_prefit_col, lqh2o_prefit_dcol
USE OMSAO_omidata_module ! nxtrack_max, ...
USE OMSAO_errstat_module
IMPLICIT NONE
! ---------------
! Input Variables
! ---------------
REAL (KIND=r8), INTENT (IN) :: ctr_maxcol
INTEGER (KIND=i4), INTENT (IN) :: &
pge_idx, iloop, first_pix, last_pix, n_max_rspec, n_fitvar_rad, &
fitspc_out_dim0
! -----------------
! Modified variable
! -----------------
INTEGER (KIND=i4), INTENT (INOUT) :: errstat
REAL (KIND=r8), INTENT (OUT ), DIMENSION (n_fitvar_rad,first_pix:last_pix) :: &
allfit_cols, allfit_errs, corr_matrix
! ---------------------------------------------------------
! Optional output variable (fitted variable for target gas)
! ---------------------------------------------------------
REAL (KIND=r8), DIMENSION(n_fincol_idx,first_pix:last_pix), INTENT (OUT) :: target_var
! CCM Output fit spectra
!REAL (KIND=r8), DIMENSION(n_comm_wvl,nxtrack_max,4), INTENT (OUT) :: fitspc_out
REAL (KIND=r8), DIMENSION(fitspc_out_dim0,nxtrack_max,4), INTENT (OUT) :: fitspc_out
! ---------------
! Local variables
! ---------------
INTEGER (KIND=i4) :: locerrstat, ipix, radfit_exval, radfit_itnum
REAL (KIND=r8) :: fitcol, rms, dfitcol, chisquav, rad_spec_avg
REAL (KIND=r8) :: brofit_col, brofit_dcol
REAL (KIND=r8) :: lqh2ofit_col, lqh2ofit_dcol
REAL (KIND=r8), DIMENSION (o3_t1_idx:o3_t3_idx) :: o3fit_cols, o3fit_dcols
LOGICAL :: yn_skip_pix, yn_cycle_this_pix
LOGICAL :: yn_bad_pixel
INTEGER (KIND=i4), DIMENSION (4) :: select_idx
INTEGER (KIND=i4), DIMENSION (2) :: exclud_idx
INTEGER (KIND=i4) :: n_solar_pts
REAL (KIND=r8), DIMENSION (n_max_rspec) :: solar_wvl
! CCM Array for holding fitted spectra
REAL (KIND=r8), DIMENSION (fitspc_out_dim0) :: fitspc
REAL (KIND=i4) :: id
CHARACTER (LEN=28), PARAMETER :: modulename = 'xtrack_radiance_fitting_loop'
locerrstat = pge_errstat_ok
!!!fitvar_rad_saved = fitvar_rad_init
XTrackPix: DO ipix = first_pix, last_pix
curr_xtrack_pixnum = ipix
! ---------------------------------------------------------------------
! If we already determined that this cross track pixel position carries
! an error, we don't even have to start processing.
! ---------------------------------------------------------------------
IF ( omi_cross_track_skippix(ipix) .OR. szamax < omi_szenith(ipix,iloop) ) CYCLE
locerrstat = pge_errstat_ok
n_database_wvl = n_omi_database_wvl(ipix)
n_omi_radwvl = omi_nwav_rad (ipix,iloop)
! ---------------------------------------------------------------------------
! For each cross-track position we have to initialize the saved Shift&Squeeze
! ---------------------------------------------------------------------------
saved_shift = -1.0e+30_r8 ; saved_squeeze = -1.0e+30_r8
! ----------------------------------------------------------------------------
! Assign the solar wavelengths. Those should be current in the DATABASE array
! and can be taken from there no matter which case - YN_SOLAR_COMP and/or
! YN_RADIANCE_REFRENCE we are processing.
! ----------------------------------------------------------------------------
n_solar_pts = n_omi_database_wvl(ipix)
if (n_solar_pts < 1) cycle ! JED fix
solar_wvl(1:n_solar_pts) = omi_database_wvl (1:n_solar_pts, ipix)
n_omi_irradwvl = n_solar_pts
CALL check_wavelength_overlap ( &
n_fitvar_rad, &
n_solar_pts, solar_wvl (1:n_solar_pts), &
n_omi_radwvl, omi_radiance_wavl (1:n_omi_radwvl,ipix,iloop), &
yn_cycle_this_pix )
IF ( yn_cycle_this_pix .OR. &
(n_database_wvl <= 0) .OR. (n_omi_radwvl <= 0) ) CYCLE
!(n_database_wvl <= n_fitvar_rad) .OR. (n_omi_radwvl <= n_fitvar_rad) ) CYCLE
! ----------------------------------------------
! Restore DATABASE from OMI_DATABASE (see above)
! ----------------------------------------------
database (1:max_rs_idx,1:n_database_wvl) = omi_database (1:max_rs_idx,1:n_database_wvl,ipix)
! ---------------------------------------------------------------------------------
! Restore solar fitting variables for across-track reference in Earthshine fitting.
! Note that, for the YN_SOLAR_COMP case, some variables have been assigned already
! in the XTRACK_RADIANCE_WAVCAL loop.
! ---------------------------------------------------------------------------------
sol_wav_avg = omi_sol_wav_avg(ipix)
hw1e = omi_solcal_pars(hwe_idx,ipix)
e_asym = omi_solcal_pars(asy_idx,ipix)
curr_sol_spec(wvl_idx,1:n_database_wvl) = omi_database_wvl(1:n_database_wvl,ipix)
curr_sol_spec(spc_idx,1:n_database_wvl) = omi_database (solar_idx,1:n_database_wvl,ipix)
! --------------------------------------------------------------------------------
omi_xtrackpix_no = ipix
! -------------------------------------------------------------------------
select_idx(1:4) = omi_ccdpix_selection(ipix,1:4)
exclud_idx(1:2) = omi_ccdpix_exclusion(ipix,1:2)
CALL omi_adjust_radiance_data ( & ! Set up generic fitting arrays
select_idx(1:4), exclud_idx(1:2), &
n_omi_radwvl, &
omi_radiance_wavl (1:n_omi_radwvl,ipix,iloop), &
omi_radiance_spec (1:n_omi_radwvl,ipix,iloop), &
omi_radiance_qflg (1:n_omi_radwvl,ipix,iloop), &
omi_radiance_ccdpix(1:n_omi_radwvl,ipix,iloop), &
n_omi_radwvl, omi_radref_wght(1:n_omi_radwvl,ipix), &
n_rad_wvl, curr_rad_spec(wvl_idx:ccd_idx,1:n_omi_radwvl),&
rad_spec_avg, yn_skip_pix )
SELECT CASE ( pge_idx )
CASE (pge_hcho_idx)
o3fit_cols (o3_t1_idx:o3_t3_idx) = o3_prefit_col (o3_t1_idx:o3_t3_idx,ipix,iloop)
o3fit_dcols(o3_t1_idx:o3_t3_idx) = o3_prefit_dcol(o3_t1_idx:o3_t3_idx,ipix,iloop)
brofit_col = bro_prefit_col (ipix,iloop)
brofit_dcol = bro_prefit_dcol(ipix,iloop)
CASE ( pge_gly_idx )
lqh2ofit_col = lqh2o_prefit_col (ipix,iloop)
lqh2ofit_dcol = lqh2o_prefit_dcol(ipix,iloop)
CASE DEFAULT
! Nothing
END SELECT
! --------------------
! The radiance fitting
! --------------------
fitcol = r8_missval
dfitcol = r8_missval
radfit_exval = INT(i2_missval, KIND=i4)
radfit_itnum = INT(i2_missval, KIND=i4)
rms = r8_missval
yn_reference_fit = .FALSE.
IF ( MAXVAL(curr_rad_spec(spc_idx,1:n_rad_wvl)) > 0.0_r8 .AND. &
n_rad_wvl > n_fitvar_rad .AND. (.NOT. yn_skip_pix) ) THEN
yn_bad_pixel = .FALSE.
CALL radiance_fit ( &
pge_idx, ipix, n_fitres_loop(radfit_idx), fitres_range(radfit_idx), &
yn_reference_fit, &
n_rad_wvl, curr_rad_spec(wvl_idx:ccd_idx,1:n_rad_wvl), &
fitcol, rms, dfitcol, radfit_exval, radfit_itnum, chisquav, &
o3fit_cols, o3fit_dcols, brofit_col, brofit_dcol, &
lqh2ofit_col, lqh2ofit_dcol, &
target_var(1:n_fincol_idx,ipix), &
allfit_cols(1:n_fitvar_rad,ipix), allfit_errs(1:n_fitvar_rad,ipix), &
corr_matrix(1:n_fitvar_rad,ipix), yn_bad_pixel, fitspc(1:n_rad_wvl) )
IF ( yn_bad_pixel ) CYCLE
END IF
! -----------------------------------
! Assign pixel values to final arrays
! -----------------------------------
omi_fitconv_flag (ipix,iloop) = INT (radfit_exval, KIND=i2)
omi_itnum_flag (ipix,iloop) = INT (radfit_itnum, KIND=i2)
omi_radfit_chisq (ipix,iloop) = chisquav
omi_fit_rms (ipix,iloop) = rms
omi_column_amount(ipix,iloop) = fitcol
omi_column_uncert(ipix,iloop) = dfitcol
IF (ozone_log) THEN
omi_ozone_amount(ipix,omi_iline) = allfit_cols(ozone_idx,ipix)
ENDIF
! CCM assign fit residual
fitspc_out(1:n_rad_wvl,ipix,1) = fitspc(1:n_rad_wvl)
fitspc_out(1:n_rad_wvl,ipix,2) = curr_rad_spec(spc_idx,1:n_rad_wvl)
fitspc_out(1:n_rad_wvl,ipix,3) = curr_rad_spec(wvl_idx,1:n_rad_wvl)
fitspc_out(1:n_rad_wvl,ipix,4) = curr_rad_spec(sig_idx,1:n_rad_wvl)
IF ( pge_idx == pge_o3_idx ) THEN
omi_o3_amount(o3_t1_idx:o3_t3_idx,ipix,iloop) = o3fit_cols (o3_t1_idx:o3_t3_idx)
omi_o3_uncert(o3_t1_idx:o3_t3_idx,ipix,iloop) = o3fit_dcols(o3_t1_idx:o3_t3_idx)
END IF
END DO XTrackPix
errstat = MAX ( errstat, locerrstat )
RETURN
END SUBROUTINE xtrack_radiance_fitting_loop
| mit |
luca-penasa/mtspec-python3 | mtspec/src/examples/src/fig5.f90 | 2 | 2306 | program fig5
!
! Simple code to generate Figure 5 of
! Prieto et al.
! A Fortran 90 library formultitaper spectrumanalysis
!
! Additional editing of the figure was performed for
! publication.
! An additional on-the-fly plotting library is used
! for the plotting of the data.
!
!********************************************************************
use spectra
use plot
implicit none
integer, parameter :: npts=86400, nfft = 2*86400, nf = 2*86400/2+1
integer, parameter :: ngf = 500, nf2 = ngf/2+1
integer :: kspec, i, iadapt
real(4) :: tbnw, dt
real(4), dimension(npts) :: pasc, ado, t
complex(4), dimension(nfft) :: trf, pasc_cmp, ado_cmp, cc
real(4), dimension(ngf) :: gf, gf2
real(4), dimension(nf2) :: freq, spec
!********************************************************************
dt = 1.
kspec = 7
tbnw = 4.
iadapt = 0 ! Adaptive multitaper
! Load the data, already resampled
open(12,file='../data/PASC_jan04_2007.dat')
do i = 1,npts
read(12,*) pasc(i)
t(i) = real(i)*dt
enddo
close(12)
open(12,file='../data/ADO_jan04_2007.dat')
do i = 1,npts
read(12,*) ado(i)
enddo
close(12)
pasc = pasc - sum(pasc)/real(npts)
ado = ado - sum(ado) /real(npts)
! Call transfer function subroutine
call mt_transfer (npts,nfft,dt,pasc,ado,tbnw,kspec,nf, &
freq=freq,trf=trf,iadapt=iadapt,demean=1)
call ifft4(trf,nfft)
do i = 1,ngf
gf(i) = real(trf(nfft-i+1))
enddo
call gplot(t(1:ngf),gf,ylimit = '3',xlimit='6',output='gf1.ps')
! The correlation approach
pasc_cmp = 0.
pasc_cmp(1:npts) = pasc
ado_cmp = 0.
ado_cmp(1:npts) = ado
call fft4(pasc_cmp,nfft)
call fft4(ado_cmp,nfft)
cc = pasc_cmp * conjg(ado_cmp)
call ifft4(cc,nfft)
do i = 1,ngf
gf2(i) = real(cc(nfft-i+1))
enddo
call gplot(t(1:ngf),gf2,ylimit = '3',xlimit='6',output='gf2.ps')
! Single taper Spectral estimates
tbnw = 1.5
kspec = 1
call mtspec(ngf,dt,gf,tbnw,kspec,nf2,freq,spec)
call gplot(freq,spec,'hold',logxy='loglog')
call mtspec(ngf,dt,gf2,tbnw,kspec,nf2,freq,spec)
call gplot(freq,spec,logxy='loglog',output='gfspec.ps')
end program fig5
| gpl-2.0 |
SaberMod/GCC_SaberMod | gcc/testsuite/gfortran.dg/common_errors_1.f90 | 193 | 1080 | ! { dg-do compile }
! Tests a number of error messages relating to derived type objects
! in common blocks. Originally due to PR 33198
subroutine one
type a
sequence
integer :: i = 1
end type a
type(a) :: t ! { dg-error "Derived type variable .t. in COMMON at ... may not have default initializer" }
common /c/ t
end
subroutine first
type a
integer :: i
integer :: j
end type a
type(a) :: t ! { dg-error "Derived type variable .t. in COMMON at ... has neither the SEQUENCE nor the BIND.C. attribute" }
common /c/ t
end
subroutine prime
type a
sequence
integer, allocatable :: i(:)
integer :: j
end type a
type(a) :: t ! { dg-error "Derived type variable .t. in COMMON at ... has an ultimate component that is allocatable" }
common /c/ t
end
subroutine source
parameter(x=0.) ! { dg-error "COMMON block .x. at ... is used as PARAMETER at ..." }
common /x/ i ! { dg-error "COMMON block .x. at ... is used as PARAMETER at ..." }
intrinsic sin
common /sin/ j ! { dg-error "COMMON block .sin. at ... is also an intrinsic procedure" }
end subroutine source
| gpl-2.0 |
SaberMod/GCC_SaberMod | gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_trailz.f90 | 174 | 1541 | program test_intrinsic_trailz
implicit none
call test_trailz(0_1,0_2,0_4,0_8,1_1,1_2,1_4,1_8,8_1,8_2,8_4,8_8)
stop
contains
subroutine test_trailz(z1,z2,z4,z8,i1,i2,i4,i8,e1,e2,e4,e8)
integer(kind=1) :: z1, i1, e1
integer(kind=2) :: z2, i2, e2
integer(kind=4) :: z4, i4, e4
integer(kind=8) :: z8, i8, e8
if (trailz(0_1) /= 8) call abort()
if (trailz(0_2) /= 16) call abort()
if (trailz(0_4) /= 32) call abort()
if (trailz(0_8) /= 64) call abort()
if (trailz(1_1) /= 0) call abort()
if (trailz(1_2) /= 0) call abort()
if (trailz(1_4) /= 0) call abort()
if (trailz(1_8) /= 0) call abort()
if (trailz(8_1) /= 3) call abort()
if (trailz(8_2) /= 3) call abort()
if (trailz(8_4) /= 3) call abort()
if (trailz(8_8) /= 3) call abort()
if (trailz(z1) /= 8) call abort()
if (trailz(z2) /= 16) call abort()
if (trailz(z4) /= 32) call abort()
if (trailz(z8) /= 64) call abort()
if (trailz(i1) /= 0) call abort()
if (trailz(i2) /= 0) call abort()
if (trailz(i4) /= 0) call abort()
if (trailz(i8) /= 0) call abort()
if (trailz(e1) /= 3) call abort()
if (trailz(e2) /= 3) call abort()
if (trailz(e4) /= 3) call abort()
if (trailz(e8) /= 3) call abort()
end subroutine test_trailz
end program
| gpl-2.0 |
MALBECC/lio | lioamber/liomods/garcha_mod.f | 2 | 4421 | !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%!
module garcha_mod
implicit none
INCLUDE 'param.f'
integer natom,ntatom,NMAX,NCO,NUNP,igrid,igrid2
> ,Iexch,nsol,npas,npasw,watermod,noconverge,
> converge,ndiis,nang,propagator,NBCH
integer ex_functional_id, ec_functional_id
logical use_libxc
integer restart_freq, energy_freq
real*8 GOLD, TOLD
character*20 fcoord,fmulliken,frestart,frestartin,solv,solv2
logical MEMO,predcoef
logical OPEN,DIRECT,VCINP,DIIS
logical sol
logical primera,writexyz
logical writeforces
logical cubegen_only,cube_dens,cube_orb,cube_elec, cube_sqrt_orb
integer cube_res,cube_sel
character*20 cube_dens_file,cube_orb_file,cube_elec_file
real*8 e_(50,3),wang(50),e_2(116,3),wang2(116),e3(194,3), ! intg1 e intg2
> wang3(194) !
integer Nr(0:54),Nr2(0:54)
real*8, dimension (:,:), ALLOCATABLE :: r,v,rqm,d
real*8, dimension (:), ALLOCATABLE :: Em, Rm, pc
integer, dimension (:), ALLOCATABLE :: Iz
real*8 :: Rm2(0:54)
c Everything is dimensioned for 2 basis, normal and density
c ncf, lt,at,ct parameters for atomic basis sets
real*8, dimension (:), ALLOCATABLE :: Fmat_vec, Fmat_vec2,
> Pmat_vec, Hmat_vec, Ginv_vec, Gmat_vec, Pmat_en_wgt
real*8, dimension (:), ALLOCATABLE :: rhoalpha,rhobeta
real*8, dimension (:,:), ALLOCATABLE :: X
real*8 :: pi, pi32, rpi, pi5, pi52
real*8 :: piss, pis32, rpis, pis5, pis52
parameter(pi32=5.56832799683170698D0,pi=3.14159265358979312D0,
> rpi=1.77245385090551588D0, pi5=34.9868366552497108D0,
> pi52=34.9868366552497108D0)
parameter(pis32=5.56832799683170698E0,piss=3.14159265358979312E0,
> rpis=1.77245385090551588E0, pis5=34.9868366552497108E0,
> pis52=34.9868366552497108E0)
c Angular momenta : up to f functions ( could be easily extended if
c necessary)
! FFR - My global variables
!------------------------------------------------------------------------------!
real*8,allocatable,dimension(:,:) :: Smat
real*8,allocatable,dimension(:,:) :: RealRho
logical :: doing_ehrenfest=.false.
logical :: first_step
real*8,allocatable,dimension(:) :: atom_mass
real*8,allocatable,dimension(:,:) :: nucpos, nucvel
real*8 :: total_time
real*8,allocatable,dimension(:,:) :: qm_forces_ds
real*8,allocatable,dimension(:,:) :: qm_forces_total
!------------------------------------------------------------------------------!
!-Variables for hibrid damping-diis
logical :: hybrid_converg
double precision :: good_cut
double precision :: Etold
!-Variables for property calculations.
logical :: fukui, dipole, lowdin, mulliken, print_coeffs
integer :: nng, max_func
! GPU OPTIONS
logical :: assign_all_functions, remove_zero_weights,
> energy_all_iterations
real*8 :: free_global_memory, sphere_radius, little_cube_size
integer :: min_points_per_cube, max_function_exponent
! Energy contributions
real*8 :: Enucl
real*8,dimension(:) ,allocatable :: Eorbs, Eorbs_b
! need this for lowdin
real*8,dimension(:,:),allocatable :: sqsm
!-Variables for distance combination restrain
INTEGER :: number_restr, number_index
INTEGER, ALLOCATABLE, DIMENSION(:,:) :: restr_pairs
INTEGER, ALLOCATABLE, DIMENSION(:) :: restr_index
DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:) :: restr_k,restr_w,
> restr_r0
!-Debug. Activates check of NaN in Fock and Rho
Logical :: Dbug
integer :: timers
real*8, dimension (:,:), ALLOCATABLE :: MO_coef_at, MO_coef_at_b
!Geometry optimizations
logical :: steep !enables steepest decend algorithm
real*8 :: Force_cut, Energy_cut, minimzation_steep !energy and force convergence crit and initial steep
integer :: n_points ! number of points scaned for lineal search
integer :: n_min_steeps !number of optimization steps
integer :: charge, gpu_level=4
logical :: lineal_search !enable lineal search
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%!
end module
| gpl-2.0 |