text
stringlengths 12
986k
| repo_path
stringlengths 6
121
|
---|---|
! Copyright (c) 2014 Harvey Richardson
! All rights reserved.
!
! See the LICENSE file elsewhere in this distribution for the
! terms under which this software is made available.
module pm_lib
implicit none
public
private :: i64
private pm_init_counters
integer(selected_int_kind(9)),parameter :: i64=selected_int_kind(18)
! Make this consistent with the pm_lib.h declarations
enum, bind(c) :: pm_counter
enumerator :: PM_COUNTER_FRESHNESS
enumerator :: PM_COUNTER_POWER
enumerator :: PM_COUNTER_ENERGY
enumerator :: PM_COUNTER_ACCEL_POWER
enumerator :: PM_COUNTER_ACCEL_ENERGY
enumerator :: PM_COUNTER_STARTUP
enumerator :: PM_NCOUNTERS
enumerator :: PM_COUNTER_POWER_CAP
enumerator :: PM_COUNTER_ACCEL_POWER_CAP
end enum pm_counter
interface
subroutine pm_init_counters(n,counters) bind(c,name='pm_init_counters')
use, intrinsic :: iso_c_binding
integer(c_int),value :: n
integer(c_int),intent(in),optional :: counters(*)
end subroutine pm_init_counters
end interface
interface
subroutine pm_close() bind(c,name='pm_close')
end subroutine pm_close
end interface
interface
function pm_get_num_opencounters() &
& bind(c,name='pm_get_num_opencounters')
use, intrinsic :: iso_c_binding
integer(c_int) :: pm_get_num_opencounters
end function pm_get_num_opencounters
end interface
interface
function pm_get_freshness() bind(c,name='pm_get_freshness')
use, intrinsic :: iso_c_binding
integer(c_int) :: pm_get_freshness
end function pm_get_freshness
end interface
interface
function pm_get_power() bind(c,name='pm_get_power')
use, intrinsic :: iso_c_binding
integer(c_int) :: pm_get_power
end function pm_get_power
end interface
interface
function pm_get_power_cap() bind(c,name='pm_get_power_cap')
use, intrinsic :: iso_c_binding
integer(c_int) :: pm_get_power_cap
end function pm_get_power_cap
end interface
interface
function pm_get_energy() bind(c,name='pm_get_energy')
use, intrinsic :: iso_c_binding
integer(c_long_long) :: pm_get_energy
end function pm_get_energy
end interface
interface
function pm_get_accel_power() bind(c,name='pm_get_accel_power')
use, intrinsic :: iso_c_binding
integer(c_int) :: pm_get_accel_power
end function pm_get_accel_power
end interface
interface
function pm_get_accel_power_cap() bind(c,name='pm_get_accel_power_cap')
use, intrinsic :: iso_c_binding
integer(c_int) :: pm_get_accel_power_cap
end function pm_get_accel_power_cap
end interface
interface
function pm_get_accel_energy() bind(c,name='pm_get_accel_energy')
use, intrinsic :: iso_c_binding
integer(c_long_long) :: pm_get_accel_energy
end function pm_get_accel_energy
end interface
interface
function pm_get_startup() bind(c,name='pm_get_startup')
use, intrinsic :: iso_c_binding
integer(c_long_long) :: pm_get_startup
end function pm_get_startup
end interface
interface
function pm_get_open_counters() bind(c,name='pm_get_open_counters')
use, intrinsic :: iso_c_binding
integer(c_int) :: pm_get_open_counters
end function pm_get_open_counters
end interface
interface
function pm_get_counters_firstn(n,values,atomic) &
& bind(c,name='pm_get_counters_firstn')
use, intrinsic :: iso_c_binding
integer(c_int) :: pm_get_counters_firstn
integer(c_int),value :: n
integer(c_long_long) :: values(*)
integer(c_int),value :: atomic
end function pm_get_counters_firstn
end interface
interface
function pm_get_counters(n,counters,values,atomic) &
& bind(c,name='pm_get_counters')
use, intrinsic :: iso_c_binding
integer(c_int) :: pm_get_counters
integer(c_int),value :: n
integer(c_int), intent(in) :: counters(*)
integer(c_long_long), intent(out) :: values(*)
integer(c_int),value :: atomic
end function pm_get_counters
end interface
interface
function c_pm_get_counter_label(counter) &
& bind(c,name='pm_get_counter_label')
use, intrinsic :: iso_c_binding
integer(c_int), value :: counter
type(c_ptr) :: c_pm_get_counter_label
end function c_pm_get_counter_label
end interface
contains
subroutine pm_init(counters)
use, intrinsic :: iso_c_binding
implicit none
type(pm_counter),optional, intent(in) :: counters(:)
if (present(counters)) then
call pm_init_counters(size(counters),counters)
else
call pm_init_counters(0) ! optional matches null poinrter
end if
end subroutine pm_init
subroutine pm_get_counter_label(counter,label)
use, intrinsic :: iso_c_binding
implicit none
type(pm_counter), intent(in) :: counter
character*(*), intent(out) :: label
character(len=1),pointer, dimension(:) :: label_tmp
integer i,length
length=len(label)
label=''
call c_f_pointer(c_pm_get_counter_label(counter),label_tmp,[length])
do i=1,length
if (label_tmp(i)==C_NULL_CHAR) exit
label(i:i)=label_tmp(i)
end do
end subroutine pm_get_counter_label
end module pm_lib
| vendor/pmlib/pm_lib_interface.f90 |
subroutine tcspvec(ict,ivec,xvec,yvec,zvec,ivd,fval,
> nx,xpkg,ny,ypkg,nz,zpkg,fspl,inf4,inf5,
> iwarn,ier)
c
c vectorized spline evaluation routine -- 3d spline
c 1. call vectorized zone lookup routine
c 2. call vectorized spline evaluation routine
c
c--------------------------
c input:
integer ict(10) ! selector:
c ict(1)=1 for f (don't evaluate if ict(1)=0)
c ict(2)=1 for df/dx (don't evaluate if ict(2)=0)
c ict(3)=1 for df/dy (don't evaluate if ict(3)=0)
c ict(4)=1 for df/dy (don't evaluate if ict(4)=0)
c ict(5)=1 for d2f/dx2 (don't evaluate if ict(5)=0)
c ict(6)=1 for d2f/dy2 (don't evaluate if ict(6)=0)
c ict(7)=1 for d2f/dz2 (don't evaluate if ict(7)=0)
c ict(8)=1 for d2f/dxdy (don't evaluate if ict(8)=0)
c ict(9)=1 for d2f/dxdz (don't evaluate if ict(9)=0)
c ict(10)=1 for d2f/dydz (don't evaluate if ict(10)=0)
c
integer ivec ! vector dimensioning
c
c ivec-- number of vector pts (spline values to look up)
c
c list of (x,y,z) triples:
c
real xvec(ivec) ! x-locations at which to evaluate
real yvec(ivec) ! y-locations at which to evaluate
real zvec(ivec) ! z-locations at which to evaluate
c
integer ivd ! 1st dimension of output array
c
c ivd -- 1st dimension of fval, .ge.ivec
c
c output:
real fval(ivd,*) ! output array
c
c fval(1:ivec,1) -- values as per 1st non-zero ict(...) element
c fval(1:ivec,2) -- values as per 2nd non-zero ict(...) element
c --etc--
c
c input:
integer nx,ny,nz ! dimension of spline grids
real xpkg(nx,4) ! x grid "package" (cf genxpkg)
real ypkg(ny,4) ! y grid "package" (cf genxpkg)
real zpkg(nz,4) ! z grid "package" (cf genxpkg)
integer inf4 ! fspl 4th array dimension, .ge.nx
integer inf5 ! fspl 5th array dimension, .ge.ny
real fspl(4,4,4,inf4,inf5,nz) ! (non-compact) spline coefficients
c
c output:
c condition codes, 0 = normal return
integer iwarn ! =1 if an x value was out of range
integer ier ! =1 if argument error detected
c
c---------------------------------------------------------------
c local arrays
c
integer, dimension(:), allocatable :: ix,iy,iz
real, dimension(:), allocatable :: dxv,dyv,dzv
c
c---------------------------------------------------------------
c
c error checks
c
ier=0
c
if(nx.lt.2) then
write(6,*) ' ?tcspvec: nx.lt.2: nx = ',nx
ier=1
endif
c
if(ny.lt.2) then
write(6,*) ' ?tcspvec: ny.lt.2: ny = ',ny
ier=1
endif
c
if(nz.lt.2) then
write(6,*) ' ?tcspvec: nz.lt.2: nz = ',nz
ier=1
endif
c
if(ivec.le.0) then
write(6,*) ' ?tcspvec: vector dimension .le. 0: ivec = ',
> ivec
ier=1
endif
c
if(ivd.lt.ivec) then
write(6,*)
> ' ?tcspvec: output vector dimension less than input ',
> 'vector dimension.'
write(6,*) ' ivec=',ivec,' ivd=',ivd
ier=1
endif
c
if(ier.ne.0) return
c
allocate(ix(ivec), iy(ivec), iz(ivec),
> dxv(ivec), dyv(ivec), dzv(ivec), stat=ier)
c
if(ier.ne.0) then
write(6,*)
> ' ?tcspvec: memory allocation failure.'
ier=99
endif
c
if(ier.ne.0) return
c
c vectorized lookups
c
ix=0; iy=0; iz=0
call xlookup(ivec,xvec,nx,xpkg,1,ix,dxv,dxv,dxv,iwarn1)
call xlookup(ivec,yvec,ny,ypkg,1,iy,dyv,dyv,dyv,iwarn2)
call xlookup(ivec,zvec,nz,zpkg,1,iz,dzv,dzv,dzv,iwarn3)
iwarn=max(iwarn1,iwarn2,iwarn3)
c
c vectorized evaluation
c
call tcspevfn(ict,ivec,ivd,fval,ix,iy,iz,dxv,dyv,dzv,
> fspl,inf4,inf5,nz)
c
deallocate(ix,iy,iz,dxv,dyv,dzv)
c
return
end
| gfile_Bfield/PSPLINE/Pspline/tcspvec.f |
Located on the corner of Sutter and Riley in Old Folsom, this place rivals Zacharys Pizza for good Chicago Style Pizza.
This place not only serves Stuffed Crust AND Deep Dish Pizza, but also has Chicago style thin crust (really thin crispy crust) as well as great salads.
The prices are a little higher, but you burn less gas getting to Folsom than to Berkeley. The seating in more spacious as well. There are sizable waits on Friday and Saturday nights, but the rest of the time you can get seated quickly. Parking right near the Folsom restaurant can be rough because it is in old Folsom, and it shares a tiny parking lot with The Powerhouse Pub, but you can easily find a parking space within a few blocks.
Directions: Hwy 50 to Folsom Blvd. Exit. Go west into old Folsom. Exit right on Sutter St. contiune through the 1st stop light to 614 Sutter St.
If you dont want to trek out to Folsom, they will be opening a location in Midtown Sacramento Midtown this summer.
Reservation Policy: They accept reservations for parties of 8 or more on Sunday through Thursday only. Friday and Saturday reservations may be available either early or late into the evening. Please call for more info.
| lab/davisWiki/Chicago_Fire_Restaurant.f |
submodule (pathlib) envfun
implicit none (type, external)
contains
module procedure home
!! returns home directory, or empty string if not found
!!
!! https://en.wikipedia.org/wiki/Home_directory#Default_home_directory_per_operating_system
character(4096) :: buf
integer :: L, istat
call get_environment_variable("HOME", buf, length=L, status=istat)
if (L==0 .or. istat /= 0) then
call get_environment_variable("USERPROFILE", buf, length=L, status=istat)
endif
if (L==0 .or. istat /= 0) then
write(stderr,*) 'ERROR:pathlib:home: could not determine home directory from env variable'
if (istat==1) write(stderr,*) 'neither HOME or USERPROFILE env variable exists.'
home = ""
endif
home = trim(buf)
end procedure home
end submodule envfun
| src/envvar.f90 |
SUBROUTINE cescale(srces)
c This subroutine performs cmul and efield scaling, and calculates the
c dominant - diagonal scaling arrays.
C-----------------------------------------------
C M o d u l e s
C-----------------------------------------------
USE Vnamecl2
USE dkes_input, ONLY: lalpha, psip
USE dkes_realspace
IMPLICIT NONE
C-----------------------------------------------
C L o c a l P a r a m e t e r s
C-----------------------------------------------
INTEGER, PARAMETER :: l0 = 1, l1 = 2, l2 = 3, l3 = 4,
1 epar = 2, pgrad = 1, plus = 1, minus = 2
C-----------------------------------------------
C D u m m y A r g u m e n t s
C-----------------------------------------------
REAL(rprec), DIMENSION(mpnt,lsource,2,2), INTENT(out) :: srces
C-----------------------------------------------
C L o c a l V a r i a b l e s
C-----------------------------------------------
INTEGER :: mn
REAL(rprec) :: cmul2, eoc, e2oc, SQRT10, bmod
C-----------------------------------------------
SQRT10 = SQRT(10._dp)
IF (psip .ne. zero) THEN
weov = efield1/psip !!EXB drift frequency (normed to 1/v)
ELSE
weov = efield1/EPSILON(psip)
END IF
cmul2 = cmul1*cmul1
wcyclo = 9.58e7_dp * b00 !!b00 in [Tesla]
vthermi = 9.79e3_dp * SQRT(2._dp) * SQRT(1.e3_dp) !!vi for Ti=1keV, [m/s]
c Spitzer FUNCTION contribution to conductivity
c Note that fspitzer = qB/nu/SQRT(bsqav), S3 = qB*jacobian/SQRT(bsqav), so that
c g33s ~ INT(q**2)/nu * vp.
g33s = one/(cmul1*rt3o2**2) !!1./rt3o2**2 = 1/(2/3) from pitch integral of q**2
eoc = -efield1/cmul1
e2oc = -efield1*eoc
cols = cmul1*cols0(1:lalpha)
al1 = al01/cmul1
al2 = al02/cmul1
al3 = e2oc*al03
al4 = al04/cmul1
bl1 = eoc*bl01
bl2 = eoc*bl02
bl3 = eoc*bl03
bl4 = eoc*bl04
cl1 = cl01/cmul1
cl2 = cl02/cmul1
cl3 = cl03/cmul1
cl4 = cl04/cmul1
bmod = SQRT(bsqav)
s1cs1 = s1cs10/cols(l2)
c e-field dependent particle conservation matrix elements
diagle = 0
DO mn = 1,mpnt
diagle(mn,mn,1) = efield1*exbgrad(mn)
diagle(mn,mn,2) =-efield1*exbgrad(mn)
END DO
c itype = pgrad (density gradient sources)
srces(:,l1,pgrad,minus) = omgl(l2)*auxs1(:,1)/cols(l2)
srces(:,l2,pgrad,minus) = auxs1(:,2)*eoc/cols0(l2)
srces(:,l3,pgrad,minus) = omgl(l3)*auxs1(:,3)/cols(l2)
c itype = epar (parallel E-field sources)
srces(:,l1,epar,plus) = auxs3p(:,1)*eoc/bmod !!l=1 component of s3
srces(:,l2,epar,plus) = 3*omgl(l2)*auxs3p(:,2)/cmul1/bmod !!l=2 component of s3
srces(:,l1,epar,minus) = auxs3m(:)/bmod
END SUBROUTINE cescale
| DKES/Sources/General/cescale.f |
c ==================================================================================================================================
c current version: 4.0
c version 1.0(July 31th, 2013)
c version 2.0(August 23th,2013) works faster, some unnecessary caclulations removed
c version 3.0(September 5th,2014) handles extremely eccentric orbits, corrections
c done thanks to comments submitted by Zong-Fu,Sie NCU Taiwan
c version 4.0(July 30th,2017) removes important bug injected in version 3.0,
c corrections done thanks to comments submitted by
c Robert Jedicke,University of Hawaii
c--------------------------------
c This program calculates the MOID between two asteroids - Lutetia and Magdalena.
c It uses all ideas and solutions described with details in the paper by
c T.Wisniowski and H.Rickman "A Fast, Geometric Method for Calculating Accurate
c Minimum Orbit Intersection Distances (MOIDs)" published in 2013 in Acta Astronomica.
c The program is free and may be used without limits as the core of any other program.
c The authors will appreciate for mentioning them, when the program will appear to be useful.
c ==================================================================================================================================
real*8 function moid(saxisA,eccenA,argpeA,omegaA,incliA,saxisB,
a eccenB,argpeB,omegaB,incliB)
implicit real*8 (a-h,o-z), integer*4 (i-n)
real*8 longit,longit_m,longit_o,incliA,incliB !moid
logical aleft,aright,bleft,bright,calc1,calc2,calc3,calc4
c tables
real*8, dimension(3)::rAt,rBt,Axt,Ayt,Bxt,Byt,Bzt
real*8, dimension(10)::tmpmoid,tmptrueB,tmplongit
c....parameters of the program
ccc (these steps are optimized with respect to speed and reliability)
cstep=0.12d0 ! scanning step of true anomaly/longitude in radians
stepini=0.07d0 !initial step of first tuning in radians
steptresh=1E-5 !final step of first tunig (to choose the MOID) in radians
ccc (this step depends on expected final accuracy)
stepmin=1E-14 !threshold step of second tuning in radians
c....constants and given values
pi=3.141592653589793d0
twopi=2d0*pi
degrad=pi/180d0
c....orbital parameters of body A - asteroid Magdalena, angles in [deg]
! saxisA=3.1924186d0 !semiaxis [AU]
! eccenA=0.0843230d0 !eccenticity [deg]
! argpeA=298.98851d0 !argument of perihelion [deg]
! omegaA=161.64831d0 !longitude of ascending node [deg]
! incliA=10.64148d0 !inclination [deg]
c....orbital parameters of body B - asteroid Lutetia, angles in [deg]
! saxisB=2.4354656d0 !semiaxis [AU]
! eccenB=0.1629385d0 !eccenticity [deg]
! argpeB=250.36793d0 !argument of perihelion [deg]
! omegaB=80.89426d0 !longitude of ascending node [deg]
! incliB=3.06405d0 !inclination [deg]
ccccccccc START OF PREPARING THE ORBITS ccccccccccccccc
c....converting angles to [rad]
argpeA=argpeA*degrad
omegaA=omegaA*degrad
incliA=incliA*degrad
argpeB=argpeB*degrad
omegaB=omegaB*degrad
incliB=incliB*degrad
c....computing parameters of transition matrix c11...c33
c11=dcos(omegaA)*dcos(argpeA)-dsin(omegaA)*dcos(incliA)
a *dsin(argpeA)
c12=dsin(omegaA)*dcos(argpeA)+dcos(omegaA)*dcos(incliA)
a *dsin(argpeA)
c13=dsin(incliA)*dsin(argpeA)
c21=-dcos(omegaA)*dsin(argpeA)-dsin(omegaA)*dcos(incliA)
a *dcos(argpeA)
c22=-dsin(omegaA)*dsin(argpeA)+dcos(omegaA)*dcos(incliA)
a *dcos(argpeA)
c23=dsin(incliA)*dcos(argpeA)
c31=dsin(incliA)*dsin(omegaA)
c32=-dsin(incliA)*dcos(omegaA)
c33=dcos(incliA)
c....calculating new values of Euler angles using transition matrix
sintmpi=dsin(incliB)
costmpi=dcos(incliB)
costmpo=dcos(omegaB)
sintmpo=dsin(omegaB)
costmpa=dcos(argpeB)
sintmpa=dsin(argpeB)
x1=costmpo*costmpa-sintmpo*costmpi*sintmpa
x2=sintmpo*costmpa+costmpo*costmpi*sintmpa
x3=sintmpi*sintmpa
y1=-costmpo*sintmpa-sintmpo*costmpi*costmpa
y2=-sintmpo*sintmpa+costmpo*costmpi*costmpa
y3=sintmpi*costmpa
z1=sintmpi*sintmpo
z2=-sintmpi*costmpo
z3=costmpi
z1n=c11*z1+c12*z2+c13*z3
z2n=c21*z1+c22*z2+c23*z3
z3n=c31*z1+c32*z2+c33*z3
y3n=c31*y1+c32*y2+c33*y3
x3n=c31*x1+c32*x2+c33*x3
incliB=datan2(dsqrt(z1n*z1n+z2n*z2n),z3n)
omegaB=-datan2(z1n,-z2n)
argpeB=-datan2(x3n,y3n)
c....helpful precalculated values
costmpo=dcos(omegaB)
sintmpo=dsin(omegaB)
sintmpi=dsin(incliB) !=z1n/sintmpo
costmpi=z3n !=dcos(incliB)
sint=sintmpo*costmpi
cost=costmpo*costmpi
radA=saxisA*(1d0-eccenA*eccenA)
radB=saxisB*(1d0-eccenB*eccenB)
ccccccccc END OF PREPARING THE ORBITS ccccccccccccccc
ccccccccc START OF SCANNING ccccccccccccccccccccccccc
ccc This tool yields a preliminary approach to the minima of the distance function.
ccc By scanning one full revolution of meridional plane we look for the local minima.
c......initial parameters
trueB=-2d0*cstep
moid=1E6;dist_o=1E6 !something big
tmpmoid(1)=1E6;tmpmoid(2)=1E6
tmpmoid(3)=1E6;tmpmoid(4)=1E6
iii1=0;jjj1=0
c.....Looking for the minima with rotating meridional plane
c.......a)at first we calculate the coordinates of two additional positions of the plane to create first triplet
do 307 iii=1,2
rB=radB/(1d0+eccenB*dcos(trueB))!compute the radius for B
sintmp=dsin(trueB+argpeB)
costmp=dcos(trueB+argpeB)
Bz_sq=sintmpi*sintmp
Bz_sq=Bz_sq*Bz_sq !square of Z-coordinate for B
longit=datan2(sintmpo*costmp+sintmp*cost,
a costmpo*costmp-sintmp*sint) !compute the longitude for A
tmp2=eccenA*dcos(longit) !temporary value
rA=radA/(1d0+tmp2) !compute the radius for A (two possibilities)
rA2=radA/(1d0-tmp2)
tmp1=rB*dsqrt(1d0-Bz_sq) !temporary value
if (dabs(tmp1-rA)>dabs(tmp1+rA2)) then
rA=rA2
longit=longit-pi !the second possibility gives smaller distance
tmp1=tmp1+rA2
else
tmp1=tmp1-rA
endif
dist=rB*rB*Bz_sq+tmp1*tmp1 !square of the distance A-B
if (iii.eq.1) then
dist_oo=dist
else
dist_o=dist
trueB_o=trueB
longit_o=longit
endif
trueB=trueB+cstep
307 continue
c.......b)now we scan doing one full revolution of the meridional plane
nmax=0 !counts the minima
dist_min=dist
do while (trueB<(twopi+cstep)) !loop for true anomaly of B
rB=radB/(1d0+eccenB*dcos(trueB))!compute the radius for B
sintmp=dsin(trueB+argpeB)
costmp=dcos(trueB+argpeB)
Bz_sq=sintmpi*sintmp
Bz_sq=Bz_sq*Bz_sq !square of Z-coordinate for B
longit=datan2(sintmpo*costmp+sintmp*cost,
a costmpo*costmp-sintmp*sint) !compute the longitude for A
tmp2=eccenA*dcos(longit) !temporary value
rA=radA/(1d0+tmp2) !compute the radius for A (two possibilities)
rA2=radA/(1d0-tmp2)
tmp1=rB*dsqrt(1d0-Bz_sq) !temporary value
if (dabs(tmp1-rA)>dabs(tmp1+rA2)) then
rA=rA2
longit=longit-pi !the second possibility gives smaller distance
tmp1=tmp1+rA2
else
tmp1=tmp1-rA
endif
dist=rB*rB*Bz_sq+tmp1*tmp1 !square of the distance A-B
if ((dist_o<=dist).and.(dist_o<=dist_oo)) then !the minimum was found
nmax=nmax+1
tmptrueB(nmax)=trueB_o
tmplongit(nmax)=longit_o
tmpmoid(nmax)=dist_o
endif
if (dist_min>dist) dist_min=dist
dist_oo=dist_o
trueB_o=trueB
longit_o=longit
dist_o=dist
trueB=trueB+cstep
end do
ccccccccc END OF SCANNING ccccccccccccccccccccccccc
ccc "WATER" PROCEDURE cccccccccccccccccccccccccccccccccc
ccc In case only one minimum is detected we take a special care
ccc to avoid the risk of missing the minima.
ccc Instead of starting the tuning with one detected minimum,
ccc we start it with four positions of the meridional plane, evenly
ccc distributed along the inclined orbit. The later tuning procedure
ccc moves the points along the orbits similarly as water droplets
ccc are leading by the gravity to the points of minimum height � so
ccc we called this phase �water procedure�. It slightly slows down
ccc the calculations, but minimizes the risk of missing the MOID.
ccc With "water procedure" the speed is 9-12 seconds per 100,000 MOIDs, risk of missing <1E-6
ccc Without "water procedure" the speed is <9 seconds per 100,000 MOIDs, risk of missing about 3E-5
ccc (speed measured on fast single CPU core)
!goto 510 !if this jump is active - the water procedure is switched off
405 if (nmax<2) then !only one minimum was detected
nmax=4
do 407 iii=1,4
tmptrueB(iii)=(.25+.5*iii)*pi !evenly distributed points
sintmp=dsin(tmptrueB(iii)+argpeB)
costmp=dcos(tmptrueB(iii)+argpeB)
tmplongit(iii)=datan2(sintmpo*costmp+sintmp*cost,
a costmpo*costmp-sintmp*sint) !compute the longitude for A
tmpmoid(iii)=1E6 !something big
407 continue
endif
cccccc END OF "WATER" PROCEDURE ccccccccccccccccccccccccc
cccccc START OF PARALLEL TUNING ccccccccccccccccccccccc
ccc After the scanning phase, we typically have a few minima on a meridional plane.
ccc The goal of the tuning procedure is to move objects separately along their orbits
ccc in order to find the smallest possible distance between them, which is no longer a meridional distance.
510 do 615 jjj=1,nmax+1
if (jjj.le.nmax) then
moid=tmpmoid(jjj)
trueB_m=tmptrueB(jjj)
longit_m=tmplongit(jjj)
step=stepini
threshold=steptresh
else
if (nmax.eq.2) then
if (dabs(tmpmoid(1)-tmpmoid(2)).lt.1E-4) then
ccc in case of two minima are very close to each other(<1E-4 a.u.) go to "water procedure"
nmax=1
goto 405
else
if (tmpmoid(1)<moid) then
moid=tmpmoid(1)
trueB_m=tmptrueB(1)
longit_m=tmplongit(1)
endif
endif
else
do 634 iii=1,nmax-1 !the choice of moids for final tuning
if (tmpmoid(iii)<moid) then
moid=tmpmoid(iii)
trueB_m=tmptrueB(iii)
longit_m=tmplongit(iii)
endif
634 continue
endif
step=2d0*stepini !initial step for final tuning
threshold=stepmin !terminal step for final tuning
endif
rBt(2)=radB/(1d0+eccenB*dcos(trueB_m))
sintmp=dsin(trueB_m+argpeB)
costmp=dcos(trueB_m+argpeB)
Bxt(2)=costmpo*costmp-sintmp*sint
Byt(2)=sintmpo*costmp+sintmp*cost
Bzt(2)=sintmpi*sintmp
rAt(2)=radA/(1d0+eccenA*dcos(longit_m))
Axt(2)=dcos(longit_m)
Ayt(2)=dsin(longit_m)
aleft=.true.;aright=.true.;bleft=.true.;bright=.true.
do while (step>=threshold)
lpoints=0
j1min=1;j1max=3
i1min=1;i1max=3
calc1=.false.;calc2=.false.
calc3=.false.;calc4=.false.
if (bleft) then
rBt(1)=radB/(1d0+eccenB*dcos(trueB_m-step))
sintmp=dsin(trueB_m-step+argpeB)
costmp=dcos(trueB_m-step+argpeB)
Bxt(1)=costmpo*costmp-sintmp*sint
Byt(1)=sintmpo*costmp+sintmp*cost
Bzt(1)=sintmpi*sintmp
lpoints=lpoints+1
endif
if (bright) then
rBt(3)=radB/(1d0+eccenB*dcos(trueB_m+step))
sintmp=dsin(trueB_m+step+argpeB)
costmp=dcos(trueB_m+step+argpeB)
Bxt(3)=costmpo*costmp-sintmp*sint
Byt(3)=sintmpo*costmp+sintmp*cost
Bzt(3)=sintmpi*sintmp
lpoints=lpoints+1
endif
if (aleft) then
rAt(1)=radA/(1d0+eccenA*dcos(longit_m-step))
Axt(1)=dcos(longit_m-step)
Ayt(1)=dsin(longit_m-step)
lpoints=lpoints+1
endif
if (aright) then
rAt(3)=radA/(1d0+eccenA*dcos(longit_m+step))
Axt(3)=dcos(longit_m+step)
Ayt(3)=dsin(longit_m+step)
lpoints=lpoints+1
endif
j1_t=2;i1_t=2
if (lpoints.eq.1) then
if (aleft) i1max=1
if (aright) i1min=3
if (bleft) j1max=1
if (bright) j1min=3
endif
if (lpoints.eq.2) then
if (aleft.and.bright) calc1=.true.
if (aleft.and.bleft) calc2=.true.
if (aright.and.bright) calc3=.true.
if (aright.and.bleft) calc4=.true.
endif
do 557 j1=j1min,j1max
do 555 i1=i1min,i1max
if (lpoints.eq.2) then
if (i1.ne.1) then
if (((j1.ne.3).and.calc1)
a .or.((j1.ne.1).and.calc2)) goto 555
endif
if (i1.ne.3) then
if (((j1.ne.3).and.calc3)
a .or.((j1.ne.1).and.calc4)) goto 555
endif
endif
if ((i1.eq.2).and.(j1.eq.2)) goto 555
Dx=rBt(j1)*Bxt(j1)-rAt(i1)*Axt(i1)
Dy=rBt(j1)*Byt(j1)-rAt(i1)*Ayt(i1)
Dz=rBt(j1)*Bzt(j1)
dist=(Dx*Dx+Dy*Dy+Dz*Dz)
if (dist<moid) then
moid=dist
j1_t=j1;i1_t=i1
endif
555 continue
557 continue
if ((j1_t.ne.2).or.(i1_t.ne.2)) then
aleft=.false.;aright=.false.;bleft=.false.;bright=.false.
if (i1_t.ne.2) then
if (i1_t.eq.1) then
aleft=.true.
longit_m=longit_m-step
rAt(3)=rAt(2);Axt(3)=Axt(2);Ayt(3)=Ayt(2)
rAt(2)=rAt(1);Axt(2)=Axt(1);Ayt(2)=Ayt(1)
else
aright=.true.
longit_m=longit_m+step
rAt(1)=rAt(2);Axt(1)=Axt(2);Ayt(1)=Ayt(2)
rAt(2)=rAt(3);Axt(2)=Axt(3);Ayt(2)=Ayt(3)
endif
endif
if (j1_t.ne.2) then
if (j1_t.eq.1) then
bleft=.true.
trueB_m=trueB_m-step
rBt(3)=rBt(2);Bxt(3)=Bxt(2);Byt(3)=Byt(2);Bzt(3)=Bzt(2)
rBt(2)=rBt(1);Bxt(2)=Bxt(1);Byt(2)=Byt(1);Bzt(2)=Bzt(1)
else
bright=.true.
trueB_m=trueB_m+step
rBt(1)=rBt(2);Bxt(1)=Bxt(2);Byt(1)=Byt(2);Bzt(1)=Bzt(2)
rBt(2)=rBt(3);Bxt(2)=Bxt(3);Byt(2)=Byt(3);Bzt(2)=Bzt(3)
endif
endif
else
aleft=.true.;aright=.true.;bleft=.true.;bright=.true.
step=step*.15 !.15 is optimal value
endif
end do
if (jjj.le.nmax) then
tmpmoid(jjj)=moid
tmptrueB(jjj)=trueB_m
tmplongit(jjj)=longit_m
endif
615 continue
cccccc END OF PARALLEL TUNING ccccccccccccccccccccccc
moid=dsqrt(moid) !we dealed with squares
!write (*,*) 'MOID [AU] =', moid
END
| deps/moid_v4_fun.f |
C Copyright(C) 1999-2020 National Technology & Engineering Solutions
C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
C NTESS, the U.S. Government retains certain rights in this software.
C
C See packages/seacas/LICENSE for details
C=======================================================================
SUBROUTINE WRMAP (NTXT, OPTION, NUMNP, NUMEL,
& NPMAP, ELMAP, MAPEL)
C=======================================================================
C --*** WRMAP *** (EXOTXT) Write database node number map,
C -- element number map, and/or element order map
C -- Written by Amy Gilkey - revised 02/27/86
C -- Modified for ExodusIIv2 - 10/24/95
C --
C --Parameters:
C -- NTXT - IN - the database text file
C -- OPTION - IN - '*' write all
C -- 'N' write node number map
C -- 'E' write element number map
C -- 'O' write element order map
C -- NUMNP - IN - number of nodes
C -- NUMEL - IN - number of elements
C -- NPMAP - IN - node number map (if OPTION)
C -- ELMAP - IN - element number map (if OPTION)
C -- MAPEL - IN - element order map (if OPTION)
INTEGER NTXT
CHARACTER*(*) OPTION
INTEGER NUMNP
INTEGER NUMEL
INTEGER NPMAP(*)
INTEGER ELMAP(*)
INTEGER MAPEL(*)
LOGICAL ALL, NOPT, EOPT, OOPT
LOGICAL INORDR
ALL = (OPTION .EQ. '*')
NOPT = (INDEX (OPTION, 'N') .GT. 0)
EOPT = (INDEX (OPTION, 'E') .GT. 0)
OOPT = (INDEX (OPTION, 'O') .GT. 0)
C Write node number map
IF (ALL .OR. NOPT) THEN
WRITE (NTXT, 1000) '! Node number map'
if (inordr(npmap, numnp)) then
write (ntxt, 1000) 'sequence 1..numnp'
else
write (ntxt, 1000) 'explicit map'
WRITE (NTXT, 1010) (NPMAP(I), I = 1, NUMNP)
end if
END IF
C Write element number map
IF (ALL .OR. EOPT) THEN
WRITE (NTXT, 1000) '! Element number map'
if (inordr(elmap, numel)) then
write (ntxt, 1000) 'sequence 1..numel'
else
write (ntxt, 1000) 'explicit map'
WRITE (NTXT, 1010) (ELMAP(I), I = 1, NUMEL)
end if
END IF
C Write element order map
IF (ALL .OR. OOPT) THEN
WRITE (NTXT, 1000) '! Element order map'
if (inordr(mapel, numel)) then
write (ntxt, 1000) 'sequence 1..numel'
else
write (ntxt, 1000) 'explicit map'
WRITE (NTXT, 1010) (MAPEL(I), I = 1, NUMEL)
end if
END IF
1000 FORMAT (A)
1010 FORMAT (8I10)
RETURN
END
C=======================================================================
logical function inordr(MAP, ISIZE)
C=======================================================================
C ... Determine if the passed in map is simply a sequence from 1..isize
integer map(isize)
inordr = .FALSE.
do 10 i=1, isize
if (map(i) .ne. i) then
inordr = .FALSE.
return
end if
10 continue
inordr = .TRUE.
return
end
| packages/seacas/applications/exotxt/et_wrmap.f |
C @(#)swpkal.f 20.3 2/13/96
subroutine swpkal(m,n)
include 'ipfinc/parametr.inc'
include 'ipfinc/area.inc'
include 'ipfinc/sort.inc'
itemp=kaloc(m)
kaloc(m)=kaloc(n)
kaloc(n)=itemp
itemp=nsysno(m)
nsysno(m)=nsysno(n)
nsysno(n)=itemp
return
end
| ipf/swpkal.f |
real(rk), parameter :: external_points(3, 0) = reshape((/ /), (/ 3, 0 /))
real(rk), parameter :: external_energy = 0.0_rk
| legacy/include/icosahedron.f90 |
module type_operator_wrapper
use type_operator, only: operator_t
implicit none
!> Wrapper for storing an array of dynamic equationset_t allocations.
!!
!! @author Nathan A. Wukie(AFRL)
!! @date 8/29/2016
!!
!!
!----------------------------------------------------------------------------
type, public :: operator_wrapper_t
class(operator_t), allocatable :: op
end type operator_wrapper_t
!*****************************************************************************
end module type_operator_wrapper
| src/equations/type_operator_wrapper.f90 |
SUBROUTINE DATEISO( CUR_DATE )
!***********************************************************************
!* Returns the Current Date in the ISO Format: YYYY/MM/DD
!*
!* Language: Fortran
!*
!* Author: Stuart G. Mentzer
!* Andrew Orndorff
!*
!* Date: 2004/10/25
!***********************************************************************
! Arguments ______________________________________________________
CHARACTER*(*) CUR_DATE ! Current date string returned (LEN >= 10)
! Variables ______________________________________________________
CHARACTER DATE_STR*8
! Initialize the date string
CALL DATE_AND_TIME( DATE=DATE_STR )
CUR_DATE = DATE_STR(1:4)//'/'//DATE_STR(5:6)//'/'//DATE_STR(7:8)
RETURN
END
| src/lib/dateiso.for |
Describe Users/DezareeFinch here.
20080611 21:24:11 nbsp Welcome to the Wiki. See Counselors and Therapists. Users/JasonAller
20080611 21:52:32 nbsp Theres usually some discussion about adding items to Explore. If not kept in check, itd be overwhelming. You can discuss additions on the explore sandbox page, but keep in mind that usually only mature pages with lots of links usually are put there. Users/PhilipNeustrom
| lab/davisWiki/DezareeFinch.f |
#redirect Marvin Zamora
| lab/davisWiki/MarvinZamora.f |
SUBROUTINE outdyn(inicia, foutp, ecdis )
!***********************************************************************
!
!** output routine
!
!***********************************************************************
USE ctrl_db,ONLY: ifunc, ifixd, istep, numct, ndime, ndofn, nrotd, &
neulr, nload, npoin, dtime, ttime, xbase, &
begtm, neq , therm , tscal , itemp, ndoft
USE kinc_db, ONLY : nvelr,nn,velor,npsdf,nesdf,ftsdf,nsdof !,sldvl
USE lispa0
USE npo_db, ONLY : label,coord,coora,ifpre,resid,fcont,force,euler,velnp, &
veloc,acelr,ymass,naeul,ddisp,psia,tempe
USE outp_db
USE c_input, ONLY: del_old_files
USE gvar_db, ONLY : static
IMPLICIT NONE
!--- Dummy variables
LOGICAL,INTENT(IN):: foutp, & ! .TRUE. write compulsory
inicia ! .TRUE. first call, write initial values
INTEGER(kind=4),INTENT(IN):: ecdis !internal equation number controlling output
!--- Function
REAL(kind=8):: functs !time function
!--- Local varibles
INTEGER(kind=4):: ipoin,ireq,idofn,ieq,iq,ib,ie,i,j,k,nv1,npt
REAL(kind=8):: velcr,cinet,poter,toler,time1,cputm,auxil,enkint, &
enkinr,fract,tdisp,tstra,value,angls(3),rm(3,3),fac
LOGICAL:: b1,b2
! auxiliar arrays to write down information
REAL(kind=8),ALLOCATABLE :: disp1(:,:),velo1(:,:),acce1(:,:), disp3(:,:)
REAL(kind=8),SAVE:: oldt1=0d0
TYPE (slave_list), POINTER :: sl_d
INTERFACE
INCLUDE 'angeul.h'
INCLUDE 'elemnt.h'
INCLUDE 'contac.h'
END INTERFACE
IF( lastst .AND. .NOT.foutp )THEN
lastst = .FALSE.
RETURN
END IF
! first determine if OUTPUT must be done at this step
nv1 = nvelr+1 !last position in array of prescribed velocities
CALL timuse(cputm) !present CPU time
cputm = cputm-cpui !elapsed CPU time since the beginning of the process
npt = INT(toutp(1)) !number of points defining output period
! initializes flags
b1 = .FALSE. !output at selected points
b2 = .FALSE. !global output
IF (ecdis < 0) THEN
!POSTYPE = 'C' curve control (curve number = -ECDIS)
value = functs(-ecdis,ttime) !present associated function value
auxil = functs(-ecdis,ttime+dtime) !next step function value
toler = (auxil-value)*(1.0000000001d0)/2d0 !tolerance
!for Selected points (History)
time1 = MODULO(value,toutd) !rest of the divition
IF(time1+toler > toutd .OR. time1 < toler) b1 = .TRUE. !output at selected points
!for global output (GiD or TecPlot)
IF (npt == 1) THEN !only one value
auxil = toutp(2) != PERIOD
time1 = MODULO(value,auxil) !rest of the divition
IF (time1+toler > auxil .OR. time1 < toler) b2 = .TRUE. !global output
ELSE !multiple value definition
DO i=1,npt !compare each value
auxil = toutp(i+1) !time
time1 = value-auxil !difference
IF (ABS(time1) < toler) b2 = .TRUE. !Global OUTPUT selected
END DO
END IF
ELSE IF(ecdis > 10)THEN
!POSTYPE = 'D' displacemente control
ipoin = ecdis/10 !node (internal)
idofn = MOD(ecdis,10) !DOFs
ieq = ifpre(idofn,ipoin) !associated equation
tdisp = ABS( coora(idofn,ipoin) - coord(idofn,ipoin) ) !total displacement
IF(ieq > 0)THEN !an active DOF
IF( static )THEN
toler = ABS(ddisp(ieq))*(1.2d0)/2d0 !tolerance
ELSE
toler = dtime*ABS(veloc(ieq))*(1.050000d0)/2d0 !tolerance
END IF
ELSE IF(ieq < -nn )THEN !a prescribed DOF
toler = dtime*ABS(velor(-ieq-nn,nv1))*(1.010000d0)/2d0
ELSE IF(ieq < 0 .AND. ieq > -nn)THEN !a slave DOF
ib = npsdf(-ieq) !first Master
ie = npsdf(-ieq+1)-1 !last Master
auxil = 0d0 !initializes
DO i = ib,ie !loop to compute velocity
iq = nesdf(i) !associated equation of master DOF
IF (iq > 0) THEN !if a Active DOF
IF( static )THEN
auxil = auxil + ddisp(iq)*ftsdf(i)
ELSE
auxil = auxil + veloc(iq)*ftsdf(i)
END IF
ELSE IF (iq < -nn) THEN !if a Prescribed DOF
auxil = auxil + velor(-iq-nn,nv1)*ftsdf(i)
END IF
END DO
toler = dtime*auxil*(1.050000d0)/2d0 !tolerance
ELSE !ieq == 0 (no associated DOF)
toler = 0d-0 !this should not happen
END IF
!for selected points (History)
time1 = MODULO(tdisp,toutd) !rest of the division
IF (time1+toler > toutd .OR. time1 < toler )THEN
IF( static ) THEN
b1 = .TRUE.
ELSE
IF( ABS((tdisp-oldt1)/toutd) > 0.5d0) b1 = .TRUE.
END IF
END IF
IF( b1 ) oldt1 = tdisp !keep last value
!for Global Output (GiD or TecPlot)
IF (npt == 1) THEN
auxil = toutp(2)
time1 = MODULO(tdisp,auxil)
IF(time1+toler > auxil .OR. time1 < toler) b2 = .TRUE.
ELSE
DO i=1,npt
auxil = toutp(i+1)
time1 = tdisp-auxil
IF(ABS(time1) < toler) b2 = .TRUE.
END DO
END IF
value = tdisp
ELSE
!POSTYPE = 'T' for time control
toler = dtime*(1.0001d0)/2d0 !half the incremental time
!for selected points (History)
time1 = MODULO(ttime,toutd) !rest of the division
IF (time1+toler > toutd .OR. time1 < toler )THEN !
IF( static )THEN
b1 = .TRUE.
ELSE
IF( ABS((ttime-oldt1)/toutd) > 0.5d0) b1 = .TRUE.
END IF
END IF
IF( b1 ) oldt1 = ttime
!for global output (GiD or TecPlot)
IF(npt == 1)THEN
auxil = toutp(2)
time1 = MODULO(ttime,auxil)
IF(time1+toler > auxil .OR. time1 < toler) b2 = .TRUE.
ELSE
DO i=1,npt
auxil = toutp(i+1)
time1 = ttime-auxil
IF(ABS(time1) < toler) b2 = .TRUE.
END DO
END IF
value = ttime
END IF
IF( foutp .OR. inicia) b1 = .TRUE. !output compulsory of initial values
IF( foutp ) b2 = .TRUE. !output compulsory
!*** OUTPUT FOR SELECTED VALUES
IF(b1)THEN
! D I S P L A C E M E N T S
IF(nreqd > 0) THEN
ALLOCATE ( disp1(ndofn,nreqd) )
DO ireq = 1,nreqd
ipoin = nprqd(ireq)
DO idofn = 1,ndime
disp1(idofn,ireq) = (coora(idofn,ipoin)-coord(idofn,ipoin))
END DO
! for local systems
IF(neulr > 0) THEN
IF(ndime == 2) THEN !2-D problems (1 DOF)
disp1(ndofn,ireq) = euler(1,ipoin) !present angle
ELSE !3-D problems (3 DOFs)
rm = RESHAPE( euler(1:9,ipoin),(/3,3/)) !rotation matrix
angls = 0d0 !angles
CALL angeul(rm,angls,.TRUE.) !returns Euler angles (in rads)
disp1(ndime+1:nrotd,ireq) = angls(1:nrotd-ndime)
END IF
END IF
IF( ndofn == 8 )disp1(7:8,ireq) = psia(:,ipoin)
END DO
WRITE(11,ERR=9999) value,((disp1(i,ireq),i=1,ndofn),ireq=1,nreqd)
DEALLOCATE ( disp1 )
END IF
IF( .NOT.static )THEN
! V E L O C I T I E S
IF(nreqv > 0) THEN
ALLOCATE ( velo1(ndofn,nreqv) )
DO ireq = 1,nreqv
ipoin = nprqv(ireq)
DO idofn = 1,ndofn
ieq = ifpre(idofn,ipoin)
IF(ieq > 0 )THEN !active DOFs
velo1(idofn,ireq) = veloc(ieq)
ELSE IF(ieq < -nn)THEN !fixed DOFs
velo1(idofn,ireq) = velor(-ieq-nn,nv1)
ELSE IF(ieq < 0 .AND. ieq > -nn)THEN !slave DOFs
ib = npsdf(-ieq)
ie = npsdf(-ieq+1)-1
auxil = 0d0
DO i = ib,ie
iq = nesdf(i)
IF(iq > 0)THEN
auxil = auxil + veloc(iq)*ftsdf(i)
ELSE IF(iq < -nn)THEN
auxil = auxil + velor(-iq-nn,nv1)*ftsdf(i)
END IF
END DO
velo1(idofn,ireq) = auxil
ELSE
velo1(idofn,ireq) = 0d0 !non-existent DOFs
END IF
END DO
END DO
WRITE(19,ERR=9999) value,((velo1(i,ireq),i=1,ndofn),ireq=1,nreqv)
DEALLOCATE ( velo1 )
END IF
! A C C E L E R A T I O N S
IF(nreqa > 0) THEN
ALLOCATE ( acce1(ndofn,nreqa) )
DO ireq = 1,nreqa
ipoin = nprqa(ireq)
DO idofn = 1,ndofn
ieq = ifpre(idofn,ipoin)
IF(ieq > 0 )THEN !active DOFs
acce1(idofn,ireq) = acelr(ieq)
ELSE
acce1(idofn,ireq) = 0d0 !otherwise 0
END IF
END DO
END DO
WRITE(20,ERR=9999) value,((acce1(i,ireq),i=1,ndofn),ireq=1,nreqa)
DEALLOCATE ( acce1 )
END IF
END IF
! N O D A L E Q U I V A L E N T F O R C E S
IF(nreql > 0) THEN
res = resid(:,nprql(1:nreql)) !direct contributions
!write(58,"(3e15.5)")resid(1:3,365:377)
!search for slave dependencies
IF( nsdof > 0 )THEN
sl_d => sl_head
DO ipoin=1,nreql
DO idofn=1,ndofn
DO i=1,sl_d%nvalues
j = sl_d%deps(1,i)
k = sl_d%deps(2,i)
ib = sl_d%deps(3,i)
res(idofn,ipoin) = res(idofn,ipoin) + ftsdf(ib)*resid(j,k)
!IF( idofn == 6 ) WRITE(58,"(3i5,3e15.5)")k,j,ib,ftsdf(ib),resid(j,k),ftsdf(ib)*resid(j,k)
END DO
!IF( idofn == 6 ) WRITE(58,"(3e15.5)")(ftsdf(sl_d%deps(3,i)),i=1,39)
sl_d => sl_d%next
END DO
END DO
END IF
WRITE(12,ERR=9999) value,res(1:ndofn,1:nreql)
END IF
! N O D A L C O N T A C T F O R C E S
IF(numct > 0 .AND. nreqc > 0) WRITE(14,ERR=9999) value,fcont(1:ndime,nprqc(1:nreqc))
! P A I R S C O N T A C T F O R C E S
IF(numct > 0) CALL contac('OUTDY1',0, ttime=value, dtcal = dtime)
! E N E R G Y V A L U E S
IF(iener /= 0 .AND. .NOT.static) THEN
cinet = 0d0
IF(nvelr > 0)THEN
DO ieq = 1,neq
cinet = cinet + veloc(ieq)**2/ymass(ieq)
END DO
END IF
poter = 0d0
enkint=0.
DO ipoin=1,npoin
DO idofn=1,ndime
ieq = ifpre(idofn,ipoin)
IF(ieq > 0)THEN
tdisp = coora(idofn,ipoin) - coord(idofn,ipoin)
IF(nload > 0)poter = poter +tdisp*force(ieq,nload+1)
enkint= enkint+veloc(ieq)**2/ymass(ieq)
END IF
END DO
END DO
IF(neulr > 0)THEN
enkinr = cinet - enkint
ELSE
enkinr = 0d0
cinet = enkint
END IF
velcr = SQRT(enkint/sumat)
enkint = 0.5*enkint
enkinr = 0.5*enkinr
cinet = 0.5*cinet
fract = 0.
IF (energ(2)+cinet-energ(3).ne.0.) fract=1d0-energ(1)/(energ(2)+cinet-energ(3))
WRITE(15,ERR=9999) value,cinet,velcr,dtime,enkint,enkinr, &
energ(1),energ(2),fract,cinet-energ(3),energ(5),poter
!WRITE(55,"(' Time=',e12.4,' Kin. E=',e12.5,' Pot. E=',e12.5)",ERR=9999) ttime,cinet,poter
END IF
! volume & pressure of volume dependent follower loads
CALL wrtfl1 (ttime)
! T E M P E R A T U R E S
IF(nreqT > 0) THEN
ALLOCATE ( disp1(ndoft,nreqt) )
DO ireq = 1,nreqt
ipoin = nprqt(ireq)
DO idofn = 1,ndoft
disp1(idofn,ireq) = tempe(idofn,ipoin)
END DO
END DO
WRITE(70,ERR=9999) value,((disp1(i,ireq),i=1,ndoft),ireq=1,nreqt)
DEALLOCATE ( disp1 )
END IF
END IF
!*** GLOBAL OUTPUT
IF( .NOT. static) lastst = b2
IF( b2 )THEN
!message in .RSN file, if IWRIT == 1, results are printed to ASCII file
WRITE(lures,"(5x,//'Results are reported for postprocess at:',/, &
10x,'Istep= ',i8,5x,'Ttime= ',e15.7,/)",ERR=9999) istep,ttime
WRITE(17,ERR=9999) istep,value,postype !heading
IF (ifunc==0)WRITE(17,ERR=9999) xbase(1:3) !ground acc, vel & disp
!** Total Displacements
DO ipoin = 1,npoin
WRITE(17,ERR=9999) (coora(1:ndime,ipoin) - coord(1:ndime,ipoin))
END DO
! for local systems
IF(neulr > 0) THEN
fac = 45d0/ATAN(1d0)
IF(ndime == 2) THEN !2-D problems (1 DOF)
DO ipoin = 1,npoin
WRITE(17,ERR=9999) euler(1,ipoin) !present angle
END DO
ELSE !3-D problems (3 DOFs)
DO ipoin = 1,npoin
angls = 0d0 !angles
IF(naeul(ipoin) )THEN
rm = RESHAPE( euler(1:9,ipoin),(/3,3/)) !rotation matrix
CALL angeul(rm,angls) !returns Euler angles (in degrees)
END IF
WRITE (17,ERR=9999) angls(1:3)
END DO
END IF
IF( ndofn == 8 )THEN
DO ipoin = 1,npoin
WRITE (17,ERR=9999) psia(1:2,ipoin)
END DO
END IF
END IF
IF(iwrit == 1) THEN !write to ASCII file (.RSN)
WRITE(lures,"(//5x,'Displacements at time step ',i10,5x,'Time ',e20.11/, &
& 5x,'Nnode',3x,'X-disp',6x,'Y-disp',6x,'Z-disp'/)",ERR=9999) &
& istep,ttime
DO ipoin = 1,npoin !displacements
WRITE(lures,902,ERR=9999) label(ipoin),(coora(1:ndime,ipoin)-coord(1:ndime,ipoin))
END DO
IF(neulr > 0) THEN !for local systmes
IF(ndime == 2) THEN !2-D problems
WRITE(lures,930,ERR=9999)
DO i=1,npoin
IF(.NOT.naeul(i) )CYCLE
WRITE(lures,933,ERR=9999) label(i),euler(1,i)*fac
END DO
ELSE !3-D problemas
WRITE(lures,931,ERR=9999)
DO ipoin = 1,npoin
IF(.NOT.naeul(ipoin) )CYCLE
rm = RESHAPE( euler(1:9,ipoin),(/3,3/)) !rotation matrix
angls = 0d0 !angles
CALL angeul(rm,angls,.TRUE.) !returns Euler angles (in rads)
WRITE(lures,"(i7,3e17.8)",ERR=9999) label(ipoin),angls(1:3)*fac
END DO
IF( ndofn == 8 )THEN
WRITE(lures,"(//5x,'AdditionalDisplacements at time step ',i10,5x,'Time ',e20.11/, &
& 5x,'Nnode',3x,'X-disp',6x,'Y-disp'/)",ERR=9999) &
& istep,ttime
DO ipoin = 1,npoin
WRITE(lures,932,ERR=9999)label(ipoin), psia(1:2,ipoin)
END DO
END IF
END IF
END IF
END IF
IF( .NOT.static )THEN
!** velocity vector
DO ipoin=1,npoin
WRITE(17,ERR=9999) velnp(1:ndofn,ipoin)
END DO
IF(iwrit == 1) THEN !write to ASCII file
WRITE(lures,950,ERR=9999) istep,ttime
IF(ndime == 2) WRITE(lures,952,ERR=9999)
IF(ndime == 3) WRITE(lures,953,ERR=9999)
DO ipoin = 1,npoin
WRITE(lures,902,ERR=9999) label(ipoin),velnp(1:ndofn,ipoin)
END DO
END IF
!** aceleration vector
ALLOCATE( disp3(ndofn,npoin) ) !get memory
DO ipoin = 1,npoin ! rearrange first
DO idofn = 1,ndofn
ieq = ifpre(idofn,ipoin)
IF(ieq > 0) THEN
disp3(idofn,ipoin) = acelr(ieq)
ELSE
disp3(idofn,ipoin) = 0d0
END IF
END DO
WRITE(17,ERR=9999) disp3(1:ndofn,ipoin)
END DO
IF(iwrit == 1) THEN ! write to ASCII file
WRITE(lures,960,ERR=9999) istep,ttime
IF(ndime == 2) WRITE(lures,962,ERR=9999)
IF(ndime == 3) WRITE(lures,963,ERR=9999)
DO ipoin=1,npoin
WRITE(lures,902,ERR=9999) label(ipoin),disp3(1:ndofn,ipoin)
END DO
END IF
DEALLOCATE( disp3 ) ! release memory
END IF
!** CONTACT values (gaps, pressures, friction-work)
IF (numct > 0) CALL contac('OUTDY2',0,ttime=value,dtcal=dtime)
!** temperatures at nodal points
IF (itemp) THEN
DO ipoin=1,npoin
WRITE(17,ERR=9999) tempe(:,ipoin)
END DO
tstra = (ttime - begtm)*tscal ! time from the strategy start
!WRITE(17,ERR=9999) (bqgen(ipoin)/tstra,ipoin=1,npoin) ! average heat generation rate
! the above is for wear algorithm
IF(iwrit==1) THEN
WRITE(3,961,ERR=9999) istep,ttime
DO ipoin=1,npoin
WRITE(3,902,ERR=9999) label(ipoin),(tempe(:,ipoin))
END DO
END IF
END IF
END IF
!*** elemental variables (Gauss-points)
IF(iwrit == 1 .AND. b2) WRITE(lures,"(/,10x,'Stresses ',/)",ERR=9999)
IF(b1 .OR. b2) THEN
CALL elemnt ('OUTDYN', deltc=dtime, ttime=value, flag1=b1, flag2=b2)
IF(iwrit == 1) CALL flushf(lures)
IF(b2) THEN
CALL flushf(16)
CALL flushf(17)
WRITE(*,"(5x,'Results have been reported for postprocess')") !screen
END IF
!IF (b2) CALL del_old_files(0) !DO NOT erase GiD old files
END IF
RETURN
902 FORMAT(5x,i5,6e13.5)
930 FORMAT(//' Nodal angles '/)
933 FORMAT(i7,3x,e15.7)
931 FORMAT(//' Nodal cartesyan systems (Euler angles in rads) '/)
932 FORMAT(1x,i10,1x,3f8.4)
950 FORMAT(//5x,'Velocity at time step ',i10,5x,'Time ',e20.11/)
952 FORMAT( 5x,'Nnode',3x,'X-vel',7x,'Y-vel',7x,'Omega'/)
953 FORMAT( 5x,'Nnode',3x,'X-vel',7x,'Y-vel',7x,'Z-vel',6x, &
& 'Omega-1',5x,'Omega-2',5x,'Omega-3'/)
960 FORMAT(//5x,'Acceleration at time step ',i10,5x,'Time ',e20.11,/)
961 FORMAT(//5X,'Temperatures at time step ',I10,5X,'Time ',e20.11,/ &
& 5X,'Nnode',3X,'Temperatures')
962 FORMAT( 5x,'Nnode',3x,'X-accel',6x,'Y-accel',6x,'Alpha',/)
963 FORMAT( 5x,'nnode',3x,'X-accel',6x,'Y-accel',6x,'Z-accel',6x, &
& 'Alpha-1',6x,'Alpha-2',6x,'Alpha-3'/)
965 FORMAT(//5x,'Hydrostatic pressure at time step ',i10, &
& 5x,'Time ',e20.11/)
966 FORMAT(i10,e13.5)
9999 CALL runen2('')
END SUBROUTINE outdyn
| src/mainp/outdyn.f90 |
On the Davis Wiki, DSC may stand for:
The Davis Senior Center
The Davis Student Coop
| lab/davisWiki/DSC.f |
! DART software - Copyright UCAR. This open source software is provided
! by UCAR, "as is", without charge, subject to all terms of use at
! http://www.image.ucar.edu/DAReS/DART/DART_download
!
! $Id$
program html_functoc
implicit none
! Interactive creation of html for interface list documentation for DART
integer :: num, num_items, i, max_len, len, j
character(len = 299) :: c1, c2, module_name, item_name, spaces
write(22, *) '<!--============== DESCRIPTION OF PUBLIC INTERFACES ================-->'
write(22, *) ''
spaces = ' '
! get the name of the module
write(*, *) 'input the name of this module'
read(*, *) module_name
! Put in the standard header stuff
write(22, *) '<A NAME="Interface"></A>'
write(22, *) '<div class="top">[<a href="#">top</a>]</div><hr />'
write(22, *) '<H2><PUBLIC INTERFACES</H2>'
write(22, *) ''
write(22, *) "<TABLE summary='public interfaces'>"
write(22, *) '<TR><TD><em class=call>use ' // trim(module_name), ', only : </em></TD>'
write(*, *) 'input the names of the subroutines and functions in this module'
write(*, *) 'input "end" when done'
readloop: do i=1, 10000
write(*, *) 'next routine name ("end" to finish)'
read(*, *) item_name
if (trim(item_name) == "end") exit readloop
if (i==1) then
write(22, *) ' <TD><A HREF="#'//trim(item_name)//'"> '//trim(item_name)//' </A></TD></TR>'
else
write(22, *) '<TR><TD> </TD><TD><A HREF="#'//trim(item_name)//'"> '//trim(item_name)//' </A></TD></TR>'
endif
end do readloop
write(22, *) '</TABLE>'
write(22, *) ''
write(22, *) '<P>'
write(22, *) ' A note about documentation style.'
write(22, *) ' Optional arguments are enclosed in brackets'
write(22, *) ' <em class=optionalcode>[like this]</em>.'
write(22, *) '</P>'
write(22, *) ''
write(22, *) '<!--================================================================-->'
write(*,*) 'output file is fort.22 -- move or rename before running program again'
end program html_functoc
! <next few lines under version control, do not edit>
! $URL$
! $Id$
! $Revision$
! $Date$
| docs/html/boilerplate/html_functoc.f90 |
Purrfection Pet Watch is a pet sitting service. Diane Pierzinski will sit your cat, dog, bird or exotic pet. She also does house sitting for those without pets. She is bonded, licensed and insured.
You can reach Purrfection Pet Watch by calling (5307567157) or emailing [email protected]
20071016 19:37:46 nbsp Diane came over to take care of my dog while I was out of town for the weekend and I was very impressed with how thorough and professional she wasshe had thought of everything in advance (authorizations for emergency vet treatment, what kind of training you currently do with the dog, making sure I had arrived home even when it was late so that Judge wouldnt be left alone if my plane had been delayed, etc.) and had everything written down which reassured me it wouldnt be forgotten. She even left a sweet note with how Judge did each day on her 2 visits & what they did. I would recommed her to anyone who needs a pet sitter while going on vacation. Users/Judge
| lab/davisWiki/Purrfection_Pet_Watch.f |
C Uninitialized scalar variables
program scalar05
integer x,y
common /aaa/ x,y
x = y
print *,x
end
| packages/PIPS/validation/UseBeforeSet/scalar05.f |
module mod_functional
#include <messenger.h>
use mod_kinds, only: rk, ik
use type_fclvector, only: fclvector_t
use type_evaluator, only: evaluator_t
use mod_string, only: string_to_lower
use type_chidg_worker, only: chidg_worker_t
use DNAD_D
! INTERNAL FLOW FUNCTIONALS
use fcl_mass_averaged_entropy, only: mass_averaged_entropy_t
use fcl_mass_averaged_P0_ratio, only: mass_averaged_P0_ratio_t
use fcl_mass_averaged_P_ratio, only: mass_averaged_P_ratio_t
use fcl_mass_averaged_flowangle12, only: mass_averaged_flowangle12_t
use fcl_mass_averaged_flowangle13, only: mass_averaged_flowangle13_t
use fcl_mass_averaged_flowangle32, only: mass_averaged_flowangle32_t
use fcl_mass_flux, only: mass_flux_t
use fcl_mass_flux_balance, only: mass_flux_balance_t
use fcl_mass_averaged_total_pressure, only: mass_averaged_total_pressure_t
use fcl_mass_averaged_total_temperature,only: mass_averaged_total_temperature_t
! EXTERNAL FLOW FUNCTIONALS
!use fcl_kinetic_energy, only: kinetic_energy_t
use fcl_xforce, only: xforce_t
use fcl_yforce, only: yforce_t
use fcl_zforce, only: zforce_t
use fcl_xforce_coeff, only: xforce_coeff_t
use fcl_yforce_coeff, only: yforce_coeff_t
use fcl_zforce_coeff, only: zforce_coeff_t
! SCALAR FUNCTIONALS
use fcl_test_1D_energy, only: test_1D_energy_t
use fcl_test_1D_integral, only: test_1D_integral_t
use fcl_test_1D_face_integral, only: test_1D_face_integral_t
implicit none
! Register of functionals
type(fclvector_t) :: registered_functional
logical :: initialized = .false.
contains
!> Register functionals in a module vector
!!
!! This gets called by chidg%start_up('core')
!!
!!
!! @author Matteo Ugolotti
!! @date 05/10/2017
!!
!!
!------------------------------------------------------------------------------------------
subroutine register_functionals()
integer(ik) :: nfcls
integer(ik) :: ifcl
! Instantiate functionals
type(mass_averaged_entropy_t) :: MASS_AVERAGED_ENTROPY
type(mass_averaged_P0_ratio_t) :: MASS_AVERAGED_P0_RATIO
type(mass_averaged_P_ratio_t) :: MASS_AVERAGED_P_RATIO
type(mass_averaged_flowangle12_t) :: MASS_AVERAGED_FLOWANGLE_12
type(mass_averaged_flowangle13_t) :: MASS_AVERAGED_FLOWANGLE_13
type(mass_averaged_flowangle32_t) :: MASS_AVERAGED_FLOWANGLE_32
type(mass_averaged_total_pressure_t) :: MASS_AVERAGED_TOTAL_PRESSURE
type(mass_averaged_total_temperature_t) :: MASS_AVERAGED_TOTAL_TEMPERATURE
!type(kinetic_energy_t) :: KINETIC_ENERGY
type(test_1D_energy_t) :: TEST_1D_ENERGY
type(test_1D_integral_t) :: TEST_1D_INTEGRAL
type(test_1D_face_integral_t) :: TEST_1D_FACE_INTEGRAL
type(xforce_t) :: XFORCE
type(yforce_t) :: YFORCE
type(zforce_t) :: ZFORCE
type(xforce_coeff_t) :: XFORCE_COEFF
type(yforce_coeff_t) :: YFORCE_COEFF
type(zforce_coeff_t) :: ZFORCE_COEFF
type(mass_flux_t) :: MASS_FLUX
type(mass_flux_balance_t) :: MASS_FLUX_BALANCE
if ( .not. initialized ) then
call registered_functional%push_back(MASS_AVERAGED_ENTROPY)
call registered_functional%push_back(MASS_AVERAGED_P0_RATIO)
call registered_functional%push_back(MASS_AVERAGED_P_RATIO)
call registered_functional%push_back(MASS_AVERAGED_FLOWANGLE_12)
call registered_functional%push_back(MASS_AVERAGED_FLOWANGLE_13)
call registered_functional%push_back(MASS_AVERAGED_FLOWANGLE_32)
call registered_functional%push_back(MASS_AVERAGED_TOTAL_PRESSURE)
call registered_functional%push_back(MASS_AVERAGED_TOTAL_TEMPERATURE)
!call registered_functional%push_back(KINETIC_ENERGY)
call registered_functional%push_back(XFORCE)
call registered_functional%push_back(YFORCE)
call registered_functional%push_back(ZFORCE)
call registered_functional%push_back(XFORCE_COEFF)
call registered_functional%push_back(YFORCE_COEFF)
call registered_functional%push_back(ZFORCE_COEFF)
call registered_functional%push_back(ZFORCE_COEFF)
call registered_functional%push_back(MASS_FLUX)
call registered_functional%push_back(MASS_FLUX_BALANCE)
call registered_functional%push_back(TEST_1D_ENERGY)
call registered_functional%push_back(TEST_1D_INTEGRAL)
call registered_functional%push_back(TEST_1D_FACE_INTEGRAL)
end if
nfcls = registered_functional%size()
do ifcl = 1,nfcls
call registered_functional%data(ifcl)%func%init()
end do
! Confirm initialization
initialized = .true.
end subroutine register_functionals
!******************************************************************************************
!> List all the functionals registered
!!
!! This get called by chidg_edit_adjoint
!!
!! @author Matteo Ugolotti
!! @date 05/10/2017
!!
!------------------------------------------------------------------------------------------
subroutine list_functionals()
integer(ik) :: ifcl, nfcls
character(:), allocatable :: name_
nfcls = registered_functional%size()
do ifcl = 1,nfcls
name_=registered_functional%data(ifcl)%func%get_name()
call write_line(trim(name_))
end do
end subroutine list_functionals
!******************************************************************************************
!> Verify that an input functional is registered
!!
!! @author Matteo Ugolotti
!! @date 05/10/2017
!!
!------------------------------------------------------------------------------------------
function check_functional_existence(func_name) result(exists)
character(*), intent(in) :: func_name
logical :: exists
integer(ik) :: ifcl, nfcls
character(:), allocatable :: name_
nfcls = registered_functional%size()
exists = .false.
do ifcl = 1,nfcls
name_=registered_functional%data(ifcl)%func%get_name()
if (name_ == trim(func_name)) then
exists = .true.
exit
end if
end do
end function check_functional_existence
!******************************************************************************************
!> Crate a concrete functional
!!
!! @author Matteo Ugolotti
!! @date 05/14/2017
!!
!------------------------------------------------------------------------------------------
subroutine create_functional(fcl_name,func)
character(*), intent(in) :: fcl_name
class(evaluator_t), allocatable, intent(inout) :: func
integer(ik) :: ierr, ofindex
if (allocated(func)) deallocate(func)
! Find the functional in the register "registered_functional"
ofindex = registered_functional%index_by_name(trim(fcl_name))
if (ofindex == 0) call chidg_signal_one(FATAL,"create_functional: functional not recognized", trim(fcl_name))
! Allocate concrete functional
allocate(func, source=registered_functional%data(ofindex)%func, stat=ierr)
if (ierr/=0) call chidg_signal(FATAL,"create_functional: error allocating functional from register")
! Chekc if functional was allocated
if (.not. allocated(func)) call chidg_signal(FATAL,"create_functional: error allocating the concrete functional")
end subroutine create_functional
!******************************************************************************************
end module mod_functional
| src/functionals/mod_functional.f90 |
Jump to Timeline #Navigation Navigation
State census for Yolo County lists:
Whites, males: 1,085
Whites, females: 189
Negros, males: 11
Negros, females: 3
Indians, males: 109
Indians, females: 43
There is a note suggesting that the census only recorded Indians who were permanent residence of the county.
The census lists four towns: Washington (now the Broderick section of wiki:westsac:Broderick West Sacramento), Fremont (was located north east of Knights Landing), Putah, Cottonwood, and Merritt.
State Senator M. M. Wombough
Sheriff and Tax Collector E. A. Harris
| lab/davisWiki/1852.f |
!-------------------------------------------------------------------------------
! Copyright (c) 2016 The University of Tokyo
! This software is released under the MIT License, see LICENSE.txt
!-------------------------------------------------------------------------------
!> This module provides functions to initialize heat analysis
module m_heat_init
contains
!C***
!C*** INIT_AMPLITUDE
!C***
subroutine heat_init_amplitude (hecMESH, fstrHEAT)
use m_fstr
implicit none
integer(kind=kint) :: namax, i, nn, is, iE, icou, j, k
real(kind=kreal) :: x1, y1, x2, y2
type(fstr_heat) :: fstrHEAT
type(hecmwST_local_mesh) :: hecMESH
!C
!C===
namax = 0
do i = 1, hecMESH%amp%n_amp
nn = hecMESH%amp%amp_index(i) - hecMESH%amp%amp_index(i-1)
namax = max(nn,namax)
enddo
fstrHEAT%AMPLITUDEtot= hecMESH%amp%n_amp
allocate (fstrHEAT%AMPLtab (fstrHEAT%AMPLITUDEtot) )
allocate (fstrHEAT%AMPL (fstrHEAT%AMPLITUDEtot,namax), &
fstrHEAT%AMPLtime(fstrHEAT%AMPLITUDEtot,namax) )
fstrHEAT%AMPLtab = 0
fstrHEAT%AMPL = 0.d0
fstrHEAT%AMPLtime = 0.d0
do i = 1, fstrHEAT%AMPLITUDEtot
is = hecMESH%amp%amp_index(i-1) + 1
iE = hecMESH%amp%amp_index(i)
nn = iE - is + 1
fstrHEAT%AMPLtab(i) = nn
icou = 0
do j = is, iE
icou = icou + 1
fstrHEAT%AMPL (i,icou) = hecMESH%amp%amp_val (j)
fstrHEAT%AMPLtime(i,icou) = hecMESH%amp%amp_table(j)
enddo
enddo
!C===
!C
!C +-----------+
!C | AMP-TABLE |
!C +-----------+
!C===
allocate ( fstrHEAT%AMPLfuncA( fstrHEAT%AMPLITUDEtot,namax+1 ) )
allocate ( fstrHEAT%AMPLfuncB( fstrHEAT%AMPLITUDEtot,namax+1 ) )
fstrHEAT%AMPLfuncA = 0.d0
fstrHEAT%AMPLfuncB = 0.d0
!C
!C--
do i = 1, fstrHEAT%AMPLITUDEtot
fstrHEAT%AMPLfuncA(i,1) = 0.d0
fstrHEAT%AMPLfuncB(i,1) = fstrHEAT%AMPL(i,1)
nn = fstrHEAT%AMPLtab(i)
do k = 2, nn
x1 = fstrHEAT%AMPLtime(i,k-1)
y1 = fstrHEAT%AMPL (i,k-1)
x2 = fstrHEAT%AMPLtime(i,k)
y2 = fstrHEAT%AMPL (i,k)
fstrHEAT%AMPLfuncA(i,k) = (y2-y1)/(x2-x1)
fstrHEAT%AMPLfuncB(i,k) = -(y2-y1)/(x2-x1)*x1 + y1
enddo
fstrHEAT%AMPLfuncA(i,nn+1) = 0.d0
fstrHEAT%AMPLfuncB(i,nn+1) = fstrHEAT%AMPL(i,nn)
enddo
!C===
end subroutine heat_init_amplitude
!C***
!C*** INIT_MATERIAL
!C***
subroutine heat_init_material (hecMESH, fstrHEAT)
use m_fstr
implicit none
integer(kind=kint) :: m1max, m2max, m3max, icou, im, jm, nn, ic, jS, jE, kc, km, k
real(kind=kreal) :: aa, bb
type(fstr_heat) :: fstrHEAT
type(hecmwST_local_mesh) :: hecMESH
!C
!C +----------+
!C | MATERIAL |
!C +----------+
!C===
fstrHEAT%MATERIALtot= hecMESH%material%n_mat
m1max = 0
m2max = 0
m3max = 0
icou = 0
do im = 1, hecMESH%material%n_mat
do jm = 1, 3
icou = icou + 1
nn = hecMESH%material%mat_TABLE_index(icou) - hecMESH%material%mat_TABLE_index(icou-1)
if( jm.eq.1 ) m1max = max(nn,m1max)
if( jm.eq.2 ) m2max = max(nn,m2max)
if( jm.eq.3 ) m3max = max(nn,m3max)
enddo
enddo
allocate (fstrHEAT%RHOtab (fstrHEAT%MATERIALtot), &
fstrHEAT%CPtab (fstrHEAT%MATERIALtot), &
fstrHEAT%CONDtab (fstrHEAT%MATERIALtot))
allocate (fstrHEAT%RHO (fstrHEAT%MATERIALtot,m1max), &
fstrHEAT%RHOtemp (fstrHEAT%MATERIALtot,m1max))
allocate (fstrHEAT%CP (fstrHEAT%MATERIALtot,m2max), &
fstrHEAT%CPtemp (fstrHEAT%MATERIALtot,m2max))
allocate (fstrHEAT%COND (fstrHEAT%MATERIALtot,m3max), &
fstrHEAT%CONDtemp(fstrHEAT%MATERIALtot,m3max))
fstrHEAT%RHO = 0.d0
fstrHEAT%CP = 0.d0
fstrHEAT%COND = 0.d0
fstrHEAT%RHOtemp = 0.d0
fstrHEAT%CPtemp = 0.d0
fstrHEAT%CONDtemp = 0.d0
fstrHEAT%RHOtab = 0
fstrHEAT%CPtab = 0
fstrHEAT%CONDtab = 0
ic = 0
do im = 1, fstrHEAT%MATERIALtot
do jm = 1, 3
ic = ic + 1
jS = hecMESH%material%mat_TABLE_index(ic-1) + 1
jE = hecMESH%material%mat_TABLE_index(ic )
nn = jE - jS + 1
if( jm.eq.1 ) fstrHEAT%RHOtab (im) = nn
if( jm.eq.2 ) fstrHEAT%CPtab (im) = nn
if( jm.eq.3 ) fstrHEAT%CONDtab(im) = nn
kc = 0
do km = jS, jE
kc = kc + 1
if( jm.eq.1 ) then
fstrHEAT%RHO (im,kc) = hecMESH%material%mat_VAL (km)
fstrHEAT%RHOtemp (im,kc) = hecMESH%material%mat_TEMP(km)
endif
if( jm.eq.2 ) then
fstrHEAT%CP (im,kc) = hecMESH%material%mat_VAL (km)
fstrHEAT%CPtemp (im,kc) = hecMESH%material%mat_TEMP(km)
endif
if( jm.eq.3 ) then
fstrHEAT%COND (im,kc) = hecMESH%material%mat_VAL (km)
fstrHEAT%CONDtemp(im,kc) = hecMESH%material%mat_TEMP(km)
endif
enddo
enddo
enddo
!C===
!C
!C +-----------+
!C | MAT-TABLE |
!C +-----------+
!C===
allocate (fstrHEAT%RHOfuncA (fstrHEAT%MATERIALtot, m1max+1) &
,fstrHEAT%RHOfuncB (fstrHEAT%MATERIALtot, m1max+1))
allocate (fstrHEAT%CPfuncA (fstrHEAT%MATERIALtot, m2max+1) &
,fstrHEAT%CPfuncB (fstrHEAT%MATERIALtot, m2max+1))
allocate (fstrHEAT%CONDfuncA(fstrHEAT%MATERIALtot, m3max+1) &
,fstrHEAT%CONDfuncB(fstrHEAT%MATERIALtot, m3max+1))
fstrHEAT%RHOfuncA = 0.d0
fstrHEAT%RHOfuncB = 0.d0
fstrHEAT%CPfuncA = 0.d0
fstrHEAT%CPfuncB = 0.d0
fstrHEAT%CONDfuncA = 0.d0
fstrHEAT%CONDfuncB = 0.d0
!C
!C--RHO
do im = 1, fstrHEAT%MATERIALtot
fstrHEAT%RHOfuncB(im,1) = fstrHEAT%RHO(im,1)
do k = 2, fstrHEAT%RHOtab(im)
bb= fstrHEAT%RHO (im,k) - fstrHEAT%RHO (im,k-1)
aa= fstrHEAT%RHOtemp(im,k) - fstrHEAT%RHOtemp(im,k-1)
fstrHEAT%RHOfuncA(im,k) = bb/aa
fstrHEAT%RHOfuncB(im,k) = -(bb/aa)*fstrHEAT%RHOtemp(im,k-1) + fstrHEAT%RHO(im,k-1)
enddo
fstrHEAT%RHOfuncB(im,fstrHEAT%RHOtab(im)+1) = fstrHEAT%RHO(im,fstrHEAT%RHOtab(im))
enddo
!C
!C-- CP
do im = 1, fstrHEAT%MATERIALtot
fstrHEAT%CPfuncB(im,1) = fstrHEAT%CP(im,1)
do k = 2, fstrHEAT%CPtab(im)
bb= fstrHEAT%CP (im,k) - fstrHEAT%CP (im,k-1)
aa= fstrHEAT%CPtemp(im,k) - fstrHEAT%CPtemp(im,k-1)
fstrHEAT%CPfuncA(im,k) = bb/aa
fstrHEAT%CPfuncB(im,k) = -(bb/aa)*fstrHEAT%CPtemp(im,k-1) + fstrHEAT%CP(im,k-1)
enddo
fstrHEAT%CPfuncB(im,fstrHEAT%CPtab(im)+1) = fstrHEAT%CP(im,fstrHEAT%CPtab(im))
enddo
!C
!C-- COND.
do im = 1, fstrHEAT%MATERIALtot
fstrHEAT%CONDfuncB(im,1)= fstrHEAT%COND(im,1)
do k = 2, fstrHEAT%CONDtab(im)
bb = fstrHEAT%COND (im,k) - fstrHEAT%COND (im,k-1)
aa = fstrHEAT%CONDtemp(im,k) - fstrHEAT%CONDtemp(im,k-1)
fstrHEAT%CONDfuncA(im,k) = bb/aa
fstrHEAT%CONDfuncB(im,k) = -(bb/aa)*fstrHEAT%CONDtemp(im,k-1) + fstrHEAT%COND(im,k-1)
enddo
fstrHEAT%CONDfuncB(im,fstrHEAT%CONDtab(im)+1) = fstrHEAT%COND(im,fstrHEAT%CONDtab(im))
enddo
!C===
end subroutine heat_init_material
end module m_heat_init
| fistr1/src/analysis/heat/heat_init.f90 |
c Program to process Ireland subdaily info
c AJ_Kettle, Nov20/2017
c************************************************************************
c List of subroutines
c import_list_names need z_filelist.dat
c readin_metadata need ireland_subday_metadata2.txt
c create_basis_set
c get_daydata
c clean_daydata
c convert_var_day
c find_statf_ei_day
c calc_mon_total2_ei
c find_month_airt2
c strip_gaps_month
c export_header_day2 sent to: D:\Export\Meteireann_daily_header
c export_observation_day3 sent to: D:\Export\Meteireann_daily_observation
c export_header_month2 sent to: D:\Export\Meteireann_monthly_header
c export_observation_month3 sent to: D:\Export\Meteireann_monthly_observation
c export_archstats create: export_stats_day.dat
c export_archstats create: export_stats_mon.dat
c************************************************************************
c print*,'7 SNClaremorris(Auto): 1 missing hour/time stamp Aug 2011'
c print*,' SNClaremorris(Manual): all missing hour/time stamp'
c print*,'11 SNDublinApt: all missing hour/time stamp'
c print*,'17 SNKilkenny: all missing hour/time stamp'
c print*,'18 SNKnockAirport: all missing hour/time stamp'
c print*,'21 SNMalinhead(Manual): all missing hour/time stamp'
c print*,'26 SNMullingar(Manual): all missing hour/time stamp'
c print*,'30 SNRochesPoint(Manual): all missing hour/time stamp'
c print*,'32 SNRosslare(Manual): all missing hour/time stamp'
c print*,'33 SNShannonAirport: all missing hour/time stamp'
c print*,'35 SNValentia(Manual): all missing hour/time stamp'
c2-------10--------20--------30--------40--------50--------60--------70--------80
IMPLICIT NONE
c************************************************************************
c Declare variables
REAL :: f_time_st,f_time_en,f_deltime_s
CHARACTER(LEN=8) :: s_date
CHARACTER(LEN=10) :: s_time
CHARACTER(LEN=5) :: s_zone
INTEGER :: i_values(8)
INTEGER :: i,j,k,ii,jj,kk
INTEGER :: io
INTEGER :: i_ndflag
REAL :: f_ndflag
DOUBLE PRECISION :: d_ndflag
CHARACTER(LEN=4) :: s_ndflag
CHARACTER(LEN=300) :: s_directory
CHARACTER(LEN=300) :: s_filename
CHARACTER(LEN=300) :: s_filename_test
CHARACTER(LEN=300) :: s_pathandname
CHARACTER(LEN=300) :: s_directory_output
INTEGER, PARAMETER :: l_nfile=50
CHARACTER(LEN=300) :: s_filelist(l_nfile)
INTEGER :: l_nfile_use
INTEGER :: l_meta
CHARACTER(LEN=30) :: s_meta_namelist(l_nfile)
CHARACTER(LEN=4) :: s_meta_fileid(l_nfile)
CHARACTER(LEN=4) :: s_meta_alt_m(l_nfile)
CHARACTER(LEN=7) :: s_meta_lat(l_nfile)
CHARACTER(LEN=7) :: s_meta_lon(l_nfile)
CHARACTER(LEN=17) :: s_meta_wigos(l_nfile)
CHARACTER(LEN=30) :: s_basis_nameshort(l_nfile)
CHARACTER(LEN=30) :: s_basis_namelist(l_nfile)
CHARACTER(LEN=4) :: s_basis_fileid(l_nfile)
CHARACTER(LEN=4) :: s_basis_alt_m(l_nfile)
CHARACTER(LEN=7) :: s_basis_lat(l_nfile)
CHARACTER(LEN=7) :: s_basis_lon(l_nfile)
CHARACTER(LEN=17) :: s_basis_wigos(l_nfile)
INTEGER, PARAMETER :: l_mlent =50000
INTEGER, PARAMETER :: l_mlent_mon=5000
c preliminary data
INTEGER :: l_datalines_pre
CHARACTER(LEN=8) :: s_vec_stnnum_pre(l_mlent)
CHARACTER(LEN=10) :: s_vec_date_pre(l_mlent)
CHARACTER(LEN=8) :: s_vec_time_pre(l_mlent)
REAL :: f_vec_rain_mm_pre(l_mlent)
REAL :: f_vec_maxdy_c_pre(l_mlent)
REAL :: f_vec_mindy_c_pre(l_mlent)
c data after correction for duplicates
INTEGER :: l_datalines
CHARACTER(LEN=8) :: s_vec_stnnum(l_mlent)
CHARACTER(LEN=10) :: s_vec_date(l_mlent)
CHARACTER(LEN=8) :: s_vec_time(l_mlent)
REAL :: f_vec_rain_mm(l_mlent)
REAL :: f_vec_maxdy_c(l_mlent)
REAL :: f_vec_mindy_c(l_mlent)
c Derived variables
REAL :: f_vec_airt_k_pre(l_mlent)
REAL :: f_vec_airt_k(l_mlent)
REAL :: f_vec_maxdy_k(l_mlent)
REAL :: f_vec_mindy_k(l_mlent)
c Basic stats - 3 variables
REAL :: f_stat_rain_mm_ngd
REAL :: f_stat_rain_mm_nbd
REAL :: f_stat_rain_mm_avg
REAL :: f_stat_rain_mm_min
REAL :: f_stat_rain_mm_max
REAL :: f_stat_maxdy_c_ngd
REAL :: f_stat_maxdy_c_nbd
REAL :: f_stat_maxdy_c_avg
REAL :: f_stat_maxdy_c_min
REAL :: f_stat_maxdy_c_max
REAL :: f_stat_mindy_c_ngd
REAL :: f_stat_mindy_c_nbd
REAL :: f_stat_mindy_c_avg
REAL :: f_stat_mindy_c_min
REAL :: f_stat_mindy_c_max
REAL :: f_stat_airt_k_ngd
REAL :: f_stat_airt_k_nbd
REAL :: f_stat_airt_k_avg
REAL :: f_stat_airt_k_min
REAL :: f_stat_airt_k_max
c Archives of stats - 3 variables + 1 derived
CHARACTER(LEN=8) :: s_arch_stnnum(l_nfile)
REAL :: f_arch_rain_ngd_mm(l_nfile)
REAL :: f_arch_rain_nbd_mm(l_nfile)
REAL :: f_arch_rain_avg_mm(l_nfile)
REAL :: f_arch_rain_min_mm(l_nfile)
REAL :: f_arch_rain_max_mm(l_nfile)
REAL :: f_arch_maxdy_ngd_c(l_nfile)
REAL :: f_arch_maxdy_nbd_c(l_nfile)
REAL :: f_arch_maxdy_avg_c(l_nfile)
REAL :: f_arch_maxdy_min_c(l_nfile)
REAL :: f_arch_maxdy_max_c(l_nfile)
REAL :: f_arch_mindy_ngd_c(l_nfile)
REAL :: f_arch_mindy_nbd_c(l_nfile)
REAL :: f_arch_mindy_avg_c(l_nfile)
REAL :: f_arch_mindy_min_c(l_nfile)
REAL :: f_arch_mindy_max_c(l_nfile)
REAL :: f_arch_airt_ngd_k(l_nfile)
REAL :: f_arch_airt_nbd_k(l_nfile)
REAL :: f_arch_airt_avg_k(l_nfile)
REAL :: f_arch_airt_min_k(l_nfile)
REAL :: f_arch_airt_max_k(l_nfile)
c***
c Monthly values
INTEGER :: l_mon_maxdy_c
CHARACTER(LEN=2) :: s_monrec_maxdy_c_year(l_mlent_mon)
CHARACTER(LEN=4) :: s_monrec_maxdy_c_month(l_mlent_mon)
REAL :: f_monrec_maxdy_c_nseconds(l_mlent_mon)
CHARACTER(LEN=8) :: s_monrec_maxdy_c_stime(l_mlent_mon)
CHARACTER(LEN=5) :: s_monrec_maxdy_c_timezone5(l_mlent_mon)
REAL :: f_monrec_avg_maxdy_c(l_mlent_mon)
REAL :: f_monrec_tot_maxdy_c(l_mlent_mon)
REAL :: f_monrec_max_maxdy_c(l_mlent_mon)
REAL :: f_monrec_min_maxdy_c(l_mlent_mon)
INTEGER :: i_monrec_maxdy_c_flag(l_mlent_mon)
INTEGER :: l_mon_mindy_c
CHARACTER(LEN=2) :: s_monrec_mindy_c_year(l_mlent_mon)
CHARACTER(LEN=4) :: s_monrec_mindy_c_month(l_mlent_mon)
REAL :: f_monrec_mindy_c_nseconds(l_mlent_mon)
CHARACTER(LEN=8) :: s_monrec_mindy_c_stime(l_mlent_mon)
CHARACTER(LEN=5) :: s_monrec_mindy_c_timezone5(l_mlent_mon)
REAL :: f_monrec_avg_mindy_c(l_mlent_mon)
REAL :: f_monrec_tot_mindy_c(l_mlent_mon)
REAL :: f_monrec_max_mindy_c(l_mlent_mon)
REAL :: f_monrec_min_mindy_c(l_mlent_mon)
INTEGER :: i_monrec_mindy_c_flag(l_mlent_mon)
INTEGER :: l_mon_maxdy_k
CHARACTER(LEN=2) :: s_monrec_maxdy_k_year(l_mlent_mon)
CHARACTER(LEN=4) :: s_monrec_maxdy_k_month(l_mlent_mon)
REAL :: f_monrec_maxdy_k_nseconds(l_mlent_mon)
CHARACTER(LEN=8) :: s_monrec_maxdy_k_stime(l_mlent_mon)
CHARACTER(LEN=5) :: s_monrec_maxdy_k_timezone5(l_mlent_mon)
REAL :: f_monrec_avg_maxdy_k(l_mlent_mon)
REAL :: f_monrec_tot_maxdy_k(l_mlent_mon)
REAL :: f_monrec_max_maxdy_k(l_mlent_mon)
REAL :: f_monrec_min_maxdy_k(l_mlent_mon)
INTEGER :: i_monrec_maxdy_k_flag(l_mlent_mon)
INTEGER :: l_mon_mindy_k
CHARACTER(LEN=2) :: s_monrec_mindy_k_year(l_mlent_mon)
CHARACTER(LEN=4) :: s_monrec_mindy_k_month(l_mlent_mon)
REAL :: f_monrec_mindy_k_nseconds(l_mlent_mon)
CHARACTER(LEN=8) :: s_monrec_mindy_k_stime(l_mlent_mon)
CHARACTER(LEN=5) :: s_monrec_mindy_k_timezone5(l_mlent_mon)
REAL :: f_monrec_avg_mindy_k(l_mlent_mon)
REAL :: f_monrec_tot_mindy_k(l_mlent_mon)
REAL :: f_monrec_max_mindy_k(l_mlent_mon)
REAL :: f_monrec_min_mindy_k(l_mlent_mon)
INTEGER :: i_monrec_mindy_k_flag(l_mlent_mon)
INTEGER :: l_mon_rain_mm
CHARACTER(LEN=2) :: s_monrec_rain_mm_month(l_mlent_mon)
CHARACTER(LEN=4) :: s_monrec_rain_mm_year(l_mlent_mon)
REAL :: f_monrec_rain_mm_nseconds(l_mlent_mon)
CHARACTER(LEN=8) :: s_monrec_rain_mm_stime(l_mlent_mon)
CHARACTER(LEN=5) :: s_monrec_rain_mm_timezone5(l_mlent_mon)
REAL :: f_monrec_avg_rain_mm(l_mlent_mon)
REAL :: f_monrec_tot_rain_mm(l_mlent_mon)
REAL :: f_monrec_max_rain_mm(l_mlent_mon)
REAL :: f_monrec_min_rain_mm(l_mlent_mon)
INTEGER :: i_monrec_rain_mm_flag(l_mlent_mon)
INTEGER :: l_mon_airt_c
CHARACTER(LEN=2) :: s_monrec_airt_c_year(l_mlent_mon)
CHARACTER(LEN=4) :: s_monrec_airt_c_month(l_mlent_mon)
REAL :: f_monrec_airt_c_nseconds(l_mlent_mon)
CHARACTER(LEN=8) :: s_monrec_airt_c_stime(l_mlent_mon)
CHARACTER(LEN=5) :: s_monrec_airt_c_timezone5(l_mlent_mon)
REAL :: f_monrec_avg_airt_c(l_mlent_mon)
INTEGER :: i_monrec_airt_c_flag(l_mlent_mon)
REAL :: f_monrec_airt_c(l_mlent_mon)
REAL :: f_monrec_airt_k(l_mlent_mon)
c Declare common vectors
INTEGER :: l_moncom
CHARACTER(LEN=2) :: s_moncom_month(l_mlent_mon)
CHARACTER(LEN=4) :: s_moncom_year(l_mlent_mon)
REAL :: f_moncom_nseconds(l_mlent_mon)
CHARACTER(LEN=8) :: s_moncom_stime(l_mlent_mon)
CHARACTER(LEN=5) :: s_moncom_timezone5(l_mlent_mon)
REAL :: f_moncom_max_maxdy_c(l_mlent_mon)
REAL :: f_moncom_min_mindy_c(l_mlent_mon)
REAL :: f_moncom_max_maxdy_k(l_mlent_mon)
REAL :: f_moncom_min_mindy_k(l_mlent_mon)
REAL :: f_moncom_tot_rain_mm(l_mlent_mon)
REAL :: f_moncom_airt_c(l_mlent_mon)
REAL :: f_moncom_airt_k(l_mlent_mon)
c INTEGER :: l_mon_airt
c CHARACTER(LEN=2) :: s_monrec_airt_month(l_mlent_mon)
c CHARACTER(LEN=4) :: s_monrec_airt_year(l_mlent_mon)
c REAL :: f_monrec_airt_k(l_mlent_mon)
c INTEGER :: i_monrec_airt_flag(l_mlent_mon)
c***
c Statistics of monthly values
REAL :: f_statmon_rain_mm_ngd
REAL :: f_statmon_rain_mm_nbd
REAL :: f_statmon_rain_mm_avg
REAL :: f_statmon_rain_mm_min
REAL :: f_statmon_rain_mm_max
REAL :: f_statmon_airt_k_ngd
REAL :: f_statmon_airt_k_nbd
REAL :: f_statmon_airt_k_avg
REAL :: f_statmon_airt_k_min
REAL :: f_statmon_airt_k_max
c Statistics of 2 month variables
REAL :: f_archmon_rain_ngd_mm(l_nfile)
REAL :: f_archmon_rain_nbd_mm(l_nfile)
REAL :: f_archmon_rain_avg_mm(l_nfile)
REAL :: f_archmon_rain_min_mm(l_nfile)
REAL :: f_archmon_rain_max_mm(l_nfile)
REAL :: f_archmon_airt_ngd_k(l_nfile)
REAL :: f_archmon_airt_nbd_k(l_nfile)
REAL :: f_archmon_airt_avg_k(l_nfile)
REAL :: f_archmon_airt_min_k(l_nfile)
REAL :: f_archmon_airt_max_k(l_nfile)
CHARACTER(LEN=200) :: s_directory_root
c************************************************************************
c Find start time
CALL CPU_TIME(f_time_st)
c Find date & time
CALL DATE_AND_TIME(s_date,s_time,s_zone,i_values)
c************************************************************************
i_ndflag=-999
f_ndflag=-999.0
d_ndflag=-999.0
s_ndflag='-999'
c************************************************************************
s_directory='D:\Ireland\Daily\'
s_directory_output ='Data_middle/' !changed 20171013 for UNIX consistency
c************************************************************************
c Import list of data directories
s_filename='z_filelist.dat'
s_pathandname=TRIM(s_directory)//TRIM(s_filename)
CALL import_list_names(s_pathandname,
+ l_nfile,
+ l_nfile_use,s_filelist)
print*,'l_nfile_use',l_nfile_use
c************************************************************************
c Read in metadata
s_filename='ireland_subday_metadata2.txt'
CALL readin_metadata(s_filename,l_nfile,
+ l_meta,
+ s_meta_namelist,s_meta_fileid,s_meta_alt_m,
+ s_meta_lat,s_meta_lon,s_meta_wigos)
c Create basis metadata set
CALL create_basis_set(l_nfile,l_nfile_use,s_filelist,
+ l_meta,
+ s_meta_namelist,s_meta_fileid,s_meta_alt_m,
+ s_meta_lat,s_meta_lon,s_meta_wigos,
+ s_basis_nameshort,s_basis_namelist,s_basis_fileid,
+ s_basis_alt_m,s_basis_lat,s_basis_lon,s_basis_wigos)
c************************************************************************
DO i=1,l_nfile_use
s_pathandname=TRIM(s_directory)//TRIM(s_filelist(i))
print*,'s_pathandname=',i,TRIM(s_pathandname)
CALL get_daydata(s_pathandname,l_mlent,
+ s_ndflag,i_ndflag,f_ndflag,
+ l_datalines_pre,s_vec_stnnum_pre,
+ s_vec_date_pre,s_vec_time_pre,
+ f_vec_rain_mm_pre,f_vec_maxdy_c_pre,f_vec_mindy_c_pre,
+ f_vec_airt_k_pre)
c Eliminate duplicate for Claremorris(Auto)
s_filename_test='SNClaremorris(Auto)'
s_filename =s_filelist(i)
CALL clean_daydata(l_mlent,s_filename,s_filename_test,
+ l_datalines_pre,s_vec_stnnum_pre,
+ s_vec_date_pre,s_vec_time_pre,
+ f_vec_rain_mm_pre,f_vec_maxdy_c_pre,f_vec_mindy_c_pre,
+ f_vec_airt_k_pre,
+ l_datalines,s_vec_stnnum,
+ s_vec_date,s_vec_time,
+ f_vec_rain_mm,f_vec_maxdy_c,f_vec_mindy_c,
+ f_vec_airt_k)
c Conversion algorithm: convert C to K
CALL convert_var_day(l_datalines,l_mlent,f_ndflag,
+ f_vec_maxdy_c,f_vec_mindy_c,
+ f_vec_maxdy_k,f_vec_mindy_k)
c print*,'f_vec_rain_mm=',(f_vec_rain_mm(j),j=1,10)
c print*,'f_vec_maxdy_c=',(f_vec_maxdy_c(j),j=1,10)
c print*,'f_vec_mindy_c=',(f_vec_mindy_c(j),j=1,10)
c print*,'s_vec_date=',(s_vec_date(k),k=1,5)
c print*,'s_vec_time=',(s_vec_time(k),k=1,5)
c CALL SLEEP(5)
c****
CALL find_statf_ei_day(l_mlent,l_datalines,f_vec_rain_mm,
+ f_ndflag,
+ f_stat_rain_mm_ngd,f_stat_rain_mm_nbd,
+ f_stat_rain_mm_avg,
+ f_stat_rain_mm_min,f_stat_rain_mm_max)
CALL find_statf_ei_day(l_mlent,l_datalines,f_vec_maxdy_c,
+ f_ndflag,
+ f_stat_maxdy_c_ngd,f_stat_maxdy_c_nbd,
+ f_stat_maxdy_c_avg,
+ f_stat_maxdy_c_min,f_stat_maxdy_c_max)
CALL find_statf_ei_day(l_mlent,l_datalines,f_vec_mindy_c,
+ f_ndflag,
+ f_stat_mindy_c_ngd,f_stat_mindy_c_nbd,
+ f_stat_mindy_c_avg,
+ f_stat_mindy_c_min,f_stat_mindy_c_max)
CALL find_statf_ei_day(l_mlent,l_datalines,f_vec_airt_k,
+ f_ndflag,
+ f_stat_airt_k_ngd,f_stat_airt_k_nbd,
+ f_stat_airt_k_avg,
+ f_stat_airt_k_min,f_stat_airt_k_max)
c print*,'stat=',f_stat_airt_k_ngd,f_stat_airt_k_nbd,
c + f_stat_airt_k_avg,
c + f_stat_airt_k_min,f_stat_airt_k_max
c****
c Archive metadata
s_arch_stnnum(i) =s_vec_stnnum(1)
c Archive stats
f_arch_rain_ngd_mm(i) =f_stat_rain_mm_ngd
f_arch_rain_nbd_mm(i) =f_stat_rain_mm_nbd
f_arch_rain_avg_mm(i) =f_stat_rain_mm_avg
f_arch_rain_min_mm(i) =f_stat_rain_mm_min
f_arch_rain_max_mm(i) =f_stat_rain_mm_max
f_arch_maxdy_ngd_c(i) =f_stat_maxdy_c_ngd
f_arch_maxdy_nbd_c(i) =f_stat_maxdy_c_nbd
f_arch_maxdy_avg_c(i) =f_stat_maxdy_c_avg
f_arch_maxdy_min_c(i) =f_stat_maxdy_c_min
f_arch_maxdy_max_c(i) =f_stat_maxdy_c_max
f_arch_mindy_ngd_c(i) =f_stat_mindy_c_ngd
f_arch_mindy_nbd_c(i) =f_stat_mindy_c_nbd
f_arch_mindy_avg_c(i) =f_stat_mindy_c_avg
f_arch_mindy_min_c(i) =f_stat_mindy_c_min
f_arch_mindy_max_c(i) =f_stat_mindy_c_max
f_arch_airt_ngd_k(i) =f_stat_airt_k_ngd
f_arch_airt_nbd_k(i) =f_stat_airt_k_nbd
f_arch_airt_avg_k(i) =f_stat_airt_k_avg
f_arch_airt_min_k(i) =f_stat_airt_k_min
f_arch_airt_max_k(i) =f_stat_airt_k_max
c******
c******
c Calculate monthly values here
print*,'f_ndflag=',f_ndflag
c airt_c_max
CALL calc_mon_total2_ei(f_ndflag,
+ l_mlent,l_mlent_mon,l_datalines,
+ s_vec_date,f_vec_maxdy_c,
+ l_mon_maxdy_c,
+ s_monrec_maxdy_c_year,s_monrec_maxdy_c_month,
+ f_monrec_maxdy_c_nseconds,
+ s_monrec_maxdy_c_stime,s_monrec_maxdy_c_timezone5,
+ f_monrec_avg_maxdy_c,f_monrec_tot_maxdy_c,
+ f_monrec_max_maxdy_c,f_monrec_min_maxdy_c,
+ i_monrec_maxdy_c_flag)
print*,'f_ndflag=',f_ndflag
c airt_c_min
CALL calc_mon_total2_ei(f_ndflag,
+ l_mlent,l_mlent_mon,l_datalines,
+ s_vec_date,f_vec_mindy_c,
+ l_mon_mindy_c,
+ s_monrec_mindy_c_year,s_monrec_mindy_c_month,
+ f_monrec_mindy_c_nseconds,
+ s_monrec_mindy_c_stime,s_monrec_mindy_c_timezone5,
+ f_monrec_avg_mindy_c,f_monrec_tot_mindy_c,
+ f_monrec_max_mindy_c,f_monrec_min_mindy_c,
+ i_monrec_mindy_c_flag)
print*,'f_ndflag=',f_ndflag
c airt_k_max
CALL calc_mon_total2_ei(f_ndflag,
+ l_mlent,l_mlent_mon,l_datalines,
+ s_vec_date,f_vec_maxdy_k,
+ l_mon_maxdy_k,
+ s_monrec_maxdy_k_year,s_monrec_maxdy_k_month,
+ f_monrec_maxdy_k_nseconds,
+ s_monrec_maxdy_k_stime,s_monrec_maxdy_k_timezone5,
+ f_monrec_avg_maxdy_k,f_monrec_tot_maxdy_k,
+ f_monrec_max_maxdy_k,f_monrec_min_maxdy_k,
+ i_monrec_maxdy_k_flag)
print*,'f_ndflag=',f_ndflag
c airt_k_min
CALL calc_mon_total2_ei(f_ndflag,
+ l_mlent,l_mlent_mon,l_datalines,
+ s_vec_date,f_vec_mindy_k,
+ l_mon_mindy_k,
+ s_monrec_mindy_k_year,s_monrec_mindy_k_month,
+ f_monrec_mindy_k_nseconds,
+ s_monrec_mindy_k_stime,s_monrec_mindy_k_timezone5,
+ f_monrec_avg_mindy_k,f_monrec_tot_mindy_k,
+ f_monrec_max_mindy_k,f_monrec_min_mindy_k,
+ i_monrec_mindy_k_flag)
print*,'f_ndflag=',f_ndflag
c Rain_mm
CALL calc_mon_total2_ei(f_ndflag,
+ l_mlent,l_mlent_mon,l_datalines,
+ s_vec_date,f_vec_rain_mm,
+ l_mon_rain_mm,
+ s_monrec_rain_mm_year,s_monrec_rain_mm_month,
+ f_monrec_rain_mm_nseconds,
+ s_monrec_rain_mm_stime,s_monrec_rain_mm_timezone5,
+ f_monrec_avg_rain_mm,f_monrec_tot_rain_mm,
+ f_monrec_max_rain_mm,f_monrec_min_rain_mm,
+ i_monrec_rain_mm_flag)
c Find monthly average temperature
c CALL find_month_airt(l_mlent_mon,
c + l_mon_maxdy_c,
c + s_monrec_maxdy_c_year,s_monrec_maxdy_c_month,
c + f_monrec_maxdy_c_nseconds,
c + s_monrec_maxdy_c_stime,s_monrec_maxdy_c_timezone5,
c + f_monrec_avg_maxdy_c,
c + i_monrec_maxdy_c_flag,
c + l_mon_mindy_c,
c + s_monrec_mindy_c_year,s_monrec_mindy_c_month,
c + f_monrec_mindy_c_nseconds,
c + s_monrec_mindy_c_stime,s_monrec_mindy_c_timezone5,
c + f_monrec_avg_mindy_c,
c + i_monrec_mindy_c_flag,
c + l_mon_airt_c,
c + s_monrec_airt_c_year,s_monrec_airt_c_month,
c + f_monrec_airt_c_nseconds,
c + s_monrec_airt_c_stime,s_monrec_mindy_c_timezone5,
c + f_monrec_avg_airt_c,
c + i_monrec_airt_c_flag)
CALL find_month_airt2(l_mlent_mon,f_ndflag,
+ l_mon_maxdy_c,l_mon_mindy_c,l_mon_maxdy_k,l_mon_mindy_k,
+ f_monrec_avg_maxdy_c,f_monrec_avg_mindy_c,
+ f_monrec_avg_maxdy_k,f_monrec_avg_mindy_k,
+ f_monrec_airt_c,f_monrec_airt_k)
c Find common vector for month variables for export
CALL strip_gaps_month(l_mlent_mon,f_ndflag,
+ l_mon_maxdy_c,l_mon_mindy_c,l_mon_maxdy_k,l_mon_mindy_k,
+ l_mon_rain_mm,
+ s_monrec_rain_mm_year,s_monrec_rain_mm_month,
+ f_monrec_rain_mm_nseconds,
+ s_monrec_rain_mm_stime,s_monrec_rain_mm_timezone5,
+ f_monrec_max_maxdy_c,f_monrec_min_mindy_c,
+ f_monrec_max_maxdy_k,f_monrec_min_mindy_k,
+ f_monrec_tot_rain_mm,
+ f_monrec_airt_c,f_monrec_airt_k,
+ l_moncom,
+ s_moncom_month,s_moncom_year,f_moncom_nseconds,
+ s_moncom_stime,s_moncom_timezone5,
+ f_moncom_max_maxdy_c,f_moncom_min_mindy_c,
+ f_moncom_max_maxdy_k,f_moncom_min_mindy_k,
+ f_moncom_tot_rain_mm,f_moncom_airt_c,f_moncom_airt_k)
c CALL into_subroutine(f_ndflag,
c + l_mlent,l_mlent_mon,l_datalines,
c + s_vec_date,
c + f_vec_maxdy_c)
c Extract unbroken series of month data
c CALL month_package3(f_ndflag,
c + l_mlent,l_mlent_mon,l_datalines,
c + s_vec_date,
c + f_vec_maxdy_c,f_vec_mindy_c,f_vec_maxdy_k,f_vec_mindy_k,
c + f_vec_rain_mm)
c previous airt-avg calculation
c CALL calc_mon_value_ei(l_mlent,l_mlent_mon,l_datalines,
c + s_vec_date,f_vec_airt_k,
c + l_mon_airt,
c + s_monrec_airt_year,s_monrec_airt_month,
c + f_monrec_airt_k,i_monrec_airt_flag)
c rain_mm
c CALL calc_mon_value_ei(l_mlent,l_mlent_mon,l_datalines,
c + s_vec_date,f_vec_rain_mm,
c + l_mon_rain,
c + s_monrec_rain_year,s_monrec_rain_month,
c + f_monrec_rain_mm,i_monrec_rain_flag)
c CALL calc_mon_total_ei(l_mlent,l_mlent_mon,l_datalines,
c + s_vec_date,f_vec_rain_mm,
c + l_mon_rain,
c + s_monrec_rain_year,s_monrec_rain_month,
c + f_monrec_common_nseconds,
c + s_monrec_common_stime,s_monrec_common_timezone5,
c + f_monrec_rain_mm,f_monrec_totrain_mm,i_monrec_rain_flag)
c CALL calc_mon_total2_ei(l_mlent,l_mlent_mon,l_datalines,
c + s_vec_date,f_vec_rain_mm,
c + l_mon_rain,
c + s_monrec_rain_year,s_monrec_rain_month,
c + f_monrec_common_nseconds,
c + s_monrec_common_stime,s_monrec_common_timezone5,
c + f_monrec_rain_mm,f_monrec_totrain_mm,
c + f_monrec_maxrain_mm,f_monrec_minrain_mm,
c + i_monrec_rain_flag)
c RETURN
c END
c******
c Find stats - month (problem with Claremorris - Auto Aug 30 repeated)
CALL find_statf_ei_day(
+ l_mlent_mon,l_mon_rain_mm,f_monrec_tot_rain_mm,
+ f_ndflag,
+ f_statmon_rain_mm_ngd,f_statmon_rain_mm_nbd,
+ f_statmon_rain_mm_avg,
+ f_statmon_rain_mm_min,f_statmon_rain_mm_max)
c CALL find_statf_ei_day(l_mlent_mon,l_mon_airt,f_monrec_airt_k,
c + f_ndflag,
c + f_statmon_airt_k_ngd,f_statmon_airt_k_nbd,
c + f_statmon_airt_k_avg,
c + f_statmon_airt_k_min,f_statmon_airt_k_max)
c print*,'statmon=',f_statmon_rain_mm_ngd,f_statmon_rain_mm_nbd,
c + f_statmon_rain_mm_avg,
c + f_statmon_rain_mm_min,f_statmon_rain_mm_max
c print*,'statmon=',f_statmon_airt_k_ngd,f_statmon_airt_k_nbd,
c + f_statmon_airt_k_avg,
c + f_statmon_airt_k_min,f_statmon_airt_k_max
c******
c Archive station stats
f_archmon_rain_ngd_mm(i) =f_statmon_rain_mm_ngd
f_archmon_rain_nbd_mm(i) =f_statmon_rain_mm_nbd
f_archmon_rain_avg_mm(i) =f_statmon_rain_mm_avg
f_archmon_rain_min_mm(i) =f_statmon_rain_mm_min
f_archmon_rain_max_mm(i) =f_statmon_rain_mm_max
c f_archmon_airt_ngd_k(i) =f_statmon_airt_k_ngd
c f_archmon_airt_nbd_k(i) =f_statmon_airt_k_nbd
c f_archmon_airt_avg_k(i) =f_statmon_airt_k_avg
c f_archmon_airt_min_k(i) =f_statmon_airt_k_min
c f_archmon_airt_max_k(i) =f_statmon_airt_k_max
c******
c GOTO 20
c Export header table from Met Eireanne stations
c901 s_directory_root='D:\Export\Meteireanne_daily_header\'
c CALL export_header_day(f_ndflag,s_directory_root,
c + l_datalines,
c + s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
c + s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
c + l_mlent,
c + s_vec_date,s_vec_time,f_vec_rain_mm,f_vec_maxdy_k,f_vec_mindy_k)
901 s_directory_root='D:\Export\Meteireann_daily_header\'
CALL export_header_day2(f_ndflag,s_directory_root,
+ l_datalines,
+ s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
+ s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
+ l_mlent,
+ s_vec_date,s_vec_time,f_vec_rain_mm,f_vec_maxdy_k,f_vec_mindy_k)
c Export observation table from Met Eireanne stations
c902 s_directory_root='D:\Export\Meteireanne_daily_observation\'
c CALL export_observation_day(f_ndflag,s_directory_root,
c + l_datalines,
c + s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
c + s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
c + l_mlent,
c + s_vec_date,s_vec_time,f_vec_rain_mm,f_vec_maxdy_k,f_vec_mindy_k,
c + f_vec_maxdy_c,f_vec_mindy_c)
c removed Feb14/2018
c902 s_directory_root='D:\Export\Meteireanne_daily_observation\'
c CALL export_observation_day2(f_ndflag,s_directory_root,
c + l_datalines,
c + s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
c + s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
c + l_mlent,
c + s_vec_date,s_vec_time,f_vec_rain_mm,f_vec_maxdy_k,f_vec_mindy_k,
c + f_vec_maxdy_c,f_vec_mindy_c)
c Implemented Feb14/2018: to create CDM file with 50 columns
902 s_directory_root='D:\Export\Meteireann_daily_observation\'
CALL export_observation_day3(f_ndflag,s_directory_root,
+ l_datalines,
+ s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
+ s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
+ l_mlent,
+ s_vec_date,s_vec_time,f_vec_rain_mm,f_vec_maxdy_k,f_vec_mindy_k,
+ f_vec_maxdy_c,f_vec_mindy_c)
20 CONTINUE
c******
c GOTO 20
c Export header month
903 s_directory_root='D:\Export\Meteireann_monthly_header\'
c CALL export_header_month(f_ndflag,s_directory_root,
c + l_mon_rain_mm,
c + s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
c + s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
c + l_mlent_mon,
c + s_monrec_rain_mm_year,s_monrec_rain_mm_month,
c + f_monrec_rain_mm_nseconds,
c + s_monrec_rain_mm_stime,s_monrec_rain_mm_timezone5,
c + f_monrec_tot_rain_mm)
CALL export_header_month2(f_ndflag,s_directory_root,
+ s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
+ s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
+ l_mlent_mon,l_moncom,
+ s_moncom_year,s_moncom_month,
+ f_moncom_nseconds,
+ s_moncom_stime,s_moncom_timezone5,
+ f_moncom_max_maxdy_c,f_moncom_min_mindy_c,
+ f_moncom_max_maxdy_k,f_moncom_min_mindy_k,
+ f_moncom_tot_rain_mm,f_moncom_airt_c,f_moncom_airt_k)
c Export observation month
c904 s_directory_root='D:\Export\Meteireanne_monthly_observation\'
c CALL export_observation_month(f_ndflag,s_directory_root,
c + l_mon_rain_mm,
c + s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
c + s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
c + l_mlent_mon,
c + s_monrec_rain_mm_year,s_monrec_rain_mm_month,
c + f_monrec_rain_mm_nseconds,
c + s_monrec_rain_mm_stime,s_monrec_rain_mm_timezone5,
c + f_monrec_tot_rain_mm)
c904 s_directory_root='D:\Export\Meteireann_monthly_observation\'
c CALL export_observation_month2(f_ndflag,s_directory_root,
c + s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
c + s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
c + l_mlent_mon,l_moncom,
c + s_moncom_year,s_moncom_month,
c + f_moncom_nseconds,
c + s_moncom_stime,s_moncom_timezone5,
c + f_moncom_max_maxdy_c,f_moncom_min_mindy_c,
c + f_moncom_max_maxdy_k,f_moncom_min_mindy_k,
c + f_moncom_tot_rain_mm,f_moncom_airt_c,f_moncom_airt_k)
904 s_directory_root='D:\Export\Meteireann_monthly_observation\'
CALL export_observation_month3(f_ndflag,s_directory_root,
+ s_basis_nameshort(i),s_basis_namelist(i),s_basis_fileid(i),
+ s_basis_alt_m(i),s_basis_lat(1),s_basis_lon(1),s_basis_wigos(i),
+ l_mlent_mon,l_moncom,
+ s_moncom_year,s_moncom_month,
+ f_moncom_nseconds,
+ s_moncom_stime,s_moncom_timezone5,
+ f_moncom_max_maxdy_c,f_moncom_min_mindy_c,
+ f_moncom_max_maxdy_k,f_moncom_min_mindy_k,
+ f_moncom_tot_rain_mm,f_moncom_airt_c,f_moncom_airt_k)
c20 CONTINUE
c******
ENDDO
c************************************************************************
c Output archived stats to file
s_filename='export_stats_day.dat'
CALL export_archstats(s_date,s_directory_output,s_filename,
+ l_nfile,l_nfile_use,s_filelist,s_arch_stnnum,
+ f_arch_rain_ngd_mm,f_arch_rain_nbd_mm,
+ f_arch_rain_avg_mm,f_arch_rain_min_mm,
+ f_arch_rain_max_mm,
+ f_arch_airt_ngd_k,f_arch_airt_nbd_k,
+ f_arch_airt_avg_k,f_arch_airt_min_k,
+ f_arch_airt_max_k)
s_filename='export_stats_mon.dat'
CALL export_archstats(s_date,s_directory_output,s_filename,
+ l_nfile,l_nfile_use,s_filelist,s_arch_stnnum,
+ f_archmon_rain_ngd_mm,f_archmon_rain_nbd_mm,
+ f_archmon_rain_avg_mm,f_archmon_rain_min_mm,
+ f_archmon_rain_max_mm,
+ f_archmon_airt_ngd_k,f_archmon_airt_nbd_k,
+ f_archmon_airt_avg_k,f_archmon_airt_min_k,
+ f_archmon_airt_max_k)
c************************************************************************
c Find end time
CALL CPU_TIME(f_time_en)
f_deltime_s=f_time_en-f_time_st
print*,'f_deltime_s,f_deltime_min=',f_deltime_s,f_deltime_s/60.0
c************************************************************************
END | Github_meteireann_daily_monthly/ird1.f |
program alloc
implicit none
integer, parameter :: n = 2
real :: x(n)
real, allocatable :: y(:)
print*,"n =",n
call random_number(x)
print*,"x =",x
allocate (y(n)) ; print "(a)","allocate (y(n))"
print*,"y =",y ! undefined
deallocate (y) ! if allocated, must deallocate before allocate
allocate (y(n),source=2.0) ! source must be scalar of have size n
print "(a)","allocate (y(n),source=2.0)"
print*,"y =",y
deallocate (y)
allocate (y(n),source=[3.0,4.0])
print "(a)","allocate (y(n),source=[3.0,4.0])"
print*,"y =",y
deallocate (y)
allocate (y,mold=x) ; print "(a)","allocate (y,mold=x)"
print*,"y =",y ! undefined
deallocate (y)
allocate (y,source=x) ; print "(a)","allocate (y,source=x)"
print*,"y =",y ! y equals x
y = [-1.0,x] ! valid even if y is allocated
print "(a)","y = [-1.0,x]"
print*,"y =",y
associate (z => 2*x) ! allocates z to size(x), fills with 2*x
print "(a)","associate (z => 10*x)"
print*,"z =",z
end associate
end program alloc
! sample output:
! n = 2
! x = 0.880050063 0.891854525
!
! allocate (y(n))
! y = 2.37091988E+36 7.53898574E-43
!
! allocate (y(n),source=2.0)
! y = 2.00000000 2.00000000
!
! allocate (y(n),source=[3.0,4.0])
! y = 3.00000000 4.00000000
!
! allocate (y,mold=x)
! y = 2.37080579E+36 7.53898574E-43
!
! allocate (y,source=x)
! y = 0.880050063 0.891854525
!
! y = [-1.0,x]
! y = -1.00000000 0.880050063 0.891854525
!
! associate (z => 10*x)
! z = 1.76010013 1.78370905 | alloc_source_mold.f90 |
SUBROUTINE ORDER (GPLST,ID,REST,GRIDS,IDTAB,LCOR,B1,B2,B3)
C
LOGICAL SPILL
INTEGER GRIDS(1),ID(1),IDTAB(2),TP,GPLST(1),IGRD(2),SCR4,
1 ISYM(14),ITYPE(14),HOLD(3),ELID,SILS(34),REST(2),
2 EST,SIL,SCR2,ECPT,B1,B2,B3,THREE(3),OFFSET
COMMON /BLANK / NGP,SKP(11),EST,SKIP1(3),SIL,SKIP2(5),ECPT,OES1,
1 SCR1,SCR2,NEWOES,SCR4
EQUIVALENCE (THREE(1),IFLAG),(THREE(2),NELMT),(THREE(3),IGDPT)
EQUIVALENCE (KQ4,ISYM(13)),(KT3,ISYM(14))
DATA ISYM / 2HSH,2HT1,2HTB,2HTP,2HTM,2HQP,2HQM,2HT2,2HQ2,2HQ1,
1 2HM1,2HM2,2HQ4,2HT3/ ,KBAR/2HBR/
DATA ITYPE / 4,6,7,8,9,15,16,17,18,19,62,63,64,83/
DATA NTYPE / 14 /
C
C BUILD A TABLE FOR GPECT POINTERS TO ELID AND ITS ORDERED GRID PTS
C
SPILL = .FALSE.
J = 1
I = 3
IDTAB(1) = 0
JSPILL = 1
LCORX = LCOR
NEWIN = SCR4
NEWOUT = SCR2
2 CALL READ (*130,*12,EST,TP,1,0,M)
OFFSET = 0
IF (TP .EQ. KBAR) OFFSET = 6
IF (TP.EQ.KT3 .OR. TP.EQ.KQ4) OFFSET = 1
3 CALL FREAD (EST,NGPPE,1,0)
IDTAB(I-1) = NGPPE
C
C SKIP PAST THE NON-CONTOUR ELEMENTS
C
DO 4 K = 1,NTYPE
IF (TP .EQ. ISYM(K)) GO TO 8
4 CONTINUE
6 CALL FREAD (EST,ELID,1,0)
IF (ELID .EQ. 0) GO TO 2
J = 1 + NGPPE + OFFSET
CALL FREAD (EST,0,-J,0)
GO TO 6
C
C CONSTRUCT IDTAB 1. 0, 2.NGPPE, 3.ELID, 4.ELIDPTR, 5.REPEAT. 3,4
C FOR ALL ELEMENTS OF THIS TYPE, 6.REPEAT 1-5 FOR ALL ELEMENTS IN
C THE SET. CONSTRUCT GRIDS 1-NGPPE. GRIDS FOR 1ST ELEMENT, NEXT.
C REPEAT 1ST FOR ALL ELEMENTS IN THE IDTAB
C
8 CALL READ (*12,*12,EST,IDTAB(I),2,0,M)
I = I + 2
IF (IDTAB(I-2) .NE. 0) GO TO 10
C
C END OF ELEMENTS OF THIS TYPE
C
TP = IDTAB(I-1)
GO TO 3
C
10 CALL FREAD (EST,GRIDS(J),NGPPE,0)
IF (OFFSET .NE. 0) CALL FREAD (EST,0,-OFFSET,0)
J = J + NGPPE
IF (I .GE. LCORX) GO TO 14
GO TO 8
C
C TABLE FIT INTO CORE
C
12 CALL BCKREC (EST)
GO TO 16
C
C SPILL OCCURS - TABLE DID NOT FIT
C
14 SPILL = .TRUE.
C
C END OF TABLE
C
16 LIDTAB = I - 1
IF (LIDTAB .LE. 2) GO TO (130,140), JSPILL
LGRIDS = J - 1
LASTNG = NGPPE
GO TO (18,140), JSPILL
18 CALL OPEN (*130,ECPT,GPLST(B2),0)
CALL GOPEN (SCR2,GPLST(B1),1)
CALL FWDREC (*120,ECPT)
IGDPT = 0
20 IGDPT = IGDPT + 1
IEOR = 0
IF (GPLST(IGDPT) .NE. 0) GO TO 25
CALL FWDREC (*120,ECPT)
GO TO 20
25 NELMT = 0
IFLAG =-1
C
C ECPT--1. PIVOT POINT, 2. DEG.FREEDOM, 3. -LENGTH, 4. ELID POINTER
C 5. ELTYPE, 6.SILS (THERE ARE (LENGTH-2) OF THEM), 7. REPEAT ITEMS
C (3-6) FOR ALL ELEMENTS ATTACHED TO PIVOT, 8. EOR, 9. REPEAT ITEMS
C (1-8) FOR ALL GRIDS IN THE PROBLEM.
C
CALL READ (*120,*120,ECPT,IGRD,2,0,M)
30 CALL READ (*120,*75,ECPT,LENGTH,1,0,M)
CALL FREAD (ECPT,SILS,-LENGTH,0)
TP = SILS(2)
DO 32 I = 1,NTYPE
IF (TP .EQ. ITYPE(I)) GO TO 33
32 CONTINUE
GO TO 30
C
C MATCH ELIDPTR WITH ITS ELID AND GRID POINTS IF POSSIBLE
C
33 J = 1
DO 50 I = 1,LIDTAB,2
IF (IDTAB(I)) 40,35,40
35 NGPPE = IDTAB(I+1)
GO TO 50
40 IF (IDTAB(I+1) .EQ. SILS(1)) GO TO 55
J = J + NGPPE
50 CONTINUE
C
C IF NOT IN THE TABLE, IS THERE SPILL(IE IS TABLE NOT COMPLETE).
C NO SPILL, SKIP HIM. YES SPILL, FLAG HIM.
C
IF (.NOT.SPILL) GO TO (30,145), JSPILL
ELID =-SILS(1)
NELMT = NELMT + 1
GO TO 70
C
C FOUND ELEMENT IN THE TABLE
C
55 ELID = IDTAB(I)
DO 60 I = 1,NGPPE
K = J + I - 1
IF (IGDPT .EQ. GRIDS(K)) GO TO 65
60 CONTINUE
65 IAFTER = I - (I/NGPPE)*NGPPE + J
IBEFOR = J + I - 2
IF (I .EQ. 1) IBEFOR = IBEFOR + NGPPE
NELMT = NELMT + 1
REST(2*NELMT-1) = GRIDS(IAFTER)
REST(2*NELMT ) = GRIDS(IBEFOR)
70 ID(NELMT) = ELID
IF (NELMT .LT. LCOR/2) GO TO (30,145), JSPILL
GO TO 80
75 IF (NELMT .EQ. 0) GO TO (20,140), JSPILL
IEOR = 1
C
C ORDER ELEMENTS IF WE HAVE REACHED END OF EST FILE
C
80 IF (SPILL) GO TO 112
IF (NELMT .LE.2) GO TO 110
INDEX = 3
IALL = 2*NELMT
IONE = REST(1)
ITWO = REST(2)
85 IF (IONE .EQ. ITWO) GO TO 105
DO 90 I = INDEX,IALL,2
IF (ITWO .EQ. REST(I)) GO TO 95
90 CONTINUE
GO TO 110
95 IF (I .EQ. INDEX) GO TO 100
J = (INDEX+1)/2
K = (I+1)/2
HOLD(1) = ID(J)
ID(J) = ID(K)
ID(K) = HOLD(1)
HOLD(2) = REST(INDEX )
HOLD(3) = REST(INDEX+1)
REST(INDEX ) = REST(I )
REST(INDEX+1) = REST(I+1)
REST(I ) = HOLD(2)
REST(I+1) = HOLD(3)
100 INDEX = INDEX + 2
ITWO = REST(INDEX-1)
IF (INDEX .LT. IALL) GO TO 85
IF (IONE .NE. ITWO) GO TO 110
C
C INTERIOR ELEMENTS
C
105 CALL WRITE (NEWOUT,THREE,3,0)
CALL WRITE (NEWOUT,ID,NELMT,1)
IF (IGDPT .LT. NGP) GO TO (20,140), JSPILL
GO TO 120
C
C BORDER ELEMENTS
C
110 IFLAG = -2
112 CALL WRITE (NEWOUT,THREE,3,0)
J = -1
DO 115 I = 1,NELMT
J = J + 2
CALL WRITE (NEWOUT,ID(I),1,0)
CALL WRITE (NEWOUT,REST(J),2,0)
115 CONTINUE
IQ = 2*NELMT
CALL WRITE (NEWOUT,0,0,1)
GO TO (118,140), JSPILL
118 IF (IEOR) 25,25,119
119 IF (IGDPT .LT.NGP) GO TO 20
120 CALL CLOSE (ECPT,1)
125 CALL WRITE (NEWOUT,0,1,1)
CALL CLOSE (NEWOUT,1)
C
C IF NO SPILL - RETURN
C
130 IF (.NOT.SPILL) GO TO 170
C
C COME HERE IF WE HAVE SPILL
C
I = NEWOUT
NEWOUT = NEWIN
NEWIN = I
CALL GOPEN (NEWIN,GPLST(B1),0)
CALL GOPEN (NEWOUT,GPLST(B2),1)
JSPILL = 2
NGPPE = LASTNG
IDTAB(1) = 0
IDTAB(2) = LASTNG
I = 3
J = 1
SPILL = .FALSE.
GO TO 8
C
C TABLE CONSTRUCTED SO RETURN HERE
C
140 CALL READ (*160,*160,NEWIN,THREE,3,0,M)
NELMT = 0
145 CALL READ (*160,*75,NEWIN,SILS(1),3,0,M)
IF (SILS(1)) 150,150,155
150 SILS(1) = -SILS(1)
GO TO 33
155 ELID = SILS(1)
NELMT = NELMT + 1
REST(2*NELMT-1) = SILS(2)
REST(2*NELMT ) = SILS(3)
GO TO 70
C
C END OF FILE
C
160 CALL CLOSE (NEWIN,1)
GO TO 125
C
C OUTPUT FILE MUST BE SCRATCH 2
C
170 IF (NEWOUT .EQ. SCR2) RETURN
CALL GOPEN (NEWOUT,GPLST(B1),0)
CALL GOPEN (SCR2,GPLST(B2),1)
CALL CPYFIL (NEWOUT,SCR2,REST,LCOR,M)
CALL CLOSE (SCR2,1)
CALL CLOSE (NEWOUT,1)
RETURN
END
| mis/order.f |
!##############################################################################
! PROGRAM inversion
!
! ## Invert a matrix using LU-decomposition
!
! This code is published under the GNU General Public License v3
! (https://www.gnu.org/licenses/gpl-3.0.en.html)
!
! Authors: Hans Fehr and Fabian Kindermann
! [email protected]
!
! #VC# VERSION: 1.0 (23 January 2018)
!
!##############################################################################
program inversion
use toolbox
implicit none
integer :: i, j
real*8 :: A(3, 3), Ainv(3, 3), b(3)
! set up matrix and vector
A(1, :) = (/ 2d0, 0d0, 1d0/)
A(2, :) = (/ 0d0, 4d0, 1d0/)
A(3, :) = (/ 1d0, 1d0, 2d0/)
b = (/30d0, 40d0, 30d0/)
! invert A
Ainv = lu_invert(A)
! calculate solution
b = matmul(Ainv, b)
! output
write(*,'(a,3f7.2/)')' x = ', (b(j),j=1,3)
write(*,'(a,3f7.2/,2(8x,3f7.2/))') &
' A^-1 = ',((Ainv(i,j),j=1,3),i=1,3)
end program
| complete/prog02/prog02_03/prog02_03.f90 |
subroutine ed_driver()
use m_constants
use m_control
use m_types
use m_global
use m_lanczos
use mpi
implicit none
integer :: i,j,k
integer :: icfg, jcfg
integer :: mblock
integer :: nblock
integer :: nloc
integer :: needed(nprocs,nprocs)
integer :: end_indx(2,2,nprocs)
integer :: ierror
integer :: info
integer :: actual_step
integer :: nconv
integer :: request
integer :: stat(MPI_STATUS_SIZE)
integer :: sgn
integer :: tot_sign
integer(dp) :: old, new
integer(dp) :: num_of_nonzeros
integer, external :: binary_search
real(dp) :: rtemp
real(dp) :: time_begin
real(dp) :: time_end
real(dp) :: time_used
real(dp), allocatable :: eigvals(:)
real(dp), allocatable :: eigval_full(:)
complex(dp) :: omega
complex(dp) :: denmat(num_val_orbs, num_val_orbs, nvector)
complex(dp) :: denmat_mpi(num_val_orbs, num_val_orbs, nvector)
complex(dp), allocatable :: ham_full(:,:)
complex(dp), allocatable :: ham_full_mpi(:,:)
complex(dp), allocatable :: eigvecs_full(:,:)
complex(dp), allocatable :: eigvecs(:,:)
complex(dp), allocatable :: eigvecs_mpi(:)
character(len=20) :: fname
character(len=10) :: char_I
time_begin = 0.0_dp
time_end = 0.0_dp
time_used = 0.0_dp
call cpu_time(time_begin)
if (myid == master) then
print *, "--------------------------------------------"
print *, "edrixs >>> ED begin ... "
print *
endif
call read_hopping_i()
call read_coulomb_i()
call read_fock_i()
if (ndim_i < nprocs) then
if (myid==master) then
print *, "edrixs >>> ERROR: number of CPU processors ", nprocs, "is larger than ndim_i: ", ndim_i
endif
call MPI_BARRIER(MPI_COMM_WORLD, ierror)
STOP
endif
if (ndim_i < min_ndim ) then
if (myid==master) then
print *, "edrixs >>> ndim_i:", ndim_i, " is smaller than min_ndim:", min_ndim
print *, "edrixs >>> set ed_solver = 0, use full-diagonalization !"
print *
endif
ed_solver = 0
endif
if(ndim_i < neval) then
neval = ndim_i
endif
if(ndim_i < nvector) then
nvector=ndim_i
endif
if (myid == master) then
write(mystd,"(a20, i15)") "num_val_orbs: ", num_val_orbs
write(mystd,"(a20, i15)") "ed_solver: ", ed_solver
write(mystd,"(a20, i15)") "neval: ", neval
write(mystd,"(a20, i15)") "nvector: ", nvector
write(mystd,"(a20, i15)") "maxiter: ", maxiter
write(mystd,"(a20, i15)") "min_ndim: ", min_ndim
write(mystd,"(a20, i15)") "ncv: ", ncv
write(mystd,"(a20, i15)") "nhopp_i: ", nhopp_i
write(mystd,"(a20, i15)") "ncoul_i: ", ncoul_i
write(mystd,"(a20, i15)") "ndim_i: ", ndim_i
write(mystd,"(a20, i15)") "nprocs: ", nprocs
write(mystd,"(a20, e15.2)") "eigval_tol: ", eigval_tol
write(mystd,"(a20, l15)") "idump: ", idump
print *
endif
if (myid==master) then
print *, "edrixs >>> Build Hamiltonian ..."
endif
call partition_task(nprocs, ndim_i, ndim_i, end_indx)
rtemp = 1.0_dp
omega = czero
mblock = nprocs
nblock = nprocs
nloc = end_indx(2,2,myid+1)-end_indx(1,2,myid+1) + 1
call alloc_ham_csr(nblock)
call build_ham_i(ndim_i, fock_i, nblock, end_indx, nhopp_i, hopping_i, ncoul_i, coulomb_i, omega, rtemp, ham_csr)
call MPI_BARRIER(MPI_COMM_WORLD, ierror)
call get_needed_indx(nblock, ham_csr, needed)
call get_number_nonzeros(nblock, ham_csr, num_of_nonzeros)
call dealloc_fock_i()
call cpu_time(time_end)
time_used = time_used + time_end - time_begin
if (myid==master) then
print *, "edrixs >>> Number of nonzero elements of the Hamiltonian", num_of_nonzeros
print *, "edrixs >>> Done ! Time used: ", time_end - time_begin, " seconds"
print *
print *, "edrixs >>> Diagonalize Hamiltonian to find a few lowest states ..."
print *
endif
time_begin = time_end
allocate(eigvals(neval))
! full diagonalization
if (ed_solver == 0) then
allocate(ham_full(ndim_i, ndim_i))
allocate(ham_full_mpi(ndim_i, ndim_i))
allocate(eigvecs_full(ndim_i, ndim_i))
allocate(eigval_full(ndim_i))
allocate(eigvecs(ndim_i,nvector))
ham_full = czero
ham_full_mpi = czero
eigvecs_full = czero
eigval_full = zero
do i=1,nblock
call csr_to_full(ndim_i, ndim_i, ham_csr(i), ham_full_mpi)
enddo
call MPI_ALLREDUCE(ham_full_mpi, ham_full, size(ham_full_mpi), MPI_DOUBLE_COMPLEX, MPI_SUM, MPI_COMM_WORLD, ierror)
if (myid==master) then
call full_diag_ham(ndim_i, ham_full, eigval_full, eigvecs_full)
endif
call MPI_BARRIER(MPI_COMM_WORLD, ierror)
call MPI_BCAST(eigval_full, size(eigval_full), MPI_DOUBLE_PRECISION, master, MPI_COMM_WORLD, ierror)
call MPI_BCAST(eigvecs_full, size(eigvecs_full), MPI_DOUBLE_COMPLEX, master, MPI_COMM_WORLD, ierror)
eigvals = eigval_full(1:neval)
eigvecs = eigvecs_full(:,1:nvector)
deallocate(ham_full)
deallocate(ham_full_mpi)
deallocate(eigvecs_full)
deallocate(eigval_full)
! ordinary Lanczos method
elseif (ed_solver == 1) then
eigvals = zero
allocate(eigvecs(nloc,nvector))
eigvecs = czero
call diag_ham_lanczos(nblock, end_indx, needed, nloc, neval, maxiter, eigval_tol, ham_csr, eigvals, nvector, eigvecs)
! arpack is used
elseif (ed_solver==2) then
eigvals = zero
allocate(eigvecs(nloc,nvector))
eigvecs = czero
call diag_ham_arpack(nblock, end_indx, needed, nloc, neval, ham_csr, eigvals, nvector, &
eigvecs, ncv, maxiter, eigval_tol, info, actual_step, nconv)
if (myid==master) then
print *, " arpack return info: ", info
print *, " actual arnoldi step: ", actual_step
print *, " number of converged Ritz values: ", nconv
print *
endif
endif
call MPI_BARRIER(MPI_COMM_WORLD, ierror)
call dealloc_ham_csr(nblock)
call cpu_time(time_end)
time_used = time_used + time_end - time_begin
if (myid==master) then
print *
print *, "edrixs >>> Done ! Time used: ", time_end-time_begin, " seconds"
print *
endif
time_begin=time_end
call write_lowest_eigvals(neval, eigvals)
if (myid==master) then
print *, "edrixs >>> Calculate the density matrix ... "
endif
call read_fock_i()
denmat = czero
denmat_mpi = czero
allocate(eigvecs_mpi(ndim_i))
do k=1, nvector
eigvecs_mpi = czero
if (ed_solver==0) then
eigvecs_mpi = eigvecs(:,k)
else
! send the data
do i=1,nprocs
if (myid+1 /= i) then
call MPI_ISEND(eigvecs(:,k), nloc, MPI_DOUBLE_COMPLEX, i-1, &
i*(10*nprocs)+myid+1, MPI_COMM_WORLD, request, ierror)
endif
enddo
eigvecs_mpi(end_indx(1,2,myid+1):end_indx(2,2,myid+1)) = eigvecs(:,k)
! receive data
do i=1,nprocs
if (myid+1 /= i) then
call MPI_RECV(eigvecs_mpi(end_indx(1,2,i):end_indx(2,2,i)), &
end_indx(2,2,i)-end_indx(1,2,i)+1, MPI_DOUBLE_COMPLEX, &
-1, (myid+1)*(10*nprocs)+i, MPI_COMM_WORLD, stat, ierror)
endif
enddo
endif
call MPI_BARRIER(MPI_COMM_WORLD, ierror)
do icfg=end_indx(1,1,myid+1), end_indx(2,1,myid+1)
do j=1,num_val_orbs
if (btest(fock_i(icfg), j-1)) then
denmat_mpi(j,j,k) = denmat_mpi(j,j,k) + conjg(eigvecs_mpi(icfg)) * eigvecs_mpi(icfg)
endif
enddo
if ( abs(eigvecs_mpi(icfg)) < 1E-10 ) cycle
do i=1,num_val_orbs-1
do j=i+1,num_val_orbs
if (.not. btest(fock_i(icfg), i-1)) cycle
old = fock_i(icfg)
tot_sign = 1
call make_newfock('-', i, old, new, sgn)
tot_sign = tot_sign * sgn
old = new
if (btest(old, j-1)) cycle
call make_newfock('+', j, old, new, sgn)
tot_sign = tot_sign * sgn
jcfg = binary_search(ndim_i, fock_i, new)
if (jcfg == -1) cycle
denmat_mpi(i,j,k) = denmat_mpi(i,j,k) + conjg(eigvecs_mpi(icfg)) * eigvecs_mpi(jcfg) * tot_sign
denmat_mpi(j,i,k) = denmat_mpi(j,i,k) + conjg(eigvecs_mpi(jcfg)) * eigvecs_mpi(icfg) * tot_sign
enddo
enddo
enddo
! dump eigenvectors
if ( idump ) then
write(char_I, '(i5)') k
fname="eigvec."//trim(adjustl(char_I))
if (myid==master) then
call write_eigvecs(fname, ndim_i, eigvecs_mpi, eigvals(k))
endif
endif
enddo ! over k=1, nvector
call MPI_BARRIER(MPI_COMM_WORLD, ierror)
call MPI_ALLREDUCE(denmat_mpi, denmat, size(denmat_mpi), MPI_DOUBLE_COMPLEX, MPI_SUM, MPI_COMM_WORLD, ierror)
call write_denmat(nvector, num_val_orbs, denmat)
call dealloc_fock_i()
deallocate(eigvecs)
deallocate(eigvecs_mpi)
deallocate(eigvals)
call cpu_time(time_end)
time_used = time_used + time_end - time_begin
if (myid==master) then
print *, "edrixs >>> Done ! Time used: ", time_end-time_begin, " seconds"
print *
print *, "edrixs >>> ED end ! Total time used: ", time_used, " seconds"
print *
endif
return
end subroutine ed_driver
| src/ed_driver.f90 |
module compute_vnew_mod
use kind_params_mod
use kernel_mod
use argument_mod
use grid_mod
use field_mod
implicit none
private
public invoke_compute_vnew
public compute_vnew, compute_vnew_code
TYPE, EXTENDS(kernel_type) :: compute_vnew
TYPE(go_arg), DIMENSION(7) :: meta_args = &
(/ go_arg(GO_WRITE, GO_CV, GO_POINTWISE), & ! vnew
go_arg(GO_READ, GO_CV, GO_POINTWISE), & ! vold
go_arg(GO_READ, GO_CF, GO_POINTWISE), & ! z
go_arg(GO_READ, GO_CU, GO_POINTWISE), & ! cu
go_arg(GO_READ, GO_CT, GO_POINTWISE), & ! h
go_arg(GO_READ, GO_R_SCALAR, GO_POINTWISE), & ! tdt
go_arg(GO_READ, GO_GRID_DY_CONST) & ! dy
/)
!> This kernel operates on fields that live on an
!! orthogonal, regular grid.
integer :: GRID_TYPE = GO_ORTHOGONAL_REGULAR
!> We only have one value per grid point and that means
!! we have a single DOF per grid point.
INTEGER :: ITERATES_OVER = GO_INTERNAL_PTS
!> Although the staggering of variables used in an Arakawa
!! C grid is well defined, the way in which they are indexed is
!! an implementation choice. This can be thought of as choosing
!! which grid-point types have the same (i,j) index as a T
!! point. This kernel assumes that the U,V and F points that
!! share the same index as a given T point are those immediately
!! to the South and West of it.
integer :: index_offset = GO_OFFSET_SW
CONTAINS
procedure, nopass :: code => compute_vnew_code
END TYPE compute_vnew
CONTAINS
!===================================================
subroutine invoke_compute_vnew(vnew, vold, z, cu, h, tdt)
implicit none
type(r2d_field), intent(inout) :: vnew
type(r2d_field), intent(in) :: vold, z, cu, h
real(go_wp), intent(in) :: tdt
! Locals
integer :: I, J
real(go_wp) :: dy
! Note that we do not loop over the full extent of the field.
! Fields are allocated with extents (M+1,N+1).
! Presumably the extra row and column are needed for periodic BCs.
! We are updating a quantity on CU.
! This loop writes to vnew(1:M,2:N+1) so this looks like
! (using x to indicate a location that is written):
!
! i=1 i=M
! x x x o
! x x x o j=N
! x x x o
! o o o o j=1
! Original code looked like:
!
! DO J=1,N
! DO I=1,M
! VNEW(I,J+1) = VOLD(I,J+1)-TDTS8*(Z(I+1,J+1)+Z(I,J+1)) &
! *(CU(I+1,J+1)+CU(I,J+1)+CU(I,J)+CU(I+1,J)) &
! -TDTSDY*(H(I,J+1)-H(I,J))
! END DO
! END DO
! vnew(i,j) depends upon:
! vold(i,j) : CV
! z(i+1,j), z(i,j) : CF
! => lateral CF neighbours of the CV pt being updated
! cu(i,j), cu(i+1,j),cu(i,j-1),cu(i+1,j-1) : CU
! => all CU neighbours of the CV pt being updated
! h(i,j), h(i,j-1) : CT
! => vertical CT neighbours of the CV pt being updated
! x-------x-------fi+1j+1
! | | |
! | | |
! uij-----Tij-----ui+1j
! | | |
! | | |
! fij-----vij-----fi+1j
! | | |
! | | |
! uij-1- -Tij-1---ui+1j-1
!
dy = vnew%grid%dy
DO J=vnew%internal%ystart, vnew%internal%ystop, 1
DO I=vnew%internal%xstart, vnew%internal%xstop, 1
CALL compute_vnew_code(i, j, &
vnew%data, vold%data, &
z%data, cu%data, h%data, tdt, dy)
END DO
END DO
END SUBROUTINE invoke_compute_vnew
!===================================================
subroutine compute_vnew_code(i, j, &
vnew, vold, z, cu, h, tdt, dy)
implicit none
integer, intent(in) :: I, J
real(go_wp), intent(in) :: dy
REAL(go_wp), intent(out), DIMENSION(:,:) :: vnew
REAL(go_wp), intent(in), DIMENSION(:,:) :: vold, z, cu, h
REAL(go_wp), intent(in) :: tdt
! Locals
REAL(go_wp) :: tdts8, tdtsdy
!> These quantities are computed here because tdt is not
!! constant. (It is == dt for first time step, 2xdt for
!! all remaining time steps.)
tdts8 = tdt/8.0d0
tdtsdy = tdt/dy
VNEW(I,J) = VOLD(I,J)- &
TDTS8*(Z(I+1,J)+Z(I,J)) &
*(CU(I+1,J)+CU(I,J)+CU(I,J-1)+CU(I+1,J-1)) &
-TDTSDY*(H(I,J)-H(I,J-1))
END SUBROUTINE compute_vnew_code
END MODULE compute_vnew_mod
| benchmarks/shallow/SEQ/compute_vnew_mod.f90 |
module error_module
implicit none
public
integer e
contains
!---------------------------------------------------------------------
subroutine error_message(e)
integer e
if (e .eq. 1) then
write (*,*) "Polynomial coefficient are not recognized. Check the input file"
elseif (e .eq. 2) then
write (*,*) "SOC matrix elements are not recognized. Check the input file"
elseif (e .eq. 3) then
write (*,*) "Error in adiabatization"
elseif (e .eq. 4) then
write (*,*) "One of the gradients at the crossing point is equal to zero"
elseif (e .eq. 5) then
write (*,*) "Left limit is equal to or greater than the right limit"
elseif (e .eq. 6) then
write (*,*) "Something wrong with crosstype"
elseif (e .eq. 7) then
write (*,*) "Crossing point of two states is outside the giving limits"
write (*,*) "Only one real crossing point, while two others are complex"
elseif (e .eq. 8) then
write (*,*) "Crossing point(s) are outside the given limits"
elseif (e .eq. 9) then
write (*,*) "You have multiple crossings within the given limits"
elseif (e .eq. 10) then
write (*,*) "Reverse rate input is not recognized. Check the input file"
elseif (e .eq. 11) then
write (*,*) "WC probability is greater than 100%"
elseif (e .eq. 12) then
write (*,*) "Couldn't determine reaction coordinate for a bin"
elseif (e .eq. 13) then
write (*,*) "Only ZPE values equal to 0, 1 or 2 are accepted (ZPE=0 or ZPE=1 or ZPE=2)"
elseif (e .eq. 14) then
write (*,*) "Neither 'classic' or 'quantum' rotational model is chosen"
elseif (e .eq. 15) then
write (*,*) "TP data is not recognized. Check the input file"
elseif (e .eq. 16) then
write (*,*) "HSO components are not recognized. Check the input file"
elseif (e .eq. 17) then
write (*,*) "The T_final value in the input file is set negative"
endif
STOP
end subroutine error_message
!---------------------------------------------------------------------
end module error_module
| source/error.f90 |
! DART software - Copyright UCAR. This open source software is provided
! by UCAR, "as is", without charge, subject to all terms of use at
! http://www.image.ucar.edu/DAReS/DART/DART_download
!
! $Id$
program wod_to_obs
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! wod_to_obs - program that reads a list of World Ocean Datatbase obs
! profiles of ocean temperature and salinity in packed
! ascii format and writes a DART observation sequence file.
!
! created 19-oct-2009, based on the GTSPP reader. nsc.
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use types_mod, only : r8
use time_manager_mod, only : time_type, set_calendar_type, GREGORIAN, set_time,&
increment_time, get_time, set_date, operator(-), &
print_date, operator(+), leap_year, operator(>)
use utilities_mod, only : initialize_utilities, find_namelist_in_file, &
check_namelist_read, nmlfileunit, do_output, &
get_next_filename, error_handler, E_ERR, E_MSG, &
find_textfile_dims, finalize_utilities, &
open_file, close_file
use location_mod, only : VERTISHEIGHT, set_location
use obs_sequence_mod, only : obs_sequence_type, obs_type, read_obs_seq, &
static_init_obs_sequence, init_obs, destroy_obs, &
write_obs_seq, init_obs_sequence, get_num_obs, &
insert_obs_in_seq, destroy_obs_sequence, &
set_copy_meta_data, set_qc_meta_data, set_qc, &
set_obs_values, set_obs_def, insert_obs_in_seq
use obs_def_mod, only : obs_def_type, set_obs_def_time, set_obs_def_type_of_obs, &
set_obs_def_error_variance, set_obs_def_location, &
set_obs_def_key
use obs_kind_mod, only : get_name_for_type_of_obs
! FIXME: i don't have all the actual kinds yet (bottle? underway? )
! but it's closer than before. must have obs_def_ocean_mod.f90 in preprocess list.
use obs_kind_mod, only : &
SALINITY, QTY_SALINITY, &
TEMPERATURE, QTY_TEMPERATURE, &
U_CURRENT_COMPONENT, QTY_U_CURRENT_COMPONENT, &
V_CURRENT_COMPONENT, QTY_V_CURRENT_COMPONENT, &
SEA_SURFACE_HEIGHT, QTY_SEA_SURFACE_HEIGHT, &
SEA_SURFACE_PRESSURE, QTY_SEA_SURFACE_PRESSURE, &
ARGO_U_CURRENT_COMPONENT, ARGO_V_CURRENT_COMPONENT, &
ARGO_SALINITY, ARGO_TEMPERATURE, &
ADCP_U_CURRENT_COMPONENT, ADCP_V_CURRENT_COMPONENT, &
ADCP_SALINITY, ADCP_TEMPERATURE, &
FLOAT_SALINITY, FLOAT_TEMPERATURE
use obs_kind_mod, only : &
DRIFTER_U_CURRENT_COMPONENT, DRIFTER_V_CURRENT_COMPONENT, &
DRIFTER_SALINITY, DRIFTER_TEMPERATURE, &
GLIDER_U_CURRENT_COMPONENT, GLIDER_V_CURRENT_COMPONENT, &
GLIDER_SALINITY, GLIDER_TEMPERATURE, &
MOORING_U_CURRENT_COMPONENT, MOORING_V_CURRENT_COMPONENT, &
MOORING_SALINITY, MOORING_TEMPERATURE, &
MOORING_PRESSURE
use obs_kind_mod, only : &
CTD_SALINITY, CTD_TEMPERATURE, &
TCTD_SALINITY, TCTD_TEMPERATURE, &
XCTD_SALINITY, XCTD_TEMPERATURE, &
STD_SALINITY, STD_TEMPERATURE, &
MBT_TEMPERATURE, XBT_TEMPERATURE, &
DBT_TEMPERATURE, APB_TEMPERATURE, &
MBT_SALINITY, XBT_SALINITY, &
DBT_SALINITY, APB_SALINITY, &
BOTTLE_TEMPERATURE, BOTTLE_SALINITY, &
DOPPLER_U_CURRENT_COMPONENT, DOPPLER_V_CURRENT_COMPONENT, &
DOPPLER_W_CURRENT_COMPONENT, QTY_W_CURRENT_COMPONENT, &
SATELLITE_MICROWAVE_SST, SATELLITE_INFRARED_SST, &
SATELLITE_SSH, SATELLITE_SSS, &
HFRADAR_RADIAL_VELOCITY, QTY_VELOCITY
! not clean interface; going for working code first.
use WOD_read_routines_mod, only : WODREADDART, depth, temp, ierror, iderror, &
maxlevel, maxcalc, kdim, maxtcode, maxtax, maxpinf, &
bmiss, isec, sechead
implicit none
! version controlled file description for error handling, do not edit
character(len=256), parameter :: source = &
"$URL$"
character(len=32 ), parameter :: revision = "$Revision$"
character(len=128), parameter :: revdate = "$Date$"
integer, parameter :: num_copies = 1, & ! number of copies in sequence
num_qc = 1 ! number of QC entries
character (len=129) :: msgstring, next_infile, cdummy
integer :: j, k, nfiles, num_new_obs, castid, l
integer :: oday, osec
integer :: obsyear, obsmonth, obsday, obssec
integer :: obs_num, io, iunit, filenum, dummy
integer :: funit, levels, istdlev, nvar, nsecond, ieof
integer :: ip2(0:maxlevel), cast, itype
logical :: file_exist, did_obs, from_list = .false.
logical :: have_temp, have_salt
real(r8) :: terr, serr, &
phs, obs_val(1), &
d_qc(1)
real :: dtime, lato, lono
real(r8) :: obslat, obslon, obsdepth
! platform codes - reshape required by latest XLF compiler.
integer :: ptype(2, 16) = reshape( (/ &
MBT_TEMPERATURE, MBT_SALINITY, & ! ptype(1) = MBT
XBT_TEMPERATURE, XBT_SALINITY, & ! ptype(2) = XBT
DBT_TEMPERATURE, DBT_SALINITY, & ! ptype(3) = DBT
CTD_TEMPERATURE, CTD_SALINITY, & ! ptype(4) = CTD
STD_TEMPERATURE, STD_SALINITY, & ! ptype(5) = STD
XCTD_TEMPERATURE, XCTD_SALINITY, & ! ptype(6) = XCTD
BOTTLE_TEMPERATURE, BOTTLE_SALINITY, & ! ptype(7) = bottle
0, 0, & ! ptype(8) = underway
FLOAT_TEMPERATURE, FLOAT_SALINITY, & ! ptype(9) = profiling float
MOORING_TEMPERATURE, MOORING_SALINITY, & ! ptype(10) = moored buoy
DRIFTER_TEMPERATURE, DRIFTER_SALINITY, & ! ptype(11) = drifting buoy
TCTD_TEMPERATURE, TCTD_SALINITY, & ! ptype(12) = towed CTD
APB_TEMPERATURE, APB_SALINITY, & ! ptype(13) = animal
0, 0, & ! ptype(14) = bucket
GLIDER_TEMPERATURE, GLIDER_SALINITY, & ! ptype(15) = glider
MBT_TEMPERATURE, MBT_SALINITY /), & ! ptype(16) = microBT
(/ 2, 16 /) ) ! reshape 1d array into (2,16)
type(obs_sequence_type) :: obs_seq
type(obs_type) :: obs, prev_obs
type(time_type) :: obs_time, delta_time, prev_time
integer :: histbin(-1:26) = 0 ! for time debug
integer :: histcount = 0 ! for time debug
integer :: temp_type, salt_type, good_temp, good_salt, bad_temp, bad_salt
integer :: salt_qc(10), temp_qc(10)
!------------------------------------------------------------------------
! Declare namelist parameters
!------------------------------------------------------------------------
character(len=128) :: wod_input_file = 'XBTS2005'
character(len=128) :: wod_input_filelist = ''
character(len=128) :: wod_out_file = 'obs_seq.wod'
integer :: avg_obs_per_file = 500000
logical :: debug = .false.
logical :: timedebug = .false.
logical :: print_qc_summary = .true.
integer :: max_casts = -1
logical :: no_output_file = .false.
integer :: print_every_nth_cast = -1
real(r8) :: temperature_error = 0.5 ! degrees C
real(r8) :: salinity_error = 0.5 ! g/kg
integer :: start_month = 1
integer :: end_month = 12
namelist /wod_to_obs_nml/ &
wod_input_file, wod_input_filelist, wod_out_file, &
avg_obs_per_file, debug, max_casts, no_output_file, &
print_every_nth_cast, print_qc_summary, &
temperature_error, salinity_error, timedebug, &
start_month, end_month
! start of executable code
obs_num = 1
d_qc(1) = 0.0_r8
! time in files is year, month, day, fraction of day.
! day is sometimes = 0 (? not sure, am setting it to day 1).
! time often missing; am setting that to 0Z with less
! trepidation.
call set_calendar_type(GREGORIAN)
prev_time = set_date(4000, 1, 1) ! must be something later than all obs
! read the necessary parameters from input.nml
call initialize_utilities()
call find_namelist_in_file("input.nml", "wod_to_obs_nml", iunit)
read(iunit, nml = wod_to_obs_nml, iostat = io)
! Record the namelist values used for the run
if (do_output()) write(nmlfileunit, nml=wod_to_obs_nml)
! any needed namelist checks for sanity:
! cannot have both a single filename and a list; the namelist must
! shut one off.
if (wod_input_file /= '' .and. wod_input_filelist /= '') then
call error_handler(E_ERR, 'wod_to_obs', &
'One of wod_input_file or filelist must be NULL', &
source, revision, revdate)
endif
if (wod_input_filelist /= '') from_list = .true.
! need to know a reasonable max number of obs that could be added here.
if (from_list) then
call find_textfile_dims(wod_input_filelist, nfiles, dummy)
num_new_obs = avg_obs_per_file * nfiles
else
num_new_obs = avg_obs_per_file
endif
! FIXME: is this a good idea? to append to an existing file?
! either read existing obs_seq or create a new one
call static_init_obs_sequence()
call init_obs(obs, num_copies, num_qc)
call init_obs(prev_obs, num_copies, num_qc)
inquire(file=wod_out_file, exist=file_exist)
if (file_exist) then
print *, "replacing existing obs_seq file ", trim(wod_out_file)
else
print *, "creating obs_seq file ", trim(wod_out_file)
endif
print *, "max entries = ", num_new_obs
call init_obs_sequence(obs_seq, num_copies, num_qc, num_new_obs)
do k = 1, num_copies
call set_copy_meta_data(obs_seq, k, 'WOD observation')
end do
do k = 1, num_qc
call set_qc_meta_data(obs_seq, k, 'WOD QC')
end do
did_obs = .false.
! main loop that does either a single file or a list of files
filenum = 1
fileloop: do ! until out of files
! get the single name, or the next name from a list
if (from_list) then
next_infile = get_next_filename(wod_input_filelist, filenum)
else
next_infile = wod_input_file
if (filenum > 1) next_infile = ''
endif
if (next_infile == '') exit fileloop
have_temp = .false.
have_salt = .false.
!FIXME: more types? u, v, w current, ?
! open the next profile file
funit = open_file(next_infile, action='READ')
print *, ' '
print *, 'opening file ', trim(next_infile)
! reset anything that's per-file
good_temp = 0
bad_temp = 0
good_salt = 0
bad_salt = 0
temp_qc(:) = 0
salt_qc(:) = 0
cast = 1
castloop: do ! until out of data
call WODreadDART(funit,obsyear,obsmonth,obsday, &
dtime,lato,lono,levels,istdlev,nvar,ip2,nsecond, &
bmiss,castid,ieof)
!if (ieof /= 0) print *, 'ieof is ', ieof
! this comes back as 1 when the file has all been read.
if (ieof == 1) exit castloop
! see what data we have
if (nvar == 0) then
goto 20 ! inc counter, cycle castloop
endif
!print *, 'obsyear, obsmonth, obsday = ', obsyear, obsmonth, obsday
!print *, 'levels = ', levels
!print *, 'lato, lono = ', lato, lono
! need to gather:
! time (year, month, day, time), lat, lon, depth, obs type, ?.
! start out with converting the real time.
! do error check first. if fail, cycle here
! this routine alters bad days and times to be valid, or
! returns a failure and we loop here.
if (.not. date_ok(obsyear, obsmonth, obsday, &
dtime, bmiss, castid)) goto 20
! convert fractional hours (0-24) to integer days and seconds
! and add on to reference time. dtime was set to 0 if it was
! missing in the date_ok() routine.
obssec = int(dtime * 3600.0)
delta_time = set_time(obssec)
obs_time = set_date(obsyear, obsmonth, obsday) + delta_time
call get_time(obs_time, osec, oday)
!print *, 'oday, osec = ', oday, osec
!call print_date(obs_time)
if (debug) then
print *, ' --- '
print *, 'cast number: ', castid
print *, 'obsyear,month,day,time = ', obsyear, obsmonth, obsday, dtime
print *, 'lato, lono = ', lato, lono
endif
have_temp = .false.
have_salt = .false.
do k=1, nvar
if (ip2(k) == 1) have_temp = .true.
if (ip2(k) == 2) have_salt = .true.
enddo
temp_type = 0
salt_type = 0
do k=1, nsecond
if (isec(k) == 29) then
itype = int(sechead(29))
if (itype > 0 .and. itype <= 16) then
temp_type = ptype(1, itype)
salt_type = ptype(2, itype)
endif
if (itype > 0 .and. temp_type == 0) print *, 'temp=0, itype = ', itype
if (itype > 0 .and. salt_type == 0) print *, 'salt=0, itype = ', itype
endif
enddo
! debug
if (debug) then
print *, 'num levels: ', levels
print *, 'has temp, salinity: ', have_temp, have_salt
if (have_temp) then
cdummy = get_name_for_type_of_obs(temp_type)
print *, 'temp type/name: ', temp_type, trim(cdummy)
endif
if (have_salt) then
cdummy = get_name_for_type_of_obs(salt_type)
print *, 'salt type/name: ', salt_type, trim(cdummy)
endif
call print_date(obs_time, 'obs time')
endif
! FIXME: these are best-guess only.
terr = temperature_error ! degrees C
serr = salinity_error / 1000.0_r8 ! g/kg, convert to kg/kg
if (lono < 0.0_r8) lono = lono + 360.0_r8
obslon = lono
obslat = lato
if((obslon < 0.0_r8 .or. obslon > 360.0_r8) .or. (obslat < -90.0_r8 .or. obslat > 90.0_r8)) then
print *, 'FSC: longitude (',obslon,') or latitude (',obslat,') is not within range. cycle castloop'
goto 20 ! inc counter, cycle castloop
endif
if (have_temp) then
if (ierror(1) == 0) then
good_temp = good_temp + 1
else
bad_temp = bad_temp + 1
temp_qc(ierror(1)) = temp_qc(ierror(1)) + 1
endif
endif
if (have_salt) then
if (ierror(2) == 0) then
good_salt = good_salt + 1
else
bad_salt = bad_salt + 1
salt_qc(ierror(2)) = salt_qc(ierror(2)) + 1
endif
endif
if (debug) then
if (ierror(1) /= 0) print *, 'whole temp cast discarded, ierror == ', ierror(1)
if (ierror(2) /= 0) print *, 'whole salt cast discarded, ierror == ', ierror(2)
endif
! the incoming files are yearly collections. allow this converter to create
! output files which are only partial years by only processing selected months.
if (obsmonth < start_month .or. obsmonth > end_month) then
goto 20 ! inc counter, cycle castloop
endif
obsloop: do k = 1, levels
obsdepth = depth(k)
if (debug) then
write(*, "(A,F6.0,F8.3,F4.0,F8.3,F4.0)") "depth, temp/salt value,qc: ",&
depth(k), temp(k,1), iderror(k,1), temp(k, 2), iderror(k,2)
endif
! ierror is whole cast error
if (have_temp .and. ierror(1) == 0 .and. &
temp_type > 0 .and. temp(k, 1) /= bmiss &
.and. (.not. no_output_file)) then
! set location - incoming obs are -180 to 180 in longitude;
! dart wants 0 to 360. (also, r8)
call fill_obs(obs, obs_num, obslon, obslat, obsdepth, temp_type, &
obs_time, terr, real(temp(k, 1), r8), real(iderror(k, 1), r8))
call add_obs(obs_seq, obs, obs_time, prev_obs, prev_time)
if (.not. did_obs) did_obs = .true.
endif
! ierror is whole cast
if (have_salt .and. ierror(2) == 0 .and. &
salt_type > 0 .and. temp(k, 2) /= bmiss &
.and. (.not. no_output_file)) then
call fill_obs(obs, obs_num, obslon, obslat, obsdepth, salt_type, &
obs_time, serr, temp(k, 2) / 1000.0_r8, real(iderror(k, 2), r8))
call add_obs(obs_seq, obs, obs_time, prev_obs, prev_time)
if (.not. did_obs) did_obs = .true.
endif
end do obsloop
20 continue
if (print_every_nth_cast > 0) then
if (mod(cast, print_every_nth_cast) == 0) then
print *, 'processing cast ', cast
endif
endif
cast = cast + 1
if (max_casts > 0 .and. cast >= max_casts) exit castloop
end do castloop
call close_file(funit)
filenum = filenum + 1
if (print_qc_summary) then
call error_handler(E_MSG, '', '')
write(msgstring, *) 'input data filename: ', trim(next_infile)
call error_handler(E_MSG, '', msgstring)
call error_handler(E_MSG, '', '')
write(msgstring, *) 'total casts, total profiles: ', cast, &
good_temp+bad_temp+good_salt+bad_salt
call error_handler(E_MSG, '', msgstring)
write(msgstring, *) 'total/good/bad temperature profiles: ', &
good_temp+bad_temp, good_temp, bad_temp
call error_handler(E_MSG, '', msgstring)
write(msgstring, *) 'total/good/bad salinity profiles: ', &
good_salt+bad_salt, good_salt, bad_salt
call error_handler(E_MSG, '', msgstring)
call error_handler(E_MSG, '', '')
do j=1, 10
if (temp_qc(j) > 0) then
write(msgstring, *) 'temp qc of ', j, ' found ', temp_qc(j), ' times'
call error_handler(E_MSG, '', msgstring)
endif
enddo
call error_handler(E_MSG, '', '')
do j=1, 10
if (salt_qc(j) > 0) then
write(msgstring, *) 'salt qc of ', j, ' found ', salt_qc(j), ' times'
call error_handler(E_MSG, '', msgstring)
endif
enddo
call error_handler(E_MSG, '', '')
endif
end do fileloop
! done with main loop. if we added any obs to the sequence, write it out.
if (did_obs) then
print *, 'ready to write, nobs = ', get_num_obs(obs_seq)
if (get_num_obs(obs_seq) > 0) &
call write_obs_seq(obs_seq, wod_out_file)
! minor stab at cleanup, in the off chance this will someday get turned
! into a subroutine in a module. probably not all that needs to be done,
! but a start.
call destroy_obs(obs)
!call destroy_obs(prev_obs) ! is this identical to obs?
! get core dumps here, not sure why?
if (get_num_obs(obs_seq) > 0) call destroy_obs_sequence(obs_seq)
endif
! histogram of times, debug only
if (timedebug) then
print *, "total obs examined = ", histcount
print *, "bin -1 is < 0"
print *, "bin 0 is == 0"
print *, "bin 25 is > 24 but != 99.9"
print *, "bin 26 is == 99.9"
print *, " "
print *, 'bin count'
do l=lbound(histbin, 1), ubound(histbin, 1)
print *, l, histbin(l)
enddo
endif
call error_handler(E_MSG,'wod_to_obs','Finished successfully.',source,revision,revdate)
call finalize_utilities()
! END OF MAIN ROUTINE
contains
! local subroutines/functions follow
! subroutine to fill an obs. assumes loc is 3d, and vert is in meters.
subroutine fill_obs(obs, onum, olon, olat, odepth, otype, otime, oerr, &
oval, oqc)
type(obs_type), intent(inout) :: obs
integer, intent(inout) :: onum
real(r8), intent(in) :: olon, olat, odepth, oerr, oval, oqc
integer, intent(in) :: otype
type(time_type), intent(in) :: otime
type(obs_def_type) :: obs_def
real(r8) :: valarr(1), qcarr(1)
call set_obs_def_location(obs_def, &
set_location(olon, olat, odepth, VERTISHEIGHT))
call set_obs_def_type_of_obs(obs_def, otype)
call set_obs_def_time(obs_def, otime)
call set_obs_def_error_variance(obs_def, oerr * oerr)
call set_obs_def_key(obs_def, onum)
call set_obs_def(obs, obs_def)
valarr(1) = oval
call set_obs_values(obs, valarr)
qcarr(1) = oqc
call set_qc(obs, qcarr)
onum = onum + 1
end subroutine fill_obs
! add an obs to the sequence. if prev_time same or earlier
! than obs time, insert with search starting from prev obs.
subroutine add_obs(seq, obs, obs_time, prev_obs, prev_time)
! FIXME ... 'seq' in argument list never used ...
type(obs_sequence_type), intent(inout) :: seq
type(obs_type), intent(inout) :: obs, prev_obs
type(time_type), intent(in) :: obs_time
type(time_type), intent(inout) :: prev_time
logical, save :: first_obs = .true.
if (first_obs .or. prev_time > obs_time) then
call insert_obs_in_seq(obs_seq, obs)
first_obs = .false.
else
call insert_obs_in_seq(obs_seq, obs, prev_obs)
endif
prev_obs = obs
prev_time = obs_time
end subroutine add_obs
! date check, since a lot of these obs seem to have bad times/dates.
! modify testmonth, testday, dtime if we know what the right answer is.
! return .TRUE. if date ok, .FALSE. if bad and not fixable.
function date_ok(testyear, testmonth, testday, dtime, bmiss, castid)
integer, intent(inout) :: testyear, testmonth, testday
real, intent(inout) :: dtime ! note real, not real(r8), to match
real, intent(in) :: bmiss ! WOD-supplied code which uses reals
integer, intent(in) :: castid
logical :: date_ok
integer :: days_per_month(12) = (/31,28,31,30,31,30,31,31,30,31,30,31/)
type(time_type) :: test_time
! at least 2 files have dates of 2/29 on non-leap years. test for
! that and fix those dates. also found a 9/31, apparently without
! a bad cast qc. the 2/29s were examined and determined to be a bad
! conversion - should be mar 1 the 9/31s were recording errors and
! based on the other obs, should have been 9/30.
10 format (A,I9,A,I6,I4,I4,F6.2)
! bad month - return fail
if (testmonth <= 0 .or. testmonth > 12) then
write(*, 10) 'cast number: ', castid, ' date, dtime: ', testyear, testmonth, testday, dtime
write(*, *) ' bad month number, discarding observation'
date_ok = .FALSE.
return
endif
! try to estimate the time shifting error impacts from old code.
if (timedebug) then
histcount = histcount + 1
if (dtime == bmiss) then
! no count. it is ok since we discarded it before
else if (dtime < 0.0) then
histbin(-1) = histbin(-1) + 1
else if (dtime == 0.0) then
histbin(0) = histbin(0) + 1
else if (dtime == 99.9) then
histbin(26) = histbin(26) + 1
else if (dtime > 24.0) then
histbin(25) = histbin(25) + 1
else
histbin(int(dtime)) = histbin(int(dtime)) + 1
endif
endif
! check time - if standard missing value, don't squawk.
! otherwise, note the cast number and original value, and
! then set to 0, or fail.
if (dtime == bmiss) then
dtime = 0.0
else if (dtime == 99.90) then
! seems to be an alternative missing value in some few cases.
! got confirmation from WOD providers that this was an incorrect
! missing value and future versions of the WOD will use the standard
! 'missing_value' read out of the file (bmiss in this subroutine,
! appears to be something like -999.99)
write(*, 10) 'cast number: ', castid, ' date, dtime: ', testyear, testmonth, testday, dtime
write(*, *) ' setting to 0 and continuing'
dtime = 0.0
else if (dtime < 0) then
write(*, 10) 'cast number: ', castid, ' date, dtime: ', testyear, testmonth, testday, dtime
write(*, *) ' setting to 0 and continuing'
dtime = 0.0
else if (dtime > 24.0) then
write(*, 10) 'cast number: ', castid, ' date, dtime: ', testyear, testmonth, testday, dtime
! some obs seem to have more than 24 hours in the time variable.
! got confirmation from WOD providers that some appear to be keypunch
! entry errors. this field should never be > 24. for now, set to 0
! because the date is believed to be good.
!write(*, *) ' discarding obs'
!date_ok = .FALSE.
!return
write(*, *) ' setting to 0 and continuing'
dtime = 0.0
endif
! good day - return success
if (testday > 0 .and. testday <= days_per_month(testmonth)) then
date_ok = .TRUE.
return
endif
! don't do the year test unless this is leap day.
if ((testmonth == 2) .and. (testday == 29)) then
! jan 1st always exists. set this so we can test for leap year.
test_time = set_date(testyear, 1, 1)
if (.not. leap_year(test_time)) then
write(*, 10) 'cast number: ', castid, ' date, dtime: ', testyear, testmonth, testday, dtime
write(*, *) ' does not exist in this non-leap year; setting to mar 1'
! convert this to mar 1 (date conversion error)
testmonth = 3
testday = 1
endif
date_ok = .TRUE.
return
endif
! day 0 is possibly a processing error, but actual day is currently unknown.
! i have been advised to discard these, which i am reluctantly going to do.
if (testday == 0) then
write(*, 10) 'cast number: ', castid, ' date, dtime: ', testyear, testmonth, testday, dtime
write(*, *) ' does not exist; discarding obs'
date_ok = .FALSE.
return
! alternative code - keep obs and set day to 1 and time to 0.
!write(*, *) ' setting day to 1, dtime to 0'
!testday = 1
!dtime = 0.0
!date_ok = .TRUE.
return
endif
! if only 1 > end of month, set to end of month and succeed.
! if more than 1 > end of month, fail.
! found other files with 4/31 and 6/39 as dates.
if (testday > days_per_month(testmonth)+1) then
write(*, 10) 'cast number: ', castid, ' date, dtime: ', testyear, testmonth, testday, dtime
write(*, *) ' does not exist; discarding obs'
date_ok = .FALSE.
return
endif
! not sure this is a good idea; maybe should discard these obs?
if (testday == days_per_month(testmonth)+1) then
write(*, 10) 'cast number: ', castid, ' date, dtime: ', testyear, testmonth, testday, dtime
write(*, *) ' does not exist; assuming rollover to day 1, month+1, dtime to 0'
dtime = 0.0
testday = 1
testmonth = testmonth + 1
if (testmonth > 12) then
testmonth = 1
testyear = testyear + 1
endif
date_ok = .TRUE.
return
endif
! shouldn't get here. assume bad date.
write(*, 10) 'cast number: ', castid, ' date, dtime: ', testyear, testmonth, testday, dtime
write(*, *) ' bad date; discarding obs'
date_ok = .FALSE.
return
end function date_ok
end program wod_to_obs
! <next few lines under version control, do not edit>
! $URL$
! $Id$
! $Revision$
! $Date$
| observations/obs_converters/WOD/wod_to_obs.f90 |
subroutine setprob
implicit double precision (a-h,o-z)
common /comrp/ grav
common /comsrc/ ndim
common/cdisc/ x0,y0,alf,beta,r0,idisc
common /comic/ hin,hout
c
c # Set the material parameters for the acoustic equations
c # Passed to the Riemann solver rp1.f in a common block
c
open(unit=7,file='setprob.data',status='old',form='formatted')
c # ndim = space dimensions (2 = cylindrical symmetry, 3 = spherical)
read(7,*) ndim
c # gravitational constant:
read(7,*) grav
c # data for radial dam-break problem:
read(7,*) x0,y0,r0
read(7,*) hin,hout
c
return
end
| applications/geoclaw/bowl_radial/1drad/setprob.f |
less_toxic(dd1,f1).
less_toxic(f1,c1).
less_toxic(bb1,p1).
less_toxic(i1,p1).
| foldsCreator/files/datasets/alzheimer_toxic_noiseless/incremental1/test2.f |
! ###################################################################
! Copyright (c) 2013-2022, Marc De Graef Research Group/Carnegie Mellon University
! All rights reserved.
!
! Redistribution and use in source and binary forms, with or without modification, are
! permitted provided that the following conditions are met:
!
! - Redistributions of source code must retain the above copyright notice, this list
! of conditions and the following disclaimer.
! - Redistributions in binary form must reproduce the above copyright notice, this
! list of conditions and the following disclaimer in the documentation and/or
! other materials provided with the distribution.
! - Neither the names of Marc De Graef, Carnegie Mellon University nor the names
! of its contributors may be used to endorse or promote products derived from
! this software without specific prior written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
! USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! ###################################################################
!--------------------------------------------------------------------------
! EMsoft:EMshowxtal.f90
!--------------------------------------------------------------------------
!
! PROGRAM: EMshowxtal
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief Display crystal structure information
!
!> @date 07/31/18 MDG 1.0 original
!> @date 12/23/18 MDG 1.1 minor reorganization
!--------------------------------------------------------------------------
program EMshowxtal
!! author: MDG
!! version: 1.0
!! date: 01/23/20
!!
!! Display (quasi-)crystal structure information
use mod_kinds
use mod_global
use mod_EMsoft
use mod_symmetry
use mod_io
use mod_HDFsupport
use HDF5
use mod_crystallography
use mod_rotations
use mod_quaternions
use mod_so3
use mod_misc
use mod_QCsymmetry
use mod_QCcrystallography
use stringconstants
IMPLICIT NONE
character(fnlen) :: progname = 'EMshowxtal.f90'
character(fnlen) :: progdesc = 'Display crystal structure information'
type(EMsoft_T) :: EMsoft
type(IO_T) :: Message
type(Cell_T) :: cell
type(SpaceGroup_T) :: SG
type(QCcell_axial_T) :: QCcell_axial
type(QCcell_icosahedral_T) :: QCcell_icosahedral
type(QCSpaceGroup_T) :: QCSG
type(HDF_T) :: HDF
character(fnlen) :: xtalname, fname, dataset, groupname
logical :: verbose=.TRUE., g_exists
integer(kind=irg) :: i, j, hdferr, N_Axial
character(1) :: yesno
real(kind=dbl),allocatable :: data(:,:,:), direc(:,:,:), recip(:,:,:)
! header and command line arguments, if any
EMsoft = EMsoft_T( progname, progdesc, tpl = (/ 921 /) )
! ask for the crystal structure file
call Message%ReadValue(' Enter xtal file name [*.xtal, *.qxtal]: ', xtalname,"(A)")
! is this a regular .xtal file or a quasi-crystal file .qxtal?
i = INDEX(trim(xtalname), 'qxtal')
if (i.eq.0) then ! regular crystal structure file
call cell%getCrystalData(xtalname, SG, EMsoft, verbose=.TRUE.)
call Message%ReadValue('Do you want to print the symmetry matrices as well ? (y/n) ', yesno)
if (yesno.eq.'y') then
call Message%printMessage('Space group operators (last column = translation)')
data = SG%getSpaceGroupDataMatrices()
do i=1,SG%getSpaceGroupMATnum()
write (*,*) i,':'
write (*,*) (data(i,1,j),j=1,4)
write (*,*) (data(i,2,j),j=1,4)
write (*,*) (data(i,3,j),j=1,4)
write (*,*) ' '
end do
call Message%printMessage('Point group operators')
call Message%printMessage(' Direct space Reciprocal space')
direc = SG%getSpaceGroupPGdirecMatrices()
recip = SG%getSpaceGroupPGrecipMatrices()
do i=1,SG%getSpaceGroupNUMpt()
write (*,*) i,':'
write (*,*) (direc(i,1,j),j=1,3),' ',(recip(i,1,j),j=1,3)
write (*,*) (direc(i,2,j),j=1,3),' ',(recip(i,2,j),j=1,3)
write (*,*) (direc(i,3,j),j=1,3),' ',(recip(i,3,j),j=1,3)
write (*,*) ' '
end do
endif
else ! quasi-crystal structure file
fname = trim(EMsoft%generateFilePath('EMXtalFolderpathname',trim(xtalname)))
! first we need to check if the N_Axial field exists in this file
call openFortranHDFInterface()
HDF = HDF_T()
hdferr = HDF%openFile(fname, readonly = .TRUE.)
if (hdferr.ne.0) call HDF%error_check('ReadQCDataHDF:HDF%openFile:'//trim(fname), hdferr)
groupname = SC_CrystalData
hdferr = HDF%openGroup(groupname)
if (hdferr.ne.0) call HDF%error_check('ReadQCDataHDF:HDF%openGroup:'//trim(groupname), hdferr)
! is this an axial or icosahedral structure?
dataset = SC_AxialSymmetry
call H5Lexists_f(HDF%getobjectID(),trim(dataset),g_exists, hdferr)
if (g_exists) then
QCcell_axial = QCcell_axial_T()
call HDF%readDatasetInteger(dataset, hdferr, N_Axial)
if (hdferr.ne.0) call HDF%error_check('ReadQCDataHDF:HDF%readDatasetInteger:'//trim(dataset), hdferr)
call HDF%pop(.TRUE.)
call closeFortranHDFInterface()
if (N_Axial.eq.8) QCSG = QCspacegroup_T( nD = 2, QCtype = 'Oct')
if (N_Axial.eq.10) QCSG = QCspacegroup_T( nD = 2, QCtype = 'Dec')
if (N_Axial.eq.12) QCSG = QCspacegroup_T( nD = 2, QCtype = 'DoD')
call QCcell_axial%setfname(xtalname)
call QCcell_axial%ReadQCDataHDF(QCSG, EMsoft)
! call QCSG%printSGtable()
call QCcell_axial%setMetricParametersQC()
call QCSG%GenerateQCSymmetry(dopg=.FALSE.)
call QCcell_axial%DumpQXtalInfo(QCSG)
else
call HDF%pop(.TRUE.)
call closeFortranHDFInterface()
QCcell_icosahedral = QCcell_icosahedral_T()
call QCcell_icosahedral%setfname(xtalname)
QCSG = QCspacegroup_T( nD = 3, QCtype = 'Ico')
call QCcell_icosahedral%ReadQCDataHDF(QCSG, EMsoft)
! call QCSG%printSGtable()
call QCcell_icosahedral%setMetricParametersQC()
call QCSG%GenerateQCSymmetry(dopg=.FALSE.)
call QCcell_icosahedral%DumpQXtalInfo(QCSG)
end if
end if
end program EMshowxtal
| Source/Utilities/EMshowxtal.f90 |
C =======================================================
Subroutine clpsF1(
C =======================================================
c group (M)
& iwF, iwE,
& nP, nF, nE,
& XYP, IPF, IPE,
& calCrv, parCrv, iFnc,
& hStar,
& ICP, IEP, IFE, IEE,
& L1E, L2E, nL2, nStep,
& IHolP, IHolF, IHolE,
& status,
c group (CRV)
& L1Et, L2Et, tE,
& nL2t, nStept, nEt,
& nCrvFnc, LFnc, ILt,
C group (Q)
& HesP, rQuality, detG, qE,
& MetricFunction, flagAnalytic,
C group (S)
& lFu, lEu, iFu, iEu, IPFu, IPEu, qEu,
C group (W)
& nPw, nEw, XYPw, HesPw, IPEw,
& iSE, rSE, w1, w2,
& flag)
C =======================================================
include 'makS.fd'
include 'colors.fd'
include 'status.fd'
include 'operat.fd'
C =======================================================
C Routine realizes one of the mesh operations: collapses
C edge iwF of element iwE to its middle point.
C
C *** DATA FLOW CHART
C
C -> simple check if the edge can be collapsed
C -> collect information about the edge
c
c -> define a point to collapse the edge
c ----> mid-point of the edge
c ----> projection onto the curved boundary
c ----> one of the terminal points of the edge
c
c -> virtual evaluation of the element quality
c
c -> check that no boundary triangles were created
c -> check that 2-arm rule helds
c -> check that no traingles were tangled
c
c -> update the quality of new mesh elements
c -> update the list of curvilinear edges
c -> update mesh cross-references for the new elements
C =======================================================
C group (M)
Integer IPF(4, *), IPE(3, *)
real XYP(2, *)
EXTERNAL calCrv
Integer iFnc(*)
real parCrv(2, *), hStar
Integer L1E(2, *), L2E(*), nStep(4)
Integer IHolP(*), IHolF(*), IHolE(*)
Integer ICP(*), IEP(*)
Integer IFE(3, *), IEE(3, *)
Integer status
C group (CRV)
real tE(*)
Integer L1Et(2, *), L2Et(*)
Integer nL2t(*), nStept(4, *), nEt(*)
Integer LFnc(*), ILt(*)
C group (Q)
real HesP(3, *), rQuality
real detG(*), qE(*)
Logical flagAnalytic
Integer MetricFunction
EXTERNAL MetricFunction
C group (S)
Integer iFu(*), iEu(*), IPFu(3, *), IPEu(3, *)
real qEu(*)
C group (W)
Integer IPEw(3, *), iSE(*)
real XYPw(2, *), HesPw(3, *)
real rSE(*), w1, w2
C group (Flag)
Logical flag
C group (Local variables)
Integer iFs(MaxS), iEs(MaxS), IPFs(2, MaxS), IPEs(3, MaxS)
real prjXYPs(2), XYPs(2), HesPs(3), detGs, qEs(MaxS)
real XYPo(2)
Integer ip(4), iPs(MaxS), iOs(MaxS)
real par(6), t1, t2, tc
Logical flagBNDs, flagOrient, flagFirst, flagTM
Logical chkTangled, ifXnode
Integer minClr
C =======================================================
flag = .FALSE.
Call copySE(lFu, lEu, iFu, iEu, IPFu, IPEu, qEu,
& lF, lE, iFs, iEs, IPFs, IPEs, qEs)
ip(1) = 1
ip(2) = 2
ip(3) = 3
ip(4) = 1
i1 = iwF
i2 = ip(i1 + 1)
i3 = ip(i2 + 1)
iP1 = IPE(i1, iwE)
iP2 = IPE(i2, iwE)
iP3 = IPE(i3, iwE)
iF = IFE(iwF, iwE)
iE1 = iwE
iE2 = IEE(iwF, iE1)
C ... checking for faces which can not be collapsed
ICP1 = ICP(iP1)
ICP2 = ICP(iP2)
ICP3 = ICP(iP3)
ICPs = minClr(ICP1, ICP2)
If(ifXnode(ICPs, jVnode)) goto 1000
If(ifXnode(ICPs, jTnode)) goto 1000
If(ifXnode(ICPs, jSnode) .AND. iF.EQ.0) goto 1000
ICPt = maxClr(ICP1, ICP2)
If(ifXnode(ICPt, jVnode) .AND. ifXnode(ICPt, jTnode)) Goto 1000
C ... gathering information about the face
Do i = 1, 6
par(i) = 0D0
End do
If(iF.NE.0) Then
Call infoF(iF, iP1, iP2, iF1, iF2, iPc, iPd,
& par, IPF, parCrv, lF, iFs)
If(iPc.LE.0 .OR. iPd.LE.0) goto 1000
End if
C ... checking for inverted elements
flagTM = ifXnode(status, ANIUntangleMesh)
if(flagTM) Then
nBad = 0
Do n = 1, lE
If(qEs(n).LE.0D0) nBad = nBad + 1
End do
End if
if(flagTM) Then
flagTM = nBad.GT.0
End if
C ... finding a point in which we collapse the edge
iFNCs = 0
If(ICP1.EQ.jInode .AND. ICP2.EQ.jInode) Then
ICPs = jInode
Do i = 1, 2
XYPs(i) = XYP(i, iP1) * w1 + XYP(i, iP2) * w2
End do
Do i = 1, 3
HesPs(i) = HesP(i, iP1) * w1 + HesP(i, iP2) * w2
End do
If(.NOT.flagAnalytic) Then
Call LINTRP(nEw, IPEw, nPw, XYPw, 3, HesPw, 1,
& XYPs, HesPs, iSE, rSE, .FALSE.)
Else
Call scaleBack(XYPs, XYPo)
Call iniQ_analytic(1, XYPo, MetricFunction, HesPs)
End if
Call calDet(HesPs, detGs)
Else If(ifXnode(ICP1, jSnode) .AND. ICP2.EQ.jInode .OR.
& ifXnode(ICP1, jTnode) .AND. ICP2.EQ.jInode .OR.
& ifXnode(ICP1, jTnode) .AND. ifXnode(ICPs, jBnode) .OR.
& ifXnode(ICP1, jVnode)) Then
ICPs = ICP1
Do i = 1, 2
XYPs(i) = XYP(i, iP1)
End do
Do i = 1, 3
HesPs(i) = HesP(i, iP1)
End do
detGs = detG(iP1)
t1 = par(2)
t2 = par(3)
Else If(ifXnode(ICP2, jSnode) .AND. ICP1.EQ.jInode .OR.
& ifXnode(ICP2, jTnode) .AND. ICP1.EQ.jInode .OR.
& ifXnode(ICP2, jTnode) .AND. ifXnode(ICPs, jBnode) .OR.
& ifXnode(ICP2, jVnode)) Then
ICPs = ICP2
Do i = 1, 2
XYPs(i) = XYP(i, iP2)
End do
Do i = 1, 3
HesPs(i) = HesP(i, iP2)
End do
detGs = detG(iP2)
t1 = par(4)
t2 = par(5)
C ... changing order of points to be consistent with the previous case
i = iP2
iP2 = iP1
iP1 = i
Else If(ifXnode(ICPs, jSnode)) Then
c! ICPs = minClr(ICP1, ICP2)
iCRVs = IPF(3, iF)
If(iCRVs.NE.0) Then
t1 = par(3)
t2 = par(4)
tc = (t1 + t2) / 2
iFNCs = iFnc(iCRVs)
Call aniCrv(tc, XYPs, iFNCs, calCrv)
t1 = tc
t2 = tc
Call findSE(nCrvFnc, LFnc, iFNCs, k)
ir = ILt(k)
Call prjCrv(XYPs, prjXYPs, iFNCs, tc, calCrv,
& L1Et(1, ir), L2Et(ir), nL2t(k), nStept(1, k),
& nEt(k), tE(ir))
If(.NOT.flagAnalytic) Then
Call LINTRP(nEw, IPEw, nPw, XYPw, 3, HesPw, 1,
& prjXYPs, HesPs, iSE, rSE, .FALSE.)
Else
Call scaleBack(prjXYPs, XYPo)
Call iniQ_analytic(1, XYPo, MetricFunction, HesPs)
End if
Else
Do i = 1, 2
XYPs(i) = (XYP(i, iP1) + XYP(i, iP2)) / 2
End do
If(.NOT.flagAnalytic) Then
Call LINTRP(nEw, IPEw, nPw, XYPw, 3, HesPw, 1,
& XYPs, HesPs, iSE, rSE, .FALSE.)
Else
Call scaleBack(XYPs, XYPo)
Call iniQ_analytic(1, XYPo, MetricFunction, HesPs)
End if
End if
Call calDet(HesPs, detGs)
Else
goto 1000
End if
C ... virtual evaluation of the superelement quality
Do 10 n = 1, lE
iE = iEs(n)
If(iE.EQ.iE1 .OR. iE.EQ.iE2) Then
iEs(n) = -iEs(n)
goto 10
End if
Do i1 = 1, 3
If(IPEs(i1, n).EQ.iP1 .OR. IPEs(i1, n).EQ.iP2) Then
i2 = ip(i1 + 1)
i3 = ip(i2 + 1)
IPEs(i1, n) = iP1
iPa = IPEs(i2, n)
iPb = IPEs(i3, n)
Call calQE(
& HesP(1, iPa), XYP(1, iPa),
& HesP(1, iPb), XYP(1, iPb),
& HesPs, XYPs,
& hStar, qEs(n))
If((1.05*qEs(n)).LE.rQuality) goto 1000
goto 10
End if
End do
iEs(n) = 0
10 Continue
C ... checking for boundary triangles
If(ifXnode(status, ANIForbidBoundaryElements)) Then
Do 20 n = 1, lE
iE = iEs(n)
If(iE.LE.0) goto 20
Do i = 1, 3
iPt = IPEs(i, n)
If(ifXnode(ICP(iPt), jInode)) goto 20
End do
goto 1000
20 Continue
End if
C ... checking for surrounding points (not ICP1 but ICP(iP1))
If(ifXnode(status, ANIUse2ArmRule)) Then
If(ifXnode(ICP(iP1), jBnode) .AND. ICP(iP2).EQ.jInode) Then
Call chkSPf(iP1, iP2, ICP, IEP, IPE, IEE, lP, iPs)
Call chkSPb(iP1, iP2, 0, 0, iCLPS,
& ICP, IEP, IPE, IEE, lP, iPs, flagBNDs)
If(flagBNDs) goto 1000
End if
End if
C ... checking for orientation of triangles
Call calSO(XYP, IPE, lE, iEs, iOs)
Call chkSO(iP1, iP2, XYPs, XYP, IPE, lE, iEs, iOs, flagOrient)
If(.NOT.flagOrient) goto 1000
C ... checking for inverted elements
If(flagTM) Then
Do n = 1, lE
If(iEs(n).GE.0 .AND. qEs(n).GT.0D0) Then
Call updQb(n, lE, iEs, XYP, IPEs, qEs)
End if
End do
mBad = 0
Do n = 1, lE
If(iEs(n).GE.0 .AND. qEs(n).LE.0D0) mBad = mBad + 1
End do
If(mBad.GE.nBad) goto 1000
C ... colapsing may result in topologically wrong mesh
flagTM = chkTangled(lE, iEs, IPEs)
If(flagTM) goto 1000
End if
c ... updating the quality
If(ifXnode(status, ANISmoothMesh)) Then
flagFirst = .TRUE.
Call updQE(XYP, lE, iEs, IPEs,
& HesP, rQuality, detG, hStar, qEs, flagFirst)
If(.NOT.flagFirst) goto 1000
End if
C ... updating the grid
flag = .TRUE.
If(ifXnode(ICP1, jTnode) .or. ifXnode(ICP2, jTnode)) then
call addXnode(ICPs, jTnode)
end if
Call pntUpd(iP1, ICP, XYP, HesP, detG,
& ICPs, XYPs, HesPs, detGs)
Call pntDel(iP2, nP, ICP, IHolP)
If(ifXnode(ICP1, jSnode) .AND. ifXnode(ICP2, jSnode)) Then
Call findSE(lF, iFs, iF, nFd)
Call facDel(iF, nF, IPF, iFnc, IHolF)
iFs(nFd) = -iFs(nFd)
Call findSE(lF, iFs, iF1, nF1)
Call findSE(lF, iFs, iF2, nF2)
IPFs(1, nF1) = iPc
IPFs(2, nF1) = iP1
IPFs(1, nF2) = iP1
IPFs(2, nF2) = iPd
iCRVs = IPF(3, iF1)
iFNCs = iFnc(iF1)
iBNDs = IPF(4, iF1)
Call facUpd(nF1, IPF, parCrv, iFnc,
& iFs, IPFs, iCRVs, iFNCs, iBNDs, par(1), t1)
iCRVs = IPF(3, iF2)
iFNCs = iFnc(iF2)
iBNDs = IPF(4, iF2)
Call facUpd(nF2, IPF, parCrv, iFnc,
& iFs, IPFs, iCRVs, iFNCs, iBNDs, t2, par(6))
End if
Do n = 1, lE
iEt = iEs(n)
If(iEt.LT.0) Then
iEt = -iEt
Call lstDel(nE, L1E, nL2, L2E, nStep, IHolE, qE, iEt)
Call eleDel(iEt, IPE, IEE)
Else If(iEt.GT.0) Then
Call lstUpd(nE, L1E, nL2, L2E, nStep, qE, iEt, qEs(n))
Call eleUpd(n, IEP, IPE, IFE, IEE,
& lF, lE, iFs, iEs, IPFs, IPEs)
End if
End do
1000 Return
End
C =======================================================
Subroutine clpsF2(
C =======================================================
c group (M)
& iwP, iwE,
& nP, nF, nE,
& XYP, IPF, IPE,
& calCrv, parCrv, iFnc,
& hStar,
& ICP, IEP, IFE, IEE,
& L1E, L2E, nL2, nStep,
& IHolP, IHolF, IHolE,
& status,
c group (CRV)
& L1Et, L2Et, tE,
& nL2t, nStept, nEt,
& nCrvFnc, LFnc, ILt,
C group (Q)
& HesP, rQuality, detG, qE,
& MetricFunction, flagAnalytic,
C group (S)
& lEu, iEu,
C group (W)
& nPw, nEw, XYPw, HesPw, IPEw,
& iSE, rSE,
& flag)
C =======================================================
include 'makS.fd'
include 'colors.fd'
include 'status.fd'
C =======================================================
C Routine realizes one of the mesh operations: collapses
C an edge ending at point iwP of element iwE. It uses the
C main routine clpsF1.
C =======================================================
C group (M)
Integer IPF(4, *), IPE(3, *)
real XYP(2, *)
EXTERNAL calCrv
Integer iFnc(*)
real parCrv(2, *), hStar
Integer L1E(2, *), L2E(*), nStep(4)
Integer IHolP(*), IHolF(*), IHolE(*)
Integer ICP(*), IEP(*)
Integer IFE(3, *), IEE(3, *)
Integer status
C group (CRV)
real tE(*)
Integer L1Et(2, *), L2Et(*)
Integer nL2t(*), nStept(4, *), nEt(*)
Integer LFnc(*), ILt(*)
C group (Q)
real HesP(3, *), rQuality
real detG(*), qE(*)
Logical flagAnalytic
Integer MetricFunction
EXTERNAL MetricFunction
C group (S)
Integer iEu(*)
C group (W)
Integer IPEw(3, *), iSE(*)
real XYPw(2, *), HesPw(3, *)
real rSE(*)
C group (Flag)
Logical flag
C group (Local variables)
Integer iFs(MaxS), iEs(MaxS), IPFs(2, MaxS), IPEs(3, MaxS)
real qEs(MaxS)
Integer ip(4)
real d, w1, w2
Logical ifXnode
C =======================================================
flag = .FALSE.
ip(1) = 1
ip(2) = 2
ip(3) = 3
ip(4) = 1
C ... checking points which can not be involved
iP1 = IPE(iwP, iwE)
If(ifXnode(ICP(iP1), jSnode)) goto 1000
If(ifXnode(ICP(iP1), jTnode)) goto 1000
i2 = ip(iwP + 1)
i3 = ip(i2 + 1)
iPa = IPE(i2, iwE)
iPb = IPE(i3, iwE)
Do 10 k = 1, lEu
kE = iEu(k)
If(kE.EQ.iwE) goto 10
Do i = 1, 3
If(IPE(i, kE).EQ.iP1) Then
i1 = i
goto 5
End if
End do
goto 10
5 i2 = ip(i1 + 1)
i3 = ip(i2 + 1)
iP2 = IPE(i2, kE)
iP3 = IPE(i3, kE)
d = (XYP(1, iP2) - XYP(1, iP1)) *
& (XYP(2, iP3) - XYP(2, iP1)) -
& (XYP(1, iP3) - XYP(1, iP1)) *
& (XYP(2, iP2) - XYP(2, iP1))
If(d.LT.0D0) Then
iwF = min(i1, i3)
itF = max(i1, i3)
If(iP3.EQ.iPa .OR. iP3.EQ.iPb) goto 10
Else
iwF = min(i1, i2)
itF = max(i1, i2)
If(iP2.EQ.iPa .OR. iP2.EQ.iPb) goto 10
End if
If(iwF.EQ.1 .AND. itF.EQ.3) iwF = 3
If(iwF.EQ.i1) Then
w1 = 0D0
w2 = 1D0
Else
w1 = 1D0
w2 = 0D0
End if
Call makSE(kE, IEP, IPF, IPE, IFE, IEE, qE, MaxS,
& lFs, lEs, iFs, iEs, IPFs, IPEs, qEs,
& status)
Call clpsF1(
c group (M)
& iwF, kE,
& nP, nF, nE,
& XYP, IPF, IPE,
& calCrv, parCrv, iFnc,
& hStar,
& ICP, IEP, IFE, IEE,
& L1E, L2E, nL2, nStep,
& IHolP, IHolF, IHolE,
& status,
c group (CRV)
& L1Et, L2Et, tE,
& nL2t, nStept, nEt,
& nCrvFnc, LFnc, ILt,
C group (Q)
& HesP, rQuality, detG, qE,
& MetricFunction, flagAnalytic,
C group (S)
& lFs, lEs, iFs, iEs, IPFs, IPEs, qEs,
C group (W)
& nPw, nEw, XYPw, HesPw, IPEw,
& iSE, rSE, w1, w2,
& flag)
If(flag) goto 1000
10 Continue
1000 Return
End
| software/multifluids_icferst/libmba2d/clpsF.f |
integer Pbb,Nbmax
parameter(Pbb =6)
parameter(Nbmax =50)
| MCFM-JHUGen/TensorReduction/Include/ovBnames.f |
SUBROUTINE DQ7APL(NN, N, P, J, R, IERR)
C *****PARAMETERS.
INTEGER NN, N, P, IERR
DOUBLE PRECISION J(NN,P), R(N)
C
C ..................................................................
C ..................................................................
C
C *****PURPOSE.
C THIS SUBROUTINE APPLIES TO R THE ORTHOGONAL TRANSFORMATIONS
C STORED IN J BY QRFACT
C
C *****PARAMETER DESCRIPTION.
C ON INPUT.
C
C NN IS THE ROW DIMENSION OF THE MATRIX J AS DECLARED IN
C THE CALLING PROGRAM DIMENSION STATEMENT
C
C N IS THE NUMBER OF ROWS OF J AND THE SIZE OF THE VECTOR R
C
C P IS THE NUMBER OF COLUMNS OF J AND THE SIZE OF SIGMA
C
C J CONTAINS ON AND BELOW ITS DIAGONAL THE COLUMN VECTORS
C U WHICH DETERMINE THE HOUSEHOLDER TRANSFORMATIONS
C IDENT - U*U.TRANSPOSE
C
C R IS THE RIGHT HAND SIDE VECTOR TO WHICH THE ORTHOGONAL
C TRANSFORMATIONS WILL BE APPLIED
C
C IERR IF NON-ZERO INDICATES THAT NOT ALL THE TRANSFORMATIONS
C WERE SUCCESSFULLY DETERMINED AND ONLY THE FIRST
C ABS(IERR) - 1 TRANSFORMATIONS WILL BE USED
C
C ON OUTPUT.
C
C R HAS BEEN OVERWRITTEN BY ITS TRANSFORMED IMAGE
C
C *****APPLICATION AND USAGE RESTRICTIONS.
C NONE
C
C *****ALGORITHM NOTES.
C THE VECTORS U WHICH DETERMINE THE HOUSEHOLDER TRANSFORMATIONS
C ARE NORMALIZED SO THAT THEIR 2-NORM SQUARED IS 2. THE USE OF
C THESE TRANSFORMATIONS HERE IS IN THE SPIRIT OF (1).
C
C *****SUBROUTINES AND FUNCTIONS CALLED.
C
C DD7TPR - FUNCTION, RETURNS THE INNER PRODUCT OF VECTORS
C
C *****REFERENCES.
C (1) BUSINGER, P. A., AND GOLUB, G. H. (1965), LINEAR LEAST SQUARES
C SOLUTIONS BY HOUSEHOLDER TRANSFORMATIONS, NUMER. MATH. 7,
C PP. 269-276.
C
C *****HISTORY.
C DESIGNED BY DAVID M. GAY, CODED BY STEPHEN C. PETERS (WINTER 1977)
C CALL ON DV2AXY SUBSTITUTED FOR DO LOOP, FALL 1983.
C
C *****GENERAL.
C
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, AND MCS76-11989.
C
C ..................................................................
C ..................................................................
C
C *****LOCAL VARIABLES.
INTEGER K, L, NL1
C *****FUNCTIONS.
DOUBLE PRECISION DD7TPR
EXTERNAL DD7TPR,DV2AXY
C
C *** BODY ***
C
K = P
IF (IERR .NE. 0) K = IABS(IERR) - 1
IF ( K .EQ. 0) GO TO 999
C
DO 20 L = 1, K
NL1 = N - L + 1
CALL DV2AXY(NL1, R(L), -DD7TPR(NL1,J(L,L),R(L)), J(L,L), R(L))
20 CONTINUE
C
999 RETURN
C *** LAST LINE OF DQ7APL FOLLOWS ***
END
| src/ib/port3/dq7apl.f |
C------------------------------------------------------------------------------
C PROGRAM GETPC
C Purpose: Retrieves PC from SPICE kernal and assign to TAE variable.
C For GLL and CASSI, also assigns SCLAT, SCLON, and SCALE to TAE variable.
C------------------------------------------------------------------------------
INCLUDE 'VICMAIN_FOR'
SUBROUTINE MAIN44
IMPLICIT NONE
INTEGER IND
REAL*4 C(2),DATA(40),SCL, CONV(3)
CHARACTER*4 CKNReturn
CHARACTER*5 Project
INTEGER Camera
CALL xvmessage ('GETPC Version Jan 30, 2003',' ')
CALL MSEDR(IND,Project,Camera,CKNReturn,DATA,SCL)
IF (IND .LT. 0) THEN
CALL ABEND
END IF
C-----LAT LON to LINE SAMP Conversion
IF (project.EQ.'GLL ' .OR. project.EQ.'CASSI') THEN
CALL mvcl (PROJECT, conv, 5)
CALL mve (4,1,CAMERA, conv(3),1,1)
END IF
CALL CONVEV(IND,DATA,DATA,C(1),C(2),DATA(31),DATA(32),1,CONV)
CALL PPC(Project,C,CKNReturn,data(31),data(32),SCL)
RETURN
END
C------------------------------------------------------------------------------
C Subroutine MSEDR
C Input: none
C Output: ind => integer, 0 -> all successful
C 1 -> non-fatal error, all fine but CK source unknown
C -1 -> fatal error, getspice2 failed
C -2 -> fatal error, getcamcon failed
C -3 -> fatel error, unable to determine project/camera
C Project => CHARACTER*5, The type of project of the file specified
C by the INP VICAR user parameter (e.g. GLL)
C Camera => INTEGER, the camera serial number of the file INP
C CKReturn => CHARACTER*4, The source of C-Kernel buffer used to
C process DATA (e.g. DAVI, NAV, NAV2..etc)
C DATA => 40xREAL*4, MP Buffer
C SCL => REAL*4, Calculated Scale in KM/Pixel
C------------------------------------------------------------------------------
SUBROUTINE MSEDR(IND,Project,Camera,CKNReturn,DATA,SCL)
INTEGER IND
CHARACTER*5 Project
CHARACTER*4 CKNReturn
REAL*4 DATA(40)
REAL*4 SCL
REAL*8 PI,R2,DTOR,GBUF8(100)
REAL*4 GBUF4(200)
CHARACTER*4 CKNRequest, CKID
INTEGER*4 IntBuf
INTEGER Camera
EQUIVALENCE (GBUF4, GBUF8) ! Spice Buffer, in 4 byte and 8 byte format
Ind = 0
C-------Open input file for getspice2 and getproj
CALL XVUNIT(IUN,'INP',1,IST, ' ')
CALL XVOPEN(IUN,ind, ' ')
IF (Ind.NE.1) call xvsignal(iunit,ind,1)
C-------Get Project and Camera
CALL getproj(IUN, Project,Camera,IntBuf,ind) ! IntBuf will not be used
IF (Ind.NE.0) THEN
CALL xvmessage ('GETPROJ failed',' ')
Ind = -3
RETURN
END IF
C-------Get Spice buffer
call getspice2(IUN, .TRUE., GBUF8, ind)
CALL XVCLOSE(IUN,IST, ' ')
IF (ind.NE.1) THEN
CALL xvmessage ('GETSPICE2 Failed', ' ')
CALL xvmessage ('GETPC cannot continue', ' ')
ind = -1
RETURN
END IF
C-------Check if desired source was found.
CALL mvlc(GBUF4(11), CKNRequest,4)
IF (CKNRequest.EQ.' ') CKNRequest='NAIF'
CALL MVLC (GBUF4(172), CKID, 4)
CALL CKID2CKName (CKID, CKNReturn)
IF (CKNRequest.NE.CKNReturn) THEN
CALL XVMESSAGE ('Source '//CKNRequest//' not available',' ')
CALL XVMESSAGE ('Retrieving from '//CKNReturn,' ')
END IF
C-------Process SPICE Buffer
50 PI = 3.141592653589793D0
dtor = pi/180.D0
IntBuf=8 ! need this for MVE
CALL MVE(4, 1, IntBuf, DATA(39), 1, 1)
CALL GETCAMCON(Project,Camera,DATA(27),DATA(28),DATA(29),
+ DATA(30),IND)
IF (ind.NE.0) THEN
CALL xvmessage ('GETCAMCON error', ' ')
ind = -2
RETURN
END IF
C PLANET RADII
DATA(25) = GBUF8(15)
rp2=data(25)*data(25)
DATA(26) = GBUF8(13)
re2=data(26)*data(26)
r2=1.0D0*rp2/re2
C RANGE
DATA(38) = GBUF8(27)
C SUBSPACECRAFT (LAT,LON)
DATA(31) = GBUF8(30)
DATA(32) = DMOD(GBUF8(31)+360.D0,360.D0)
C-----NORTH ANGLE
DATA(35) = DMOD(GBUF8(68)+90.D0,360.D0)
C-----OM MATRIX
CALL MVE(8,9,GBUF8(59),DATA, 1, 1)
C-----RS VECTOR
CALL MVE(8,3,GBUF8(22),DATA(19), 1, 1)
C-----SCALE IN KM/PX
SCL = GBUF8(27)/(DATA(27)*DATA(30))
RETURN
END
C------------------------------------------------------------------------------
C Subroutine PPC
C Purpose: Print and output PC; if GLL or CAS also output SCLAT/LON and SCALE
C------------------------------------------------------------------------------
SUBROUTINE PPC(Project,PC,Source,LAT,LON,SCL)
CHARACTER*5 Project ! Input: GLL, CASSI, VGR-1 or VGR-2
CHARACTER*4 Source ! Input: DAVI, NAV, NAV2...etc
REAL*4 PC(2),LAT,LON,SCL ! Input: SCLAT,SCLON and SCALE
INTEGER*4 PARB(500)
CHARACTER*80 MSG
CALL XVMESSAGE(' ', ' ')
IF (Project.EQ.'GLL ' .or. Project.EQ.'CASSI') THEN
CALL XVMESSAGE('IMAGE SPACE PLANET CENTER (LINE, SAMP)',' ')
ELSE
CALL xvmessage('OBJECT SPACE PLANET CENTER (LINE, SAMP)',' ')
END IF
WRITE (msg, '(a4, '' PC = '', f9.2, '' '', f9.2)') Source,
+ PC(1), PC(2)
CALL XVMESSAGE(MSG,' ')
IF (Project.EQ.'GLL ' .or. Project.EQ.'CASSI') THEN
CALL PRNT(7,1,LAT,' SCLAT =.')
CALL PRNT(7,1,LON,' SCLON =.')
CALL PRNT(7,1,SCL,' SCALE (KM/PX) =.')
END IF
CALL XQINI(PARB,500,XABORT)
CALL XQREAL(PARB,'PCL',1,PC(1),XADD,IST)
CALL XQREAL(PARB,'PCS',1,PC(2),XADD,IST)
IF (Project.EQ.'GLL ' .or. Project.EQ.'CASSI') THEN
CALL XQREAL(PARB,'SCLAT',1,LAT,XADD,IST)
CALL XQREAL(PARB,'SCLON',1,LON,XADD,IST)
CALL XQREAL(PARB,'SCALE',1,SCL,XADD,IST)
END IF
CALL XVQOUT(PARB,IST)
RETURN
END
C------------------------------------------------------------------------------
C Subroutine CKID2CKName
C Purpose: Converts a C-Kernel ID (CKID) to its common Name format (CKName)
C
C Usage : This procedure is useful in converting the 172nd element of the 4x200
C SPICE buffer to common recognized SOURCE name (DAVI, NAV, NAIF, etc)
C
C Input: CKID => CHARACTER*4, CKID as returned by the 172nd element of the
C 4x200 SPICE buffer.
C Output: CKName => CHARACTER*4, Common recognized SPICE source name such as:
C NAIF, AMOS, NEAR, NAV2, FAR, NAV, DAVI, etc.
C------------------------------------------------------------------------------
SUBROUTINE CKID2CKName (CKID, CKName)
IMPLICIT NONE
CHARACTER*4 CKID
CHARACTER*4 CKName
CKNAME='NAIF' ! default to NAIF
IF (CKID.EQ.'M901') CKNAME='AMOS'
IF (CKID.EQ.'M902') CKNAME='NEAR'
IF (CKID.EQ.'M903') CKNAME='NAV2'
IF (CKID.EQ.'M904') CKNAME='FARE'
IF (CKID.EQ.'M905') CKNAME='NAV'
IF (CKID.EQ.'M906') CKNAME='DAVI'
RETURN
END
| vos/p2/prog/getpc/getpc.f |
module fqs_vector
use fqs_types, only: wp
use fqs_quaternion, only: quat_t
implicit none
private
type, public :: vect_t
real(wp) :: x = 0.0_wp
real(wp) :: y = 0.0_wp
real(wp) :: z = 0.0_wp
contains
generic, public :: operator(+) => add
generic, public :: operator(-) => sub
generic, public :: operator(*) => mul_left
generic, public :: operator(*) => mul_right
generic, public :: operator(/) => divide_by_scalar
procedure, pass(self) :: add
procedure, pass(self) :: sub
procedure, pass(self) :: mul_left
procedure, pass(self) :: mul_right
procedure, pass(self) :: divide_by_scalar
procedure, pass(self) :: norm => normal
procedure, pass(self) :: sum2 => sum_of_squares
procedure, pass(self) :: to_array => to_array
end type vect_t
type(vect_t), parameter :: e1 = vect_t(1.0_wp, 0.0_wp, 0.0_wp)
type(vect_t), parameter :: e2 = vect_t(0.0_wp, 1.0_wp, 0.0_wp)
type(vect_t), parameter :: e3 = vect_t(0.0_wp, 0.0_wp, 1.0_wp)
interface vect_t
procedure :: new_from_values
end interface vect_t
interface vect_to_array
procedure :: single_vect_to_array
procedure :: array_1d_of_vect_to_array
procedure :: array_2d_of_vect_to_array
end interface vect_to_array
public e1, e2, e3
public vect_dot, vect_cross, vect_to_array, basis_vect
contains
! vect_t constructors
! -------------------------------------------------------------------------
elemental function new_from_values(x,y,z) result(v)
real(wp), intent(in) :: x, y, z
type(vect_t) :: v
v % x = x
v % y = y
v % z = z
end function new_from_values
! vect_t methods
! -------------------------------------------------------------------------
elemental function add(self,v) result(w)
class(vect_t), intent(in) :: self
type(vect_t), intent(in) :: v
type(vect_t) :: w
w % x = self % x + v % x
w % y = self % y + v % y
w % z = self % z + v % z
end function add
elemental function sub(self,v) result(w)
class(vect_t), intent(in) :: self
type(vect_t), intent(in) :: v
type(vect_t) :: w
w % x = self % x - v % x
w % y = self % y - v % y
w % z = self % z - v % z
end function sub
elemental function mul_left(scalar,self) result(w)
class(vect_t), intent(in) :: self
real(wp), intent(in) :: scalar
type(vect_t) :: w
w % x = scalar * (self % x)
w % y = scalar * (self % y)
w % z = scalar * (self % z)
end function mul_left
elemental function mul_right(self,scalar) result(w)
class(vect_t), intent(in) :: self
real(wp), intent(in) :: scalar
type(vect_t) :: w
w % x = scalar * (self % x)
w % y = scalar * (self % y)
w % z = scalar * (self % z)
end function mul_right
elemental function divide_by_scalar(self,scalar) result(v)
class(vect_t), intent(in) :: self
real(wp), intent(in) :: scalar
type(vect_t) :: v
v%x = self%x / scalar
v%y = self%y / scalar
v%z = self%z / scalar
end function divide_by_scalar
elemental function normal(self) result(norm)
class(vect_t), intent(in) :: self
real(wp) :: norm
norm = sqrt( self % sum2() )
end function normal
elemental function sum_of_squares(self) result(sum2)
class(vect_t), intent(in) :: self
real(wp) :: sum2
sum2 = (self % x)**2 + (self % y)**2 + (self % z)**2
end function sum_of_squares
function to_array(self) result(a)
class(vect_t), intent(in) :: self
real(wp) :: a(3)
a(1) = self % x
a(2) = self % y
a(3) = self % z
end function to_array
! utility functions
! ---------------------------------------------------------------------------
elemental function vect_dot(v,w) result(val)
! Computes the dot product of vectors v and w
type(vect_t), intent(in) :: v
type(vect_t), intent(in) :: w
real(wp) :: val
val = (v % x)*(w % x) + (v % y)*(w % y) + (v % z)*(w % z)
end function vect_dot
elemental function vect_cross(v,w) result(u)
! Computes the cross product of vectors v and w
type(vect_t), intent(in) :: v
type(vect_t), intent(in) :: w
type(vect_t) :: u
u % x = ((v % y) * (w % z)) - ((v % z)*(w % y))
u % y = ((v % z) * (w % x)) - ((v % x)*(w % z))
u % z = ((v % x) * (w % y)) - ((v % y)*(w % x))
end function vect_cross
function single_vect_to_array(v) result(a)
type(vect_t), intent(in) :: v
real(wp) :: a(3)
a = v % to_array()
end function single_vect_to_array
function array_1d_of_vect_to_array(v) result(a)
type(vect_t), intent(in) :: v(:)
real(wp) :: a(size(v),3)
integer :: i
do i=1,size(v)
a(i,:) = v(i) % to_array()
end do
end function array_1d_of_vect_to_array
function array_2d_of_vect_to_array(v) result(a)
type(vect_t), intent(in) :: v(:,:)
real(wp) :: a(size(v,1),size(v,2),3)
integer :: i,j
do i=1,size(v,1)
do j=1,size(v,2)
a(i,j,:) = v(i,j) % to_array()
end do
end do
end function array_2d_of_vect_to_array
elemental function basis_vect(ind) result(v)
integer, intent(in) :: ind
type(vect_t) :: v
if ((ind > 3) .or. (ind < 0)) then
error stop 'ind must be 1,2,3'
end if
select case(ind)
case (1)
v % x = 1.0_wp
case (2)
v % y = 1.0_wp
case (3)
v % z = 1.0_wp
end select
end function basis_vect
end module fqs_vector
| src/fqs_vector.f90 |
subroutine test_mpi3rma_put_pscw( base, array_size, DIM1, win, comm )
use utilities, only: check_fompi_status
#if INCLUDE_TYPE==1
implicit none
include 'fompif.h'
#endif
#if INCLUDE_TYPE==2
use fompi
implicit none
#endif
integer, intent(in) :: array_size
integer, dimension(array_size), intent(inout) :: base
integer, intent(in) :: DIM1
integer, intent(in) :: win
integer, intent(in) :: comm
integer :: rank
integer :: commsize
integer :: mpierr
integer(kind=MPI_ADDRESS_KIND) :: start
logical :: flag
integer(kind=MPI_ADDRESS_KIND) :: create_flavor
integer, dimension(3) :: ranges
integer :: group
integer :: newgroup
character(50) :: filename
write (filename,*) "put_pscw.f90"
call MPI_Comm_rank( comm, rank, mpierr )
call MPI_Comm_size( comm, commsize, mpierr )
call foMPI_Win_get_attr( win, foMPI_WIN_CREATE_FLAVOR, create_flavor, flag, mpierr )
call check_fompi_status(mpierr, MPI_SUCCESS, filename, 35, rank)
if (flag .neqv. .true.) then
write (*,*) "Didn't found foMPI_WIN_CREATE_FLAVOR keyval."
STOP
endif
if ( create_flavor .eq. foMPI_WIN_FLAVOR_DYNAMIC ) then
if (rank .eq. 1) then
call foMPI_Get_address( base(3*DIM1), start, mpierr )
endif
call MPI_Bcast( start, 1, MPI_AINT, 1, comm, mpierr )
else
start = 3*DIM1-1
endif
ranges(1) = mod(rank+1,2)
ranges(2) = commsize-1
ranges(3) = 2
call MPI_Comm_group( comm, group, mpierr )
call MPI_Group_range_incl( group, 1, ranges, newgroup, mpierr )
call MPI_Group_free( group, mpierr )
if ( mod(rank,2) .eq. 0 ) then
call foMPI_Win_start(newgroup, 0, win, mpierr)
call check_fompi_status(mpierr, MPI_SUCCESS, filename, 59, rank)
base(1) = 4*DIM1
call foMPI_Put( base(1), 1, MPI_INTEGER, 1, start, 1, MPI_INTEGER, win, mpierr )
call check_fompi_status(mpierr, MPI_SUCCESS, filename, 64, rank)
call foMPI_Win_complete(win, mpierr)
call check_fompi_status(mpierr, MPI_SUCCESS, filename, 67, rank)
else
call foMPI_Win_post(newgroup, 0, win, mpierr)
call check_fompi_status(mpierr, MPI_SUCCESS, filename, 70, rank)
call foMPI_Win_wait(win, mpierr)
call check_fompi_status(mpierr, MPI_SUCCESS, filename, 73, rank)
endif
call MPI_Group_free( newgroup, mpierr )
if ( rank .eq. 1 ) then
if (base(3*DIM1) .ne. 4*DIM1) then
write (*,*) "Error on rank ", rank, " in ", trim(filename), &
" line ", 79, ": element ", 3*DIM1, " is ", base(3*DIM1), &
" instead of ", 4*DIM1, "."
STOP
endif
endif
call MPI_Barrier( comm, mpierr )
if (rank .eq. 0) then
write (*,*) "No Error"
endif
end subroutine test_mpi3rma_put_pscw
| tests/test_mpi3rma_fortran/put_pscw.f90 |
subroutine foo()
integer a(10), i; integer i1_0;i1_0 = 1;i = 0; 1 a(i+i1_0) = i; i = i + 1; if (i < 10) goto 1;
end
| tests/transform/replace_const/replace_5/sample/main.f90 |
!! This module define physical and numerical constant used by ROHSA
module mod_constants
!! This module define physical and numerical constant used by ROHSA
use, intrinsic :: iso_fortran_env
implicit none
integer, parameter, public :: xp = REAL64
!physical constants FIXME CHECK VALUES
real(xp), parameter, public :: G = 6.67408e-8_xp !nravitationnal cst in cgs
real(xp), parameter, public :: c = 2.99792458e10_xp !speed of light in cgs
real(xp), parameter, public :: pi = 4.0_xp*atan(1.0_xp)
real(xp), parameter, public :: M_sun = 1.98855e33_xp !mass of the sun in cgs
real(xp), parameter, public :: cst_rad = 7.5657308531642009e-15_xp !radiation cst in cgs
real(xp), parameter, public :: stefan = (c * cst_rad) / 4.0_xp !stefan cst in cgs
real(xp), parameter, public :: kb = 1.3806488e-16_xp !boltzmann cst in cgs
real(xp), parameter, public :: R = 8.3144598e7_xp !gas cst in csg = Boltzmann cst over proton mass
real(xp), parameter, public :: gammag = 5._xp / 3._xp !adiabatic coefficient
real(xp), parameter, public :: thomson = 6.6524587158e-25_xp !thomson cross-section in cgs
end module mod_constants
| src/mod_constants.f90 |
c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c $Rev: 55 $ $Date: 2014-12-31 12:16:59 -0500 (Wed, 31 Dec 2014) $
c FORTRAN 77
c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REAL FUNCTION BDREF(MU, MUP, DPHI,
& BRDF_TYPE, BRDF_ARG)
c Supplies surface bi-directional reflectivity.
c
c NOTE 1: Bidirectional reflectivity in DISORT is defined
c by Eq. 39 in STWL.
c NOTE 2: Both MU and MU0 (cosines of reflection and incidence
c angles) are positive.
c
c INPUT:
c
c MU : Cosine of angle of reflection (positive)
c
c MUP : Cosine of angle of incidence (positive)
c
c DPHI : Difference of azimuth angles of incidence and reflection
c (radians)
c
c LOCAL VARIABLES:
c
c IREF : bidirectional reflectance options
c 1 - Hapke's BDR model
c 2 - Cox-Munk BDR model
c 3 - RPV BDR model
c 4 - Ross-Li BDR model
c
c B0 : empirical factor to account for the finite size of
c particles in Hapke's BDR model
c
c B : term that accounts for the opposition effect
c (retroreflectance, hot spot) in Hapke's BDR model
c
c CTHETA : cosine of phase angle in Hapke's BDR model
c
c GAMMA : albedo factor in Hapke's BDR model
c
c H0 : H( mu0 ) in Hapke's BDR model
c
c H : H( mu ) in Hapke's BDR model
c
c HH : angular width parameter of opposition effect in Hapke's
c BDR model
c
c P : scattering phase function in Hapke's BDR model
c
c THETA : phase angle (radians); the angle between incidence and
c reflection directions in Hapke's BDR model
c
c W : single scattering albedo in Hapke's BDR model
c
c
c Called by- DREF, SURFAC
c +-------------------------------------------------------------------+
c .. Scalar Arguments ..
REAL DPHI, MU, MUP, BRDF_ARG(6)
INTEGER BRDF_TYPE
c ..
c .. Local Scalars ..
INTEGER IREF
REAL B0, H0, HH, W
REAL PWS, REFRAC_INDEX, BDREF_F
REAL PI
REAL RHO0, KAPPA, G
REAL K_ISO, K_VOL, K_GEO, ALPHA0
LOGICAL DO_SHADOW
c Additions for pyRT_DISORT
REAL ASYM, FRAC, ROUGHNESS
c ..
c .. External Subroutines ..
EXTERNAL ERRMSG
c ..
c .. Intrinsic Functions ..
INTRINSIC COS, SQRT
c ..
PI = 2.*ASIN(1.)
IREF = BRDF_TYPE
c ** 1. Hapke BRDF
IF ( IREF.EQ.1 ) THEN
c ** Hapke's BRDF model (times Pi/Mu0) (Hapke, B., Theory of reflectance
c ** and emittance spectroscopy, Cambridge University Press, 1993, Eq.
c ** 8.89 on page 233. Parameters are from Fig. 8.15 on page 231, expect
c ** for w.)
B0 = BRDF_ARG(1) !1.0
HH = BRDF_ARG(2) !0.06
W = BRDF_ARG(3) !0.6
CALL BRDF_HAPKE(MUP, MU, DPHI,
& B0, HH, W, PI,
& BDREF)
c ** 2. Cox-Munk BRDF
ELSEIF(IREF.EQ.2) THEN
c PRINT *, "Calling oceabrdf"
PWS = BRDF_ARG(1)
REFRAC_INDEX = BRDF_ARG(2)
IF(BRDF_ARG(3) .EQ. 1) THEN
DO_SHADOW = .TRUE.
ELSEIF(BRDF_ARG(3) .EQ. 0) THEN
DO_SHADOW = .FALSE.
ELSE
PRINT *, "ERROR SHADOW ARGUMENTS"
ENDIF
CALL OCEABRDF2(DO_SHADOW,
& REFRAC_INDEX, PWS,
& MUP, MU, DPHI,
& BDREF_F)
BDREF = BDREF_F
c ** 3. RPV BRDF
ELSEIF(IREF .EQ. 3) THEN
RHO0 = BRDF_ARG(1) !0.027
KAPPA = BRDF_ARG(2) !0.647
G = BRDF_ARG(3) !-0.169 !asymmetry factor for HG
H0 = BRDF_ARG(4) !0.100
CALL BRDF_RPV(MUP, MU, DPHI,
& RHO0, KAPPA, G, H0,
& BDREF_F)
BDREF = BDREF_F
c ** 4. Ross-Li BRDF
ELSEIF(IREF .EQ. 4) THEN
K_ISO = BRDF_ARG(1) !0.200
K_VOL = BRDF_ARG(2) !0.020
K_GEO = BRDF_ARG(3) !0.300
ALPHA0 = 1.5*pi/180.
CALL BRDF_ROSSLI(MUP, MU, DPHI,
& K_ISO, K_VOL, K_GEO,
& ALPHA0,
& BDREF_F)
BDREF = BDREF_F
IF(BDREF .LT. 0.00) THEN
BDREF = 0.00
ENDIF
c ** 5. Hapke + HG2 BRDF
ELSEIF ( IREF.EQ.5 ) THEN
B0 = BRDF_ARG(1) !1.0
HH = BRDF_ARG(2) !0.06
W = BRDF_ARG(3) !0.6
ASYM = BRDF_ARG(4)
FRAC = BRDF_ARG(5)
CALL BRDF_HAPKE_HG2(MUP, MU, DPHI,
& B0, HH, W, ASYM, FRAC, PI,
& BDREF)
c ** 6. Hapke + HG2 with roughness
ELSEIF ( IREF.EQ.6 ) THEN
B0 = BRDF_ARG(1) !1.0
HH = BRDF_ARG(2) !0.06
W = BRDF_ARG(3) !0.6
ASYM = BRDF_ARG(4)
FRAC = BRDF_ARG(5)
ROUGHNESS = BRDF_ARG(6)
CALL BRDF_HAPKE_HG2_ROUGHNESS(MUP, MU, DPHI,
& B0, HH, W, ASYM, FRAC, ROUGHNESS, PI,
& BDREF)
ELSE
CALL ERRMSG( 'BDREF--Need to supply surface BDRF model',
& .TRUE.)
ENDIF
RETURN
END FUNCTION
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c +--------------------------------------------------------------------
SUBROUTINE BRDF_HAPKE ( MUP, MU, DPHI,
& B0, HH, W, PI,
& BRDF )
c +--------------------------------------------------------------------
c Hapke "Theory of Reflectance and Emittance Spectroscopy" Chapter 10, Page 262
c Eq. (10.2).
c Version 3 fix: definition of phase angle / scattering angle see DISORT3
c paper Eqs. (25-26).
c +--------------------------------------------------------------------
IMPLICIT NONE
REAL MUP, MU, DPHI
REAL B0, HH, W, PI
REAL BRDF
REAL CALPHA, ALPHA, P, B, H0, GAMMA, H
CALPHA = MU * MUP - (1.-MU**2)**.5 * (1.-MUP**2)**.5
& * COS( DPHI )
ALPHA = ACOS( CALPHA )
P = 1. + 0.5 * CALPHA
B = B0 * HH / ( HH + TAN( ALPHA/2.) )
GAMMA = SQRT( 1. - W )
H0 = ( 1. + 2.*MUP ) / ( 1. + 2.*MUP * GAMMA )
H = ( 1. + 2.*MU ) / ( 1. + 2.*MU * GAMMA )
c ** Version 3: add factor PI
BRDF = W / (4.*PI) / (MU+MUP) * ( (1.+B)* P + H0 * H - 1.0 )
c BRDF = W / 4. / (MU+MUP) * ( (1.+B)* P + H0 * H - 1.0 )
END
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c +--------------------------------------------------------------------
SUBROUTINE BRDF_RPV(MU_I, MU_R, DPHI,
& RHO0, KAPPA, G_HG, H0,
& BRDF)
c +--------------------------------------------------------------------
c DISORT Version 3: RPV BRDF
c Input:
c
c MU_I: absolute cosine of incident polar angle (positive)
c MU_R: absolute cosine of reflected polar angle (positive)
c DPHI: relative azimuth to incident vector; (pi - dphi), sun-view relative
c azimuth sun located at phi = 180, while incident solar beam located
c at phi = 0
c RHO0: RPV BRDF parameter, control reflectance
c KAPPA: PRV BRDF parameter, control anisotropy
c G: RPV BRDF parameter, H-G asymmetry factor
c H0: RPV BRDF parameter, control hot spot (back scattering direction)
c
c Output:
c
c BRDF: RPV BRDF
c +--------------------------------------------------------------------
IMPLICIT NONE
REAL MU_I, MU_R, DPHI
REAL RHO0, KAPPA, G_HG, H0
REAL BRDF
REAL PI
REAL COS_ALPHA
REAL SIN_I, SIN_R, TAN_I, TAN_R
REAL G_SQ, G, F
PI = 2.*ASIN(1.)
SIN_I = SQRT(1. - MU_I*MU_I)
SIN_R = SQRT(1. - MU_R*MU_R)
TAN_I = SIN_I/MU_I
TAN_R = SIN_R/MU_R
COS_ALPHA = MU_I*MU_R - SIN_I*SIN_R
& *COS(DPHI)
G_SQ = TAN_I*TAN_I + TAN_R*TAN_R
& + 2.*TAN_I*TAN_R*COS(DPHI)
c ** hot spot
G = SQRT(G_SQ)
c ** HG phase function
F = (1. - G_HG*G_HG)/
& (1+G_HG*G_HG+2.*G_HG*COS_ALPHA)**1.5
c ** BRDF semiempirical function
BRDF = RHO0
& * (MU_I*MU_R*(MU_I+MU_R))**(KAPPA-1.)
& * F
& * (1. + ((1.-H0)/(1.+G)))
END
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c +--------------------------------------------------------------------
SUBROUTINE BRDF_ROSSLI(MU_I, MU_R, DPHI,
& K_ISO, K_VOL, K_GEO,
& ALPHA0,
& BRDF)
c +--------------------------------------------------------------------
c Version 3: Ross-Li BRDF
c Input:
c
c MU_I: absolute cosine of incident polar angle (positive)
c MU_R: absolute cosine of reflected polar angle (positive)
c DPHI: relative azimuth to incident vector; (pi - dphi), sun-view relative
c azimuth sun located at phi = 180, while incident solar beam located
c at phi = 0
c K_ISO: BRDF parameter, isotropic scattering kernel
c K_VOL: BRDF parameter, volume scattering kernel
c K_GEO: BRDF parameter, geometry scattering kernel
c ALPHA0: BRDF parameter, control hot spot (back scattering direction)
c
c Output:
c BRDF: Ross-Li BRDF
c
c +--------------------------------------------------------------------
IMPLICIT NONE
REAL MU_I, MU_R, DPHI
REAL F_GEO, F_VOL
REAL K_ISO, K_GEO, K_VOL
REAL RATIO_HB, RATIO_BR
REAL BRDF
REAL PI
REAL COS_ALPHA, SIN_ALPHA
REAL COS_ALPHA1
REAL ALPHA
REAL SIN_I, SIN_R, TAN_I, TAN_R
REAL SIN_I1, SIN_R1, COS_I1, COS_R1, TAN_I1, TAN_R1
REAL G_SQ, COS_T, T
REAL C, ALPHA0
c +--------------------------------------------------------------------
c PRINT *, MU_I, MU_R, DPHI,
c & K_ISO, K_GEO, K_VOL,
c & THETA0
c PRINT *,
RATIO_HB = 2.
RATIO_BR = 1.
PI = 2.*ASIN(1.)
SIN_I = SQRT(1. - MU_I*MU_I)
SIN_R = SQRT(1. - MU_R*MU_R)
TAN_I = SIN_I/MU_I
TAN_R = SIN_R/MU_R
COS_ALPHA = MU_I*MU_R - SIN_I*SIN_R
& *COS(DPHI)
SIN_ALPHA = SQRT(1. - COS_ALPHA*COS_ALPHA)
ALPHA = ACOS(COS_ALPHA)
c ** Compute KERNEL RossThick
C = 1. + 1./(1.+ALPHA/ALPHA0)
F_VOL = 4./(3.*PI) * (1./(MU_I+MU_R))
& * ((PI/2. - ALPHA)*COS_ALPHA+SIN_ALPHA)*C - 1./3.
c K1 = ((PI/2. - ALPHA)*COS_ALPHA + SIN_ALPHA)
c & /(MU_I + MU_R) - PI/4.
c ** Compute KERNEL LSR
TAN_I1 = RATIO_BR * TAN_I
TAN_R1 = RATIO_BR * TAN_R
SIN_I1 = TAN_I1/SQRT(1.+ TAN_I1*TAN_I1)
SIN_R1 = TAN_R1/SQRT(1.+ TAN_R1*TAN_R1)
COS_I1 = 1./SQRT(1.+ TAN_I1*TAN_I1)
COS_R1 = 1./SQRT(1.+ TAN_R1*TAN_R1)
COS_ALPHA1 = COS_I1*COS_R1 - SIN_I1*SIN_R1
& *COS(DPHI)
G_SQ = TAN_I1*TAN_I1 + TAN_R1*TAN_R1
& + 2.*TAN_I1*TAN_R1*COS(DPHI)
c M = 1./COS_I1 + 1./COS_R1
COS_T = RATIO_HB *(COS_I1*COS_R1)/(COS_I1+COS_R1)
& *SQRT(G_SQ + (TAN_I1*TAN_R1*SIN(DPHI))**2)
IF(COS_T .LE. 1. .AND. COS_T .GE. -1.) THEN
T = ACOS(COS_T)
ELSE
T = 0.
ENDIF
F_GEO = (COS_I1+COS_R1)/(PI*COS_I1*COS_R1)*(T-SIN(T)*COS(T)-PI)
& + (1.+ COS_ALPHA1)/(2.*COS_I1*COS_R1)
c Compute BRDF
c PRINT *, RATIO_HB, D_SQ,
c & TAN_I1*TAN_R1*SIN(DPHI),
c & M, COS_T
c BRDF = K1
BRDF = K_ISO + K_GEO*F_GEO + K_VOL*F_VOL
END
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c +--------------------------------------------------------------------
SUBROUTINE OCEABRDF2
& ( DO_SHADOW,
& REFRAC_INDEX, WS,
& MU_I, MU_R, DPHI,
& BRDF)
c +--------------------------------------------------------------------
c Version 3: 1D Gaussian Rough Ocean BRDF
c Input:
c
c mu_i: absolute cosine of incident polar angle (positive)
c mu_r: absolute cosine of reflected polar angle (positive)
c dphi: relative azimuth (radians)
c do_shadow: BRDF parameter, open/close shadow effect
c refrac_index: BRDF parameter, refractive index of boundary media (water)
c ws: BRDF parameter, wind speed (m/s)
c
c Output:
c
c brdf: 1D Gaussian Rough Ocean BRDF
c
c +--------------------------------------------------------------------
LOGICAL DO_SHADOW
REAL REFRAC_INDEX, WS
REAL SIN_I, SIN_R, MU_I, MU_R, DPHI, BRDF
REAL COS_THETA, SIGMA_SQ, MU_N_SQ, P
REAL N_I, N_T, COS_LI, COS_LT, SIN_LI, SIN_LT
REAL R_S, R_P, R
REAL SHADOW
REAL PI
PI = 2.*ASIN(1.)
c ** Cox Munk slope distribution
SIN_I = SQRT(1. - MU_I*MU_I)
SIN_R = SQRT(1. - MU_R*MU_R)
COS_THETA = -MU_I*MU_R + SIN_I*SIN_R*COS(DPHI)
MU_N_SQ = (MU_I + MU_R)*(MU_I + MU_R)/(2.*(1.-COS_THETA))
SIGMA_SQ = 0.003 + 0.00512*WS
P = 1./(PI*SIGMA_SQ) * EXP( -(1-MU_N_SQ)/(SIGMA_SQ*MU_N_SQ) )
c ** Fresnel reflectance
N_I = 1.0
N_T = REFRAC_INDEX
SIN_LI = SQRT( 1.-0.5*(1.-COS_THETA) )
COS_LI = SQRT( 0.5*(1.-COS_THETA) )
SIN_LT = N_I*SIN_LI/N_T
COS_LT = SQRT(1. - SIN_LT*SIN_LT)
R_S = (N_I*COS_LI-N_T*COS_LT)/(N_I*COS_LI+N_T*COS_LT)
R_P = (N_T*COS_LI-N_I*COS_LT)/(N_I*COS_LT+N_T*COS_LI)
R = 0.5*(R_S*R_S + R_P*R_P)
c ** Rough surface BRDF
BRDF = (P*R)/(4.*MU_I*MU_R*MU_N_SQ*MU_N_SQ)
c Shadowing effect (see Tsang, Kong, Shin, Theory of Microwave Remote
c Sensing, Wiley-Interscience, 1985)
IF(DO_SHADOW) THEN
SHADOW = 1./( SHADOW_ETA(MU_I, SIGMA_SQ, PI)
& + SHADOW_ETA(MU_R, SIGMA_SQ, PI) + 1. )
BRDF = BRDF*SHADOW
ENDIF
END
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c +--------------------------------------------------------------------
REAL FUNCTION SHADOW_ETA(COS_THETA, SIGMA_SQ, PI)
c +--------------------------------------------------------------------
c Version 3: shadow effect function
c called by OCEABRDF2
c Input:
c
c COS_THETA absolute cosine of incident/reflected polar angle (positive)
c SIGMA_SQ slope variance
c PI 3.141592653... constant
c
c Output:
c
c SHADOW_ETA: shadow function
c +--------------------------------------------------------------------
REAL COS_THETA, SIN_THETA
REAL MU, SIGMA_SQ, PI
REAL TERM1, TERM2
SIN_THETA = SQRT(1.-COS_THETA*COS_THETA)
MU = COS_THETA/SIN_THETA
TERM1 = SQRT(SIGMA_SQ/PI)/MU*EXP( -MU*MU/(SIGMA_SQ) )
TERM2 = ERFC( MU/SQRT(SIGMA_SQ) )
SHADOW_ETA = 0.5*(TERM1 - TERM2)
END
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c Start pyRT_DISORT additions
c Hapke + HG2 surface
c +--------------------------------------------------------------------
SUBROUTINE BRDF_HAPKE_HG2 ( MUP, MU, DPHI,
& B0, HH, W, ASYM, FRAC, PI,
& BRDF )
c +--------------------------------------------------------------------
c +--------------------------------------------------------------------
IMPLICIT NONE
REAL MUP, MU, DPHI
REAL B0, HH, W, PI
REAL BRDF
REAL CALPHA, ALPHA, P, B, H0, GAMMA, H
REAL ASYM, FRAC
REAL CTHETA, THETA, FORWARD, BACKWARD, PSI
CALPHA = MU * MUP - (1.-MU**2)**.5 * (1.-MUP**2)**.5
& * COS( DPHI )
ALPHA = ACOS( CALPHA )
B = B0 * HH / ( HH + TAN( ALPHA/2.) )
GAMMA = SQRT( 1. - W )
H0 = ( 1. + 2.*MUP ) / ( 1. + 2.*MUP * GAMMA )
H = ( 1. + 2.*MU ) / ( 1. + 2.*MU * GAMMA )
FORWARD = (1. - ASYM**2.) / (1. + 2. * ASYM * COS(ALPHA) +
& ASYM**2.)**1.5
BACKWARD = (1. - ASYM**2.) / (1. - 2. * ASYM * COS(ALPHA) +
& ASYM**2.)**1.5
P = FRAC * FORWARD + (1-FRAC)*BACKWARD
c ** Version 3: add factor PI
BRDF = W / (4.*PI) / (MU+MUP) * ( (1.+B)* P + H0 * H - 1.0 )
c BRDF = W / 4. / (MU+MUP) * ( (1.+B)* P + H0 * H - 1.0 )
END
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c Just copy Mike's code/logic here
c +--------------------------------------------------------------------
SUBROUTINE BRDF_HAPKE_HG2_ROUGHNESS ( MUP, MU, DPHI,
& B0, HH, W, ASYM, FRAC, ROUGHNESS, PI,
& BRDF )
c +--------------------------------------------------------------------
c +--------------------------------------------------------------------
IMPLICIT NONE
REAL MUP, MU, DPHI
REAL B0, HH, W, PI
REAL BRDF, P, B
REAL ASYM, FRAC, ROUGHNESS
REAL CALPHA, ALPHA, FORWARD, BACKWARD, i, e, hapke_emue
REAL H_function
REAL hapke_imue, imue, emue, H_imue, H_emue, S, S_function
LOGICAL flag
CALPHA = MU * MUP - (1.-MU**2)**.5 * (1.-MUP**2)**.5
& * COS( DPHI )
ALPHA = ACOS( CALPHA )
FORWARD = (1. - ASYM**2.) / (1. + 2. * ASYM * COS(ALPHA) +
& ASYM**2.)**1.5
BACKWARD = (1. - ASYM**2.) / (1. - 2. * ASYM * COS(ALPHA) +
& ASYM**2.)**1.5
P = FRAC * FORWARD + (1-FRAC)*BACKWARD
B = B0 * HH / ( HH + TAN( ALPHA/2.) )
flag = .false.
i = ACOS(MU)
e = ACOS(MUP)
imue = Hapke_imue(i, e, ALPHA, ROUGHNESS)
emue = Hapke_emue(i, e, ALPHA, ROUGHNESS)
H_imue = H_function(imue, w, flag)
H_emue = H_function(emue, w, flag)
S = S_function(i, e, ALPHA, ROUGHNESS)
BRDF = W / (4.*PI * MU) * (imue / (imue + emue)) *
& ((1.0 + B) * p + H_imue * H_emue - 1.0) * S
END
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c subroutines written by Frank Seelos, ported from f90 to f77 by M.
c Wolff (that fiend!)
c
c history:
c 2005/07/27 (mjw): changed "END FUNCTION" syntax to just "END"
c
REAL FUNCTION H_function(x, w, H_approx)
cFUNCTION:
c H_function
c
cCALLED BY:
c HapkeBDREF
c
cCALLS:
c Hapke_gamma
c Hapke_r0 (conditionally)
c
cINPUT PARAMETERS:
c x : the cosine of either the incidence or emission angle depending on the calling
c circumstance
c w : single scattering albedo
c
cPURPOSE:
c H_function is an approximation to Chandreskehar H-function which is fundamental to the
c calculation of the bidirectional reflectance of a semiinfinite medium of isotropic scatterers.
c
cREFERENCE:
c Hapke (1993); Eqn. 8.55; p. 212
IMPLICIT NONE
REAL Hapke_gamma
REAL Hapke_r0
LOGICAL H_approx
REAL x, w
REAL gamma, r0
gamma = Hapke_gamma(w)
if (H_approx .EQV. .FALSE.) then
H_function = (1.0 + 2.0 * x) / (1.0 + 2.0 * x * gamma)
else
r0 = Hapke_r0(gamma)
H_function = 1.0 / (1.0 - (1.0 - gamma) * x *
& (r0 + (1.0 - 0.5 * r0 - r0 * x) * alog((1.0 + x) / x)))
end if
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION B_function(g, h, B_approx)
cFUNCTION:
c B_function
c
cCALLED BY:
c HapkeBDREF
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c g : phase angle
c h : compaction parameter
c
cPURPOSE:
c The opposition effect function (B_function) calculates the effect of shadow hiding on the
c bidirectional reflectance function
c
cREFERENCE:
c Hapke (1993); Eqn. 8.81; p. 224
IMPLICIT NONE
REAL pi
REAL Hapke_y, ERF
REAL y
REAL g, h
LOGICAL B_approx
pi = 2.0 * asin(1.0)
c write (*,*), 'B_approx_flag: ', B_approx_flag
if (B_approx .EQV. .FALSE.) then
B_function = 1.0 / (1.0 + 1.0 / h * tan(g / 2.0))
else
y = Hapke_y(g, h)
B_function = sqrt((4.0 * pi) / y) * exp(1.0 / y) *
& (ERF(sqrt(4.0 / y)) - ERF(sqrt(1.0 / y))) +
& exp(-3.0 / y) - 1.0
endif
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION S_function(i, e, psi, theta_bar)
cFUNCTION:
c S_function
c
cCALLED BY:
c HapkeBDREF
c
cCALLS:
c Hapke_mue0
c Hapke_imue
c Hapke_emue
c Hapke_chi
c Hapke_fpsi
c
cINPUT PARAMETERS:
c i : incidence angle
c e : emission angle
c psi : difference in azimuth angle between incident and emergent rays
c theta_bar : macroscopic roughness parameter (mean slope angle)
c
cPURPOSE:
c The shadowing function (S_function) calculates the effect of macroscopic
c roughness on the bidirectional reflectance function
c
cREFERENCE:
c Hapke (1993); Eqn. 12.50 & 12.54; p. 345
IMPLICIT NONE
REAL Hapke_mue0, Hapke_imue, Hapke_emue, Hapke_chi, Hapke_fpsi
REAL i, e, psi, theta_bar
REAL imu, emu, imue0, emue0, imue, emue, S
imu = cos(i)
emu = cos(e)
imue0 = Hapke_mue0(i, theta_bar)
emue0 = Hapke_mue0(e, theta_bar)
imue = Hapke_imue(i, e, psi, theta_bar)
emue = Hapke_emue(i, e, psi, theta_bar)
if (i .le. e) then
S = (emue / emue0) * (imu / imue0) *
& (Hapke_chi(theta_bar) / (1.0 - Hapke_fpsi(psi) +
& Hapke_fpsi(psi) * Hapke_chi(theta_bar) * (imu / imue0)))
else
S = (emue / emue0) * (imu / imue0) *
& (Hapke_chi(theta_bar) / (1.0 - Hapke_fpsi(psi) +
& Hapke_fpsi(psi) * Hapke_chi(theta_bar) * (emu / emue0)))
endif
S_function = S
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_imue(i, e, psi, theta_bar)
cFUNCTION:
c Hapke_imue
c
cCALLED BY:
c S_function
c
cCALLS:
c Hapke_chi
c Hapke_E1
c Hapke_E2
c
cINPUT PARAMETERS:
c i : incidence angle
c e : emission angle
c psi : difference in azimuth angle between incident and emergent rays
c theta_bar : macroscopic roughness parameter (mean slope angle)
c
cPURPOSE:
c Hapke_imue is the cosine of the effective incidence angle when theta_bar NE 0.0
c
cREFERENCE:
c Hapke (1993); Eqn. 12.46 & 12.52; p. 344 & 345
IMPLICIT NONE
REAL pi
REAL Hapke_chi, Hapke_E1, Hapke_E2
REAL i, e, psi, theta_bar
REAL imue
pi = 2.0 * asin(1.0)
if (i .le. e) then
c write (*,*), 'IMUE'
c write (*,*), i, e, psi, theta_bar
c write (*,*), Hapke_chi(theta_bar)
c write (*,*), Hapke_E1(e, theta_bar), Hapke_E1(i, theta_bar)
c write (*,*), Hapke_E2(e, theta_bar), Hapke_E2(i, theta_bar)
c write (*,*)
imue = Hapke_chi(theta_bar) * (cos(i) + sin(i) *
& tan(theta_bar) * ((cos(psi) * Hapke_E2(e, theta_bar)
& + (sin(psi/2.0))**2.0 * Hapke_E2(i, theta_bar)) /
& (2.0 - Hapke_E1(e, theta_bar) - (psi/pi) *
& Hapke_E1(i, theta_bar))))
else
imue = Hapke_chi(theta_bar) * (cos(i) + sin(i) *
& tan(theta_bar) * ((Hapke_E2(i, theta_bar) -
& (sin(psi/2.0))**2.0 * Hapke_E2(e, theta_bar)) /
& (2.0 - Hapke_E1(i, theta_bar) - (psi/pi) *
& Hapke_E1(e, theta_bar))))
endif
Hapke_imue = imue
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_emue(i, e, psi, theta_bar)
cFUNCTION:
c Hapke_emue
c
cCALLED BY:
c S_function
c
cCALLS:
c Hapke_chi
c Hapke_E1
c Hapke_E2
c
cINPUT PARAMETERS:
c i : incidence angle
c e : emission angle
c psi : difference in azimuth angle between incident and emergent rays
c theta_bar : macroscopic roughness parameter (mean slope angle)
c
cPURPOSE:
c Hapke_emue is the cosine of the effective emission angle when theta_bar NE 0.0
c
cREFERENCE:
c Hapke (1993); Eqn. 12.47 & 12.53; p. 344 & 345
IMPLICIT NONE
REAL pi
REAL Hapke_chi, Hapke_E1, Hapke_E2
REAL i, e, psi, theta_bar
REAL emue
pi = 2.0 * asin(1.0)
if (i .le. e) then
emue = Hapke_chi(theta_bar) * (cos(e) + sin(e) *
& tan(theta_bar) * ((Hapke_E2(e, theta_bar) -
& (sin(psi/2.0))**2.0 * Hapke_E2(i, theta_bar)) /
& (2.0 - Hapke_E1(e, theta_bar) - (psi/pi) *
& Hapke_E1(i, theta_bar))))
else
emue = Hapke_chi(theta_bar) * (cos(e) + sin(e) *
& tan(theta_bar) * ((cos(psi) * Hapke_E2(i, theta_bar) +
& (sin(psi/2.0))**2.0 * Hapke_E2(e, theta_bar)) /
& (2.0 - Hapke_E1(i, theta_bar) - (psi/pi) *
& Hapke_E1(e, theta_bar))))
endif
Hapke_emue = emue
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_mue0(theta, theta_bar)
cFUNCTION:
c Hapke_mue0
c
cCALLED BY:
c S_function
c
cCALLS:
c Hapke_chi
c Hapke_E1
c Hapke_E2
c
cINPUT PARAMETERS:
c theta : incidence or emission angle (i or e) depending on calling circumstance
c theta_bar : macroscopic roughness parameter (mean slope angle)
c
cPURPOSE:
c Hapke_mue0 is the cosine of the effective incidence or emission angle when psi EQ 0.0
c
cREFERENCE:
c Hapke (1993); Eqn. 12.48 & 12.49; p. 344
IMPLICIT NONE
REAL Hapke_chi, Hapke_E1, Hapke_E2
REAL theta, theta_bar
Hapke_mue0 = Hapke_chi(theta_bar) * (cos(theta) + sin(theta)
& * tan(theta_bar) * Hapke_E2(theta, theta_bar) /
& (2.0 - Hapke_E1(theta, theta_bar)))
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_y(g, h)
IMPLICIT NONE
REAL g, h
Hapke_y = tan(g/2.0) / h
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_r0(gamma)
cFUNCTION:
c Hapke_r0
c
cCALLED BY:
c H_function (conditionally)
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c gamma : albedo factor
c
cPURPOSE:
c Hapke_r0 (diffusive reflectance) is used in the more exact approximation to the
c Chandreskehar H-function
c
cREFERENCE:
c Hapke (1993); Eqn. 8.25; p. 196
IMPLICIT NONE
REAL gamma
Hapke_r0 = (1.0 - gamma) / (1.0 + gamma)
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_gamma(w)
cFUNCTION:
c Hapke_gamma
c
cCALLED BY:
c H_function
c B_function
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c w : single scattering albedo
c
cPURPOSE:
c Hapke_gamma (albedo factor) is a component in the calculation of the Chandrasekhar
c H-functions and the contribution of the opposition effect
c
cREFERENCE:
c Hapke (1993); Eqn. 8.22b; p. 195
IMPLICIT NONE
REAL w
Hapke_gamma = sqrt(1.0 - w)
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_chi(theta_bar)
cFUNCTION:
c Hapke_chi
c
cCALLED BY:
c S_function
c Hapke_imue
c Hapke_emue
c Hapke_mue0
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c theta_bar : macroscopic roughness parameter (mean slope angle)
c
cPURPOSE:
c Hapke_chi is a component in the calculation of the shadowing function and the
c cosines of the effective incidence and emission angles when theta_bar NE 0.0
c
cREFERENCE:
c Hapke (1993); Eqn. 12.45a; p. 344
IMPLICIT NONE
REAL pi
REAL theta_bar
pi = 2.0 * asin(1.0)
Hapke_chi = 1.0 / sqrt(1.0 + pi * tan(theta_bar)**2.0)
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_fpsi(psi)
cFUNCTION:
c Hapke_fpsi
c
cCALLED BY:
c S_function
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c psi : difference in azimuth angle between incident and emergent rays
c
cPURPOSE:
c Hapke_fpsi is a component in the calculation of the shadowing function when theta_bar NE 0.0
c
cREFERENCE:
c Hapke (1993); Eqn. 12.51; p. 345
IMPLICIT NONE
REAL pi
REAL psi
pi = 2.0 * asin(1.0)
if (psi .eq. pi) then
Hapke_fpsi = 0.0
else
Hapke_fpsi = exp(-2.0 * tan(psi / 2.0))
endif
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_E1(x, theta_bar)
cFUNCTION:
c Hapke_E1
c
cCALLED BY:
c Hapke_imue
c Hapke_emue
c Hapke_mue0
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c x : incidence or emission angle (i or e) depending on input geometry
c theta_bar : macroscopic roughness parameter (mean slope angle)
c
cPURPOSE:
c Hapke_E1 is a component in the calculation of the cosines of the effective incidence
c and emission angles when theta_bar NE 0.0
c
cREFERENCE:
c Hapke (1993); Eqn. 12.45b; p. 344
IMPLICIT NONE
REAL pi
REAL x, theta_bar
pi = 2.0 * asin(1.0)
if (x .eq. 0.0) then
Hapke_E1 = 0.0
else
Hapke_E1 = exp(-2.0 / pi * 1.0/tan(theta_bar) * 1.0/tan(x))
endif
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION Hapke_E2(x, theta_bar)
cFUNCTION:
c Hapke_E2
c
cCALLED BY:
c Hapke_imue
c Hapke_emue
c Hapke_mue0
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c x : incidence or emission angle (i or e) depending on input geometry
c theta_bar : macroscopic roughness parameter (mean slope angle)
c
cPURPOSE:
c Hapke_E2 is a component in the calculation of the cosines of the effective incidence
c and emission angles when theta_bar NE 0.0
c
cREFERENCE:
c Hapke (1993); Eqn. 12.45c; p. 344
IMPLICIT NONE
REAL pi
REAL x, theta_bar
pi = 2.0 * asin(1.0)
if (x .eq. 0.0) then
Hapke_E2 = 0.0
else
Hapke_E2 = exp(-1.0 / pi * (1.0/tan(theta_bar))**2.0 *
& (1.0/tan(x))**2.0)
endif
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION phf_isotropic()
c
cFUNCTION:
c phf_isotropic
c
cCALLED BY:
c HapkeBDREFPhaseFunctions
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c NONE
c
cPURPOSE:
c Isotropic phase function
c
cREFERENCE:
IMPLICIT NONE
phf_isotropic = 1.0
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION phf_aniso_neg(g)
c
cFUNCTION:
c phf_aniso_neg
c
cCALLED BY:
c HapkeBDREFPhaseFunctions
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c g : phase angle
c
cPURPOSE:
c Calculate anisotropic phase function [1 - cos(g)]
c
cREFERENCE:
c Hapke (1993); p. 214
IMPLICIT NONE
REAL g
phf_aniso_neg = 1.0 - cos(g)
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION phf_aniso_pos(g)
c
cFUNCTION:
c phf_aniso_pos
c
cCALLED BY:
c HapkeBDREFPhaseFunctions
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c g : phase angle
c
cPURPOSE:
c Calculate anisotropic phase function [1 + cos(g)]
c
cREFERENCE:
c Hapke (1993); p. 214
IMPLICIT NONE
REAL g
phf_aniso_pos = 1.0 + cos(g)
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION phf_rayleigh(g)
c
cFUNCTION:
c phf_rayleigh
c
cCALLED BY:
c HapkeBDREFPhaseFunctions
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c g : phase angle
c
cPURPOSE:
c Calculate Rayleigh phase function
c
cREFERENCE:
c
IMPLICIT NONE
REAL g
phf_rayleigh = (3.0/4.0) * (1.0 + (cos(g))**2.0)
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION phf_hg1(g, a)
c
cFUNCTION:
c phf_hg1
c
cCALLED BY:
c HapkeBDREFPhaseFunctions
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c g : phase angle (radians)
c a : asymmetry parameter [-1,1];
c Negative is back; Positive is forward.
c
cPURPOSE:
c Calculate one parameter Henyey-Greenstein phase function
c
cREFERENCE:
c
IMPLICIT NONE
REAL g, a
phf_hg1 = (1.0 - a**2.0) / ((1.0 + 2.0 * a * cos(g)
$ + a**2.0)**1.5)
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION phf_hg2(g, a, f)
c
cFUNCTION:
c phf_hg2
c
cCALLED BY:
c HapkeBDREFPhaseFunctions
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c g : phase angle (radians)
c a : asymmetry parameter [0,1]
c f : forward fraction [0,1]
c
cPURPOSE:
c Calculate two parameter Henyey-Greenstein phase function
c
cREFERENCE:
c
IMPLICIT NONE
REAL g, a, f
REAL forward, backward
REAL phf_hg1
forward = phf_hg1(g, a)
backward = phf_hg1(g, -1.0 * a)
phf_hg2 = f * forward + (1.0 - f) * backward
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
REAL FUNCTION phf_hg3(g, af, ab, f)
c
cFUNCTION:
c phf_hg3
c
cCALLED BY:
c HapkeBDREFPhaseFunctions
c
cCALLS:
c NONE
c
cINPUT PARAMETERS:
c g : phase_angle (radians)
c af : forward asymmetry parameter [0,1]
c ab : backward asymmetry parameter [-1,0]
c f : forward fraction [0,1]
c
cPURPOSE:
c Calculate three parameter Henyey-Greenstein phase function
c
cREFERENCE:
c
IMPLICIT NONE
REAL g, af, ab, f
REAL phf_hg1
REAL forward, backward
forward = phf_hg1(g, af)
backward = phf_hg1(g, ab)
phf_hg3 = f * forward + (1.0 - f) * backward
RETURN
END
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
c---------------------------------------------------------------------------c
| disort4.0.99/BDREF.f |
! **********************************************************************
! *** LAMELLAR DI-BLOCK COPOLYMER + NANODIMERS *************************
! *** Structural Data Analysis *************************
! *** Author: J. Javier Burgos Mármol -- 2021 *************************
! **********************************************************************
!BSD 3-Clause License
!
!Copyright (c) 2021, J. Javier Burgos-Mármol (Github username: jjavier-bm)
!All rights reserved.
!
!Redistribution and use in source and binary forms, with or without
!modification, are permitted provided that the following conditions are met:
!
!1. Redistributions of source code must retain the above copyright notice, this
! list of conditions and the following disclaimer.
!
!2. Redistributions in binary form must reproduce the above copyright notice,
! this list of conditions and the following disclaimer in the documentation
! and/or other materials provided with the distribution.
!
!3. Neither the name of the copyright holder nor the names of its
! contributors may be used to endorse or promote products derived from
! this software without specific prior written permission.
!
!THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
!AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
!IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
!DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
!FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
!DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
!SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
!CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
!OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
!OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PROGRAM LamellarStructure
IMPLICIT NONE
!---DATA------------------------------------
CHARACTER(64) :: inputfilename='stdyn.pure.lammpstrj'
!CONSTANTS
REAL*8, PARAMETER :: PI=3.141592654d0, TWOPI=6.283185307d0, HALFPI=1.570796327d0
!PARAMETERS
INTEGER, PARAMETER :: Nchains = 12696, LchainsA = 15, LchainsB = 15 !Number of Chains and length of each of the blocks
REAL*8, PARAMETER :: Mbeadchains=1.d0 ! Mass of each bead in the chains
INTEGER, PARAMETER :: Npart = 0 !Number of nano-dimers
REAL*8, PARAMETER :: NPdiam=3.d0, RbondEqNP=2.5d0 ! NP bead diameter, NP bond eq. distance (mass derived from here)
INTEGER, PARAMETER :: Ntimesteps=100000000, period=500000, Nconfigsperfile=3 !Number of configurations and timesteps between each consecutive pair of configurations
INTEGER, PARAMETER :: Nconfigs=Ntimesteps/period+1
REAL*8, PARAMETER :: delta_t=0.001d0
INTEGER, PARAMETER :: Nslabs=180 !Number of slabs in which the box is divided
INTEGER, PARAMETER :: NAngleSlabsPer180=36 ! Number of slabs per 180 degrees
!OTHER PARAMETERS
INTEGER, PARAMETER :: Lchains=LchainsA+LchainsB
REAL*8, PARAMETER :: Vlens=(PI*(NPdiam-RbondEqNP)**2*(RbondEqNP**2+2.d0*RbondEqNP*NPdiam)/(12.d0*RbondEqNP)) ! Overlapping volume (lens shaped)
REAL*8, PARAMETER :: MbeadNpart=0.74d0*(NPdiam**3/6.d0-Vlens/2.d0) ! Mass of Nano-dimer's beads (scalates as FCC packed)
!OTHER VARIABLES
REAL*8, DIMENSION(:) :: RChain(Nchains,0:Lchains,3) !Positions of chains ! 0 is for the CoM
REAL*8, DIMENSION(:) :: Rpart(Npart,0:2,3) !Positions of Nano-dimers ! 0 is for the CoM
REAL*8, DIMENSION(:) :: Lbox(Nconfigs,0:3)
REAL*8, DIMENSION(:) :: L0box(0:3) ! SIMULATION BOX, 0=volume
REAL*8, DIMENSION(:) :: pos(3), vel(3), jvol(6) ! jvol(stresstensor*volume): xx,yy,zz,xy,xz,yz
INTEGER, DIMENSION(:) :: ir(3)
!REAL*8 :: AvDensMonomersA,AvDensMonomersB,AvDensAllMonomers,AvDensChains,AvDensJNDs
INTEGER :: i, j, k, conf, kconf, d, d2, d3, nsl, nsl2, id, idmol, idbead, tipo
REAL*8, DIMENSION(:) :: acdensProf(6,3,Nslabs)!, acdensProf2(6,3,Nslabs) !Density profile accumulation (ChA=1,ChB=2,ChCoM=3,NPA=4,NPB=5,NPCoM=6)
REAL*8, DIMENSION(:) :: acdirProf(3,3,0:Nslabs), acdirProf2(3,3,0:Nslabs) !Angle profile accumulation (Polar=1,Azim=2,abs(polar)=3)
REAL*8, DIMENSION(:) :: slabthickness(3), AvDens(4) ! DensProf Slab Thickness, AvDensity (ChA=1,ChB=2,ChCoM=3,NPA=NPB=NPCoM=4)
REAL*8, DIMENSION(:) :: NematicV(3), NematicV2(3), vnem(0:3) !Nematic directors.
REAL*8, DIMENSION(:) :: NematicT(3,3) !Nematic tensor
REAL*8, PARAMETER :: slabthicknessAngles=180.d0/dfloat(NAngleSlabsPer180)
REAL*8 :: P2, P4,zen,azim,sgn
REAL*8, DIMENSION(:) :: acVdist(2,3,2*NAngleSlabsPer180) !Angle distribution accumulation, dims: 1=Theta(polar), 2=Phi(Azim)
INTEGER, DIMENSION(:) :: counterAngles(2,3,NSlabs)
!LAMMPS NOTE: As explained on the dump doc page, atom coordinates in a dump file may be slightly outside the simulation box. This is because periodic boundary conditions are enforced only on timesteps when neighbor lists are rebuilt, which will not typically coincide with the timesteps dump snapshots are written.
!***********************************************************************************************************************************************
!-- DENSITY PROFILES
open(1111,file=trim(inputfilename))
IF (Npart>0) open(777,file='NematicDirEvolution.dat')
acdensProf=0.d0
L0box(0)=1.d0
AvDens=0.d0
conf=0
counterAngles=0
acVdist=0.d0
acdirProf=0.d0
acdirProf2=0.d0
P2=0.d0
P4=0.d0
NematicV=0.d0
NematicV2=0.d0
DO kconf=0,NconfigsperFile*Ntimesteps/((NconfigsperFile-1)*period)-1
IF (kconf>0 .and. MOD(kconf,NconfigsperFile)==0) THEN
DO i=1,9+Nchains*Lchains+Npart*2
READ(1111,*)
END DO !i
ELSE
NematicT=0.d0
conf=conf+1
!Read coordinates and accumulate values for beads
READ(1111,*)
READ(1111,*)
READ(1111,*)
READ(1111,*)
READ(1111,*)
Lbox(conf,0)=1.d0
DO d=1,3
READ(1111,*) L0box(d), Lbox(conf,d)
Lbox(conf,d)=Lbox(conf,d)-L0box(d)
Lbox(conf,0)=Lbox(conf,0)*Lbox(conf,d)
IF (conf==1) L0box(0)=L0box(0)*Lbox(conf,d) !initial volume
slabthickness(d)=Lbox(conf,d)/dfloat(Nslabs)
END DO !dims
AvDens(1)=AvDens(1)+dfloat(LchainsA*Nchains)/Lbox(conf,0)
AvDens(2)=AvDens(2)+dfloat(LchainsB*Nchains)/Lbox(conf,0)
AvDens(3)=AvDens(3)+dfloat(Nchains)/Lbox(conf,0)
AvDens(4)=AvDens(4)+dfloat(Npart)/Lbox(conf,0)
Lbox(conf,0)=Lbox(conf,0)/L0box(0) !Volume normalisation V/V_0
READ(1111,*)
DO i=1,Nchains*Lchains+Npart*2
READ(1111,*) id, pos(1), pos(2), pos(3), ir(1), ir(2), ir(3),&
vel(1), vel(2), vel(3), jvol(1), jvol(2), jvol(3), jvol(4), jvol(5), jvol(6)
IF (id<=Nchains*Lchains) THEN
idmol=int((id-1)/Lchains)+1
idbead=id-(idmol-1)*Lchains
tipo=1
IF (idbead>LchainsA) tipo=2
DO d=1,3
Rchain(idmol,idbead,d)=pos(d)-L0box(d)
!Put bead back in the box. See LAMMPS note above.
IF (Rchain(idmol,idbead,d)<0.d0) Rchain(idmol,idbead,d)=Rchain(idmol,idbead,d)+Lbox(conf,d)
IF (Rchain(idmol,idbead,d)>=Lbox(conf,d)) Rchain(idmol,idbead,d)=Rchain(idmol,idbead,d)-Lbox(conf,d)
!Accumulator
nsl=int(Rchain(idmol,idbead,d)/slabthickness(d))+1
acdensProf(tipo,d,nsl)=acdensProf(tipo,d,nsl)+1.d0/Lbox(conf,0)
END DO !dims
ELSE
idmol=int((id-Nchains*Lchains-1)/2)+1
idbead=id-Nchains*Lchains-(idmol-1)*2
tipo=4
IF (idbead==2) tipo=5
DO d=1,3
Rpart(idmol,idbead,d)=pos(d)-L0box(d)
!Put bead back in the box. See LAMMPS note above.
IF (Rpart(idmol,idbead,d)<0.d0) Rpart(idmol,idbead,d)=Rpart(idmol,idbead,d)+Lbox(conf,d)
IF (Rpart(idmol,idbead,d)>=Lbox(conf,d)) Rpart(idmol,idbead,d)=Rpart(idmol,idbead,d)-Lbox(conf,d)
!Accumulator
nsl=int(Rpart(idmol,idbead,d)/slabthickness(d))+1
acdensProf(tipo,d,nsl)=acdensProf(tipo,d,nsl)+1.d0/Lbox(conf,0)
END DO !dims
END IF
END DO !Total Nbeads
!Compute Properties for CoMs
tipo=3
DO i=1,Nchains
DO d=1,3
ir(d)=0
RChain(i,0,d)=0.d0
DO j=1,Lchains
IF (j>1) THEN
pos(d)=Rchain(i,j,d)-Rchain(i,j-1,d)
IF (pos(d)>Lbox(conf,d)/2.d0) ir(d)=ir(d)-1
IF (pos(d)<-Lbox(conf,d)/2.d0) ir(d)=ir(d)+1
END IF
RChain(i,0,d)=RChain(i,0,d)+Mbeadchains*(Rchain(i,j,d)+Lbox(conf,d)*ir(d))
END DO !Lchains
RChain(i,0,d)=RChain(i,0,d)/(dfloat(Lchains)*Mbeadchains)
IF (RChain(i,0,d)<0.d0) RChain(i,0,d)=RChain(i,0,d)-(int(RChain(i,0,d)/Lbox(conf,d))-1)*Lbox(conf,d)
IF (RChain(i,0,d)>=Lbox(conf,d)) RChain(i,0,d)=RChain(i,0,d)-int(RChain(i,0,d)/Lbox(conf,d))*Lbox(conf,d)
nsl=int(Rchain(i,0,d)/slabthickness(d))+1
acdensProf(tipo,d,nsl)=acdensProf(tipo,d,nsl)+1.d0/Lbox(conf,0)
END DO !dims
END DO !Nchains
tipo=6
DO i=1,Npart
Call DistAB(Rpart(i,2,1),Rpart(i,2,2),Rpart(i,2,3),&
Rpart(i,1,1),Rpart(i,1,2),Rpart(i,1,3),&
Lbox(conf,1),Lbox(conf,2),Lbox(conf,3),&
vnem(1),vnem(2),vnem(3),vnem(0))
DO d=1,3
!density profiles
ir(d)=0
Rpart(i,0,d)=MbeadNpart*Rpart(i,1,d)
pos(d)=Rpart(i,2,d)-Rpart(i,1,d)
IF (pos(d)>Lbox(conf,d)/2.d0) ir(d)=ir(d)-1
IF (pos(d)<-Lbox(conf,d)/2.d0) ir(d)=ir(d)+1
Rpart(i,0,d)=Rpart(i,0,d)+MbeadNpart*(Rpart(i,2,d)+Lbox(conf,d)*ir(d))
Rpart(i,0,d)=Rpart(i,0,d)/(2.d0*MbeadNpart)
IF (Rpart(i,0,d)<0.d0) Rpart(i,0,d)=Rpart(i,0,d)-(int(Rpart(i,0,d)/Lbox(conf,d))-1)*Lbox(conf,d)
IF (Rpart(i,0,d)>=Lbox(conf,d)) Rpart(i,0,d)=Rpart(i,0,d)-int(Rpart(i,0,d)/Lbox(conf,d))*Lbox(conf,d)
nsl=int(Rpart(i,0,d)/slabthickness(d))+1
acdensProf(tipo,d,nsl)=acdensProf(tipo,d,nsl)+1.d0/Lbox(conf,0)
!orientational behaviour
DO d2=1,3
NematicT(d,d2)=NematicT(d,d2)+vnem(d)*vnem(d2)/vnem(0)
END DO !dims2
zen=180.d0*dacos(vnem(d)/dsqrt(vnem(0)))/PI-90.d0
nsl2=int((zen+90.d0)/slabthicknessAngles)+1
IF (nsl2 == int(180.d0/slabthicknessAngles)+1) nsl2=nsl2-1
acVdist(1,d,nsl2)=acVdist(1,d,nsl2)+1.d0
d2=d-1
d3=d+1
IF (d2==0) d2=3
IF (d3==4) d3=1
sgn=dfloat(nint(vnem(d2)/abs(vnem(d2))))
azim=180.d0*sgn*dacos(vnem(d3)/dsqrt((vnem(d2)**2+vnem(d3)**2)))/PI
nsl2=int((azim+180.d0)/slabthicknessAngles)+1
IF (nsl2 == int(360.d0/slabthicknessAngles)+1) nsl2=nsl2-1
acVdist(2,d,nsl2)=acVdist(2,d,nsl2)+1.d0
counterAngles(1,d,nsl)=counterAngles(1,d,nsl)+1
counterAngles(2,d,nsl)=counterAngles(2,d,nsl)+1
acdirProf(1,d,nsl)=acdirProf(1,d,nsl)+zen
acdirProf2(1,d,nsl)=acdirProf2(1,d,nsl)+zen**2
acdirProf(2,d,nsl)=acdirProf(2,d,nsl)+azim
acdirProf2(2,d,nsl)=acdirProf2(2,d,nsl)+azim**2
acdirProf(3,d,nsl)=acdirProf(3,d,nsl)+dabs(zen)
acdirProf2(3,d,nsl)=acdirProf2(3,d,nsl)+zen**2
END DO !dims
END DO !Npart
IF (Npart>0) THEN
NematicT=NematicT/dfloat(Npart)
Call Order(NematicT,vnem(1),vnem(2),vnem(3),vnem(0))
P2=P2+vnem(0)
P4=P4+vnem(0)**2
DO d=1,3
NematicV(d)=NematicV(d)+vnem(d)
NematicV2(d)=NematicV2(d)+vnem(d)**2
END DO !dims
WRITE(777,777) dfloat(period*(conf-1))*delta_t, vnem(0), vnem(1), vnem(2), vnem(3)
END IF !Npart>0
END IF !ignore every
END DO !kconf Nconfigs
close(1111)
IF (Npart>0) close(777)
!-- OUTPUT DENSITY PROFILES
open(500,file='densprof_monomers.dat')
open(501,file='densprof_monomersH.dat')
open(502,file='densprof_monomersT.dat')
open(503,file='densprof_chainsCM.dat')
open(600,file='densprof_monomers_notNorm.dat')
open(601,file='densprof_monomersH_notNorm.dat')
open(602,file='densprof_monomersT_notNorm.dat')
IF (Npart>0) THEN
open(504,file='densprof_NPsA.dat')!0, for 00, H for the rest
open(505,file='densprof_NPsB.dat')!0,H or T
open(506,file='densprof_NPsCM.dat')
END IF
acdensProf=dfloat(Nslabs)*acdensProf/(dfloat(Nconfigs)*L0box(0))
AvDens=AvDens/dfloat(Nconfigs)
DO i=1,3
DO k=1,Nslabs
IF (i==1) THEN
WRITE (500, 500) real((dfloat(k)-0.5)/Nslabs),&
(real(acdensProf(1,1,k))+real(acdensProf(2,1,k)))/(AvDens(1)+AvDens(2)),&
(real(acdensProf(1,2,k))+real(acdensProf(2,2,k)))/(AvDens(1)+AvDens(2)),&
(real(acdensProf(1,3,k))+real(acdensProf(2,3,k)))/(AvDens(1)+AvDens(2))
WRITE (600, 500) real((dfloat(k)-0.5)/Nslabs),&
real(acdensProf(1,1,k))+real(acdensProf(2,1,k)),&
real(acdensProf(1,2,k))+real(acdensProf(2,2,k)),&
real(acdensProf(1,3,k))+real(acdensProf(2,3,k))
END IF
IF (i==1 .or. i==2) THEN
WRITE (500+i, 500) real((dfloat(k)-0.5)/Nslabs), real(acdensProf(i,1,k))/(AvDens(1)+AvDens(2)),&
real(acdensProf(i,2,k))/(AvDens(1)+AvDens(2)), real(acdensProf(i,3,k))/(AvDens(1)+AvDens(2))
WRITE (600+i, 500) real((dfloat(k)-0.5)/Nslabs), real(acdensProf(i,1,k)),&
real(acdensProf(i,2,k)), real(acdensProf(i,3,k))
ELSE IF (i==3) THEN
WRITE (500+i, 500) real((dfloat(k)-0.5)/Nslabs), real(acdensProf(i,1,k))/AvDens(i),&
real(acdensProf(i,2,k))/AvDens(i), real(acdensProf(i,3,k))/AvDens(i)
END IF
IF (Npart>0) THEN
WRITE (500+i+3, 500) real((dfloat(k)-0.5)/Nslabs), real(acdensProf(i+3,1,k))/AvDens(4),&
real(acdensProf(i+3,2,k))/AvDens(4), real(acdensProf(i+3,3,k))/AvDens(4)
END IF
END DO !k Nslabs
END DO !i type
close(500)
DO i=1,3
close(500+i)
IF (Npart>0) close(500+i+3)
END DO !output files
!***********************************************************************************************************************************************
!-- ORIENTATIONAL BEHAVIOUR
IF (Npart>0) THEN
!-- OUTPUT ORIENTATIONAL DATA
open(400,file='Nematic_average.out')
WRITE (400,*)
WRITE (400,*) 'Ens. Average Nematic Director of Janus Nanodimers'
WRITE (400,974) '<n_x>= ', NematicV(1)/dfloat(Nconfigs),' +- ',&
dsqrt(NematicV2(1)/dfloat(Nconfigs)-(NematicV(1)/dfloat(Nconfigs))**2)
WRITE (400,974) '<n_y>= ', NematicV(2)/dfloat(Nconfigs),' +- ',&
dsqrt(NematicV2(2)/dfloat(Nconfigs)-(NematicV(2)/dfloat(Nconfigs))**2)
WRITE (400,974) '<n_z>= ', NematicV(3)/dfloat(Nconfigs),' +- ',&
dsqrt(NematicV2(3)/dfloat(Nconfigs)-(NematicV(3)/dfloat(Nconfigs))**2)
WRITE (400,*) 'Nematic Order Parameter of Janus Nanodimers'
WRITE (400,974) '<P_2>= ', P2/dfloat(Nconfigs),' +- ',&
dsqrt(P4/dfloat(Nconfigs)-(P2/dfloat(Nconfigs))**2)
close(400)
open(100,file='Angle_average.dat')
open(110,file='polar_X_prof.dat')
open(120,file='polar_Y_prof.dat')
open(130,file='polar_Z_prof.dat')
open(210,file='azimutal_YZ_prof.dat')
open(220,file='azimutal_ZX_prof.dat')
open(230,file='azimutal_XY_prof.dat')
open(310,file='abs_polar_X_prof.dat')
open(320,file='abs_polar_Y_prof.dat')
open(330,file='abs_polar_Z_prof.dat')
DO i=1,3 !type
IF (i==1) WRITE(100,*) '# dir(x=1,y=2,z=3) Polar angles(º) stdev(º)'
IF (i==2) WRITE(100,*) '# plane(yz=1,zx=2,xy=3) Azimuthal angles(º) stdev(º)'
IF (i==3) WRITE(100,*) '# dir(x=1,y=2,z=3) ABS(Polar angles)(º) stdev(º)'
DO d=1,3 ! dims
DO j=1,Nslabs
acdirProf(i,d,0)=acdirProf(i,d,0)+acdirProf(i,d,j)
acdirProf2(i,d,0)=acdirProf2(i,d,0)+acdirProf2(i,d,j)
nsl=counterAngles(1,d,j)
IF (i==2) nsl=counterAngles(2,d,j)
IF (nsl>0) WRITE (100*i+10*d,600) &
real((dfloat(j)-0.5d0)/dfloat(Nslabs)),&
acdirProf(i,d,j)/dfloat(nsl),&
dsqrt(acdirProf2(i,d,j)/dfloat(nsl)-&
(acdirProf(i,d,j)/dfloat(nsl))**2)
END DO !j Nslabs
close(100*i+10*d)
WRITE (100,601) &
d, acdirProf(i,d,0)/dfloat(Nconfigs*Npart),&
dsqrt(acdirProf2(i,d,0)/dfloat(Nconfigs*Npart)-&
(acdirProf(i,d,0)/dfloat(Nconfigs*Npart))**2)
END DO !d dims
END DO !i type
!*************
acVdist=acVdist/dfloat(Npart*Nconfigs)
open(100,file='polar_dist.dat')
open(200,file='azimutal_dist.dat')
DO i=1,2
DO j=1, int(i*180.d0/slabthicknessAngles)
WRITE(100*i,602) real((dfloat(j)-0.5d0)*slabthicknessAngles)-i*90.d0,&
real(acVdist(i,1,j)),real(acVdist(i,2,j)),real(acVdist(i,3,j))
END DO !j Nslabs
close(100*d)
END DO !i Angle type
END IF !NPart>0
!***********************************************************************************************************************************************
!-- FORMATS
500 FORMAT (F8.5,2X,F10.5,2X,F10.5,2X,F10.5)
600 FORMAT (F10.5,2X,F12.5,2X,F12.5)
601 FORMAT (I2,2X,F12.5,2X,F12.5)
602 FORMAT (F7.1,2X,F10.5,2X,F10.5,2X,F10.5)
777 FORMAT(F14.6,2X,F9.5,2X,F9.5,2X,F9.5,2X,F9.5)
974 FORMAT(A7,F8.5,A4,F8.5)
!***********************************************************************************************************************************************
!-- SUBROUTINES
CONTAINS
!-- DISTANCE BETWEEN TWO POINTS
SUBROUTINE DistAB(Ax,Ay,Az,Bx,By,Bz,Lx,Ly,Lz,ABx,ABy,ABz,AB2)
IMPLICIT NONE
REAL*8, INTENT(IN) :: Ax,Ay,Az,Bx,By,Bz,Lx,Ly,Lz
REAL*8, INTENT(OUT) :: ABx,ABy,ABz,AB2
ABx= Ax - Bx
IF (ABx>Lx/2.d0) ABx=ABx-Lx
IF (ABx<-Lx/2.d0) ABx=ABx+Lx
ABy= Ay - By
IF (ABy>Ly/2.d0) ABy=ABy-Ly
IF (ABy<-Ly/2.d0) ABy=ABy+Ly
ABz= Az - Bz
IF (ABz>Lz/2.d0) ABz=ABz-Lz
IF (ABz<-Lz/2.d0) ABz=ABz+Lz
AB2=ABx*ABx+ABy*ABy+ABz*ABz
RETURN
END SUBROUTINE DistAB
!-- NEMATIC DIRECTOR COMPUTATION
SUBROUTINE Order(Tensorin,ex,ey,ez,OPAR) !NUMERICAL RECIPES
IMPLICIT NONE
REAL*8, DIMENSION(3,3), INTENT(IN) :: Tensorin
REAL*8, INTENT(OUT) :: ex,ey,ez, OPAR
REAL*8 :: EIGVA1,EIGVA2,EIGVA3
REAL*8, DIMENSION(3,3) :: Eigenvectors, Tensor
INTEGER :: IP, NP
INTEGER :: IQ, NROT
REAL*8 :: C,GOL, H, P, SM,SO, T,TAU, TRESH, THETA
REAL*8, DIMENSION(3) :: Dee
REAL*8, DIMENSION(100) :: B, Z
Eigenvectors=0.d0
Eigenvectors(1,1)=1.d0
Eigenvectors(2,2)=1.d0
Eigenvectors(3,3)=1.d0
Tensor=Tensorin
! Diagonalization
! INITIALIZE D AND B TO THE DIAGONAL OF A
NP=3
DO IP=1,NP
B(IP)=Tensor(IP,IP)
Dee(IP)=B(IP)
Z(IP)=0.0D00
END DO !IP
NROT=0
DO I=1,50
SM=0.0D00
! SUM OFF-DIAGONAL ELEMENTS
DO IP=1,NP-1
DO IQ=IP+1,NP
SM=SM+DABS(Tensor(IP,IQ))
END DO !IQ
END DO !IP
! CONDITION FOR MACHINE CONVERGENCE AND EXIT
IF (SM.EQ.0.0D00) THEN
EXIT
END IF
IF (I.LT.4) THEN
TRESH=0.2D00*SM/DFLOAT(NP)**2
ELSE
TRESH=0.0D00
END IF
DO IP=1,NP-1
DO IQ=IP+1,NP
GOL=100.D00*DABS(Tensor(IP,IQ))
IF ((I.GT.4).AND.(DABS(Dee(IP))+GOL.EQ.DABS(Dee(IP)))&
.AND.(DABS(Dee(IQ))+GOL.EQ.DABS(Dee(IQ)))) THEN
Tensor(IP,IQ)=0.0D00
ELSE IF (DABS(Tensor(IP,IQ)).GT.TRESH) THEN
H=Dee(IQ)-Dee(IP)
IF (DABS(H)+GOL.EQ.DABS(H)) THEN
T=Tensor(IP,IQ)/H
ELSE
THETA=0.5D00*H/Tensor(IP,IQ)
T=1.0D00/(DABS(THETA)+DSQRT(1.0D00+THETA**2))
IF (THETA.LT.0.0D00) T=-T
END IF
C=1.0D00/DSQRT(1.0D00+T*T)
SO=T*C
TAU=SO/(1.0D00+C)
H=T*Tensor(IP,IQ)
Z(IP)=Z(IP)-H
Z(IQ)=Z(IQ)+H
Dee(IP)=Dee(IP)-H
Dee(IQ)=Dee(IQ)+H
Tensor(IP,IQ)=0.0D00
DO J=1,IP-1
GOL=Tensor(J,IP)
H=Tensor(J,IQ)
Tensor(J,IP)=GOL-SO*(H+GOL*TAU)
Tensor(J,IQ)=H+SO*(GOL-H*TAU)
END DO !J
DO J=IP+1,IQ-1
GOL=Tensor(IP,J)
H=Tensor(J,IQ)
Tensor(IP,J)=GOL-SO*(H+GOL*TAU)
Tensor(J,IQ)=H+SO*(GOL-H*TAU)
END DO !J
DO J=IQ+1,NP
GOL=Tensor(IP,J)
H=Tensor(IQ,J)
Tensor(IP,J)=GOL-SO*(H+GOL*TAU)
Tensor(IQ,J)=H+SO*(GOL-H*TAU)
END DO !J
DO J=1,NP
GOL=Eigenvectors(J,IP)
H=Eigenvectors(J,IQ)
Eigenvectors(J,IP)=GOL-SO*(H+GOL*TAU)
Eigenvectors(J,IQ)=H+SO*(GOL-H*TAU)
END DO !J
NROT=NROT+1
END IF
END DO !IQ
END DO !IP
DO IP=1,NP
B(IP)=B(IP)+Z(IP)
Dee(IP)=B(IP)
Z(IP)=0.0D00
END DO !IP
END DO !I
! PAUSE '50 ITERATIONS SHOULD NEVER HAPPEN'
! SORTS TO PUT THE EIGENVALUES INTO ASCENDING ORDER, AND TO
! REARRANGE THE COLUMNS OF V
DO I=1,NP-1
K=I
P=Dee(I)
DO J=I+1,NP
IF (Dee(J).GE.P) THEN
K=J
P=Dee(J)
END IF
END DO !J
IF (K.NE.I) THEN
Dee(K)=Dee(I)
Dee(I)=P
DO J=1,NP
P=Eigenvectors(J,I)
Eigenvectors(J,I)=Eigenvectors(J,K)
Eigenvectors(J,K)=P
END DO !J
END IF
END DO !I
! EIGENVALUES OF MATRIX Q THE ORDERING TENSOR (IN DECREASING ORDER)
! Q=A-1/2
EIGVA1=3.0D00/2.0D00*Dee(1)-0.5D00
EIGVA2=3.0D00/2.0D00*Dee(2)-0.5D00
EIGVA3=3.0D00/2.0D00*Dee(3)-0.5D00
! OUTPUT
OPAR=EIGVA1
!DIRECTOR (EIGENVECTOR Eigenvectors(I,1)), ASSOCIATED WITH EIGENVALUE 1
ex=Eigenvectors(1,1)
ey=Eigenvectors(2,1)
ez=Eigenvectors(3,1)
RETURN
END SUBROUTINE Order
!******************************************************************************
END PROGRAM LamellarStructure
| Data_Analysis/lamellar_structure.f90 |
!--------------------------------------------------------------------------------------------------!
!--------------------------------------------------------------------------------------------------!
!--------------------------------------- FLTINV INPUTS --------------------------------------------!
!--------------------------------------------------------------------------------------------------!
!--------------------------------------------------------------------------------------------------!
subroutine read_inputs()
!----
! Read the input files for controlling fltinv and set up control variables and arrays. Run checks
! on inputs to make sure fltinv will operate. (PROBABLY NEEDS MORE/BETTER CHECKS. ADD AS NECESSARY.)
!----
use io, only: stderr, stdout, line_count, fileExists, verbosity
use geom, only: strdip2normal
use elast, only: stress2traction, traction_components, read_halfspace_file
use tri_disloc, only: tri_geometry, tri_geo2cart
use fltinv, only: inversion_mode, &
fault, &
slip_constraint, &
rake_constraint, &
euler_file, &
npoles, &
rigid_pt_array_disp, &
rigid_pt_array_los, &
pole_array, &
gf_euler, &
displacement, &
disp_components, &
input_disp_unit, &
los, &
prestress, &
cov_file, &
cov_matrix, &
isCovMatrixDiagonal, &
gf_model, &
gf_disp, &
gf_los, &
gf_stress, &
coord_type, &
halfspace_file, &
poisson, &
lame, &
shearmod, &
smoothing_file, &
nsmooth, &
smoothing_pointers, &
smoothing_neighbors, &
fault_slip, &
euler_pole, &
read_fltinv_data_file
implicit none
! Local variables
integer :: i, j, ios, ierr, ii, nn, mm, ndisp_dof, nlos_dof, ndof
double precision :: dist, dp1, dp2, cov, sts(3,3), nvec(3), vec(3), pt1(3), pt2(3), pt3(3)
double precision :: geo_pt1(3), geo_pt2(3), geo_pt3(3)
double precision, allocatable :: cov_matrix_temp(:)
character(len=512) :: line
character(len=1) :: nchar, mchar
logical :: foundRigidObs, isErrorMessagePrinted
if (verbosity.ge.1) then
write(stdout,*) 'read_inputs: starting'
endif
!----
! Check that coordinate type is specified
!----
if (coord_type.ne.'cartesian'.and.coord_type.ne.'geographic') then
call usage('read_inputs: no coordinate type specified: use -xy or -geo option (usage:input)')
endif
!----
! Check for and read observations
!----
! Observations are required to constrain the fault slip or Euler pole
if (displacement%file.eq.'none'.and.los%file.eq.'none'.and.prestress%file.eq.'none') then
call usage('read_inputs: no displacement, los, or pre-stress file defined (usage:input)')
endif
! Read the observation files
! The number of columns in each file must be set prior to calling read_fltinv_data_file()
! Three-component displacements
if (displacement%file.ne.'none') then
displacement%ncols = 6 ! x y z ux uy uz
call read_fltinv_data_file(displacement,ierr)
if (ierr.ne.0) then
call usage('read_inputs: problem reading displacement file (usage:input)')
elseif (displacement%nrows.eq.0) then
call usage('read_inputs: displacement file is empty (usage:input)')
endif
endif
! Line-of-sight displacements
if (los%file.ne.'none') then
los%ncols = 6 ! x y z ulos az inc
call read_fltinv_data_file(los,ierr)
if (ierr.ne.0) then
call usage('read_inputs: problem reading los file (usage:input)')
elseif (los%nrows.eq.0) then
call usage('read_inputs: los file is empty (usage:input)')
endif
endif
! Pre-stresses on faults
if (prestress%file.ne.'none') then
prestress%ncols = 6 ! sxx syy szz sxy sxz syz (correspond to fault locations defined in fault file)
call read_fltinv_data_file(prestress,ierr)
if (ierr.ne.0) then
call usage('read_inputs: problem reading pre-stress file (usage:input)')
elseif (prestress%nrows.eq.0) then
call usage('read_inputs: pre-stress file is empty (usage:input)')
endif
endif
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: finished reading observation files'
endif
!----
! Check for and read model parameter inputs
!----
! A fault file or Euler pole file is required
if (fault%file.eq.'none'.and.euler_file.eq.'none') then
call usage('read_inputs: no fault file or Euler pole defined')
endif
! The fault file contains the number of sub-faults (and sub-fault locations/geometries if used)
if (fault%file.ne.'none') then
! The number of columns to read depends on whether fltinv is reading in Green's functions or
! whether they need to be calculated. Providing ANY Green's functions via input file overrides
! the calculation of ALL OTHER Green's functions. Explicitly define this behavior here.
! If Green's functions are pre-computed, only need the number of lines from the fault file
! so set the number of columns to 1
if (gf_disp%file.ne.'none'.and.displacement%file.ne.'none') then
fault%ncols = 1
gf_model = 'precomputed'
elseif (gf_los%file.ne.'none'.and.los%file.ne.'none') then
fault%ncols = 1
gf_model = 'precomputed'
elseif (gf_stress%file.ne.'none'.and.prestress%file.ne.'none') then
fault%ncols = 1
gf_model = 'precomputed'
! Otherwise, Green's functions must be computed, so the fault file needs to have correct format
elseif (gf_model.eq.'okada_rect') then
fault%ncols = 7 ! evlo evla evdp str dip wid len
elseif (gf_model.eq.'okada_pt') then
fault%ncols = 6 ! evlo evla evdp str dip area
elseif (gf_model.eq.'triangle') then
fault%ncols = 9 ! v1x v1y v1z v2x v2y v2z v3x v3y v3z
! Need to have some Green's functions for an inversion!!!
else
write(stderr,*) 'read_inputs: neither GF model nor precomputed GFs are defined ',&
'(or did not recognize GF model "',trim(gf_model),'")'
write(stderr,*) 'Use -gf:model to select a model:'
write(stderr,*) ' okada_rect'
write(stderr,*) ' okada_pt'
write(stderr,*) ' triangle'
call usage('Or use options such as -gf:disp_file for precomputed GFs (usage:gf)')
endif
! Read the fault data
call read_fltinv_data_file(fault,ierr)
if (ierr.ne.0) then
call usage('read_inputs: problem reading fault file (usage:fault)')
endif
! Allocate memory for the output fault slip array
if (.not.allocated(fault_slip)) then
allocate(fault_slip(fault%nrows,2),stat=ierr)
if (ierr.ne.0) then
call usage('read_inputs: error allocating memory to fault_slip (usage:none)')
endif
endif
endif
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: finished reading fault and fault slip Greens function files'
endif
! The Euler pole file contains the set of observations points experiencing rigid body rotations
! Rigid body rotations defined by Euler poles
if (euler_file.ne.'none') then
! Rigid body rotational velocites correspond to units (unlike displacements, where observation
! units=fault slip units). These units must be defined explicitly.
if (input_disp_unit.eq.'m') then
call usage('read_inputs: disp units are m (displacement), incompatible with rotations '// &
'(usage:input)')
elseif (input_disp_unit.eq.'mm') then
call usage('read_inputs: disp units are mm (displacement), incompatible with rotations '// &
'(usage:input)')
elseif (input_disp_unit.eq.'m/s') then
! Velocity: all good
elseif (input_disp_unit.eq.'m/yr') then
! Velocity: all good
elseif (input_disp_unit.eq.'mm/s') then
! Velocity: all good
elseif (input_disp_unit.eq.'mm/yr') then
! Velocity: all good
else
call usage('read_inputs: no disp units named '//trim(input_disp_unit)//' (usage:input)')
endif
! Check that Euler pole file exists, then open it
if (.not.fileExists(euler_file)) then
call usage('read_inputs: no Euler pole file named '//trim(euler_file)//' (usage:input)')
endif
open(unit=68,file=euler_file,status='old')
if (verbosity.ge.2) then
write(stderr,*) 'read_inputs: reading Euler pole file named ',trim(euler_file)
endif
! Parse the Euler pole file
! First line is the number of Euler poles
read(68,*,iostat=ios) npoles
if (ios.ne.0) then
call usage('read_inputs: error reading Euler pole file 1st line: npoles (usage:input)')
endif
allocate(euler_pole(npoles,3))
! Initialize array recording which points are affected by each rigid body rotation
if (displacement%file.ne.'none') then
allocate(rigid_pt_array_disp(displacement%nrows))
rigid_pt_array_disp = 0
endif
if (los%file.ne.'none') then
allocate(rigid_pt_array_los(los%nrows))
rigid_pt_array_los = 0
endif
! Initialize array for prior constraints on Euler pole location and angular velocity
if (inversion_mode.eq.'anneal'.or.inversion_mode.eq.'anneal-psc') then
allocate(pole_array(npoles,5))
pole_array = 0.0d0
endif
! Read prior constraints on Euler pole locations: lon lat rad min_rate max_rate
do i = 1,npoles
read(68,'(A)',end=4001,iostat=ios) line
if (allocated(pole_array)) then
read(line,*,end=4002,err=4002,iostat=ios) pole_array(i,1:5)
if (pole_array(i,4).ge.pole_array(i,5)) then
call usage('read_inputs: min pole velocity greater than max pole velocity '//&
'(usage:euler)')
endif
endif
enddo
4001 if (ios.ne.0) then
call usage('read_inputs: reached end of Euler file before finished reading (usage:none)')
endif
4002 if (ios.ne.0) then
call usage('read_inputs: error parsing Euler pole lon lat radius(km) min_rate(deg/Ma) '//&
'max_rate(deg/Ma) from: '//trim(line)//' (usage:none)')
endif
! Read groups of points experiencing rigid rotations
do
read(68,'(A)',end=4003,iostat=ios) line
read(line,*,end=4004,err=4004,iostat=ios) i,nchar,j
if (nchar.eq.'3') then
if (allocated(rigid_pt_array_disp)) then
rigid_pt_array_disp(j) = i
else
call usage('read_inputs: specified rigid rotation for 3D motion but array '//&
'unallocated (usage:none)')
endif
elseif (nchar.eq.'l'.or.nchar.eq.'L') then
if (allocated(rigid_pt_array_los)) then
rigid_pt_array_los(j) = i
else
call usage('read_inputs: specified rigid rotation for LOS motion but array '//&
'unallocated (usage:none)')
endif
else
call usage('read_inputs: no observation type code named '//nchar//'; use "3" or "L"'// &
' (usage:none)')
endif
enddo
4003 ios = 0
4004 if (ios.ne.0) then
call usage('read_inputs: error parsing ipole 3|L iobs from: '//trim(line)// &
' (usage:none)')
endif
! Check that some point is constraining the Euler pole rotation
foundRigidObs = .false.
if (allocated(rigid_pt_array_disp)) then
if (maxval(rigid_pt_array_disp).gt.0) then
foundRigidObs = .true.
endif
endif
if (allocated(rigid_pt_array_los)) then
if (maxval(rigid_pt_array_los).gt.0) then
foundRigidObs = .true.
endif
endif
if (.not.foundRigidObs) then
call usage('read_inputs: user wants Euler pole but no observations have rigid rotations '//&
'(usage:euler)')
endif
! Initialize Greens functions for rotations
allocate(gf_euler(2*displacement%nrows+los%nrows,3*npoles))
gf_euler = 0.0d0
! All done with rigid block file
close(68)
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: finished reading Euler pole file'
endif
else
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: no Euler poles being used'
endif
npoles = 0
endif
!----
! Check input values
!----
! Input fault depth and dimensions depend on GF model
if (fault%file.ne.'none') then
! Rectangular faults in an elastic half-space (okada_rect)
if (gf_model.eq.'okada_rect') then
! Depth is positive down, units in meters
if (minval(fault%array(:,3)).lt.0.0d0) then
! Found negative depth
write(stderr,*) 'read_inputs: found fault depth of ',minval(fault%array(:,3))
call usage('Depth is defined positive down for gf_model '//trim(gf_model)// &
'(usage:none)')
elseif (maxval(fault%array(:,3)).lt.1000.0d0) then
! All depths are small, using km?
write(stderr,*) 'read_inputs: all fault depths are less than +1000 meters (using ', &
'gf_model ',trim(gf_model),')'
endif
! Fault dimensions are in meters
if (maxval(fault%array(:,6)).lt.100.0d0.and.maxval(fault%array(:,7)).lt.100.0d0) then
! All dimensions are small, using km?
write(stderr,*) 'read_inputs: all fault dimensions are less than 100 meters ',&
' using gf_model ',trim(gf_model)
endif
! Point source faults in an elastic half-space
elseif (gf_model.eq.'okada_pt') then
! Depth is positive down, units in meters
if (minval(fault%array(:,3)).lt.0.0d0) then
! Found negative depth
write(stderr,*) 'read_inputs: found fault depth of ',minval(fault%array(:,3))
call usage('Depth is defined positive down for gf_model '//trim(gf_model)// &
'(usage:none)')
elseif (maxval(fault%array(:,3)).lt.1000.0d0) then
! All depths are small, using km?
write(stderr,*) 'read_inputs: all fault depths are less than +1000 meters (using ', &
'gf_model ',trim(gf_model),')'
endif
! Fault areas are in square meters
if (maxval(fault%array(:,6)).lt.10000.0d0) then
! Area is small, using km^2?
write(stderr,*) 'read_inputs: all fault areas are less than 100x100 square meters ',&
'using gf_model ',trim(gf_model)
endif
! Triangular faults in an elastic half-space
elseif (gf_model.eq.'triangle') then
if (minval([fault%array(:,3),fault%array(:,6),fault%array(:,9)]).lt.0.0d0) then
! Found negative depth
write(stderr,*) 'read_inputs: found triangle vertex depth of ', &
minval([fault%array(:,3),fault%array(:,6),fault%array(:,9)])
call usage('Depth is defined positive down for gf_model '//trim(gf_model)// &
'(usage:none)')
endif
if (maxval([fault%array(:,3),fault%array(:,6),fault%array(:,9)]).lt.1000.0d0) then
! All depths are small, using km?
write(stderr,*) 'read_inputs: all fault depths are less than +1000 meters (using ', &
'gf_model ',trim(gf_model),')'
endif
elseif (gf_model.eq.'precomputed') then
! Do nothing...the user is on the hook for getting this right
else
call usage('read_inputs: no gf_model named "'//trim(gf_model)//'"'//' (usage:gf)')
endif
endif
! Check observation coordinates, which depend on coordinate type (Cartesian or geographic)
if (coord_type.eq.'cartesian') then
! Calculate distances between all faults and first displacement/los input
! In 'cartesian' mode, this value should be typically be 1e1-1e5 meters
if (displacement%file.ne.'none'.and.gf_model.ne.'precomputed') then
do i = 1,fault%nrows
dist = (displacement%array(1,1)-fault%array(i,1))**2 + &
(displacement%array(1,2)-fault%array(i,2))**2
if (dsqrt(dist).le.10.0d0) then
write(stderr,*) 'read_inputs: small fault-displacement distance found'
write(stderr,*) 'Did you mean to use the -geo flag?'
exit
endif
enddo
endif
if (los%file.ne.'none'.and.gf_model.ne.'precomputed') then
do i = 1,fault%nrows
dist = (los%array(1,1)-fault%array(i,1))**2+(los%array(1,2)-fault%array(i,2))**2
if (dsqrt(dist).le.10.0d0) then
write(stderr,*) 'read_inputs: small fault-los distance found'
write(stderr,*) 'Did you mean to use the -geo flag?'
exit
endif
enddo
endif
elseif (coord_type.eq.'geographic') then
! I am going to operate under the assumption that if the user specifically indicated to use
! geographic mode, then they used geographic coordinates. At some point I will make a check.
! ...
! ...Okay, FINE, I will not be lazy. Here is your stupid stupidity check.
if (displacement%file.ne.'none') then
if (maxval(displacement%array(:,1)).gt.360.0d0) then
call usage('read_inputs: found displacement longitude greater than 360 (usage:none)')
elseif (minval(displacement%array(:,1)).lt.-180.0d0) then
call usage('read_inputs: found displacement longitude less than -180 (usage:none)')
elseif (maxval(displacement%array(:,2)).gt.90.0d0) then
call usage('read_inputs: found displacement latitude greater than 90 (usage:none)')
elseif (minval(displacement%array(:,2)).lt.-90.0d0) then
call usage('read_inputs: found displacement latitude less than -90 (usage:none)')
endif
endif
if (los%file.ne.'none') then
if (maxval(los%array(:,1)).gt.360.0d0) then
call usage('read_inputs: found los longitude greater than 360 (usage:none)')
elseif (minval(los%array(:,1)).lt.-180.0d0) then
call usage('read_inputs: found los longitude less than -180 (usage:none)')
elseif (maxval(los%array(:,2)).gt.90.0d0) then
call usage('read_inputs: found los latitude greater than 90 (usage:none)')
elseif (minval(los%array(:,2)).lt.-90.0d0) then
call usage('read_inputs: found los latitude less than -90 (usage:none)')
endif
endif
if (gf_model.eq.'okada_rect'.or.gf_model.eq.'okada_pt') then
if (maxval(fault%array(:,1)).gt.360.0d0) then
call usage('read_inputs: found fault longitude greater than 360 (usage:none)')
elseif (minval(fault%array(:,1)).lt.-180.0d0) then
call usage('read_inputs: found fault longitude less than -180 (usage:none)')
elseif (maxval(fault%array(:,2)).gt.90.0d0) then
call usage('read_inputs: found fault latitude greater than 90 (usage:none)')
elseif (minval(fault%array(:,2)).lt.-90.0d0) then
call usage('read_inputs: found fault latitude less than -90 (usage:none)')
endif
elseif (gf_model.eq.'triangle') then
if (maxval(fault%array(:,1)).gt.360.0d0 .or. &
maxval(fault%array(:,4)).gt.360.0d0 .or. &
maxval(fault%array(:,7)).gt.360.0d0) then
call usage('read_inputs: found fault longitude greater than 360 (usage:none)')
elseif (minval(fault%array(:,1)).lt.-180.0d0 .or. &
minval(fault%array(:,4)).lt.-180.0d0 .or. &
minval(fault%array(:,7)).lt.-180.0d0) then
call usage('read_inputs: found fault longitude less than -180 (usage:none)')
elseif (maxval(fault%array(:,2)).gt.90.0d0 .or. &
maxval(fault%array(:,5)).gt.90.0d0 .or. &
maxval(fault%array(:,8)).gt.90.0d0) then
call usage('read_inputs: found fault latitude greater than 90 (usage:none)')
elseif (minval(fault%array(:,2)).lt.-90.0d0 .or. &
minval(fault%array(:,5)).lt.-90.0d0 .or. &
minval(fault%array(:,8)).lt.-90.0d0) then
call usage('read_inputs: found fault latitude less than -90 (usage:none)')
endif
endif
else
call usage('read_inputs: no coordinate type named "'//trim(coord_type)//'" (usage:input)')
endif
! The number of stresses must be equal to the number of faults
if (prestress%file.ne.'none') then
if (prestress%nrows.ne.fault%nrows) then
call usage('read_inputs: the number of pre-stresses is not equal to the number of faults'//&
'(usage:none)')
endif
endif
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: finished check on observation and fault inputs; looks okay'
endif
!----
! Convert pre-stresses from tensor components to shear tractions
!----
if (prestress%file.ne.'none') then
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: calculating shear tractions from pre-stresses'
endif
do i = 1,fault%nrows
! Get fault normal vector
if (gf_model.eq.'okada_rect'.or.gf_model.eq.'okada_pt') then
call strdip2normal(fault%array(i,4),fault%array(i,5),nvec)
elseif (gf_model.eq.'triangle') then
if (coord_type.eq.'cartesian') then
call tri_geometry(nvec,vec,vec,fault%array(i,1:3),fault%array(i,4:6), &
fault%array(i,7:9))
elseif (coord_type.eq.'geographic') then
! Triangle points: lon lat dep(m) to x y z
geo_pt1 = fault%array(i,1:3)
geo_pt2 = fault%array(i,4:6)
geo_pt3 = fault%array(i,7:9)
call tri_geo2cart(pt1,pt2,pt3,geo_pt1,geo_pt2,geo_pt3,'m')
call tri_geometry(nvec,vec,vec,pt1,pt2,pt3)
endif
else
write(stderr,*) 'read_inputs: no gf_model named "'//trim(gf_model)//'"'
write(stderr,*) 'Available models:'
write(stderr,*) ' okada_rect'
write(stderr,*) ' okada_pt'
call usage( ' triangle (usage:input)')
endif
! Compute traction vector
sts(1,1) = prestress%array(i,1)
sts(2,2) = prestress%array(i,2)
sts(3,3) = prestress%array(i,3)
sts(1,2) = prestress%array(i,4)
sts(2,1) = prestress%array(i,4)
sts(1,3) = prestress%array(i,5)
sts(3,1) = prestress%array(i,5)
sts(2,3) = prestress%array(i,6)
sts(3,2) = prestress%array(i,6)
call stress2traction(sts,nvec,vec)
! Project traction vector onto fault strike and up-dip directions
call traction_components(vec,nvec,dp1,prestress%array(i,1),prestress%array(i,2))
enddo
if (verbosity.eq.2) then
write(stdout,*) 'read_inputs: initial shear tractions computed'
endif
endif
!----
! Set up Green's functions arrays
!----
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: allocating memory to Greens function arrays'
endif
! Three-component displacements
if (displacement%file.ne.'none') then
! Assign maximum possible dimensions for three-component displacement Green's functions
gf_disp%ncols = 2*fault%nrows
if (gf_disp%file.ne.'none') then
! Read pre-computed three-component displacement Green's functions
call read_fltinv_data_file(gf_disp,ierr)
if (ierr.ne.0) then
call usage('read_inputs: problem reading gf_disp file (usage:none)')
endif
! Verify that there are the correct number of rows in the array
if (gf_disp%nrows .ne. 3*displacement%nrows) then
call usage('read_inputs: number of lines in three-component displacement GF file '// &
'must be 3*ndisplacements (one line per displacement DOF) (usage:none)')
endif
else
! Displacement Green's functions need to be calculated; allocate memory to array
gf_disp%nrows = 3*displacement%nrows
if (allocated(gf_disp%array)) then
deallocate(gf_disp%array)
endif
allocate(gf_disp%array(gf_disp%nrows,gf_disp%ncols),stat=ierr)
if (ierr.ne.0) then
call usage('read_inputs: error allocating memory to gf_disp%array (usage:none)')
endif
endif
endif
! Line-of-sight displacements
if (los%file.ne.'none') then
! Assign maximum possible dimensions for LOS Green's functions
gf_los%ncols = 2*fault%nrows
if (gf_los%file.ne.'none') then
! Read pre-computed LOS displacement Green's functions
call read_fltinv_data_file(gf_los,ierr)
if (ierr.ne.0) then
call usage('read_inputs: problem reading gf_los file (usage:none)')
endif
! Verify that there are the correct number of rows in the array
if (gf_los%nrows .ne. los%nrows) then
call usage('read_inputs: number of lines in LOS displacement GF file '// &
'must be ndisplacements (one line per displacement DOF) (usage:none)')
endif!
else
! Allocate memory to calculate Green's functions
gf_los%nrows = los%nrows
if (allocated(gf_los%array)) then
deallocate(gf_los%array)
endif
allocate(gf_los%array(gf_los%nrows,gf_los%ncols),stat=ierr)
if (ierr.ne.0) then
call usage('read_inputs: error allocating memory to gf_los%array (usage:none)')
endif
endif
endif
! Pre-stresses
if (prestress%file.ne.'none'.or.inversion_mode.eq.'anneal-psc') then
! Assign maximum possible dimensions for pre-stress Green's functions
gf_stress%ncols = 2*fault%nrows
if (gf_stress%file.ne.'none') then
! Read pre-computed displacement Green's functions
call read_fltinv_data_file(gf_stress,ierr)
if (ierr.ne.0) then
call usage('read_inputs: problem reading gf_stress file (usage:none)')
endif
! Verify that there are the correct number of rows in the array
if (gf_stress%nrows .ne. 2*fault%nrows) then
call usage('read_inputs: number of lines in pre-stress GF file must be '//&
'2*nfaults (one line per fault slip DOF) (usage:none)')
endif
else
! Allocate memory to calculate Green's functions
gf_stress%nrows = 2*fault%nrows
if (allocated(gf_stress%array)) then
deallocate(gf_stress%array)
endif
allocate(gf_stress%array(gf_stress%nrows,gf_stress%ncols),stat=ierr)
if (ierr.ne.0) then
call usage('read_inputs: error allocating memory to gf_stress%array (usage:none)')
endif
endif
endif
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: Greens function arrays allocated'
endif
!----
! Set up arrays for other inversion controls
!----
! Slip magnitude constraints
if (slip_constraint%file.ne.'none') then
! The meaning of the slip constraint file depends on the inversion mode
! mode=lsqr: fix slip components set to values less than 99999
! mode=anneal: range of slip magnitudes to search through
! mode=anneal-psc: slip for locked faults (can be 99999 to set a fault to be always unlocked)
! Read constraints from file
slip_constraint%ncols = 2
call read_fltinv_data_file(slip_constraint,ierr)
if (ierr.ne.0) then
write(stderr,*) 'read_inputs: problem reading slip constraint file'
write(stderr,*) 'Format:'
call usage( ' slip_ss slip_ds (usage:fault)')
endif
! There can be 1 value for all faults or 1 value for each fault
if (slip_constraint%nrows.ne.1.and.slip_constraint%nrows.ne.fault%nrows) then
call usage('read_inputs: number of slip constraints must be 1 or number of faults '// &
'(usage:none)')
endif
! If there is only 1 value, set the full constraint array to that value
if (slip_constraint%nrows.eq.1) then
dp1 = slip_constraint%array(1,1)
dp2 = slip_constraint%array(1,2)
if (allocated(slip_constraint%array)) then
deallocate(slip_constraint%array)
endif
allocate(slip_constraint%array(fault%nrows,slip_constraint%ncols),stat=ierr)
if (ierr.ne.0) then
call usage('read_inputs: error allocating memory to slip_constraint%array (usage:none)')
endif
slip_constraint%nrows = fault%nrows
slip_constraint%array(:,1) = dp1
slip_constraint%array(:,2) = dp2
endif
else
if (inversion_mode.eq.'anneal') then
call usage('read_inputs: a slip constraint file is required for annealing search '// &
'(usage:fault)')
elseif (inversion_mode.eq.'anneal-psc') then
call usage('read_inputs: a slip constraint file is required for annealing+'//&
'pseudo-coupling search (usage:fault)')
endif
endif
! Rake constraints
if (rake_constraint%file.ne.'none') then
! The meaning of the rake constraint file depends on its format and the inversion mode
! mode=lsqr, ncols=1: fix the rake angle of the fault
! mode=lsqr, ncols=2: use these rake angles instead of 0 and 90 to compute slip GFs
! mode=anneal, ncols=2: range of rake angles to search through
! mode=anneal-psc, ncols=1: fix the rake angles of the faults and only allow pseudo-coupling
! slip in this direction
if (inversion_mode.eq.'lsqr') then
! Count the number of columns in the file
open(unit=33,file=rake_constraint%file,status="old")
read(33,'(A)') line
read(line,*,iostat=ios) dp1, dp2
if (ios.eq.0) then
rake_constraint%ncols = 2
else
rake_constraint%ncols = 1
endif
close(33)
elseif (inversion_mode.eq.'anneal') then
rake_constraint%ncols = 2
elseif (inversion_mode.eq.'anneal-psc') then
rake_constraint%ncols = 1
else
write(stderr,*) 'read_inputs: this inversion mode does not use rake constraints'
endif
! Read constraints from file
call read_fltinv_data_file(rake_constraint,ierr)
if (ierr.ne.0) then
call usage('read_inputs: problem reading rake constraint file (usage:fault)')
endif
! There can be 1 value for all faults or 1 value for each fault
if (rake_constraint%nrows.ne.1.and.rake_constraint%nrows.ne.fault%nrows) then
call usage('read_inputs: number of rake constraints must be 1 or number of faults '// &
'(usage:none)')
endif
! If there is only 1 value, set the full constraint array to that value
if (rake_constraint%nrows.eq.1) then
dp1 = rake_constraint%array(1,1)
if (rake_constraint%ncols.eq.2) then
dp2 = rake_constraint%array(1,2)
endif
if (allocated(rake_constraint%array)) then
deallocate(rake_constraint%array)
endif
allocate(rake_constraint%array(fault%nrows,rake_constraint%ncols),stat=ierr)
if (ierr.ne.0) then
call usage('read_inputs: error allocating memory to rake_constraint%array (usage:none)')
endif
rake_constraint%nrows = fault%nrows
rake_constraint%array(:,1) = dp1
if (rake_constraint%ncols.eq.2) then
rake_constraint%array(:,2) = dp2
endif
endif
else
if (inversion_mode.eq.'anneal') then
call usage('read_inputs: a rake constraint file is required for annealing search '// &
'(usage:fault)')
endif
! Number of rakes to compute is two, even if constraint file is not provided
rake_constraint%ncols = 2
endif
! Smoothing
if (smoothing_file.ne.'none') then
! Read the smoothing file (ifault nneighbors neighbor1 neighbor2....) into two arrays:
! smoothing_pointers(nsmooth,3): ifault nneighbors index_in_neighbor_array
! smoothing_neighbors(nneighbors): single column array with neighbors only
if (.not.fileExists(smoothing_file)) then
call usage('read_inputs: no smoothing file found named '//trim(smoothing_file)// &
'(usage:lsqr)')
endif
nsmooth = line_count(smoothing_file)
if (nsmooth.gt.fault%nrows) then
call usage('read_inputs: number of faults to smooth is larger than total number of '// &
'faults (usage:none)')
endif
! Read smoothing file and calculate pointers to neighbor array
allocate(smoothing_pointers(nsmooth,3),stat=ierr)
if (ierr.ne.0) then
call usage('read_inputs: error allocating memory to smoothing_pointers (usage:none)')
endif
open(unit=34,file=smoothing_file,status='old')
do i = 1,nsmooth
read(34,*) (smoothing_pointers(i,j),j=1,2)
enddo
! Calculate the index of the location of each fault's neighbors in smoothing_neighbor array
do i = 1,nsmooth
if (i.eq.1) then
smoothing_pointers(i,3) = 1
else
smoothing_pointers(i,3) = smoothing_pointers(i-1,3) + smoothing_pointers(i-1,2)
endif
enddo
! Read smoothing file again and this time store neighbors in array
allocate(smoothing_neighbors(smoothing_pointers(nsmooth,3)+smoothing_pointers(nsmooth,2)),&
stat=ierr)
if (ierr.ne.0) then
call usage('read_inputs: error allocating memory to smoothing_neighbors (usage:none)')
endif
rewind(34)
do i = 1,nsmooth
read(34,'(A)') line
nn = smoothing_pointers(i,2)
ii = smoothing_pointers(i,3)
read(line,*,iostat=ios) j,j,(smoothing_neighbors(ii+j-1),j=1,nn)
if (ios.ne.0) then
write(stderr,*) 'read_inputs: error parsing smoothing file line ',i
write(stderr,*) 'Offending line: ',trim(line)
call usage('Expected format: iflt nnbr nbr1 nbr2...nbrn (usage:none)')
endif
enddo
close(34)
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: finished reading smoothing file "',trim(smoothing_file),'"'
endif
if (verbosity.ge.3) then
write(stdout,*) 'Number of faults to smooth: ',nsmooth
write(stdout,*) 'Smoothing pointer and neighbor arrays:'
do i = 1,nsmooth
write(stdout,*) (smoothing_pointers(i,j),j=1,3)
do j = 1+smoothing_pointers(i,3),smoothing_pointers(i,2)+smoothing_pointers(i,3)
write(stdout,*) smoothing_neighbors(j)
enddo
enddo
endif
if (verbosity.ge.2) then
write(stdout,*)
endif
endif
! Read half-space data or use default values (to calculate Green's functions)
if (gf_model.eq.'okada_rect'.or.gf_model.eq.'okada_pt'.or.gf_model.eq.'triangle') then
poisson = 0.25d0
lame = 40.0d9
shearmod = 40.0d9
if (halfspace_file.ne.'none') then
call read_halfspace_file(halfspace_file,poisson,shearmod,lame,ierr)
if (ierr.ne.0) then
call usage('')
endif
endif
if (verbosity.ge.2) then
write(stdout,*) 'Poissons ratio: ',poisson
write(stdout,*) 'Shear modulus: ',shearmod
write(stdout,*) 'Lames parameter: ',lame
endif
endif
! Covariance of three-component and/or line-of-sight observations
if (displacement%file.ne.'none'.or.los%file.ne.'none') then
! Covariance matrix has nrows and ncols equal to total displacement degrees of freedom
ndisp_dof = len_trim(disp_components)*displacement%nrows
nlos_dof = los%nrows
ndof = ndisp_dof + nlos_dof
allocate(cov_matrix(ndof,ndof),stat=ierr)
if (ierr.ne.0) then
call usage('read_inputs: error allocating memory to cov_matrix (usage:none)')
endif
! Initialize covariance matrix as the identity matrix
cov_matrix = 0.0d0
do i = 1,ndisp_dof+nlos_dof
cov_matrix(i,i) = 1.0d0
enddo
! Read in the covariance values
isErrorMessagePrinted = .false.
if (cov_file.ne.'none') then
open(unit=72,file=cov_file,status='old')
do
read(72,'(A)',iostat=ios) line
if (ios.ne.0) then
exit
endif
! Covariance file format: i_obs j_obs i_comp j_comp cov
! i_obs j_obs: indices corresponding to three-component or LOS displacement file
! i_comp j_comp: the displacement component (1, 2, or 3) or line-of-sight (L)
! cov: the covariance (m^2)
read(line,*,iostat=ios) i,j,nchar,mchar,cov
if (ios.ne.0) then
write(stderr,*) 'read_inputs: error parsing covariance matrix file'
write(stderr,*) 'Offending line: ',trim(line)
call usage('Expected format: i_obs j_obs i_comp j_comp cov (usage:none)')
endif
if (nchar.eq.'L'.or.nchar.eq.'l') then
nn = ndisp_dof
mm = ndisp_dof
else
if (index(disp_components,nchar).le.0) then
if (.not.isErrorMessagePrinted) then
write(stderr,*) 'read_inputs: found a covariance input not used in inversion'
write(stderr,*) 'Line: ',trim(line)
write(stderr,*) 'First component (',nchar,') is not used in inversion'
write(stderr,*) 'It is not being loaded into the covariance matrix.'
isErrorMessagePrinted = .true.
endif
cycle
endif
if (index(disp_components,mchar).le.0) then
if (.not.isErrorMessagePrinted) then
write(stderr,*) 'read_inputs: found a covariance input not used in inversion'
write(stderr,*) 'Line: ',trim(line)
write(stderr,*) 'Second component (',mchar,') is not used in inversion'
write(stderr,*) 'It is not being loaded into the covariance matrix.'
isErrorMessagePrinted = .true.
endif
cycle
endif
nn = (index(disp_components,nchar)-1)*displacement%nrows
mm = (index(disp_components,mchar)-1)*displacement%nrows
endif
cov_matrix(i+nn,j+mm) = cov
cov_matrix(j+mm,i+nn) = cov
enddo
close(72)
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: finished reading covariance file "',trim(cov_file),'"'
endif
else
if (verbosity.ge.2) then
write(stdout,*) 'read_inputs: data covariance matrix is identity matrix'
endif
endif
! If covariance matrix is diagonal, then only store diagonal elements
! Check if matrix is diagonal
isCovMatrixDiagonal = .true.
do i = 1,ndof
do j = 1,ndof
! If off-diagonal term is non-zero, set flag to false and exit
if (i.ne.j) then
if (abs(cov_matrix(i,j)).gt.1.0d-10) then
isCovMatrixDiagonal = .false.
exit
endif
endif
enddo
enddo
! If diagonal, resize covariance array
if (isCovMatrixDiagonal) then
! Store covariance matrix in a temporary array of length ndof
allocate(cov_matrix_temp(ndof))
do i = 1,ndof
cov_matrix_temp(i) = cov_matrix(i,i)
enddo
! Re-size the matrix
deallocate(cov_matrix)
allocate(cov_matrix(ndof,1))
! Update the covariance matrix with stored values and get rid of the temporary array
cov_matrix(:,1) = cov_matrix_temp
deallocate(cov_matrix_temp)
if (verbosity.ge.1) then
write(stdout,*) 'read_inputs: covariance matrix is diagonal'
endif
else
if (verbosity.ge.1) then
write(stdout,*) 'read_inputs: covariance matrix is not diagonal'
endif
endif
if (verbosity.ge.3) then
write(stdout,*) 'Covariance matrix:'
do i = 1,ndof
write(stdout,*) cov_matrix(i,:)
enddo
endif
endif
if (verbosity.ge.1) then
write(stdout,*) 'read_inputs: finished'
write(stdout,*)
endif
return
end subroutine read_inputs
!--------------------------------------------------------------------------------------------------!
!--------------------------------------------------------------------------------------------------!
!--------------------------------------- FLTINV OUTPUTS -------------------------------------------!
!--------------------------------------------------------------------------------------------------!
!--------------------------------------------------------------------------------------------------!
subroutine write_solution()
use trig, only: d2r
use io, only: stdout, stderr, verbosity
use earth, only: pole_xyz2geo
use misfit, only: misfit_rms
use fltinv, only: output_file, &
inversion_mode, &
fault, &
rake_constraint, &
euler_file, &
euler_output_file, &
npoles, &
displacement, &
disp_components, &
disp_misfit_file, &
gf_disp, &
fault_slip, &
euler_pole
implicit none
! Local variables
integer :: i, ierr, ounit, icmp, idsp, iflt, ndsp, nflt, nobs
double precision :: slip_mag, rms, geo_pole(3)
double precision, allocatable :: pre(:), obs(:)
if (verbosity.ge.1) then
write(stdout,*) 'write_solution: starting'
endif
! Print RMS misfit to three-component displacements
if (disp_misfit_file.ne.'none') then
! Open misfit file
open(unit=81,file=disp_misfit_file,status='unknown')
ndsp = displacement%nrows
nobs = len_trim(disp_components)*displacement%nrows
nflt = fault%nrows
! Load predicted three-component displacements
if (.not.allocated(pre)) then
allocate(pre(ndsp*len_trim(disp_components)),stat=ierr)
if (ierr.ne.0) then
call usage('write_solution: error allocating memory to pre array (usage:none)')
endif
endif
pre = 0.0d0
do i = 1,len_trim(disp_components)
read(disp_components(i:i),*) icmp
do idsp = 1,ndsp
do iflt = 1,nflt
pre((i-1)*ndsp+idsp) = pre((i-1)*ndsp+idsp) + &
gf_disp%array((icmp-1)*ndsp+idsp, iflt)*fault_slip(iflt,1)
pre((i-1)*ndsp+idsp) = pre((i-1)*ndsp+idsp) + &
gf_disp%array((icmp-1)*ndsp+idsp,nflt+iflt)*fault_slip(iflt,2)
enddo
enddo
enddo
! Load observed three-component displacements
if (.not.allocated(obs)) then
allocate(obs(nobs),stat=ierr)
if (ierr.ne.0) then
call usage('write_solution: error allocating memory to obs array (usage:none)')
endif
endif
obs = 0.0d0
do i = 1,len_trim(disp_components)
read(disp_components(i:i),*) icmp
obs((i-1)*ndsp+1:i*ndsp) = displacement%array(1:ndsp,3+icmp)
enddo
call misfit_rms(obs,pre,nobs,rms)
write(81,*) rms
close(81)
endif
! ! Line-of-sight RMS misfit
! if (los_misfit_file.ne.'none') then
! if (verbosity.ge.1) then
! write(stderr,'(A)') 'write_solution says: writing LOS RMS misfit to '//trim(los_misfit_file)
! endif
!
! write(0,*) 'write_solution: opening misfit file'
! open(unit=81,file=los_misfit_file,status='unknown')
!
! ! If rake is constrained, make an array of the correct size to use with misfit function
! if (inversion_mode.eq.'lsqr'.and.rake_constraint%file.ne.'none' &
! .and.rake_constraint%nfields.eq.1) then
! do i = 1,fault%nrecords
! tmp_slip_array(i,1) = fault_slip(i,1) ! Green's functions already calculated for this rake
! tmp_slip_array(i,2) = 0.0d0
! enddo
! write(81,*) los_misfit_l2norm(tmp_slip_array)/dsqrt(dble(fault%nrecords))
!
! ! Otherwise, just use the misfit function directly
! else
! write(81,*) los_misfit_l2norm(fault_slip)/dsqrt(dble(fault%nrecords))
! endif
!
! write(0,*) 'write_solution: closing misfit file'
! close(81)
! endif
! Print fault slip solution
if (fault%file.ne.'none') then
if (verbosity.ge.1) then
write(stdout,*) 'write_solution: writing slip solution to '//trim(output_file)
endif
if (output_file.eq.'stdout') then
ounit = stdout
else
ounit = 99
open (unit=ounit,file=output_file,status='unknown')
endif
do i = 1,fault%nrows
slip_mag = dsqrt(fault_slip(i,1)*fault_slip(i,1)+fault_slip(i,2)*fault_slip(i,2))
if (inversion_mode.eq.'lsqr') then
if (rake_constraint%ncols.eq.1) then
write(ounit,5001) fault_slip(i,1)*cos(rake_constraint%array(i,1)*d2r), &
fault_slip(i,1)*sin(rake_constraint%array(i,1)*d2r)
elseif (rake_constraint%file.ne.'none') then
write(ounit,5001) fault_slip(i,1)*cos(rake_constraint%array(i,1)*d2r) + &
fault_slip(i,2)*cos(rake_constraint%array(i,2)*d2r), &
fault_slip(i,1)*sin(rake_constraint%array(i,1)*d2r) + &
fault_slip(i,2)*sin(rake_constraint%array(i,2)*d2r)
else
write(ounit,5001) fault_slip(i,1:2)
endif
elseif (inversion_mode.eq.'anneal') then
write(ounit,5001) fault_slip(i,1:2)
elseif (inversion_mode.eq.'anneal-psc') then
write(ounit,5001) fault_slip(i,1:2)
else
write(stderr,*) 'write_solution: frankly, I do not know how you got this far using an '//&
'inversion mode that does not seem to exist...'
write(stderr,*) 'Available inversion modes:'
write(stderr,*) ' lsqr'
write(stderr,*) ' anneal'
call usage( ' anneal-psc (usage:general)')
endif
enddo
5001 format(1P2E16.8)
close(ounit)
endif
! Print rigid body rotation solution
if (euler_file.ne.'none') then
if (verbosity.ge.1) then
write(stdout,*) 'write_solution: writing Euler pole solution to '//trim(euler_output_file)
endif
if (euler_output_file.eq.'stdout') then
ounit = stdout
else
ounit = 99
open (unit=ounit,file=euler_output_file,status='unknown')
endif
do i = 1,npoles
call pole_xyz2geo(euler_pole(i,1),euler_pole(i,2),euler_pole(i,3), &
geo_pole(1),geo_pole(2),geo_pole(3), 'sphere')
write(ounit,5002) geo_pole(1:3)
enddo
5002 format(3F16.4)
close(ounit)
endif
if (verbosity.ge.1) then
write(stdout,*) 'write_solution: finished'
endif
return
end subroutine write_solution
!--------------------------------------------------------------------------------------------------!
!--------------------------------------------------------------------------------------------------!
!----------------------------------- PARSE COMMAND LINE -------------------------------------------!
!--------------------------------------------------------------------------------------------------!
!--------------------------------------------------------------------------------------------------!
subroutine gcmdln()
use io, only: stdout, verbosity, debug
use fltinv, only: output_file, &
inversion_mode, &
fault, &
slip_constraint, &
rake_constraint, &
euler_file, &
euler_output_file, &
displacement, &
disp_components, &
disp_misfit_file, &
input_disp_unit, &
los, &
prestress, &
cov_file, &
gf_model, &
gf_disp, &
gf_los, &
gf_stress, &
coord_type, &
halfspace_file, &
damping_constant, &
smoothing_constant, &
smoothing_file, &
lsqr_mode, &
anneal_init_mode, &
anneal_init_file, &
anneal_step_file, &
max_iteration, &
reset_iteration, &
temp_start, &
temp_minimum, &
cooling_factor, &
anneal_log_file, &
anneal_seed, &
modelUncertainty, &
min_flip, &
max_flip, &
init_fltinv_data
implicit none
! Local variables
integer :: i, narg, ios
character(len=256) :: tag
! integer :: char_index
! Initialize variables
output_file = ''
inversion_mode = ''
call init_fltinv_data(fault)
call init_fltinv_data(slip_constraint)
call init_fltinv_data(rake_constraint)
euler_file = 'none'
euler_output_file = ''
call init_fltinv_data(displacement)
disp_components = '123'
call init_fltinv_data(los)
call init_fltinv_data(prestress)
cov_file = 'none'
input_disp_unit = 'm'
gf_model = 'none'
call init_fltinv_data(gf_disp)
call init_fltinv_data(gf_los)
call init_fltinv_data(gf_stress)
coord_type = ''
halfspace_file = 'none'
damping_constant = -1.0d0
smoothing_constant = -1.0d0
smoothing_file = 'none'
lsqr_mode = 'gels'
anneal_init_mode = ''
anneal_init_file = 'none'
anneal_step_file = 'none'
max_iteration = 1000
reset_iteration = 1000000
temp_start = 2.0d0
temp_minimum = 0.00d0
cooling_factor = 0.98d0
anneal_log_file = ''
anneal_seed = 0
modelUncertainty = .false.
min_flip = 1
max_flip = 10
! pl2u = 0.01d0
! pu2l = 0.01d0
verbosity = 0
debug = .false.
disp_misfit_file = 'none'
! los_misfit_file = 'none'
!
! stress_weight = 1.0d-9
! los_weight = 1.0d0
! sts_dist = 1.0d10
! prob_lock2unlock = 0.25d0
! prob_unlock2lock = 0.10d0
! mcmc_iteration = 0
! mcmc_log_file = 'none'
narg = command_argument_count()
if (narg.eq.0) then
call usage('')
endif
i = 1
do while (i.le.narg)
call get_command_argument(i,tag)
! General options
if (trim(tag).eq.'-o') then
i = i + 1
call get_command_argument(i,output_file)
elseif (trim(tag).eq.'-mode') then
i = i + 1
call get_command_argument(i,inversion_mode)
! if (trim(inversion_mode).eq.'anneal-psc') then
! anneal_init_mode = 'unlocked'
! endif
! Fault options
elseif (trim(tag).eq.'-flt') then
i = i + 1
call get_command_argument(i,fault%file)
elseif (trim(tag).eq.'-flt:slip'.or.trim(tag).eq.'-flt:slip_constraint') then
i = i + 1
call get_command_argument(i,slip_constraint%file)
elseif (trim(tag).eq.'-flt:rake'.or.trim(tag).eq.'-flt:rake_constraint') then
i = i + 1
call get_command_argument(i,rake_constraint%file)
! Euler setup file
elseif (trim(tag).eq.'-euler') then
i = i + 1
call get_command_argument(i,euler_file)
i = i + 1
call get_command_argument(i,euler_output_file)
! Input options
elseif (trim(tag).eq.'-disp') then
i = i + 1
call get_command_argument(i,displacement%file)
elseif (trim(tag).eq.'-disp:components') then
i = i + 1
call get_command_argument(i,disp_components)
elseif (trim(tag).eq.'-los') then
i = i + 1
call get_command_argument(i,los%file)
elseif (trim(tag).eq.'-prests'.or.tag.eq.'-prestress') then
i = i + 1
call get_command_argument(i,prestress%file)
elseif (trim(tag).eq.'-cov') then
i = i + 1
call get_command_argument(i,cov_file)
elseif (trim(tag).eq.'-disp:unit') then
i = i + 1
call get_command_argument(i,input_disp_unit)
! elseif (trim(tag).eq.'-los:weight') then
! i = i + 1
! call get_command_argument(i,tag)
! read(tag,*) los_weight
! elseif (trim(tag).eq.'-los:misfit') then
! i = i + 1
! call get_command_argument(i,los_misfit_file)
! elseif (trim(tag).eq.'-prests:weight') then
! i = i + 1
! call get_command_argument(i,tag)
! read(tag,*) stress_weight
! elseif (trim(tag).eq.'-prests:dist_threshold') then
! i = i + 1
! call get_command_argument(i,tag)
! read(tag,*) sts_dist
! Output options
elseif (trim(tag).eq.'-disp:misfit') then
i = i + 1
call get_command_argument(i,disp_misfit_file)
! Green's functions options
elseif (trim(tag).eq.'-gf:model') then
i = i + 1
call get_command_argument(i,gf_model)
elseif (trim(tag).eq.'-gf:disp') then
i = i + 1
call get_command_argument(i,gf_disp%file)
elseif (trim(tag).eq.'-gf:los') then
i = i + 1
call get_command_argument(i,gf_los%file)
elseif (trim(tag).eq.'-gf:stress') then
i = i + 1
call get_command_argument(i,gf_stress%file)
elseif (trim(tag).eq.'-xy'.or.trim(tag).eq.'-cartesian') then
coord_type = 'cartesian'
elseif (trim(tag).eq.'-geo'.or.trim(tag).eq.'-geographic') then
coord_type = 'geographic'
! Half-space options
elseif (trim(tag).eq.'-haf') then
i = i + 1
call get_command_argument(i,halfspace_file)
! Regularization options
elseif (trim(tag).eq.'-damp') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) damping_constant
elseif (trim(tag).eq.'-smooth') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) smoothing_constant
i = i + 1
call get_command_argument(i,smoothing_file)
! Least squares options
elseif (trim(tag).eq.'-lsqr:mode') then
i = i + 1
call get_command_argument(i,lsqr_mode)
! Simulated annealing options
elseif (trim(tag).eq.'-anneal:init_mode') then
i = i + 1
call get_command_argument(i,anneal_init_mode)
if (trim(anneal_init_mode).eq.'user') then
i = i + 1
call get_command_argument(i,anneal_init_file)
endif
elseif (trim(tag).eq.'-anneal:step') then
i = i + 1
call get_command_argument(i,anneal_step_file)
elseif (trim(tag).eq.'-anneal:max_it') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) max_iteration
elseif (trim(tag).eq.'-anneal:reset_it') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) reset_iteration
elseif (trim(tag).eq.'-anneal:temp_start') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) temp_start
elseif (trim(tag).eq.'-anneal:temp_min') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) temp_minimum
elseif (trim(tag).eq.'-anneal:cool') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) cooling_factor
elseif (trim(tag).eq.'-anneal:log_file') then
i = i + 1
call get_command_argument(i,anneal_log_file)
elseif (trim(tag).eq.'-anneal:seed') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) anneal_seed
elseif (tag.eq.'-anneal:model_uncertainty') then
modelUncertainty = .true.
elseif (trim(tag).eq.'-anneal-psc:min_flip') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) min_flip
elseif (trim(tag).eq.'-anneal-psc:max_flip') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*) max_flip
! elseif (trim(tag).eq.'-anneal-psc:pl2u') then
! i = i + 1
! call get_command_argument(i,tag)
! read(tag,*) pl2u
! elseif (trim(tag).eq.'-anneal-psc:pu2l') then
! i = i + 1
! call get_command_argument(i,tag)
! read(tag,*) pu2l
! elseif (trim(tag).eq.'-anneal:mcmc') then
! i = i + 1
! call get_command_argument(i,tag)
! read(tag,*) mcmc_iteration
! i = i + 1
! call get_command_argument(i,mcmc_log_file)
! elseif (trim(tag).eq.'-anneal:p_unlock2lock' .or. &
! trim(tag).eq.'-anneal:prob_unlock2lock') then
! i = i + 1
! call get_command_argument(i,tag)
! read(tag,*) prob_unlock2lock
! Miscellaneous options
elseif (trim(tag).eq.'-v') then
i = i + 1
call get_command_argument(i,tag)
read(tag,*,iostat=ios) verbosity
if (ios.ne.0) then
verbosity = 1
endif
elseif (trim(tag).eq.'-debug') then
debug = .true.
else
call usage('fltinv: No option '//trim(tag))
endif
i = i + 1
enddo
! Parsed command line values
if (verbosity.ge.2) then
write(stdout,'(" Parsed command line inputs")')
write(stdout,'(" output_file: ",A)') trim(output_file)
write(stdout,'(" inversion_mode: ",A)') trim(inversion_mode)
write(stdout,*)
write(stdout,'(" fault%file: ",A)') trim(fault%file)
write(stdout,'(" slip_constraint%file: ",A)') trim(slip_constraint%file)
write(stdout,'(" rake_constraint%file: ",A)') trim(rake_constraint%file)
write(stdout,*)
write(stdout,'(" euler_file: ",A)') trim(euler_file)
write(stdout,*)
write(stdout,'(" displacement%file: ",A)') trim(displacement%file)
write(stdout,'(" disp_components: ",A)') trim(disp_components)
write(stdout,'(" disp_misfit_file: ",A)') trim(disp_misfit_file)
write(stdout,'(" los%file: ",A)') trim(los%file)
write(stdout,'(" prestress%file: ",A)') trim(prestress%file)
write(stdout,'(" cov_file: ",A)') trim(cov_file)
write(stdout,'(" input_disp_unit: ",A)') trim(input_disp_unit)
write(stdout,*)
write(stdout,'(" gf_model: ",A)') trim(gf_model)
write(stdout,'(" gf_disp%file: ",A)') trim(gf_disp%file)
write(stdout,'(" gf_los%file: ",A)') trim(gf_los%file)
write(stdout,'(" gf_stress%file: ",A)') trim(gf_stress%file)
write(stdout,'(" coord_type: ",A)') trim(coord_type)
write(stdout,*)
write(stdout,'(" halfspace_file: ",A)') trim(halfspace_file)
write(stdout,*)
! write(stdout,'(" stress_weight: ",1PE14.6)') stress_weight
! write(stdout,'(" sts_dist: ",1PE14.6)') sts_dist
! write(stdout,'(" los_weight: ",1PE14.6)') los_weight
! write(stdout,'(" los_misfit_file: ",A)') trim(los_misfit_file)
! write(stdout,*)
write(stdout,'(" damping_constant: ",1PE14.6)') damping_constant
write(stdout,'(" smoothing_constant: ",1PE14.6)') smoothing_constant
write(stdout,'(" smoothing_file: ",A)') trim(smoothing_file)
write(stdout,*)
write(stdout,'(" lsqr_mode: ",A)') trim(lsqr_mode)
write(stdout,*)
write(stdout,'(" anneal_init_mode: ",A)') trim(anneal_init_mode)
write(stdout,'(" anneal_init_file: ",A)') trim(anneal_init_file)
write(stdout,'(" anneal_step_file: ",A)') trim(anneal_step_file)
write(stdout,'(" max_iteration: ",I14)') max_iteration
write(stdout,'(" reset_iteration: ",I14)') reset_iteration
write(stdout,'(" temp_start: ",1PE14.6)') temp_start
write(stdout,'(" temp_minimum: ",1PE14.6)') temp_minimum
write(stdout,'(" cooling_factor: ",1PE14.6)') cooling_factor
write(stdout,'(" anneal_log_file: ",A)') trim(anneal_log_file)
write(stdout,'(" anneal_seed: ",I14)') anneal_seed
write(stdout,'(" modelUncertainty: ",A)') modelUncertainty
write(stdout,'(" min_flip: ",I14)') min_flip
write(stdout,'(" max_flip: ",I14)') max_flip
! write(stdout,'(" pl2u: ",1PE14.6)') pl2u
! write(stdout,'(" pu2l: ",1PE14.6)') pu2l
! write(stdout,'(" mcmc_iteration: ",A)') mcmc_iteration
! write(stdout,'(" mcmc_log_file: ",A)') mcmc_log_file
! write(stdout,'(" anneal_verbosity: ",I14)') anneal_verbosity
write(stdout,*)
endif
return
end subroutine
!--------------------------------------------------------------------------------------------------!
subroutine usage(string)
use io, only: stderr
implicit none
character(len=*) :: string
character(len=8) :: info
integer :: i
info = 'all'
i = len_trim(string)+1
if (string.ne.'') then
if (index(string,'(usage:general)').ne.0) then
i = index(string,'(usage:general)')
info = 'general'
elseif (index(string,'(usage:fault)').ne.0) then
i = index(string,'(usage:fault)')
info = 'fault'
elseif (index(string,'(usage:euler)').ne.0) then
i = index(string,'(usage:euler)')
info = 'euler'
elseif (index(string,'(usage:input)').ne.0) then
i = index(string,'(usage:input)')
info = 'input'
elseif (index(string,'(usage:output)').ne.0) then
i = index(string,'(usage:output)')
info = 'output'
elseif (index(string,'(usage:gf)').ne.0) then
i = index(string,'(usage:gf)')
info = 'gf'
elseif (index(string,'(usage:hafspc)').ne.0) then
i = index(string,'(usage:hafspc)')
info = 'hafspc'
elseif (index(string,'(usage:lsqr)').ne.0) then
i = index(string,'(usage:lsqr)')
info = 'lsqr'
elseif (index(string,'(usage:anneal)').ne.0) then
i = index(string,'(usage:anneal)')
info = 'anneal'
elseif (index(string,'(usage:none)').ne.0) then
i = index(string,'(usage:none)')
info = 'none'
endif
write(stderr,*) string(1:i-1)
write(stderr,*)
if (info.eq.'none') then
write(stderr,*) 'See fltinv man page for details'
write(stderr,*)
call error_exit(1)
endif
endif
write(stderr,*) 'Usage: fltinv ...options...'
write(stderr,*)
if (info.eq.'all'.or.info.eq.'general') then
write(stderr,*) 'General Options'
write(stderr,*) '-o OUTPUT_FILE Output fault slip file'
write(stderr,*) '-mode INVERSION_MODE Inversion mode'
write(stderr,*)
endif
if (info.eq.'all'.or.info.eq.'fault') then
write(stderr,*) 'Fault Options'
write(stderr,*) '-flt FAULT_FILE Input fault locations and geometries'
write(stderr,*) '-flt:slip SLIP_FILE Slip magnitude constraints'
write(stderr,*) '-flt:rake RAKE_FILE Rake angle constraints'
write(stderr,*)
endif
if (info.eq.'all'.or.info.eq.'euler') then
write(stderr,*) 'Euler Pole Options'
write(stderr,*) '-euler EULER_FILE POLE_FILE Include rigid rotation in the fit [UNDER DEVELOPMENT]'
write(stderr,*)
endif
if (info.eq.'all'.or.info.eq.'input') then
write(stderr,*) 'Input Options'
write(stderr,*) '-disp DISP_FILE Input displacements'
write(stderr,*) '-disp:components COMPNTS Specify displacement components'
write(stderr,*) '-los LOS_FILE Input line-of-sight displacements'
write(stderr,*) '-prests PRESTS_FILE Input pre-stresses'
write(stderr,*) '-cov COVAR_FILE Displacement and LOS covariances'
write(stderr,*) '-disp:unit UNITS Units for displacement (or to specify velocity inputs)'
! write(stderr,*) '-prests:weight WEIGHT Stress weighting factor'
! write(stderr,*) '-prests:dist_threshold DIST Set tractions to zero at distances>DIST'
! write(stderr,*) '-los:misfit MISFIT_FILE Output RMS misfit to LOS displacements'
write(stderr,*) '-xy Treat input coordinates as Cartesian'
write(stderr,*) '-geo Treat input coordinates as geographic'
write(stderr,*)
endif
if (info.eq.'all'.or.info.eq.'output') then
write(stderr,*) 'Output Options'
write(stderr,*) '-disp:misfit MISFIT_FILE Output RMS misfit to displacements'
write(stderr,*)
endif
if (info.eq.'all'.or.info.eq.'gf') then
write(stderr,*) 'Greens Functions Options'
write(stderr,*) '-gf:model MODEL Greens functions calculation model'
write(stderr,*) '-gf:disp GF_DSP_FILE Pre-computed displacement Greens functions'
write(stderr,*) '-gf:los GF_LOS_FILE Pre-computed LOS displacement Greens functions'
write(stderr,*) '-gf:sts GF_STS_FILE Pre-computed stress Greens functions'
write(stderr,*)
endif
if (info.eq.'all'.or.info.eq.'hafspc') then
write(stderr,*) 'Half-space Options'
write(stderr,*) '-haf HALFSPACE_FILE Elastic half-space parameters'
write(stderr,*)
endif
if (info.eq.'all'.or.info.eq.'lsqr') then
write(stderr,*) 'Regularization Options'
write(stderr,*) '-damp DAMP Damping regularization'
write(stderr,*) '-smooth SMOOTH SMOOTH_FILE Smoothing regularization'
write(stderr,*)
write(stderr,*) 'Least-Squares Options'
write(stderr,*) '-lsqr:mode MODE Solver algorithm'
write(stderr,*)
endif
if (info.eq.'all'.or.info.eq.'anneal') then
write(stderr,*) 'Simulated Annealing Options'
write(stderr,*) '-anneal:init_mode OPT [FILE] Mode to initialize solution'
write(stderr,*) '-anneal:step STEP_FILE Parameter step size'
write(stderr,*) '-anneal:max_it N Number of iterations in search'
write(stderr,*) '-anneal:reset_it N Reset temperature every N iterations'
write(stderr,*) '-anneal:temp_start T0 Starting temperature'
write(stderr,*) '-anneal:temp_min TMIN Minimum temperature'
write(stderr,*) '-anneal:cool COOL_FACT Cooling factor'
write(stderr,*) '-anneal:log_file LOG_FILE File with annealing progress'
write(stderr,*) '-anneal:seed SEED Random number generator seed'
write(stderr,*) '-anneal:model_uncertainty Search for model uncertainty'
write(stderr,*) '-anneal-psc:min_flip N Minimum number of faults to flip'
write(stderr,*) '-anneal-psc:max_flip N Maximum number of faults to flip'
write(stderr,*)
endif
write(stderr,*) 'Miscellaneous Options'
write(stderr,*) '-v LEVEL Program verbosity'
write(stderr,*)
if (info.ne.'all') then
write(stderr,*) 'Type "fltinv" without any arguments to see all options'
write(stderr,*)
endif
write(stderr,*) 'See man page for details'
write(stderr,*)
call error_exit(1)
end subroutine usage
| src/fltinv_io.f90 |
! File VersionID:
! $Id: irrigation.for 176 2010-03-13 11:36:14Z kroes006 $
! ----------------------------------------------------------------------
subroutine irrigation(task)
! ----------------------------------------------------------------------
! Date : November 2004
! Purpose : evaluate and schedule irrigations
! ----------------------------------------------------------------------
! -- global variables
use variables
implicit none
! -- local variables
integer irr,node,nodsen,task,tcs,tcsfix,dcslim,dcs
integer ifnd,i,datea(6),getun2,dayfix,irgdayfix
integer endirr(2),startirr(2)
integer yearendcrp, yearstacrp
real*8 frlow,phlo,phhi,phme,awlh,awmh,awah,cdef
real*8 wclo,wcme,wchi,wcac,tps1,tps2,tps3,tps4,tps5,depl,phcrit
real*8 watcon,prhead,dps1,dps2,afgen,Tred
real*8 dvstage(7),trel(7),raw(7),taw(7),dwa(7),hcri(7),tcri(7)
real*8 di(7),fid(7),irgdepmax,irgdepmin,irgthreshold
real*4 fsec
real*8 tstairryrx,tendirryrx, grai_red
logical flIrriTime
logical rdinqr
character filnam*80, messag*200
! save local variables
save
! dcs(1) = Amount of under- or over-irrigation (L) in case of a scheduled irrigation event
! dcs(2) = Prescribed fixed irrigation depth (L) for each scheduled irrigation event
! ----------------------------------------------------------------------
goto (1000,2000) task
1000 continue
! == = initialization calculated irrigation ============================
dayfix = 1
if (schedule .eq. 1) then
! --- open crop file
filnam = trim(pathcrop)//trim(cropfil(icrop))//'.crp'
irr = getun2 (10,90,2)
call rdinit(irr,logf,filnam)
! --- no scheduled irrigation before this date
call rdfinr('startirr',1,31,startirr,2,2)
call rdfinr('endirr',1,31,endirr,2,2)
datea(1) = 1900
datea(2) = startirr(2)
datea(3) = startirr(1)
fsec = 0.0
call dtardp (datea, fsec, tstairrig)
datea(2) = endirr(2)
datea(3) = endirr(1)
call dtardp (datea, fsec, tendirrig)
! --- application method
call rdsinr ('isuas',0,1,isuas)
! --- solute concentration irrigation water
call rdsdor ('cirrs',0.0d0,100.0d0,cirrs)
! --- timing criteria
call rdsinr ('tcs',1,6,tcs)
! -1- timing - allowable daily stress
! minimum of ratio actual/potential transpiration
if (tcs.eq.1) then
call rdador('dvs_tc1',0.0d0,2.0d0,dvstage,7,ifnd)
call rdfdor('trel',0.0d0,1.0d0,trel,7,ifnd)
do i = 1, ifnd
treltab(i*2) = trel(i)
treltab(i*2-1) = dvstage(i)
end do
endif
! -2- timing - depletion of readily available water
! minimum fraction of readily available water
if (tcs.eq.2) then
call rdador('dvs_tc2',0.0d0,2.0d0,dvstage,7,ifnd)
call rdfdor('raw',0.0d0,1.0d0,raw,7,ifnd)
do i = 1, ifnd
rawtab(i*2) = raw(i)
rawtab(i*2-1) = dvstage(i)
end do
endif
! -3- timing - depletion of totally available water
! minimum fraction of totally available water
if (tcs.eq.3) then
call rdador('dvs_tc3',0.0d0,2.0d0,dvstage,7,ifnd)
call rdfdor('taw',0.0d0,1.0d0,taw,7,ifnd)
do i = 1, ifnd
tawtab(i*2) = taw(i)
tawtab(i*2-1) = dvstage(i)
end do
endif
! -4- timing - allowable depletion amount
! maximum amount of water (L) depleted below field capacity
if (tcs.eq.4) then
call rdador('dvs_tc4',0.0d0,2.0d0,dvstage,7,ifnd)
call rdfdor('dwa',0.0d0,500.0d0,dwa,7,ifnd)
do i = 1, ifnd
dwatab(i*2) = dwa(i)
dwatab(i*2-1) = dvstage(i)
end do
endif
! -5- timing - critical press. head or moist. content at sensor depth
! minimum pressure head or water content
if (tcs.eq.5) then
call rdsinr ('phormc',0,1,phormc)
call rdsdor ('dcrit',-100.0d0,0.0d0,dcrit)
call rdador('dvs_tc5',0.0d0,2.0d0,dvstage,7,ifnd)
if (phormc.eq.0) then
call rdfdor('value_tc5',-1.0d6,100.0d0,hcri,7,ifnd)
do i = 1, ifnd
hcritab(i*2) = hcri(i)
hcritab(i*2-1) = dvstage(i)
end do
else
call rdfdor('value_tc5',0.0d0,1.0d0,tcri,7,ifnd)
do i = 1, ifnd
tcritab(i*2) = tcri(i)
tcritab(i*2-1) = dvstage(i)
end do
endif
endif
! -6- Timing - fixed intervals, weekly with threshold (below it: no irrigation)
if (tcs.eq.6) then
call rdsdor ('irgthreshold',0.0d0,20.0d0,irgthreshold)
dayfix = 6
endif
! -7- Timing - fixed intervals
call rdsinr ('tcsfix',0,1,tcsfix)
if (tcsfix.eq.1) then
if (tcs.eq.6) then
messag = 'Timing criteria: conflict with fixed intervals'//
& ' tcsfix=1 AND tcs=1 not allowed, adapt input !'
call fatalerr ('Irrigation',messag)
endif
call rdsinr('irgdayfix',1,366,irgdayfix)
endif
! --- depth criteria
call rdsinr ('dcs',1,2,dcs)
! --- field capacity as input for timing and depth options
if (tcs.eq.2 .or. tcs.eq.3 .or. tcs.eq.4 .or. dcs.eq.1) then
call rdsdor('phFieldCapacity',-500.0d0,0.0d0,phlo)
else
phlo = -100.0d0
endif
! -1- depth - back to field capacity
if (dcs.eq.1) then
call rdador('dvs_dc1',0.0d0,2.0d0,dvstage,7,ifnd)
call rdfdor('di',-100.0d0,+100.0d0,di,7,ifnd)
raithreshold = 0.0d0
if(rdinqr('raithreshold')) then
call rdsdor('raithreshold',0.0d0,1000.0d0,raithreshold)
endif
do i = 1, ifnd
ditab(i*2) = di(i)
ditab(i*2-1) = dvstage(i)
end do
endif
! -2- depth - fixed depth
if (dcs.eq.2) then
call rdador('dvs_dc2',0.0d0,2.0d0,dvstage,7,ifnd)
call rdfdor('fid',0.0d0,400.0d0,fid,7,ifnd)
do i = 1, ifnd
fidtab(i*2) = fid(i)
fidtab(i*2-1) = dvstage(i)
end do
endif
! --- depth - limited by min and max
call rdsinr ('dcslim',0,1,dcslim)
if (dcslim.eq.1) then
call rdsdor('irgdepmin',0.0d0,100.0d0,irgdepmin)
call rdsdor('irgdepmax',irgdepmin,1.0d7,irgdepmax)
else
irgdepmin = 0.0d0
irgdepmax = 1.0d7
endif
! - close input file
close(irr)
endif
return
2000 continue
! == = determine irrigation rates and states =============================================
! --- reset intermediate soil water fluxes
if (flzerointr) then
igird = 0.0d0
inird = 0.0d0
endif
! --- reset cumulative soil water fluxes
if (flzerocumu) then
cgird = 0.0d0
cnird = 0.0d0
endif
gird = 0.0d0
irrigevent = 0
! --- fixed irrigations
if (swirfix .eq. 1) then
if (abs(irdate(nirri) - t1900) .lt. 1.d-3) then
gird = irdepth(nirri)
cirr = irconc(nirri)
isua = irtype(nirri)
nirri = nirri + 1
irrigevent = 1
endif
endif
! --- scheduling mode - current timing and depth criterion
! scheduled timing within desired period ?
if (schedule.eq.1) then
call dtdpar (cropstart(icrop),datea,fsec)
yearstacrp = datea(1)
call dtdpar (cropend(icrop),datea,fsec)
yearendcrp = datea(1)
flIrriTime = .false.
if (yearendcrp.gt.yearstacrp) then
datea(1) = yearstacrp
datea(2) = startirr(2)
datea(3) = startirr(1)
fsec = 0.0
call dtardp (datea, fsec, tstairryrx)
datea(1) = yearendcrp
datea(2) = endirr(2)
datea(3) = endirr(1)
call dtardp (datea, fsec, tendirryrx)
if ( (t1900-tstairryrx).gt.1.0d-3 .and.
& (t1900-tendirryrx).le.1.0d-3 ) then
flIrriTime = .true.
endif
else
if ((t-tstairrig).gt.1.0d-3.and.(t-tendirrig).le.1.0d-3) then
flIrriTime = .true.
endif
endif
endif
if (schedule.eq.1 .and. irrigevent.eq.0 .and.
& flCropGrowth .and. flIrriTime) then
cirr = cirrs
isua = isuas
! --- determine lowest compartment containing roots
i = 1
do while ((z(i) - dz(i)*0.5d0) .gt. (-rd + 1.d-8))
i = i + 1
end do
noddrz = i
frlow = (z(noddrz) + dz(noddrz)*0.5d0 + rd) / dz(noddrz)
! --- determine water holding capacity, readily available water,
! --- actual available water and water deficit
! phlo = -100.0d0 ! field capacity became input (from swap32(6)
phme = (hlim3l+hlim3h)/2.0d0
phhi = hlim4
awlh = 0.0d0
awmh = 0.0d0
awah = 0.0d0
cdef = 0.0d0
do node = 1,noddrz
wclo = watcon(node,phlo,cofgen(1,node),swsophy,numtab,sptab)
& * dz(node)
if (node.eq.noddrz) wclo = wclo*frlow
wcme = watcon(node,phme,cofgen(1,node),swsophy,numtab,sptab)
& * dz(node)
if (node.eq.noddrz) wcme = wcme*frlow
wchi = watcon(node,phhi,cofgen(1,node),swsophy,numtab,sptab)
& * dz(node)
if (node.eq.noddrz) wchi = wchi*frlow
wcac = watcon(node,h(node),cofgen(1,node),swsophy,
& numtab,sptab) * dz(node)
if (node.eq.noddrz) wcac = wcac*frlow
awlh = awlh+(wclo-wchi)
awmh = awmh+(wcme-wchi)
awah = awah+(wcac-wchi)
cdef = cdef+(wclo-wcac)
end do
! -1- timing - allowable daily stress - only under dry stress circumstances
if (tcs.eq.1) then
tps1 = afgen(treltab,14,dvs)
! --- transpiration fraction due to drought and salinity stress
if (qrosum .gt. 1.d-8) then
Tred = 1.0d0 - (qreddrysum+qredsolsum)/ptra
else
Tred = 1.0d0
endif
if (Tred .lt. tps1) irrigevent = 2
endif
! -2- timing - depletion of readily available water (fraction)
if (tcs.eq.2) then
! --- compare readily available water and actual available water
tps2 = afgen(rawtab,14,dvs)
depl = tps2*(awlh-awmh)
if (depl.gt.awlh) depl=awlh
if (awah .lt. (awlh-depl)) irrigevent = 2
endif
! -3- timing - depletion of totally available water (fraction)
if (tcs.eq.3) then
! --- compare totally available water and actual available water
tps3 = afgen(tawtab,14,dvs)
depl = tps3*awlh
if (awah.lt.(awlh-depl)) irrigevent = 2
endif
! -4- timing - allowable amount of depletion
if (tcs.eq.4) then
! --- check if depletion amount has been exceeded
tps4 = afgen(dwatab,14,dvs)
if ((awlh-awah).gt.(tps4/10.d0)) irrigevent = 2
endif
! -5- timing - critical pressure head or moisture content exceeded
if (tcs.eq.5) then
! --- determine compartment number of sensor depth
i = 1
do while (z(i) .gt. (dcrit + 1.d-5))
i = i+1
end do
nodsen = i
! --- calculation of critical pressure head
if (phormc.eq.0) then
tps5 = afgen(hcritab,14,dvs)
! PG/JK start 15-feb-2010
! originally not intended to simulate paddy rice fields,
! but made applicable for paddy by changing the statement:
phcrit = tps5 ! old statement was: phcrit = -abs(tps5)
! PG/JK end 15-feb-2010
elseif (phormc.eq.1) then
tps5 = afgen(tcritab,14,dvs)
phcrit = prhead(nodsen,disnod(nodsen),cofgen,tps5,h,
& swsophy,numtab,sptab)
endif
! --- compare critical pressure head and actual pressure head
if (h(nodsen).le.phcrit) irrigevent = 2
endif
! -6- Timing - fixed irrigation time (weekly during crop growth)
if (tcs.eq.6) then
! (weekly) irrigation only when deficit is higher then threshold
! cdef (cm) en IrgThreshold (mm)
dayfix = dayfix + 1
if (dayfix.eq.7) then
dayfix = 0
if (10.0*cdef.gt.irgthreshold) then
irrigevent = 2
endif
endif
endif
! -7- Timing - fixed intervals
if (tcsfix.eq.1) then
if(irrigevent.eq.2 .and. (dayfix .eq. irgdayfix)) then
irrigevent = 2
dayfix = 1
else
irrigevent = 0
if (dayfix .lt. irgdayfix) dayfix = dayfix + 1
endif
endif
! --- depth - back to field capacity [cm]
if ((irrigevent.eq.2).and.(dcs.eq.1)) then
! --- correct for over- or under irrigation
dps1 = afgen(ditab,14,dvs)
! PG/JK start 15-feb-2010
! option to reduce irrigation on rainy (> raithreshold) day
! raithreshold = ! threshold (cm/d) to define rainy days; used to reduce irrigation
grai_red = 0.0d0
if(grai .gt. raithreshold) grai_red = grai
gird = max (0.0d0,cdef+dps1/10.0d0-grai_red)
! PG/JK start 15-feb-2010
endif
! --- depth - fixed depth [cm]
if ((irrigevent.eq.2).and.(dcs.eq.2)) then
dps2 = afgen(fidtab,14,dvs)
gird = dps2/10.0d0
endif
! --- depth - limited depth [cm]
if ((irrigevent.eq.2).and.(dcslim.eq.1)) then
gird = max(gird,irgdepmin/10.0d0)
gird = min(gird,irgdepmax/10.0d0)
endif
endif
if (irrigevent .ne. 0) flIrrigationOutput = .true.
return
end
| code/irrigation.for |
module intgustmod
!$$$ module documentation block
! . . . .
! module: intgustmod module for intgust and its tangent linear intgust_tl
! prgmmr:
!
! abstract: module for intgust and its tangent linear intgust_tl
!
! program history log:
! 2012-09-14 Syed RH Rizvi, NCAR/NESL/MMM/DAS - implemented obs adjoint test
! 2016-05-18 guo - replaced ob_type with polymorphic obsNode through type casting
!
! subroutines included:
! sub intgust
!
! variable definitions:
!
! attributes:
! language: f90
! machine:
!
!$$$ end documentation block
use m_obsNode , only: obsNode
use m_gustNode, only: gustNode
use m_gustNode, only: gustNode_typecast
use m_gustNode, only: gustNode_nextcast
use m_obsdiagNode, only: obsdiagNode_set
implicit none
PRIVATE
PUBLIC intgust
contains
subroutine intgust(gusthead,rval,sval)
!$$$ subprogram documentation block
! . . . .
! subprogram: intgust apply nonlin qc obs operator for conv. gust
! prgmmr: zhu org: np23 date: 2011-02-20
!
! abstract: apply observation operator and adjoint for conventional gust
! observations with nonlinear qc operator
!
! program history log:
!
! 2012-09-14 Syed RH Rizvi, NCAR/NESL/MMM/DAS - introduced ladtest_obs
! 2014-12-03 derber - modify so that use of obsdiags can be turned off
!
! input argument list:
! gusthead
! sgust - increment in grid space
! rgust
!
! output argument list:
! rgust - results from observation operator (0 for no data)
!
! attributes:
! language: f90
! machine: ibm RS/6000 SP
!
!$$$
use kinds, only: r_kind,i_kind
use constants, only: half,one,tiny_r_kind,cg_term
use obsmod, only: lsaveobsens, l_do_adjoint,luse_obsdiag
use qcmod, only: nlnqc_iter,varqc_iter
use jfunc, only: jiter
use gsi_bundlemod, only: gsi_bundle
use gsi_bundlemod, only: gsi_bundlegetpointer
use gsi_4dvar, only: ladtest_obs
implicit none
! Declare passed variables
class(obsNode),pointer,intent(in ) :: gusthead
type(gsi_bundle), intent(in ) :: sval
type(gsi_bundle), intent(inout) :: rval
! Declare local variables
integer(i_kind) ier,istatus
integer(i_kind) j1,j2,j3,j4
! real(r_kind) penalty
real(r_kind) w1,w2,w3,w4
real(r_kind) val
real(r_kind) cg_gust,p0,grad,wnotgross,wgross,pg_gust
real(r_kind),pointer,dimension(:) :: sgust
real(r_kind),pointer,dimension(:) :: rgust
type(gustNode), pointer :: gustptr
! Retrieve pointers
! Simply return if any pointer not found
ier=0
call gsi_bundlegetpointer(sval,'gust',sgust,istatus);ier=istatus+ier
call gsi_bundlegetpointer(rval,'gust',rgust,istatus);ier=istatus+ier
if(ier/=0)return
!gustptr => gusthead
gustptr => gustNode_typecast(gusthead)
do while (associated(gustptr))
j1=gustptr%ij(1)
j2=gustptr%ij(2)
j3=gustptr%ij(3)
j4=gustptr%ij(4)
w1=gustptr%wij(1)
w2=gustptr%wij(2)
w3=gustptr%wij(3)
w4=gustptr%wij(4)
! Forward model
val=w1*sgust(j1)+w2*sgust(j2)&
+w3*sgust(j3)+w4*sgust(j4)
if(luse_obsdiag)then
if (lsaveobsens) then
grad = val*gustptr%raterr2*gustptr%err2
!-- gustptr%diags%obssen(jiter) = grad
call obsdiagNode_set(gustptr%diags,jiter=jiter,obssen=grad)
else
!-- if (gustptr%luse) gustptr%diags%tldepart(jiter)=val
if (gustptr%luse) call obsdiagNode_set(gustptr%diags,jiter=jiter,tldepart=val)
endif
endif
if (l_do_adjoint) then
if (.not. lsaveobsens) then
if(.not.ladtest_obs) val=val-gustptr%res
! gradient of nonlinear operator
if (nlnqc_iter .and. gustptr%pg > tiny_r_kind .and. &
gustptr%b > tiny_r_kind) then
pg_gust=gustptr%pg*varqc_iter
cg_gust=cg_term/gustptr%b
wnotgross= one-pg_gust
wgross = pg_gust*cg_gust/wnotgross
p0 = wgross/(wgross+exp(-half*gustptr%err2*val**2))
val = val*(one-p0)
endif
if( ladtest_obs) then
grad = val
else
grad = val*gustptr%raterr2*gustptr%err2
end if
endif
! Adjoint
rgust(j1)=rgust(j1)+w1*grad
rgust(j2)=rgust(j2)+w2*grad
rgust(j3)=rgust(j3)+w3*grad
rgust(j4)=rgust(j4)+w4*grad
endif
!gustptr => gustptr%llpoint
gustptr => gustNode_nextcast(gustptr)
end do
return
end subroutine intgust
end module intgustmod
| GEOSaana_GridComp/GSI_GridComp/intgust.f90 |
module ms_m_set
use MatrixSwitch_ops
implicit none
contains
!================================================!
! implementation: reference !
!================================================!
subroutine m_set_sddenref(C,seC,alpha,beta)
implicit none
!**** INPUT ***********************************!
character(1), intent(in) :: seC
real(dp), intent(in) :: alpha
real(dp), intent(in) :: beta
!**** INOUT ***********************************!
type(matrix), intent(inout) :: C
!**** INTERNAL ********************************!
integer :: luC
integer :: i, j
!**********************************************!
call process_seM(seC,luC)
if (luC==0) then
do i=1,C%dim1
do j=1,C%dim2
if (i/=j) then
C%dval(i,j)=alpha
else
C%dval(i,j)=beta
end if
end do
end do
else if (luC==1) then
do i=1,C%dim1
do j=i,C%dim2
if (i/=j) then
C%dval(i,j)=alpha
else
C%dval(i,j)=beta
end if
end do
end do
else if (luC==2) then
do i=1,C%dim1
do j=1,i
if (i/=j) then
C%dval(i,j)=alpha
else
C%dval(i,j)=beta
end if
end do
end do
end if
end subroutine m_set_sddenref
subroutine m_set_szdenref(C,seC,alpha,beta)
implicit none
!**** INPUT ***********************************!
character(1), intent(in) :: seC
complex(dp), intent(in) :: alpha
complex(dp), intent(in) :: beta
!**** INOUT ***********************************!
type(matrix), intent(inout) :: C
!**** INTERNAL ********************************!
integer :: luC
integer :: i, j
!**********************************************!
call process_seM(seC,luC)
if (luC==0) then
do i=1,C%dim1
do j=1,C%dim2
if (i/=j) then
C%zval(i,j)=alpha
else
C%zval(i,j)=beta
end if
end do
end do
else if (luC==1) then
do i=1,C%dim1
do j=i,C%dim2
if (i/=j) then
C%zval(i,j)=alpha
else
C%zval(i,j)=beta
end if
end do
end do
else if (luC==2) then
do i=1,C%dim1
do j=1,i
if (i/=j) then
C%zval(i,j)=alpha
else
C%zval(i,j)=beta
end if
end do
end do
end if
end subroutine m_set_szdenref
end module ms_m_set
| external/libOMM/src/MatrixSwitch/ms_m_set.f90 |
subroutine supf_bouope_4rd(a)
use typre
use Mod_Element
use Mod_SUPFractionalStep
use Mod_Element
use Mod_SUPF_Element
use Mod_nsm_elmdir
use Mod_php_elmdir
implicit none
class(SUPFractionalStepProblem) :: a
class(FiniteElement), pointer :: e => NULL()
integer(ip) :: nelem,nboun,inodb,jnodb,inode,jnode,iboun,igaub,idime
real(rp) :: acden,acvis,dsurf
integer(ip) :: nsteps
real(rp) :: LHSdtinv
real(rp), allocatable :: elmat(:,:,:,:)
real(rp), allocatable :: elrhs(:,:)
real(rp) :: dvol,gppre(1)
real(rp), allocatable :: bosig(:,:,:),gpsig(:),tract(:)
real(rp), allocatable :: bopre(:,:)
integer(ip) :: currentbvess,bcstar,auxtens
!todo multy materials
integer(ip) :: imat=1
!Initializations
call a%Mesh%GetNelem(nelem)
call a%Mesh%GetNboun(nboun)
!Memory allocation
call a%Mesh%ElementAlloc(e,a%Memor,'DefaultRule','supf_bouope_3rd')
auxtens=(e%ndime-1)*(e%ndime-1)+2
call a%Memor%alloc(e%ndime,e%mnode,e%ndime,e%mnode,elmat,'elmat','nsm_bouop0')
call a%Memor%alloc(e%ndime,e%mnode,elrhs,'elrhs','nsm_bouop0')
call a%Memor%alloc(auxtens,e%mnodb,1,bosig,'bopre','nsf_elmope_3rd')
call a%Memor%alloc(auxtens,gpsig,'gpsig','nsf_elmope_3rd')
call a%Memor%alloc(e%ndime,tract,'tract','nsf_elmope_3rd')
call a%Memor%alloc(e%mnodb,1,bopre,'bopre','nsf_elmope_3rd')
!Physical Parameters
call a%GetPhysicalParameters(imat,acden,acvis)
! Loop over boundaries
boundaries: do iboun=1,nboun
!Load Element
call a%Mesh%BoundaryLoad(iboun,e)
!Initialize
elmat=0.0_rp
elrhs=0.0_rp
!Gathers
call e%gatherb(auxtens,bosig,a%sigma(:,:,3))
call e%gatherb(1,bopre,a%press(:,3)) ! p_n
call e%elmdel
!Gauss-Point Loop
do igaub=1,e%pgaub
e%igaub = igaub
!Calculate exterior Normal
call e%bounor
!Derivatives at the boundary
call e%elmderb
dsurf=e%weigb(e%igaub)*e%eucta
!Open flow, integration by parts of (v,grad p) => (n*v,p)_Gamma
if (a%kfl_fixbo(iboun) == 14) then
call e%interpb(auxtens,gpsig,bosig)
call e%interpb(1,bopre,gppre)
if(e%ndime==2)then
tract(1) = e%baloc(1,e%ndime)*gpsig(1) + e%baloc(2,e%ndime)*gpsig(3)
tract(2) = e%baloc(1,e%ndime)*gpsig(3) + e%baloc(2,e%ndime)*gpsig(2)
elseif(e%ndime==3)then
tract(1) = e%baloc(1,e%ndime)*gpsig(1) + e%baloc(2,e%ndime)*gpsig(6) + e%baloc(3,e%ndime)*gpsig(5)
tract(2) = e%baloc(1,e%ndime)*gpsig(6) + e%baloc(2,e%ndime)*gpsig(2) + e%baloc(3,e%ndime)*gpsig(4)
tract(3) = e%baloc(1,e%ndime)*gpsig(5) + e%baloc(2,e%ndime)*gpsig(4) + e%baloc(3,e%ndime)*gpsig(3)
end if
else if (a%kfl_fixbo(iboun) == 15)then
if(e%ndime==2)then
tract(1) = -e%baloc(1,e%ndime)*gppre(1)
tract(2) = -e%baloc(2,e%ndime)*gppre(1)
elseif(e%ndime==3)then
tract(1) = -e%baloc(1,e%ndime)*gppre(1)
tract(2) = -e%baloc(2,e%ndime)*gppre(1)
tract(3) = -e%baloc(3,e%ndime)*gppre(1)
end if
endif
do inodb = 1,e%pnodb
inode = e%lboel(inodb)
do idime = 1,e%ndime
elrhs(idime,inode)=elrhs(idime,inode)+dsurf*(tract(idime)*e%shapb(inodb,e%igaub))
enddo
enddo
enddo
!Boundary conditions
call nsm_rotdir(a,e,e%ndime,elmat,elrhs)
! php_elmdir(a,e,ndofn,ndofbc,ndofbcstart,currentbvess,elmat,elrhs)
currentbvess=auxtens+1
bcstar=0_ip
call php_elmdir(a,e,e%ndime,e%ndime,bcstar,currentbvess,elmat,elrhs)
! Assembly
call a%LinearSystem%Assembly(e,elmat,elrhs)
end do boundaries
call a%Memor%dealloc(e%ndime,e%mnode,e%ndime,e%mnode,elmat,'elmat','nsm_bouop0')
call a%Memor%dealloc(e%ndime,e%mnode,elrhs,'elrhs','nsm_bouop0')
call a%Memor%dealloc(auxtens,e%mnodb,1,bosig,'bopre','nsf_elmope_3rd')
call a%Memor%dealloc(auxtens,gpsig,'gpsig','nsf_elmope_3rd')
call a%Memor%dealloc(e%ndime,tract,'tract','nsf_elmope_3rd')
call a%Memor%dealloc(e%mnodb,1,bopre,'bopre','nsf_elmope_3rd')
call a%Mesh%ElementDeAlloc(e,a%Memor,'DefaultRule','allocs')
end subroutine | Sources/modules/supFractionalStep/supf_bouope_4rd.f90 |
module convb_t
!$$$ module documentation block
! . . . .
! module: convb_t
! prgmmr: su org: np2 date: 2014-03-28
! abstract: This module contains variables and routines related
! to the assimilation of conventional observations b paramter to read
! temperature b table, the structure is different from current
! one, the first
!
! program history log:
! 2014-03-28 su - original code - move reading observation b table
! from read_prepbufr to here so all the
! processor can have the b information
!
! Subroutines Included:
! sub convb_t_read - allocate arrays for and read in conventional b table
! sub convb_t_destroy - destroy conventional b arrays
!
! Variable Definitions:
! def btabl_t - the array to hold the b table
! def bptabl_t - the array to have vertical pressure values
!
! attributes:
! language: f90
! machine: ibm RS/6000 SP
!
!$$$ end documentation block
use kinds, only:r_kind,i_kind,r_single
use constants, only: zero
use obsmod, only : bflag
implicit none
! set default as private
private
! set subroutines as public
public :: convb_t_read
public :: convb_t_destroy
! set passed variables as public
public :: btabl_t,bptabl_t,isuble_bt
integer(i_kind),save:: ibtabl_t,itypex,itypey,lcount,iflag,k,m,n
real(r_single),save,allocatable,dimension(:,:,:) :: btabl_t
real(r_kind),save,allocatable,dimension(:) :: bptabl_t
integer(i_kind),save,allocatable,dimension(:,:) :: isuble_bt
contains
subroutine convb_t_read(mype)
!$$$ subprogram documentation block
! . . . .
! subprogram: convb_t_read read b table
!
! prgmmr: su org: np2 date: 2014-03-28
!
! abstract: This routine reads the conventional b table file
!
! program history log:
! 2008-06-04 safford -- add subprogram doc block
! 2013-05-14 guo -- add status and iostat in open, to correctly
! handle the b case of "obs b table not
! available to 3dvar".
! 2015-03-06 yang -- add ld = 3000 for the size of nlqc_b table. Remove
! the hardwired value in the calculation of table array
! index.
! ld=300 is sufficient for current conventional
! observing systems.
!
! input argument list:
!
! output argument list:
!
! attributes:
! language: f90
! machine: ibm RS/6000 SP
!
!$$$ end documentation block
use constants, only: half
implicit none
integer(i_kind),parameter :: ld=300
integer(i_kind),intent(in ) :: mype
integer(i_kind):: ier
allocate(btabl_t(ld,33,6),isuble_bt(ld,5))
allocate(bptabl_t(34))
btabl_t=1.e9_r_kind
ibtabl_t=19
open(ibtabl_t,file='btable_t',form='formatted',status='old',iostat=ier)
if(ier/=0) then
write(6,*)'CONVB_T: ***WARNING*** obs b table ("btabl") not available to 3dvar.'
lcount=0
bflag=.false.
return
endif
rewind ibtabl_t
btabl_t=1.e9_r_kind
lcount=0
loopd : do
read(ibtabl_t,100,IOSTAT=iflag,end=120) itypey
if( iflag /= 0 ) exit loopd
100 format(1x,i3)
lcount=lcount+1
itypex=itypey
read(ibtabl_t,105,IOSTAT=iflag,end=120) (isuble_bt(itypex,n),n=1,5)
105 format(8x,5i12)
do k=1,33
read(ibtabl_t,110)(btabl_t(itypex,k,m),m=1,6)
110 format(1x,6e12.5)
end do
end do loopd
120 continue
if(lcount<=0 .and. mype==0) then
write(6,*)'CONVB_T: ***WARNING*** obs b table not available to 3dvar.'
bflag=.false.
else
! use the pressure values of last obs. type, itypex
if (itypex > 0 ) then
bptabl_t=zero
bptabl_t(1)=btabl_t(itypex,1,1)
do k=2,33
bptabl_t(k)=half*(btabl_t(itypex,k-1,1)+btabl_t(itypex,k,1))
enddo
bptabl_t(34)=btabl_t(itypex,33,1)
else
write(6,*)'ERROR IN CONVB_T: NO OBSERVATION TYPE READ IN'
return
endif
endif
close(ibtabl_t)
return
end subroutine convb_t_read
subroutine convb_t_destroy
!$$$ subprogram documentation block
! . . . .
! subprogram: convb_t_destroy destroy conventional information file
! prgmmr: su org: np2 date: 2007-03-15
!
! abstract: This routine destroys arrays from convb_t file
!
! program history log:
! 2007-03-15 su
!
! input argument list:
!
! output argument list:
!
! attributes:
! language: f90
! machine: ibm rs/6000 sp
!
!$$$
implicit none
deallocate(btabl_t,bptabl_t,isuble_bt)
return
end subroutine convb_t_destroy
end module convb_t
| GEOSaana_GridComp/GSI_GridComp/convb_t.f90 |
#include "scalar.fpp"
!=====================================================================!
! A class modeling rigid body dynamics.
!
! Author: Komahan Boopathy ([email protected])
!=====================================================================!
module rigidbody_dynamics_class
use constants , only : WP
use dynamic_physics_interface , only : dynamics
implicit none
private
public :: rigidbody
!-------------------------------------------------------------------!
! Type that implements rigidbody mass damper ODE
!-------------------------------------------------------------------!
type, extends(dynamics) :: rigidbody
! Define constants and other parameters needed for residual and
! jacobian assembly here
! Inertial properties of the rigidbody (assuming 3d space)
type(scalar) :: mass
type(scalar) :: first_moment_mass(3)
type(scalar) :: second_moment_mass(3,3)
! Initial conditions of the rigidbody (assuming 3d space)
type(scalar) :: position(3)
type(scalar) :: orientation(3)
type(scalar) :: linear_velocity(3)
type(scalar) :: angular_velocity(3)
contains
! Implement deferred procedures from superclasses
procedure :: add_residual
procedure :: add_jacobian
procedure :: get_initial_condition
! Destructor
final :: destruct
end type rigidbody
! Interface to construct rigidbody system
interface rigidbody
procedure construct
end interface rigidbody
contains
!===================================================================!
! Constructor for rigidbody system
!===================================================================!
pure type(rigidbody) function construct(mass, fmass, smass, &
& r, theta, v, omega) result (this)
type(scalar), intent(in) :: mass, fmass(:), smass(:,:)
type(scalar), intent(in) :: r(:), theta(:), v(:), omega(:)
! Set the number of state variables of RIGIDBODY system
call this % set_num_state_vars(6)
! Set time order of RIGIDBODY system
call this % set_differential_order(2)
! Set the object attributes
this % mass = mass
this % first_moment_mass = fmass
this % second_moment_mass = smass
! Set the states
this % position = r
this % orientation = theta
this % linear_velocity = v
this % angular_velocity = omega
end function construct
!===================================================================!
! Destructor for rigidbody system
!===================================================================!
pure subroutine destruct(this)
type(rigidbody), intent(inout) :: this
end subroutine destruct
!===================================================================!
! Residual assembly at each time step. This is a mandary function
! that the user needs to implement to use the integration
! scheme. This is where the differential equations are supplied to
! the solver.
!===================================================================!
pure subroutine add_residual(this, residual, U, X)
class(rigidbody) , intent(inout) :: this
type(scalar) , intent(inout) :: residual(:)
type(scalar) , intent(in) :: U(:,:)
type(scalar) , intent(in) :: X(:,:)
associate( q => U(1,:), qdot => U(2,:), qddot => U(3,:), &
& m => this % mass, &
& r1m => this % first_moment_mass, &
& r2m => this % second_moment_mass )
!residual = residual + m*qddot - m*g
end associate
end subroutine add_residual
!===================================================================!
! Jacobian assembly at each time step.
!
! Jacobian is the matrix of partial derivatives. Each row in the
! Jacobian matrix arises from differentiating a single
! equation. Each column in the Jacobian comes from a variable in the
! problem. Note the NEQN should be equal to NVARS for the system to
! be solved.
!
! Note: alpha, beta and gamma are scalars that need to be multiplied
! with the partial derivatives DRDQ, DRDudot and DRDuddot
! respectively.
!===================================================================!
pure subroutine add_jacobian(this, jacobian, coeff, U, X)
class(rigidbody) , intent(inout) :: this
type(scalar) , intent(inout) :: jacobian(:,:)
type(scalar) , intent(in) :: coeff(:)
type(scalar) , intent(in) :: U(:,:)
type(scalar) , intent(in) :: X(:,:)
associate( q => U(1,:), qdot => U(2,:), qddot => U(3,:), &
& m => this % mass, &
& r1m => this % first_moment_mass, &
& r2m => this % second_moment_mass )
!jacobian = jacobian + gamma*M
end associate
end subroutine add_jacobian
!===================================================================!
! Sets the initial condition for use in the integator. If first order
! system just set initial Q, if a second order system set initial Q
! and qdot
!===================================================================!
pure subroutine get_initial_condition(this, U, X)
class(rigidbody) , intent(in) :: this
type(scalar) , intent(inout) :: U(:,:)
type(scalar) , intent(in) :: X(:,:)
! location (might use displacement)
U(1,1:3) = this % position
! orientation (might use ang. displacement)
U(1,4:6) = this % orientation
! translational velocity
U(2,1:3) = this % linear_velocity
! angular velocity
U(2,4:6) = this % angular_velocity
end subroutine get_initial_condition
end module rigidbody_dynamics_class
| src/rigidbody_dynamics_class.f90 |
CSTA2
C SUBROUTINE STA2
C SATISFY CONTINUITY OF FLOW AT ROTOR EXIT
SUBROUTINE STA2
C
REAL MFSTOP
LOGICAL PREVER
COMMON /SNTCP/G,AJ,PRPC,ICASE,PREVER,MFSTOP,JUMP,LOPIN,ISCASE,
1 K,GAMF,IP,SCRIT,PTRN,ISECT,KSTG,WTOL,RHOTOL,PRTOL,TRLOOP,LSTG,
2LBRC,IBRC,ICHOKE,ISORR,CHOKE,PT0PS1(6,8),PTRS2(6,8),TRDIAG,SC,RC,
3DELPR,PASS,IPC,LOPC,ISS
C
COMMON /SINIT/H1(6,8),H2(6,8),DP0(6,8),DP1(6,8),DP1A(6,8),DP2(6,8)
1,DP2A(6,8),CSALF1(6,8),ALF1(6,8),CSBET2(6,8),BET2(6,8),RADSD(6,8),
2RADRD(6,8),ANN1(6,8),ANN2(6,8),ANN2A(6,8),ANN1A(6,8),U1A(6,8),
3U2(6,8),ANN0(6,8),PT0(6,8),TT0(6,8),ALPHA0(6,8),PTP(6,8)
C
COMMON /SINPUT/
1PTPS,PTIN,TTIN,WAIR,FAIR,DELC,DELL,DELA,AACS,VCTD,STG,SECT,EXPN,
2EXPP,EXPRE,RG,RPM,PAF,SLI,STGCH,ENDJOB,XNAME(20),TITLE(20),
3PCNH(6),GAM(6,8),DR(6,8),DT(6,8),RWG(6,8),ALPHAS(6,8),ALPHA1(6,8),
4ETARS(6,8),ETAS(6,8),CFS(6,8),ANDO(6,8),BETA1(6,8),BETA2(6,8),ETAR
5R(6,8),ETAR(6,8),CFR(6,8),TFR(6,8),ANDOR(6,8),OMEGAS(6,8),AS0(6,8)
6,ASMP0(6,8),ACMN0(6,8),A1(6,8),A2(6,8),A3(6,8),A4(6,8),A5(6,8),A6(
76,8),OMEGAR(6,8),BSIA(6,8),BSMPIA(6,8),BCMNIA(6,8),B1(6,8),B2(6,8)
8,B3(6,8),B4(6,8),B5(6,8),B6(6,8),SESTHI(8),RERTHI(8)
9,fairx(5,8),wairx(5,8),rg1(8),rg1a(8),rg2(8),rg2a(8)
COMMON /SADDIN/ PS1P(8),PS2P(8)
C
REAL MR1A
COMMON /SSTA1A/VU1A(6,8),WG1A(6,8),WGT1A(8),VZ1A(6,8), CP1A(8),
1PS1A(6,8),RU1A(6,8),R1A(6,8),BET1A(6,8),RI(6,8),TTR1A(6,8),PTR1A(6
2,8),MR1A(6,8)
C
COMMON /SSTA2/V2(6,8),TTR2(6,8),PTR2(6,8),WG2(6,8),WGT2(8),TA2(8),
1 PS2(6,8),PHI2(6,8)
C
REAL MR2,M2 ,MF2
COMMON /SFLOW2/TS2(6,8),CP2(8),R2(6,8),RHOS2(6,8),BET2E(6,8),RU2(6
1,8),VU2(6,8),DPDR2(6,8),VZ2(6,8),MR2(6,8),MF2(6,8),M2(6,8)
COMMON/RPMCOM/RPMK(8)
COMMON /TDIL/TWG (6,8),pwg(6,8)
C COMMON RES(6),PCNFS(6), DTT(6),DPT(6),TR2M1(6)
COMMON RES(8),PCNFS(6), DTT(6),DPT(6),TR2M1(6)
COMMON/DESOPT/RVU1(6,8),RVU2(6,8),WG,EPR
COMMON/SLSHFT/STRF1(6,8),STRF2(6,8),UPSI1(6)
EQUIVALENCE (STRF2 ,PCNF)
C
C
DIMENSION WGT2C(8),PCNF(6,8),IS2(8)
C
PCNFS(1)=WG1A(1,K)/WGT1A(K)/2.
PTRN=0.
J=1
TGJCP=2.*G*AJ*CP1A(K)
TWGF=0.
IF(TWG(4,K).GT.0.) TWGF=1.
SCRIT=0.0
PTRMO=1.
IS2(K)=0
RUOT=0.
EXI=GAM(3,K)/(GAM(3,K)-1.)
WR=RWG(4,K)/RWG(3,K)
DO 1 I=1,ISECT
IF(PCNF(I,K).GT.0.) GO TO 1160
TTR2(I,K)=TTR1A(I,K)+(U2(I,K)**2 - U1A(I,K)**2)/TGJCP
PTR2(I,K)=PTR1A(I,K)*(TTR2(I,K)/TTR1A(I,K))**EXI
if (twgf.gt.0.1) then
twgr=twg(4,k)+u2(i,k)**2/tgjcp
ttm=(ttr2(i,k)+(wr-1.)*twgr)/wr
tpp=(ttm+ttr2(i,k))/2.
tpc=(ttm+twgr)/2.
call cpa(ptr1a(i,k),tpc,0.0,0.0,cpc)
call gama(ptr1a(i,k),tpp,fairx(3,k),wairx(3,k),gamtpp)
extpp=gamtpp/(gamtpp-1.)
cpp=rg1a(k)*extpp/aj
ttr2(i,k)=(cpp*ttr2(i,k)+(wr-1.)*cpc*twgr)/(cpp+(wr-1.)*cpc)
end if
1160 IF(I.EQ.1) GO TO 1
PCNFS(I)=PCNFS(I-1)+(WG1A(I-1,K)+WG1A(I,K))/2./WGT1A(K)
1 WG2(I,K)=WR*WG1A(I,K)
KF=ISECT-1
CALL BESFIT(ISECT,PCNFS,U1A(1,K),KF,TR2M1,RES)
IU=KF+1
KF=ISECT-1
CALL BESFIT(ISECT,PCNFS,PTR1A(1,K),KF,DPT,RES)
IPT=KF+1
KF=ISECT-1
CALL BESFIT(ISECT,PCNFS,TTR1A(1,K),KF,DTT,RES)
ITT=KF+1
WGT2(K)=WR*WGT1A(K)
I=IP
ID=-1
WGT2C(K)=0.
C IF(ICHOKE)26,26,3
C replced by ..............
IF(ICHOKE.LE.0) THEN
GO TO 26
ELSE
GO TO 3
ENDIF
C26 IF(LOPIN)27,27,3
C replced by ..............
26 IF(LOPIN.LE.0) THEN
GO TO 27
ELSE
GO TO 3
ENDIF
C27 IF(GAMF)2,2,16
C replced by ..............
27 IF(GAMF.LE.0.) THEN
GO TO 2
ELSE
GO TO 16
ENDIF
2 TA2(K)=.95*TTR2(IP,K)
CALL GAMA(PTR2(I,K),TA2(K),FAIRx(4,k),WAIRx(4,k),GAM(4,K))
16 CP2(K)=rg2(k)*EXI/AJ
IF(RVU1(IP,K).NE.0.)
*RUOT=(RVU2(IP,K)/DP2(IP,K)+.5*U2(IP,K))**2/CP2(K)/TTR2(IP,K)/G/AJ
1*2.
FFA2 =WG2(I,K)*SQRT(TTR2(I,K))/(144.*PTR2(I,K)*
1ANN2(I,K))
IF(RVU1(I,K).EQ.0.)FFA2=FFA2/CSBET2(I,K)
CALL PRATIO(FFA2 ,GAM(4,K),rg2(k),PTRS2 (I ,K),PRTOL,
1 ETAR(I ,K),RUOT,k)
IF(PS2P(K).NE.0.) PTRS2(I,K)= PTR2(I,K) / PS2P(K)
IF(PCNF(1,K).LE.0.) GO TO 1103
3 DO 1150 I=1,ISECT
TTR2IK=0.
PTR2(I,K)=0.
UPSI1(I)=0.
PSIRP=1.
DO 1140 IFT=1,ISECT
IF(IFT.GT.IU) GO TO 1130
UPSI1(I)=UPSI1(I)+TR2M1(IFT)*PSIRP
1130 IF(IFT.GT.IPT) GO TO 1120
PTR2(I,K)=PTR2(I,K)+DPT(IFT)*PSIRP
1120 IF(IFT.GT.ITT) GO TO 1140
TTR2 I K =TTR2 I K +DTT(IFT)*PSIRP
1140 PSIRP=PSIRP*PCNF(I,K)
TTR2(I,K)= TTR2IK+(U2(I,K)**2-UPSI1(I)**2)/TGJCP
PTR2(I,K)=PTR2(I,K)*(TTR2(I,K)/TTR2IK)**EXI
if (twgf.gt.0.1) then
twgr=twg(4,k)+u2(i,k)**2/tgjcp
ttm=(ttr2(i,k)+(wr-1.)*twgr)/wr
tpp=(ttm+ttr2(i,k))/2.
tpc=(ttm+twgr)/2.
call cpa(ptr1a(i,k),tpc,0.0,0.0,cpc)
call gama(ptr1a(i,k),tpp,fairx(3,k),wairx(3,k),gamtpp)
extpp=gamtpp/(gamtpp-1.)
cpp=rg1a(k)*extpp/aj
ttr2(i,k)=(cpp*ttr2(i,k)+(wr-1.)*cpc*twgr)/(cpp+(wr-1.)*cpc)
end if
1150 continue
I=IP
1103 CALL FLOW2(I)
IF (PREVER) GO TO 22
WGT2C(K)=WGT2C(K)+WG2(I,K)
L=1
IF (PTRS2(I,K).LE.PTRS2(IP,K)) L=I
C IF(ISECT-I)7,7,4
C replaced by ..........
IF((ISECT-I).LE.0) THEN
GO TO 7
ELSE
GO TO 4
ENDIF
4 I=I+ID
C IF(I)5,5,6
C replaced by ..........
IF(I.LE.0) THEN
GO TO 5
ELSE
GO TO 6
ENDIF
5 ID=1
I=IP+ID
6 L=I-ID
GM2=(GAM(4,K)-1.)/2.*VU2(L,K)**2/GAM(4,K)/G/rg2(k)/TS2(L,K)
DRSQ=(DP2(L,K)/DP2(I,K))**2
PS2(I,K)=PS2(L,K)
1 *(1.+GM2*(1.-DRSQ)) **(GAM(4,K)/(GAM(4,K)-1.))
PTRS2(I,K)=PTR2(I,K)/PS2(I,K)
C IF (PTRS2(I,K)-1.)19,19,1103
C replaced by ..........
IF (PTRS2(I,K)-1..LE.0) THEN
GO TO 19
ELSE
GO TO 1103
ENDIF
C REVERSE FLOW INDICATION
19 PTRS2(I,K) = 1.0 + PRTOL
PTRN=-1.
GO TO 1103
C7 IF(IS2(K))8,8,9
C replaced by ..........
7 IF(IS2(K).LE.0) THEN
GO TO 8
ELSE
GO TO 9
ENDIF
8 EXI=GAM(4,K)/(GAM(4,K)-1.)
IF(RUOT.NE.0.)GO TO 1210
CALL PHIM(EXI,ETAR(L,K),PHIX,PRCRIT)
PRUP=PTR2(IP,K)*PRCRIT*PS2(L,K)/(PTR2(L,K)*PS2(IP,K))
1*(1.+PRTOL)
GO TO 1220
1210 PRUP=1./(1.-(GAM(4,K)-1.+2.*RUOT)/(GAM(4,K)+1.)/ETAR(IP,K))**EXI
1220 PRLOW=1.
9 IS2(K)=IS2(K)+1
L = IBRC + 1
IF(PS2P(K).NE.0.) GO TO 40
IF(ICHOKE.EQ.L) PTRS2(IP,K) = PRUP
PCNF (1,K)=WG2(1,K)/WGT2C(K)/2.
DO 50 I=2,ISECT
50 PCNF(I,K)=(WG2(I-1,K)+WG2(I,K))/2./WGT2C(K)+PCNF (I-1,K)
C IF(WGT2(K)-WGT2C(K))12,15,11
C replaced by ..........
IF(WGT2(K)-WGT2C(K).LT.0.) THEN
GO TO 12
ELSEIF (WGT2(K)-WGT2C(K).EQ.0.) THEN
GO TO 15
ELSEIF (WGT2(K)-WGT2C(K).GT.0.) THEN
GO TO 11
ENDIF
C
11 PRLOW= PTRS2(IP,K)*.8+.2*PRLOW
GO TO 13
12 PRUP= PTRS2(IP,K)*.8+.2*PRUP
IS2(K)=1
13 WE=1.-WGT2(K)/WGT2C(K)
J=J+1
C IF(J-26)29,17,17
C replaced by ..........
IF(J-26.LT.0) THEN
GO TO 29
ELSE
GO TO 17
ENDIF
C29 IF(ICHOKE-L) 30,31,30
C replaced by ..........
29 IF((ICHOKE-L).NE.0) THEN
GO TO 30
ELSE
GO TO 31
ENDIF
31 SCRIT= -WE
GO TO 15
C30 IF(LOPIN)14,14,15
C replaced by ..........
30 IF(LOPIN.LE.0) THEN
GO TO 14
ELSE
GO TO 15
ENDIF
14 CONTINUE
C
IF(PTRS2(IP,K).LT.1.15) GO TO 71
C IF (ABS( WE)- WTOL)15,15,24
C replaced by ..........
IF ((ABS( WE)- WTOL).LE.0.) THEN
GO TO 15
ELSE
GO TO 24
ENDIF
C71 IF(ABS(WE)-10.*WTOL) 15,15,24
C replaced by ..........
71 IF((ABS(WE)-10.*WTOL).LE.0.) THEN
GO TO 15
ELSE
GO TO 24
ENDIF
17 CONTINUE
IF(PTRN.LT.0.) GO TO 18
IF(WE.GT.10.*WTOL) GO TO 18
IF(PTRS2(IP,K).GE.1.15.AND.WE.GT.WTOL) GO TO 18
IF(PTRS2(IP,K).LT.1.15) GO TO 73
C IF (ABS(WE)-WTOL)15,15,23
C replaced by ..........
IF ((ABS(WE)- WTOL).LE.0.) THEN
GO TO 15
ELSE
GO TO 23
ENDIF
C73 IF(ABS(WE)-10.*WTOL) 15,15,23
C replaced by ..........
73 IF((ABS(WE)-10.*WTOL).LE.0.) THEN
GO TO 15
ELSE
GO TO 23
ENDIF
24 PTRMO=PTRS2(IP,K)
I=IP
ID=-1
C IF (SCRIT)28,28,15
C replaced by .........
IF (SCRIT.GT.0.) GO TO 15
28 CONTINUE
IF (PTRS2(IP,K).LE.PRCRIT
1.OR.RVU1(I,K).NE.0.) PRPC=0.
WGT2C(K)=0.0
PTRS2 (IP,K)=(PRUP+PRLOW)*0.5
GO TO 3
40 DO 45 I= 1,ISECT
COSB2E= CSBET2(I,K) * WGT2(K) / WGT2C(K)
CSBET2(I,K) = COSB2E
45 BET2E(I,K)= ATAN2(SQRT(1.-COSB2E*COSB2E),COSB2E)
IF(J.GE.6) GO TO 15
J= J+1
I= IP
WGT2C(K)=0.0
ID= -1
GO TO 3
23 SCRIT= 1.
15 IF(TRLOOP.EQ.0.) GO TO 25
18 WRITE(16,1000)K,PRUP,PRLOW,WE,PRCRIT,J,WGT2(K),WGT2C(K),(WG2(L,K),
1 L=1,ISECT)
WRITE(16,1001)(PTRS2(L,K),L=1,ISECT)
1000 FORMAT(2X,2HK=,I4, 2X,6H PRUP=,
&F8.5,2X,6HPRLOW=,F8.5,2X,6H WE=,
1F8.5,1X,7HPRCRIT=,F8.5,2X,2HJ=,I4/
22X,6H WGT2=,F8.3,2X,6HWGT2C=,F8.3/
32X,6H WG2=,6F8.3)
1001 FORMAT(2X,6HPTPS2=,6F8.5)
25 j=2
GO TO (20,21),J
20 CALL DIAGT(4)
GO TO 22
21 CALL LOOP
22 RETURN
END
| contrib/axod/src/sta2.f |
Selby is a second year Computer Science major. She also loves playing world of warcraft and working out.
20061019 21:32:17 nbsp Yay! Selby is on the wiki! :) Users/WilliamLewis
| lab/davisWiki/SelbyWalker.f |
module mod_hydro_mixratio
!===================================================================================85
!---------------------------- DESCRIPTION ------------------------------------------85
!
!
!
! Module name:
! 'mod_hydro_mixratio'
!
! Purpose:
! Hydrometeors mixing ratio expressed in kg/kg
!
!
! History:
! Date: 21-09-2017
! Time: 09:23 GMT+2
!
! Version:
!
! Major: 1
! Minor: 0
! Micro: 0
!
! Author: Bernard Gingold
!
!
!
!
!
! E-mail:
!
! [email protected]
!==================================================================================85
! Tab:5 col - Type and etc.. definitions
! Tab:10,11 col - Type , function and subroutine code blocks.
implicit none
private ! everything is private beside variables and procedures deemed public
use ISO_FORTRAN_ENV, only : stderr=>ERROR_UNIT , &
stdout=>OUTPUT_UNIT
use IFPORT, only : TRACEBACKQQ
use module_class_error_check, only : array3D_not_alloc
use module_kinds
use mod_constants
use module_logger
use mod_code_timing
public :: assignment (=)
public :: operator (/=)
public :: operator (==)
public :: operator (>)
public :: operator (<)
public :: operator (.grad.)
public :: operator (.laplacian.)
!=====================================================59
! File and module information:
! version,creation and build date, author,description
!=====================================================59
! Version major
integer(I32P), parameter, public :: MOD_HYDRO_MIXRATIO_MAJOR = 1
! Version minor
integer(I32P), parameter, public :: MOD_HYDRO_MIXRATIO_MINOR = 0
! Version micro
integer(I32P), parameter, public :: MOD_HYDRO_MIXRATIO_MICRO = 0
! Module full version
integer(I32P), parameter, public :: MOD_HYDRO_MIXRATIO_FULLVER = 1000*MOD_HYDRO_MIXRATIO_MAJOR+100*MOD_HYDRO_MIXRATIO_MINOR+ &
10*MOD_HYDRO_MIXRATIO_MICRO
! Module creation date/time
character(*), parameter, public :: MOD_HYDRO_MIXRATIO_CREATE_DATE = "21-09-2017 09:30 +00200 (THR 21 SEP 2017 GMT+2)"
! Module build date/time (should be set after successfull compilation)
character(*), parameter, public :: MOD_HYDRO_MIXRATIO_BUILD_DATE = " "
! Module author info
character(*), parameter, public :: MOD_HYDRO_MIXRATIO_AUTHOR = "Programmer: Bernard Gingold e-mail: [email protected]"
! Module short description
character(*), parameter, public :: MOD_HYDRO_MIXRATIO_INFO = "Hydrometeors mixing ratio representation."
!============================================50
! Type: HydroMRatio
!============================================50
type, public :: HydroMRatio
! public by default
! Indices conforms to WRF implementation.
! Order of indices as follows:
! 1) Memory: ims,kms,jms,... at m_idx(1)->m_idx(6)
! 2) Domain: ids,kds,jds,... at m_idx(7)->m_idx(12)
! 3) Tile: its,kts,jts,... at m_idx(13)->m_idx(18)
integer(I64P), dimension(A3DNidx) :: m_idx
! Hydrometeor name i.e. water vapour, ice, hail ..etc
character(len=64) :: m_name
real(R64P), allocatable, dimension(:,:,:) :: m_mratio
!DIR$ ATTRIBUTES ALIGN : 32 :: m_mratio
! Build indicator (logical)
logical(I32P) :: m_isbuilt
contains
!===========================================55
! Constructors and Destructor procedures.
!===========================================55
procedure, pass(this), public :: default_init
procedure, pass(this), public :: init
procedure, pass(this), public :: copy
procedure, pass(this), public :: destroy
!============================================55
! Read/Write procedures
!============================================55
procedure, nopass, public :: read_hmratio
procedure, nopass, public :: write_hmratio
end type HydroMRatio
!=================================================60
! Module operators
!=================================================60
interface assignment (=)
module procedure assign_hmratio
end interface
interface operator (/=)
module procedure hmratio_neq_hmratio
end interface
interface operator (==)
module procedure hmratio_eq_hmratio
end interface
interface operator (>)
module procedure hmratio_gt_hmratio
end interface
interface operator (<)
module procedure hmratio_lt_hmratio
end interface
interface operator (.grad.)
module procedure hmratio_gradient
end interface
interface operator (.laplacian.)
module procedure hmratio_laplacian
end interface
contains
!=================================================60
! Implementation
!=================================================60
!======================================================60
! subroutine: default_init
! Initialziation to default values in this case +INF.
! @Warning:
! Upon non-fatal early exit parameter
! 'err' will be set to -1
!======================================================60
subroutine default_init(this,indices,name,logging,filename, &
append,dbg,err )
implicit none
class(HydroMRatio), intent(inout) :: this
integer(I64P), dimension(A3DNidx), intent(in) :: indices
character(len=*), intent(in) :: name
logical(I32P), intent(in) :: logging
character(*), intent(in) :: filename
logical(I32P), intent(in) :: append,dbg
integer(I32P), intent(inout) :: err
! Locals
character(len=40) :: sdate,stime
character(len=256) :: emsg
integer(I64P) :: j,k,i
integer(I32P) :: aerr
integer(BOOL) :: ifail
logical(I32P) :: bfail
! Start of executable statements
if(err.LT.0) err = 0
if(this%m_isbuilt .EQ. .true.) then
if(logging) then
call log_startup(filename,append)
call log_UsrMsg("logger:189, In->mod_hydro_mixratio/default_init: HydroMRatio already initiliazed!!")
call log_shutdown()
else
call DATE_AND_TIME(date=sdate,time=stime)
write(stderr,*) "===========================NON-FATAL=========================="
write(sdterr,*) " ( mod_hydro_mixratio/default_init:189, HydroMRatio already initialized!!)"
write(stderr,*) " ( Non-Fatal Error at:) ", &
sdate(1:4),"-",sdate(5:6),"-",sdate(7:8), " ", &
stime(1:2),":",stime(3:4),":",stime(5:6)
write(stderr,*) "===========================NON-FATAL=========================="
end if
err = -1
return
end if
! Begin construction
this%m_idx = indices
this%m_name = name
associate(d1s=>this%m_idx(1), &
d1e=>this%m_idx(2), &
d2s=>this%m_idx(3), &
d2e=>this%m_idx(4), &
d3s=>this%m_idx(5), &
d3e=>this%m_idx(6) )
allocate(this%m_mratio(d1s:d1e,d2s:d2e,d3s:d3e), &
STAT=aerr, &
ERRMSG=emsg )
end associate
if(aerr.NE.0) then
if(logging) then
call log_startup(filename,append)
call log_UsrMsg("logger:218, In->mod_hydro_mixratio/default_init: Failed to allocate: [m_mratio]")
call log_shutdown()
else
call DATE_AND_TIME(date=sdate,time=stime)
write(ERROR_UNIT,*) "===========================FATAL========================="
write(ERROR_UNIT,*) " (mod_hydro_mixratio/default_init:218, Failed to allocate: [m_mratio])"
write(ERROR_UNIT,*) " (System message:)", emsg
write(ERROR_UNIT,*) " ( Fatal Error at:) ", &
sdate(1:4),"-",sdate(5:6),"-",sdate(7:8), " ", &
stime(1:2),":",stime(3:4),":",stime(5:6)
write(ERROR_UNIT,*) "===========================FATAL=========================="
end if
!DIR$ IF (SHOW_CALLSTACK .EQ. 1)
call TRACEBACKQQ(STRING="FATAL-ERROR", USER_EXIT_CODE= -1)
!DIR$ ENDIF
ERROR STOP "mod_hydro_mixratio/default_init:218 -> [FATAL-ERROR]: Terminating execution!!"
end if
! Array initialzation
do j = this%m_idx(17), this%m_idx(18) ! m_jts, m_jte
do k = this%m_idx(15), this%m_idx(16) ! m_kts, m_kte
!DIR$ SIMD VECTORLENGTHFOR(REAL(KIND=8))
do i = this%m_idx(13), this%m_idx(14) ! m_its, m_ite
this%m_mratio(i,k,j) = LAM_PINF
end do
end do
end do
this%m_isbuilt = .true.
if(dbg) then
print*, "Hydrometeor=", this%m_name
print*, this%m_mratio
end if
end subroutine
!======================================================60
! subroutine: init
! Initialziation by user(caller) passed array which
! usually contain computed scalar values of hydrometeor
! mixing ratios.
! @Warning:
! Upon non-fatal early exit parameter
! 'err' will be set to -1
!======================================================60
subroutine init(this,indices,name,mratio,logging,profiling, &
filename,append,dbg,err,qpctimer )
implicit none
class(HydroMRatio), intent(inout) :: this
integer(I64P), dimension(A3DNidx), intent(in) :: indices
character(len=*), intent(in) :: name
real(R64P), dimension(:,:,:), intent(in) :: mratio
!DIR$ ASSUME_ALIGNED mratio:32
logical(I32P), intent(in) :: logging,profiling
character(len=*), intent(in) :: filename
logical(I32P), intent(in) :: append,dbg
integer(I32P), intent(inout) :: err
type(QPCTimer_t), intent(inout) :: qpctimer
! Locals
character(len=40) :: sdate,stime
character(len=256) :: emsg
integer(I64P) :: j,k,i
!DIR$ IF (USE_LOOP_BLOCKING .EQ. 1)
integer(I64P) :: jj,kk,ii
!DIR$ ENDIF
integer(I32P) :: aerr
integer(BOOL) :: ifail
logical(I32P) :: bfail
! Start of executable statements
if(err.LT.0) err = 0
if(this%m_isbuilt .EQ. .true. .OR. &
array3D_not_alloc(mratio)) then
if(logging) then
call log_startup(filename,append)
call log_UsrMsg("logger:292, In->mod_hydro_mixratio/init: HydroMRatio already initialized, or invalid argument!!")
call log_shutdown()
else
call DATE_AND_TIME(date=sdate,time=stime)
write(stderr,*) "===========================NON-FATAL=========================="
write(sdterr,*) " ( mod_hydro_mixratio/init:292, HydroMRatio already initialized!!)"
write(stderr,*) " ( Non-Fatal Error at:) ", &
sdate(1:4),"-",sdate(5:6),"-",sdate(7:8), " ", &
stime(1:2),":",stime(3:4),":",stime(5:6)
write(stderr,*) "===========================NON-FATAL=========================="
end if
err = -1
return
end if
! Begin construction
this%m_idx = indices
this%m_name = name
associate(d1s=>this%m_idx(1), &
d1e=>this%m_idx(2), &
d2s=>this%m_idx(3), &
d2e=>this%m_idx(4), &
d3s=>this%m_idx(5), &
d3e=>this%m_idx(6) )
allocate(this%m_mratio(d1s:d1e,d2s:d2e,d3s:d3e), &
STAT=aerr, &
ERRMSG=emsg )
end associate
if(aerr.NE.0) then
if(logging) then
call log_startup(filename,append)
call log_UsrMsg("logger:323, In->mod_hydro_mixratio/init: Failed to allocate: [m_mratio]")
call log_shutdown()
else
call DATE_AND_TIME(date=sdate,time=stime)
write(ERROR_UNIT,*) "===========================FATAL========================="
write(ERROR_UNIT,*) " (mod_hydro_mixratio/init:323, Failed to allocate: [m_mratio])"
write(ERROR_UNIT,*) " (System message:)", emsg
write(ERROR_UNIT,*) " ( Fatal Error at:) ", &
sdate(1:4),"-",sdate(5:6),"-",sdate(7:8), " ", &
stime(1:2),":",stime(3:4),":",stime(5:6)
write(ERROR_UNIT,*) "===========================FATAL=========================="
end if
!DIR$ IF (SHOW_CALLSTACK .EQ. 1)
call TRACEBACKQQ(STRING="FATAL-ERROR", USER_EXIT_CODE= -1)
!DIR$ ENDIF
ERROR STOP "mod_hydro_mixratio/default:323 -> [FATAL-ERROR]: Terminating execution!!"
end if
! Array initialization
if(profiling) then
call qpctimer_start(qpctimer,ifail)
if(ifail.EQ.0) then
write(stderr,*) "mod_hydro_mixratio/init: qpctimer_start failed to query performance frequency counter!"
end if
end if
!DIR$ IF (USE_LOOP_BLOCKING .EQ. 1)
do j = this%m_idx(17), this%m_idx(18), DEFAULT_BLOCK_SIZE ! m_jts, m_jte
do k = this%m_idx(15), this%m_idx(16), DEFAULT_BLOCK_SIZE ! m_kts, m_kte
do i = this%m_idx(13), this%m_idx(14), DEFAULT_BLOCK_SIZE ! m_its, m_ite
do jj = j, DEFAULT_BLOCK_SIZE
do kk = k, DEFAULT_BLOCK_SIZE
!DIR$ SIMD VECTORLENGTHFOR(REAL(KIND=8))
do ii = i, DEFAULT_BLOCK_SIZE
!DIR$ IF (USE_SOFT_PREFETCH .EQ. 1)
call MM_PREFETCH(mratio(ii+2,kk,jj),1)
!DIR$ ENDIF
this%m_mratio(ii,kk,jj) = mratio(ii,kk,jj)
end do
end do
end do
end do
end do
end do
!DIR$ ELSE
do j = this%m_idx(17), this%m_idx(18)
do k = this%m_idx(15), this%m_idx(16)
!DIR$ SIMD VECTORLENGTHFOR(REAL(KIND=8))
do i = this%m_idx(13), this%m_idx(14)
!DIR$ IF (USE_SOFT_PREFETCH .EQ. 1)
call MM_PREFETCH(mratio(i+2,k,j),1)
!DIR$ ENDIF
this%m_mratio(i,k,j) = mratio(i,k,j)
end do
end do
end do
!DIR$ ENDIF
if(profiling) then
if(ifail.EQ.0) then
call qpctimer_stop(qpctimer,ifail)
call qpctimer_delta(qpctimer,bfail)
if(bfail .EQ. .false.) then
call qpctimer_print(qpctimer)
else
write(stderr,*) "mod_hydro_mixratio/init: qpctimer_delta: failed to compute delta measurement!!"
end if
else
write(stderr,*) "mod_hydro_mixratio/init: Unable to read performance counter -- fatal!!"
end if
end if
this%m_isbuilt = .true.
if(dbg) then
print*, "Hydrometeor=", this%m_name
print*, this%m_mratio
end if
end subroutine
!======================================================60
! subroutine: copy
! Remark:
! Upon detecting non-fatal error inout
! integer indicator 'err' will be set to -1.
!======================================================60
subroutine copy(this,other,logging,filename,append,err)
implicit none
class(HydroMRatio), intent(inout) :: this
class(HydroMRatio), intent(in) :: other
logical(I32P), intent(in) :: logging
character(len=*), intent(in) :: filename
logical(I32P), intent(in) :: append
integer(I32P), intent(inout) :: err
! Locals
character(len=40) :: sdate,stime
! Start of executable statements
if(err.LT.0) err = 0
if(this%m_isbuilt .EQ. .true.) then
if(logging) then
call log_startup(filename,append)
call log_UsrMsg("logger:420, In->mod_hydro_mixratio/copy: HydroMRatio already initialized!!")
call log_shutdown()
else
call DATE_AND_TIME(date=sdate,time=stime)
write(stderr,*) "===========================NON-FATAL=========================="
write(sdterr,*) " ( mod_hydro_mixratio/copy:420, HydroMRatio already initialized!!)"
write(stderr,*) " ( Non-Fatal Error at:) ", &
sdate(1:4),"-",sdate(5:6),"-",sdate(7:8), " ", &
stime(1:2),":",stime(3:4),":",stime(5:6)
write(stderr,*) "===========================NON-FATAL=========================="
end if
err = -1
return
end if
! Begin construction
this%m_idx(:) = other%m_idx(:)
this%m_name = other%m_name
this%m_mratio = other%m_ratio
this%m_isbuilt = .true.
end subroutine
!======================================================60
! subroutine: destroy
! Remark:
! Upon detecting non-fatal error inout
! integer indicator 'err' will be set to -1.
!======================================================60
subroutine destroy(this,logging,filename,append,err)
implicit none
class(HydroMRatio), intent(inout) :: this
logical(I32P), intent(in) :: logging
character(len=*), intent(in) :: filename
logical(I32P), intent(in) :: append
integer(I32P), intent(inout) :: err
! Locals
character(len=40) :: sdate,stime
character(len=256) :: emsg
integer(I32P) :: derr
! Start of executable statements
if(err.LT.0) err = 0
if(this%m_isbuilt .EQ. .false.) then
if(logging) then
call log_startup(filename,append)
call log_UsrMsg("logger:463, In->mod_hydro_mixratio/destroy: HydroMRatio already destroy!!")
call log_shutdown()
else
call DATE_AND_TIME(date=sdate,time=stime)
write(stderr,*) "===========================NON-FATAL=========================="
write(sdterr,*) " ( mod_hydro_mixratio/copy:463, HydroMRatio already destroy!!)"
write(stderr,*) " ( Non-Fatal Error at:) ", &
sdate(1:4),"-",sdate(5:6),"-",sdate(7:8), " ", &
stime(1:2),":",stime(3:4),":",stime(5:6)
write(stderr,*) "===========================NON-FATAL=========================="
end if
err = -1
return
end if
this%m_idx(:) = 0
this%m_name = " "
if(ALLOCATED(this%m_mratio)) then
deallocate(this%m_mratio, &
STAT=derr, &
ERRMSG=emsg )
if(derr.NE.0) then
if(logging) then
call log_startup(filename,append)
call log_UsrMsg("logger:486, In->mod_hydro_mixratio/destroy: Failed to deallocate: [m_mratio]")
call log_shutdown()
else
call DATE_AND_TIME(date=sdate,time=stime)
write(ERROR_UNIT,*) "===========================FATAL========================="
write(ERROR_UNIT,*) " (mod_hydro_mixratio/destroy:486, Failed deallocate: [m_mratio])"
write(ERROR_UNIT,*) " (System message:)", emsg
write(ERROR_UNIT,*) " ( Fatal Error at:) ", &
sdate(1:4),"-",sdate(5:6),"-",sdate(7:8), " ", &
stime(1:2),":",stime(3:4),":",stime(5:6)
write(ERROR_UNIT,*) "===========================FATAL=========================="
end if
!DIR$ IF (SHOW_CALLSTACK .EQ. 1)
call TRACEBACKQQ(STRING="FATAL-ERROR", USER_EXIT_CODE= -1)
!DIR$ ENDIF
ERROR STOP "mod_hydro_mratio/destroy:486 -> [FATAL-ERROR]: Terminating execution!!"
end if
end if
this%m_isbuilt = .false.
end subroutine
!======================================================60
! subroutine: read_hmratio
! Remark:
! Upon detecting non-fatal error inout
! integer indicator 'err' will be set to -1.
!======================================================60
subroutine read_hmratio(this,unit,ioerr,err)
implicit none
class(HydroMRatio), intent(in) :: this
integer, intent(in) :: unit
integer(I32P), intent(inout) :: ioerr,err
! Start of executable statements
if(err.LT.0) err = 0
if(this%m_isbuilt .EQ. .false.) then
err = -1
return
end if
READ(unit,iostat=ioerr) this
end subroutine
!======================================================60
! subroutine: write_hmratio
! Remark:
! Upon detecting non-fatal error inout
! integer indicator 'err' will be set to -1.
!======================================================60
subroutine write_hmratio(this,unit,ioerr,err)
implicit none
class(HydroMRatio), intent(in) :: this
integer, intent(in) :: unit
integer(I32P), intent(inout) :: ioerr,err
! Start of executable statements
if(err.LT.0) err = 0
if(this%m_isbuilt .EQ. .false.) then
err = -1
return
end if
WRITE(unit,iostat=ioerr) this
end subroutine
!======================================================60
! Module operators
!======================================================60
!=======================================================60
! subroutine: overloaded assignment (=)
!=======================================================60
subroutine assign_hmratio(this,other)
implicit none
type(HydroMRatio), intent(inout) :: this
type(HydroMRatio), intent(in) :: other
! Locals
character(len=40) :: sdate,stime
! Start of executable statements
if(LOC(this).EQ.LOC(other)) then
write(stderr,*) "===========================NON-FATAL=========================="
write(sdterr,*) " ( mod_hydro_mixratio/assignment(=):564, Attempted self_assignment!)"
write(stderr,*) " ( Non-Fatal Error at:) ", &
sdate(1:4),"-",sdate(5:6),"-",sdate(7:8), " ", &
stime(1:2),":",stime(3:4),":",stime(5:6)
write(stderr,*) "===========================NON-FATAL=========================="
return
end if
this%m_idx(:) = other%m_idx(:)
this%m_name = other%m_name
this%m_mratio = other%m_mratio
this%m_isbuilt = other%m_isbuilt
end subroutine
!======================================================60
! function: hmratio_neq_hmratio i.e. overloaded
! operator (/=)
! Warning: No error checking is made!!
! Both arguments should be the same i.e.
! Same arrays size.
!======================================================60
function hmratio_neq_hmratio(h1,h2) result(neq)
implicit none
type(HydroMRatio), intent(in) :: h1,h2
! Locals
logical(I64P), allocatable, dimension(:,:,:) :: neq
!DIR$ ATTRIBUTES ALIGN : 32 :: neq
! Start of executable statements
neq = h1%m_mratio /= h2%m_mratio
end function
!======================================================60
! function: hmratio_eq_hmratio i.e. overloaded
! operator (==)
! Warning: No error checking is made!!
! Both arguments should be the same i.e.
! Same arrays size.
!======================================================60
function hmratio_eq_hmratio(h1,h2) result(eq)
implicit none
type(HydroMRatio), intent(in) :: h1,h2
! Locals
logical(I64P), allocatable, dimension(:,:,:) :: eq
!DIR$ ATTRIBUTES ALIGN : 32 :: eq
! Start of executable statements
eq = h1%m_mratio == h2%m_mratio
end function
!======================================================60
! function: hmratio_gt_hmratio i.e. overloaded
! operator (>)
! Warning: No error checking is made!!
! Both arguments should be the same i.e.
! Same arrays size.
!======================================================60
function hmratio_gt_hmratio(h1,h2) result(gt)
implicit none
type(HydroMRatio), intent(in) :: h1,h2
! Locals
logical(I64P), allocatable, dimension(:,:,:) :: gt
!DIR$ ATTRIBUTES ALIGN : 32 :: gt
! Start of executable statements
gt = h1%m_mratio > h2%m_mratio
end function
!======================================================60
! function: hmratio_lt_hmratio i.e. overloaded
! operator (<)
! Warning: No error checking is made!!
! Both arguments should be the same i.e.
! Same arrays size.
!======================================================60
function hmratio_lt_hmratio(h1,h2) result(lt)
implicit none
type(HydroMRatio), intent(in) :: h1,h2
! Locals
logical(I64P), allocatable, dimension(:,:,:) :: lt
!DIR$ ATTRIBUTES ALIGN : 32 :: lt
! Start of executable statements
lt = h1%m_mratio < h2%m_mratio
end function
!======================================================60
! function: hmratio_gradient i.e.
! operator (.grad.)
! Warning: No error checking is made!!
! TODO:
! CADNA for cancellation errors?
!======================================================60
function hmratio_gradient(this) result(hgrad)
implicit none
type(HydroMRatio), intent(in) :: this
! Locals
real(R64P), allocatable, dimension(:,:,:) :: hgrad
!DIR$ ATTRIBUTES ALIGN : 32 :: hgrad
integer(I64P) :: j,k,i
!DIR$ IF (USE_LOOP_BLOCKING .EQ. 1)
integer(I64P) :: jj,kk,ii
!DIR$ ENDIF
integer(I64P), parameter :: sf = 1000000000000000_I64P
real(R64P) :: eps,tmp,isf
! Start of executable statements
associate(d1s=>this%m_ims, &
d1e=>this%m_ime, &
d2s=>this%m_kms, &
d2e=>this%m_kme, &
d3s=>this%m_jms, &
d3e=>this%m_jme )
allocate(hgrad(d1s:d1e,d2s:d2e,d3s:d3e))
end associate
hgrad = LAM_PINF
isf = 1._R64P/real(sf,R64P)
eps = MACHEPSF64*0.333333333333333333333333_R64P
!DIR$ IF (USE_LOOP_BLOCKING .EQ. 1)
do j = this%m_jts+1, this%m_jte-1, DEFAULT_BLOCK_SIZE
do k = this%m_kts+1, this%m_kte-1, DEFAULT_BLOCK_SIZE
do i = this%m_its+1, this%m_ite-1, DEFAULT_BLOCK_SIZE
do jj = j, DEFAULT_BLOCK_SIZE
do kk = k, DEFAULT_BLOCK_SIZE
do ii = i, DEFAULT_BLOCK_SIZE
!DIR$ IF (USE_SOFT_PREFETCH .EQ. 1)
call MM_PREFETCH(this%m_mratio(ii+2,kk,jj),1)
!DIR$ ENDIF
tmp = this%m_mratio(ii+1,kk+1,jj+1)- &
this%m_mratio(ii-1,kk-1,jj-1)
hgrad(ii,kk,jj) = tmp/ &
(2._R64P*eps*DMAX1(DABS(tmp),isf)*DSIGN(tmp,tmp))
end do
end do
end do
end do
end do
end do
!DIR$ ELSE
do j = this%m_jts+1, this%m_jte-1
do k = this%m_kts+1, this%m_kte-1
do i = this%m_its+1, this%m_ite-1
!DIR$ IF (USE_SOFT_PREFETCH .EQ. 1)
call MM_PREFETCH(this%m_mratio(i+2,k,j),1)
!DIR$ ENDIF
tmp = this%m_mratio(i+1,k+1,j+1)- &
this%m_mratio(i-1,k-1,j-1)
hgrad(i,k,j) = tmp/ &
(2._R64P*eps*DMAX1(DABS(tmp),isf)*DSIGN(tmp,tmp))
end do
end do
end do
!DIR$ ENDIF
end function
!======================================================60
! function: hmratio_laplacian i.e.
! operator (.laplacian.)
! Warning: No error checking is made!!
! TODO:
! CADNA for cancellation errors?
!======================================================60
function hmratio_laplacian(this) result(hlap)
implicit none
type(HydroMRatio), intent(in) :: this
! Locals
real(R64P), allocatable, dimension(:,:,:) :: hlap
!DIR$ ATTRIBUTES ALIGN : 32 :: hlap
integer(I64P) :: j,k,i
!DIR$ IF (USE_LOOP_BLOCKING .EQ. 1)
integer(I64P) :: jj,kk,ii
!DIR$ ENDIF
integer(I64P), parameter :: sf = 1000000000000000_I64P
real(R64P) :: eps,tmp,isf
! Start of executable statements
hlap = .grad.this
isf = 1._R64P/real(sf,R64P)
eps = MACHEPSF64*0.333333333333333333333333_R64P
!DIR$ IF (USE_LOOP_BLOCKING .EQ. 1)
do j = this%m_jts+1, this%m_jte-1, DEFAULT_BLOCK_SIZE
do k = this%m_kts+1, this%m_kte-1, DEFAULT_BLOCK_SIZE
do i = this%m_its+1, this%m_ite-1, DEFAULT_BLOCK_SIZE
do jj = j, DEFAULT_BLOCK_SIZE
do kk = k, DEFAULT_BLOCK_SIZE
do ii = i, DEFAULT_BLOCK_SIZE
!DIR$ IF (USE_SOFT_PREFETCH .EQ. 1)
call MM_PREFETCH(hlap(ii+2,kk,jj),1)
!DIR$ ENDIF
tmp = hlap(ii+1,kk+1,jj+1)- &
hlap(ii-1,kk-1,jj-1)
hlap(ii,kk,jj) = tmp/ &
(2._R64P*eps*DMAX1(DABS(tmp),isf)*DSIGN(tmp,tmp))
end do
end do
end do
end do
end do
end do
!DIR$ ELSE
do j = this%m_jts+1, this%m_jte-1
do k = this%m_kts+1, this%m_kte-1
do i = this%m_its+1, this%m_ite-1
!DIR$ IF (USE_SOFT_PREFETCH .EQ. 1)
call MM_PREFETCH(hlap(i+2,k,j),1)
!DIR$ ENDIF
tmp = hlap(i+1,k+1,j+1)- &
hlap(i-1,k-1,j-1)
hlap(i,k,j) = tmp/ &
(2._R64P*eps*DMAX1(DABS(tmp),isf)*DSIGN(tmp,tmp))
end do
end do
end do
!DIR$ ENDIF
end function
end module mod_hydro_mixratio | Atmosphere/module_hydro_mixratio.f90 |
! unix_inet.f90
module unix_inet
use, intrinsic :: iso_c_binding
implicit none
private
public :: c_htons
public :: c_inet_addr
interface
! uint16_t htons(uint16_t host)
function c_htons(host) bind(c, name='htons')
import :: c_int16_t
integer(kind=c_int16_t), intent(in), value :: host
integer(kind=c_int16_t) :: c_htons
end function c_htons
! in_addr_t inet_addr(const char *cp)
function c_inet_addr(cp) bind(c, name='inet_addr')
import :: c_char, c_int32_t
character(kind=c_char), intent(in) :: cp
integer(kind=c_int32_t) :: c_inet_addr
end function c_inet_addr
end interface
end module unix_inet
| src/unix_inet.f90 |
*> \brief \b DLAGTS solves the system of equations (T-λI)x = y or (T-λI)Tx = y,where T is a general tridiagonal matrix and λ a scalar, using the LU factorization computed by slagtf.
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download DLAGTS + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlagts.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlagts.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlagts.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE DLAGTS( JOB, N, A, B, C, D, IN, Y, TOL, INFO )
*
* .. Scalar Arguments ..
* INTEGER INFO, JOB, N
* DOUBLE PRECISION TOL
* ..
* .. Array Arguments ..
* INTEGER IN( * )
* DOUBLE PRECISION A( * ), B( * ), C( * ), D( * ), Y( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DLAGTS may be used to solve one of the systems of equations
*>
*> (T - lambda*I)*x = y or (T - lambda*I)**T*x = y,
*>
*> where T is an n by n tridiagonal matrix, for x, following the
*> factorization of (T - lambda*I) as
*>
*> (T - lambda*I) = P*L*U ,
*>
*> by routine DLAGTF. The choice of equation to be solved is
*> controlled by the argument JOB, and in each case there is an option
*> to perturb zero or very small diagonal elements of U, this option
*> being intended for use in applications such as inverse iteration.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] JOB
*> \verbatim
*> JOB is INTEGER
*> Specifies the job to be performed by DLAGTS as follows:
*> = 1: The equations (T - lambda*I)x = y are to be solved,
*> but diagonal elements of U are not to be perturbed.
*> = -1: The equations (T - lambda*I)x = y are to be solved
*> and, if overflow would otherwise occur, the diagonal
*> elements of U are to be perturbed. See argument TOL
*> below.
*> = 2: The equations (T - lambda*I)**Tx = y are to be solved,
*> but diagonal elements of U are not to be perturbed.
*> = -2: The equations (T - lambda*I)**Tx = y are to be solved
*> and, if overflow would otherwise occur, the diagonal
*> elements of U are to be perturbed. See argument TOL
*> below.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The order of the matrix T.
*> \endverbatim
*>
*> \param[in] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (N)
*> On entry, A must contain the diagonal elements of U as
*> returned from DLAGTF.
*> \endverbatim
*>
*> \param[in] B
*> \verbatim
*> B is DOUBLE PRECISION array, dimension (N-1)
*> On entry, B must contain the first super-diagonal elements of
*> U as returned from DLAGTF.
*> \endverbatim
*>
*> \param[in] C
*> \verbatim
*> C is DOUBLE PRECISION array, dimension (N-1)
*> On entry, C must contain the sub-diagonal elements of L as
*> returned from DLAGTF.
*> \endverbatim
*>
*> \param[in] D
*> \verbatim
*> D is DOUBLE PRECISION array, dimension (N-2)
*> On entry, D must contain the second super-diagonal elements
*> of U as returned from DLAGTF.
*> \endverbatim
*>
*> \param[in] IN
*> \verbatim
*> IN is INTEGER array, dimension (N)
*> On entry, IN must contain details of the matrix P as returned
*> from DLAGTF.
*> \endverbatim
*>
*> \param[in,out] Y
*> \verbatim
*> Y is DOUBLE PRECISION array, dimension (N)
*> On entry, the right hand side vector y.
*> On exit, Y is overwritten by the solution vector x.
*> \endverbatim
*>
*> \param[in,out] TOL
*> \verbatim
*> TOL is DOUBLE PRECISION
*> On entry, with JOB .lt. 0, TOL should be the minimum
*> perturbation to be made to very small diagonal elements of U.
*> TOL should normally be chosen as about eps*norm(U), where eps
*> is the relative machine precision, but if TOL is supplied as
*> non-positive, then it is reset to eps*max( abs( u(i,j) ) ).
*> If JOB .gt. 0 then TOL is not referenced.
*>
*> On exit, TOL is changed as described above, only if TOL is
*> non-positive on entry. Otherwise TOL is unchanged.
*> \endverbatim
*>
*> \param[out] INFO
*> \verbatim
*> INFO is INTEGER
*> = 0 : successful exit
*> .lt. 0: if INFO = -i, the i-th argument had an illegal value
*> .gt. 0: overflow would occur when computing the INFO(th)
*> element of the solution vector x. This can only occur
*> when JOB is supplied as positive and either means
*> that a diagonal element of U is very small, or that
*> the elements of the right-hand side vector y are very
*> large.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date September 2012
*
*> \ingroup auxOTHERauxiliary
*
* =====================================================================
SUBROUTINE DLAGTS( JOB, N, A, B, C, D, IN, Y, TOL, INFO )
*
* -- LAPACK auxiliary routine (version 3.4.2) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* September 2012
*
* .. Scalar Arguments ..
INTEGER INFO, JOB, N
DOUBLE PRECISION TOL
* ..
* .. Array Arguments ..
INTEGER IN( * )
DOUBLE PRECISION A( * ), B( * ), C( * ), D( * ), Y( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ONE, ZERO
PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
* ..
* .. Local Scalars ..
INTEGER K
DOUBLE PRECISION ABSAK, AK, BIGNUM, EPS, PERT, SFMIN, TEMP
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, MAX, SIGN
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH
EXTERNAL DLAMCH
* ..
* .. External Subroutines ..
EXTERNAL XERBLA
* ..
* .. Executable Statements ..
*
INFO = 0
IF( ( ABS( JOB ).GT.2 ) .OR. ( JOB.EQ.0 ) ) THEN
INFO = -1
ELSE IF( N.LT.0 ) THEN
INFO = -2
END IF
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'DLAGTS', -INFO )
RETURN
END IF
*
IF( N.EQ.0 )
$ RETURN
*
EPS = DLAMCH( 'Epsilon' )
SFMIN = DLAMCH( 'Safe minimum' )
BIGNUM = ONE / SFMIN
*
IF( JOB.LT.0 ) THEN
IF( TOL.LE.ZERO ) THEN
TOL = ABS( A( 1 ) )
IF( N.GT.1 )
$ TOL = MAX( TOL, ABS( A( 2 ) ), ABS( B( 1 ) ) )
DO 10 K = 3, N
TOL = MAX( TOL, ABS( A( K ) ), ABS( B( K-1 ) ),
$ ABS( D( K-2 ) ) )
10 CONTINUE
TOL = TOL*EPS
IF( TOL.EQ.ZERO )
$ TOL = EPS
END IF
END IF
*
IF( ABS( JOB ).EQ.1 ) THEN
DO 20 K = 2, N
IF( IN( K-1 ).EQ.0 ) THEN
Y( K ) = Y( K ) - C( K-1 )*Y( K-1 )
ELSE
TEMP = Y( K-1 )
Y( K-1 ) = Y( K )
Y( K ) = TEMP - C( K-1 )*Y( K )
END IF
20 CONTINUE
IF( JOB.EQ.1 ) THEN
DO 30 K = N, 1, -1
IF( K.LE.N-2 ) THEN
TEMP = Y( K ) - B( K )*Y( K+1 ) - D( K )*Y( K+2 )
ELSE IF( K.EQ.N-1 ) THEN
TEMP = Y( K ) - B( K )*Y( K+1 )
ELSE
TEMP = Y( K )
END IF
AK = A( K )
ABSAK = ABS( AK )
IF( ABSAK.LT.ONE ) THEN
IF( ABSAK.LT.SFMIN ) THEN
IF( ABSAK.EQ.ZERO .OR. ABS( TEMP )*SFMIN.GT.ABSAK )
$ THEN
INFO = K
RETURN
ELSE
TEMP = TEMP*BIGNUM
AK = AK*BIGNUM
END IF
ELSE IF( ABS( TEMP ).GT.ABSAK*BIGNUM ) THEN
INFO = K
RETURN
END IF
END IF
Y( K ) = TEMP / AK
30 CONTINUE
ELSE
DO 50 K = N, 1, -1
IF( K.LE.N-2 ) THEN
TEMP = Y( K ) - B( K )*Y( K+1 ) - D( K )*Y( K+2 )
ELSE IF( K.EQ.N-1 ) THEN
TEMP = Y( K ) - B( K )*Y( K+1 )
ELSE
TEMP = Y( K )
END IF
AK = A( K )
PERT = SIGN( TOL, AK )
40 CONTINUE
ABSAK = ABS( AK )
IF( ABSAK.LT.ONE ) THEN
IF( ABSAK.LT.SFMIN ) THEN
IF( ABSAK.EQ.ZERO .OR. ABS( TEMP )*SFMIN.GT.ABSAK )
$ THEN
AK = AK + PERT
PERT = 2*PERT
GO TO 40
ELSE
TEMP = TEMP*BIGNUM
AK = AK*BIGNUM
END IF
ELSE IF( ABS( TEMP ).GT.ABSAK*BIGNUM ) THEN
AK = AK + PERT
PERT = 2*PERT
GO TO 40
END IF
END IF
Y( K ) = TEMP / AK
50 CONTINUE
END IF
ELSE
*
* Come to here if JOB = 2 or -2
*
IF( JOB.EQ.2 ) THEN
DO 60 K = 1, N
IF( K.GE.3 ) THEN
TEMP = Y( K ) - B( K-1 )*Y( K-1 ) - D( K-2 )*Y( K-2 )
ELSE IF( K.EQ.2 ) THEN
TEMP = Y( K ) - B( K-1 )*Y( K-1 )
ELSE
TEMP = Y( K )
END IF
AK = A( K )
ABSAK = ABS( AK )
IF( ABSAK.LT.ONE ) THEN
IF( ABSAK.LT.SFMIN ) THEN
IF( ABSAK.EQ.ZERO .OR. ABS( TEMP )*SFMIN.GT.ABSAK )
$ THEN
INFO = K
RETURN
ELSE
TEMP = TEMP*BIGNUM
AK = AK*BIGNUM
END IF
ELSE IF( ABS( TEMP ).GT.ABSAK*BIGNUM ) THEN
INFO = K
RETURN
END IF
END IF
Y( K ) = TEMP / AK
60 CONTINUE
ELSE
DO 80 K = 1, N
IF( K.GE.3 ) THEN
TEMP = Y( K ) - B( K-1 )*Y( K-1 ) - D( K-2 )*Y( K-2 )
ELSE IF( K.EQ.2 ) THEN
TEMP = Y( K ) - B( K-1 )*Y( K-1 )
ELSE
TEMP = Y( K )
END IF
AK = A( K )
PERT = SIGN( TOL, AK )
70 CONTINUE
ABSAK = ABS( AK )
IF( ABSAK.LT.ONE ) THEN
IF( ABSAK.LT.SFMIN ) THEN
IF( ABSAK.EQ.ZERO .OR. ABS( TEMP )*SFMIN.GT.ABSAK )
$ THEN
AK = AK + PERT
PERT = 2*PERT
GO TO 70
ELSE
TEMP = TEMP*BIGNUM
AK = AK*BIGNUM
END IF
ELSE IF( ABS( TEMP ).GT.ABSAK*BIGNUM ) THEN
AK = AK + PERT
PERT = 2*PERT
GO TO 70
END IF
END IF
Y( K ) = TEMP / AK
80 CONTINUE
END IF
*
DO 90 K = N, 2, -1
IF( IN( K-1 ).EQ.0 ) THEN
Y( K-1 ) = Y( K-1 ) - C( K-1 )*Y( K )
ELSE
TEMP = Y( K-1 )
Y( K-1 ) = Y( K )
Y( K ) = TEMP - C( K-1 )*Y( K )
END IF
90 CONTINUE
END IF
*
* End of DLAGTS
*
END
| Ipopt-3.12.9/ThirdParty/Lapack/dlagts.f |
! This is a test program that CMake uses to check that the Fortran compiler is
! working.
PROGRAM TESTFortran
PRINT *, 'Hello'
END
| integration_tests/program_cmake_01.f90 |
SUBROUTINE SI_TMST ( isffln, dattim, stid, addstn, slat, slon,
+ iret )
C************************************************************************
C* SI_TMST *
C* *
C* This subroutine sets the time and station in a surface data file. *
C* A station not already in the file will be added only if ADDSTN is *
C* set. A time not already in the file will be added. *
C* *
C* SI_TMST ( ISFFLN, DATTIM, STID, ADDSTN, SLAT, SLON, IRET ) *
C* *
C* Input parameters: *
C* ISFFLN INTEGER Sounding file number *
C* DATTIM CHAR*15 Nominal date/time *
C* STID CHAR* Station identifier *
C* ADDSTN LOGICAL Add station flag *
C* SLAT REAL Latitue *
C* SLON REAL Longitude *
C* *
C* Output parameters: *
C* IRET INTEGER Return code *
C* 0 = normal return *
C* -3 = time cannot be set *
C* -4 = station cannot be set *
C** *
C* Log: *
C* T. Lee/SAIC 8/02 Created
C************************************************************************
INCLUDE 'GEMPRM.PRM'
C*
CHARACTER*(*) dattim, stid
LOGICAL addstn
C*
CHARACTER stat*4, coun*4
C*
DATA stat, coun / 2 * '--' /
DATA selv / 0. /
C------------------------------------------------------------------------
iret = 0
ispri = 0
C
C* Find the time in the file.
C
CALL SF_FTIM ( isffln, dattim, iret )
C
C* If time is not found, add time.
C
IF ( iret .ne. 0 ) THEN
CALL SF_ATIM ( isffln, dattim, iret )
IF ( iret .eq. 0 ) THEN
CALL SF_FTIM ( isffln, dattim, ier )
ELSE
iret = -3
RETURN
END IF
END IF
C
C* Find the station.
C
CALL SF_FSTN ( isffln, stid, iret )
C
C* If station is not found, add to file.
C
IF ( ( iret .ne. 0 ) .and. ( addstn ) ) THEN
CALL ST_NUMB ( stid, istnum, iret )
CALL ST_LSTR ( stid, istr, iret )
IF ( istr .eq. 3 ) stid = '0' // stid
CALL SF_ASTN ( isffln, 1, stid, istnum, slat, slon, selv,
+ stat, coun, ispri, nadd, iret )
IF ( iret .eq. 0 ) THEN
CALL SF_FSTN ( isffln, stid, ier )
ELSE
iret = -4
RETURN
END IF
END IF
C*
RETURN
END
| gempak/source/bridge/si/sitmst.f |
double complex function cdotpr(J1,J2)
implicit none
double complex J1(4),J2(4)
cdotpr=J1(4)*J2(4)-J1(1)*J2(1)-J1(2)*J2(2)-J1(3)*J2(3)
return
end
| MCFM-JHUGen/src/Need/cdotpr.f |
module tools
use mpi
implicit none
contains
!*****************************************************************************!
function cross(a, b)
real(8),dimension(3) :: cross
real(8),dimension(3),intent(in) :: a, b
cross(1) = a(2) * b(3) - a(3) * b(2)
cross(2) = a(3) * b(1) - a(1) * b(3)
cross(3) = a(1) * b(2) - a(2) * b(1)
end function cross
!*****************************************************************************!
function dot(a, b)
real(8) :: dot
real(8),dimension(3),intent(in) :: a, b
dot = a(1)*b(1) + a(2)*b(2) + a(3)*b(3)
end function dot
!*****************************************************************************!
function dot3d(a, b)
real(8) :: dot3d
real(8),dimension(3),intent(in) :: a, b
dot3d = a(1)*b(1) + a(2)*b(2) + a(3)*b(3)
end function dot3d
!*****************************************************************************!
function norm3d(a)
real(8) :: norm3d
real(8),dimension(3),intent(in) :: a
norm3d = sqrt(a(1)**2 + a(2)**2 + a(3)**2)
end function norm3d
!*****************************************************************************!
subroutine gaussQuadrature(t,w,npts)
implicit none
integer,intent(in) :: npts
real(8),intent(out) :: t(:),w(:)
! allocate(t(1:npts))
! allocate(w(1:npts))
if (npts==1) then
t(1) = 0.0d0
w(1) = 2.0d0
elseif (npts==2) then
t(1) = -1.0d0/sqrt(3.0d0)
t(2) = -t(1)
w(1) = 1.0d0
w(2) = w(1)
elseif (npts==3) then
t(1) = 0.000000000000000d0
t(2) = 0.774596669241483d0
t(3) = -t(2)
w(1) = 0.888888888888889d0
w(2) = 0.555555555555556d0
w(3) = w(2)
elseif (npts==4) then
t(1) = 0.339981043584856d0
t(2) = 0.861136311594053d0
t(3:4) = -t(1:2)
w(1) = 0.652145154862546d0
w(2) = 0.347854845137454d0
w(3:4) = w(1:2)
elseif (npts==5) then
t(1) = 0.000000000000000d0
t(2) = 0.538469310105683d0
t(3) = 0.906179845938664d0
t(4:5) = -t(2:3)
w(1) = 0.568888888888889d0
w(2) = 0.478628670499366d0
w(3) = 0.236926885056189d0
w(4:5) = w(2:3)
elseif (npts==6) then
t(1) = 0.238619186083197d0
t(2) = 0.661209386466265d0
t(3) = 0.932469514203152d0
t(4:6) = -t(1:3)
w(1) = 0.467913934572691d0
w(2) = 0.360761573048139d0
w(3) = 0.171324492379170d0
w(4:6) = w(1:3)
elseif (npts==7) then
t(1) = 0.000000000000000d0
t(2) = 0.405845151377397d0
t(3) = 0.741531185599394d0
t(4) = 0.949107912342759d0
t(5:7) = -t(2:4)
w(1) = 0.417959183673469d0
w(2) = 0.381830050505119d0
w(3) = 0.279705391489277d0
w(4) = 0.129484966168870d0
w(5:7) = w(2:4)
elseif(npts ==8) then
t(1) = 0.183434642495650d0
t(2) = 0.525532409916329d0
t(3) = 0.796666477413627d0
t(4) = 0.960289856497536d0
t(5:8) = -t(1:4)
w(1) = 0.362683783378362d0
w(2) = 0.313706645877887d0
w(3) = 0.222381034453374d0
w(4) = 0.101228536290376d0
w(5:8) = w(1:4)
endif
return
end subroutine gaussQuadrature
!*****************************************************************************!
subroutine gaussQuadratureTriangles(V,wei,nQ)
implicit none
integer,intent(in) :: nQ
real(8),intent(out) :: V(:,:),wei(:)
if (nQ==3) then
V(1,:) = (/ 4.0d0, 1.0d0, 1.0d0 /)
V(2,:) = (/ 1.0d0, 4.0d0, 1.0d0 /)
V(3,:) = (/ 1.0d0, 1.0d0, 4.0d0 /)
V = V/6.0d0
wei =1.0d0/3.0d0
elseif (nQ==4) then
V(1,:) = (/0.33333333d0, 0.33333333d0, 0.33333333d0/)
V(2,:) = (/0.60000000d0, 0.20000000d0, 0.20000000d0/)
V(3,:) = (/0.20000000d0, 0.60000000d0, 0.20000000d0/)
V(4,:) = (/0.20000000d0, 0.20000000d0, 0.60000000d0/)
wei = (/-0.56250000d0,0.52083333d0,0.52083333d0,0.52083333d0/)
elseif (nQ==6) then
V(1,:) = (/ 0.10810301d0, 0.44594849d0, 0.44594849d0 /)
V(2,:) = (/ 0.44594849d0, 0.10810301d0, 0.44594849d0 /)
V(3,:) = (/ 0.44594849d0, 0.44594849d0, 0.10810301d0 /)
V(4,:) = (/ 0.81684757d0, 0.09157621d0, 0.09157621d0 /)
V(5,:) = (/ 0.09157621d0, 0.81684757d0, 0.09157621d0 /)
V(6,:) = (/ 0.09157621d0, 0.09157621d0, 0.81684757d0 /)
wei = (/0.22338158d0,0.22338158d0,0.22338158d0,0.10995174d0,0.10995174d0,0.10995174d0/)
elseif (nQ==7) then
V(1,:) = (/ 0.33333333d0, 0.33333333d0, 0.33333333d0 /)
V(2,:) = (/ 0.05971587d0, 0.47014206d0, 0.47014206d0 /)
V(3,:) = (/ 0.47014206d0, 0.05971587d0, 0.47014206d0 /)
V(4,:) = (/ 0.47014206d0, 0.47014206d0, 0.05971587d0 /)
V(5,:) = (/ 0.79742698d0, 0.10128650d0, 0.10128650d0 /)
V(6,:) = (/ 0.10128650d0, 0.79742698d0, 0.10128650d0 /)
V(7,:) = (/ 0.10128650d0, 0.10128650d0, 0.79742698d0 /)
wei = (/0.22500000d0,0.13239415d0,0.13239415d0,0.13239415d0,0.12593918d0,0.12593918d0,0.12593918d0/)
endif
return
end subroutine gaussQuadratureTriangles
!*****************************************************************************!
subroutine divide_work(start,finish,n_size)
implicit none
integer :: ierr , n_procs , id , lWork
integer, intent(out) :: start , finish
integer, intent(in) :: n_size
!---------------------------------------------!
call mpi_comm_size(MPI_COMM_WORLD,N_procs,ierr)
call mpi_comm_rank(MPI_COMM_WORLD,id,ierr)
lWork = n_size / n_procs
start = 1+id*lWork
finish = (id+1)*lWork
if (id == N_procs-1) then
finish = n_size
endif
return
end subroutine divide_work
end module
| src/BEMExtra/tools.f90 |
! ###################################################################
! # HDF5 hands on #
! # Created : April 2011 #
! # #
! # Author: #
! # Matthieu Haefele #
! # [email protected] #
! # High Level Support Team (HLST) #
! # Max-Planck Institut fuer Plasmaphysik #
! # #
! ###################################################################
PROGRAM PHDF5_EX
USE HDF5
use mpi
IMPLICIT NONE
CHARACTER(LEN=10), PARAMETER :: filename = "example.h5" ! File name
CHARACTER(LEN=8), PARAMETER :: dsetname = "IntArray" ! Dataset name
CHARACTER(LEN=15) :: obj_name
INTEGER, PARAMETER :: rank = 2
INTEGER, PARAMETER :: NX = 16
INTEGER, PARAMETER :: NY = 32
INTEGER(HID_T) :: file, dataset, dataspace, filespace, memspace, plist_id1, plist_id2
INTEGER(HSIZE_T), DIMENSION(2) :: dims, start, el_count
INTEGER :: status
INTEGER, DIMENSION(:,:), allocatable :: dat
INTEGER :: i,j,var_nx, var_ny, size_x, size_y, offset_x, offset_y
integer :: mpi_id, size, ierr
CALL MPI_INIT( ierr )
CALL MPI_COMM_RANK( MPI_COMM_WORLD, mpi_id, ierr )
CALL MPI_COMM_SIZE( MPI_COMM_WORLD, size, ierr )
if(size .ne. 1 .and. size .ne. 4 .and. size .ne. 16) then
if(mpi_id==0) then
print*, "Error: Authorized number of process is 1, 4 or 16, exiting..."
end if
call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
end if
var_nx = NX
var_ny = NY
call init(var_nx, var_ny, mpi_id, size, size_x, size_y, offset_x, offset_y, dat)
!
! Initialize FORTRAN predefined datatypes.
!
CALL h5open_f(status)
!HDF5 file creation
CALL h5pcreate_f(H5P_FILE_ACCESS_F, plist_id1, status)
CALL h5pset_fapl_mpio_f(plist_id1, MPI_COMM_WORLD, MPI_INFO_NULL, status)
CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file, status, access_prp = plist_id1)
!Dataspace creation
dims(1) = NX
dims(2) = NY
CALL h5screate_simple_f(rank, dims, dataspace, status)
!Dataset creation
CALL h5dcreate_f(file, dsetname, H5T_NATIVE_INTEGER, dataspace, &
dataset, status)
!Actual data IO
CALL h5pcreate_f (H5P_DATASET_XFER_F, plist_id2, status)
CALL h5pset_dxpl_mpio_f (plist_id2, H5FD_MPIO_COLLECTIVE_F, status)
el_count(1) = size_x
el_count(2) = size_y
start(1) = offset_x
start(2) = offset_y
CALL h5screate_simple_f(rank, el_count, memspace, status)
CALL h5screate_simple_f(rank, dims, filespace, status)
CALL H5sselect_hyperslab_f(filespace, H5S_SELECT_SET_F, start, el_count, status)
CALL h5dwrite_f(dataset, H5T_NATIVE_INTEGER, dat, el_count, status, &
mem_space_id=memspace, file_space_id=filespace, xfer_prp = plist_id2)
!Closing all opened HDF5 objects
CALL h5dclose_f(dataset, status)
CALL h5sclose_f(dataspace, status)
CALL h5sclose_f(filespace, status)
CALL h5sclose_f(memspace, status)
CALL h5fclose_f(file, status)
CALL h5close_f(status)
CALL MPI_FINALIZE(ierr)
contains
subroutine init(NX, NY, mpi_id, size, size_x, size_y, offset_x, offset_y , dat)
integer, intent(in) :: NX, NY, mpi_id, size
integer, intent(out) :: size_x, size_y, offset_x, offset_y
integer :: i,j
integer, dimension(:,:), allocatable :: dat
integer :: nb_proc_per_dim
nb_proc_per_dim = int(sqrt(real(size)))
size_x = NX/nb_proc_per_dim
size_y = NY/nb_proc_per_dim
offset_x = mod(mpi_id,nb_proc_per_dim) * size_x
offset_y = int(mpi_id/nb_proc_per_dim) * size_y
allocate(dat(size_x,size_y))
do j=1, size_y
do i=1, size_x
dat(i,j) = i+offset_x-1 + (j+offset_y-1)*NX;
end do
end do
end subroutine init
END PROGRAM PHDF5_EX
| phdf5-3/F90/solution/phdf5_ex3.f90 |
The TMobile Wireless store is now at a new convenient location, located across the street from the Regal Cinemas Davis Holiday 6 Regal Cinema on F street. TMobile has no contract plans and is great for students! They also have many other plans to choose from and a large selection of phones on display.
| lab/davisWiki/T-Mobile.f |
program test_hwm
!! https://map.nrl.navy.mil/map/pub/nrl/HWM/HWM14/HWM14_ess224-sup-0002-supinfo/README.txt
use hwm_interface, only : hwm_14, dwm_07
implicit none (type, external)
integer :: day = 150
real :: &
utsec = 12 * 3600, &
alt_km = 400., &
glat = -45.0, &
glon = -85.0, &
Ap = 80.0
real :: Wmeridional, Wzonal, Dw(2)
call hwm_14(day, utsec, alt_km, glat, glat, Ap, Wmeridional, Wzonal)
if (abs(Wmeridional - (-34.1767464)) > 0.001) error stop 'Wmeridional'
if (abs(Wzonal - (-64.3156433)) > 0.001) error stop 'Wzonal'
call dwm_07(day, utsec, alt_km, glat, glat, Ap, Dw)
if (abs(DW(1)-(24.6438866)) > 0.001) error stop 'Dw(1)'
if (abs(DW(2)-(-10.9287968)) > 0.001) error stop 'Dw(2)'
print *, "OK: HWM14"
end program
| src/vendor/nrl_hwm/test_hwm.f90 |
SUBROUTINE CMP3SET(IM,NC3,DT,IMOVER2,IMOVER4,NDT,UT,VT,TT,
* QTDELTA,FRY, HSOLCO2, HSOLDST, HTH15, HTHOUT,
* HCONADJ, HTURBO, HRINUM, FCONADJ, FTURBO,
* FRINUM, FRAYFR, HRAYFR, DISRAY, CO2LAT,QCDEL)
! Legacy Mars GCM v24
! Mars Climate Modeling Center
! NASA Ames Research Center
C PURPOSE:
C CMP3SET PERFORMS LOOP INITILIZATION FOR THE LARGE ATMOSPHERIC
C TEMPERATURE CALCULATION LOOP IN COMP3.
C AUTHOR
C STEVE POHORSKY INFORMATICS TASK 605 OCT 81
C FOR
C JIM POLLACK
C ENVIRONMENT
C Cray-2 UNICOS 3.0 FORTRAN
C REVISION HISTORY
C
C OUTPUT PARAMETERS
C UT, VT, & TT ARRAYS, AND VARIABLES IN LOOPVAL COMMON BLOCK
C ARE INITIALIZED.
C
C CALLED BY
C COMP3
C
use grid_h
use defines_h
implicit none
C######################################################################
C
REAL*8 :: NDT
REAL*8 :: UT(L_JSIZE,L_ISIZE,L_LAYERS)
REAL*8 :: VT(L_JSIZE,L_ISIZE,L_LAYERS)
REAL*8 :: TT(L_JSIZE,L_ISIZE,L_LAYERS)
REAL*8 :: QTDELTA(L_JSIZE,L_ISIZE,L_LAYERS,NTRACE)
REAL*8 :: QCDEL(L_JSIZE,L_ISIZE,NTRACE)
real*8 :: FRY(L_JSIZE,L_LAYERS)
real*8 :: HSOLCO2(L_JSIZE,L_LAYERS)
real*8 :: HSOLDST(L_JSIZE,L_LAYERS)
real*8 :: HTH15(L_JSIZE,L_LAYERS)
real*8 :: HTHOUT(L_JSIZE,L_LAYERS)
real*8 :: HCONADJ(L_JSIZE,L_LAYERS)
real*8 :: HTURBO(L_JSIZE,L_LAYERS)
real*8 :: HRINUM(L_JSIZE,L_LAYERS)
real*8 :: FCONADJ(L_JSIZE,L_LAYERS)
real*8 :: FTURBO(L_JSIZE,L_LAYERS)
real*8 :: FRINUM(L_JSIZE,L_LAYERS)
real*8 :: FRAYFR(L_JSIZE,L_LAYERS)
real*8 :: HRAYFR(L_JSIZE,L_LAYERS)
real*8 :: DISRAY(L_JSIZE,L_LAYERS)
real*8 :: CO2LAT(L_JSIZE,L_LAYERS)
! implicit none
integer :: I, J, L, M, IM, JM, IMOVER2, IMOVER4, NC3
real*8 :: DT
C=======================================================================
IMOVER2 = IM/2
IMOVER4 = IM/4
C Atmospheric temperature calculation time step
NDT = FLOAT(NC3)*DT
C ZERO LARGE ARRAYS.
DO L=1,L_LAYERS
DO J=1,L_JSIZE
DO I=1,L_ISIZE
UT(J,I,L) = 0.0
VT(J,I,L) = 0.0
TT(J,I,L) = 0.0
DO M = 1,NTRACE
QTDELTA(J,I,L,M) = 0.0
END DO
END DO
END DO
END DO
DO J=1,L_JSIZE
DO I=1,L_ISIZE
DO M = 1,NTRACE
QCDEL(J,I,M) = 0.0D0
END DO
END DO
END DO
C
C Set the (J,L) arrays to zero each time through COMP3.
C
DO 1030 L=1,L_LAYERS
DO 1010 J=1,L_JSIZE
FRY(J,L) = 0.0
HSOLCO2(J,L) = 0.0
HSOLDST(J,L) = 0.0
HTH15(J,L) = 0.0
HTHOUT(J,L) = 0.0
HCONADJ(J,L) = 0.0
HTURBO(J,L) = 0.0
HRINUM(J,L) = 0.0
FCONADJ(J,L) = 0.0
FTURBO(J,L) = 0.0
FRINUM(J,L) = 0.0
FRAYFR(J,L) = 0.0
HRAYFR(J,L) = 0.0
DISRAY(J,L) = 0.0
CO2LAT(J,L) = 0.0
1010 CONTINUE
1030 CONTINUE
3900 CONTINUE
RETURN
END
| code/cmp3set.f |
! { dg-do run }
! Short test program with a CASE statement that uses a range.
!
program select_4
integer i
do i = 1, 34, 4
select case(i)
case (:5)
if (i /= 1 .and. i /= 5) STOP 1
case (13:21)
if (i /= 13 .and. i /= 17 .and. i /= 21) STOP 2
case (29:)
if (i /= 29 .and. i /= 33) STOP 3
case default
if (i /= 9 .and. i /= 25) STOP 4
end select
end do
end program select_4
| validation_tests/llvm/f18/gfortran.dg/select_3.f90 |
! RUN: %python %S/test_errors.py %s %flang_fc1
! C1131 -- check valid and invalid DO loop naming
PROGRAM C1131
IMPLICIT NONE
! Valid construct
validDo: DO WHILE (.true.)
PRINT *, "Hello"
END DO ValidDo
! Missing name on END DO
missingEndDo: DO WHILE (.true.)
PRINT *, "Hello"
!ERROR: DO construct name required but missing
END DO
! Missing name on DO
DO WHILE (.true.)
PRINT *, "Hello"
!ERROR: DO construct name unexpected
END DO missingDO
END PROGRAM C1131
| flang/test/Semantics/dosemantics01.f90 |
PROGRAM OSCMGO
C
C PLOT RESULTS OF OSCARS RUNS WHICH HAVE BEEN STORED IN FOR008
C SAME AS OSCPLT EXCEPT USES MONGO
C
COMMON /PPAK/ XMIN,XMAX,DELX,YMIN,YMAX,DELY,FILFAC
COMMON /PLTBLK/ PLT(200,10)
C
COMMON /MONGOPAR/
1 X1,X2,Y1,Y2,GX1,GX2,GY1,GY2,LX1,LX2,LY1,LY2,
1 GX,GY,CX,CY,
1 EXPAND,ANGLE,LTYPE,LWEIGHT,
1 CHEIGHT,CWIDTH,CXDEF,CYDEF,PXDEF,PYDEFF,COFFMGO,
1 TERMOUT,XYSWAPPED,NUMDEV,
1 PIMGO,USERVAR(10),AUTODOT
C
CHARACTER*30 CH(30)
CHARACTER*1 DISPOSE
DIMENSION RATIOM(10),DENS(10),BETAZ(10),TPAR(10),TPERP(10)
DIMENSION XX(900),YY(900),ZZ(900),SYM(900)
C
OPEN(UNIT=8,FILE='FOR008.DAT',TYPE='OLD',READONLY)
C OPEN(UNIT=8,FILE='FOR008.DAT;2',TYPE='OLD',READONLY)
XMIN = 0.
XMAX = 0.
YMIN = 0.
YMAX = 0.
N = 0
READ (8,105) WR,WI,WCYCL,XKX,XKZ,RW,RKX,RKZ,NC,KIT,MODE
READ (8,101)(RATIOM(I),DENS(I),BETAZ(I),TPAR(I),TPERP(I),I=1,NC)
WCI = WCYCL/RATIOM(2)
C
PRINT*,'MODE=',MODE
IF(MODE.GT.6) GO TO 50
IF(MODE.LE.2) GO TO 30
C
C READ IN THE DATA FROM A FILE FOR008.DAT
C
10 READ (8,361,END=20) WR,WI,DML,DTR,DTI,XKX,XKZ
C print 361, WR,WI,DML,DTR,DTI,XKX,XKZ
N = N+1
C THE FOLLOWING SET IS FOR RADIUS PROP. TO. WR, DIRECTION OF K
C I.E.
XK = SQRT(XKX**2 + XKZ**2)
PLT(N,5) = WR*XKX/XK**2
PLT(N,6) = WR*XKZ/XK**2
C THE FOLLOWING SET IS FOR RADIUS PROP. TO. WI, DIRECTION OF K
PLT(N,7) = -WI*XKX/XK**2
PLT(N,8) = -WI*XKZ/XK**2
C THE FOLLOWING IS FOR KX VS KZ
C XX(N) =XKX
C YY(N) = XKZ
C SYM(N) = DTR
C YMIN = AMIN1(YMIN,YY(N))
C YMAX = AMAX1(YMAX,YY(N))
C XMIN = AMIN1(XX(N),XMIN)
C XMAX = AMAX1(XX(N),XMAX)
GO TO 10
C
20 CONTINUE
CALL OSCAMG(5)
C CALL OSCAMG(6)
TYPE*,'STOP JUST AFTER 20 CONTINUE'
READ(5,107) DISPOSE
IF(1) STOP
C
C PLOT MODE = 1 OR 2, W VS MAG(K)
C
C
C READ IN THE DATA FROM A FILE FOR008.DAT
C
30 READ (8,361,END=40) WR,WI,DML,DTR,DTI,XKX,XKZ
C print 361, WR,WI,DML,DTR,DTI,XKX,XKZ
N = N+1
C THE FOLLOWING SET IS FOR RADIUS PROP. TO. WR, DIRECTION OF K
C I.E.
XK = SQRT(XKX**2 + XKZ**2)
PLT(N,5) = WR
PLT(N,6) = WI
PLT(N,7) = XK
NPLT = N
TEMP = ABS(YMIN)
NTEMP = TEMP
TEMP = NTEMP+1
GO TO 30
40 PRINT*,'AT 40,NPLT',NPLT
c XMAX = AMAX1(ABS(YMAX),ABS(YMIN),ABS(XMAX))
C YMIN = -YMAX
c YMIN = 0.
c DELX = .1E-6
c xmin = 0.
c xmax = .9e-6
c ymax = xmax
c xmax = 1.143*xmax
c FILFAC = 1.
c DELY = DELX
C PRINT*,(XX(I),YY(I),I=1,NPLT)
C
C FILL IN SO MONGO DOESNT PLOT ZEROS
C
DO N = NPLT+1,200
PLT(N,5) = PLT(N-1,5)
PLT(N,6) = PLT(N-1,6)
PLT(N,7) = PLT(N-1,7)
ENDDO
NCH = 1
CH(NCH) = 'PRINTER 1'
NCH = NCH+1
CH(NCH) = 'ERASE'
NCH = NCH+1
CH(NCH) = 'WINDOW 1 2 1'
NCH = NCH+1
CH(NCH) = 'XCOLUMN 7'
NCH = NCH+1
CH(NCH) = 'YCOLUMN 5'
NCH = NCH+1
CH(NCH) = 'LIMITS'
NCH = NCH+1
CH(NCH) = 'CONNECT'
NCH = NCH+1
CH(NCH) = 'BOX'
NCH = NCH+1
CH(NCH) = 'XLABEL k c /wpe'
NCH = NCH+1
CH(NCH) = 'YLABEL Re(w)/wpe'
NCH = NCH+1
CH(NCH) = 'WINDOW 1 2 2'
NCH = NCH+1
CH(NCH) = 'XCOLUMN 7'
NCH = NCH+1
CH(NCH) = 'YCOLUMN 6'
NCH = NCH+1
CH(NCH) = 'LIMITS'
NCH = NCH+1
CH(NCH) = 'CONNECT'
NCH = NCH+1
CH(NCH) = 'BOX'
NCH = NCH+1
CH(NCH) = 'XLABEL k c /wpe'
NCH = NCH+1
CH(NCH) = 'yLABEL Im(w)/wpe'
NCH = NCH+1
CH(NCH) = 'ID'
NCH = NCH+1
CH(NCH) = 'HARDCOPY'
NCH = NCH+1
CH(NCH) = 'END'
C PRINT*,(CH(N),N=1,NCH)
CALL MONGO(NCH,CH,200,10,PLT)
105 FORMAT(8E12.5,3I3)
106 FORMAT(5F10.5,3F5.3,3I2)
101 FORMAT(5E12.4)
107 FORMAT(A)
361 FORMAT (1X,E12.6 ',' E10.3,1X,F8.3,F8.3,',',F7.3,E12.4 ',' E11.4)
TYPE *,'STOP AFTER 361'
READ(5,107) DISPOSE
STOP
C
C READ IN THE DATA FROM A FILE FOR008.DAT--MODE GT 6
C
50 READ (8,361,END=60) WR,WI,DML,DTR,DTI,XKX,XKZ
N = N+1
PRINT*,N,WR,WI,XKX,XKZ
XX(N) = XKX
YY(N) = XKZ
ZZ(N) = WI
XK = SQRT(XKX**2 + XKZ**2)
PLT(N,3) = XKX
PLT(N,4) = XKZ
PLT(N,5) = WR*XKX/XK**2
PLT(N,6) = WR*XKZ/XK**2
C THE FOLLOWING SET IS FOR RADIUS PROP. TO. WI, DIRECTION OF K
PLT(N,7) = -WI*XKX/XK**2
PLT(N,8) = -WI*XKZ/XK**2
C YMAX = AMAX1(YMAX,YY(N))
C XMAX = AMAX1(XX(N),XMAX)
GO TO 50
C
60 CONTINUE
C NOW PLOT THE RESULTS WHICH HAVE BEEN READ IN
C
FILFAC = 1.
NPLT = N
C********
c NPLT = 71
C
C PLOT CONSTANT W CONTOUR IN K SPACE
C
XMAX = 0.
YMAX = 0.
DO 62 N = 1,NPLT
YMAX = AMAX1(YMAX,YY(N))
XMAX = AMAX1(XX(N),XMAX)
SYM(N) = 1.
62 CONTINUE
PRINT*,'NPLT',NPLT,' X,YMAX',XMAX,YMAX
c YMAX = AMAX1(ABS(YMAX),ABS(XMAX))
c XMAX = AMAX1(ABS(YMAX),ABS(XMAX))
XMAX = 1.2*XMAX
YMAX = 1.2*YMAX
C
C LOAD REST OF ARRAY TO AVOID ZEROS IN PLOT
C
DO N = NPLT+1,200
DO J = 1,10
PLT(N,J) = PLT(N-1,J)
ENDDO
ENDDO
C DELX = .1*XMAX
C NXMAX = (ALOG10(DELX) + 50.)
C DELX = 10.**(NXMAX-50)
C DELY = DELX
C
PRINT*,'NPLT',NPLT,' X,YMAX',XMAX,YMAX
C YMAX = AMAX1(ABS(YMAX),ABS(XMAX))
C XMAX = AMAX1(ABS(YMAX),ABS(XMAX))
C XMAX = 1.2*XMAX
C YMAX = 1.2*YMAX
C XMAX = 1.140*XMAX
C DELX = .01
C DELY = DELX
C
C PLOT CONSTANT W CONTOUR IN K SPACE
C
X1 = 0.
Y1 = 0.
x2 = xmax
y2 = ymax
c X2 = AMAX1(XMAX,YMAX)
c Y2 = X2
PRINT*,'MGO2 USER LIMITS',X1,X2,Y1,Y2
CALL OSCAMG(2)
C
C PLOT IMAGINARY PART OF FREQUENCY
C
XMAX = 0.
YMAX = 0.
DO 61 N = 1,NPLT
XK = SQRT(XX(N)**2 + YY(N)**2)
IF(XK.EQ.0.) XK = 1.
WI = ZZ(N)/WCI
YY(N) = -WI*YY(N)/XK**2
XX(N) = -WI*XX(N)/XK**2
PLT(N,7) = XX(N)
PLT(N,8) = YY(N)
YMAX = AMAX1(YMAX,YY(N))
XMAX = AMAX1(XX(N),XMAX)
SYM(N) = 1.
61 CONTINUE
X1 = 0.
Y1 = 0.
x2 = xmax
y2 = ymax
X2 = AMAX1(XMAX,YMAX)
Y2 = X2
C
CALL OSCAMG(3)
PAUSE
C
STOP
END
SUBROUTINE OSCAMG(IMRP)
C
CHARACTER*50 COM(20)
CHARACTER*1 DISPOSE
COMMON /PLTBLK/ PLT(200,10)
C
COMMON /MONGOPAR/
1 X1,X2,Y1,Y2,GX1,GX2,GY1,GY2,LX1,LX2,LY1,LY2,
1 GX,GY,CX,CY,
1 EXPAND,ANGLE,LTYPE,LWEIGHT,
1 CHEIGHT,CWIDTH,CXDEF,CYDEF,PXDEF,PYDEFF,COFFMGO,
1 TERMOUT,XYSWAPPED,NUMDEV,
1 PIMGO,USERVAR(10),AUTODOT
C
C ITERM = 3 FOR TERMINAL, -1 or -2 FOR PRINTER
C DATA ITERM /-1/
DATA ITERM /3/
C
c DO N = 1,10
c PRINT*,(PLT(N,J),J=1,4)
c ENDDO
C
IF(ITERM.GT.0) THEN
COM(1) = 'TERMINAL 3'
NCOM = 1
ELSE
COM(1) = 'PRINTER 1'
NCOM = 1
ENDIF
NCOM = NCOM+1
IF(IMRP.EQ.0) COM(NCOM) = 'INPUT SHZMGO.MGO'
IF(IMRP.EQ.1) COM(NCOM) = 'INPUT SHZMGO.IMG'
IF(IMRP.EQ.2) COM(NCOM) = 'INPUT OSCPLT.MGO2'
IF(IMRP.EQ.3) COM(NCOM) = 'INPUT OSCPLT.MGO3'
IF(IMRP.EQ.5) COM(NCOM) = 'INPUT SHZMGO.MGO4'
IF(ITERM.LT.0) THEN
NCOM = NCOM+1
COM(NCOM) = 'HARDCOPY'
ENDIF
C NCOM = NCOM+1
C COM(NCOM) = 'END'
CALL MONGO(NCOM,COM,200,10,PLT)
PRINT*,'END OSCAMG',IMRP
T1 = SECNDS(0.0)
123 T2 = SECNDS(T1)
IF(T2.LT.5.) GO TO 123
C IF(IMRP.EQ.5) COM(NCOM) = 'INPUT SHZMGO.MGO5'
IF(IMRP.EQ.5) COM(NCOM) = 'INPUT SHZMGO.MGO6'
CALL MONGO(NCOM,COM,200,10,PLT)
T1 = SECNDS(0.0)
124 T2 = SECNDS(T1)
IF(T2.LT.5.) GO TO 124
READ(5,107) DISPOSE
107 FORMAT(A)
C 120 STOP
END
| WAVES_VMS_Fortran/PJK_Fortran/waves_dir/oscmgo_97.for |
!
! Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
!
! 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.
program dt66
implicit none
type t1
integer :: i1
integer, allocatable :: x1
end type t1
type t2
integer :: i2
type(t1) :: x2
end type t2
type t3
integer :: i3
type(t2), allocatable :: x3
end type t3
type(t3), allocatable :: y
allocate(y)
deallocate(y)
call check(1,1,1)
end program
| test/f90_correct/src/dt66.f90 |
SUBROUTINE W3FT201(ALOLA,APOLA,INTERP)
C$$$ SUBROUTINE DOCUMENTATION BLOCK ***
C
C SUBROUTINE: W3FT201 CONVERT (361,181) GRID TO (65,65) N. HEMI. GRID
C AUTHOR: JONES,R.E. ORG: W342 DATE: 94-09-11
C
C ABSTRACT: CONVERT A GLOBAL 1.0 DEGREE LAT.,LON. 361 BY
C 181 GRID TO A POLAR STEREOGRAPHIC 65 BY 65 GRID. THE POLAR
C STEREOGRAPHIC MAP PROJECTION IS TRUE AT 60 DEG. N. , THE MESH
C LENGTH IS 381 KM. AND THE ORIENTION IS 105 DEG. W. THIS IS THE
C SAME AS W3FT43V EXCEPT THE ORIENTION IS 105 DEG. W.
C
C PROGRAM HISTORY LOG:
C 93-03-29 R.E.JONES ADD SAVE STATEMENT
C
C USAGE: CALL W3FT201(ALOLA,APOLA,INTERP)
C
C INPUT ARGUMENTS: ALOLA - 361*181 GRID 1.0 DEG. LAT,LON GRID
C 65341 POINT GRID. 360 * 181 ONE DEGREE
C GRIB GRID 3 WAS FLIPPED, GREENWISH ADDED
C TO RIGHT SIDE TO MAKE 361 * 181.
C INTERP - 1 LINEAR INTERPOLATION , NE.1 BIQUADRATIC
C
C INPUT FILES: NONE
C
C OUTPUT ARGUMENTS: APOLA - 65*65 GRID OF NORTHERN HEMISPHERE.
C 4225 POINT GRID IS AWIPS GRID TYPE 201
C
C OUTPUT FILES: ERROR MESSAGE TO FORTRAN OUTPUT FILE
C
C WARNINGS:
C
C 1. W1 AND W2 ARE USED TO STORE SETS OF CONSTANTS WHICH ARE
C REUSABLE FOR REPEATED CALLS TO THE SUBROUTINE.
C
C 2. WIND COMPONENTS ARE NOT ROTATED TO THE 65*65 GRID ORIENTATION
C AFTER INTERPOLATION. YOU MAY USE W3FC08 TO DO THIS.
C
C 3. ALL POINTS BELOW EQUATOR ARE ON THIS GRID.
C
C RETURN CONDITIONS: NORMAL SUBROUTINE EXIT
C
C SUBPROGRAMS CALLED:
C UNIQUE : NONE
C
C LIBRARY: ASIN , ATAN2
C
C ATTRIBUTES:
C LANGUAGE: CRAY CFT77 FORTRAN
C MACHINE: CRAY C916-128, CRAY Y-MP8/864, CRAY Y-MP EL2/256
C
C$$$
C
PARAMETER (NPTS=4225,II=65,JJ=65)
PARAMETER (ORIENT=105.0,IPOLE=33,JPOLE=33)
PARAMETER (XMESH=381.0)
C
REAL R2(NPTS), WLON(NPTS)
REAL XLAT(NPTS), XI(II,JJ), XJ(II,JJ)
REAL XII(NPTS), XJJ(NPTS), ANGLE(NPTS)
REAL ALOLA(361,181), APOLA(NPTS), ERAS(NPTS,4)
REAL W1(NPTS), W2(NPTS)
REAL XDELI(NPTS), XDELJ(NPTS)
REAL XI2TM(NPTS), XJ2TM(NPTS)
C
INTEGER IV(NPTS), JV(NPTS), JY(NPTS,4)
INTEGER IM1(NPTS), IP1(NPTS), IP2(NPTS)
C
LOGICAL LIN
C
SAVE
C
EQUIVALENCE (XI(1,1),XII(1)),(XJ(1,1),XJJ(1))
C
DATA DEGPRD/57.2957795/
DATA EARTHR/6371.2/
DATA INTRPO/99/
DATA ISWT /0/
C
LIN = .FALSE.
IF (INTERP.EQ.1) LIN = .TRUE.
C
IF (ISWT.EQ.1) GO TO 900
C
DEG = 1.0
GI2 = (1.86603 * EARTHR) / XMESH
GI2 = GI2 * GI2
C
C NEXT 32 LINES OF CODE PUTS SUBROUTINE W3FB01 IN LINE
C
DO 100 J = 1,JJ
XJ1 = J - JPOLE
DO 100 I = 1,II
XI(I,J) = I - IPOLE
XJ(I,J) = XJ1
100 CONTINUE
C
DO 200 KK = 1,NPTS
R2(KK) = XJJ(KK) * XJJ(KK) + XII(KK) * XII(KK)
XLAT(KK) = DEGPRD *
& ASIN((GI2 - R2(KK)) / (GI2 + R2(KK)))
200 CONTINUE
C
XII(2113) = 1.0
DO 300 KK = 1,NPTS
ANGLE(KK) = DEGPRD * ATAN2(XJJ(KK),XII(KK))
300 CONTINUE
C
DO 400 KK = 1,NPTS
IF (ANGLE(KK).LT.0.0) ANGLE(KK) = ANGLE(KK) + 360.0
400 CONTINUE
C
DO 500 KK = 1,NPTS
WLON(KK) = 270.0 + ORIENT - ANGLE(KK)
500 CONTINUE
C
DO 600 KK = 1,NPTS
IF (WLON(KK).LT.0.0) WLON(KK) = WLON(KK) + 360.0
600 CONTINUE
C
DO 700 KK = 1,NPTS
IF (WLON(KK).GE.360.0) WLON(KK) = WLON(KK) - 360.0
700 CONTINUE
C
XLAT(2113) = 90.0
WLON(2113) = 0.0
C
DO 800 KK = 1,NPTS
W1(KK) = (360.0 - WLON(KK)) / DEG + 1.0
W2(KK) = XLAT(KK) / DEG + 91.0
800 CONTINUE
C
ISWT = 1
INTRPO = INTERP
GO TO 1000
C
C AFTER THE 1ST CALL TO W3FT201 TEST INTERP, IF IT HAS
C CHANGED RECOMPUTE SOME CONSTANTS
C
900 CONTINUE
IF (INTERP.EQ.INTRPO) GO TO 2100
INTRPO = INTERP
C
1000 CONTINUE
DO 1100 K = 1,NPTS
IV(K) = W1(K)
JV(K) = W2(K)
XDELI(K) = W1(K) - IV(K)
XDELJ(K) = W2(K) - JV(K)
IP1(K) = IV(K) + 1
JY(K,3) = JV(K) + 1
JY(K,2) = JV(K)
1100 CONTINUE
C
IF (LIN) GO TO 1400
C
DO 1200 K = 1,NPTS
IP2(K) = IV(K) + 2
IM1(K) = IV(K) - 1
JY(K,1) = JV(K) - 1
JY(K,4) = JV(K) + 2
XI2TM(K) = XDELI(K) * (XDELI(K) - 1.0) * .25
XJ2TM(K) = XDELJ(K) * (XDELJ(K) - 1.0) * .25
1200 CONTINUE
C
DO 1300 KK = 1,NPTS
IF (IV(KK).EQ.1) THEN
IP2(KK) = 3
IM1(KK) = 360
ELSE IF (IV(KK).EQ.360) THEN
IP2(KK) = 2
IM1(KK) = 359
ENDIF
1300 CONTINUE
C
1400 CONTINUE
C
IF (LIN) GO TO 1700
C
DO 1500 KK = 1,NPTS
IF (JV(KK).GE.180) XJ2TM(KK) = 0.0
1500 CONTINUE
C
DO 1600 KK = 1,NPTS
IF (IP2(KK).LT.1) IP2(KK) = 1
IF (IM1(KK).LT.1) IM1(KK) = 1
IF (IP2(KK).GT.361) IP2(KK) = 361
IF (IM1(KK).GT.361) IM1(KK) = 361
1600 CONTINUE
C
1700 CONTINUE
DO 1800 KK = 1,NPTS
IF (IV(KK).LT.1) IV(KK) = 1
IF (IP1(KK).LT.1) IP1(KK) = 1
IF (IV(KK).GT.361) IV(KK) = 361
IF (IP1(KK).GT.361) IP1(KK) = 361
1800 CONTINUE
C
C LINEAR INTERPOLATION
C
DO 1900 KK = 1,NPTS
IF (JY(KK,2).GT.181) JY(KK,2) = 181
IF (JY(KK,3).GT.181) JY(KK,3) = 181
1900 CONTINUE
C
IF (.NOT.LIN) THEN
DO 2000 KK = 1,NPTS
IF (JY(KK,1).GT.181) JY(KK,1) = 181
IF (JY(KK,4).GT.181) JY(KK,4) = 181
2000 CONTINUE
ENDIF
C
2100 CONTINUE
IF (LIN) THEN
C
C LINEAR INTERPOLATION
C
DO 2200 KK = 1,NPTS
ERAS(KK,2) = (ALOLA(IP1(KK),JY(KK,2))-ALOLA(IV(KK),JY(KK,2)))
& * XDELI(KK) + ALOLA(IV(KK),JY(KK,2))
ERAS(KK,3) = (ALOLA(IP1(KK),JY(KK,3))-ALOLA(IV(KK),JY(KK,3)))
& * XDELI(KK) + ALOLA(IV(KK),JY(KK,3))
2200 CONTINUE
C
DO 2300 KK = 1,NPTS
APOLA(KK) = ERAS(KK,2) + (ERAS(KK,3) - ERAS(KK,2))
& * XDELJ(KK)
2300 CONTINUE
C
ELSE
C
C QUADRATIC INTERPOLATION
C
DO 2400 KK = 1,NPTS
ERAS(KK,1)=(ALOLA(IP1(KK),JY(KK,1))-ALOLA(IV(KK),JY(KK,1)))
& * XDELI(KK) + ALOLA(IV(KK),JY(KK,1)) +
& ( ALOLA(IM1(KK),JY(KK,1)) - ALOLA(IV(KK),JY(KK,1))
& - ALOLA(IP1(KK),JY(KK,1))+ALOLA(IP2(KK),JY(KK,1)))
& * XI2TM(KK)
ERAS(KK,2)=(ALOLA(IP1(KK),JY(KK,2))-ALOLA(IV(KK),JY(KK,2)))
& * XDELI(KK) + ALOLA(IV(KK),JY(KK,2)) +
& ( ALOLA(IM1(KK),JY(KK,2)) - ALOLA(IV(KK),JY(KK,2))
& - ALOLA(IP1(KK),JY(KK,2))+ALOLA(IP2(KK),JY(KK,2)))
& * XI2TM(KK)
ERAS(KK,3)=(ALOLA(IP1(KK),JY(KK,3))-ALOLA(IV(KK),JY(KK,3)))
& * XDELI(KK) + ALOLA(IV(KK),JY(KK,3)) +
& ( ALOLA(IM1(KK),JY(KK,3)) - ALOLA(IV(KK),JY(KK,3))
& - ALOLA(IP1(KK),JY(KK,3))+ALOLA(IP2(KK),JY(KK,3)))
& * XI2TM(KK)
ERAS(KK,4)=(ALOLA(IP1(KK),JY(KK,4))-ALOLA(IV(KK),JY(KK,4)))
& * XDELI(KK) + ALOLA(IV(KK),JY(KK,4)) +
& ( ALOLA(IM1(KK),JY(KK,4)) - ALOLA(IV(KK),JY(KK,4))
& - ALOLA(IP1(KK),JY(KK,4))+ALOLA(IP2(KK),JY(KK,4)))
& * XI2TM(KK)
2400 CONTINUE
C
DO 2500 KK = 1,NPTS
APOLA(KK) = ERAS(KK,2) + (ERAS(KK,3) - ERAS(KK,2))
& * XDELJ(KK) + (ERAS(KK,1) - ERAS(KK,2)
& - ERAS(KK,3) + ERAS(KK,4)) * XJ2TM(KK)
2500 CONTINUE
C
ENDIF
C
C SET POLE POINT , WMO STANDARD FOR U OR V
C
APOLA(2113) = ALOLA(181,181)
C
RETURN
END
| buildscripts/libs/NCEPlibs/src/w3emc/v2.2.0/src/w3ft201.f |
!--------------------------------------------------------------------
!
!
! PURPOSE
!
! This program solves nonlinear Schrodinger equation in 2 dimensions
! i*u_t+Es*|u|^2u+u_{xx}+u_{yy}=0
! using a second order time spectral splitting scheme
!
! The boundary conditions are u(x=0,y)=u(2*Lx*\pi,y),
! u(x,y=0)=u(x,y=2*Ly*\pi)
! The initial condition is u=exp(-x^2-y^2)
!
! .. Parameters ..
! Nx = number of modes in x - power of 2 for FFT
! Ny = number of modes in y - power of 2 for FFT
! Nt = number of timesteps to take
! Tmax = maximum simulation time
! plotgap = number of timesteps between plots
! FFTW_IN_PLACE = value for FFTW input
! FFTW_MEASURE = value for FFTW input
! FFTW_EXHAUSTIVE = value for FFTW input
! FFTW_PATIENT = value for FFTW input
! FFTW_ESTIMATE = value for FFTW input
! FFTW_FORWARD = value for FFTW input
! FFTW_BACKWARD = value for FFTW input
! pi = 3.14159265358979323846264338327950288419716939937510d0
! Lx = width of box in x direction
! Ly = width of box in y direction
! ES = +1 for focusing and -1 for defocusing
! .. Scalars ..
! i = loop counter in x direction
! j = loop counter in y direction
! n = loop counter for timesteps direction
! allocatestatus = error indicator during allocation
! start = variable to record start time of program
! finish = variable to record end time of program
! count_rate = variable for clock count rate
! planfx = Forward 1d fft plan in x
! planbx = Backward 1d fft plan in x
! planfy = Forward 1d fft plan in y
! planby = Backward 1d fft plan in y
! dt = timestep
! .. Arrays ..
! u = approximate solution
! v = Fourier transform of approximate solution
! unax = temporary field
! vnax = temporary field
! vnbx = temporary field
! vnay = temporary field
! vnby = temporary field
! potx = potential
! .. Vectors ..
! kx = fourier frequencies in x direction
! ky = fourier frequencies in y direction
! x = x locations
! y = y locations
! time = times at which save data
! name_config = array to store filename for data to be saved
! fftfx = array to setup x Fourier transform
! fftbx = array to setup x Fourier transform
! fftfy = array to setup y Fourier transform
! fftby = array to setup y Fourier transform
!
! REFERENCES
!
! ACKNOWLEDGEMENTS
!
! ACCURACY
!
! ERROR INDICATORS AND WARNINGS
!
! FURTHER COMMENTS
! Check that the initial iterate is consistent with the
! boundary conditions for the domain specified
!--------------------------------------------------------------------
! External routines required
!
! External libraries required
! FFTW3 -- Fast Fourier Transform in the West Library
! (http://www.fftw.org/)
! OpenMP library
PROGRAM main
USE omp_lib
IMPLICIT NONE
! Declare variables
INTEGER(kind=4), PARAMETER :: Nx=2**8
INTEGER(kind=4), PARAMETER :: Ny=2**8
INTEGER(kind=4), PARAMETER :: Nt=20
INTEGER(kind=4), PARAMETER :: plotgap=5
REAL(kind=8), PARAMETER :: &
pi=3.14159265358979323846264338327950288419716939937510d0
REAL(kind=8), PARAMETER :: Lx=2.0d0
REAL(kind=8), PARAMETER :: Ly=2.0d0
REAL(kind=8), PARAMETER :: Es=0.0d0
REAL(kind=8) :: dt=0.10d0/Nt
COMPLEX(kind=8), DIMENSION(:), ALLOCATABLE :: kx,ky
REAL(kind=8), DIMENSION(:), ALLOCATABLE :: x,y
COMPLEX(kind=8), DIMENSION(:,:), ALLOCATABLE:: unax,vnax,vnbx,potx
COMPLEX(kind=8), DIMENSION(:,:), ALLOCATABLE:: vnay,vnby
REAL(kind=8), DIMENSION(:), ALLOCATABLE :: time
INTEGER(kind=4) :: i,j,k,n,allocatestatus
INTEGER(kind=4) :: start, finish, count_rate
INTEGER(kind=8), PARAMETER :: FFTW_IN_PLACE=8, FFTW_MEASURE=0,&
FFTW_EXHAUSTIVE=8, FFTW_PATIENT=32,&
FFTW_ESTIMATE=64
INTEGER(kind=8),PARAMETER :: FFTW_FORWARD=-1, FFTW_BACKWARD=1
COMPLEX(kind=8), DIMENSION(:), ALLOCATABLE :: fftfx,fftbx,fftfy,fftby
INTEGER(kind=8) :: planfx,planbx,planfy,planby
CHARACTER*100 :: name_config
ALLOCATE(kx(1:Nx),ky(1:Nx),x(1:Nx),y(1:Nx),unax(1:Nx,1:Ny),&
vnax(1:Nx,1:Ny),vnbx(1:Nx,1:Ny),potx(1:Nx,1:Ny),fftfx(1:Nx),&
fftbx(1:Nx),fftfy(1:Nx),fftby(1:Nx),vnay(1:Ny,1:Nx),&
vnby(1:Ny,1:Nx),time(1:1+Nt/plotgap),stat=allocatestatus)
IF (allocatestatus .ne. 0) stop
PRINT *,'allocated memory'
! set up ffts
CALL dfftw_plan_dft_1d_(planfx,Nx,fftfx(1:Nx),fftbx(1:Nx),&
FFTW_FORWARD,FFTW_ESTIMATE)
CALL dfftw_plan_dft_1d_(planbx,Nx,fftbx(1:Nx),fftfx(1:Nx),&
FFTW_BACKWARD,FFTW_ESTIMATE)
CALL dfftw_plan_dft_1d_(planfy,Ny,fftfy(1:Ny),fftby(1:Ny),&
FFTW_FORWARD,FFTW_ESTIMATE)
CALL dfftw_plan_dft_1d_(planby,Ny,fftby(1:Ny),fftfy(1:Ny),&
FFTW_BACKWARD,FFTW_ESTIMATE)
PRINT *,'Setup FFTs'
! setup fourier frequencies
!$OMP PARALLEL DO PRIVATE(i) SCHEDULE(static)
DO i=1,1+Nx/2
kx(i)= cmplx(0.0d0,1.0d0)*REAL(i-1,kind(0d0))/Lx
END DO
!$OMP END PARALLEL DO
kx(1+Nx/2)=0.0d0
!$OMP PARALLEL DO PRIVATE(i) SCHEDULE(static)
DO i = 1,Nx/2 -1
kx(i+1+Nx/2)=-kx(1-i+Nx/2)
END DO
!$OMP END PARALLEL DO
!$OMP PARALLEL DO PRIVATE(i) SCHEDULE(static)
DO i=1,Nx
x(i)=(-1.0d0+2.0d0*REAL(i-1,kind(0d0))/REAL(Nx,kind(0d0)) )*pi*Lx
END DO
!$OMP END PARALLEL DO
!$OMP PARALLEL DO PRIVATE(j) SCHEDULE(static)
DO j=1,1+Ny/2
ky(j)= cmplx(0.0d0,1.0d0)*REAL(j-1,kind(0d0))/Ly
END DO
!$OMP END PARALLEL DO
ky(1+Ny/2)=0.0d0
!$OMP PARALLEL DO PRIVATE(j) SCHEDULE(static)
DO j = 1,Ny/2 -1
ky(j+1+Ny/2)=-ky(1-j+Ny/2)
END DO
!$OMP END PARALLEL DO
!$OMP PARALLEL DO PRIVATE(j) SCHEDULE(static)
DO j=1,Ny
y(j)=(-1.0d0+2.0d0*REAL(j-1,kind(0d0))/REAL(Ny,kind(0d0)) )*pi*Ly
END DO
!$OMP END PARALLEL DO
PRINT *,'Setup grid and fourier frequencies'
!$OMP PARALLEL DO PRIVATE(j) SCHEDULE(static)
DO j=1,Ny
DO i=1,Nx
unax(i,j)=exp(-1.0d0*(x(i)**2 +y(j)**2))
END DO
END DO
!$OMP END PARALLEL DO
name_config = 'uinitial.dat'
OPEN(unit=11,FILE=name_config,status="UNKNOWN")
REWIND(11)
DO j=1,Ny
DO i=1,Nx
WRITE(11,*) abs(unax(i,j))**2
END DO
END DO
CLOSE(11)
!$OMP PARALLEL DO PRIVATE(j) SCHEDULE(static)
DO j=1,Ny
DO i=1,Nx
CALL dfftw_execute_dft_(planfx,unax(i,j),vnax(i,j))
END DO
END DO
!$OMP END PARALLEL DO
vnay(1:Ny,1:Nx)=TRANSPOSE(vnax(1:Nx,1:Ny))
! transform initial data and do first half time step
!$OMP PARALLEL DO PRIVATE(i) SCHEDULE(static)
DO i=1,Nx
CALL dfftw_execute_dft_(planfy,vnay(1:Ny,i),vnby(1:Ny,i))
DO j=1,Ny
vnby(j,i)=exp(0.5d0*dt*(kx(i)*kx(i) + ky(j)*ky(j))&
*cmplx(0.0d0,1.0d0))*vnby(j,i)
END DO
CALL dfftw_execute_dft_(planby,vnby(j,i),vnay(j,i))
END DO
!$OMP END PARALLEL DO
PRINT *,'Got initial data, starting timestepping'
time(1)=0.0d0
CALL system_clock(start,count_rate)
DO n=1,Nt
vnbx(1:Nx,1:Ny)=TRANSPOSE(vnay(1:Ny,1:Nx))/REAL(Ny,kind(0d0))
!$OMP PARALLEL DO PRIVATE(j) SCHEDULE(static)
DO j=1,Ny
CALL dfftw_execute_dft_(planbx,vnbx(1:Nx,j),unax(1:Nx,j))
DO i=1,Nx
unax(i,j)=unax(1:Nx,j)/REAL(Nx,kind(0d0))
potx(i,j)=Es*unax(i,j)*conjg(unax(i,j))
unax(i,j)=exp(cmplx(0.0d0,-1.0d0)*dt*potx(i,j))&
*unax(i,j)
END DO
CALL dfftw_execute_dft_(planfx,unax(1:Nx,j),vnax(1:Nx,j))
END DO
!$OMP END PARALLEL DO
vnby(1:Ny,1:Nx)=TRANSPOSE(vnax(1:Nx,1:Ny))
!$OMP PARALLEL DO PRIVATE(i) SCHEDULE(static)
DO i=1,Nx
CALL dfftw_execute_dft_(planfy,vnby(1:Ny,i),vnay(1:Ny,i))
DO j=1,Ny
vnby(j,i)=exp(dt*(kx(i)*kx(i) + ky(j)*ky(j))&
*cmplx(0.0d0,1.0d0))*vnay(j,i)
END DO
CALL dfftw_execute_dft_(planby,vnby(1:Ny,i),vnay(1:Ny,i))
END DO
!$OMP END PARALLEL DO
IF (mod(n,plotgap)==0) then
time(1+n/plotgap)=n*dt
PRINT *,'time',n*dt
END IF
END DO
PRINT *,'Finished time stepping'
CALL system_clock(finish,count_rate)
PRINT*,'Program took ',REAL(finish-start)/REAL(count_rate),&
'for Time stepping'
! transform back final data and do another half time step
vnbx(1:Nx,1:Ny)=transpose(vnay(1:Ny,1:Nx))/REAL(Ny,kind(0d0))
!$OMP PARALLEL DO PRIVATE(j) SCHEDULE(static)
DO j=1,Ny
CALL dfftw_execute_dft_(planbx,vnbx(1:Nx,j),unax(1:Nx,j))
unax(1:Nx,j)=unax(1:Nx,j)/REAL(Nx,kind(0d0))
potx(1:Nx,j)=Es*unax(1:Nx,j)*conjg(unax(1:Nx,j))
unax(1:Nx,j)=exp(cmplx(0,-1)*dt*potx(1:Nx,j))*unax(1:Nx,j)
CALL dfftw_execute_dft_(planfx,unax(1:Nx,j),vnax(1:Nx,j))
END DO
!$OMP END PARALLEL DO
vnby(1:Ny,1:Nx)=TRANSPOSE(vnax(1:Nx,1:Ny))
!$OMP PARALLEL DO PRIVATE(i) SCHEDULE(static)
DO i=1,Nx
CALL dfftw_execute_dft_(planfy,vnby(1:Ny,i),vnay(1:Ny,i))
vnby(1:Ny,i)=exp(0.5d0*dt*(kx(i)*kx(i) + ky(1:Ny)*ky(1:Ny))&
*cmplx(0,1))*vnay(1:Ny,i)
CALL dfftw_execute_dft_(planby,vnby(1:Ny,i),vnay(1:Ny,i))
END DO
!$OMP END PARALLEL DO
vnbx(1:Nx,1:Ny)=TRANSPOSE(vnay(1:Ny,1:Nx))/REAL(Ny,kind(0d0))
!$OMP PARALLEL DO PRIVATE(j) SCHEDULE(static)
DO j=1,Ny
CALL dfftw_execute_dft_(planbx,vnbx(1:Nx,j),unax(1:Nx,j))
unax(1:Nx,j)=unax(1:Nx,j)/REAL(Nx,kind(0d0))
END DO
!$OMP END PARALLEL DO
name_config = 'ufinal.dat'
OPEN(unit=11,FILE=name_config,status="UNKNOWN")
REWIND(11)
DO j=1,Ny
DO i=1,Nx
WRITE(11,*) abs(unax(i,j))**2
END DO
END DO
CLOSE(11)
name_config = 'tdata.dat'
OPEN(unit=11,FILE=name_config,status="UNKNOWN")
REWIND(11)
DO j=1,1+Nt/plotgap
WRITE(11,*) time(j)
END DO
CLOSE(11)
name_config = 'xcoord.dat'
OPEN(unit=11,FILE=name_config,status="UNKNOWN")
REWIND(11)
DO i=1,Nx
WRITE(11,*) x(i)
END DO
CLOSE(11)
name_config = 'ycoord.dat'
OPEN(unit=11,FILE=name_config,status="UNKNOWN")
REWIND(11)
DO j=1,Ny
WRITE(11,*) y(j)
END DO
CLOSE(11)
PRINT *,'Saved data'
CALL dfftw_destroy_plan_(planbx)
CALL dfftw_destroy_plan_(planfx)
CALL dfftw_destroy_plan_(planby)
CALL dfftw_destroy_plan_(planfy)
CALL dfftw_cleanup_()
DEALLOCATE(unax,vnax,vnbx,potx, vnay,vnby,stat=allocatestatus)
IF (allocatestatus .ne. 0) STOP
PRINT *,'Deallocated memory'
PRINT *,'Program execution complete'
END PROGRAM main
| CubicNonlinearSchrodinger/Programs/NLS2dFortran/NLSsplitting.f90 |
SUBROUTINE clawpack46_qinit(meqn,mbc,mx,my,mz,xlower,ylower,zlower, &
dx,dy,dz, q,maux,aux)
IMPLICIT NONE
INTEGER :: meqn, mbc, mx, my, mz, maux
DOUBLE PRECISION :: xlower, ylower, zlower, dx, dy, dz
DOUBLE PRECISION :: q(1-mbc:mx+mbc, 1-mbc:my+mbc,1-mbc:mz+mbc,meqn)
DOUBLE PRECISION :: aux(1-mbc:mx+mbc, 1-mbc:my+mbc,1-mbc:mz+mbc,maux)
INTEGER :: i, j, k, mq
DOUBLE PRECISION :: xlow, ylow, zlow, w
integer :: blockno
blockno = 0
DO mq = 1,meqn
do k = 1-mbc,mz+mbc
zlow = zlower + (k-1)*dz
DO j = 1-mbc,my+mbc
ylow = ylower + (j-1)*dy
DO i = 1-mbc,mx+mbc
xlow = xlower + (i-1)*dx
CALL cellave3(blockno,xlow,ylow,zlow,dx,dy,dz,w)
q(i,j,k,1) = w
end do
ENDDO
ENDDO
ENDDO
END SUBROUTINE clawpack46_qinit
| applications/clawpack/advection/3d/filament/user_4.6/qinit.f90 |
subroutine getjxy_testd
real*4 txa(6),tya(6),txy(6),txy1(6),terr(6),terr1(6),that(6)
real*4 j_xy_xa(6,6),j_xy_ya(6,6),dummy(36)
real*4 del/0.001/
do 9 l=1,3
do k=1,3
txa(k)=rand(0)-0.5
tya(k)=rand(0)-0.5
txa(3+k)=10.*(rand(0)-0.5)
tya(3+k)=10.*(rand(0)-0.5)
enddo
write(*,"('Tax ',3f10.6,3f10.4)")txa
write(*,"('Tay ',3f10.6,3f10.4)")tya
call gettxy(txa,tya,that,dummy,dummy)
do k=1,3
that(k)= that(k) +0.5*(rand(0)-0.5)
that(3+k)=that(3+k)+9.0*(rand(0)-0.5)
enddo
write(*,"('That ',3f10.6,3f10.4)")that
call getjxy(txa,tya,txy,that,terr,j_xy_xa,j_xy_ya)
write(*,"('Txy ',3f10.6,3f10.4)")txy
write(*,"('Terr ',3f10.6,3f10.4)")terr
do 8 j=1,6
write(*,"('J_xy_xa',i3,3f10.6,3f10.4)")j,(j_xy_xa(k,j),k=1,6)
txa(j)=txa(j)+del
call getjxy(txa,tya,txy1,that,terr1,dummy,dummy)
txa(j)=txa(j)-del
8 write(*,"(10x, 3f10.6,3f10.4)")((terr1(k)-terr(k))/del,k=1,6)
do 7 j=1,6
write(*,"('J_xy_ya',i3,3f10.6,3f10.4)")j,(j_xy_ya(k,j),k=1,6)
tya(j)=tya(j)+del
call getjxy(txa,tya,txy1,that,terr1,dummy,dummy)
tya(j)=tya(j)-del
7 write(*,"(10x, 3f10.6,3f10.4)")((terr1(k)-terr(k))/del,k=1,6)
9 write(*,"()")
call exit(0)
end
subroutine getjxy(txa,tya,txy,that,terr,j_xy_xa,j_xy_ya)
real*4 txa(6),tya(6),txy(6),that(6),terr(6)
real*4 j_xy_xa(6,6),j_xy_ya(6,6)
real*4 exa(0:3),eay(0:3),exy(0:3),dexydexa(0:3,3),dexydeay(0:3,3)
real*4 e4hat(0:3,0:3),ehat(0:3)
real*4 rxa(3,3),drxa(3,3,3)
real*4 ray(3,3),dray(3,3,3)
real*4 rxy(3,3),drxydexa(3,3,3),drxydeay(3,3,3)
logical*4 ldebug/.false./
if(ldebug)write(*,"(3f10.6,3f10.4,' txa')")txa
if(ldebug)write(*,"(3f10.6,3f10.4,' tya')")tya
do 2 k=1,3
exa(k)= txa(k)
eay(k)=-tya(k)
2 ehat(k)=that(k)
ehat(0)=sqrt(1.0-ehat(1)**2-ehat(2)**2-ehat(3)**2)
do 3 l=0,3
e4hat(0,l)= ehat(l)
3 e4hat(l,l)= ehat(0)
e4hat(1,2)=-ehat(3)
e4hat(1,3)= ehat(2)
e4hat(2,3)=-ehat(1)
do 4 l=0,2
do 4 m=l+1,3
4 e4hat(m,l)=-e4hat(l,m)
if(.false.)then
do l=0,3
write(*,"(4f10.6)")(e4hat(l,m),m=0,3)
enddo
call exit(1)
endif
call ckmuld(exa,eay,exy,dexydexa,dexydeay)
do 6 k=1,3
terr(k)=0.
do 6 m=0,3
6 terr(k)=terr(k)+e4hat(k,m)*exy(m)
do 1 k=1,6
do 1 j=1,6
j_xy_xa(k,j)=0.
1 j_xy_ya(k,j)=0.
call e2rd(exa,rxa,drxa)
call e2rd(eay,ray,dray)
call matmul(rxa,ray,rxy,3)
do j=1,3
call matmul(drxa(1,1,j),ray,drxydexa(1,1,j),3)
call matmul(rxa,dray(1,1,j),drxydeay(1,1,j),3)
enddo
do k=1,3
txy(k)=exy(k)
txy (3+k)=txa(3+k)-rxy(k,1)*tya(4)-rxy(k,2)*tya(5)-rxy(k,3)*tya(6)
terr(3+k)=txy(3+k)-that(3+k)
do j=1,3
do m=0,3
j_xy_xa(k,j)=j_xy_xa(k,j)+e4hat(k,m)*dexydexa(m,j)
j_xy_ya(k,j)=j_xy_ya(k,j)-e4hat(k,m)*dexydeay(m,j)
enddo
enddo
do j=1,3
j_xy_xa(3+k,j)=-drxydexa(k,1,j)*tya(4)-drxydexa(k,2,j)*tya(5)-drxydexa(k,3,j)*tya(6)
j_xy_ya(3+k,j)= drxydeay(k,1,j)*tya(4)+drxydeay(k,2,j)*tya(5)+drxydeay(k,3,j)*tya(6)
j_xy_ya(3+k,3+j)=-rxy(k,j)
enddo
j_xy_xa(3+k,3+k)=1.
enddo
if(ldebug)write(*,"(3f10.6,3f10.4,' txy')")txy
return
end
| 4dfp/imglin/getjxy.f |
!
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998 Guido Dhondt
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation(version 2);
!
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
subroutine createtet(kontet,ifatet,ielement,inodfa,
& ifreefa,planfa,ipofa,nodes,cotet,iparentelement)
!
implicit none
!
integer nodes(4),nodef(3),kontet(4,*),ifatet(4,*),inodfa(4,*),
& ipofa(*),ifreetet,ifreefa,ifree,ig(3,4),j,
& n1,n2,n3,n4,nxa,nxb,nxc,nxd,nya,nyb,nyc,nyd,nza,nzb,nzc,
& nzd,nx1,nx2,ny1,ny2,nz1,nz2,index,j1,j2,j3,i,n,kflag,idum,
& node,indexold,ielement,ndx,ndy,ndz,iparentelement
!
real*8 planfa(4,*),cotet(3,*),dd
!
data ig /2,3,4,3,4,1,4,1,2,1,2,3/
!
! updating the node per element relationship
!
do i=1,4
kontet(i,ielement)=nodes(i)
enddo
!
! creating faces
!
do i=1,4
nodef(1)=nodes(ig(1,i))
nodef(2)=nodes(ig(2,i))
nodef(3)=nodes(ig(3,i))
!
n=3
kflag=1
call isortii(nodef,idum,n,kflag)
!
! check whether face already exists
!
node=nodef(1)
index=ipofa(node)
!
do
if(index.eq.0) exit
if((inodfa(2,index).eq.nodef(2)).and.
& (inodfa(3,index).eq.nodef(3))) exit
indexold=index
index=inodfa(4,index)
enddo
!
if(index.eq.0) then
index=ifreefa
ifreefa=inodfa(4,ifreefa)
if(ifreefa.eq.0) then
write(*,*) '*ERROR in generatet: increase the dimension'
write(*,*) ' of inodfa'
endif
inodfa(1,index)=nodef(1)
inodfa(2,index)=nodef(2)
inodfa(3,index)=nodef(3)
inodfa(4,index)=0
if(ipofa(node).eq.0) then
ipofa(node)=index
else
inodfa(4,indexold)=index
endif
!
call planeeq(cotet,nodef,planfa(1,index))
!
endif
!
! the face number in ifatet is negative, if the equation
! of the face plane is such, that its value in the
! remaining node of the tetrahedron is negative
!
dd=planfa(1,index)*cotet(1,nodes(i))+
& planfa(2,index)*cotet(2,nodes(i))+
& planfa(3,index)*cotet(3,nodes(i))+
& planfa(4,index)
if(dabs(dd).lt.1.d-10) then
write(*,*) '*WARNING in createtet: element ',
& iparentelement
write(*,*) ' is extremely flat'
write(*,*) ' the element is deleted'
ielement=ielement-1
return
endif
if(dd.ge.0.d0) then
ifatet(i,ielement)=index
else
ifatet(i,ielement)=-index
endif
enddo
!
return
end
| ccx_prool/CalculiX/ccx_2.15/src/createtet.f |
! -*- F90 -*-
SUBROUTINE CtLhALFSET (QS, ALFS)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
EXTERNAL CtLhRTALF
COMMON / CtLhRTALFC / ALFST, JORD, NEFF
DATA ALAM, BLAM, ERR / 0.01, 10.0, 0.02 /
ALFST = ALFS
CALL CtLhParQcd (2, 'ORDR', ORDR, IR1)
JORD = Int(ORDR)
NEFF = LhCtNFL(QS)
EFLLN = CtLhQZBRNT (CtLhRTALF, ALAM, BLAM, ERR, IR2)
EFFLAM = QS / EXP (EFLLN)
CALL CtLhSETL1 (NEFF, EFFLAM)
END SUBROUTINE CtLhALFSET
FUNCTION CtLhALPI (AMU)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtCWZPRM / ALAM(0:9), AMHAT(0:9), AMN, NHQ
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
LOGICAL SET
PARAMETER (D0 = 0.D0, D1 = 1.D0, BIG = 1.0D15)
DATA IW1, IW2 / 2*0 /
IF(.NOT.SET) CALL CtLhLAMCWZ
NEFF = LhCtNFL(AMU)
ALM = ALAM(NEFF)
CtLhALPI = CtLhALPQCD (NORDER, NEFF, AMU/ALM, IRT)
IF (IRT .EQ. 1) THEN
CALL CtLhWARNR (IW1, 'AMU < ALAM in CtLhALPI', 'AMU', AMU, &
& ALM, BIG, 1)
ELSEIF (IRT .EQ. 2) THEN
CALL CtLhWARNR (IW2, 'CtLhALPI > 3; Be aware!', 'CtLhALPI', &
& CtLhALPI, D0, D1, 0)
ENDIF
RETURN
END FUNCTION CtLhALPI
FUNCTION CtLhALPQCD (IRDR, NF, RML, IRT)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (D0 = 0.D0, D1 = 1.D0, BIG = 1.0D15)
PARAMETER (CG = 3.0d0, TR = 0.5d0, CF = 4.0d0/3.0d0)
IRT = 0
IF (IRDR .LT. 1 .OR. IRDR .GT. 2) THEN
print *, &
& 'Order out of range in CtLhALPQCD: IRDR = ', IRDR
STOP
ENDIF
B0 = (11.d0*CG - 2.* NF) / 3.d0
B1 = (34.d0*CG**2 - 10.d0*CG*NF - 6.d0*CF*NF) / 3.d0
RM2 = RML**2
IF (RM2 .LE. 1.) THEN
IRT = 1
CtLhALPQCD = 99.
RETURN
ENDIF
ALN = LOG (RM2)
AL = 4.d0/ B0 / ALN
IF (IRDR .GE. 2) AL = AL * (1.d0-B1*LOG(ALN) / ALN / B0**2)
IF (AL .GE. 3.) THEN
IRT = 2
ENDIF
CtLhALPQCD = AL
RETURN
END FUNCTION CtLhALPQCD
FUNCTION CtLhAMHATF(I)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtCWZPRM / ALAM(0:9), AMHAT(0:9), AMN, NHQ
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
LOGICAL SET
IF (.NOT.SET) CALL CtLhLAMCWZ
IF ((I.LE.0).OR.(I.GT.9)) THEN
print *,'warning I OUT OF RANGE IN CtLhAMHATF'
CtLhAMHATF = 0
ELSE
CtLhAMHATF = AMHAT(I)
ENDIF
RETURN
END FUNCTION CtLhAMHATF
FUNCTION CtLhDXDZ (Z)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (D0=0D0, D1=1D0, D2=2D0, D3=3D0, D4=4D0, D10=1D1)
DATA HUGE, IWRN / 1.E20, 0 /
ZZ = Z
X = CtLhXFRMZ (ZZ)
TEM = CtLhDZDX (X)
IF (TEM .NE. D0) THEN
TMP = D1 / TEM
Else
CALL CtLhWARNR(IWRN, 'CtLhDXDZ singular in CtLhDXDZ; set=HUGE', &
& 'Z', Z, D0, D1, 0)
TMP = HUGE
EndIf
CtLhDXDZ = TMP
RETURN
END FUNCTION CtLhDXDZ
SUBROUTINE CtLhEVLPAR (IACT, NAME, VALUE, IRET)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
CHARACTER*(*) NAME
IRET = 1
IF (IACT .EQ. 0) THEN
WRITE ( NINT(VALUE) , 101)
101 FORMAT (/ ' Initiation parameters: Qini, Ipd0, Ihdn ' / &
& ' Maximum Q, Order of Alpha: Qmax, IKNL ' / &
& ' X- mesh parameters : Xmin, Xcr, Nx ' / &
& ' LnQ-mesh parameters : Nt, Jt ' / &
& ' # of parton flavors : NfMx ' /)
IRET = 4
ElseIF (IACT .EQ. 1) THEN
CALL CtLhEVLSET (NAME, VALUE, IRET)
Else
print *,'fatal evlpar'
stop
EndIf
RETURN
END SUBROUTINE CtLhEVLPAR
SUBROUTINE CtLhEVLSET (NAME, VALUE, IRET)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL LSTX
CHARACTER*(*) NAME
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MXPN = MXF * 2 + 2)
PARAMETER (MXQX= MXQ * MXX, MXPQX = MXQX * MXPN)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtQARAY1 / QINI,QMAX, QV(0:MXQ),TV(0:MXQ), NT,JT,NG
COMMON / LhCtEVLPAC / AL, IKNL, IPD0, IHDN, NfMx &
& / PdfSwh / Iset, IpdMod, Iptn0, NuIni
IRET = 1
IF (NAME .EQ. 'QINI') THEN
IF (VALUE .LE. 0) GOTO 12
QINI = VALUE
ElseIF (NAME .EQ. 'IPD0') THEN
ITEM = NINT(VALUE)
IF (Item .Eq. 10 .or. Item .Eq. 11) GOTO 12
IPD0 = ITEM
ElseIF (NAME .EQ. 'IHDN') THEN
ITEM = NINT(VALUE)
IF (ITEM .LT. -1 .OR. ITEM .GT. 5) GOTO 12
IHDN = ITEM
ElseIF (NAME .EQ. 'QMAX') THEN
IF (VALUE .LE. QINI) GOTO 12
QMAX = VALUE
ElseIF (NAME .EQ. 'IKNL') THEN
ITMP = NINT(VALUE)
ITEM = ABS(ITMP)
IF (ITEM.NE.1.AND.ITEM.NE.2) GOTO 12
IKNL = ITMP
ElseIF (NAME .EQ. 'XCR') THEN
IF (VALUE .LT. XMIN .OR. VALUE .GT. 10.) GOTO 12
XCR = VALUE
LSTX = .FALSE.
ElseIF (NAME .EQ. 'XMIN') THEN
IF (VALUE .LT. 1D-7 .OR. VALUE .GT. 1D0) GOTO 12
XMIN = VALUE
LSTX = .FALSE.
ElseIF (NAME .EQ. 'NX') THEN
ITEM = NINT(VALUE)
IF (ITEM .LT. 10 .OR. ITEM .GT. MXX-1) GOTO 12
NX = ITEM
LSTX = .FALSE.
ElseIF (NAME .EQ. 'NT') THEN
ITEM = NINT(VALUE)
IF (ITEM .LT. 2 .OR. ITEM .GT. MXQ) GOTO 12
NT = ITEM
ElseIF (NAME .EQ. 'JT') THEN
ITEM = NINT(VALUE)
IF (ITEM .LT. 1 .OR. ITEM .GT. 5) GOTO 12
JT = ITEM
ElseIF (NAME .EQ. 'NFMX') THEN
ITEM = NINT(VALUE)
IF (ITEM .LT. 1 .OR. ITEM .GT. MXPN) GOTO 12
NfMx = ITEM
ElseIF (NAME .EQ. 'IPDMOD') THEN
ITEM = NINT(VALUE)
IF (Abs(Item) .Gt. 1) GOTO 12
IpdMod = ITEM
ElseIF (NAME .EQ. 'IPTN0') THEN
ITEM = NINT(VALUE)
IF (ABS(ITEM) .GT. MXF) GOTO 12
IPTN0 = ITEM
ElseIF (NAME .EQ. 'NUINI') THEN
ITEM = NINT(VALUE)
IF (ITEM .LE. 0) GOTO 12
NuIni = ITEM
Else
IRET = 0
EndIf
RETURN
12 IRET = 2
RETURN
END SUBROUTINE CtLhEVLSET
SUBROUTINE CtLhEVOLVE (FINI, IRET)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
include 'parmsetup.inc'
LOGICAL LSTX
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MXPN = MXF * 2 + 2)
PARAMETER (MXQX= MXQ * MXX, MXPQX = MXQX * MXPN)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtQARAY1 / QINI,QMAX, QV(0:MXQ),TV(0:MXQ), NT,JT,NG
COMMON / LhCtQARAY2 / TLN(MXF), DTN(MXF), NTL(MXF), NTN(MXF)
COMMON / LhCtEVLPAC / AL, IKNL, IPD0, IHDN, NfMx
COMMON / LhCtPEVLDT / UPD(MXPQX,nmxset), KF, Nelmt
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
COMMON / LhCtVARBAB / GB(NDG, NDH, MXX), H(NDH, MXX, M1:M2)
DIMENSION QRKP(MXF)
DIMENSION JI(-MXF : MXF+1)
EXTERNAL LhCtNSRHSP, LhCtNSRHSM, FINI
DATA DZER / 0.0 /
save nxsave, ntsave, jtsave, ngsave, &
& xcrsave, xminsave, qinisave, qmaxsave, ientry
data ientry / 0 /
!
call getnset(iset)
!
ientry = ientry + 1
IRET = 0
IF (IHDN .LE. 4) THEN
MXVAL = 2
ElseIF (IHDN .LE. 6) THEN
MXVAL = 3
EndIf
IF (.NOT. LSTX) CALL CtLhXARRAY
CALL CtLhPARPDF (2, 'ALAM', AL, IR)
CALL CtLhQARRAY (NINI)
NFSN = NFMX + 1
KF = 2 * NFMX + 2
Nelmt = KF * (Nt+1) * (Nx+1)
DO IFLV = -NFMX, NFMX+1
JFL = NFMX + IFLV
JI(IFLV) = JFL * (NT+1) * (NX+1)
END DO
DO IZ = 1, NX
UPD(JI(0)+IZ+1,iset) = FINI (0, XV(IZ))
UPD(JI(NFSN)+IZ+1,iset) = 0
IF (NFMX .EQ. 0) EXIT
DO IFLV = 1, NINI
A = FINI ( IFLV, XV(IZ))
B = FINI (-IFLV, XV(IZ))
QRKP (IFLV) = A + B
UPD(JI(NFSN)+IZ+1,iset) = &
& UPD(JI(NFSN)+IZ+1,iset) + QRKP (IFLV)
UPD(JI(-IFLV)+IZ+1,iset) = A - B
END DO
DO IFLV = 1, NINI
UPD(JI( IFLV)+IZ+1,iset) = &
& QRKP(IFLV) - UPD(JI(NFSN)+IZ+1,iset)/NINI
END DO
END DO
DO NEFF = NINI, NFMX
IF (IKNL .EQ. 2) CALL CtLhSTUPKL (NEFF)
ICNT = NEFF - NINI + 1
IF (NTN(ICNT) .EQ. 0) EXIT
NITR = NTN (ICNT)
DT = DTN (ICNT)
TIN = TLN (ICNT)
CALL CtLhSNEVL (IKNL, NX, NITR, JT, DT, TIN, NEFF, &
& UPD(JI(NFSN)+2,iset), UPD(JI(0)+2,iset), &
& UPD(JI(NFSN)+1,iset), UPD(JI(0)+1,iset))
IF (NEFF .EQ. 0) GOTO 88
DO IFLV = 1, NEFF
CALL CtLhNSEVL (LhCtNSRHSP, IKNL, NX, NITR, JT, DT, TIN, &
& NEFF, UPD(JI( IFLV)+2,iset), UPD(JI( IFLV)+1,iset))
IF (IFLV .LE. MXVAL) &
& CALL CtLhNSEVL (LhCtNSRHSM, IKNL, NX, NITR, JT, DT, TIN, &
& NEFF, UPD(JI(-IFLV)+2,iset), UPD(JI(-IFLV)+1,iset))
DO IS = 0, NITR
DO IX = 0, NX
TP = UPD (IS*(NX+1) + IX + 1 + JI( IFLV),iset)
TS = UPD (IS*(NX+1) + IX + 1 + JI( NFSN),iset) / NEFF
TP = TP + TS
IF (IKNL .GT. 0) TP = MAX (TP, DZER)
IF (IFLV .LE. MXVAL) THEN
TM = UPD (IS*(NX+1) + IX + 1 + JI(-IFLV),iset)
IF (IKNL .GT. 0) THEN
TM = MAX (TM, DZER)
TP = MAX (TP, TM)
EndIf
Else
TM = 0.
EndIf
UPD (JI( IFLV) + IS*(NX+1) + IX + 1,iset) = (TP + TM)/2.
UPD (JI(-IFLV) + IS*(NX+1) + IX + 1,iset) = (TP - TM)/2.
END DO
END DO
END DO
DO IFLV = NEFF + 1, NFMX
DO IS = 0, NITR
DO IX = 0, NX
UPD(JI( IFLV) + IS*(NX+1) + IX + 1,iset) = 0
UPD(JI(-IFLV) + IS*(NX+1) + IX + 1,iset) = 0
END DO
END DO
END DO
88 CONTINUE
IF (NFMX .EQ. NEFF) EXIT
DO IFLV = -NFMX, NFMX+1
JI(IFLV) = JI(IFLV) + NITR * (NX+1)
END DO
CALL CtLhHQRK (NX, TT, NEFF+1, UPD(JI(0)+2,iset), &
& UPD(JI(NEFF+1)+2,iset))
DO IZ = 1, NX
QRKP (NEFF+1) = 2. * UPD(JI( NEFF+1) + IZ + 1,iset)
UPD (JI(NFSN)+IZ+1,iset) = UPD (JI(NFSN)+IZ+1,iset) &
& + QRKP (NEFF+1)
VS00 = UPD (JI(NFSN)+IZ+1,iset) / (NEFF+1)
UPD(JI( NEFF+1) + IZ + 1,iset) = QRKP(NEFF+1) - VS00
DO IFL = 1, NEFF
A = UPD(JI( IFL)+IZ+1,iset)
B = UPD(JI(-IFL)+IZ+1,iset)
QRKP(IFL) = A + B
UPD(JI( IFL)+IZ+1,iset) = QRKP(IFL) - VS00
IF (IFL .LE. MXVAL) UPD(JI(-IFL)+IZ+1,iset) = A - B
END DO
END DO
END DO
if(ientry .eq. 1) then
nxsave = nx
ntsave = nt
jtsave = jt
ngsave = ng
xcrsave = xcr
xminsave = xmin
qinisave = qini
qmaxsave = qmax
endif
if((nx .ne. nxsave) .or. &
& (nt .ne. ntsave) .or. &
& (jt .ne. jtsave) .or. &
& (ng .ne. ngsave) .or. &
& (xcr .ne. xcrsave) .or. &
& (xmin .ne. xminsave) .or. &
& (qini .ne. qinisave) .or. &
& (qmax .ne. qmaxsave)) then
write(6,669) nx, nt, jt, ng, xcr, xmin, &
& qini, qmax, ientry
669 format(1x,'evolve.f: nx,nt,jt,ng=',4i4, &
& ' xcr,xmin=',2f9.6, &
& ' qini, qmax',f7.4,1x,e12.5,' ientry=',i6)
nxsave = nx
ntsave = nt
jtsave = jt
ngsave = ng
qinisave = qini
qmaxsave = qmax
xcrsave = xcr
xminsave = xmin
endif
Return
END SUBROUTINE CtLhEVOLVE
FUNCTION CtLhFINTRP (FF, X0, DX, NX, XV, ERR, IR)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (D0=0D0, D1=1D0, D2=2D0, D3=3D0, D4=4D0, D10=1D1)
PARAMETER (MX = 3)
DIMENSION FF (0:NX), XX(MX)
DATA SML, XX / 1.D-5, 0., 1.0, 2.0 /
DATA IW1, IW3, IW5 / 3 * 0 /
IR = 0
X = XV
ERR = 0.
ANX = NX
CtLhFINTRP = 0.
IF (NX .LT. 1) THEN
CALL CtLhWARNI(IW1, 'Nx < 1, error in CtLhFINTRP.', &
& 'NX', NX, 1, 256, 1)
IR = 1
RETURN
ELSE
MNX = MIN(NX+1, MX)
ENDIF
IF (DX .LE. 0) THEN
CALL CtLhWARNR(IW3, 'DX < 0, error in CtLhFINTRP.', &
& 'DX', DX, D0, D1, 1)
IR = 2
RETURN
ENDIF
XM = X0 + DX * NX
IF (X .LT. X0-SML .OR. X .GT. XM+SML) THEN
CALL CtLhWARNR(IW5, &
& 'X out of range in CtLhFINTRP, Extrapolation used.', &
& 'X',X,X0,XM,1)
IR = 3
ENDIF
TX = (X - X0) / DX
IF (TX .LE. 1.) THEN
IX = 0
ELSEIF (TX .GE. ANX-1.) THEN
IX = NX - 2
ELSE
IX = Int(TX)
ENDIF
DDX = TX - IX
CALL CtLhRATINT (XX, FF(IX), MNX, DDX, TEM, ERR)
CtLhFINTRP = TEM
RETURN
END FUNCTION CtLhFINTRP
FUNCTION CtLhGausInt(F,XL,XR,AERR,RERR,ERR,IRT)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
DIMENSION XLIMS(100), R(93), W(93)
INTEGER PTR(4),NORD(4)
external f
DATA PTR,NORD/4,10,22,46, 6,12,24,48/
DATA R/.2386191860,.6612093865,.9324695142, &
& .1252334085,.3678314990,.5873179543,.7699026742,.9041172563, &
& .9815606342,.0640568929,.1911188675,.3150426797,.4337935076, &
& .5454214714,.6480936519,.7401241916,.8200019860,.8864155270, &
& .9382745520,.9747285560,.9951872200,.0323801710,.0970046992, &
& .1612223561,.2247637903,.2873624873,.3487558863,.4086864820, &
& .4669029048,.5231609747,.5772247261,.6288673968,.6778723796, &
& .7240341309,.7671590325,.8070662040,.8435882616,.8765720203, &
& .9058791367,.9313866907,.9529877032,.9705915925,.9841245837, &
& .9935301723,.9987710073,.0162767488,.0488129851,.0812974955, &
& .1136958501,.1459737146,.1780968824,.2100313105,.2417431561, &
& .2731988126,.3043649444,.3352085229,.3656968614,.3957976498, &
& .4254789884,.4547094222,.4834579739,.5116941772,.5393881083, &
& .5665104186,.5930323648,.6189258401,.6441634037,.6687183100, &
& .6925645366,.7156768123,.7380306437,.7596023411,.7803690438, &
& .8003087441,.8194003107,.8376235112,.8549590334,.8713885059, &
& .8868945174,.9014606353,.9150714231,.9277124567,.9393703398, &
& .9500327178,.9596882914,.9683268285,.9759391746,.9825172636, &
& .9880541263,.9925439003,.9959818430,.9983643759,.9996895039/
DATA W/.4679139346,.3607615730,.1713244924, &
& .2491470458,.2334925365,.2031674267,.1600783285,.1069393260, &
& .0471753364,.1279381953,.1258374563,.1216704729,.1155056681, &
& .1074442701,.0976186521,.0861901615,.0733464814,.0592985849, &
& .0442774388,.0285313886,.0123412298,.0647376968,.0644661644, &
& .0639242386,.0631141923,.0620394232,.0607044392,.0591148397, &
& .0572772921,.0551995037,.0528901894,.0503590356,.0476166585, &
& .0446745609,.0415450829,.0382413511,.0347772226,.0311672278, &
& .0274265097,.0235707608,.0196161605,.0155793157,.0114772346, &
& .0073275539,.0031533461,.0325506145,.0325161187,.0324471637, &
& .0323438226,.0322062048,.0320344562,.0318287589,.0315893308, &
& .0313164256,.0310103326,.0306713761,.0302999154,.0298963441, &
& .0294610900,.0289946142,.0284974111,.0279700076,.0274129627, &
& .0268268667,.0262123407,.0255700360,.0249006332,.0242048418, &
& .0234833991,.0227370697,.0219666444,.0211729399,.0203567972, &
& .0195190811,.0186606796,.0177825023,.0168854799,.0159705629, &
& .0150387210,.0140909418,.0131282296,.0121516047,.0111621020, &
& .0101607705,.0091486712,.0081268769,.0070964708,.0060585455, &
& .0050142027,.0039645543,.0029107318,.0018539608,.0007967921/
DATA TOLABS,TOLREL,NMAX/1.E-35,5.E-4,100/
TOLABS=AERR
TOLREL=RERR
CtLhGausInt=0.
NLIMS=2
XLIMS(1)=XL
XLIMS(2)=XR
10 AA=(XLIMS(NLIMS)-XLIMS(NLIMS-1))/2D0
BB=(XLIMS(NLIMS)+XLIMS(NLIMS-1))/2D0
TVAL=0.
DO 15 I=1,3
15 TVAL=TVAL+W(I)*(F(BB+AA*R(I))+F(BB-AA*R(I)))
TVAL=TVAL*AA
DO 25 J=1,4
VAL=0.
DO 20 I=PTR(J),PTR(J)-1+NORD(J)
20 VAL=VAL+W(I)*(F(BB+AA*R(I))+F(BB-AA*R(I)))
VAL=VAL*AA
TOL=MAX(TOLABS,TOLREL*ABS(VAL))
IF (ABS(TVAL-VAL).LT.TOL) THEN
CtLhGausInt=CtLhGausInt+VAL
NLIMS=NLIMS-2
IF (NLIMS.NE.0) GOTO 10
RETURN
END IF
25 TVAL=VAL
IF (NMAX.EQ.2) THEN
CtLhGausInt=VAL
RETURN
END IF
IF (NLIMS.GT.(NMAX-2)) THEN
write(*,50) CtLhGausInt,NMAX,BB-AA,BB+AA
RETURN
END IF
XLIMS(NLIMS+1)=BB
XLIMS(NLIMS+2)=BB+AA
XLIMS(NLIMS)=BB
NLIMS=NLIMS+2
GOTO 10
50 FORMAT (' CtLhGausInt FAILS, CtLhGausInt,NMAX,XL,XR=', &
& G15.7,I5,2G15.7)
END
SUBROUTINE CtLhHINTEG (NX, F, H)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MXPN = MXF * 2 + 2)
PARAMETER (MXQX= MXQ * MXX, MXPQX = MXQX * MXPN)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
COMMON / LhCtHINTEC / GH(NDG, MXX)
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
DIMENSION F(NX), H(NX), G(MXX)
DZ = 1D0 / (NX-1)
DO 20 I = 1, NX-2
NP = NX - I + 1
TEM = GH(1,I)*F(I) + GH(2,I)*F(I+1) + GH(3,I)*F(I+2)
DO 30 KZ = 3, NP
IY = I + KZ - 1
W = XA(I,1) / XA(IY,1)
G(KZ) = DXTZ(IY)*(F(IY)-W*F(I))/(1.-W)
30 CONTINUE
HTEM = CtLhSMPSNA (NP-2, DZ, G(3), ERR)
TEM1 = F(I) * ELY(I)
H(I) = TEM + HTEM + TEM1
20 END DO
H(NX-1) = F(NX) - F(NX-1) + F(NX-1) * (ELY(NX-1) - XA(NX-1,0))
H(NX) = 0
RETURN
END
SUBROUTINE CtLhHQRK (NX, TT, NQRK, Y, F)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
DIMENSION Y(NX), F(NX)
IF (NX .GT. 1) GOTO 11
11 CONTINUE
DO IZ = 1, NX
IF (NX .GT. 1) THEN
F(IZ) = 0
EXIT
EndIf
END DO
RETURN
END
SUBROUTINE CtLhINTEGR (NX, M, F, G, IR)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
CHARACTER MSG*80
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MXPN = MXF * 2 + 2)
PARAMETER (MXQX= MXQ * MXX, MXPQX = MXQX * MXPN)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
COMMON / LhCtVARBAB / GB(NDG, NDH, MXX), H(NDH, MXX, M1:M2)
DIMENSION F(NX), G(NX)
DATA IWRN1, IWRN2 / 0, 0 /
IRR = 0
IF (NX .LT. 1 .OR. XA(NX-1,1) .EQ. 0D0) THEN
MSG = 'NX out of range in CtLhINTEGR call'
CALL CtLhWARNI (IWRN1, MSG, 'NX', NX, 0, MXX, 0)
IRR = 1
EndIf
IF (M .LT. M1 .OR. M .GT. M2) THEN
MSG ='Exponent M out of range in CtLhINTEGR'
CALL CtLhWARNI (IWRN2, MSG, 'M', M, M1, M2, 1)
IRR = 2
EndIf
G(NX) = 0D0
TEM = H(1, NX-1, -M) * F(NX-2) + H(2, NX-1, -M) * F(NX-1) &
& + H(3, NX-1, -M) * F(NX)
IF (M .EQ. 0) THEN
G(NX-1) = TEM
Else
G(NX-1) = TEM * XA(NX-1, M)
EndIf
DO 10 I = NX-2, 2, -1
TEM = TEM + H(1,I,-M)*F(I-1) + H(2,I,-M)*F(I) &
& + H(3,I,-M)*F(I+1) + H(4,I,-M)*F(I+2)
IF (M .EQ. 0) THEN
G(I) = TEM
Else
G(I) = TEM * XA(I, M)
EndIf
10 END DO
TEM = TEM + H(2,1,-M)*F(1) + H(3,1,-M)*F(2) + H(4,1,-M)*F(3)
IF (M .EQ. 0) THEN
G(1) = TEM
Else
G(1) = TEM * XA(1, M)
EndIf
IR = IRR
RETURN
END
SUBROUTINE CtLhKERNEL &
&(XX, FF1, FG1, GF1, GG1, PNSP, PNSM, FF2, FG2, GF2, GG2, NFL, IRT)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (PI = 3.141592653589793d0, PI2 = PI ** 2)
PARAMETER (D0 = 0.0, D1 = 1.0)
DATA CF, CG, TR, IWRN / 1.33333333333333d0, 3.0d0, 0.5d0, 0 /
IRT = 0
TRNF = TR * NFL
X = XX
IF (X .LE. 0. .OR. X .GE. 1.) THEN
CALL CtLhWARNR(IWRN, 'X out of range in CtLhKERNEL', 'X', X, &
& D0, D1, 1)
IRT = 1
RETURN
EndIf
XI = 1./ X
X2 = X ** 2
XM1I = 1./ (1.- X)
XP1I = 1./ (1.+ X)
XLN = LOG (X)
XLN2 = XLN ** 2
XLN1M = LOG (1.- X)
SPEN2 = CtLhSPENC2 (X)
FFP = (1.+ X2) * XM1I
FGP = (2.- 2.* X + X2) / X
GFP = 1. - 2.* X + 2.* X2
GGP = XM1I + XI - 2. + X - X2
FFM = (1.+ X2) * XP1I
FGM = - (2.+ 2.* X + X2) / X
GFM = 1. + 2.* X + 2.* X2
GGM = XP1I - XI - 2. - X - X2
FF1 = CF * FFP * (1.- X)
FG1 = CF * FGP * X
GF1 = 2.* TRNF * GFP
GG1 = 2.* CG * GGP * X * (1.-X)
PCF2 = -2.* FFP *XLN*XLN1M - (3.*XM1I + 2.*X)*XLN &
& - (1.+X)/2.*XLN2 - 5.*(1.-X)
PCFG = FFP * (XLN2 + 11.*XLN/3.+ 67./9.- PI**2 / 3.) &
& + 2.*(1.+X) * XLN + 40.* (1.-X) / 3.
PCFT = (FFP * (- XLN - 5./3.) - 2.*(1.-X)) * 2./ 3.
PQQB = 2.* FFM * SPEN2 + 2.*(1.+X)*XLN + 4.*(1.-X)
PQQB = (CF**2-CF*CG/2.) * PQQB
PQQ2 = CF**2 * PCF2 + CF*CG * PCFG / 2. + CF*TRNF * PCFT
PNSP = (PQQ2 + PQQB) * (1.-X)
PNSM = (PQQ2 - PQQB) * (1.-X)
FFCF2 = - 1. + X + (1.- 3.*X) * XLN / 2. - (1.+ X) * XLN2 / 2. &
& - FFP * (3.* XLN / 2. + 2.* XLN * XLN1M) &
& + FFM * 2.* SPEN2
FFCFG = 14./3.* (1.-X) &
& + FFP * (11./6.* XLN + XLN2 / 2. + 67./18. - PI2 / 6.) &
& - FFM * SPEN2
FFCFT = - 16./3. + 40./3.* X + (10.* X + 16./3.* X2 + 2.) * XLN &
& - 112./9.* X2 + 40./9./X - 2.* (1.+ X) * XLN2 &
& - FFP * (10./9. + 2./3. * XLN)
FGCF2 = - 5./2.- 7./2.* X + (2.+ 7./2.* X) * XLN + (X/2.-1.)*XLN2 &
& - 2.* X * XLN1M &
& - FGP * (3.* XLN1M + XLN1M ** 2)
FGCFG = 28./9. + 65./18.* X + 44./9. * X2 - (12.+ 5.*X + 8./3.*X2)&
& * XLN + (4.+ X) * XLN2 + 2.* X * XLN1M &
& + FGP * (-2.*XLN*XLN1M + XLN2/2. + 11./3.*XLN1M + XLN1M**2 &
& - PI2/6. + 0.5) &
& + FGM * SPEN2
FGCFT = -4./3.* X - FGP * (20./9.+ 4./3.*XLN1M)
GFCFT = 4.- 9.*X + (-1.+ 4.*X)*XLN + (-1.+ 2.*X)*XLN2 + 4.*XLN1M &
& + GFP * (-4.*XLN*XLN1M + 4.*XLN + 2.*XLN2 - 4.*XLN1M &
& + 2.*XLN1M**2 - 2./3.* PI2 + 10.)
GFCGT = 182./9.+ 14./9.*X + 40./9./X + (136./3.*X - 38./3.)*XLN &
& - 4.*XLN1M - (2.+ 8.*X)*XLN2 &
& + GFP * (-XLN2 + 44./3.*XLN - 2.*XLN1M**2 + 4.*XLN1M &
& + PI2/3. - 218./9.) &
& + GFM * 2. * SPEN2
GGCFT = -16.+ 8.*X + 20./3.*X2 + 4./3./X + (-6.-10.*X)*XLN &
& - 2.* (1.+ X) * XLN2
GGCGT = 2.- 2.*X + 26./9.*X2 - 26./9./X - 4./3.*(1.+X)*XLN &
& - GGP * 20./9.
GGCG2 = 27./2.*(1.-X) + 67./9.*(X2-XI) + 4.*(1.+X)*XLN2 &
& + (-25.+ 11.*X - 44.*X2)/3.*XLN &
& + GGP * (67./9.- 4.*XLN*XLN1M + XLN2 - PI2/3.) &
& + GGM * 2.* SPEN2
FF2 = CF * TRNF * FFCFT + CF ** 2 * FFCF2 + CF * CG * FFCFG
FG2 = CF * TRNF * FGCFT + CF ** 2 * FGCF2 + CF * CG * FGCFG
GF2 = CF * TRNF * GFCFT + CG * TRNF * GFCGT
GG2 = CF * TRNF * GGCFT + CG ** 2 * GGCG2 + CG * TRNF * GGCGT
XLG = (LOG(1./(1.-X)) + 1.)
XG2 = XLG ** 2
FF2 = FF2 * X * (1.- X)
FG2 = FG2 * X / XG2
GF2 = GF2 * X / XG2
GG2 = GG2 * X * (1.- X)
RETURN
END
SUBROUTINE CtLhLAMCWZ
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
LOGICAL SET
CALL CtLhSETL1 (NF, AL)
END
FUNCTION LhCtNAMQCD(NNAME)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
CHARACTER NNAME*(*), NAME*8
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
LOGICAL SET
CHARACTER ONECH*(1)
ONECH = '0'
IASC0 = ICHAR(ONECH)
NAME = NNAME
LhCtNAMQCD=0
IF ( (NAME .EQ. 'ALAM') .OR. (NAME .EQ. 'LAMB') .OR. &
& (NAME .EQ. 'LAM') .OR. (NAME .EQ. 'LAMBDA') ) &
& LhCtNAMQCD=1
IF ( (NAME .EQ. 'NFL') .OR. (NAME(1:3) .EQ. '#FL') .OR. &
& (NAME .EQ. '# FL') ) &
& LhCtNAMQCD=2
DO 10 I=1, 9
IF (NAME .EQ. 'M'//CHAR(I+IASC0)) &
& LhCtNAMQCD=I+2
10 CONTINUE
DO 20 I= 0, NF
IF (NAME .EQ. 'LAM'//CHAR(I+IASC0)) &
& LhCtNAMQCD=I+13
20 CONTINUE
IF (NAME(:3).EQ.'ORD' .OR. NAME(:3).EQ.'NRD') LhCtNAMQCD = 24
RETURN
END
FUNCTION LhCtNFL(AMU)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtCWZPRM / ALAM(0:9), AMHAT(0:9), AMN, NHQ
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
LOGICAL SET
IF (.NOT. SET) CALL CtLhLAMCWZ
LhCtNFL = NF - NHQ
IF ((LhCtNFL .EQ. NF) .OR. (AMU .LE. AMN)) GOTO 20
DO 10 I = NF - NHQ + 1, NF
IF (AMU .GE. AMHAT(I)) THEN
LhCtNFL = I
ELSE
GOTO 20
ENDIF
10 CONTINUE
20 RETURN
END
SUBROUTINE CtLhNSEVL (RHS, IKNL,NX,NT,JT,DT,TIN,NEFF,U0,UN)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MXPN = MXF * 2 + 2)
PARAMETER (MXQX= MXQ * MXX, MXPQX = MXQX * MXPN)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
DIMENSION U0(NX), UN(0:NX, 0:NT)
DIMENSION Y0(MXX), Y1(MXX), YP(MXX), F0(MXX), F1(MXX), FP(MXX)
external rhs
DDT = DT / JT
IF (NX .GT. MXX) THEN
WRITE (*,*) 'Nx =', NX, ' greater than Max pts in CtLhNSEVL.'
STOP 'Program stopped in CtLhNSEVL'
EndIf
! ++ remove unused quantities (jcp)
! ++ TMD = TIN + DT * NT / 2.
! ++ AMU = EXP(TMD)
! ++ TEM = 6./ (33.- 2.* NEFF) / CtLhALPI(AMU)
! ++ TLAM = TMD - TEM
DO 9 IX = 1, NX
UN(IX, 0) = U0(IX)
9 END DO
UN(0, 0) = 3D0*U0(1) - 3D0*U0(2) - U0(1)
TT = TIN
DO 10 IZ = 1, NX
Y0(IZ) = U0(IZ)
10 END DO
DO 20 IS = 1, NT
DO 202 JS = 1, JT
IRND = (IS-1) * JT + JS
IF (IRND .EQ. 1) THEN
CALL RHS (TT, Neff, Y0, F0)
DO 250 IZ = 1, NX
Y0(IZ) = Y0(IZ) + DDT * F0(IZ)
250 CONTINUE
TT = TT + DDT
CALL RHS (TT, NEFF, Y0, F1)
DO 251 IZ = 1, NX
Y1(IZ) = U0(IZ) + DDT * (F0(IZ) + F1(IZ)) / 2D0
251 CONTINUE
Else
CALL RHS (TT, NEFF, Y1, F1)
DO 252 IZ = 1, NX
YP(IZ) = Y1(IZ) + DDT * (3D0 * F1(IZ) - F0(IZ)) / 2D0
252 CONTINUE
TT = TT + DDT
CALL RHS (TT, NEFF, YP, FP)
DO 253 IZ = 1, NX
Y1(IZ) = Y1(IZ) + DDT * (FP(IZ) + F1(IZ)) / 2D0
F0(IZ) = F1(IZ)
253 CONTINUE
EndIf
202 CONTINUE
DO 260 IZ = 1, NX
UN (IZ, IS) = Y1(IZ)
260 CONTINUE
UN(0, IS) = 3D0*Y1(1) - 3D0*Y1(2) + Y1(3)
20 END DO
RETURN
END
SUBROUTINE LhCtNSRHSM (TT, NEFF, FI, FO)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL LSTX
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtXYARAY / ZZ(MXX, MXX), ZV(0:MXX)
COMMON / LhCtKRNL01 / AFF2(MXX),AFG2(MXX),AGF2(MXX),AGG2(MXX), &
& ANSP (MXX), ANSM (MXX), ZFG2, ZGF2, ZQQB
COMMON / LhCtKRN2ND / FFG(MXX, MXX), GGF(MXX, MXX), PNS(MXX, MXX)
COMMON / LhCtEVLPAC / AL, IKNL, IPD0, IHDN, NfMx
DIMENSION G1(MXX), FI(NX), FO(NX)
DIMENSION W0(MXX), W1(MXX), WH(MXX)
S = EXP(TT)
Q = AL * EXP (S)
CPL = CtLhALPI(Q)
CPL2= CPL ** 2 / 2. * S
CPL = CPL * S
CALL CtLhINTEGR (NX, 0, FI, W0, IR1)
CALL CtLhINTEGR (NX, 1, FI, W1, IR2)
CALL CtLhHINTEG (NX, FI, WH)
DO 230 IZ = 1, NX
FO(IZ) = 2.* FI(IZ) + 4./3.* ( 2.* WH(IZ) - W0(IZ) - W1(IZ))
FO(IZ) = CPL * FO(IZ)
230 END DO
IF (IKNL .EQ. 2) THEN
DZ = 1./ (NX - 1)
DO 21 IX = 1, NX-1
NP = NX - IX + 1
IS = NP
DO 31 KZ = 2, NP
IY = IX + KZ - 1
IT = NX - IY + 1
XY = ZZ (IS, IT)
G1(KZ) = PNS (IS,IT) * (FI(IY) - XY * FI(IX))
31 CONTINUE
TEM1 = CtLhSMPNOL (NP, DZ, G1, ERR)
TMP2 = (TEM1 - FI(IX) * ANSM(IX)) * CPL2
FO(IX) = FO(IX) + TMP2
21 END DO
EndIf
RETURN
END
SUBROUTINE LhCtNSRHSP (TT, NEFF, FI, FO)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL LSTX
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtXYARAY / ZZ(MXX, MXX), ZV(0:MXX)
COMMON / LhCtKRNL01 / AFF2(MXX),AFG2(MXX),AGF2(MXX),AGG2(MXX), &
& ANSP (MXX), ANSM (MXX), ZFG2, ZGF2, ZQQB
COMMON / LhCtKRN2ND / FFG(MXX, MXX), GGF(MXX, MXX), PNS(MXX, MXX)
COMMON / LhCtEVLPAC / AL, IKNL, IPD0, IHDN, NfMx
DIMENSION G1(MXX), FI(NX), FO(NX)
DIMENSION W0(MXX), W1(MXX), WH(MXX)
S = EXP(TT)
Q = AL * EXP (S)
CPL = CtLhALPI(Q)
CPL2= CPL ** 2 / 2. * S
CPL = CPL * S
CALL CtLhINTEGR (NX, 0, FI, W0, IR1)
CALL CtLhINTEGR (NX, 1, FI, W1, IR2)
CALL CtLhHINTEG (NX, FI, WH)
DO 230 IZ = 1, NX
FO(IZ) = 2.* FI(IZ) + 4./3.* ( 2.* WH(IZ) - W0(IZ) - W1(IZ))
FO(IZ) = CPL * FO(IZ)
230 END DO
IF (IKNL .EQ. 2) THEN
DZ = 1./ (NX - 1)
DO 21 IX = 1, NX-1
NP = NX - IX + 1
DO 31 KZ = 2, NP
IY = IX + KZ - 1
XY = ZZ (NX-IX+1, NX-IY+1)
G1(KZ) = PNS (IX,IY) * (FI(IY) - XY * FI(IX))
31 CONTINUE
TEM1 = CtLhSMPNOL (NP, DZ, G1, ERR)
TMP2 = (TEM1 + FI(IX) * (-ANSP(IX) + ZQQB)) * CPL2
FO(IX) = FO(IX) + TMP2
21 END DO
EndIf
RETURN
END
FUNCTION CtLhPARDIS (IPRTN, XX, QQ)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
include 'parmsetup.inc'
Character Msg*80
LOGICAL LSTX
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MXPN = MXF * 2 + 2)
PARAMETER (MXQX= MXQ * MXX, MXPQX = MXQX * MXPN)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
PARAMETER (Smll = 1D-9)
parameter(nqvec = 4)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtXYARAY / ZZ(MXX, MXX), ZV(0:MXX)
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
COMMON / LhCtQARAY1 / QINI,QMAX, QV(0:MXQ),TV(0:MXQ), NT,JT,NG
COMMON / LhCtQARAY2 / TLN(MXF), DTN(MXF), NTL(MXF), NTN(MXF)
COMMON / LhCtEVLPAC / AL, IKNL, IPD0, IHDN, NfMx
COMMON / LhCtPEVLDT / UPD(MXPQX,nmxset), KF, Nelmt
COMMON / LhCtCOMQMS / VALQMS(9)
dimension fvec(4), fij(4)
dimension xvpow(0:mxx)
Data Iwrn1, Iwrn2, Iwrn3, OneP / 3*0, 1.00001 /
!**** choice of interpolation variable
data xpow / 0.3d0 /
data nxsave / 0 /
save xvpow, nxsave
save xlast, qlast
save jq, jx, JLx, JLq, ss, sy2, sy3, s23, ty2, ty3
save const1 , const2, const3, const4, const5, const6
save tt, t13, t12, t23, t34 , t24, tmp1, tmp2, tdet
!
call getnset(iset)
!
if(nx .ne. nxsave) then
xvpow(0) = 0D0
do i = 1, nx
xvpow(i) = xv(i)**xpow
enddo
nxsave = nx
endif
X = XX
Q = QQ
! if((x.lt.xmin).or.(x.gt.1.d0)) print 98,x
! 98 format(' WARNING: X=',e12.5,' OUT OF RANGE')
! if((q.lt.qini).or.(q.gt.qmax)) print 99,q
! 99 format(' WARNING: Q=',e12.5,' OUT OF RANGE')
! enforce threshold early to improve speed...
ii = iabs(IPRTN)
if(ii .ne. 0) then
if(QQ .lt. VALQMS(ii) ) then
ctlhpardis = 0.d0
return
endif
endif
! force pardis = 0.0d0 at exactly =1.0d0 - added mrw 10/May/06
if(xx .eq. 1.0d0) then
ctlhpardis = 0.0d0
return
endif
! skip the initialization in x if same as in the previous call.
if(x .eq. xlast) goto 100
xlast = x
JLx = -1
JU = Nx+1
11 If (JU-JLx .GT. 1) Then
JM = (JU+JLx) / 2
If (X .Ge. XV(JM)) Then
JLx = JM
Else
JU = JM
Endif
Goto 11
Endif
If (JLx .LE. -1) Then
Print '(A,1pE12.4)','Severe error: x <= 0 in ParDis x=', x
Stop
ElseIf (JLx .Eq. 0) Then
Jx = 0
Msg = '0 < X < Xmin in ParDis; extrapolation used!'
CALL CtLhWARNR (IWRN1, Msg, 'X', X, Xmin, 1D0, 1)
Elseif (JLx .LE. Nx-2) Then
Jx = JLx - 1
Elseif (JLx.Eq.Nx-1 .or. x.LT.OneP) Then
Jx = JLx - 2
Else
Print '(A,1pE12.4)','Severe error: x > 1 in ParDis x=', x
Stop
Endif
ss = x**xpow
If (JLx.Ge.2 .and. JLx.Le.Nx-2) Then
svec1 = xvpow(jx)
svec2 = xvpow(jx+1)
svec3 = xvpow(jx+2)
svec4 = xvpow(jx+3)
s12 = svec1 - svec2
s13 = svec1 - svec3
s23 = svec2 - svec3
s24 = svec2 - svec4
s34 = svec3 - svec4
sy2 = ss - svec2
sy3 = ss - svec3
const1 = s13/s23
const2 = s12/s23
const3 = s34/s23
const4 = s24/s23
s1213 = s12 + s13
s2434 = s24 + s34
sdet = s12*s34 - s1213*s2434
tmp = sy2*sy3/sdet
const5 = (s34*sy2-s2434*sy3)*tmp/s12
const6 = (s1213*sy2-s12*sy3)*tmp/s34
EndIf
100 continue
! skip the initialization in q if same as in the previous call.
if(q .eq. qlast) goto 110
qlast = q
tt = log(log(Q/Al))
JLq = -1
JU = NT+1
12 If (JU-JLq .GT. 1) Then
JM = (JU+JLq) / 2
If (Q .GE. QV(JM)) Then
JLq = JM
Else
JU = JM
Endif
Goto 12
Endif
If (JLq .LE. 0) Then
Jq = 0
If (JLq .LT. 0) Then
Msg = 'Q < Q0 in ParDis; extrapolation used!'
CALL CtLhWARNR (IWRN2, Msg, 'Q', Q, Qini, 1D0, 1)
EndIf
Elseif (JLq .LE. Nt-2) Then
Jq = JLq - 1
Else
Jq = Nt - 3
If (JLq .GE. Nt) Then
Msg = 'Q > Qmax in ParDis; extrapolation used!'
CALL CtLhWARNR (IWRN3, Msg, 'Q', Q, Qmax, 1D0, 1)
Endif
Endif
If (JLq.GE.1 .and. JLq.LE.Nt-2) Then
tvec1 = Tv(jq)
tvec2 = Tv(jq+1)
tvec3 = Tv(jq+2)
tvec4 = Tv(jq+3)
t12 = tvec1 - tvec2
t13 = tvec1 - tvec3
t23 = tvec2 - tvec3
t24 = tvec2 - tvec4
t34 = tvec3 - tvec4
ty2 = tt - tvec2
ty3 = tt - tvec3
tmp1 = t12 + t13
tmp2 = t24 + t34
tdet = t12*t34 - tmp1*tmp2
EndIf
110 continue
jtmp = ((IPRTN + NfMx)*(NT+1)+(jq-1))*(NX+1)+jx+1
Do it = 1, nqvec
J1 = jtmp + it*(NX+1)
If (Jx .Eq. 0) Then
fij(1) = 0
fij(2) = Upd(J1+1,iset) * Xa(1,2)
fij(3) = Upd(J1+2,iset) * Xa(2,2)
fij(4) = Upd(J1+3,iset) * Xa(3,2)
Call CtLhPolint4 (XVpow(0), Fij(1), 4, ss, Fx, Dfx)
If (x .GT. 0D0) Fvec(it) = Fx / x**2
ElseIf (JLx .Eq. Nx-1) Then
Call CtLhPolint4 (XVpow(Nx-3), Upd(J1,iset), 4, ss, Fx, Dfx)
Fvec(it) = Fx
Else
sf2 = Upd(J1+1,iset)
sf3 = Upd(J1+2,iset)
Fvec(it) = (const5*(Upd(J1,iset) &
& - sf2*const1 + sf3*const2) &
& + const6*(Upd(J1+3,iset) &
& + sf2*const3 - sf3*const4) &
& + sf2*sy3 - sf3*sy2) / s23
Endif
enddo
If (JLq .LE. 0) Then
Call CtLhPolint4 (TV(0), Fvec(1), 4, tt, ff, Dfq)
ElseIf (JLq .GE. Nt-1) Then
Call CtLhPolint4 (TV(Nt-3), Fvec(1), 4, tt, ff, Dfq)
Else
tf2 = fvec(2)
tf3 = fvec(3)
g1 = ( tf2*t13 - tf3*t12) / t23
g4 = (-tf2*t34 + tf3*t24) / t23
h00 = ((t34*ty2-tmp2*ty3)*(fvec(1)-g1)/t12 &
& + (tmp1*ty2-t12*ty3)*(fvec(4)-g4)/t34)
ff = (h00*ty2*ty3/tdet + tf2*ty3 - tf3*ty2) / t23
EndIf
CtLhPARDIS = ff
Return
END
SUBROUTINE CtLhPARPDF (IACT, NAME, VALUE, IRET)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
CHARACTER NAME*(*), Uname*10
LOGICAL START1
DATA ILEVEL, LRET / 1, 1 /
JRET = IRET
CALL CtLhUPC (NAME, Ln, Uname)
IF (IACT .EQ. 0 .OR. IACT .EQ. 4) then
! > IVALUE = NINT (VALUE) !tentatively remove this since it see
print *,'Fatal error: iact=',iact
stop
ENDIF
START1 = (IACT .NE. 1) .AND. (IACT .NE. 2)
! prepare to remove this stuff, since I think IACT=1 or 2 always
if(start1) then
print *,'Fatal error: start1=',start1
stop
endif
IF (START1) ILEVEL = 1
GOTO (1, 2), ILEVEL
1 START1 = .TRUE.
ILEVEL = 0
CALL CtLhParQcd (IACT, Uname(1:Ln), VALUE, JRET)
IF (JRET .EQ. 1) GOTO 11
IF (JRET .EQ. 2) GOTO 12
IF (JRET .EQ. 3) GOTO 13
IF (JRET .GT. 4) GOTO 15
ILEVEL = ILEVEL + 1
2 CALL CtLhEVLPAR (IACT, Uname(1:Ln), VALUE, JRET)
IF (JRET .EQ. 1) GOTO 11
IF (JRET .EQ. 2) GOTO 12
IF (JRET .EQ. 3) GOTO 13
IF (JRET .GT. 4) GOTO 15
ILEVEL = ILEVEL + 1
IF (.NOT. START1) GOTO 1
IF (JRET .EQ. 0) GOTO 10
GOTO 14
10 CONTINUE
11 CONTINUE
12 CONTINUE
13 CONTINUE
14 CONTINUE
15 CONTINUE
IF (JRET .NE. 4) LRET = JRET
IF (LRET.EQ.0 .OR. LRET.EQ.2 .OR. LRET.EQ.3) THEN
PRINT *, 'Error in CtLhPARPDF: IRET, IACT, NAME, VALUE =', &
& LRET, IACT, NAME, VALUE
PRINT *, 'fatal error in CtLhparpdf'
stop
EndIf
IRET= JRET
RETURN
END
SUBROUTINE CtLhParQcd(IACT,NAME,VALUE,IRET)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
INTEGER IACT,IRET
CHARACTER*(*) NAME
IRET=1
IF (IACT.EQ.0) THEN
WRITE (NINT(VALUE), *) 'LAM(BDA), NFL, ORD(ER), Mi, ', &
& '(i in 1 to 9), LAMi (i in 1 to NFL)'
IRET=4
ELSEIF (IACT.EQ.1) THEN
CALL CtLhQCDSET (NAME,VALUE,IRET)
ELSEIF (IACT.EQ.2) THEN
CALL CtLhQCDGET (NAME,VALUE,IRET)
ELSE
IRET=3
ENDIF
RETURN
END
FUNCTION CtLhPFF1 (XX)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL LA, LB, LSTX
PARAMETER (D0=0D0, D1=1D0, D2=2D0, D3=3D0, D4=4D0, D10=1D1)
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
PARAMETER (MX = 3)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtKRNL00 / DZ, XL(MX), NNX
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
COMMON / LhCtKRN1ST / FF1(0:MXX),FG1(0:MXX),GF1(0:MXX),GG1(0:MXX),&
& FF2(0:MXX), FG2(0:MXX), GF2(0:MXX), GG2(0:MXX), &
& PNSP(0:MXX), PNSM(0:MXX)
SAVE
DATA LA, LB / 2 * .FALSE. /
LB = .TRUE.
ENTRY CtLhTFF1(ZZ)
LA = .TRUE.
IF (LA .AND. .NOT.LB) THEN
Z = ZZ
X = CtLhXFRMZ (Z)
Else
X = XX
EndIf
IF (X .GE. D1) THEN
CtLhPFF1 = 0
RETURN
ElseIF (X .GE. XMIN) THEN
Z = CtLhZFRMX (X)
TEM = CtLhFINTRP (FF1, -DZ, DZ, NX, Z, ERR, IRT)
Else
CALL CtLhPOLIN1 (XL, FF1(1), MX, X, TEM, ERR)
EndIf
IF (LA) THEN
IF (LB) THEN
CtLhPFF1 = TEM / (1.-X)
LB =.FALSE.
Else
CtLhTFF1 = TEM / (1.-X) * CtLhDXDZ(Z)
EndIf
LA =.FALSE.
Else
IF (LB) THEN
! +++ something is wrong, since QFF1 and RFF1 are not used.
! +++ but this code appears to only be used for extrapolation
! +++ to small x, which is unreliable anyway, so ignore for now (jcp)
QFF1 = TEM
LB =.FALSE.
Else
RFF1 = TEM * X / (1.-X)
EndIf
EndIf
RETURN
ENTRY CtLhFNSP (XX)
X = XX
IF (X .GE. D1) THEN
CtLhFNSP = 0.
RETURN
ElseIF (X .GE. XMIN) THEN
Z = CtLhZFRMX (X)
TEM = CtLhFINTRP (PNSP, -DZ, DZ, NX, Z, ERR, IRT)
Else
CALL CtLhPOLIN1 (XL, PNSP(1), MX, X, TEM, ERR)
EndIf
CtLhFNSP = TEM / (1.- X)
RETURN
ENTRY CtLhFNSM (XX)
X = XX
IF (X .GE. D1) THEN
CtLhFNSM = 0.
RETURN
ElseIF (X .GE. XMIN) THEN
Z = CtLhZFRMX (X)
TEM = CtLhFINTRP (PNSM, -DZ, DZ, NX, Z, ERR, IRT)
Else
CALL CtLhPOLIN1 (XL, PNSM(1), MX, X, TEM, ERR)
EndIf
CtLhFNSM = TEM / (1.- X)
RETURN
ENTRY CtLhRGG1 (XX)
X = XX
IF (X .GE. D1) THEN
!error corrected? (jcp)
CtLhRGG1= 0
RETURN
ElseIF (X .GE. XMIN) THEN
Z = CtLhZFRMX (X)
TEM = CtLhFINTRP (GG1, -DZ, DZ, NX, Z, ERR, IRT)
Else
CALL CtLhPOLIN1 (XL, GG1(1), MX, X, TEM, ERR)
EndIf
IF (LA) THEN
!error corrected? (jcp)
CtLhRGG1 = TEM / X / (1.-X)
LA =.FALSE.
Else
IF (LB) THEN
!error corrected? (jcp)
CtLhRGG1 = TEM / X
LB =.FALSE.
Else
CtLhRGG1 = TEM / (1.-X)
EndIf
EndIf
RETURN
ENTRY CtLhRFF2 (XX)
X = XX
IF (X .GE. D1) THEN
!error corrected? (jcp)
CtLhRFF2 = 0
RETURN
ElseIF (X .GE. XMIN) THEN
Z = CtLhZFRMX (X)
TEM = CtLhFINTRP (FF2, -DZ, DZ, NX, Z, ERR, IRT)
Else
CALL CtLhPOLIN1 (XL, FF2(1), MX, X, TEM, ERR)
EndIf
IF (LA) THEN
!error corrected? (jcp)
CtLhRFF2 = TEM / X / (1.-X)
LA =.FALSE.
Else
IF (LB) THEN
!error corrected? (jcp)
CtLhRFF2 = TEM / X
LB =.FALSE.
Else
CtLhRFF2 = TEM / (1.-X)
EndIf
EndIf
RETURN
ENTRY CtLhRGG2 (XX)
X = XX
IF (X .GE. D1) THEN
!error corrected? (jcp)
CtLhRGG2 = 0
RETURN
ElseIF (X .GE. XMIN) THEN
Z = CtLhZFRMX (X)
TEM = CtLhFINTRP (GG2, -DZ, DZ, NX, Z, ERR, IRT)
Else
CALL CtLhPOLIN1 (XL, GG2(1), MX, X, TEM, ERR)
EndIf
IF (LA) THEN
!error corrected? (jcp)
CtLhRGG2 = TEM / X / (1.-X)
LA =.FALSE.
Else
IF (LB) THEN
!error corrected? (jcp)
CtLhRGG2 = TEM / X
LB =.FALSE.
Else
CtLhRGG2 = TEM / (1.-X)
EndIf
EndIf
RETURN
END
SUBROUTINE CtLhPOLIN1 (XA,YA,N,X,Y,DY)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (NMAX=10)
DIMENSION XA(N),YA(N),C(NMAX),D(NMAX)
NS=1
DIF=ABS(X-XA(1))
DO 11 I=1,N
DIFT=ABS(X-XA(I))
IF (DIFT.LT.DIF) THEN
NS=I
DIF=DIFT
ENDIF
C(I)=YA(I)
D(I)=YA(I)
11 END DO
Y=YA(NS)
NS=NS-1
DO 13 M=1,N-1
DO 12 I=1,N-M
HO=XA(I)-X
HP=XA(I+M)-X
W=C(I+1)-D(I)
DEN=HO-HP
DEN=W/DEN
D(I)=HP*DEN
C(I)=HO*DEN
12 CONTINUE
IF (2*NS.LT.N-M)THEN
DY=C(NS+1)
ELSE
DY=D(NS)
NS=NS-1
ENDIF
Y=Y+DY
13 END DO
RETURN
END
SUBROUTINE CtLhQARRAY (NINI)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MXPN = MXF * 2 + 2)
PARAMETER (MXQX= MXQ * MXX, MXPQX = MXQX * MXPN)
COMMON / LhCtQARAY1 / QINI,QMAX, QV(0:MXQ),TV(0:MXQ), NT,JT,NG
COMMON / LhCtQARAY2 / TLN(MXF), DTN(MXF), NTL(MXF), NTN(MXF)
COMMON / LhCtEVLPAC / AL, IKNL, IPD0, IHDN, NfMx
NCNT = 0
IF (NT .GE. mxq) NT = mxq - 1
S = LOG(QINI/AL)
TINI = LOG(S)
S = LOG(QMAX/AL)
TMAX = LOG(S)
1 DT0 = (TMAX - TINI) / float(NT)
NINI = LhCtNFL(QINI)
NFMX = LhCtNFL(QMAX)
Call CtLhParQcd (2, 'ORDER', Ord, Ir)
Call CtLhParQcd (2, 'ALAM', Al0, Ir)
Call CtLhParQcd (2, 'NFL', Afl0, Ir)
AFL = NfMx
Call CtLhParQcd (1, 'NFL', AFL, Ir)
Iordr = Nint (Ord)
Ifl0 = Nint (Afl0)
Call CtLhSetLam (Ifl0, Al0, Iordr)
NG = NFMX - NINI + 1
QIN = QINI
QOUT = QINI
S = LOG(QIN/AL)
TIN = LOG(S)
TLN(1) = TIN
NTL(1) = 0
QV(0) = QINI
TV(0) = Tin
DO 20 NEFF = NINI, NFMX
ICNT = NEFF - NINI + 1
IF (NEFF .LT. NFMX) THEN
THRN = CtLhAMHATF (NEFF + 1)
QOUN = MIN (QMAX, THRN)
Else
QOUN = QMAX
EndIf
IF (QOUN-QOUT .LE. 0.0001) THEN
DT = 0
NITR = 0
Else
QOUT = QOUN
S = LOG(QOUT/AL)
TOUT = LOG(S)
TEM = TOUT - TIN
NITR = INT (TEM / DT0) + 1
DT = TEM / NITR
EndIf
DTN (ICNT) = DT
NTN (ICNT) = NITR
TLN (ICNT) = TIN
NTL (ICNT+1) = NTL(ICNT) + NITR
IF (NITR .NE. 0) THEN
DO 205 I = 1, NITR
TV (NTL(ICNT)+I) = TIN + DT * I
S = EXP (TV(NTL(ICNT)+I))
QV (NTL(ICNT)+I) = AL * EXP (S)
205 CONTINUE
EndIf
QIN = QOUT
TIN = TOUT
20 END DO
NCNT = NCNT + 1
NTP = NTL (NG + 1)
ND = NTP - NT
IF (NTP .GE. MXQ) THEN
NT = MXQ - ND - NCNT
GOTO 1
EndIf
NT = NTP
RETURN
END
SUBROUTINE CtLhQCDGET(NAME,VALUE,IRET)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
CHARACTER*(*) NAME
COMMON / LhCtCWZPRM / ALAM(0:9), AMHAT(0:9), AMN, NHQ
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
COMMON / LhCtCOMQMS / VALQMS(9)
LOGICAL SET
PARAMETER (PI=3.141592653589793d0, EULER=0.57721566)
ICODE = LhCtNAMQCD(NAME)
IRET = 1
IF (ICODE .EQ. 1) THEN
VALUE = AL
ELSEIF (ICODE .EQ. 2) THEN
VALUE = NF
ELSEIF ((ICODE .GE. 3) .AND. (ICODE .LE. 12)) THEN
VALUE = VALQMS(ICODE - 2)
ELSEIF ((ICODE .GE. 13) .AND. (ICODE .LE. 13+NF)) THEN
VALUE = ALAM(ICODE - 13)
ELSEIF (ICODE .EQ. 24) THEN
VALUE = NORDER
ELSE
IRET=0
ENDIF
END
SUBROUTINE CtLhQCDSET (NAME,VALUE,IRET)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
CHARACTER*(*) NAME
COMMON / LhCtCOMQMS / VALQMS(9)
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
LOGICAL SET
PARAMETER (PI=3.141592653589793d0, EULER=0.57721566)
IVALUE = NINT(VALUE)
ICODE = LhCtNAMQCD(NAME)
IF (ICODE .EQ. 0) THEN
IRET=0
! print *,'warning empty CtLhQCDSET call: NAME=',
! & NAME,' VALUE=',VALUE
ELSE
IRET = 1
SET = .FALSE.
IF (ICODE .EQ. 1) THEN
IF (VALUE.LE.0) GOTO 12
AL=VALUE
ELSEIF (ICODE .EQ. 2) THEN
IF ( (IVALUE .LT. 0) .OR. (IVALUE .GT. 9)) GOTO 12
NF = IVALUE
ELSEIF ((ICODE .GE. 3) .AND. (ICODE .LE. 11)) THEN
IF (VALUE .LT. 0) GOTO 12
Scle = Min (Value , VALQMS(ICODE - 2))
AlfScle = CtLhALPI(Scle) * Pi
VALQMS(ICODE - 2) = VALUE
Call CtLhAlfSet (Scle, AlfScle)
ELSEIF ((ICODE .GE. 13) .AND. (ICODE .LE. 13+NF)) THEN
IF (VALUE .LE. 0) GOTO 12
CALL CtLhSETL1 (ICODE-13, VALUE)
ELSEIF (ICODE .EQ. 24) THEN
IF ((IVALUE .LT. 1) .OR. (IVALUE .GT. 2)) GOTO 12
NORDER = IVALUE
ENDIF
IF (.NOT. SET) CALL CtLhLAMCWZ
ENDIF
RETURN
12 IRET=2
RETURN
END
FUNCTION CtLhQZBRNT(FUNC, X1, X2, TOLIN, IRT)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (ITMAX = 1000, EPS = 3.E-12)
external func
TOL = ABS(TOLIN)
A=X1
B=X2
FA=FUNC(A)
FB=FUNC(B)
IF(FB*FA.GT.0.) THEN
WRITE (*, *) 'Root must be bracketed for CtLhQZBRNT.'
IRT = 1
ENDIF
FC=FB
DO 11 ITER=1,ITMAX
IF(FB*FC.GT.0.) THEN
C=A
FC=FA
D=B-A
E=D
ENDIF
IF(ABS(FC).LT.ABS(FB)) THEN
A=B
B=C
C=A
FA=FB
FB=FC
FC=FA
ENDIF
TOL1=2.*EPS*ABS(B)+0.5*TOL
XM=.5*(C-B)
IF(ABS(XM).LE.TOL1 .OR. FB.EQ.0.)THEN
CtLhQZBRNT=B
RETURN
ENDIF
IF(ABS(E).GE.TOL1 .AND. ABS(FA).GT.ABS(FB)) THEN
S=FB/FA
IF(A.EQ.C) THEN
P=2.*XM*S
Q=1.-S
ELSE
Q=FA/FC
R=FB/FC
P=S*(2.*XM*Q*(Q-R)-(B-A)*(R-1.))
Q=(Q-1.)*(R-1.)*(S-1.)
ENDIF
IF(P.GT.0.) Q=-Q
P=ABS(P)
IF(2.*P .LT. MIN(3.*XM*Q-ABS(TOL1*Q),ABS(E*Q))) THEN
E=D
D=P/Q
ELSE
D=XM
E=D
ENDIF
ELSE
D=XM
E=D
ENDIF
A=B
FA=FB
IF(ABS(D) .GT. TOL1) THEN
B=B+D
ELSE
B=B+SIGN(TOL1,XM)
ENDIF
FB=FUNC(B)
11 END DO
WRITE (*, *) 'CtLhQZBRNT exceeding maximum iterations.'
IRT = 2
CtLhQZBRNT=B
RETURN
END
SUBROUTINE CtLhRATINT(XA,YA,N,X,Y,DY)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (NMAX=10,TINY=1.E-25)
DIMENSION XA(N),YA(N),C(NMAX),D(NMAX)
NS=1
HH=ABS(X-XA(1))
DO 11 I=1,N
H=ABS(X-XA(I))
IF (H.EQ.0.)THEN
Y=YA(I)
DY=0.0
RETURN
ELSE IF (H.LT.HH) THEN
NS=I
HH=H
ENDIF
C(I)=YA(I)
D(I)=YA(I)+TINY
11 END DO
Y=YA(NS)
NS=NS-1
DO 13 M=1,N-1
DO 12 I=1,N-M
W=C(I+1)-D(I)
H=XA(I+M)-X
T=(XA(I)-X)*D(I)/H
DD=T-C(I+1)
DD=W/DD
D(I)=C(I+1)*DD
C(I)=T*DD
12 CONTINUE
IF (2*NS.LT.N-M)THEN
DY=C(NS+1)
ELSE
DY=D(NS)
NS=NS-1
ENDIF
Y=Y+DY
13 END DO
RETURN
END
FUNCTION CtLhRTALF (EFLLN)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
include 'parmsetup.inc'
PARAMETER (PI = 3.141592653589793d0)
COMMON / CtLhRTALFC / ALFST, JORD, NEFF
EFMULM = EXP (EFLLN)
TEM1 = PI / ALFST
TEM2 = 1. / CtLhALPQCD (JORD, NEFF, EFMULM, I)
CtLhRTALF = TEM1 - TEM2
END
Subroutine CtLhbldat1
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
include 'parmsetup.inc'
LOGICAL LSTX
PARAMETER (MXX = 105, MXQ = 25, MxF = 6)
PARAMETER (MxPN = MxF * 2 + 2)
PARAMETER (MxQX= MXQ * MXX, MxPQX = MxQX * MxPN)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtQARAY1 / QINI,QMAX, QV(0:MXQ),TV(0:MXQ), NT,JT,NG
COMMON / LhCtEVLPAC / AL, IKNL, IPD0, IHDN, NfMx
COMMON / LhCtPEVLDT / UPD(MXPQX,nmxset), KF, Nelmt
PARAMETER (NF0 = 4, Nshp = 8,NEX = Nshp+2)
XMIN = .999999D-4
XCR = 1.5
JT = 1
Return
END
SUBROUTINE CtLhSETL1 (NEF, VLAM)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL SET
COMMON / LhCtCWZPRM / ALAM(0:9), AMHAT(0:9), AMN, NHQ
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
COMMON / LhCtCOMQMS / VALQMS(9)
IF (NEF .LT. 0 .OR. NEF .GT. NF) THEN
WRITE(*,*)'NEF out of range in CtLhSETL1: NEF NF =',NEF,NF
STOP
ENDIF
AMHAT(0) = 0.
DO 5 N = 1, NF
AMHAT(N) = VALQMS(N)
5 CONTINUE
ALAM(NEF) = VLAM
DO 10 N = NEF, 1, -1
CALL CtLhTRNLAM(NORDER, N, -1, IR1)
10 CONTINUE
DO 20 N = NEF, NF-1
CALL CtLhTRNLAM(NORDER, N, 1, IR1)
20 CONTINUE
DO 30, N = NF, 1, -1
IF ((ALAM(N) .GE. 0.7 * AMHAT(N)) &
& .OR. (ALAM(N-1) .GE. 0.7 * AMHAT(N)))THEN
NHQ = NF - N
GOTO 40
ENDIF
30 CONTINUE
NHQ = NF
40 CONTINUE
DO 50, N = NF-NHQ, 1, -1
AMHAT(N) = 0
ALAM(N-1) = ALAM(N)
50 CONTINUE
AMN = ALAM(NF)
DO 60, N = 0, NF-1
IF (ALAM(N) .GT. AMN) AMN = ALAM(N)
60 CONTINUE
AMN = AMN * 1.0001
AL = ALAM(NF)
SET = .TRUE.
RETURN
END
SUBROUTINE CtLhSETLAM (NEF, WLAM, IRDR)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
LOGICAL SET
IF ((NEF .LT. 0) .OR. (NEF .GT. NF)) THEN
WRITE(*,*)'NEF out of range in CtLhSETLAM: NEF NF=',NEF,NF
STOP
ENDIF
VLAM = WLAM
IF (IRDR .NE. NORDER) then
PRINT *,'fatal error: wanted cnvl1'
stop
ENDIF
CALL CtLhSETL1 (NEF, VLAM)
END
Subroutine CtLhbldat2
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtCOMQMS / VALQMS(9)
COMMON / LhCtQCDPAR_LHA / AL, NF, NORDER, SET
LOGICAL SET
AL = .226d0
NF = 5
NORDER = 2
SET = .FALSE.
VALQMS(1) = 0.
VALQMS(2) = 0.
VALQMS(3) = 0.2d0
VALQMS(4) = 1.3d0
VALQMS(5) = 4.5d0
VALQMS(6) = 174.d0
VALQMS(7) = 0.
VALQMS(8) = 0.
VALQMS(9) = 0.
Return
END
FUNCTION CtLhSMPNOL (NX, DX, FN, ERR)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
DIMENSION FN(NX)
MS = MOD(NX, 2)
IF (NX .LE. 1 .OR. NX .GT. 1000) THEN
PRINT *, 'NX =', NX, ' OUT OF RANGE IN CtLhSMPNOL!'
STOP
ELSEIF (NX .EQ. 2) THEN
TEM = DX * FN(2)
ELSEIF (NX .EQ. 3) THEN
TEM = DX * FN(2) * 2.
ELSE
IF (MS .EQ. 0) THEN
TEM = DX * (23.* FN(2) - 16.* FN(3) + 5.* FN(4)) / 12.
TMP = DX * (3.* FN(2) - FN(3)) / 2.
ERR = ABS(TEM - TMP)
TEM = TEM + CtLhSMPSNA (NX-1, DX, FN(2), ER1)
ERR = ABS(ER1) + ERR
ELSE
TEM = DX * (8.* FN(2) - 4.* FN(3) + 8.* FN(4)) / 3.
TMP = DX * (3.* FN(2) + 2.* FN(3) + 3.* FN(4)) / 2.
ERR = ABS(TEM - TMP)
TEM = TEM + CtLhSMPSNA (NX-4, DX, FN(5), ER1)
ERR = ABS(ER1) + ERR
ENDIF
ENDIF
CtLhSMPNOL = TEM
RETURN
END
FUNCTION CtLhSMPSNA (NX, DX, F, ERR)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (D0=0D0, D1=1D0, D2=2D0, D3=3D0, D4=4D0, D10=1D1)
PARAMETER (MAXX = 1000)
DIMENSION F(NX)
DATA IW1, IW2, TINY / 2*0, 1.E-35 /
IF (DX .LE. 0.) THEN
CALL CtLhWARNR(IW2,'DX cannot be < 0. in CtLhSMPSNA', 'DX', &
& DX, D0, D1, 0)
CtLhSMPSNA = 0.
RETURN
ENDIF
IF (NX .LE. 0 .OR. NX .GT. MAXX) THEN
CALL CtLhWARNI(IW1, 'NX out of range in CtLhSMPSNA', 'NX', NX, &
& 1, MAXX, 1)
SIMP = 0.
ELSEIF (NX .EQ. 1) THEN
SIMP = 0.
ELSEIF (NX .EQ. 2) THEN
SIMP = (F(1) + F(2)) / 2.
ERRD = (F(1) - F(2)) / 2.
ELSE
MS = MOD(NX, 2)
IF (MS .EQ. 0) THEN
ADD = (9.*F(NX) + 19.*F(NX-1) - 5.*F(NX-2) + F(NX-3)) / 24.
NZ = NX - 1
ELSE
ADD = 0.
NZ = NX
ENDIF
IF (NZ .EQ. 3) THEN
SIMP = (F(1) + 4.* F(2) + F(3)) / 3.
TRPZ = (F(1) + 2.* F(2) + F(3)) / 2.
ELSE
SE = F(2)
SO = 0
NM1 = NZ - 1
DO 60 I = 4, NM1, 2
IM1 = I - 1
SE = SE + F(I)
SO = SO + F(IM1)
60 CONTINUE
SIMP = (F(1) + 4.* SE + 2.* SO + F(NZ)) / 3.
TRPZ = (F(1) + 2.* (SE + SO) + F(NZ)) / 2.
ENDIF
ERRD = TRPZ - SIMP
SIMP = SIMP + ADD
ENDIF
CtLhSMPSNA = SIMP * DX
IF (ABS(SIMP) .GT. TINY) THEN
ERR = ERRD / SIMP
ELSE
ERR = 0.
ENDIF
RETURN
END
SUBROUTINE CtLhSNEVL(IKNL,NX,NT,JT,DT,TIN,NEFF,UI,GI,US,GS)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MXQX= MXQ * MXX)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
DIMENSION UI(NX), US(0:NX, 0:NT)
DIMENSION GI(NX), GS(0:NX, 0:NT)
DIMENSION Y0(MXX), Y1(MXX), YP(MXX), F0(MXX), F1(MXX), FP(MXX)
DIMENSION Z0(MXX), Z1(MXX), ZP(MXX), G0(MXX), G1(MXX), GP(MXX)
DATA D0 / 0.0 /
JTT = 2 * JT
DDT = DT / JTT
IF (NX .GT. MXX) THEN
WRITE (*,*) 'Nx =', NX, ' too many pts in CtLhSNEVL'
STOP 'Program stopped in CtLhSNEVL'
EndIf
! ++ remove unused quantities (jcp)
! ++ TMD = TIN + DT * NT / 2.
! ++ AMU = EXP(TMD)
! ++ TEM = 6./ (33.- 2.* NEFF) / CtLhALPI(AMU)
! ++ TLAM = TMD - TEM
DO 9 IX = 1, NX
US (IX, 0) = UI(IX)
GS (IX, 0) = GI(IX)
9 END DO
US ( 0, 0) = (UI(1) - UI(2))* 3D0 + UI(3)
GS ( 0, 0) = (GI(1) - GI(2))* 3D0 + GI(3)
TT = TIN
DO 10 IZ = 1, NX
Y0(IZ) = UI(IZ)
Z0(IZ) = GI(IZ)
10 END DO
DO 20 IS = 1, NT
DO 202 JS = 1, JTT
IRND = (IS-1) * JTT + JS
IF (IRND .EQ. 1) THEN
CALL CtLhSNRHS (TT, NEFF, Y0,Z0, F0,G0)
DO 250 IZ = 1, NX
Y0(IZ) = Y0(IZ) + DDT * F0(IZ)
Z0(IZ) = Z0(IZ) + DDT * G0(IZ)
250 CONTINUE
TT = TT + DDT
CALL CtLhSNRHS (TT, NEFF, Y0, Z0, F1, G1)
DO 251 IZ = 1, NX
Y1(IZ) = UI(IZ) + DDT * (F0(IZ) + F1(IZ)) / 2D0
Z1(IZ) = GI(IZ) + DDT * (G0(IZ) + G1(IZ)) / 2D0
251 CONTINUE
Else
CALL CtLhSNRHS (TT, NEFF, Y1, Z1, F1, G1)
DO 252 IZ = 1, NX
YP(IZ) = Y1(IZ) + DDT * (3D0 * F1(IZ) - F0(IZ)) / 2D0
ZP(IZ) = Z1(IZ) + DDT * (3D0 * G1(IZ) - G0(IZ)) / 2D0
252 CONTINUE
TT = TT + DDT
CALL CtLhSNRHS (TT, NEFF, YP, ZP, FP, GP)
DO 253 IZ = 1, NX
Y1(IZ) = Y1(IZ) + DDT * (FP(IZ) + F1(IZ)) / 2D0
Z1(IZ) = Z1(IZ) + DDT * (GP(IZ) + G1(IZ)) / 2D0
F0(IZ) = F1(IZ)
G0(IZ) = G1(IZ)
253 CONTINUE
EndIf
202 CONTINUE
DO 260 IX = 1, NX
IF (IKNL .GT. 0) THEN
US (IX, IS) = MAX(Y1(IX), D0)
GS (IX, IS) = MAX(Z1(IX), D0)
Else
US (IX, IS) = Y1(IX)
GS (IX, IS) = Z1(IX)
EndIf
260 CONTINUE
US(0, IS) = 3D0*Y1(1) - 3D0*Y1(2) + Y1(3)
GS(0, IS) = 3D0*Z1(1) - 3D0*Z1(2) + Z1(3)
20 END DO
RETURN
END
SUBROUTINE CtLhSNRHS (TT, NEFF, FI, GI, FO, GO)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL LSTX
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtXYARAY / ZZ(MXX, MXX), ZV(0:MXX)
COMMON / LhCtKRNL01 / AFF2(MXX),AFG2(MXX),AGF2(MXX),AGG2(MXX), &
& ANSP (MXX), ANSM (MXX), ZFG2, ZGF2, ZQQB
COMMON / LhCtKRN2ND / FFG(MXX, MXX), GGF(MXX, MXX), PNS(MXX, MXX)
COMMON / LhCtEVLPAC / AL, IKNL, IPD0, IHDN, NfMx
DIMENSION GI(NX), GO(NX), G1(MXX), G2(MXX), G3(MXX), G4(MXX)
DIMENSION FI(NX), FO(NX), W0(MXX), W1(MXX), WH(MXX), WM(MXX)
DIMENSION R0(MXX), R1(MXX), R2(MXX), RH(MXX), RM(MXX)
S = EXP(TT)
Q = AL * EXP (S)
CPL = CtLhALPI(Q)
CPL2= CPL ** 2 / 2. * S
CPL = CPL * S
CALL CtLhINTEGR (NX,-1, FI, WM, IR1)
CALL CtLhINTEGR (NX, 0, FI, W0, IR2)
CALL CtLhINTEGR (NX, 1, FI, W1, IR3)
CALL CtLhINTEGR (NX,-1, GI, RM, IR4)
CALL CtLhINTEGR (NX, 0, GI, R0, IR5)
CALL CtLhINTEGR (NX, 1, GI, R1, IR6)
CALL CtLhINTEGR (NX, 2, GI, R2, IR7)
CALL CtLhHINTEG (NX, FI, WH)
CALL CtLhHINTEG (NX, GI, RH)
IF (IKNL .GT. 0) THEN
DO 230 IZ = 1, NX
FO(IZ) = ( 2D0 * FI(IZ) &
& + 4D0 / 3D0 * ( 2D0 * WH(IZ) - W0(IZ) - W1(IZ) )) &
& + NEFF * ( R0(IZ) - 2D0 * R1(IZ) + 2D0 * R2(IZ) )
FO(IZ) = FO(IZ) * CPL
GO(IZ) = 4D0 / 3D0 * ( 2D0 * WM(IZ) - 2D0 * W0(IZ) + W1(IZ) ) &
& + (33D0 - 2D0 * NEFF) / 6D0 * GI(IZ) &
& + 6D0 * (RH(IZ) + RM(IZ) - 2D0 * R0(IZ) + R1(IZ) - R2(IZ))
GO(IZ) = GO(IZ) * CPL
230 END DO
Else
DO 240 IZ = 1, NX
FO(IZ) = NEFF * (-R0(IZ) + 2.* R1(IZ) ) &
& + 2.* FI(IZ) + 4./ 3.* ( 2.* WH(IZ) - W0(IZ) - W1(IZ) )
FO(IZ) = FO(IZ) * CPL
GO(IZ) = 4./ 3.* ( 2.* W0(IZ) - W1(IZ) ) &
&+ (33.- 2.* NEFF) / 6.* GI(IZ) + 6.*(RH(IZ) + R0(IZ) - 2.* R1(IZ))
GO(IZ) = GO(IZ) * CPL
240 END DO
EndIf
IF (IKNL .EQ. 2) THEN
DZ = 1./(NX - 1)
DO 21 I = 1, NX-1
NP = NX - I + 1
IS = NP
g2(1)=0d0
g3(1)=0d0
DO 31 KZ = 2, NP
IY = I + KZ - 1
IT = NX - IY + 1
XY = ZZ (IS, IT)
G1(KZ) = FFG(I, IY) * (FI(IY) - XY**2 *FI(I))
G4(KZ) = GGF(I, IY) * (GI(IY) - XY**2 *GI(I))
!FG
G2(KZ) = FFG(IS,IT) * (GI(IY) - xy*GI(I))
!GF (usual notat
G3(KZ) = GGF(IS,IT) * (FI(IY) - XY*FI(I))
31 CONTINUE
TEM1 = CtLhSMPNOL (NP, DZ, G1, ERR)
TEM2 = CtLhSMPSNA (NP, DZ, G2, ERR)
TEM3 = CtLhSMPSNA (NP, DZ, G3, ERR)
TEM4 = CtLhSMPNOL (NP, DZ, G4, ERR)
TEM1 = TEM1 - FI(I) * (AFF2(I) + ZGF2)
TEM4 = TEM4 - GI(I) * (AGG2(I) + ZFG2)
tem2 = tem2 + GI(I)*AFG2(I)
tem3= tem3 + FI(I)*AGF2(I)
TMF = TEM1 + TEM2
TMG = TEM3 + TEM4
FO(I) = FO(I) + TMF * CPL2
GO(I) = GO(I) + TMG * CPL2
21 END DO
EndIf
RETURN
END
FUNCTION CtLhSPENC2 (X)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
EXTERNAL CtLhSPN2IN
COMMON / LhCtSPENCC / XX
DATA U1, AERR, RERR / 1.D0, 1.E-7, 5.E-3 /
XX = X
TEM = CtLhGausInt(CtLhSPN2IN, XX, U1, AERR, RERR, ERR, IRT)
CtLhSPENC2 = TEM + LOG (XX) ** 2 / 2.
RETURN
END
FUNCTION CtLhSPN2IN (ZZ)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtSPENCC / X
Z = ZZ
TEM = LOG (1.+ X - Z) / Z
CtLhSPN2IN = TEM
RETURN
END
SUBROUTINE CtLhSTUPKL (NFL)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL LSTX
PARAMETER (D0=0D0, D1=1D0, D2=2D0, D3=3D0, D4=4D0, D10=1D1)
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MX = 3)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtXYARAY / ZZ(MXX, MXX), ZV(0:MXX)
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
COMMON / LhCtKRN1ST / FF1(0:MXX),FG1(0:MXX),GF1(0:MXX),GG1(0:MXX),&
& FF2(0:MXX), FG2(0:MXX), GF2(0:MXX), GG2(0:MXX), &
& PNSP(0:MXX), PNSM(0:MXX)
COMMON / LhCtKRN2ND / FFG(MXX, MXX), GGF(MXX, MXX), PNS(MXX, MXX)
COMMON / LhCtKRNL00 / DZ, XL(MX), NNX
COMMON / LhCtKRNL01 / AFF2(MXX),AFG2(MXX),AGF2(MXX),AGG2(MXX), &
& ANSP (MXX), ANSM (MXX), ZFG2, ZGF2, ZQQB
EXTERNAL CtLhPFF1, CtLhRGG1, CtLhRFF2, CtLhRGG2
EXTERNAL CtLhFNSP, CtLhFNSM
dimension aff1(mxx),agg1(mxx)
PARAMETER (PI = 3.141592653589793d0, PI2 = PI**2)
DATA CF, CG, TR / 1.33333333333333d0, 3.0, 0.5 /
! zeta(3.0)
data zeta3/1.20205690315959d0/
SAVE
DATA AERR, RERR / 0.0, 0.02 /
NNX = NX
DZ = 1./ (NX - 1)
DO 5 I0 = 1, MX
XL(I0) = XV(I0)
5 END DO
DO 10 I = 1, NX-1
XZ = XV(I)
CALL CtLhKERNEL (XZ, FF1(I), GF1(I), FG1(I), GG1(I), PNSP(I), &
& PNSM(I), FF2(I), GF2(I), FG2(I), GG2(I), NFL, IRT)
10 END DO
FF1(0) = FF1(1) * 3. - FF1(2) * 3. + FF1(3)
FG1(0) = FG1(1) * 3. - FG1(2) * 3. + FG1(3)
GF1(0) = GF1(1) * 3. - GF1(2) * 3. + GF1(3)
GG1(0) = GG1(1) * 3. - GG1(2) * 3. + GG1(3)
PNSP(0) = PNSP(1) * 3. - PNSP(2) * 3. + PNSP(3)
PNSM(0) = PNSM(1) * 3. - PNSM(2) * 3. + PNSM(3)
FF2(0) = FF2(1) * 3. - FF2(2) * 3. + FF2(3)
FG2(0) = FG2(1) * 3. - FG2(2) * 3. + FG2(3)
GF2(0) = GF2(1) * 3. - GF2(2) * 3. + GF2(3)
GG2(0) = GG2(1) * 3. - GG2(2) * 3. + GG2(3)
FF1(NX) = FF1(NX-1) * 3. - FF1(NX-2) * 3. + FF1(NX-3)
FG1(NX) = FG1(NX-1) * 3. - FG1(NX-2) * 3. + FG1(NX-3)
GF1(NX) = GF1(NX-1) * 3. - GF1(NX-2) * 3. + GF1(NX-3)
GG1(NX) = GG1(NX-1) * 3. - GG1(NX-2) * 3. + GG1(NX-3)
PNSM(NX) = PNSM(NX-1) * 3. - PNSM(NX-2) * 3. + PNSM(NX-3)
PNSP(NX) = PNSP(NX-1) * 3. - PNSP(NX-2) * 3. + PNSP(NX-3)
FF2(NX) = FF2(NX-1) * 3. - FF2(NX-2) * 3. + FF2(NX-3)
FG2(NX) = FG2(NX-1) * 3. - FG2(NX-2) * 3. + FG2(NX-3)
GF2(NX) = GF2(NX-1) * 3. - GF2(NX-2) * 3. + GF2(NX-3)
GG2(NX) = GG2(NX-1) * 3. - GG2(NX-2) * 3. + GG2(NX-3)
RER = RERR * 4.
AFF1(1) = CtLhGausInt(CtLhPFF1,D0,XV(1),AERR,RERR,ER1,IRT)
DGG1 = NFL / 3.
TMPG = CtLhGausInt(CtLhRGG1,D0,XV(1),AERR,RERR,ER3,IRT)
AGG1(1) = TMPG + DGG1
ANSM(1) = CtLhGausInt(CtLhFNSM,D0,XV(1),AERR,RER,ER2,IRT)
ANSP(1) = CtLhGausInt(CtLhFNSP,D0,XV(1),AERR,RER,ER2,IRT)
AER = AFF1(1) * RER
AFF2(1) = CtLhGausInt(CtLhRFF2, D0, XV(1), AER, RER, ER2, IRT)
AER = AGG1(1) * RER
AGG2(1) = CtLhGausInt(CtLhRGG2, D0, XV(1), AER, RER, ER4, IRT)
DO 20 I2 = 2, NX-1
TEM =CtLhGausInt(CtLhPFF1,XV(I2-1),XV(I2),AERR,RERR,ER1,IRT)
AFF1(I2) = TEM + AFF1(I2-1)
AER = ABS(TEM * RER)
AFF2(I2)=CtLhGausInt(CtLhRFF2,XV(I2-1),XV(I2),AER,RER,ER2,IRT) &
& +AFF2(I2-1)
TEM = CtLhGausInt(CtLhRGG1,XV(I2-1),XV(I2),AERR,RERR,ER3,IRT)
TMPG = TMPG + TEM
AGG1(I2) = TMPG + DGG1
AER = ABS(TEM * RER)
AGG2(I2)=CtLhGausInt(CtLhRGG2,XV(I2-1),XV(I2),AER,RER,ER4,IRT) &
& +AGG2(I2-1)
ANSP(I2)=CtLhGausInt(CtLhFNSP,XV(I2-1),XV(I2),AERR,RER,ER4,IRT) &
& +ANSP(I2-1)
ANSM(I2)=CtLhGausInt(CtLhFNSM,XV(I2-1),XV(I2),AERR,RER,ER4,IRT) &
& +ANSM(I2-1)
20 END DO
ANSP(NX)=CtLhGausInt(CtLhFNSP,XV(NX-1),D1,AERR,RER,ERR, &
& IRT) + ANSP(NX-1)
ANSM(NX)=CtLhGausInt(CtLhFNSM,XV(NX-1),D1,AERR,RER,ERR, &
& IRT) + ANSM(NX-1)
TRNF = TR * NFL
!loop over x
do i2=1,nx-1
x=xv(i2)
! XI = 1./ X !unused - jcp
X2 = X ** 2
X3= x**3
XLN = DLOG (X)
XLN2 = XLN ** 2
XLN1M = DLOG (1.- X)
xLi2m=CtLhxLi(2,-x)
xLi2=CtLhxLi(2,x)
xLi3=CtLhxLi(3,x)
xLi31m=CtLhxLi(3,1d0-x)
xLi32=CtLhxLi(3,x2)
xln1m2=xln1m*xln1m
xln1p=dlog(1d0+x)
x1m=1d0-x
x1p=1d0+x
x3m=3d0-x
x3p=3d0+x
wgfcft= &
& (9 + 4*Pi2 - 22*x + 13*x2 + 6*(3 - 4*x + x2)*xln1m + &
& 40*xln - 24*xLi2)/9.
wgfcf2= &
& (6*(2*(-9 + Pi2) + 3*x*(5 + x)) +4*(3 +2*Pi2+3*x*(-3 + 2*x))* &
& xln1m + 6*x3m*x1m*xln1m2 - 6*(x*(8 + 3*x) + 4*xln1m2)* &
& xln - 3*(-4 + x)*x*xln2)/12 - 2*(3 + 2*xln1m)*xLi2 - 4*xLi31m
wgfcfg= &
& (3637-186*Pi2-x*(3198+72*Pi2+x*(231 + 208*x)))/108.- xln + &
& (3*xln1m*(-33 - 4*Pi2 + (50 - 17*x)*x - 3*x3m*x1m*xln1m) + &
& 2*(x*(198 + x*(27+8*x))+9*xln1m*(3 - 4*x + x2 + 2*xln1m))* &
& xln - 9*x*(4 + x)*xln2)/18- x1p*x3p*xln*xln1p- &
& (x1p*x3p - 4*xln)*xLi2m + (31d0/3d0 +4*xln1m- 4*xln)*xLi2 + &
& 4*xLi31m + 12*xLi3 - 2*xLi32 - 10*zeta3
wfgcft= &
& (18 - 81*x + 6*Pi2*x + 123*x2 - 6*Pi2*x2 - 60*x3 + &
& 4*Pi2*x3 - 6*(-2 + 3*x - 3*x2 + 2*x3)*xln1m2 -33*x*xln + &
& 15*x2*xln - 24*x3*xln - 9*x*xln2 + 9*x2*xln2 - &
& 12*x3*xln2 - 12*x1m*xln1m*(-1 + 2*x2 + 2*xln - x*xln + &
& 2*x2*xln) - 24*xLi2)/9.
wfgcgt= &
& (2*(-67 + 2*Pi2 + x*(64 + x*(-91 + 3*Pi2 + 94*x)) + &
& x1m*(7+x*(-5+16*x))*xln1m -3*x1m*(2+ x*(-1+2*x))*xln1m2 - &
& 20*xln - 3*x*xln*(13 + 16*x*x1p - 3*x1p*xln) + &
& 6*x1p*(2+x+2*x2)*xln*xln1p+6*x1p*(2+x+2*x2)*xLi2m))/9.
AGF2(I2) = CF*TRNF*WGFCFT+CF**2* WGFCF2+CF*CG*WGFCFG
AFG2(I2) = CF*TRNF*WFGCFT +CG*TRNF*WFGCGT
!i2
enddo
AGF2(nx)=0d0
AFG2(nx)=0d0
ZGF2=-28./27.*Cf**2+94./27.*Cf*Cg -52./27.*Cf*TrNf
ZFG2= 37./27.*Cf*TrNf + 35./54.*Cg*TrNf
ZQQB=1.43862321154902*(Cf**2-0.5*Cf*Cg)
DO 21 IX = 1, NX-1
X = XV(IX)
NP = NX - IX + 1
IS = NP
XG2 = (LOG(1./(1.-X)) + 1.) ** 2
FFG (IS, IS) = FG2(NX) * DXTZ(I) * XG2
GGF (IS, IS) = GF2(NX) * DXTZ(I) * XG2
PNS (IS, IS) =PNSM(NX) * DXTZ(I)
DO 31 KZ = 2, NP
IY = IX + KZ - 1
IT = NX - IY + 1
XY = X / XV(IY)
XM1 = 1.- XY
XG2 = (LOG(1./XM1) + 1.) ** 2
Z = ZZ (IX, IY)
TZ = (Z + DZ) / DZ
IZ = Int(TZ)
IZ = MAX (IZ, 0)
IZ = MIN (IZ, NX-1)
DT = TZ - IZ
TEM = (FF2(IZ) * (1.- DT) + FF2(IZ+1) * DT) / XM1 / XY
FFG (IX, IY) = TEM * DXTZ(IY)
TEM = (FG2(IZ) * (1.- DT) + FG2(IZ+1) * DT) * XG2 / XY
FFG (IS, IT) = TEM * DXTZ(IY)
TEM = (GF2(IZ) * (1.- DT) + GF2(IZ+1) * DT) * XG2 / XY
GGF (IS, IT) = TEM * DXTZ(IY)
TEM = (GG2(IZ) * (1.- DT) + GG2(IZ+1) * DT) / XM1 / XY
GGF (IX, IY) = TEM * DXTZ(IY)
TEM = (PNSP(IZ) * (1.- DT) + PNSP(IZ+1) * DT) / XM1
PNS (IX, IY) = TEM * DXTZ(IY)
TEM = (PNSM(IZ) * (1.- DT) + PNSM(IZ+1) * DT) / XM1
PNS (IS, IT) = TEM * DXTZ(IY)
31 CONTINUE
21 END DO
RETURN
END
SUBROUTINE CtLhTRNLAM (IRDR, NF, IACT, IRT)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtCWZPRM / ALAM(0:9), AMHAT(0:9), AMN, NHQ
COMMON / LhCtTRNCOM / VMULM, JRDR, N, N1
EXTERNAL CtLhZBRLAM
DATA ALM0, BLM0, RERR / 0.01, 10.0, 0.0001 /
DATA IR1, SML / 0, 1.E-5 /
IRT = 0
N = NF
JRDR = IRDR
JACT = IACT
VLAM = ALAM(N)
IF (JACT .GT. 0) THEN
N1 = N + 1
THMS = AMHAT(N1)
ALM = LOG (THMS/VLAM)
BLM = BLM0
ELSE
N1 = N -1
THMS = AMHAT(N)
ALM = ALM0
THMS = MAX (THMS, SML)
BLM = LOG (THMS/VLAM)
ENDIF
IF (VLAM .GE. 0.7 * THMS) THEN
IF (JACT .EQ. 1) THEN
AMHAT(N1) = 0
ELSE
AMHAT(N) = 0
ENDIF
IRT = 4
ALAM(N1) = VLAM
RETURN
ENDIF
IF (ALM .GE. BLM) THEN
WRITE (*, *) 'CtLhTRNLAM has ALM >= BLM: ', ALM, BLM
WRITE (*, *) 'I do not know how to continue'
STOP
ENDIF
VMULM = THMS/VLAM
ERR = RERR * LOG (VMULM)
WLLN = CtLhQZBRNT (CtLhZBRLAM, ALM, BLM, ERR, IR1)
ALAM(N1) = THMS / EXP (WLLN)
IF (IR1 .NE. 0) THEN
WRITE (*, *) 'CtLhQZBRNT failed in CtLhTRNLAM; ', &
& 'NF, VLAM =', NF, VLAM
WRITE (*, *) 'I do not know how to continue'
STOP
ENDIF
RETURN
END
SUBROUTINE CtLhUPC (A, La, UpA)
CHARACTER A*(*), UpA*(*), C*(1)
INTEGER I, La, Ld
La = Len(A)
Lb = Len(UpA)
If (Lb .Lt. La) Stop 'UpCase conversion length mismatch!'
Ld = ICHAR('A')-ICHAR('a')
DO 1 I = 1, Lb
If (I .Le. La) Then
c = A(I:I)
IF ( LGE(C, 'a') .AND. LLE(C, 'z') ) THEN
UpA (I:I) = CHAR(Ichar(c) + ld)
Else
UpA (I:I) = C
ENDIF
Else
UpA (I:I) = ' '
Endif
1 END DO
RETURN
END
SUBROUTINE CtLhWARNI (IWRN, MSG, NMVAR, IVAB, &
& IMIN, IMAX, IACT)
CHARACTER*(*) MSG, NMVAR
Save Iw
Data Nmax / 100 /
IW = IWRN
IV = IVAB
IF (IW .EQ. 0) THEN
PRINT '(1X,A/1X, 2A,I10)', MSG, NMVAR,' = ', IV
IF (IACT .EQ. 1) THEN
PRINT '(A/2I10)', ' The limits are: ', IMIN, IMAX
ENDIF
ENDIF
If (Iw .LT. Nmax) Then
PRINT '(1X,A/1X, 2A,I10)', MSG, NMVAR,' = ', IV
Elseif (Iw .Eq. Nmax) Then
Print '(/A/)', 'CtLhWARNI Severe Warning: Too many errors'
Endif
IWRN = IW + 1
RETURN
END
SUBROUTINE CtLhWARNR (IWRN, MSG, NMVAR, VARIAB, &
& VMIN, VMAX, IACT)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (D0=0D0, D1=1D0, D2=2D0, D3=3D0, D4=4D0, D10=1D1)
CHARACTER*(*) MSG, NMVAR
Save Iw
! Data Nmax / 100 /
Data Nmax / 10 /
IW = IWRN
VR = VARIAB
IF (IW .EQ. 0) THEN
PRINT '(1X, A/1X,2A,1PD16.7)', MSG, NMVAR, ' = ', VR
IF (IACT .EQ. 1) THEN
PRINT '(A/2(1PE15.4))', ' The limits are: ', VMIN, VMAX
ENDIF
ENDIF
If (Iw .LT. Nmax) Then
PRINT '(I5, 2A/1X,2A,1PD16.7)', IW, ' ', MSG, &
& NMVAR, ' = ', VR
Elseif (Iw .Eq. Nmax) Then
Print '(/A/)', 'CtLhWARNR Severe Warning: Too many errors'
Endif
IWRN = IW + 1
RETURN
END
SUBROUTINE CtLhXARRAY
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL LSTX
PARAMETER (D0 = 0.0, D10=10.0)
PARAMETER (MXX = 105, MXQ = 25, MXF = 6)
PARAMETER (MXPN = MXF * 2 + 2)
PARAMETER (MXQX= MXQ * MXX, MXPQX = MXQX * MXPN)
PARAMETER (M1=-3, M2=3, NDG=3, NDH=NDG+1, L1=M1-1, L2=M2+NDG-2)
Character Msg*80
COMMON / LhCtVARIBX / XA(MXX, L1:L2), ELY(MXX), DXTZ(MXX)
COMMON / LhCtVARBAB / GB(NDG, NDH, MXX), H(NDH, MXX, M1:M2)
COMMON / LhCtHINTEC / GH(NDG, MXX)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtXYARAY / ZZ(MXX, MXX), ZV(0:MXX)
DIMENSION G1(NDG,NDH), G2(NDG,NDH), A(NDG)
DATA F12, F22, F32 / 1D0, 1D0, 1D0 /
DATA (G1(I,NDH), G2(I,1), I=1,NDG) / 0.0,0.0,0.0,0.0,0.0,0.0 /
DATA PUNY / 1D-30 /
XV(0) = 0D0
DZ = 1D0 / (NX-1)
DO 10 I = 1, NX - 1
Z = DZ * (I-1)
ZV(I) = Z
X = CtLhXFRMZ (Z)
DXTZ(I) = CtLhDXDZ(Z) / X
XV (I) = X
XA(I, 1) = X
XA(I, 0) = LOG (X)
DO 20 L = L1, L2
IF (L .NE. 0 .AND. L .NE. 1) XA(I, L) = X ** L
20 CONTINUE
10 END DO
XV(1) = Xmin
XV(NX) = 1D0
ZV(Nx) = 1D0
DXTZ(NX) = CtLhDXDZ(1.D0)
DO 21 L = L1, L2
XA (NX, L) = 1D0
21 CONTINUE
XA (NX, 0) = 0D0
DO 11 I = 1, NX-1
ELY(I) = LOG(1D0 - XV(I))
11 END DO
ELY(NX) = 3D0* ELY(NX-1) - 3D0* ELY(NX-2) + ELY(NX-3)
DO 17 IX = 1, NX
ZZ (IX, IX) = 1.
DO 17 IY = IX+1, NX
XY = XV(IX) / XV(IY)
ZZ (IX, IY) = CtLhZFRMX (XY)
ZZ (NX-IX+1, NX-IY+1) = XY
17 CONTINUE
DO 30 I = 1, NX-1
IF (I .NE. NX-1) THEN
F11 = 1D0/XV(I)
F21 = 1D0/XV(I+1)
F31 = 1D0/XV(I+2)
F13 = XV(I)
F23 = XV(I+1)
F33 = XV(I+2)
DET = F11*F22*F33 + F21*F32*F13 + F31*F12*F23 &
& - F31*F22*F13 - F21*F12*F33 - F11*F32*F23
IF (ABS(DET) .LT. PUNY) THEN
Msg='Determinant close to zero; will be arbitrarily set to:'
CALL CtLhWARNR(IWRN, Msg, 'DET', PUNY, D0, D0, 0)
DET = PUNY
EndIf
G2(1,2) = (F22*F33 - F23*F32) / DET
G2(1,3) = (F32*F13 - F33*F12) / DET
G2(1,4) = (F12*F23 - F13*F22) / DET
G2(2,2) = (F23*F31 - F21*F33) / DET
G2(2,3) = (F33*F11 - F31*F13) / DET
G2(2,4) = (F13*F21 - F11*F23) / DET
G2(3,2) = (F21*F32 - F22*F31) / DET
G2(3,3) = (F31*F12 - F32*F11) / DET
G2(3,4) = (F11*F22 - F12*F21) / DET
B2 = LOG (XV(I+2)/XV(I))
B3 = XV(I) * (B2 - 1.) + XV(I+2)
GH (1,I) = B2 * G2 (2,2) + B3 * G2 (3,2)
GH (2,I) = B2 * G2 (2,3) + B3 * G2 (3,3)
GH (3,I) = B2 * G2 (2,4) + B3 * G2 (3,4)
EndIf
DO 51 J = 1, NDH
DO 52 L = 1, NDG
IF (I .EQ. 1) THEN
GB(L,J,I) = G2(L,J)
ElseIF (I .EQ. NX-1) THEN
GB(L,J,I) = G1(L,J)
Else
GB(L,J,I) = (G1(L,J) + G2(L,J)) / 2D0
EndIf
52 CONTINUE
51 CONTINUE
DO 35 MM = M1, M2
DO 40 K = 1, NDG
KK = K + MM - 2
IF (KK .EQ. 0) THEN
A(K) = XA(I+1, 0) - XA(I, 0)
Else
A(K) = (XA(I+1, KK) - XA(I, KK)) / DBLE(KK)
EndIf
40 CONTINUE
DO 41 J = 1, NDH
TEM = 0
DO 43 L = 1, NDG
TEM = TEM + A(L) * GB(L,J,I)
43 CONTINUE
H(J,I,MM) = TEM
41 CONTINUE
35 CONTINUE
DO 42 J = 1, NDG
DO 44 L = 1, NDG
G1(L,J) = G2(L,J+1)
44 END DO
42 END DO
30 END DO
LSTX = .TRUE.
RETURN
END
FUNCTION CtLhXFRMZ (Z)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL LSTX
PARAMETER (D0=0D0, D1=1D0, D2=2D0, D3=3D0, D4=4D0, D10=1D1)
PARAMETER (MXX = 105)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
COMMON / LhCtINVERT / ZA
EXTERNAL CtLhZFXL
DATA TEM, RER / D1, 1E-3 /
DATA ZLOW, ZHIGH, IWRN2 / -10.0, 1.00002, 0 /
EPS = TEM * RER
ZA = Z
IF (Z .LE. ZHIGH .AND. Z .GT. ZLOW) THEN
XLA = LOG (XMIN) * 1.5
XLB = 0.00001
TEM = CtLhZBRNT (CtLhZFXL, XLA, XLB, EPS, IRT)
Else
CALL CtLhWARNR (IWRN2, 'Z out of range in CtLhXFRMZ, X set=0.', &
& 'Z', Z, ZLOW, ZHIGH, 1)
TEM = 0
EndIf
CtLhXFRMZ = EXP(TEM)
RETURN
END
FUNCTION CtLhxLi(n,x)
implicit NONE
integer NCUT, i,n,m3
real*8 CtLhxLi,Out,x,pi2by6,zeta3,c1,c2
real*8 r,xt,L,xln1m
parameter (m3=8)
dimension c1(2:m3),c2(2:m3)
data NCUT/27/
data c1/0.75,-0.5833333333333333d0,0.454861111111111d0, &
& -0.3680555555555555d0,0.3073611111111111d0, &
& -0.2630555555555555d0,0.2294880243764172d0/
data c2/-0.5d0,0.5d0,-0.4583333333333333d0,0.416666666666666d0, &
& -0.3805555555555555d0,0.35d0,-0.3241071428571428d0/
data zeta3,pi2by6 /1.20205690315959d0,1.64493406684823d0/
L=0.0
i=0
r=1.0
if (abs(x).gt.r) then
PRINT *,'Li: x out of range (-1,1) , x=',x
STOP
endif
if (n.lt.0) then
PRINT *,'Polylogarithm Li undefined for n=',n
STOP
elseif (n.eq.0) then
Out=x/(1d0-x)
elseif (n.eq.1) then
Out=-dlog(1-x)
elseif (n.eq.2) then
!Calculate dilogarithm
!separately for x<0.5 an
if (x.ge.(-0.5).and.x.le.0.5) then
do while(i.le.NCUT)
i=i+1
r=r*x
L=L+r/i/i
enddo
Out=L
elseif (x.eq.0) then
Out=0d0
!n.eq.2,x>0.5
elseif(x.gt.0.5) then
xt = 1.0-x
L = pi2by6 - dlog(x)*dlog(xt)
do while(i.le.NCUT)
i=i+1
r=r*xt
L=L-r/i/i
enddo
Out=L
elseif (x.lt.(-0.5)) then
xt=-x/(1d0-x)
L=-0.5*dlog(1-x)**2
do while (i.le.NCUT)
i=i+1
r=r*xt
L=L-r/i/i
enddo
Out=L
endif
!use the expansion of Li3 near x
elseif (n.eq.3.and.x.ge.0.8) then
L=zeta3+pi2by6*dlog(x)
xt=(1d0-x)
xln1m=dlog(xt)
do i=2,m3
L=L+(c1(i)+c2(i)*xln1m)*xt**i
enddo
Out=L
!n>3 or x=3,x<0.8
else
do while(i.le.NCUT)
i=i+1
r=r*x
L=L+r/dble(i)**dble(n)
enddo
Out=L
endif
CtLhxLi=Out
! CtLhxLi
END
FUNCTION CtLhZBRLAM (WLLN)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtTRNCOM / VMULM, JRDR, N, N1
WMULM = EXP (WLLN)
TEM1 = 1./ CtLhALPQCD(JRDR, N1, WMULM, I)
TEM2 = 1./ CtLhALPQCD(JRDR, N, VMULM, I)
CtLhZBRLAM = TEM1 - TEM2
END
FUNCTION CtLhZBRNT(FUNC, X1, X2, TOL, IRT)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (ITMAX = 1000, EPS = 3.E-12)
external func
IRT = 0
TOL = ABS(TOL)
A=X1
B=X2
FA=FUNC(A)
FB=FUNC(B)
IF(FB*FA.GT.0.) THEN
PRINT *, 'Root must be bracketed for CtLhZBRNT. Set = 0'
IRT = 1
CtLhZBRNT=0.
RETURN
ENDIF
FC=FB
DO 11 ITER=1,ITMAX
IF(FB*FC.GT.0.) THEN
C=A
FC=FA
D=B-A
E=D
ENDIF
IF(ABS(FC).LT.ABS(FB)) THEN
A=B
B=C
C=A
FA=FB
FB=FC
FC=FA
ENDIF
TOL1=2.*EPS*ABS(B)+0.5*TOL
XM=.5*(C-B)
IF(ABS(XM).LE.TOL1 .OR. FB.EQ.0.)THEN
CtLhZBRNT=B
RETURN
ENDIF
IF(ABS(E).GE.TOL1 .AND. ABS(FA).GT.ABS(FB)) THEN
S=FB/FA
IF(A.EQ.C) THEN
P=2.*XM*S
Q=1.-S
ELSE
Q=FA/FC
R=FB/FC
P=S*(2.*XM*Q*(Q-R)-(B-A)*(R-1.))
Q=(Q-1.)*(R-1.)*(S-1.)
ENDIF
IF(P.GT.0.) Q=-Q
P=ABS(P)
IF(2.*P .LT. MIN(3.*XM*Q-ABS(TOL1*Q),ABS(E*Q))) THEN
E=D
D=P/Q
ELSE
D=XM
E=D
ENDIF
ELSE
D=XM
E=D
ENDIF
A=B
FA=FB
IF(ABS(D) .GT. TOL1) THEN
B=B+D
ELSE
B=B+SIGN(TOL1,XM)
ENDIF
FB=FUNC(B)
11 END DO
PRINT *, 'CtLhZBRNT exceeding maximum iterations.'
IRT = 2
CtLhZBRNT=B
RETURN
END
FUNCTION CtLhZFRMX (XX)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
LOGICAL LSTX
PARAMETER (D0=0D0, D1=1D0, D2=2D0, D3=3D0, D4=4D0, D10=1D1)
PARAMETER (MXX = 105)
COMMON / LhCtXXARAY / XCR, XMIN, XV(0:MXX), LSTX, NX
DATA IWRN1, HUGE, TINY / 0, 1.E35, 1.E-35 /
F(X) = (XCR-XMIN) * LOG (X/XMIN) + LOG (XCR/XMIN) * (X-XMIN)
D(X) = (XCR-XMIN) / X + LOG (XCR/XMIN)
X = XX
IF (X .GE. XMIN) THEN
TEM = F(X) / F(D1)
ElseIF (X .GE. D0) THEN
X = MAX (X, TINY)
TEM = F(X) / F(D1)
Else
CALL CtLhWARNR(IWRN1, 'X out of range in CtLhZFRMX' &
& , 'X', X, TINY, HUGE, 1)
TEM = 99.
STOP
EndIf
CtLhZFRMX = TEM
RETURN
ENTRY CtLhDZDX (XX)
X = XX
IF (X .GE. XMIN) THEN
TEM = D(X) / F(D1)
ElseIF (X .GE. D0) THEN
X = MAX (X, TINY)
TEM = D(X) / F(D1)
Else
CALL CtLhWARNR(IWRN1, 'X out of range in CtLhDZDX ' &
& , 'X', X, TINY, HUGE, 1)
TEM = 99.
STOP
EndIf
CtLhDZDX = TEM
RETURN
END
FUNCTION CtLhZFXL (XL)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / LhCtINVERT / ZA
X = EXP(XL)
TT = CtLhZFRMX (X) - ZA
CtLhZFXL = TT
RETURN
END
SUBROUTINE CtLhPOLINT4 (XA,YA,N,X,Y,DY)
! fast version of polint, valid only for N=4
! Have explicitly unrolled the loops.
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (NMAX=4)
DIMENSION XA(N),YA(N),C(NMAX),D(NMAX)
if(n .ne. 4) then
print *,'fatal CtLhPolint4 call',n
stop
endif
NS=1
DIF=ABS(X-XA(1))
DIFT=ABS(X-XA(1))
IF (DIFT.LT.DIF) THEN
NS=1
DIF=DIFT
ENDIF
C(1)=YA(1)
D(1)=YA(1)
DIFT=ABS(X-XA(2))
IF (DIFT.LT.DIF) THEN
NS=2
DIF=DIFT
ENDIF
C(2)=YA(2)
D(2)=YA(2)
DIFT=ABS(X-XA(3))
IF (DIFT.LT.DIF) THEN
NS=3
DIF=DIFT
ENDIF
C(3)=YA(3)
D(3)=YA(3)
DIFT=ABS(X-XA(4))
IF (DIFT.LT.DIF) THEN
NS=4
DIF=DIFT
ENDIF
C(4)=YA(4)
D(4)=YA(4)
Y=YA(NS)
NS=NS-1
HO=XA(1)-X
HP=XA(2)-X
W=C(2)-D(1)
DEN=W/(HO-HP)
D(1)=HP*DEN
C(1)=HO*DEN
HO=XA(2)-X
HP=XA(3)-X
W=C(3)-D(2)
DEN=W/(HO-HP)
D(2)=HP*DEN
C(2)=HO*DEN
HO=XA(3)-X
HP=XA(4)-X
W=C(4)-D(3)
DEN=W/(HO-HP)
D(3)=HP*DEN
C(3)=HO*DEN
IF (2*NS.LT.3)THEN
DY=C(NS+1)
ELSE
DY=D(NS)
NS=NS-1
ENDIF
Y=Y+DY
HO=XA(1)-X
HP=XA(3)-X
W=C(2)-D(1)
DEN=W/(HO-HP)
D(1)=HP*DEN
C(1)=HO*DEN
HO=XA(2)-X
HP=XA(4)-X
W=C(3)-D(2)
DEN=W/(HO-HP)
D(2)=HP*DEN
C(2)=HO*DEN
IF (2*NS.LT.2)THEN
DY=C(NS+1)
ELSE
DY=D(NS)
NS=NS-1
ENDIF
Y=Y+DY
HO=XA(1)-X
HP=XA(4)-X
W=C(2)-D(1)
DEN=W/(HO-HP)
D(1)=HP*DEN
C(1)=HO*DEN
IF (2*NS.LT.4-3)THEN
DY=C(NS+1)
ELSE
DY=D(NS)
NS=NS-1
ENDIF
Y=Y+DY
RETURN
END
SUBROUTINE CTLHPOLINT3 (XA,YA,N,X,Y,DY)
! fast version of polint, valid only for N=3
! Have explicitly unrolled the loops.
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
PARAMETER (NMAX=3)
DIMENSION XA(N),YA(N),C(NMAX),D(NMAX)
if(n .ne. 3) then
print *,'fatal CtLhPolint3 call',n
stop
endif
NS=1
DIF=ABS(X-XA(1))
DIFT=ABS(X-XA(1))
IF (DIFT.LT.DIF) THEN
NS=1
DIF=DIFT
ENDIF
C(1)=YA(1)
D(1)=YA(1)
DIFT=ABS(X-XA(2))
IF (DIFT.LT.DIF) THEN
NS=2
DIF=DIFT
ENDIF
C(2)=YA(2)
D(2)=YA(2)
DIFT=ABS(X-XA(3))
IF (DIFT.LT.DIF) THEN
NS=3
DIF=DIFT
ENDIF
C(3)=YA(3)
D(3)=YA(3)
Y=YA(NS)
NS=NS-1
HO=XA(1)-X
HP=XA(2)-X
W=C(2)-D(1)
DEN=W/(HO-HP)
D(1)=HP*DEN
C(1)=HO*DEN
HO=XA(2)-X
HP=XA(3)-X
W=C(3)-D(2)
DEN=W/(HO-HP)
D(2)=HP*DEN
C(2)=HO*DEN
IF (2*NS.LT.2)THEN
DY=C(NS+1)
ELSE
DY=D(NS)
NS=NS-1
ENDIF
Y=Y+DY
HO=XA(1)-X
HP=XA(3)-X
W=C(2)-D(1)
DEN=W/(HO-HP)
D(1)=HP*DEN
C(1)=HO*DEN
IF (2*NS.LT.1)THEN
DY=C(NS+1)
ELSE
DY=D(NS)
NS=NS-1
ENDIF
Y=Y+DY
RETURN
END
| LHAPDF/lhapdf-5.9.1/src/EVLCTEQ.f |
!Copyright (c) 2012-2022, Xcompact3d
!This file is part of Xcompact3d (xcompact3d.com)
!SPDX-License-Identifier: BSD 3-Clause
!********************************************************************
!
subroutine schemes()
!
!********************************************************************
USE param
USE derivX
USE derivY
USE derivZ
USE variables
USE var
implicit none
integer :: is
#ifdef DEBG
if (nrank .eq. 0) print *,'# schemes start'
#endif
!Velocity
! First derivative
if (nclx1.eq.0.and.nclxn.eq.0) derx => derx_00
if (nclx1.eq.1.and.nclxn.eq.1) derx => derx_11
if (nclx1.eq.1.and.nclxn.eq.2) derx => derx_12
if (nclx1.eq.2.and.nclxn.eq.1) derx => derx_21
if (nclx1.eq.2.and.nclxn.eq.2) derx => derx_22
!
if (ncly1.eq.0.and.nclyn.eq.0) dery => dery_00
if (ncly1.eq.1.and.nclyn.eq.1) dery => dery_11
if (ncly1.eq.1.and.nclyn.eq.2) dery => dery_12
if (ncly1.eq.2.and.nclyn.eq.1) dery => dery_21
if (ncly1.eq.2.and.nclyn.eq.2) dery => dery_22
!
if (nclz1.eq.0.and.nclzn.eq.0) derz => derz_00
if (nclz1.eq.1.and.nclzn.eq.1) derz => derz_11
if (nclz1.eq.1.and.nclzn.eq.2) derz => derz_12
if (nclz1.eq.2.and.nclzn.eq.1) derz => derz_21
if (nclz1.eq.2.and.nclzn.eq.2) derz => derz_22
! Second derivative
call first_derivative(alfa1x,af1x,bf1x,cf1x,df1x,alfa2x,af2x,alfanx,afnx,bfnx,&
cfnx,dfnx,alfamx,afmx,alfaix,afix,bfix,&
ffx,fsx,fwx,ffxp,fsxp,fwxp,dx,nx,nclx1,nclxn)
call first_derivative(alfa1y,af1y,bf1y,cf1y,df1y,alfa2y,af2y,alfany,afny,bfny,&
cfny,dfny,alfamy,afmy,alfajy,afjy,bfjy,&
ffy,fsy,fwy,ffyp,fsyp,fwyp,dy,ny,ncly1,nclyn)
call first_derivative(alfa1z,af1z,bf1z,cf1z,df1z,alfa2z,af2z,alfanz,afnz,bfnz,&
cfnz,dfnz,alfamz,afmz,alfakz,afkz,bfkz,&
ffz,fsz,fwz,ffzp,fszp,fwzp,dz,nz,nclz1,nclzn)
call second_derivative(alsa1x,as1x,bs1x,&
cs1x,ds1x,alsa2x,as2x,alsanx,asnx,bsnx,csnx,dsnx,alsamx,&
asmx,alsa3x,as3x,bs3x,alsatx,astx,bstx,&
alsa4x,as4x,bs4x,cs4x,&
alsattx,asttx,bsttx,csttx,&
alsaix,asix,bsix,csix,dsix,&
sfx,ssx,swx,sfxp,ssxp,swxp,dx2,nx,nclx1,nclxn)
call second_derivative(alsa1y,as1y,bs1y,&
cs1y,ds1y,alsa2y,as2y,alsany,asny,bsny,csny,dsny,alsamy,&
asmy,alsa3y,as3y,bs3y,alsaty,asty,bsty,&
alsa4y,as4y,bs4y,cs4y,&
alsatty,astty,bstty,cstty,&
alsajy,asjy,bsjy,csjy,dsjy,&
sfy,ssy,swy,sfyp,ssyp,swyp,dy2,ny,ncly1,nclyn)
call second_derivative(alsa1z,as1z,bs1z,&
cs1z,ds1z,alsa2z,as2z,alsanz,asnz,bsnz,csnz,dsnz,alsamz,&
asmz,alsa3z,as3z,bs3z,alsatz,astz,bstz,&
alsa4z,as4z,bs4z,cs4z,&
alsattz,asttz,bsttz,csttz,&
alsakz,askz,bskz,cskz,dskz,&
sfz,ssz,swz,sfzp,sszp,swzp,dz2,nz,nclz1,nclzn)
if (iscalar.ne.0 .or. (ilmn)) then
!Scalar
! First derivative
if (nclxS1.eq.0.and.nclxSn.eq.0) derxS => derx_00
if (nclxS1.eq.1.and.nclxSn.eq.1) derxS => derx_11
if (nclxS1.eq.1.and.nclxSn.eq.2) derxS => derx_12
if (nclxS1.eq.2.and.nclxSn.eq.1) derxS => derx_21
if (nclxS1.eq.2.and.nclxSn.eq.2) derxS => derx_22
!
if (nclyS1.eq.0.and.nclySn.eq.0) deryS => dery_00
if (nclyS1.eq.1.and.nclySn.eq.1) deryS => dery_11
if (nclyS1.eq.1.and.nclySn.eq.2) deryS => dery_12
if (nclyS1.eq.2.and.nclySn.eq.1) deryS => dery_21
if (nclyS1.eq.2.and.nclySn.eq.2) deryS => dery_22
!
if (nclzS1.eq.0.and.nclzSn.eq.0) derzS => derz_00
if (nclzS1.eq.1.and.nclzSn.eq.1) derzS => derz_11
if (nclzS1.eq.1.and.nclzSn.eq.2) derzS => derz_12
if (nclzS1.eq.2.and.nclzSn.eq.1) derzS => derz_21
if (nclzS1.eq.2.and.nclzSn.eq.2) derzS => derz_22
! Second derivative
call first_derivative(alfa1x,af1x,bf1x,cf1x,df1x,alfa2x,af2x,alfanx,afnx,bfnx,&
cfnx,dfnx,alfamx,afmx,alfaix,afix,bfix,&
ffxS,fsxS,fwxS,ffxpS,fsxpS,fwxpS,dx,nx,nclxS1,nclxSn)
call first_derivative(alfa1y,af1y,bf1y,cf1y,df1y,alfa2y,af2y,alfany,afny,bfny,&
cfny,dfny,alfamy,afmy,alfajy,afjy,bfjy,&
ffyS,fsyS,fwyS,ffypS,fsypS,fwypS,dy,ny,nclyS1,nclySn)
call first_derivative(alfa1z,af1z,bf1z,cf1z,df1z,alfa2z,af2z,alfanz,afnz,bfnz,&
cfnz,dfnz,alfamz,afmz,alfakz,afkz,bfkz,&
ffzS,fszS,fwzS,ffzpS,fszpS,fwzpS,dz,nz,nclzS1,nclzSn)
call second_derivative(alsa1x,as1x,bs1x,&
cs1x,ds1x,alsa2x,as2x,alsanx,asnx,bsnx,csnx,dsnx,alsamx,&
asmx,alsa3x,as3x,bs3x,alsatx,astx,bstx,&
alsa4x,as4x,bs4x,cs4x,&
alsattx,asttx,bsttx,csttx,&
alsaix,asix,bsix,csix,dsix,&
sfxS,ssxS,swxS,sfxpS,ssxpS,swxpS,dx2,nx,nclxS1,nclxSn)
call second_derivative(alsa1y,as1y,bs1y,&
cs1y,ds1y,alsa2y,as2y,alsany,asny,bsny,csny,dsny,alsamy,&
asmy,alsa3y,as3y,bs3y,alsaty,asty,bsty,&
alsa4y,as4y,bs4y,cs4y,&
alsatty,astty,bstty,cstty,&
alsajy,asjy,bsjy,csjy,dsjy,&
sfyS,ssyS,swyS,sfypS,ssypS,swypS,dy2,ny,nclyS1,nclySn)
call second_derivative(alsa1z,as1z,bs1z,&
cs1z,ds1z,alsa2z,as2z,alsanz,asnz,bsnz,csnz,dsnz,alsamz,&
asmz,alsa3z,as3z,bs3z,alsatz,astz,bstz,&
alsa4z,as4z,bs4z,cs4z,&
alsattz,asttz,bsttz,csttz,&
alsakz,askz,bskz,cskz,dskz,&
sfzS,sszS,swzS,sfzpS,sszpS,swzpS,dz2,nz,nclzS1,nclzSn)
endif
call interpolation(dx,nxm,nx,nclx1,nclxn,&
alcaix6,acix6,bcix6,&
ailcaix6,aicix6,bicix6,cicix6,dicix6,&
cfx6,ccx6,cbx6,cfxp6,ciwxp6,csxp6,&
cwxp6,csx6,cwx6,cifx6,cicx6,cisx6,&
cibx6,cifxp6,cisxp6,ciwx6,&
cfi6,cci6,cbi6,cfip6,csip6,cwip6,csi6,&
cwi6,cifi6,cici6,cibi6,cifip6,&
cisip6,ciwip6,cisi6,ciwi6)
call interpolation(dy,nym,ny,ncly1,nclyn,&
alcaiy6,aciy6,bciy6,&
ailcaiy6,aiciy6,biciy6,ciciy6,diciy6,&
cfy6,ccy6,cby6,cfyp6,ciwyp6,csyp6,&
cwyp6,csy6,cwy6,cify6,cicy6,cisy6,&
ciby6,cifyp6,cisyp6,ciwy6,&
cfi6y,cci6y,cbi6y,cfip6y,csip6y,cwip6y,csi6y,&
cwi6y,cifi6y,cici6y,cibi6y,cifip6y,&
cisip6y,ciwip6y,cisi6y,ciwi6y)
call interpolation(dz,nzm,nz,nclz1,nclzn,&
alcaiz6,aciz6,bciz6,&
ailcaiz6,aiciz6,biciz6,ciciz6,diciz6,&
cfz6,ccz6,cbz6,cfzp6,ciwzp6,cszp6,&
cwzp6,csz6,cwz6,cifz6,cicz6,cisz6,&
cibz6,cifzp6,ciszp6,ciwz6,&
cfi6z,cci6z,cbi6z,cfip6z,csip6z,cwip6z,csi6z,&
cwi6z,cifi6z,cici6z,cibi6z,cifip6z,&
cisip6z,ciwip6z,cisi6z,ciwi6z)
#ifdef DEBG
if (nrank .eq. 0) print *,'# schemes end'
#endif
return
end subroutine schemes
!*******************************************************************
!
subroutine prepare (b,c,f,s,w,n)
!
!*******************************************************************
use decomp_2d, only : mytype
use param, only : one
implicit none
integer, intent(in) :: n
real(mytype), dimension(n), intent(in) :: b,c,f
real(mytype), dimension(n), intent(out) :: s,w
integer :: i
do i=1,n
w(i)=c(i)
enddo
do i=2,n
s(i)=b(i-1)/w(i-1)
w(i)=w(i)-f(i-1)*s(i)
enddo
do i=1,n
w(i)=one/w(i)
enddo
return
end subroutine prepare
!*******************************************************************
!
subroutine first_derivative(alfa1,af1,bf1,cf1,df1,alfa2,af2,alfan,afn,bfn,&
cfn,dfn,alfam,afm,alfai,afi,bfi,&
ff,fs,fw,ffp,fsp,fwp,d,n,ncl1,ncln)
!
!*******************************************************************
use decomp_2d, only : mytype, nrank
use param
use MPI
implicit none
real(mytype),intent(in) :: d
integer,intent(in) :: n,ncl1,ncln
real(mytype),dimension(n),intent(out) :: ff,fs,fw,ffp,fsp,fwp
real(mytype),intent(out) :: alfa1,af1,bf1,cf1,df1,alfa2,af2,alfan,afn,bfn,&
cfn,dfn,alfam,afm,alfai,afi,bfi
integer :: i,code,ierror
real(mytype),dimension(n) :: fb,fc
ff=zero;fs=zero;fw=zero;ffp=zero;fsp=zero;fwp=zero
fb=zero;fc=zero
if (ifirstder==1) then ! Second-order central
alfai= zero
afi = one/(two*d)
bfi = zero
elseif(ifirstder==2) then ! Fourth-order central
if (nrank==0) print *,'Set of coefficients not ready yet'
call MPI_ABORT(MPI_COMM_WORLD,code,ierror); stop
elseif(ifirstder==3) then ! Fourth-order compact
if (nrank==0) print *,'Set of coefficients not ready yet'
call MPI_ABORT(MPI_COMM_WORLD,code,ierror); stop
elseif(ifirstder==4) then ! Sixth-order compact
alfai= one/three
afi = (seven/nine)/d
bfi = (one/thirtysix)/d
else
if (nrank==0) then
print *, 'This is not an option. Please use ifirstder=1,2,3,4'
endif
call MPI_ABORT(MPI_COMM_WORLD,code,ierror); stop
endif
if (ifirstder==1) then
alfa1 = zero
af1 = zero
bf1 = zero
cf1 = zero
df1 = zero
alfa2 = zero
af2 = zero
alfam = zero
afm = zero
alfan = zero
afn = zero
bfn = zero
cfn = zero
dfn = zero
else
alfa1= two
af1 =-(five/two)/d
bf1 = (two)/d
cf1 = (half)/d
df1 = zero
alfa2= one/four
af2 = (three/four)/d
alfan= two
afn =-(five/two)/d
bfn = (two)/d
cfn = (half)/d
dfn = zero
alfam= one/four
afm = (three/four)/d
endif
if (ncl1.eq.0) then !Periodic
ff(1) =alfai
ff(2) =alfai
fc(1) =two
fc(2) =one
fb(1) =alfai
fb(2) =alfai
elseif (ncl1.eq.1) then !Free-slip
ff(1) =alfai+alfai
ff(2) =alfai
fc(1) =one
fc(2) =one
fb(1) =alfai
fb(2) =alfai
elseif (ncl1.eq.2) then !Dirichlet
ff(1) =alfa1
ff(2) =alfa2
fc(1) =one
fc(2) =one
fb(1) =alfa2
fb(2) =alfai
endif
if (ncln.eq.0) then !Periodic
ff(n-2)=alfai
ff(n-1)=alfai
ff(n) =zero
fc(n-2)=one
fc(n-1)=one
fc(n )=one+alfai*alfai
fb(n-2)=alfai
fb(n-1)=alfai
fb(n )=zero
elseif (ncln.eq.1) then !Free-slip
ff(n-2)=alfai
ff(n-1)=alfai
ff(n) =zero
fc(n-2)=one
fc(n-1)=one
fc(n )=one
fb(n-2)=alfai
fb(n-1)=alfai+alfai
fb(n )=zero
elseif (ncln.eq.2) then !Dirichlet
ff(n-2)=alfai
ff(n-1)=alfam
ff(n) =zero
fc(n-2)=one
fc(n-1)=one
fc(n )=one
fb(n-2)=alfam
fb(n-1)=alfan
fb(n )=zero
endif
do i=3,n-3
ff(i)=alfai
fc(i)=one
fb(i)=alfai
enddo
do i=1,n
ffp(i)=ff(i)
enddo
call prepare (fb,fc,ff ,fs ,fw ,n)
if (ncl1.eq.1) then
ffp(1)=zero
endif
if (ncln.eq.1) then
fb(n-1)=zero
endif
call prepare (fb,fc,ffp,fsp,fwp,n)
return
end subroutine first_derivative
!*******************************************************************
subroutine second_derivative(alsa1,as1,bs1,&
cs1,ds1,alsa2,as2,alsan,asn,bsn,csn,dsn,alsam,&
asm,alsa3,as3,bs3,alsat,ast,bst,&
alsa4,as4,bs4,cs4,&
alsatt,astt,bstt,cstt,&
alsai,asi,bsi,csi,dsi,&
sf,ss,sw,sfp,ssp,swp,d2,n,ncl1,ncln)
!*******************************************************************
use decomp_2d, only : mytype, nrank
use param
use MPI
use variables, only : nu0nu,cnu
implicit none
real(mytype),intent(in) :: d2
integer,intent(in) :: n,ncl1,ncln
integer :: code,ierror
real(mytype),dimension(n),intent(out) :: sf,ss,sw,sfp,ssp,swp
real(mytype),intent(out) :: alsa1,as1,bs1,&
cs1,ds1,alsa2,as2,alsan,asn,bsn,csn,dsn,alsam,&
asm,alsa3,as3,bs3,alsat,ast,bst,&
alsa4,as4,bs4,cs4,&
alsatt,astt,bstt,cstt,&
alsai,asi,bsi,csi,dsi
integer :: i
real(mytype),dimension(n) :: sb,sc
real(mytype) :: xxnu,dpis3,kppkc,kppkm,xnpi2,xmpi2,den
sf=zero;ss=zero;sw=zero;sfp=zero;ssp=zero;swp=zero
! Define coefficients based on the desired formal accuracy of the numerical schemes
if (isecondder==1) then ! Second-order central
alsai=zero
asi =one/d2 !((six-nine*alsai)/four)/d2
bsi =zero !((-three+twentyfour*alsai)/five)/(four*d2)
csi =zero !((two-eleven*alsai)/twenty)/(nine*d2)
dsi =zero
alsa4= alsai
as4 = asi
bs4 = bsi
cs4 = csi
alsatt = alsai
astt = asi
bstt = bsi
cstt = csi
elseif(isecondder==2) then ! Fourth-order central
if (nrank==0) print *,'Set of coefficients not ready yet'
call MPI_ABORT(MPI_COMM_WORLD,code,ierror); stop
elseif(isecondder==3) then ! Fourth-order compact
if (nrank==0) print *,'Set of coefficients not ready yet'
call MPI_ABORT(MPI_COMM_WORLD,code,ierror); stop
elseif(isecondder==4) then ! Sixth-order compact Lele style (no extra dissipation)
alsai= 2./11.
asi = (12./11.)/d2
bsi = (3./44. )/d2
csi = zero
dsi = zero
alsa4= alsai
as4 = asi
bs4 = bsi
cs4 = csi
alsatt = alsai
astt = asi
bstt = bsi
cstt = csi
elseif(isecondder==5) then ! Sixth-order Hyperviscous operator
if(nrank==0) print *, 'Using the hyperviscous operator with (nu_0/nu,c_nu) = ', '(', nu0nu,',', cnu,')'
dpis3=two*pi/three
kppkc=pi*pi*(one+nu0nu)
kppkm=dpis3*dpis3*(one+cnu*nu0nu) !exp(-((pi-dpis3)/(zpthree*pi-dpis3))**two)/xxnu+dpis3*dpis3
xnpi2=kppkc
xmpi2=kppkm
den = 405._mytype * xnpi2 - 640._mytype * xmpi2 + 144._mytype
alsai = half - (320._mytype * xmpi2 - 1296._mytype) / den
asi = -(4329._mytype * xnpi2 / eight - 32._mytype * xmpi2 - 140._mytype * xnpi2 * xmpi2 + 286._mytype) / den / d2
bsi = (2115._mytype * xnpi2 - 1792._mytype * xmpi2 - 280._mytype * xnpi2 * xmpi2 + 1328._mytype) / den / (four * d2)
csi = -(7695 * xnpi2 / eight + 288._mytype * xmpi2 - 180._mytype * xnpi2 * xmpi2 - 2574._mytype) / den / (nine * d2)
dsi = (198._mytype * xnpi2 + 128._mytype * xmpi2 - 40._mytype * xnpi2 * xmpi2 - 736._mytype) / den / (four**2 * d2)
else
if (nrank==0) then
print *, 'This is not an option.'
endif
endif
! Defined for the bounadies when dirichlet conditions are used
alsa1= eleven
as1 = (thirteen)/d2
bs1 =-(twentyseven)/d2
cs1 = (fifteen)/d2
ds1 =-(one)/d2
if (isecondder==1) then
alsa2 = zero
as2 = one / d2
else
alsa2= zpone
as2 = (six/five)/d2
endif
alsa3= two/eleven
as3 = (twelve/eleven)/d2
bs3 = (three/fortyfour)/d2
alsa4= two/eleven
as4 = (twelve/eleven)/d2
bs4 = (three/fortyfour)/d2
cs4 = zero
alsan= eleven
asn = (thirteen)/d2
bsn =-(twentyseven)/d2
csn = (fifteen)/d2
dsn =-(one)/d2
if (isecondder==1) then
alsam = zero
asm = one / d2
else
alsam= zpone
asm = (six/five)/d2
endif
alsat= two/eleven
ast = (twelve/eleven)/d2
bst = (three/fortyfour)/d2
alsatt = two/eleven
astt = (twelve/eleven)/d2
bstt = (three/fortyfour)/d2
cstt = zero
if (ncl1.eq.0) then !Periodic
sf(1) =alsai
sf(2) =alsai
sf(3) =alsai
sf(4) =alsai
sc(1) =two
sc(2) =one
sc(3) =one
sc(4) =one
sb(1) =alsai
sb(2) =alsai
sb(3) =alsai
sb(4) =alsai
elseif (ncl1.eq.1) then !Free-slip
sf(1) =alsai+alsai
sf(2) =alsai
sf(3) =alsai
sf(4) =alsai
sc(1) =one
sc(2) =one
sc(3) =one
sc(4) =one
sb(1) =alsai
sb(2) =alsai
sb(3) =alsai
sb(4) =alsai
elseif (ncl1.eq.2) then !Dirichlet
sf(1) =alsa1
sf(2) =alsa2
sf(3) =alsa3
sf(4) =alsa4
sc(1) =one
sc(2) =one
sc(3) =one
sc(4) =one
sb(1) =alsa2
sb(2) =alsa3
sb(3) =alsa4
sb(4) =alsai
endif
if (ncln.eq.0) then !Periodic
sf(n-4)=alsai
sf(n-3)=alsai
sf(n-2)=alsai
sf(n-1)=alsai
sf(n) =zero
sc(n-4)=one
sc(n-3)=one
sc(n-2)=one
sc(n-1)=one
sc(n )=one+alsai*alsai
sb(n-4)=alsai
sb(n-3)=alsai
sb(n-2)=alsai
sb(n-1)=alsai
sb(n )=zero
elseif (ncln.eq.1) then !Free-slip
sf(n-4)=alsai
sf(n-3)=alsai
sf(n-2)=alsai
sf(n-1)=alsai
sf(n) =zero
sc(n-4)=one
sc(n-3)=one
sc(n-2)=one
sc(n-1)=one
sc(n )=one
sb(n-4)=alsai
sb(n-3)=alsai
sb(n-2)=alsai
sb(n-1)=alsai+alsai
sb(n )=zero
elseif (ncln.eq.2) then !Dirichlet
sf(n-4)=alsai
sf(n-3)=alsatt
sf(n-2)=alsat
sf(n-1)=alsam
sf(n) =zero
sc(n-4)=one
sc(n-3)=one
sc(n-2)=one
sc(n-1)=one
sc(n )=one
sb(n-4)=alsatt
sb(n-3)=alsat
sb(n-2)=alsam
sb(n-1)=alsan
sb(n )=zero
endif
do i=5,n-5
sf(i)=alsai
sc(i)=one
sb(i)=alsai
enddo
do i=1,n
sfp(i)=sf(i)
enddo
if (ncl1.eq.1) then
sf (1)=zero
endif
call prepare (sb,sc,sf ,ss ,sw ,n)
call prepare (sb,sc,sfp,ssp,swp,n)
if (ncln.eq.1) then
sb(n-1)=zero
call prepare (sb,sc,sf ,ss ,sw ,n)
endif
return
end subroutine second_derivative
!*******************************************************************
!
subroutine interpolation(dx,nxm,nx,nclx1,nclxn,&
alcaix6,acix6,bcix6,&
ailcaix6,aicix6,bicix6,cicix6,dicix6,&
cfx6,ccx6,cbx6,cfxp6,ciwxp6,csxp6,&
cwxp6,csx6,cwx6,cifx6,cicx6,cisx6,&
cibx6,cifxp6,cisxp6,ciwx6,&
cfi6,cci6,cbi6,cfip6,csip6,cwip6,csi6,&
cwi6,cifi6,cici6,cibi6,cifip6,&
cisip6,ciwip6,cisi6,ciwi6)
!
!*******************************************************************
use decomp_2d, only : mytype
use param, only : zero, half, one, two, three, four, nine, ten
use param, only : ipinter, ifirstder
implicit none
real(mytype),intent(in) :: dx
integer,intent(in) :: nxm,nx,nclx1,nclxn
real(mytype) :: alcaix6,acix6,bcix6
real(mytype) :: ailcaix6,aicix6,bicix6,cicix6,dicix6
real(mytype),dimension(nxm) :: cfx6,ccx6,cbx6,cfxp6,ciwxp6,csxp6,&
cwxp6,csx6,cwx6,cifx6,cicx6,cisx6
real(mytype),dimension(nxm) :: cibx6,cifxp6,cisxp6,ciwx6
real(mytype),dimension(nx) :: cfi6,cci6,cbi6,cfip6,csip6,cwip6,csi6,&
cwi6,cifi6,cici6,cibi6,cifip6
real(mytype),dimension(nx) :: cisip6,ciwip6,cisi6,ciwi6
integer :: i
if (ifirstder==1) then
alcaix6 = zero
acix6 = one / dx
bcix6 = zero
else
alcaix6=nine/62._mytype
acix6=(63._mytype/62._mytype)/dx
bcix6=(17._mytype/62._mytype)/three/dx
endif
cfx6(1)=alcaix6
cfx6(2)=alcaix6
cfx6(nxm-2)=alcaix6
cfx6(nxm-1)=alcaix6
cfx6(nxm)=zero
if (nclx1==0) ccx6(1)=two
if (nclx1==1) ccx6(1)=one + alcaix6
if (nclx1==2) ccx6(1)=one + alcaix6
ccx6(2)=one
ccx6(nxm-2)=one
ccx6(nxm-1)=one
if (nclxn==0) ccx6(nxm)=one + alcaix6*alcaix6
if (nclxn==1) ccx6(nxm)=one + alcaix6
if (nclxn==2) ccx6(nxm)=one + alcaix6
cbx6(1)=alcaix6
cbx6(2)=alcaix6
cbx6(nxm-2)=alcaix6
cbx6(nxm-1)=alcaix6
cbx6(nxm)=0.
do i=3,nxm-3
cfx6(i)=alcaix6
ccx6(i)=one
cbx6(i)=alcaix6
enddo
cfi6(1)=alcaix6 + alcaix6
cfi6(2)=alcaix6
cfi6(nx-2)=alcaix6
cfi6(nx-1)=alcaix6
cfi6(nx)=zero
cci6(1)=one
cci6(2)=one
cci6(nx-2)=one
cci6(nx-1)=one
cci6(nx)=one
cbi6(1)=alcaix6
cbi6(2)=alcaix6
cbi6(nx-2)=alcaix6
cbi6(nx-1)=alcaix6 + alcaix6
cbi6(nx)=zero
do i=3,nx-3
cfi6(i)=alcaix6
cci6(i)=one
cbi6(i)=alcaix6
enddo
if (ifirstder == 1) then
ailcaix6 = zero
aicix6 = half
bicix6 = zero
cicix6 = zero
dicix6 = zero
else if (ipinter.eq.1) then
ailcaix6=three/ten
aicix6=three/four
bicix6=one/(two*ten)
cicix6=zero
dicix6=zero
else if (ipinter.eq.2) then
ailcaix6=0.461658
dicix6=0.00293016
aicix6=one/64._mytype *(75._mytype +70._mytype *ailcaix6-320._mytype *dicix6)
bicix6=one/128._mytype *(126._mytype *ailcaix6-25._mytype +1152._mytype *dicix6)
cicix6=one/128._mytype *(-ten*ailcaix6+three-640._mytype *dicix6)
aicix6=aicix6/two
bicix6=bicix6/two
cicix6=cicix6/two
dicix6=dicix6/two
else if (ipinter.eq.3) then
ailcaix6=0.49_mytype
aicix6=one/128._mytype *(75._mytype +70._mytype*ailcaix6)
bicix6=one/256._mytype *(126._mytype*ailcaix6-25._mytype)
cicix6=one/256._mytype *(-ten*ailcaix6+three)
dicix6=zero
endif
cifx6(1)=ailcaix6
cifx6(2)=ailcaix6
cifx6(nxm-2)=ailcaix6
cifx6(nxm-1)=ailcaix6
cifx6(nxm)=zero
if (nclx1==0) cicx6(1)=two
if (nclx1==1) cicx6(1)=one + ailcaix6
if (nclx1==2) cicx6(1)=one + ailcaix6
cicx6(2)=one
cicx6(nxm-2)=one
cicx6(nxm-1)=one
if (nclxn==0) cicx6(nxm)=one + ailcaix6*ailcaix6
if (nclxn==1) cicx6(nxm)=one + ailcaix6
if (nclxn==2) cicx6(nxm)=one + ailcaix6
cibx6(1)=ailcaix6
cibx6(2)=ailcaix6
cibx6(nxm-2)=ailcaix6
cibx6(nxm-1)=ailcaix6
cibx6(nxm)=zero
do i=3,nxm-3
cifx6(i)=ailcaix6
cicx6(i)=one
cibx6(i)=ailcaix6
enddo
cifi6(1)=ailcaix6 + ailcaix6
cifi6(2)=ailcaix6
cifi6(nx-2)=ailcaix6
cifi6(nx-1)=ailcaix6
cifi6(nx)=zero
cici6(1)=one
cici6(2)=one
cici6(nx-2)=one
cici6(nx-1)=one
cici6(nx)=one
cibi6(1)=ailcaix6
cibi6(2)=ailcaix6
cibi6(nx-2)=ailcaix6
cibi6(nx-1)=ailcaix6 + ailcaix6
cibi6(nx)=zero
do i=3,nx-3
cifi6(i)=ailcaix6
cici6(i)=one
cibi6(i)=ailcaix6
enddo
do i=1,nxm
cfxp6(i)=cfx6(i)
cifxp6(i)=cifx6(i)
enddo
do i=1,nx
cifip6(i)=cifi6(i)
cfip6(i)=cfi6(i)
enddo
cfxp6(1)=zero
cfip6(1)=zero
call prepare (cbx6,ccx6,cfx6 ,csx6 ,cwx6 ,nxm)
call prepare (cbx6,ccx6,cfxp6,csxp6,cwxp6,nxm)
call prepare (cibx6,cicx6,cifx6 ,cisx6 ,ciwx6 ,nxm)
call prepare (cibx6,cicx6,cifxp6,cisxp6,ciwxp6,nxm)
call prepare (cbi6,cci6,cfi6 ,csi6 ,cwi6 ,nx)
call prepare (cbi6,cci6,cfip6,csip6,cwip6,nx)
call prepare (cibi6,cici6,cifi6 ,cisi6 ,ciwi6 ,nx)
call prepare (cibi6,cici6,cifip6,cisip6,ciwip6,nx)
if (nclxn.eq.1) then
cbx6(nxm-1)=zero
cibx6(nxm)=0
cbi6(nx-1)=zero
cibi6(nx)=0
call prepare (cbx6,ccx6,cfxp6,csxp6,cwxp6,nxm)
call prepare (cibx6,cicx6,cifxp6,cisxp6,ciwxp6,nxm)
call prepare (cbi6,cci6,cfip6,csip6,cwip6,nx)
call prepare (cibi6,cici6,cifip6,cisip6,ciwip6,nx)
endif
if (nclxn.eq.2) then
cbx6(nxm-1)=zero
cibx6(nxm)=zero
cbi6(nx-1)=zero
cibi6(nx)=zero
call prepare (cbx6,ccx6,cfxp6,csxp6,cwxp6,nxm)
call prepare (cibx6,cicx6,cifxp6,cisxp6,ciwxp6,nxm)
call prepare (cbi6,cci6,cfip6,csip6,cwip6,nx)
call prepare (cibi6,cici6,cifip6,cisip6,ciwip6,nx)
endif
return
end subroutine interpolation
| src/schemes.f90 |
! This is part of the netCDF package.
! Copyright 2007 University Corporation for Atmospheric Research/Unidata.
! See COPYRIGHT file for conditions of use.
! This program tests netCDF-4 new types from fortran 90.
! $Id: tst_types.f90,v 1.7 2009/01/25 14:33:44 ed Exp $
program tst_types
use typeSizes
use netcdf
implicit none
! This is the name of the data file we will create.
character (len = *), parameter :: FILE_NAME = "tst_types.nc"
! Information for the types we create.
character (len = *), parameter :: OPAQUE_TYPE_NAME = "Odessyus"
character (len = *), parameter :: var_name = "Polyphemus"
character (len = 80) :: name_in
character (len = 10), parameter :: opaque_data = "0123456789"
character (len = *), parameter :: att_name = "att1"
integer, parameter :: OPAQUE_SIZE = 10
integer (kind = EightByteInt) BIG_NUMBER, num_in
parameter (BIG_NUMBER = 4294967295_EightByteInt)
integer :: ncid, opaque_typeid, varid
integer :: size_in, base_typeid_in, nfields_in, class_in
print *, ''
print *,'*** Testing new netCDF-4 types from Fortran 90.'
! Create the netCDF file.
call check(nf90_create(FILE_NAME, nf90_netcdf4, ncid))
! Create an opaque type.
call check(nf90_def_opaque(ncid, OPAQUE_SIZE, OPAQUE_TYPE_NAME, opaque_typeid))
! Write an (global) opaque attribute.
call check(nf90_put_att_any(ncid, NF90_GLOBAL, att_name, opaque_typeid, 1, opaque_data))
! Create an int64 scalar variable.
call check(nf90_def_var(ncid, var_name, nf90_int64, varid))
! Write a large integer (too large to fit in 32-bit ints).
call check(nf90_put_var(ncid, varid, BIG_NUMBER))
! Close the file.
call check(nf90_close(ncid))
! Reopen the netCDF file.
call check(nf90_open(FILE_NAME, 0, ncid))
! Check the opaque type.
call check(nf90_inq_user_type(ncid, opaque_typeid, name_in, size_in, &
base_typeid_in, nfields_in, class_in))
if (name_in(1:len(OPAQUE_TYPE_NAME)) .ne. OPAQUE_TYPE_NAME .or. &
size_in .ne. OPAQUE_SIZE .or. base_typeid_in .ne. 0 .or. &
nfields_in .ne. 0 .or. class_in .ne. NF90_OPAQUE) stop 2
! Check it again with the inq_opaque call.
call check(nf90_inq_opaque(ncid, opaque_typeid, name_in, size_in))
if (name_in(1:len(OPAQUE_TYPE_NAME)) .ne. OPAQUE_TYPE_NAME .or. &
size_in .ne. OPAQUE_SIZE) stop 2
! Check it again with the inq_type call
!! call check(nf90_inq_type(ncid, opaque_typeid, name_in, size_in))
if (name_in(1:len(OPAQUE_TYPE_NAME)) .ne. OPAQUE_TYPE_NAME .or. &
size_in .ne. OPAQUE_SIZE) stop 2
! Read in the large number.
call check(nf90_get_var(ncid, varid, num_in))
if (num_in .ne. BIG_NUMBER) stop 2
! Close the file.
call check(nf90_close(ncid))
print *,'*** SUCCESS!'
! This subroutine handles errors by printing an error message and
! exiting with a non-zero status.
contains
subroutine check(status)
integer, intent ( in) :: status
if(status /= nf90_noerr) then
print *, trim(nf90_strerror(status))
stop 2
end if
end subroutine check
end program tst_types
| components/elm/src/external_models/sbetr/3rd-party/netcdf-fortran/nf_test/tst_types.f90 |
! test_mem_pool.f90 --
! Test program for the memory pool facility
!
! $Id: test_btree.f90,v 1.2 2006/03/26 19:03:53 arjenmarkus Exp $
!
module MYDATA_MODULE
type MYDATA
integer :: pool_index ! Required field, used internally
integer :: value ! Simple value to store
end type MYDATA
end module
module MYDATA_POOL
use MYDATA_MODULE, POOL_DATA => MYDATA
include "mem_pool.f90"
end module MYDATA_POOL
program test_mem_pool
use MYDATA_POOL
implicit none
!
! Define a new data type so that we can hold a lot of
! pointers to POOL_DATA data
!
type MYDATA_ARRAY
type(POOL_DATA), pointer :: v
end type
type(MYDATA_ARRAY), dimension(210) :: array
integer :: i
!
! Acquire N POOL_DATA items
!
do i = 1,210
call pool_acquire( array(i)%v )
if ( .not. associated( array(i)%v ) ) then
write(*,*) 'Error: data not acquired - ', i
stop
endif
array(i)%v%value = 2*i
enddo
!
! Release half of them
!
do i = 51,150
call pool_release( array(i)%v )
if ( associated( array(i)%v ) ) then
write(*,*) 'Error: data not released - ', i
stop
endif
enddo
!
! Acquire them again
!
do i = 51,150
call pool_acquire( array(i)%v )
if ( .not. associated( array(i)%v ) ) then
write(*,*) 'Error: data not acquired (part 2) - ', i
stop
endif
array(i)%v%value = -i
enddo
!
! Test that we have indeed all values
!
do i = 1,210
write(*,*) i, array(i)%v%value
enddo
end program
| source/atlnts-backend-main/3rdparty/flibs-0.9/flibs/tests/datastructures/salford/test_mem_pool.f90 |
program dynload
use kernel32
use iso_c_binding
implicit none
abstract interface
function ffun_int(x, y)
!GCC$ ATTRIBUTES DLLEXPORT, STDCALL :: FFUN
double precision :: ffun_int, x, y
end function
end interface
procedure(ffun_int), pointer :: ffun_ptr
integer(c_intptr_t) :: ptr
integer(handle) :: h
double precision :: x, y
h = LoadLibrary("dllfun.dll" // c_null_char)
if (h == 0) error stop "Error: LoadLibrary"
ptr = GetProcAddress(h, "ffun_@8" // c_null_char)
if (ptr == 0) error stop "Error: GetProcAddress"
call c_f_procpointer(transfer(ptr, c_null_funptr), ffun_ptr)
read *, x, y
print *, ffun_ptr(x, y)
if (FreeLibrary(h) == 0) error stop "Error: FreeLibrary"
end program
| Task/Call-a-function-in-a-shared-library/Fortran/call-a-function-in-a-shared-library-7.f |
The Garrison Room is located on the second floor of the Memorial Union. It overlooks the second story patio. It is south of the Fielder Room so it enjoys two walls of windows.
The Campus Unions page has http://campusunions.ucdavis.edu/mumap.html maps of the building to help you locate the room.
Groups that Regularly Meet in the Garrison room
Internal Affairs Commission
External Affairs Commission
Ethnic and Cultural Affairs Commission.
| lab/davisWiki/Garrison_Room.f |
program random
!$ use omp_lib
integer count
integer status
integer argLength
character(len=10) responder
character(len=100) arg
character(len=10) valueType
character(len=100) seedType
integer seed
integer length
logical concurrent
logical visible
logical shown
valueType="real"
seedType="time"
seed=0
length=1
concurrent=.false.
visible=.true.
shown=.false.
count = command_argument_count()
do n=1,count
call get_command_argument(n,arg,argLength,status)
if (status==0) then
if ((count==1).and.((arg=="help").or.(arg=="-help").or.(arg=="--help"))) then
call help()
shown=.true.
else if ((count==1).and.((arg=="version").or.(arg=="-version").or.(arg=="--version"))) then
call version()
shown=.true.
else if ((arg=="-s").or.(arg=="-seed")) then
responder="seed"
else if ((arg=="-l").or.(arg=="-length")) then
responder="length"
else if ((arg=="-i").or.(arg=="-int")) then
valueType="int"
else if ((arg=="-r").or.(arg=="-real")) then
valueType="real"
else if ((arg=="-parallel").or.(arg=="-concurrent")) then
concurrent=.true.
else if ((arg=="-invisible").or.(arg=="-hidden")) then
visible=.false.
else if (responder=="length") then
read (arg,*) length
responder=""
else if (responder=="seed") then
seedType=arg
responder=""
end if
end if
end do
if (.not.shown) then
if (seedType=="time") then
seed=time()
else if (seedType=="none") then
seed=0
else
read (seedType,*) seed
end if
call execRand(valueType,seed,visible)
if (concurrent) then
!$omp parallel
!$omp do
do n=1,length-1
call execRand(valueType,0,visible)
end do
!$omp end do
!$omp end parallel
else
do n=1,length-1
call execRand(valueType,0,visible)
end do
end if
end if
end program random
subroutine execRand(valueType,seed,visible)
character(len=10)::valueType
integer seed
logical visible
character(len=10) container
if (visible) then
if (valueType=="real") then
write (container,'(f10.8)') rand(seed)
else if (valueType=="int") then
write (container,'(i10)') irand(seed)
! 0≤x≤2147483647 の範囲の整数の乱数を生成する
end if
print '(a)',container
else
if (valueType=="real") then
x=rand(seed)
else if (valueType=="int") then
x=irand(seed)
end if
end if
end subroutine
subroutine help()
print *
print *
print '("使い方:")'
print *
print '(" random help")'
print '(" このページを表示します")'
print *
print '(" random version")'
print '(" このソフトウェアのバージョンを表示します")'
print *
print '(" random [options]")'
print '(" 以下のオプションに基づき乱数を生成します")'
print *
print '(" -l,-length : 生成する乱数の数を指定します (初期値:1)")'
print *
print '(" -i,-int : 整数の乱数を出力します")'
print '(" -r,-real : 実数の乱数を出力します (初期値)")'
print '(" 0≤x<1の範囲の実数を出力します")'
print *
print '(" -parallel : 並列処理により乱数を生成します")'
print '(" -hidden : 生成した乱数を表示しません (ベンチマーク等に最適)")'
print *
print *
end subroutine
subroutine version()
print *
print '("Random (Fortran version)")'
print '("ビルド: 2019/7/31")'
print *
print '("Fortran で書かれた乱数生成システムです。")'
print '("シェルから簡単に乱数を呼び出すことができます。")'
print *
end subroutine | Random/Random.f95 |
! keep track of the CPU time since the simulation began.
!
! Note: we only expect this information to be valid on the IOProcessor
module cputime_module
use bl_types
use bl_constants_module
use bl_error_module, only: bl_warn
use parallel
use omp_module
implicit none
! previous_elapsed_cputime is zero at the start of a simulation.
! When restarting from a checkpoint, previous_elapsed_cputime will
! hold the CPU time used before now.
real (kind=dp_t), save :: previous_elapsed_cputime = ZERO
real (kind=dp_t), save :: start_cputime
logical, save :: initialized = .FALSE.
private
public :: initialize_elapsed_cputime, start_cputime_clock, get_cputime
contains
subroutine initialize_elapsed_cputime(cputime)
real (kind=dp_t) :: cputime
previous_elapsed_cputime = cputime
end subroutine initialize_elapsed_cputime
subroutine start_cputime_clock()
start_cputime = parallel_wtime()
initialized = .TRUE.
end subroutine start_cputime_clock
function get_cputime() result (time)
real (kind=dp_t) :: time
integer :: ncores
if (.not. initialized) then
call start_cputime_clock()
call bl_warn("WARNING! You called get_cputime() without first calling start_cputime_clock()")
endif
ncores = parallel_nprocs() * omp_get_max_threads()
time = ncores*(parallel_wtime() - start_cputime) + previous_elapsed_cputime
return
end function get_cputime
end module cputime_module
| Source/cputime.f90 |
SUBROUTINE MG5_1_SMATRIX(P,ANS_SUMMED)
C
C Simple routine wrapper to provide the same interface for
C backward compatibility for usage without split orders.
C
C
C CONSTANTS
C
INTEGER NEXTERNAL
PARAMETER (NEXTERNAL=4)
INTEGER NSQAMPSO
PARAMETER (NSQAMPSO=1)
C
C ARGUMENTS
C
REAL*8 P(0:3,NEXTERNAL), ANS_SUMMED
C
C VARIABLES
C
INTEGER I
REAL*8 ANS(0:NSQAMPSO)
C
C BEGIN CODE
C
CALL MG5_1_SMATRIX_SPLITORDERS(P,ANS)
ANS_SUMMED=ANS(0)
END
SUBROUTINE MG5_1_SMATRIXHEL(P,HEL,ANS)
IMPLICIT NONE
C
C CONSTANT
C
INTEGER NEXTERNAL
PARAMETER (NEXTERNAL=4)
INTEGER NCOMB
PARAMETER ( NCOMB=16)
C
C ARGUMENTS
C
REAL*8 P(0:3,NEXTERNAL),ANS
INTEGER HEL
C
C GLOBAL VARIABLES
C
INTEGER USERHEL
COMMON/MG5_1_HELUSERCHOICE/USERHEL
C ----------
C BEGIN CODE
C ----------
USERHEL=HEL
CALL MG5_1_SMATRIX(P,ANS)
USERHEL=-1
END
SUBROUTINE MG5_1_SMATRIX_SPLITORDERS(P,ANS)
C
C Generated by MadGraph5_aMC@NLO v. %(version)s, %(date)s
C By the MadGraph5_aMC@NLO Development Team
C Visit launchpad.net/madgraph5 and amcatnlo.web.cern.ch
C
C MadGraph StandAlone Version
C
C Returns amplitude squared summed/avg over colors
C and helicities
C for the point in phase space P(0:3,NEXTERNAL)
C
C Process: u u~ > u u~ [ virt = QCD ] @1
C
IMPLICIT NONE
C
C CONSTANTS
C
INTEGER NEXTERNAL
PARAMETER (NEXTERNAL=4)
INTEGER NCOMB
PARAMETER ( NCOMB=16)
INTEGER NSQAMPSO
PARAMETER (NSQAMPSO=1)
INTEGER HELAVGFACTOR
PARAMETER (HELAVGFACTOR=4)
LOGICAL CHOSEN_SO_CONFIGS(NSQAMPSO)
DATA CHOSEN_SO_CONFIGS/.TRUE./
COMMON/MG5_1_CHOSEN_BORN_SQSO/CHOSEN_SO_CONFIGS
C
C ARGUMENTS
C
REAL*8 P(0:3,NEXTERNAL),ANS(0:NSQAMPSO)
C
C LOCAL VARIABLES
C
INTEGER NHEL(NEXTERNAL,NCOMB),NTRY
REAL*8 T(NSQAMPSO), BUFF
INTEGER IHEL,IDEN, I
INTEGER JC(NEXTERNAL)
LOGICAL GOODHEL(NCOMB)
DATA NTRY/0/
DATA GOODHEL/NCOMB*.FALSE./
DATA (NHEL(I, 1),I=1,4) / 1,-1,-1, 1/
DATA (NHEL(I, 2),I=1,4) / 1,-1,-1,-1/
DATA (NHEL(I, 3),I=1,4) / 1,-1, 1, 1/
DATA (NHEL(I, 4),I=1,4) / 1,-1, 1,-1/
DATA (NHEL(I, 5),I=1,4) / 1, 1,-1, 1/
DATA (NHEL(I, 6),I=1,4) / 1, 1,-1,-1/
DATA (NHEL(I, 7),I=1,4) / 1, 1, 1, 1/
DATA (NHEL(I, 8),I=1,4) / 1, 1, 1,-1/
DATA (NHEL(I, 9),I=1,4) /-1,-1,-1, 1/
DATA (NHEL(I, 10),I=1,4) /-1,-1,-1,-1/
DATA (NHEL(I, 11),I=1,4) /-1,-1, 1, 1/
DATA (NHEL(I, 12),I=1,4) /-1,-1, 1,-1/
DATA (NHEL(I, 13),I=1,4) /-1, 1,-1, 1/
DATA (NHEL(I, 14),I=1,4) /-1, 1,-1,-1/
DATA (NHEL(I, 15),I=1,4) /-1, 1, 1, 1/
DATA (NHEL(I, 16),I=1,4) /-1, 1, 1,-1/
DATA IDEN/36/
C
C GLOBAL VARIABLES
C
INTEGER USERHEL
DATA USERHEL/-1/
COMMON/MG5_1_HELUSERCHOICE/USERHEL
C ----------
C BEGIN CODE
C ----------
NTRY=NTRY+1
DO IHEL=1,NEXTERNAL
JC(IHEL) = +1
ENDDO
DO I=1,NSQAMPSO
ANS(I) = 0D0
ENDDO
DO IHEL=1,NCOMB
IF (USERHEL.EQ.-1.OR.USERHEL.EQ.IHEL) THEN
IF (GOODHEL(IHEL) .OR. NTRY .LT. 2) THEN
CALL MG5_1_MATRIX(P ,NHEL(1,IHEL),JC(1), T)
BUFF=0D0
DO I=1,NSQAMPSO
ANS(I)=ANS(I)+T(I)
BUFF=BUFF+T(I)
ENDDO
IF (BUFF .NE. 0D0 .AND. .NOT. GOODHEL(IHEL)) THEN
GOODHEL(IHEL)=.TRUE.
ENDIF
ENDIF
ENDIF
ENDDO
ANS(0)=0.0D0
DO I=1,NSQAMPSO
ANS(I)=ANS(I)/DBLE(IDEN)
IF (CHOSEN_SO_CONFIGS(I)) THEN
ANS(0)=ANS(0)+ANS(I)
ENDIF
ENDDO
IF(USERHEL.NE.-1) THEN
ANS(0)=ANS(0)*HELAVGFACTOR
DO I=1,NSQAMPSO
ANS(I)=ANS(I)*HELAVGFACTOR
ENDDO
ENDIF
END
SUBROUTINE MG5_1_SMATRIXHEL_SPLITORDERS(P,HEL,ANS)
IMPLICIT NONE
C
C CONSTANT
C
INTEGER NEXTERNAL
PARAMETER (NEXTERNAL=4)
INTEGER NCOMB
PARAMETER ( NCOMB=16)
INTEGER NSQAMPSO
PARAMETER (NSQAMPSO=1)
C
C ARGUMENTS
C
REAL*8 P(0:3,NEXTERNAL),ANS(0:NSQAMPSO)
INTEGER HEL
C
C GLOBAL VARIABLES
C
INTEGER USERHEL
COMMON/MG5_1_HELUSERCHOICE/USERHEL
C ----------
C BEGIN CODE
C ----------
USERHEL=HEL
CALL MG5_1_SMATRIX_SPLITORDERS(P,ANS)
USERHEL=-1
END
SUBROUTINE MG5_1_MATRIX(P,NHEL,IC,RES)
C
C Generated by MadGraph5_aMC@NLO v. %(version)s, %(date)s
C By the MadGraph5_aMC@NLO Development Team
C Visit launchpad.net/madgraph5 and amcatnlo.web.cern.ch
C
C Returns amplitude squared summed/avg over colors
C for the point with external lines W(0:6,NEXTERNAL)
C
C Process: u u~ > u u~ [ virt = QCD ] @1
C
IMPLICIT NONE
C
C CONSTANTS
C
INTEGER NGRAPHS
PARAMETER (NGRAPHS=2)
INTEGER NEXTERNAL
PARAMETER (NEXTERNAL=4)
INTEGER NWAVEFUNCS, NCOLOR
PARAMETER (NWAVEFUNCS=5, NCOLOR=2)
INTEGER NAMPSO, NSQAMPSO
PARAMETER (NAMPSO=1, NSQAMPSO=1)
REAL*8 ZERO
PARAMETER (ZERO=0D0)
COMPLEX*16 IMAG1
PARAMETER (IMAG1=(0D0,1D0))
C
C ARGUMENTS
C
REAL*8 P(0:3,NEXTERNAL)
INTEGER NHEL(NEXTERNAL), IC(NEXTERNAL)
REAL*8 RES(NSQAMPSO)
C
C LOCAL VARIABLES
C
INTEGER I,J,M,N
COMPLEX*16 ZTEMP
REAL*8 DENOM(NCOLOR), CF(NCOLOR,NCOLOR)
COMPLEX*16 AMP(NGRAPHS)
COMPLEX*16 JAMP(NCOLOR,NAMPSO), LNJAMP(NCOLOR,NAMPSO)
COMMON/MG5_1_JAMP/JAMP,LNJAMP
COMPLEX*16 W(18,NWAVEFUNCS)
COMPLEX*16 DUM0,DUM1
DATA DUM0, DUM1/(0D0, 0D0), (1D0, 0D0)/
C
C FUNCTION
C
INTEGER MG5_1_SQSOINDEX
C
C GLOBAL VARIABLES
C
INCLUDE 'coupl.inc'
C
C COLOR DATA
C
DATA DENOM(1)/1/
DATA (CF(I, 1),I= 1, 2) / 9, 3/
C 1 T(2,1) T(3,4)
DATA DENOM(2)/1/
DATA (CF(I, 2),I= 1, 2) / 3, 9/
C 1 T(2,4) T(3,1)
C ----------
C BEGIN CODE
C ----------
CALL IXXXXX(P(0,1),ZERO,NHEL(1),+1*IC(1),W(1,1))
CALL OXXXXX(P(0,2),ZERO,NHEL(2),-1*IC(2),W(1,2))
CALL OXXXXX(P(0,3),ZERO,NHEL(3),+1*IC(3),W(1,3))
CALL IXXXXX(P(0,4),ZERO,NHEL(4),-1*IC(4),W(1,4))
CALL FFV1P0_3(W(1,1),W(1,2),GC_5,ZERO,ZERO,W(1,5))
C Amplitude(s) for diagram number 1
CALL FFV1_0(W(1,4),W(1,3),W(1,5),GC_5,AMP(1))
CALL FFV1P0_3(W(1,1),W(1,3),GC_5,ZERO,ZERO,W(1,5))
C Amplitude(s) for diagram number 2
CALL FFV1_0(W(1,4),W(1,2),W(1,5),GC_5,AMP(2))
C JAMPs contributing to orders QCD=2
JAMP(1,1)=+1D0/2D0*(+1D0/3D0*AMP(1)+AMP(2))
JAMP(2,1)=+1D0/2D0*(-AMP(1)-1D0/3D0*AMP(2))
LNJAMP(1,1)=+1D0/2D0*(+AMP(2))
LNJAMP(2,1)=+1D0/2D0*(-AMP(1))
RES = 0.D0
DO M = 1, NAMPSO
DO I = 1, NCOLOR
ZTEMP = (0.D0,0.D0)
DO J = 1, NCOLOR
ZTEMP = ZTEMP + CF(J,I)*JAMP(J,M)
ENDDO
DO N = 1, NAMPSO
RES(MG5_1_SQSOINDEX(M,N)) = RES(MG5_1_SQSOINDEX(M,N))
$ + ZTEMP*DCONJG(JAMP(I,N))/DENOM(I)
ENDDO
ENDDO
ENDDO
END
SUBROUTINE MG5_1_BORN(P,NHEL)
C
C Generated by MadGraph5_aMC@NLO v. %(version)s, %(date)s
C By the MadGraph5_aMC@NLO Development Team
C Visit launchpad.net/madgraph5 and amcatnlo.web.cern.ch
C
C Returns amplitude squared summed/avg over colors
C for the point with external lines W(0:6,NEXTERNAL)
C
C Process: u u~ > u u~ [ virt = QCD ] @1
C
IMPLICIT NONE
C
C CONSTANTS
C
INTEGER NGRAPHS
PARAMETER (NGRAPHS=2)
INTEGER NEXTERNAL
PARAMETER (NEXTERNAL=4)
INTEGER NWAVEFUNCS, NCOLOR
PARAMETER (NWAVEFUNCS=5, NCOLOR=2)
INTEGER NAMPSO, NSQAMPSO
PARAMETER (NAMPSO=1, NSQAMPSO=1)
REAL*8 ZERO
PARAMETER (ZERO=0D0)
COMPLEX*16 IMAG1
PARAMETER (IMAG1=(0D0,1D0))
C
C ARGUMENTS
C
REAL*8 P(0:3,NEXTERNAL)
INTEGER NHEL(NEXTERNAL), IC(NEXTERNAL)
C
C LOCAL VARIABLES
C
INTEGER I,J,M,N
COMPLEX*16 ZTEMP
REAL*8 DENOM(NCOLOR), CF(NCOLOR,NCOLOR)
COMPLEX*16 AMP(NGRAPHS)
COMPLEX*16 JAMP(NCOLOR,NAMPSO), LNJAMP(NCOLOR,NAMPSO)
COMMON/MG5_1_JAMP/JAMP,LNJAMP
COMPLEX*16 W(18,NWAVEFUNCS)
COMPLEX*16 DUM0,DUM1
DATA DUM0, DUM1/(0D0, 0D0), (1D0, 0D0)/
C
C GLOBAL VARIABLES
C
INCLUDE 'coupl.inc'
C
C COLOR DATA
C
DATA DENOM(1)/1/
DATA (CF(I, 1),I= 1, 2) / 9, 3/
C 1 T(2,1) T(3,4)
DATA DENOM(2)/1/
DATA (CF(I, 2),I= 1, 2) / 3, 9/
C 1 T(2,4) T(3,1)
C ----------
C BEGIN CODE
C ----------
DO I=1,NEXTERNAL
IC(I) = 1
ENDDO
CALL IXXXXX(P(0,1),ZERO,NHEL(1),+1*IC(1),W(1,1))
CALL OXXXXX(P(0,2),ZERO,NHEL(2),-1*IC(2),W(1,2))
CALL OXXXXX(P(0,3),ZERO,NHEL(3),+1*IC(3),W(1,3))
CALL IXXXXX(P(0,4),ZERO,NHEL(4),-1*IC(4),W(1,4))
CALL FFV1P0_3(W(1,1),W(1,2),GC_5,ZERO,ZERO,W(1,5))
C Amplitude(s) for diagram number 1
CALL FFV1_0(W(1,4),W(1,3),W(1,5),GC_5,AMP(1))
CALL FFV1P0_3(W(1,1),W(1,3),GC_5,ZERO,ZERO,W(1,5))
C Amplitude(s) for diagram number 2
CALL FFV1_0(W(1,4),W(1,2),W(1,5),GC_5,AMP(2))
C JAMPs contributing to orders QCD=2
JAMP(1,1)=+1D0/2D0*(+1D0/3D0*AMP(1)+AMP(2))
JAMP(2,1)=+1D0/2D0*(-AMP(1)-1D0/3D0*AMP(2))
LNJAMP(1,1)=+1D0/2D0*(+AMP(2))
LNJAMP(2,1)=+1D0/2D0*(-AMP(1))
END
SUBROUTINE MG5_1_GET_JAMP(NJAMP, ONEJAMP)
INTEGER NCOLOR, NJAMP
PARAMETER (NCOLOR=2)
INTEGER NAMPSO
PARAMETER (NAMPSO=1)
COMPLEX*16 JAMP(NCOLOR,NAMPSO), ONEJAMP
COMMON/MG5_1_JAMP/JAMP,LNJAMP
ONEJAMP = JAMP(NJAMP+1,1) ! +1 since njamp start at zero (c convention)
END
SUBROUTINE MG5_1_GET_LNJAMP(NJAMP, ONEJAMP)
INTEGER NCOLOR, NJAMP
PARAMETER (NCOLOR=2)
INTEGER NAMPSO
PARAMETER (NAMPSO=1)
COMPLEX*16 JAMP(NCOLOR,NAMPSO), LNJAMP(NCOLOR,NAMPSO), ONEJAMP
COMMON/MG5_1_JAMP/JAMP,LNJAMP
ONEJAMP = LNJAMP(NJAMP+1,1) ! +1 since njamp start at zero (c convention)
END
SUBROUTINE MG5_1_GET_NCOLOR(IN1, IN2, OUT)
INTEGER IN1, IN2, OUT
IF (IN1.EQ.0.AND.IN2.EQ.1)THEN
OUT = 1
ELSEIF (IN1.EQ.0.AND.IN2.EQ.0)THEN
OUT = 2
ELSEIF (IN1.EQ.0.AND.IN2.EQ.5)THEN
OUT = 0
ELSEIF (IN1.EQ.0.AND.IN2.EQ.4)THEN
OUT = 4
ELSEIF (IN1.EQ.0.AND.IN2.EQ.3)THEN
OUT = 3
ELSEIF (IN1.EQ.0.AND.IN2.EQ.2)THEN
OUT = 0
ELSEIF (IN1.EQ.1.AND.IN2.EQ.2)THEN
OUT = 0
ELSEIF (IN1.EQ.1.AND.IN2.EQ.3)THEN
OUT = 3
ELSEIF (IN1.EQ.1.AND.IN2.EQ.4)THEN
OUT = 1
ELSEIF (IN1.EQ.1.AND.IN2.EQ.5)THEN
OUT = 0
ELSEIF (IN1.EQ.1.AND.IN2.EQ.0)THEN
OUT = 2
ELSEIF (IN1.EQ.1.AND.IN2.EQ.1)THEN
OUT = 4
ELSE
OUT = - 1
ENDIF
END
SUBROUTINE MG5_1_GET_NCOL(NCOL)
INTEGER NCOL
NCOL = 2
RETURN
END
C Set of functions to handle the array indices of the split orders
INTEGER FUNCTION MG5_1_SQSOINDEX(ORDERINDEXA, ORDERINDEXB)
C
C This functions plays the role of the interference matrix. It can
C be hardcoded or
C made more elegant using hashtables if its execution speed ever
C becomes a relevant
C factor. From two split order indices, it return the corresponding
C index in the squared
C order canonical ordering.
C
C CONSTANTS
C
INTEGER NSO, NSQUAREDSO, NAMPSO
PARAMETER (NSO=1, NSQUAREDSO=1, NAMPSO=1)
C
C ARGUMENTS
C
INTEGER ORDERINDEXA, ORDERINDEXB
C
C LOCAL VARIABLES
C
INTEGER I, SQORDERS(NSO)
INTEGER AMPSPLITORDERS(NAMPSO,NSO)
DATA (AMPSPLITORDERS( 1,I),I= 1, 1) / 2/
COMMON/MG5_1_AMPSPLITORDERS/AMPSPLITORDERS
C
C FUNCTION
C
INTEGER MG5_1_SOINDEX_FOR_SQUARED_ORDERS
C
C BEGIN CODE
C
DO I=1,NSO
SQORDERS(I)=AMPSPLITORDERS(ORDERINDEXA,I)+AMPSPLITORDERS(ORDERI
$ NDEXB,I)
ENDDO
MG5_1_SQSOINDEX=MG5_1_SOINDEX_FOR_SQUARED_ORDERS(SQORDERS)
END
INTEGER FUNCTION MG5_1_SOINDEX_FOR_SQUARED_ORDERS(ORDERS)
C
C This functions returns the integer index identifying the squared
C split orders list passed in argument which corresponds to the
C values of the following list of couplings (and in this order).
C ['QCD']
C
C CONSTANTS
C
INTEGER NSO, NSQSO, NAMPSO
PARAMETER (NSO=1, NSQSO=1, NAMPSO=1)
C
C ARGUMENTS
C
INTEGER ORDERS(NSO)
C
C LOCAL VARIABLES
C
INTEGER I,J
INTEGER SQSPLITORDERS(NSQSO,NSO)
DATA (SQSPLITORDERS( 1,I),I= 1, 1) / 4/
COMMON/MG5_1_SQPLITORDERS/SQPLITORDERS
C
C BEGIN CODE
C
DO I=1,NSQSO
DO J=1,NSO
IF (ORDERS(J).NE.SQSPLITORDERS(I,J)) GOTO 1009
ENDDO
MG5_1_SOINDEX_FOR_SQUARED_ORDERS = I
RETURN
1009 CONTINUE
ENDDO
WRITE(*,*) 'ERROR:: Stopping in function'
WRITE(*,*) 'MG5_1_SOINDEX_FOR_SQUARED_ORDERS'
WRITE(*,*) 'Could not find squared orders ',(ORDERS(I),I=1,NSO)
STOP
END
SUBROUTINE MG5_1_GET_NSQSO_BORN(NSQSO)
C
C Simple subroutine returning the number of squared split order
C contributions returned when calling smatrix_split_orders
C
INTEGER NSQUAREDSO
PARAMETER (NSQUAREDSO=1)
INTEGER NSQSO
NSQSO=NSQUAREDSO
END
C This is the inverse subroutine of SOINDEX_FOR_SQUARED_ORDERS.
C Not directly useful, but provided nonetheless.
SUBROUTINE MG5_1_GET_SQUARED_ORDERS_FOR_SOINDEX(SOINDEX,ORDERS)
C
C This functions returns the orders identified by the squared
C split order index in argument. Order values correspond to
C following list of couplings (and in this order):
C ['QCD']
C
C CONSTANTS
C
INTEGER NSO, NSQSO
PARAMETER (NSO=1, NSQSO=1)
C
C ARGUMENTS
C
INTEGER SOINDEX, ORDERS(NSO)
C
C LOCAL VARIABLES
C
INTEGER I
INTEGER SQPLITORDERS(NSQSO,NSO)
COMMON/MG5_1_SQPLITORDERS/SQPLITORDERS
C
C BEGIN CODE
C
IF (SOINDEX.GT.0.AND.SOINDEX.LE.NSQSO) THEN
DO I=1,NSO
ORDERS(I) = SQPLITORDERS(SOINDEX,I)
ENDDO
RETURN
ENDIF
WRITE(*,*) 'ERROR:: Stopping function MG5_1_GET_SQUARED_ORDERS_F'
$ //'OR_SOINDEX'
WRITE(*,*) 'Could not find squared orders index ',SOINDEX
STOP
END SUBROUTINE
C This is the inverse subroutine of getting amplitude SO orders.
C Not directly useful, but provided nonetheless.
SUBROUTINE MG5_1_GET_ORDERS_FOR_AMPSOINDEX(SOINDEX,ORDERS)
C
C This functions returns the orders identified by the split order
C index in argument. Order values correspond to following list of
C couplings (and in this order):
C ['QCD']
C
C CONSTANTS
C
INTEGER NSO, NAMPSO
PARAMETER (NSO=1, NAMPSO=1)
C
C ARGUMENTS
C
INTEGER SOINDEX, ORDERS(NSO)
C
C LOCAL VARIABLES
C
INTEGER I
INTEGER AMPSPLITORDERS(NAMPSO,NSO)
COMMON/MG5_1_AMPSPLITORDERS/AMPSPLITORDERS
C
C BEGIN CODE
C
IF (SOINDEX.GT.0.AND.SOINDEX.LE.NAMPSO) THEN
DO I=1,NSO
ORDERS(I) = AMPSPLITORDERS(SOINDEX,I)
ENDDO
RETURN
ENDIF
WRITE(*,*) 'ERROR:: Stopping function MG5_1_GET_ORDERS_FOR_AMPSO'
$ //'INDEX'
WRITE(*,*) 'Could not find amplitude split orders index ',SOINDEX
STOP
END SUBROUTINE
C This function is not directly useful, but included for completene
C ss
INTEGER FUNCTION MG5_1_SOINDEX_FOR_AMPORDERS(ORDERS)
C
C This functions returns the integer index identifying the
C amplitude split orders passed in argument which correspond to
C the values of the following list of couplings (and in this
C order):
C ['QCD']
C
C CONSTANTS
C
INTEGER NSO, NAMPSO
PARAMETER (NSO=1, NAMPSO=1)
C
C ARGUMENTS
C
INTEGER ORDERS(NSO)
C
C LOCAL VARIABLES
C
INTEGER I,J
INTEGER AMPSPLITORDERS(NAMPSO,NSO)
COMMON/MG5_1_AMPSPLITORDERS/AMPSPLITORDERS
C
C BEGIN CODE
C
DO I=1,NAMPSO
DO J=1,NSO
IF (ORDERS(J).NE.AMPSPLITORDERS(I,J)) GOTO 1009
ENDDO
MG5_1_SOINDEX_FOR_AMPORDERS = I
RETURN
1009 CONTINUE
ENDDO
WRITE(*,*) 'ERROR:: Stopping function MG5_1_SOINDEX_FOR_AMPORDER'
$ //'S'
WRITE(*,*) 'Could not find squared orders ',(ORDERS(I),I=1,NSO)
STOP
END
| tests/input_files/IOTestsComparison/TestCmdMatchBox.moved/MatchBoxOutput/%TEST%SubProcesses%P1_uux_uux%born_matrix.f |
! $Id: TestLUPIV.f90 460 2013-03-05 09:01:48Z abuttari $
! ------------------------------------
! Programme principal permettant
! de tester la factorisation LU AVEC pivotage
! d'une matrice pleine
! ------------------------------------
program mainlu
implicit none
interface
subroutine init(a, acopie, xexact, b, bcopie, x, y, r, &
p,q,lda, n,ipivot)
integer, intent(out) :: lda,n,ipivot
double precision, dimension(:,:), allocatable, intent(out) :: a, acopie
integer, dimension(:), allocatable , intent(out) :: p,q
double precision, dimension(:), allocatable, intent(out) :: &
xexact, b, bcopie, x, y, r
end subroutine init
end interface
! Dimension principale (taille de la structure de donn�e allouee en memoire)
integer :: lda
! Dimension reelle du systeme a factoriser (on factorise A(1:n,1:n))
integer :: n
! Matrice a factoriser et permutation P et Q
double precision, dimension(:,:), allocatable :: a, acopie
integer, dimension (:), allocatable :: p, q
! Solution exacte, second membre, solution calculee du systeme et residu
double precision, dimension(:), allocatable :: xexact, b, x, &
r, bcopie
! Vecteur temporaire
double precision, dimension(:), allocatable :: y
! Determinant = DET_Mantisse * 2^DET_Exposant
! Pour eviter les underflows et overflows, le mantisse
! et l'exposant du determinant sont separees.
double precision :: det_mantisse
integer :: det_exposant
! Scalaire local
integer :: ierr
! Strat�gie de pivot
integer :: ipivot
! EXTERNAL
external norme
double precision norme
!
! --------------------------------------------
! Initialisation matrice A et second membre b
! --------------------------------------------
! -- definir A et Xexact puis calculer b = A xexact
! (faire une copie de A --> Acopie et b --> bcopie)
! allouer x, y et r, P
call init(a, acopie, xexact, b, bcopie, x, y, r, p,q, lda, n,ipivot)
! -------------------------
! Factorisation de Gauss ( P A = L U ) et calcul du determinant
! -------------------------
!! write(6,*) ' '
!! write(6,*) ' ............................... '
!! write(6,*) ' FACTORISATION LU A ECRIRE '
!! write(6,*) ' ............................... '
call facto(a, lda, n,ipivot, p,q,ierr)
write(6,*) ' '
if(ierr==1)then
write(6,*) 'Echec de la factorisation'
else
! ----------------------
! Algorithme de descente ( L y = Pb)
! ----------------------
call descente ( a, lda, n, p, b, y)
! ----------------------
! Algorithme de remontee ( U x = y )
! ----------------------
call remontee ( a, lda, n, y, x)
!------------------------------------------
! Analyse de l'erreur :
! Calcul/affichage du residu || b - A x || et
! du residu equilibre || b - A x || / || |A||X| + |b| ||
! Calcul et affichage de || x - xexact�|| / || xexact ||
!------------------------------------------
!! write(6,*) ' '
!! write(6,*) ' ............................... '
!! write(6,*) ' ROUTINE ANALYSE ERREUR A ECRIRE '
!! write(6,*) ' ............................... '
call analyse_erreur (acopie,lda,n,bcopie,x,r,xexact)
write(6,*) ' '
endif
deallocate (a, acopie, p, b, bcopie, x, r, y, xexact)
stop
end program mainlu
!--------------------------------------------------------------
!--------------------------------------------------------------
!**************************************************
! Subroutines utilis�es par le programme principal
!
!
!**************************************************
subroutine init(m,mcopie,xexact,b,bcopie, &
x,y,r,p,q,ldm,n,ipivot)
implicit none
! -------------------------------------------------------------
! Objectif:
! - Tous les tableaux/matrices passes en arguments
! sont alloues dans la routine.
! - Initialisation, de la matrice M, de la solution x
! et du vecteur b tel que b = M x
! M est une matrice de dimension principale ldm avec
! n colonnes.
! Deux classes de matrices sont proposees:
! Classe I/
! -Les matrices d'ordre pair sont diagonales dominantes
! -Les matrices d'ordre impair ont de petites valeurs
! sur la diagonale et peuvent conduire � une perte
! de precision dans la solution
! Classe II/
! -12 matrices utilisant le generateur de LAPACK
! Soit x / x(i) = dble(i) on construit alors b = M x
! Une copie de M (-->Mcopie) et de b (--> bcopie) est effectuee
! --------------------------------------------------------------
!
interface
subroutine matgen(imat, a, n, info)
real(kind(1.d0)), allocatable :: a(:,:)
integer :: imat, n, info
end subroutine matgen
end interface
! Parametres :
! ----------
integer, intent(out) :: ldm,n,ipivot
double precision, allocatable, intent(out) :: &
m(:,:), mcopie(:,:), xexact(:), &
b(:), bcopie(:), x(:), y(:), r(:)
integer, allocatable, intent(out) :: p(:), q(:)
! Dimension maximale du systeme
integer :: ldmmax=5000
!
! Variables locales :
! -----------------
integer :: i,j, ierr, classmat, imat
logical :: pair
!
! Fonctions intrinseques
intrinsic dble, min
! -- taille du probleme
classmat = 1
ldm = -1
n = 0
do while (n.gt.ldm.or. ldm.ge.ldmmax)
write(6,*) ' Entrer la taille de la matrice lda (< ', &
ldmmax, ' ) ?'
read(5,*) ldm
write(6,*) ' Entrer la dimension reelle n (< ', ldm, ' ) ?'
read(5,*) n
!
write(6,*) ' Entrer la classe de matrice ', &
' (1 sinon 2 (generateur LAPACK)) ?'
read(5,*) classmat
!
if (classmat.eq.1) then
! -------------------------------
! Utilisation du generateur local
! -------------------------------
!
allocate(m(ldm,n), stat=ierr)
if (ierr > 0) then
write(6,*) ' Probleme allocation memoire :', &
' reduire n=', n
stop
endif
!
pair=(mod(n,2) .eq. 0)
! -- Initialisation de la matrice M
! Les matrices d'indice pair sont diagonales dominantes
! les matrices d'indice impair ont de petites valeurs
! sur la diagonale.
if (pair) then
do i = 1,n
do j=1,n
m(i,j) = dble(1)
end do
m(i,i) = dble(n+100)
end do
else
do i = 1,n
do j=1,n
m(i,j) = dble(i)*dble(j)
end do
m(i,i) = dble(i)*sqrt(epsilon(m(i,i)))
end do
endif
else
! -------------------------------------------------------------------
! Utilisation du generateur de matrices pour valider les codes LAPACK
! -------------------------------------------------------------------
imat = 0
do while (imat.le.0.or.imat.gt.12)
write(6,*) ' Generateur de matrices de LAPACK '
write(6,*) ' Entrer le numero de la matrice entre 1 et 12 ?'
read(5,*) imat
end do
! -- Initialisation de la matrice M
ldm = n
call matgen(imat, m, n, ierr)
if (ierr.ne.0) then
write(6,*) " Erreur dans le gnerateur LAPACK (matgen)"
stop
endif
endif
!
! -- allocation des structures de donn�es
allocate (p(n),q(n), mcopie(ldm,n), b(n), bcopie(n), x(n), &
r(n), y(n), xexact(n), stat=ierr)
! Strat�gie de pivot
write(6,*) ' Entreer la strategie de pivot ', &
'0: sans pivot, 1 : pivot partiel, 2 : recherche du noyau'
read(5,*) ipivot
end do
if (ierr > 0) then
write(6,*) ' Probleme allocation memoire :', &
' reduire n=', n
stop
endif
! Copie de la matrice
mcopie = m
! -- Initialisation de la solution exacte dans xexact
do i=1,n
xexact(i) = dble(i)
end do
!
! -- Calcul de b / b = A xexact
do i = 1, n
b(i) = dble(0)
do j=1,n
b(i) = b(i) + m(i,j) * xexact(j)
enddo
enddo
! Sauvegarde de b
bcopie = b
! -- impression des donnees
if (n.le.10) then
write (6,*) ' Matrice initiale A = '
do i = 1,min(n,6)
write(6,'(A,I3,6(E14.5))') ' ... Ligne ', i, m(i,1:min(n,6))
end do
write (6,'(A,6(E14.5))') ' xexact =', xexact(1:min(n,6))
write (6,'(A,6(E14.5))') ' b =', b(1:min(n,6))
endif
return
end subroutine init
!
!
!**************************************************
subroutine facto(m, ldm, n, ipivot, p, q, ierr)
implicit none
! ------------------------------------------------------
! Objectifs: Factorisation LU AVEC pivotage
! 1/ Calculer L / P M = L U
! La matrice M est de dimension principale ldm.
! On factorise le bloc M(1:n, 1:n)
! par l'algorithme de factorisation LU sans pivotage
! comme present� en cours.
!
! Calculer le determinant
!
! En entr�e la matrice M est �cras�e en sortie
! par les facteurs L et U.
!
! IERR > 0 si un pivot trop petit
! a �t� rencontr� durant factorisation
! ------------------------------------------------------
!
! Parametres :
! ----------
integer, intent(in) :: ldm,n,ipivot
double precision, intent(inout) :: m(ldm,n) ! matrice
integer, intent(out) :: p(n) ! permutation des lignes
integer, intent(out) ::q(n) ! permutation des colonnes
integer, intent(out) :: ierr
!
! Interface
interface
double precision function norme_f ( a, n,m)
integer, intent(in) :: n,m
double precision, intent(in) :: a(n,m)
end function norme_f
end interface
! Fonctions intrinseques
intrinsic epsilon
! Variables locales :
! -----------------
! Indices de boucle
integer :: i,j,k
double precision :: eps
! epsilon machine (pour v�rifier si pas d pivot trop petit)
eps = epsilon(eps)
! initialisation de la permutation (identit�)
do k = 1, n
p(k) = k
end do
!!!!!!!!!!!!!!!!! A ECRIRE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!Etape de factorisation LU avec trois strat�gies de pivot :
!! sans pivot (ipivot =0), avec pivot partiel (ipivot=1),
!! recherche du noyau pour matrice non inversible (ipivot>1)
do j = 1, n-1
if (abs(m(j, j)) < eps) then
ierr = ierr + 1
end if
m(j+1:n, j) = m(j+1:n, j) / m(j, j);
!m(j+1:n, j+1:n) = m(j+1:n, j+1:n) - matmul(m(j+1:n, j), m(j, j+1:n))
end do
! -- impression des donnees :
! -- determinant
write(6,*) " =============================================="
write(6,*) " Fin de la FACTORISATION "
write(6,*) " ========================"
write(6,*) " ... AFFICHER DETERMINANT de la matrice "
if (n.le.6) then
write (6,*) ' ... Matrice factorisee par ligne : '
do i = 1,n
write(6,'(6(E14.5))') m(i,1:n)
end do
write (6,*) " ... Permutation P : ", P(1:n)
write (6,*) " ... Permutation Q : ", Q(1:n)
endif
write(6,*) " =============================================="
return
end subroutine facto
!**************************************************
subroutine descente (m,ldm,n,p,b,x)
implicit none
! -----------------------------------------------------------
! Objectif:
! Resoudre L x = P b avec
! L la partie triangulaire inferieure de la matrice M,
! de dimension principale ldm et de n colonnes.
! Algorithme avec report:
! cet algorithme a assez naturellement tendance
! � modifier le second membre ce qui n'est
! ni une bonne propriete ni
! indispensable comme le montre l'implementation fournie ici
! -------------------------------------------------------------
!
! Parametres :
! ----------
integer, intent(in) :: ldm,n
double precision, intent(in) :: m(ldm,n)
integer, intent(in) :: p(n)
! attention assez naturellement on va
! lors du report modifier b
! ( MAIS uniquement si on est peu attentif !)
double precision, intent(in) :: b(n)
double precision, intent(out) :: x(n)
!
! Variables locales :
! -----------------
! Indices de boucle
integer :: i,j
double precision :: xtemp
!
! Algorithme avec report sans modification de b
!
x = b
! Ecrire la prise en compte de la permutation P en permutant
! le second membre qui est maintenant dans x
write(6,*)"Descente : permutation P non prise en compte"
do i = 1, n
! calcul du x(i)
! L a des 1 sur la diagonale (non stockes dans M!)
! report de la connaissance de x(i) sur es second membres.
! pour eviter de modifier b on note
! qu'a chaque etape i, les parties
! modifiees de b et calculees de x forment une partition de {1,..,n}
do j = i+1, n
! --- avec modification de b:
! --- b(j) = b(j) - M(j,i) * x(i)
! sans modification de b:
x(j) = x(j) - m(j,i) * x(i)
end do
end do
! write (6,*) " En sortie de la descente Ly = b: "
! write (6,'(A,6(E14.5))') ' b =', b(1:min(n,6))
! write (6,'(A,6(E14.5))') ' y =', x(1:min(n,6))
return
end subroutine descente
!
!**************************************************
subroutine remontee (m,ldm,n,b,x)
implicit none
! ------------------------------------------------------
! Objectif:
! Resoudre U x = b avec
! U la partie triangulaire superieure de la matrice M,
! de dimension principale ldm et de n colonnes.
! Algorithme sans report.
! ------------------------------------------------------
!
! Parametres :
! ----------
integer, intent(in) :: ldm,n
double precision, intent(in) :: m(ldm,n), b(n)
double precision, intent(out) :: x(n)
!
! Variables locales :
! -----------------
! Indices de boucle
integer :: i,j
! Permutation
double precision :: xtemp
! Algorithme sans report.
do i = n, 1, -1
x(i) = b(i)
! on reporte la connaissance des x(j) pour j> i
! et on va chercher M(i,j) dans la triangulaire inferieure
do j = i+1, n
x(i) = x(i) - m(i,j) * x(j)
end do
x(i) = x(i) / m(i,i)
end do
! write (6,*) " En sortie de la remontee Ux = y: "
! write (6,'(A,6(E14.5))') ' y =', b(1:min(n,6))
! write (6,'(A,6(E14.5))') ' x =', x(1:min(n,6))
return
end subroutine remontee
!**************************************************
subroutine analyse_erreur(m,ldm,n,b,x,r,xexact)
implicit none
! ------------------------------------------------------------
! Objectif:
! Analyse de l'erreur :
! Calcul et affichage de || b - M x || / || |M||X| + |b| ||
! Calcul et affichage de || x - xexact�|| / || xexact ||
! M etant une matrice carree de
! dimension principale ldm et de n colonnes.
! -------------------------------------------------------------
!
! Parametres :
! ----------
integer, intent(in) :: ldm,n
double precision, intent(in) :: m(ldm,n), x(n), b(n)
double precision, intent(out) :: r(n)
double precision, intent(in) :: xexact(n)
! Interfaces
interface
double precision function norme ( x, n)
integer, intent(in) :: n
double precision, intent(in) :: x(n)
end function norme
double precision function norme_f ( a, n,m)
integer, intent(in) :: n,m
double precision, intent(in) :: a(n,m)
end function norme_f
end interface
!
! Variables locales :
! -----------------
! Indices de boucles
integer :: i, j
!!!!!!!!!!!!!!!!! A ECRIRE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Calcul et affichage de des erreurs relatives directe et inverse
!! Calcul et afffichage de la norme du r�sidu
write(6,*) "Analyse erreur non faite "
write(6,*) " "
write(6,*) " =============================================="
write(6,*) " Analyse d'ERREUR "
write(6,*) " ================ "
write(6,'(A,6(E14.5))') ' xexact =', xexact(1:min(n,6))
write(6,'(A,6(E14.5))') ' xcalcule =', x(1:min(n,6))
write(6,*) " =============================================="
return
end subroutine analyse_erreur
!**************************************************
subroutine noyau (m,ldm,n,q,kstop,x)
implicit none
! ------------------------------------------------------
! Objectif:
! Calculer une base du noyau depuis la factorisation incomplete
! Arret de la factosiation � l'�tape kstop
! Ker (AQ) = Im[-U11^(-1)*U12;Ir]
!
!
! ------------------------------------------------------
!
! Parametres :
! ----------
integer, intent(in) :: ldm,n,kstop
double precision, intent(in) :: m(ldm,n) ! facto LU incomplete de PAQ
integer, intent(in) :: q(n) ! permutation des colonnes
double precision, intent(out) :: x(n,n-kstop+1) ! base du noyau
!
! Variables locales :
! -----------------
! Indices de boucle
integer :: i,j,l
!!!!!!!!!!!!!!!!! A ECRIRE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Calcul d'une base du noyau de A
write (6,*) "Base du noyau non calculee"
return
end subroutine noyau
!**************************************************
double precision function norme ( x, n)
implicit none
! ---------------------------------------
! Objectif: NORME = || x || , with 2 norm
! ----------------------------------------
integer, intent(in) :: n
double precision, intent(in) :: x(n)
!
! Variables locales :
! -----------------
! Indices de boucles
integer :: i
!
! Fonctions intrinseques
intrinsic sqrt, dble
norme = dble(0)
do i=1, n
norme = norme + x(i) *x(i)
enddo
norme = sqrt(norme)
return
end function norme
!**************************************************
double precision function norme_f ( a, n,m)
implicit none
! ---------------------------------------
! Objectif: NORME_F = || A ||, avec norme de Frobenius
! ----------------------------------------
integer, intent(in) :: n, m
double precision, intent(in) :: a(n,m)
!
! Variables locales :
! -----------------
! Indices de boucles
integer :: i,j
!
! Fonctions intrinseques
intrinsic sqrt, dble
norme_f = dble(0)
do j=1,m
do i=1,n
norme_f = norme_f + a(i,j)*a(i,j)
enddo
enddo
norme_f = sqrt(norme_f)
return
end function norme_f
| Calcul_Scientifique/TP2/TestLUPIV.f90 |
program main
implicit none
integer i,n
integer,dimension (128) :: iseed
real(8) diff,norm
real(8),allocatable,dimension(:) :: x,g,u,ud
n = 10000
allocate( x(3*n),g(3*n),u(3*n),ud(3*n) )
do i = 1,128
iseed(i) = 0
enddo
call random_seed(put=iseed)
call random_number(x)
call random_number(g)
do i = 1,n
g(3*i-2) = (g(3*i-2) - 0.5) / n
g(3*i-1) = (g(3*i-1) - 0.5) / n
g(3*i-0) = (g(3*i-0) - 0.5) / n
u(3*i-2) = 0
u(3*i-1) = 0
u(3*i-0) = 0
ud(3*i-2) = 0
ud(3*i-1) = 0
ud(3*i-0) = 0
enddo
call fmm_init()
call fmm_biot_savart(n,x,g,u)
call direct_biot_savart(n,x,g,ud)
diff = 0
norm = 0
do i = 1,n
diff = diff + (u(3*i-2) - ud(3*i-2)) ** 2
diff = diff + (u(3*i-1) - ud(3*i-1)) ** 2
diff = diff + (u(3*i-0) - ud(3*i-0)) ** 2
norm = norm + ud(3*i-2) ** 2
norm = norm + ud(3*i-1) ** 2
norm = norm + ud(3*i-0) ** 2
enddo
print '(a,es12.5)',"error :",sqrt(diff/norm)
call fmm_finalize()
deallocate( x,g,u,ud )
end program main
| wrapper/test_serial.f90 |
!==============================================================================!
subroutine Prec_Form(ni, a, d, prec)
!------------------------------------------------------------------------------!
! Forms preconditioning matrix "d" from provided matrix "a". !
!------------------------------------------------------------------------------!
implicit none
!---------------------------------[Arguments]----------------------------------!
integer :: ni
type(Matrix_Type) :: a
type(Matrix_Type) :: d
character(len=80) :: prec ! preconditioner
!-----------------------------------[Locals]-----------------------------------!
real :: sum1
integer :: i, j, k
!==============================================================================!
!---------------------------------!
! 1) diagonal preconditioning !
!---------------------------------!
if(prec .eq. 'DIAGONAL') then
do i = 1, ni
d % val(d % dia(i)) = a % val(a % dia(i))
end do
!--------------------------------------------!
! 2) incomplete cholesky preconditioning !
!--------------------------------------------!
else if(prec .eq. 'INCOMPLETE_CHOLESKY') then
do i = 1, ni
sum1 = a % val(a % dia(i)) ! take diaginal entry
do j = a % row(i), a % dia(i)-1 ! only lower traingular
k = a % col(j)
sum1 = sum1 - d % val(d % dia(k)) * a % val(j) * a % val(j)
end do
d % val(d % dia(i)) = 1.0 / sum1
end do
!---------------------------!
! .) no preconditioning !
!---------------------------!
else
do i = 1, ni
d % val(d % dia(i)) = 1.0
end do
end if
end subroutine
| Sources/Process/Solver_Mod/Prec_Form.f90 |
While some like to eat their dessert, others prefer it in the form of a frozen drink. Theyre especially delicious during Davis hot Summer.
NonAlcoholic
Slurpees
Slurpees are only available at 7Eleven mini markets, such as the one on L Street. 7Eleven licensed the frozen drink from the Icee Corporation in 1967 and began selling the frozen carbonated product in its stores under the name Slurpee. Some people use the name Slurpee to refer to any similar beverage, but a true connoisseur knows the difference.
Available only at:
7Eleven
Icees
Icees are available at many places. Some would lump them in the same category as Slurpees, however, the main difference is in texture (Slurpees being gritty, and Icees being more...liquidy).
Available at:
Aggie Student Store the only place on campus, they bought the machine in 2006(They did have another Icee machine before that going back to at least the 90s)
AM/PM
Burger King
Chevron Extra Mile At the Chevron on Chiles Rd.
Fast and Easy Mart
Olive Drive Market (99¢ any size)
Movie Theaters Davis Movie Theaters At Regal Cinemas, they serve Icees under the name of Freeze Frame.
Milk Shakes
Available at most fast food joints and ice cream shops.
Available at:
Baskin Robbins
Burgers and Brews shakes are on the thin side.
Burger King uses premixed liquid instead of real ice cream.
Carls Jr. uses real ice cream.
Davis Creamery at Sugar Daddies uses their homemade ice cream for their shakes; they also have malts.
Innout
Jack in the Box uses real ice cream.
McDonalds uses premixed liquid instead of real ice cream.
Redrum Burger has pretty thick shakes.
Floats
Root beer might be the classic, but lots of people like Coke or orange soda as well.
Innout Part of the Secret Menu.
Burgers and Brew
Jack in the Box They have floats in any brand of soda from their fountain including Fanta Floats(Orange, Strawberry), root beer, etc. They use real ice cream unlike McDonalds or BK.
Coffee Drinks
If you want some caffeine with that coldness, a number of places in Davis offer frozen, blended coffee drinks.
Available at:
Baskin Robbins
CoHo
Nugget
Peets Coffee
Starbucks
Dutch Bros Coffee
Smoothies
Smoothies differ from the above in that they contain real fruit; of course, they can still contain plenty of calories, depending on the other ingredients.
Available at:
Ciocolat
Jamba Juice
Nugget
Italian Ice
Sweet and Shavery
Alcoholic
The Classics
Daiquiri
Margarita
Piña Colada
Mix It Up Mix It Up!
Davis Specialties
Thai Breaker (Sophias Thai Kitchen Sophias)
Departed Businesses:
Seattles Best Coffee JavaKula
Wendys used to serve Frosty Floats.
Dairy Queen
| lab/davisWiki/Frozen_Drinks.f |
College Cab is a Taxi Services cab company that works to meet and exceed your transportation expectations! If you need a ride to Amtrak, SFO the airport or Northern California anywhere at all just give them a call. And if youre Adventures Outside of Davis traveling out of town, ask the College Cab dispatcher for a special flat student rate.
Davis Business License on file.
Sac Airport Permits Yes, #2061
Yolo County Business License This business is not in need of this license as it already has a business license on file for the incorporated City in which it is based (Davis). Businesses that have no base in an incorporated city within the County & who routinely do business in or solicit business in the Unincorporated Areas of the County need to obtain this Yolo County Business License from the Planning & Public Works Office.
Weights & Measures Two devices on file with Yolo County Dept of Weights & Measures.
Need a ride? See the Taxi Services entry!
20100401 05:28:12 nbsp Only company I could get to even pick up the phone at 5AM after another companys cabbie didnt show up to take me to the airport. Users/DavidA2
20100908 22:46:40 nbsp Called after missing the airport Yolobus on Labor Day weekend Sunday. Tried two other companies before one didnt pick up, and the other told me I could get a cab in 3040 minutes. College Cab came in ten minutes, cabbie was great. Is now my first call for portage needs. Users/JaniceW
20100920 18:35:48 nbsp AFTER AN HOUR WAIT/ NO SHOW, gave up and called College Cab @ 11:15p.m., Sunday evening from Amtrac. They arrived within 15 minutes (as promised), and saved the day....THANKS ! from RichD @ NorCalGarage. Users/RichardDurland
20100923 17:56:56 nbsp Thank You College Cab for the referrals you have sent Village Cab
since you have opened & we appreciate the calls you have covered for us!!
Thanks Michael & Yelena! David Max Placencia Users/DavidPlacencia
20110125 16:47:08 nbsp I used College Cab throughout Fall quarter last year for rides to and from Amtrak since I was commuting from the Bay Area and had my threeyearold with me and they were great. Always on time and very reasonable with rates (I made an arrangement with them since I needed a ride twice or thrice a week). Michael and Yelena are super friendly and very reliable. Users/ZehraR
20110323 22:00:59 nbsp College Cab is AMAZING!!!! I reserved to have them pick me up at the Amtrak station and they asked me to call them when I was in Sacramento so they could track me and make sure I did not have to wait out in the cold. I unfortunately forgot my phone back home and pretty much had no way of calling them when I was in Sacramento. When I got to Davis, I was afraid that they would not show up because I never called, but the Driver called the Amtrak station to see if the bus I was on came in and hurried on over to see if I was there! I am so glad that I reserved with College Cab! The driver was so sweet and Ill definitely do business with them again! Users/LivYaj
20110906 11:51:56 nbsp I use College Cab to get to and from the airport a couple of times a month. I schedule pickups in advance and they are ALWAYS on time (and usually a few minutes early). I really appreciate knowing that I can count on them to be there when I arrive at the airport or when I need to catch a flight. As a bonus, Michael and Yelena are really friendly, great people and totally reliable. I cant recommend them highly enough. If you need a ride in Davis or to the airport should definitely call them. Youll be happy you did. Users/dkco
| lab/davisWiki/College_Cab.f |
C$Procedure REMLAI ( Remove elements from an integer array )
SUBROUTINE REMLAI ( NE, LOC, ARRAY, NA )
C$ Abstract
C
C Remove one or more elements from an integer array at the
C indicated location.
C
C$ Disclaimer
C
C THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
C CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
C GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
C ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
C PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
C TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
C WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
C PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
C SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
C SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
C
C IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
C BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
C LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
C INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
C REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
C REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
C
C RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
C THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
C CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
C ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
C
C$ Required_Reading
C
C None.
C
C$ Keywords
C
C ARRAY, ASSIGNMENT
C
C$ Declarations
INTEGER NE
INTEGER LOC
INTEGER ARRAY ( * )
INTEGER NA
C$ Brief_I/O
C
C VARIABLE I/O DESCRIPTION
C -------- --- --------------------------------------------------
C NE I Number of elements to be removed.
C LOC I Location of the first removed element.
C ARRAY I/O Input/output array.
C NA I/O Number of elements in the input/output array.
C
C$ Detailed_Input
C
C NE is the number of elements to be removed.
C
C LOC is the location in the array at which the first
C element is to be removed.
C
C ARRAY on input, is the original array.
C
C NA on input, is the number of elements in ARRAY.
C
C$ Detailed_Output
C
C ARRAY on output, is the original array with elements
C LOC through LOC+NE-1 removed. Succeeding elements
C are moved forward to fill the vacated spaces.
C
C NA on output, is the number of elements in ARRAY.
C
C$ Parameters
C
C None.
C
C$ Particulars
C
C The elements in positions LOC through LOC+NE-1 are overwritten
C as the elements beginning at LOC+NE are moved back.
C
C$ Examples
C
C Let
C
C NA = 7 ARRAY(1) = 1
C ARRAY(2) = 2
C ARRAY(3) = 3
C ARRAY(4) = 4
C ARRAY(5) = 5
C ARRAY(6) = 6
C ARRAY(7) = 7
C
C Then the call
C
C CALL REMLAI ( 3, 3, ARRAY, NA )
C
C yields the following result:
C
C NA = 4 ARRAY(1) = 1
C ARRAY(2) = 2
C ARRAY(3) = 6
C ARRAY(4) = 7
C
C
C The following calls would signal errors:
C
C CALL REMLAI ( 3, 1, ARRAY, -1 )
C CALL REMLAI ( 3, -1, ARRAY, 7 )
C CALL REMLAI ( 3, 6, ARRAY, 7 )
C
C$ Restrictions
C
C None.
C
C$ Exceptions
C
C 1) If LOC is not in the interval [1, NA], the error
C SPICE(INVALIDINDEX) is signalled.
C
C 2) If the number of elements to be removed is greater than the
C number of elements that can be removed, the error
C SPICE(NONEXISTELEMENTS) is signalled.
C
C 3) If NE is less than one, the array is not modified.
C
C 4) If NA is less than one, any location is invalid, and the
C error SPICE(INVALIDINDEX) is signalled.
C
C$ Files
C
C None.
C
C$ Author_and_Institution
C
C H.A. Neilan (JPL)
C I.M. Underwood (JPL)
C
C$ Literature_References
C
C None.
C
C$ Version
C
C- SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
C
C Comment section for permuted index source lines was added
C following the header.
C
C- SPICELIB Version 1.0.0, 31-JAN-1990 (IMU)
C
C-&
C$ Index_Entries
C
C remove elements from an integer array
C
C-&
C$ Revisions
C
C- Beta Version 2.0.0, 1-JAN-1989 (HAN)
C
C Code was added to handle the following exceptinoal
C inputs.
C
C If the dimension of the array is less than one, any
C value of LOC is invalid. The old verison did not check
C the dimension of the array, and as a result, its output
C was unpredictable.
C
C If the location at which the elements are to be removed is
C not in the interval [1, NA], an error is signalled.
C Locations not within that interval refer to non-existent
C array elements. The old routine did not signal an error.
C It just returned the original array.
C
C If the number of elements to be removed is greater than the
C number of elements can be removed, an error is signalled.
C In the old version, only those elements that could be
C removed were removed, and no error was signalled.
C
C-&
C
C SPICELIB functions
C
LOGICAL RETURN
C
C Local variables
C
INTEGER I
C
C Standard SPICE error handling.
C
IF ( RETURN () ) THEN
RETURN
ELSE
CALL CHKIN ( 'REMLAI' )
END IF
C
C If LOC does not point to an actual element, signal an error and
C check out. If the dimension of the array is less than one, any
C value of LOC is invalid, and an error is signalled.
C
IF ( ( LOC .LT. 1 ) .OR. ( LOC .GT. NA ) ) THEN
CALL SETMSG ( 'Location was *.' )
CALL ERRINT ( '*', LOC )
CALL SIGERR ( 'SPICE(INVALIDINDEX)' )
CALL CHKOUT ( 'REMLAI' )
RETURN
C
C Don't try to remove non-existent elements.
C
ELSE IF ( NE .GT. NA-LOC+1 ) THEN
CALL SETMSG ( 'Trying to remove non-existent elements.' )
CALL SIGERR ( 'SPICE(NONEXISTELEMENTS)' )
CALL CHKOUT ( 'REMLAI' )
RETURN
C
C If there are elements to be removed, remove them. Otherwise,
C do not modify the array.
C
ELSE IF ( NE .GT. 0 ) THEN
C
C Move the elements forward.
C
DO I = LOC, NA - NE
ARRAY(I) = ARRAY(I+NE)
END DO
C
C Update the number of elements in the array.
C
NA = NA - NE
END IF
CALL CHKOUT ( 'REMLAI' )
RETURN
END
| source/nasa_f/remlai.f |
!..here is the tabular helmholtz free energy eos:
!..
!..routine helmeos computes the pressure, energy and entropy via tables
module helm
implicit none
contains
subroutine helmeos2(
> T, logT, Rho, logRho, Zfrac, Xfrac, abar_in, zbar_in, helm_res,
> clip_to_table_boundaries, ierr)
use dStar_eos_def
use const_def, only: pi
implicit none
double precision, intent(in) :: T, logT, Rho, logRho
double precision, intent(in) :: Zfrac, Xfrac, abar_in, zbar_in
double precision, intent(out) :: helm_res(num_helm_results)
logical, intent(in) :: clip_to_table_boundaries
integer, intent(out) :: ierr
logical :: skip_elec_pos
!double precision, parameter :: logRho1 = -10.0d0
!double precision, parameter :: logRho2 = -10.5d0
!double precision, parameter :: logT1 = 4.8d0
!double precision, parameter :: logT2 = 4.5d0
double precision, parameter :: logT1 = 5.0d0
double precision, parameter :: logT2 = 4.5d0
double precision, parameter :: logQ1 = 4d0
double precision, parameter :: logQ2 = 3d0
double precision, parameter :: logRho1 = logQ1 + 2*logT2 - 12
double precision, parameter :: logRho2 = logQ2 + 2*logT2 - 12
double precision :: dx, dy, dlogT2, dlogQ2, dist, alfa, beta, logQ, P, x
double precision, dimension(num_helm_results) :: helm_res_alfa, helm_res_beta
logical, parameter :: dbg = .false.
include 'formats.dek'
! alfa = 0 for with ele_pos,
! alfa = 1 for without ele_pos,
! otherwise, blend.
logQ = logRho - 2*logT + 12
if (logT >= logT1) then ! above transition
if (dbg) write(*,*) 'logT >= logT1'
alfa = 0 ! full on
else if (logT >= logT2) then ! in temperature transition region
if (dbg) then
write(*,*) 'logT >= logT2'
write(*,1) 'logRho1', logRho1
write(*,1) 'logRho2', logRho2
write(*,1) 'logRho', logRho
write(*,1) 'logQ', logQ
end if
if (logQ >= logQ1) then
alfa = 0 ! full on
else if (logQ < logQ2) then ! upper edge of region
alfa = (logT - logT1) / (logT2 - logT1)
else ! corner
dlogT2 = ((logT - logT2) / (logT1 - logT2))**2
dlogQ2 = (logQ - logQ2) / (logQ1 - logQ2)**2
dist = sqrt(dlogT2 + dlogQ2) ! dist from (Q2,T2) corner
alfa = max(0d0, 1d0 - dist)
end if
else ! logT < logT2
if (dbg) write(*,*) 'logT < logT2'
if (logRho >= logRho1) then
alfa = 0 ! full on
else if (logRho > logRho2) then
alfa = (logRho - logRho1) / (logRho2 - logRho1)
else
alfa = 1 ! full off
end if
end if
if (alfa > 0 .and. alfa < 1) alfa = 0.5d0*(1 - cos(pi*alfa))
beta = 1 - alfa
if (dbg) write(*,1) 'HELM elect-pos: alfa, beta', alfa, beta
if (beta > 0) then ! eval with ele_pos
skip_elec_pos = .false.
call helmeos2aux(
> T, logT, Rho, logRho, Zfrac, Xfrac, abar_in, zbar_in, helm_res_beta,
> clip_to_table_boundaries, skip_elec_pos, ierr)
if (ierr /= 0 .or. helm_res_beta(h_stot) <= 0) then
if (dbg) then
write(*,1) 'T', T
write(*,1) 'logT', logT
write(*,1) 'Rho', Rho
write(*,1) 'logRho', logRho
write(*,1) 'abar', abar_in
write(*,1) 'zbar', zbar_in
write(*,*) 'with ele pos'
write(*,*)
write(*,1) 'stot', helm_res_beta(h_stot)
write(*,1) 'sgas', helm_res_beta(h_sgas)
write(*,1) 'srad', helm_res_beta(h_srad)
write(*,1) 'sion', helm_res_beta(h_sion)
write(*,1) 'sele', helm_res_beta(h_sele)
write(*,1) 'scoul', helm_res_beta(h_scou)
write(*,*)
stop
end if
ierr = 0
alfa = 1
beta = 0
end if
end if
if (alfa > 0) then ! eval without ele_pos
skip_elec_pos = .true.
call helmeos2aux(
> T, logT, Rho, logRho, Zfrac, Xfrac, abar_in, zbar_in, helm_res_alfa,
> clip_to_table_boundaries, skip_elec_pos, ierr)
if (ierr /= 0) return
if (helm_res_alfa(h_stot) <= 0) then
ierr = -1
if (dbg) write(*,1) 'without ele_pos, helm_res_alfa(h_stot)', helm_res_alfa(h_stot)
return
end if
end if
if (alfa == 1) then
helm_res = helm_res_alfa
return
end if
if (beta == 1) then
helm_res = helm_res_beta
return
end if
helm_res = alfa*helm_res_alfa + beta*helm_res_beta
! redo the gammas, etc. to preserve consistency
P = helm_res(h_ptot)
if (dbg) then
write(*,1) 'lgP blend', log10(P)
write(*,1) 'lgP with', log10(helm_res_beta(h_ptot))
write(*,1) 'lgP skip', log10(helm_res_alfa(h_ptot))
write(*,*)
end if
helm_res(h_chit) = helm_res(h_dpt)*T/P
helm_res(h_chid) = helm_res(h_dpd)*rho/P
x = helm_res(h_dpt)/(helm_res(h_det)*rho)
helm_res(h_gam3) = 1d0 + x
helm_res(h_gam1) = helm_res(h_chit)*x + helm_res(h_chid)
helm_res(h_nabad) = x/helm_res(h_gam1)
helm_res(h_cp) = helm_res(h_cv)*helm_res(h_gam1)/helm_res(h_chid)
end subroutine helmeos2
subroutine helmeos2aux(
> temp_in, logtemp_in, den_in, logden_in, Zfrac, Xfrac, abar_in, zbar_in, helm_res,
> clip_to_table_boundaries, must_skip_elec_pos, ierr)
use dStar_eos_def
use const_def, asol=>crad
use utils_lib, only: is_bad_num
implicit none
double precision, intent(in) :: temp_in, logtemp_in, den_in, logden_in
double precision, intent(in) :: Zfrac, Xfrac, abar_in, zbar_in
double precision, intent(out) :: helm_res(num_helm_results)
logical, intent(in) :: clip_to_table_boundaries, must_skip_elec_pos
integer, intent(out) :: ierr
double precision :: Am, Zm, Yfrac, dabar_dlnY, dzbar_dlnY
double precision :: dabar_dlnY_X, dzbar_dlnY_X, dabar_dlnY_Z, dzbar_dlnY_Z
double precision :: h ! = planck_h
type (Helm_Table), pointer :: ht
!..declare local variables
include 'helm_declare_local_variables.dek'
!..given a temperature temp [K], density den [g/cm**3], and a composition
!..characterized by abar and zbar, this routine returns most of the other
!..thermodynamic quantities. of prime interest is the pressure [erg/cm**3],
!..specific thermal energy [erg/gr], the entropy [erg/g/K], along with
!..their derivatives with respect to temperature, density, abar, and zbar.
!..other quantites such the normalized chemical potential eta (plus its
!..derivatives), number density of electrons and positron pair (along
!..with their derivatives), adiabatic indices, specific heats, and
!..relativistically correct sound speed are also returned.
!..
!..this routine assumes planckian photons, an ideal gas of ions,
!..and an electron-positron gas with an arbitrary degree of relativity
!..and degeneracy. interpolation in a table of the helmholtz free energy
!..is used to return the electron-positron thermodynamic quantities.
!..all other derivatives are analytic.
!..
!..references: cox & giuli chapter 24 ; timmes & swesty apj 1999
!..this routine assumes a call to subroutine read_helm_table has
!..been performed prior to calling this routine.
!..declare
double precision abar, zbar, temp, logtemp, den, logden
logical skip_elec_pos
!..for the interpolations
integer iat, jat
double precision dth, dt2, dti, dt2i, dt3i, dd, dd2, ddi, dd2i, dd3i,
1 xt, xd, mxt, mxd, fi(36),
2 din, dindd, dinda, dindz, dindda, dinddz, dindaa,
3 dindaz, dindzz, dinddaa, dinddaz,
2 w0t, w1t, w2t, w0mt, w1mt, w2mt,
3 w0d, w1d, w2d, w0md, w1md, w2md,
4 dpepdd_in, dpepddd_in, dpepddt_in
double precision psi0, dpsi0, ddpsi0, dddpsi0,
1 psi1, dpsi1, ddpsi1, dddpsi1,
2 psi2, dpsi2, ddpsi2, dddpsi2,
3 h5
double precision xpsi0, xdpsi0, xddpsi0,
1 xpsi1, xdpsi1, xddpsi1, h3
double precision si0t, si1t, si2t, si0mt, si1mt, si2mt,
1 si0d, si1d, si2d, si0md, si1md, si2md,
2 dsi0t, dsi1t, dsi2t, dsi0mt, dsi1mt, dsi2mt,
3 dsi0d, dsi1d, dsi2d, dsi0md, dsi1md, dsi2md,
4 ddsi0t, ddsi1t, ddsi2t, ddsi0mt, ddsi1mt, ddsi2mt,
5 ddsi0d, ddsi1d, ddsi2d, ddsi0md, ddsi1md, ddsi2md,
6 dddsi0t, dddsi1t, dddsi2t,
7 dddsi0mt, dddsi1mt, dddsi2mt,
8 dddsi0d, dddsi1d, dddsi2d,
9 dddsi0md, dddsi1md, dddsi2md
double precision free, df_d, df_t, df_dd, df_tt, df_dt,
1 df_ttt, df_dtt, df_ddt, df_ddd
!..quintic hermite polynomial statement functions
!..psi0 and its derivatives
psi0(z) = z**3 * ( z * (-6.0d0*z + 15.0d0) - 10.0d0) + 1.0d0
dpsi0(z) = z**2 * ( z * (-30.0d0*z + 60.0d0) - 30.0d0)
ddpsi0(z) = z* ( z*( -120.0d0*z + 180.0d0) - 60.0d0)
dddpsi0(z) = z*( -360.0d0*z + 360.0d0) - 60.0d0
!..psi1 and its derivatives
psi1(z) = z* (z**2 * ( z * (-3.0d0*z + 8.0d0) - 6.0d0) + 1.0d0)
dpsi1(z) = z*z * ( z * (-15.0d0*z + 32.0d0) - 18.0d0) +1.0d0
ddpsi1(z) = z * (z * (-60.0d0*z + 96.0d0) -36.0d0)
dddpsi1(z) = z * (-180.0d0*z + 192.0d0) - 36.0d0
!..psi2 and its derivatives
psi2(z) = 0.5d0*z*z*( z* ( z * (-z + 3.0d0) - 3.0d0) + 1.0d0)
dpsi2(z) = 0.5d0*z*( z*(z*(-5.0d0*z + 12.0d0) - 9.0d0) + 2.0d0)
ddpsi2(z) = 0.5d0*(z*( z * (-20.0d0*z + 36.0d0) - 18.0d0) +2.0d0)
dddpsi2(z) = 0.5d0*(z * (-60.0d0*z + 72.0d0) - 18.0d0)
!..biquintic hermite polynomial statement function
h5(i, j, w0t, w1t, w2t, w0mt, w1mt, w2mt, w0d, w1d, w2d, w0md, w1md, w2md)=
1 fi(1) *w0d*w0t + fi(2) *w0md*w0t
2 + fi(3) *w0d*w0mt + fi(4) *w0md*w0mt
3 + fi(5) *w0d*w1t + fi(6) *w0md*w1t
4 + fi(7) *w0d*w1mt + fi(8) *w0md*w1mt
5 + fi(9) *w0d*w2t + fi(10) *w0md*w2t
6 + fi(11) *w0d*w2mt + fi(12) *w0md*w2mt
7 + fi(13) *w1d*w0t + fi(14) *w1md*w0t
8 + fi(15) *w1d*w0mt + fi(16) *w1md*w0mt
9 + fi(17) *w2d*w0t + fi(18) *w2md*w0t
& + fi(19) *w2d*w0mt + fi(20) *w2md*w0mt
1 + fi(21) *w1d*w1t + fi(22) *w1md*w1t
2 + fi(23) *w1d*w1mt + fi(24) *w1md*w1mt
3 + fi(25) *w2d*w1t + fi(26) *w2md*w1t
4 + fi(27) *w2d*w1mt + fi(28) *w2md*w1mt
5 + fi(29) *w1d*w2t + fi(30) *w1md*w2t
6 + fi(31) *w1d*w2mt + fi(32) *w1md*w2mt
7 + fi(33) *w2d*w2t + fi(34) *w2md*w2t
8 + fi(35) *w2d*w2mt + fi(36) *w2md*w2mt
!..cubic hermite polynomial statement functions
!..psi0 & derivatives
xpsi0(z) = z * z * (2.0d0*z - 3.0d0) + 1.0
xdpsi0(z) = z * (6.0d0*z - 6.0d0)
xddpsi0(z) = 12.0d0*z - 6.0d0
!..psi1 & derivatives
xpsi1(z) = z * ( z * (z - 2.0d0) + 1.0d0)
xdpsi1(z) = z * (3.0d0*z - 4.0d0) + 1.0d0
xddpsi1(z) = 6.0d0*z - 4.0d0
!..bicubic hermite polynomial statement function
h3(i, j, w0t, w1t, w0mt, w1mt, w0d, w1d, w0md, w1md) =
1 fi(1) *w0d*w0t + fi(2) *w0md*w0t
2 + fi(3) *w0d*w0mt + fi(4) *w0md*w0mt
3 + fi(5) *w0d*w1t + fi(6) *w0md*w1t
4 + fi(7) *w0d*w1mt + fi(8) *w0md*w1mt
5 + fi(9) *w1d*w0t + fi(10) *w1md*w0t
6 + fi(11) *w1d*w0mt + fi(12) *w1md*w0mt
7 + fi(13) *w1d*w1t + fi(14) *w1md*w1t
8 + fi(15) *w1d*w1mt + fi(16) *w1md*w1mt
!..end of statement function definitions
ht => eos_ht
h = planck_h
third = 1.0d0/3.0d0
sioncon = (2.0d0 * pi * amu * kerg)/(h*h)
sifac = 8.6322745944370191d-45
kergavo = kerg * avo
asoli3 = asol/3.0d0
clight2 = clight*clight
eostol = 1.0d-13
fpmin = 1.0d-14
!..note: sifac = h**3/(2.0d0*pi*amu)**1.5d0
forth = 4.0d0/3.0d0
fiveth = 5.0d0/3.0d0
teninth = 10.0d0/9.0d0
esqu = qe*qe
forthpi = forth * pi
ierr = 0
abar = abar_in
zbar = zbar_in
temp = temp_in
logtemp = logtemp_in
den = den_in
logden = logden_in
!..for very low T, convert all H to H2. adjust abar and zbar accordingly.
! NOTE: table lookup uses din rather than den
ytot1 = 1.0d0/abar
ye = ytot1 * zbar
din = ye*den
skip_elec_pos = must_skip_elec_pos
if (.not. skip_elec_pos) then ! see if need to set it true
if (temp < ht% templo) then
if (din > -5d0) then ! clip T so can keep elec_pos
temp = ht% templo
logtemp = log10(temp)
else
skip_elec_pos = .true.
end if
end if
if (din < ht% denlo) then
skip_elec_pos = .true.
end if
end if
if (temp > ht% temphi) then
temp = ht% temphi
logtemp = ht% logthi
end if
if (din > ht% denhi) then
din = ht% denhi
end if
if (skip_elec_pos) then
abar = 1d0 / (1/abar - Xfrac/2)
zbar = 1d-10 ! don't set it to 0
ytot1 = 1.0d0/abar
ye = ytot1 * zbar
end if
!..very neutron rich compositions may need to be bounded,
!..avoid that extrema for now in order to increase efficiency
c ye = max(1.0d-16, ye)
!..initialize local variables
include 'helm_initialize_local_variables.dek'
!..radiation section:
! include 'helm_radiation.dek'
!..ion section:
! include 'helm_ideal_ions.dek'
!..electron-positron section:
if (.not. skip_elec_pos) then
include 'helm_electron_positron.dek'
else ! drop the electron-positron section at very low T
pele = 0.0d0
dpeledd = 0.0d0
dpeledt = 0.0d0
dpeleda = 0.0d0
dpeledz = 0.0d0
eele = 0.0d0
deeledd = 0.0d0
deeledt = 0.0d0
deeleda = 0.0d0
deeledz = 0.0d0
sele = 0.0d0
dseledd = 0.0d0
dseledt = 0.0d0
dseleda = 0.0d0
dseledz = 0.0d0
ppos = 0.0d0
dpposdd = 0.0d0
dpposdt = 0.0d0
dpposda = 0.0d0
dpposdz = 0.0d0
epos = 0.0d0
deposdd = 0.0d0
deposdt = 0.0d0
deposda = 0.0d0
deposdz = 0.0d0
spos = 0.0d0
dsposdd = 0.0d0
dsposdt = 0.0d0
dsposda = 0.0d0
dsposdz = 0.0d0
etaele = -20d0
end if
!..coulomb section:
if ((ht% with_coulomb_corrections) .and. (.not. skip_elec_pos)) then
! include 'helm_coulomb2.dek'
else
pcoul = 0.0d0
dpcouldd = 0.0d0
dpcouldt = 0.0d0
dpcoulda = 0.0d0
dpcouldz = 0.0d0
ecoul = 0.0d0
decouldd = 0.0d0
decouldt = 0.0d0
decoulda = 0.0d0
decouldz = 0.0d0
scoul = 0.0d0
dscouldd = 0.0d0
dscouldt = 0.0d0
dscoulda = 0.0d0
dscouldz = 0.0d0
plasg = 0
end if
!..sum the gas and total (gas + radiation) components
include 'helm_sum_totals.dek'
!..compute the derivative quantities (cv, gamma1 ...etc)
! include 'helm_gammas.dek'
!..maxwell relations; each is zero if the consistency is perfect
!..if you don't need this, save three divides and comment this out
! x = den * den
! dse = temp*dentrdt/denerdt - 1.0d0
! dpe = (denerdd*x + temp*dpresdt)/pres - 1.0d0
! dsp = -dentrdd*x/dpresdt - 1.0d0
if (.false.) then
!write(*,'(a30,1pe26.16)') 'temp', temp
!write(*,'(a30,1pe26.16)') 'den', den
!write(*,'(a30,1pe26.16)') 'dentrdt', dentrdt
!write(*,'(a30,1pe26.16)') 'denerdt', denerdt
!write(*,'(a30,1pe26.16)') 'denerdd', denerdd
!write(*,'(a30,1pe26.16)') 'dpresdt', dpresdt
!write(*,'(a30,1pe26.16)') 'dentrdd', dentrdd
!write(*,'(a30,1pe26.16)') 'dsraddd', dsraddd
!write(*,'(a30,1pe26.16)') 'dsgasdd', dsgasdd
write(*,'(a30,1pe26.16)') 'dsiondd', dsiondd
write(*,'(a30,1pe26.16)') 'dsepdd', dsepdd
write(*,'(a30,1pe26.16)') 'dscouldd', dscouldd
write(*,'(a30,1pe26.16)') 'plasg', plasg
write(*,*) 'ht% with_coulomb_corrections', ht% with_coulomb_corrections
write(*,*) 'skip_elec_pos', skip_elec_pos
stop
end if
!..store results
include 'helm_store_results.dek'
helm_res(h_crp) = sion
!..debugging printout
if (.false.) then
include 'helm_print_results.dek'
end if
return
end subroutine helmeos2aux
end module
| dStar_eos/private/helm_core.f |
c
c
c ###################################################
c ## COPYRIGHT (C) 1991 by Jay William Ponder ##
c ## All Rights Reserved ##
c ###################################################
c
c ##############################################################
c ## ##
c ## subroutine kstrbnd -- assign stretch-bend parameters ##
c ## ##
c ##############################################################
c
c
c "kstrbnd" assigns parameters for stretch-bend interactions
c and processes new or changed parameter values
c
c
subroutine kstrbnd
implicit none
include 'sizes.i'
include 'angle.i'
include 'angpot.i'
include 'atmlst.i'
include 'atmtyp.i'
include 'atoms.i'
include 'couple.i'
include 'fields.i'
include 'inform.i'
include 'iounit.i'
include 'keys.i'
include 'kstbnd.i'
include 'potent.i'
include 'strbnd.i'
integer i,j,k,nsb
integer ia,ib,ic
integer ita,itb,itc
integer nba,nbc
integer size,next
real*8 sb1,sb2,temp
logical header
character*4 pa,pb,pc
character*12 blank,pt
character*20 keyword
character*120 record
character*120 string
c
c
c process keywords containing stretch-bend parameters
c
blank = ' '
header = .true.
do i = 1, nkey
next = 1
record = keyline(i)
call gettext (record,keyword,next)
call upcase (keyword)
if (keyword(1:7) .eq. 'STRBND ') then
ia = 0
ib = 0
ic = 0
sb1 = 0.0d0
sb2 = 0.0d0
string = record(next:120)
read (string,*,err=10,end=10) ia,ib,ic,sb1,sb2
10 continue
if (.not. silent) then
if (header) then
header = .false.
write (iout,20)
20 format (/,' Additional Stretch-Bend Parameters :',
& //,5x,'Atom Classes',6x,'K(SB)-1',5x,
& 'K(SB)-2',/)
end if
write (iout,30) ia,ib,ic,sb1,sb2
30 format (4x,3i4,2x,2f12.3)
end if
size = 4
call numeral (ia,pa,size)
call numeral (ib,pb,size)
call numeral (ic,pc,size)
if (ia .le. ic) then
pt = pa//pb//pc
else
pt = pc//pb//pa
temp = sb1
sb1 = sb2
sb2 = temp
end if
do j = 1, maxnsb
if (ksb(j).eq.blank .or. ksb(j).eq.pt) then
ksb(j) = pt
stbn(1,j) = sb1
stbn(2,j) = sb2
goto 50
end if
end do
write (iout,40)
40 format (/,' KSTRBND -- Too many Stretch-Bend',
& ' Interaction Parameters')
abort = .true.
50 continue
end if
end do
c
c determine the total number of forcefield parameters
c
nsb = maxnsb
do i = maxnsb, 1, -1
if (ksb(i) .eq. blank) nsb = i - 1
end do
c
c use special stretch-bend parameter assignment method for MMFF
c
if (forcefield .eq. 'MMFF94') then
call kstrbndm
return
end if
c
c assign the stretch-bend parameters for each angle
c
nstrbnd = 0
if (nsb .ne. 0) then
do i = 1, nangle
ia = iang(1,i)
ib = iang(2,i)
ic = iang(3,i)
ita = class(ia)
itb = class(ib)
itc = class(ic)
size = 4
call numeral (ita,pa,size)
call numeral (itb,pb,size)
call numeral (itc,pc,size)
if (ita .le. itc) then
pt = pa//pb//pc
else
pt = pc//pb//pa
end if
do j = 1, nsb
if (ksb(j) .eq. pt) then
nstrbnd = nstrbnd + 1
do k = 1, n12(ib)
if (i12(k,ib) .eq. ia) nba = bndlist(k,ib)
if (i12(k,ib) .eq. ic) nbc = bndlist(k,ib)
end do
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nba
isb(3,nstrbnd) = nbc
if (ita .le. itc) then
sbk(1,nstrbnd) = stbn(1,j)
sbk(2,nstrbnd) = stbn(2,j)
else
sbk(1,nstrbnd) = stbn(2,j)
sbk(2,nstrbnd) = stbn(1,j)
end if
goto 60
end if
end do
60 continue
end do
end if
c
c turn off the stretch-bend potential if it is not used
c
if (nstrbnd .eq. 0) use_strbnd = .false.
return
end
c
c
c ###############################################################
c ## ##
c ## subroutine kstrbndm -- assign MMFF str-bnd parameters ##
c ## ##
c ###############################################################
c
c
c "kstrbndm" assigns parameters for stretch-bend interactions
c according to the Merck Molecular Force Field (MMFF)
c
c Note: "stbnt" is the MMFF Stretch-Bend Type for angle "a-b-c",
c where atom "a" has a smaller class number than atom "c"
c
c if the BT of a-b = 1, then stbnt = 1
c if the BT of b-c = 1, then stbnt = 2
c if both = 1, then stbnt = 3
c if 4-membered ring, then stbnt = 4
c if 3-membered ring, then stbnt = 5
c if 3-membered ring with BT of a-b = 1, then stbnt = 6
c if 3-membered ring with BT of b-c = 1, then stbnt = 7
c if 3-membered ring with BT of both = 1, then stbnt = 8
c if 4-membered ring with BT of a-b = 1, then stbnt = 9
c if 4-membered ring with BT of b-c = 1, then stbnt = 10
c if 4-membered ring with BT of both = 1, then stbnt = 11
c else, if all BT = 0 and no small ring, then stbnt = 0
c
c literature references:
c
c T. A. Halgren, "Merck Molecular Force Field. I. Basis, Form,
c Scope, Parametrization, and Performance of MMFF94", Journal of
c Computational Chemistry, 17, 490-519 (1995)
c
c T. A. Halgren, "Merck Molecular Force Field. V. Extension of
c MMFF94 Using Experimental Data, Additional Computational Data,
c and Empirical Rules", Journal of Computational Chemistry, 17,
c 616-641 (1995)
c
c
subroutine kstrbndm
implicit none
include 'sizes.i'
include 'angle.i'
include 'atmlst.i'
include 'atmtyp.i'
include 'couple.i'
include 'merck.i'
include 'potent.i'
include 'ring.i'
include 'strbnd.i'
integer i,j,k,l,m
integer ia,ib,ic
integer ita,itb,itc
integer ina,inb,inc
integer ira,irb,irc
integer nb1,nb2
integer stbnt,ab,bc
logical ring3,ring4
c
c
c assign stretch-bend parameters for each angle
c
nstrbnd = 0
do i = 1, nangle
ia = iang(1,i)
ib = iang(2,i)
ic = iang(3,i)
c
c stretch-bend interactions are omitted for linear angles
c
if (lin(class(ib)) .eq. 0) then
ita = class (ia)
itb = class (ib)
itc = class (ic)
ina = atomic(ia)
inb = atomic(ib)
inc = atomic(ic)
sbk(1,nstrbnd+1) = 0.0d0
sbk(2,nstrbnd+1) = 0.0d0
do k = 1, n12(ib)
if (i12(k,ib) .eq. ia) nb1 = bndlist(k,ib)
if (i12(k,ib) .eq. ic) nb2 = bndlist(k,ib)
end do
stbnt = 0
ab = 0
bc = 0
c
c check if the atoms belong to a single 3- or 4-membered ring
c
ring3 = .false.
ring4 = .false.
do j = 1, nring3
do k = 1, 3
if (ia .eq. iring3(k,j)) then
do l = 1, 3
if (ib .eq. iring3(l,j)) then
do m = 1, 3
if (ic .eq. iring3(m,j))
& ring3 = .true.
end do
end if
end do
end if
end do
end do
if (.not. ring3) then
do j = 1, nring4
do k = 1, 4
if (ia .eq. iring4(k,j)) then
do l = 1, 4
if (ib .eq. iring4(l,j)) then
do m = 1, 4
if (ic .eq. iring4(m,j))
& ring4 = .true.
end do
end if
end do
end if
end do
end do
end if
c
c determine the MMFF stretch-bend type for the current angle
c
if (ita .lt. itc) then
do j = 1, nlignes
if (((ia.eq.bt_1(j,1).and.ib.eq.bt_1(j,2)) .or.
& (ib.eq.bt_1(j,1).and.ia.eq.bt_1(j,2)))) then
ab = 1
end if
if (((ic.eq.bt_1(j,1).and.ib.eq.bt_1(j,2)) .or.
& (ib.eq.bt_1(j,1).and.ic.eq.bt_1(j,2)))) then
bc = 1
end if
end do
if (ab.eq.1 .and. bc.eq.0) stbnt = 1
if (ab.eq.0 .and. bc.eq.1) stbnt = 2
if (ab.eq.1 .and. bc.eq.1) stbnt = 3
if (stbnt.eq.0 .AND. ring3) then
stbnt = 5
else if (stbnt.eq.1 .and. ring3) then
stbnt = 6
else if (stbnt.eq.2 .and. ring3) then
stbnt = 7
else if (stbnt.eq.3 .and. ring3) then
stbnt = 8
else if (stbnt.eq.0 .and. ring4) then
stbnt = 4
else if (stbnt.eq.1 .and. ring4) then
stbnt = 9
else if (stbnt.eq.2 .and. ring4) then
stbnt = 10
else if (stbnt.eq.3 .and. ring4) then
stbnt = 11
end if
else if (ita .gt. itc) then
do j = 1, nlignes
if (((ia.eq.bt_1(j,1).and.ib.eq.bt_1(j,2)) .or.
& (ib.eq.bt_1(j,1).and.ia.eq.bt_1(j,2)))) then
ab = 1
end if
if (((ic.eq.bt_1(j,1).and.ib.eq.bt_1(j,2)) .or.
& (ib.eq.bt_1(j,1).and.ic.eq.bt_1(j,2)))) then
bc = 1
end if
end do
if (ab.eq.1 .and. bc.eq.0) stbnt = 2
if (ab.eq.0 .and. bc.eq.1) stbnt = 1
if (ab.eq.1 .and. bc.eq.1) stbnt = 3
if (stbnt.eq.0 .and. ring3) then
stbnt = 5
else if (stbnt.eq.1 .and. ring3) then
stbnt = 6
else if (stbnt.eq.2 .and. ring3) then
stbnt = 7
else if (stbnt.eq.3 .and. ring3) then
stbnt = 8
else if (stbnt.eq.0 .and. ring4) then
stbnt = 4
else if (stbnt.eq.1 .and. ring4) then
stbnt = 9
else if (stbnt.eq.2 .and. ring4) then
stbnt = 10
else if (stbnt.eq.3 .and. ring4) then
stbnt = 11
end if
else if (ita .eq. itc) then
do j = 1, nlignes
if (((ic.eq.bt_1(j,1).and.ib.eq.bt_1(j,2)) .or.
& (ib.eq.bt_1(j,1).and.ic.eq.bt_1(j,2)))) then
bc = 1
end if
if (((ia.eq.bt_1(j,1).and.ib.eq.bt_1(j,2)) .or.
& (ib.eq.bt_1(j,1).and.ia.eq.bt_1(j,2)))) then
ab = 1
end if
end do
if (ab.eq.1 .and. bc.eq.0) stbnt = 1
if (ab.eq.0 .and. bc.eq.1) stbnt = 2
if (ab.eq.1 .and. bc.eq.1) stbnt = 3
if (stbnt.eq.0 .and. ring3) then
stbnt = 5
else if (stbnt.eq.1 .and. ring3) then
stbnt = 6
else if (stbnt.eq.2 .and. ring3) then
stbnt = 7
else if (stbnt.eq.3 .and. ring3) then
stbnt = 8
else if (stbnt.eq.0 .and. ring4) then
stbnt = 4
else if (stbnt.eq.1 .and. ring4) then
stbnt = 9
else if (stbnt.eq.2 .and. ring4) then
stbnt = 10
else if (stbnt.eq.3 .and. ring4) then
stbnt = 11
end if
end if
c
c find the periodic table row for the atoms in the angle
c
if (ina .eq. 1) ira = 0
if (ina.ge.3 .and. ina.le.10) ira = 1
if (ina.ge.11 .and. ina.le.18) ira = 2
if (ina.ge.19 .and. ina.le.36) ira = 3
if (ina.ge.37 .and. ina.le.54) ira = 4
if (inb .eq. 1) irb = 0
if (inb.ge.3 .and. inb.le.10) irb = 1
if (inb.ge.11 .and. inb.le.18) irb = 2
if (inb.ge.19 .and. inb.le.36) irb = 3
if (inb.ge.37 .and. inb.le.54) irb = 4
if (inc .eq. 1) irc = 0
if (inc.ge.3 .and. inc.le.10) irc = 1
if (inc.ge.11 .and. inc.le.18) irc = 2
if (inc.ge.19 .and. inc.le.36) irc = 3
if (inc.ge.37 .and. inc.le.54) irc = 4
c
c assign parameters via explicit values or empirical rules
c
if (stbnt .eq. 11) then
if ((stbn_abc11(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba11(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc11(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba11(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 10) then
if ((stbn_abc10(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba10(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc10(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba10(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 9) then
if ((stbn_abc9(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba9(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc9(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba9(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 8) then
if ((stbn_abc8(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba3(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc8(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba8(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 7) then
if ((stbn_abc7(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba7(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc7(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba7(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 6) then
if ((stbn_abc6(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba3(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc6(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba6(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 5) then
if (((stbn_abc5(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba3(ita,itb,itc).ne.1000.0d0))
& .or. (ita.eq.22.and.itb.eq.22.and.itc.eq.22)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc5(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba5(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 4) then
if ((stbn_abc4(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba4(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc4(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba4(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 3) then
if ((stbn_abc3(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba3(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc3(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba3(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 2) then
if ((stbn_abc2(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba2(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc2(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba2(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 1) then
if ((stbn_abc1(ita,itb,itc).ne.1000.0d0) .and.
& (stbn_cba1(ita,itb,itc).ne.1000.0d0)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc1(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba1(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
else if (stbnt .eq. 0) then
if (((stbn_abc(ita,itb,itc) .ne. 1000.0d0) .and.
& (stbn_cba(ita,itb,itc) .ne. 1000.0d0))
& .or. (ita.eq.12.AND.itb.eq.20.AND.itc.eq.20)
& .or. (ita.eq.20.AND.itb.eq.20.AND.itc.eq.12)) then
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = stbn_abc(ita,itb,itc)
sbk(2,nstrbnd) = stbn_cba(ita,itb,itc)
else
nstrbnd = nstrbnd + 1
isb(1,nstrbnd) = i
isb(2,nstrbnd) = nb1
isb(3,nstrbnd) = nb2
sbk(1,nstrbnd) = defstbn_abc(ira,irb,irc)
sbk(2,nstrbnd) = defstbn_cba(ira,irb,irc)
end if
end if
end if
end do
c
c turn off the stretch-bend potential if it is not used
c
if (nstrbnd .eq. 0) use_strbnd = .false.
return
end
| HCsbLib/HCsbLib/HTLib2.Bioinfo/External.Tinker/src/tinker-6.2.06/kstrbnd.f |
module pmmf_fic_case3
#include <messenger.h>
use mod_kinds, only: rk,ik
use mod_constants, only: ZERO, HALF, ONE, TWO, THREE, FOUR, FIVE, EIGHT, PI
use type_prescribed_mesh_motion_function, only: prescribed_mesh_motion_function_t
implicit none
private
!> Flow In Cylinder - case3 prescribed motion.
!!
!! @author Nathan A. Wukie
!! @date 10/02/2019
!!
!-------------------------------------------------------------------------------
type, extends(prescribed_mesh_motion_function_t), public :: fic_case3_pmmf
private
contains
procedure :: init
procedure :: compute_pos
procedure :: compute_vel
end type fic_case3_pmmf
!********************************************************************************
contains
!>
!!
!! @author Nathan A. Wukie
!! @date 10/02/2019
!!
!-------------------------------------------------------------------------
subroutine init(self)
class(fic_case3_pmmf), intent(inout) :: self
! Set function name
call self%set_name("Flow In Cylinder - Case3")
end subroutine init
!*************************************************************************
!>
!!
!! @author Nathan A. Wukie
!! @date 10/02/2019
!!
!!
!-----------------------------------------------------------------------------------------
function compute_pos(self,time,node) result(val)
class(fic_case3_pmmf), intent(inout) :: self
real(rk), intent(in) :: time
real(rk), intent(in) :: node(3)
real(rk) :: val(3)
real(rk) :: Aa, alpha, psi, x0, y0, r0, theta0, &
a, b, e, r, x_ale, y_ale
Aa = 1.5
alpha = time**TWO*(THREE-time)/FOUR
psi = ONE + (Aa - ONE)*alpha
! Get the reference frame nodeinates of the grid point
x0 = node(1)
y0 = node(2)
r0 = sqrt(x0*x0 + y0*y0)
theta0 = atan2(y0,x0)
a = psi * r0
b = r0 / psi
e = sqrt(ONE - psi**(-FOUR))
r = b/(sqrt(ONE - (e*cos(theta0))**TWO))
x_ale = r*cos(theta0)
y_ale = r*sin(theta0)
val(1) = x_ale
val(2) = y_ale
val(3) = node(3)
end function compute_pos
!**********************************************************************************
!>
!!
!! @author Nathan A. Wukie
!! @date 10/02/2019
!!
!!
!-----------------------------------------------------------------------------------------
function compute_vel(self,time,node) result(val)
class(fic_case3_pmmf), intent(inout) :: self
real(rk), intent(in) :: time
real(rk), intent(in) :: node(3)
real(rk) :: val(3)
real(rk) :: Aa, alpha, psi, x0, y0, r0, theta0, &
a, b, e, r, dalphadt, dpsidt, h, dhdt, drdt, &
vr, vx_ale, vy_ale, f, dedt, dbdt, dfdt
Aa = 1.5
alpha = time**TWO*(THREE-time)/FOUR
psi = ONE + (Aa - ONE)*alpha
! Get the reference frame nodeinates of the grid point
x0 = node(1)
y0 = node(2)
r0 = sqrt(x0*x0 + y0*y0)
theta0 = atan2(y0,x0)
! Location
a = psi * r0
b = r0 / psi
e = sqrt(ONE - psi**(-FOUR))
r = b/(sqrt(ONE - (e*cos(theta0))**TWO))
f = sqrt(ONE - e*e*cos(theta0)*cos(theta0))
! Velocity
dalphadt = TWO*time*(THREE-time)/FOUR - (time**TWO)/FOUR
dpsidt = (Aa - ONE)*dalphadt
dedt = TWO*dpsidt/((psi**5._rk)*sqrt(ONE - psi**(-FOUR)))
dfdt = - cos(theta0)**TWO * e * dedt / (sqrt(ONE - e*e*cos(theta0)*cos(theta0)))
dbdt = -r0*dpsidt/(psi*psi)
drdt = (dbdt*f - b*dfdt)/(f*f)
! h = sqrt( (psi**FOUR)*(sin(theta0)**TWO) + cos(theta0)**TWO)
! dhdt = TWO*psi*psi*psi*dpsidt/h
! drdt = (r0*dpsidt*h - r0*psi*dhdt)/(h*h)
vr = drdt
! Convert to cartesian: assumes theta is not a function of (t)
vx_ale = vr*cos(theta0)
vy_ale = vr*sin(theta0)
! print*, sign(1._rk,vr), sign(1._rk,r - r0), vx_ale, vy_ale
val(1) = vx_ale
val(2) = vy_ale
val(3) = ZERO
end function compute_vel
!**********************************************************************************
end module pmmf_fic_case3
| src/mesh_motion/prescribed_mesh_motion/flow_in_cylinder/pmmf_fic_case3.f90 |
subroutine recycle(t)
! *********************
use constante, only: k_oxyd, KO2
implicit none
include 'combine_foam.inc'
ranoxyd = 0
! Surface basins (O2 in equilibrium with atmosphere)
do j0=1,nsurface
j = jbox_surface(j0)
roxyd(j) = 0
enddo
! Deep and intermediate basins
do j0=1,nnosurface-1
j = jbox_nosurface(j0)
roxyd(j) = k_oxyd*(1 - dexp(-var(11,j)/KO2))
end do
! Atmosphere
roxyd(nbasin) = 0
return
end
| source/recycle.f |
MODULE obs_rot_vel
USE par_kind
USE par_oce
USE in_out_manager
USE dom_oce
USE obs_grid
USE obs_utils
USE obs_profiles_def
USE obs_inter_h2d
USE obs_inter_sup
USE geo2ocean
USE obs_fbm
IMPLICIT NONE
PRIVATE
PUBLIC :: obs_rotvel
CONTAINS
SUBROUTINE obs_rotvel(profdata, k2dint, pu, pv)
TYPE(obs_prof), INTENT(INOUT) :: profdata
INTEGER, INTENT(IN) :: k2dint
REAL(KIND = wp), DIMENSION(*) :: pu, pv
REAL(KIND = wp), DIMENSION(2, 2, 1) :: zweig
REAL(KIND = wp), DIMENSION(:, :, :), ALLOCATABLE :: zmasku, zmaskv, zcoslu, zsinlu, zcoslv, zsinlv, zglamu, zgphiu, zglamv, zgphiv
REAL(KIND = wp), DIMENSION(1) :: zsinu, zcosu, zsinv, zcosv
REAL(KIND = wp) :: zsin
REAL(KIND = wp) :: zcos
REAL(KIND = wp), DIMENSION(1) :: zobsmask
REAL(KIND = wp), DIMENSION(jpi, jpj) :: zsingu, zcosgu, zsingv, zcosgv
INTEGER, DIMENSION(:, :, :), ALLOCATABLE :: igrdiu, igrdju, igrdiv, igrdjv
INTEGER :: ji
INTEGER :: jk
ALLOCATE(igrdiu(2, 2, profdata % nprof), igrdju(2, 2, profdata % nprof), zglamu(2, 2, profdata % nprof), zgphiu(2, 2, profdata % nprof), zmasku(2, 2, profdata % nprof), zcoslu(2, 2, profdata % nprof), zsinlu(2, 2, profdata % nprof), igrdiv(2, 2, profdata % nprof), igrdjv(2, 2, profdata % nprof), zglamv(2, 2, profdata % nprof), zgphiv(2, 2, profdata % nprof), zmaskv(2, 2, profdata % nprof), zcoslv(2, 2, profdata % nprof), zsinlv(2, 2, profdata % nprof))
CALL obs_rot(zsingu, zcosgu, zsingv, zcosgv)
DO ji = 1, profdata % nprof
igrdiu(1, 1, ji) = profdata % mi(ji, 1) - 1
igrdju(1, 1, ji) = profdata % mj(ji, 1) - 1
igrdiu(1, 2, ji) = profdata % mi(ji, 1) - 1
igrdju(1, 2, ji) = profdata % mj(ji, 1)
igrdiu(2, 1, ji) = profdata % mi(ji, 1)
igrdju(2, 1, ji) = profdata % mj(ji, 1) - 1
igrdiu(2, 2, ji) = profdata % mi(ji, 1)
igrdju(2, 2, ji) = profdata % mj(ji, 1)
igrdiv(1, 1, ji) = profdata % mi(ji, 2) - 1
igrdjv(1, 1, ji) = profdata % mj(ji, 2) - 1
igrdiv(1, 2, ji) = profdata % mi(ji, 2) - 1
igrdjv(1, 2, ji) = profdata % mj(ji, 2)
igrdiv(2, 1, ji) = profdata % mi(ji, 2)
igrdjv(2, 1, ji) = profdata % mj(ji, 2) - 1
igrdiv(2, 2, ji) = profdata % mi(ji, 2)
igrdjv(2, 2, ji) = profdata % mj(ji, 2)
END DO
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiu, igrdju, glamu, zglamu)
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiu, igrdju, gphiu, zgphiu)
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiu, igrdju, umask(:, :, 1), zmasku)
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiu, igrdju, zsingu, zsinlu)
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiu, igrdju, zcosgu, zcoslu)
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiv, igrdjv, glamv, zglamv)
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiv, igrdjv, gphiv, zgphiv)
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiv, igrdjv, vmask(:, :, 1), zmaskv)
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiv, igrdjv, zsingv, zsinlv)
CALL obs_int_comm_2d(2, 2, profdata % nprof, jpi, jpj, igrdiv, igrdjv, zcosgv, zcoslv)
DO ji = 1, profdata % nprof
CALL obs_int_h2d_init(1, 1, k2dint, profdata % rlam(ji), profdata % rphi(ji), zglamu(:, :, ji), zgphiu(:, :, ji), zmasku(:, :, ji), zweig, zobsmask)
CALL obs_int_h2d(1, 1, zweig, zsinlu(:, :, ji), zsinu)
CALL obs_int_h2d(1, 1, zweig, zcoslu(:, :, ji), zcosu)
CALL obs_int_h2d_init(1, 1, k2dint, profdata % rlam(ji), profdata % rphi(ji), zglamv(:, :, ji), zgphiv(:, :, ji), zmaskv(:, :, ji), zweig, zobsmask)
CALL obs_int_h2d(1, 1, zweig, zsinlv(:, :, ji), zsinv)
CALL obs_int_h2d(1, 1, zweig, zcoslv(:, :, ji), zcosv)
zcos = 0.5_wp * (zcosu(1) + zcosv(1))
zsin = 0.5_wp * (zsinu(1) + zsinv(1))
IF ((profdata % npvsta(ji, 1) /= profdata % npvsta(ji, 2)) .OR. (profdata % npvend(ji, 1) /= profdata % npvend(ji, 2))) THEN
CALL fatal_error('Different number of U and V observations ' // 'in a profile in obs_rotvel', 190)
END IF
DO jk = profdata % npvsta(ji, 1), profdata % npvend(ji, 1)
IF ((profdata % var(1) % vmod(jk) /= fbrmdi) .AND. (profdata % var(2) % vmod(jk) /= fbrmdi)) THEN
pu(jk) = profdata % var(1) % vmod(jk) * zcos - profdata % var(2) % vmod(jk) * zsin
pv(jk) = profdata % var(2) % vmod(jk) * zcos + profdata % var(1) % vmod(jk) * zsin
ELSE
pu(jk) = fbrmdi
pv(jk) = fbrmdi
END IF
END DO
END DO
DEALLOCATE(igrdiu, igrdju, zglamu, zgphiu, zmasku, zcoslu, zsinlu, igrdiv, igrdjv, zglamv, zgphiv, zmaskv, zcoslv, zsinlv)
END SUBROUTINE obs_rotvel
END MODULE obs_rot_vel | obs_rot_vel.f90 |
! This program reads from the netcdf file
! containing six integers written by
! the ncdf_write.f90 program.
PROGRAM read
USE, intrinsic :: iso_c_binding
USE module_netcdf
integer(C_INT), parameter :: nx = 3, ny = 6 ! Dimensions
character(len=20, kind=c_char), target :: FILE_NAME = "simple_write.nc" //C_NULL_CHAR
! Name of the variable to read.
character(len=10, kind=c_char), target :: data_name = "data" //C_NULL_CHAR
! Identification number and variable identifer
integer(C_INT), target :: ncid, varid
! Function return value
integer(C_INT) error
! Array into which to read data
integer(C_INT), target :: data_in(nx, ny)
! Loop indexes
integer :: index1, index2
! Open the netcdf file
error = nc_open(C_LOC(FILE_NAME), NC_NOWRITE, C_LOC(ncid))
! Report any errors
! Get the identifiers from the data name.
error = nc_inq_varid(ncid, C_LOC(data_name), C_LOC(data_in))
! Get the data from the file.
error = nc_get_var_int(ncid, varid, C_LOC(data_in))
! Loop through and print the information
do index1 = 1, nx
do index2 = 1, ny
WRITE(*,*) data_in(index1, index2)
end do
end do
! Close the netcdf file.
error = nc_close(ncid)
end program nc_read
| Example/Example_5/ncdf_read.f90 |
! How to remove ^M in source code on linux %s/^M//g (^M = Ctrl+v+m)
! Note on subroutine random_number
! Returns a single pseudorandom number or an array of pseudorandom numbers from the uniform distribution over the range [0, 1).
! The runtime-library implements the xorshift1024* random number generator(RNG). This generator has a period of 2^{1024} - 1,
! and when using multiple threads up to 2^{512} threads can each generate 2^{512} random numbers before any aliasing occurs.
module parameters
integer, parameter :: latt_leng = 80
integer, parameter :: EXCH_CONST = 1 ! exchange constant
integer, dimension(-1 : latt_leng, -1 : latt_leng) :: spin_of ! (-1 ... latt_leng) X (-1 ... latt_leng)
double precision, dimension(-2 : 2) :: accept_prob_chart
end module
program Ising_Model
use parameters
implicit none ! Require all variables to be explicitly declared
integer(kind=8), parameter :: MC_max = 1E7 * latt_leng**2
double precision, parameter :: T = 2.269d0 ! Unit = kT/J, Tc computed with each of the physical observables
call create_lattice_random
if(EXCH_CONST == -1) then ! Anti-ferromagnetic, EXCH_CONST = -1
accept_prob_chart = (/ exp(-8d0 / T), exp(-4d0 / T), &
1d0, exp(4d0 / T), exp(8d0 / T) /) ! Acceptance probability chart
else ! Ferromagnetic, EXCH_CONST = 1
accept_prob_chart = (/ exp(8d0 / T), exp(4d0 / T), &
1d0, exp(-4d0 / T), exp(-8d0 / T) /)
end if
call flip_sites_metropolis(MC_max) ! Iterate MC simulation MC_max times per temperature
end program
subroutine create_lattice_random
use parameters
integer :: x, y
double precision :: u
do x = 0, latt_leng - 1
do y = 0, latt_leng - 1
call random_number(u) ! Return random real number in [0,1)
if (u >= 0.5) then
spin_of(x, y) = 1 ! Assign random spin values
else
spin_of(x, y) = -1
end if
end do
end do
do x = 0, latt_leng - 1 ! Assign spins to top and bottom line of padding sites to make it periodic
spin_of(x, -1) = spin_of(x, latt_leng - 1)
spin_of(x, latt_leng) = spin_of(x, 0)
end do
do y = 0, latt_leng -1 ! Assign spins to left and right line of padding sites to make it periodic
spin_of(-1, y) = spin_of(latt_leng - 1, y)
spin_of(latt_leng, y) = spin_of(0, y)
end do
end subroutine
subroutine create_lattice_aligned
use parameters
integer :: x, y
do x = 0, latt_leng - 1 ! Assign spins on each site
do y = 0, latt_leng - 1
spin_of(x, y) = 1 ! All up spins
end do
end do
do x = 0, latt_leng - 1 ! Assign spins to top and bottom line of padding sites to make it periodic
spin_of(x, -1) = spin_of(x, latt_leng - 1)
spin_of(x, latt_leng) = spin_of(x, 0)
end do
do y = 0, latt_leng -1 ! Assign spins to left and right line of padding sites to make it periodic
spin_of(-1, y) = spin_of(latt_leng - 1, y)
spin_of(latt_leng, y) = spin_of(0, y)
end do
end subroutine
subroutine flip_sites_metropolis(MC_max)
use parameters
integer :: first_open = 1
integer :: x, y, sum_spin_nbr, sum_nbr_spin
integer :: out_unit1 = 10, out_unit2 = 20 !,out_unit3 = 30
integer(kind=8), intent(in) :: MC_max
integer(kind=8) :: MC_step
double precision :: accept_prob, tot_en, tot_mag, tot_en2, tot_E, tot_M, tot_E2
double precision :: u, v, r
n_sample = 0 ! Initialize variable to be used in averaging samples
sum_tot_E = 0d0
sum_tot_M = 0d0
sum_tot_E2 = 0d0
call compute_tot_E_M_E2(tot_en, tot_mag, tot_en2) ! Compute initial values of physical observables
tot_E = tot_en
tot_M = tot_mag
tot_E2 = tot_en2
do MC_step = 0, MC_max
call random_number(u) ! Return random real number in [0,1)
call random_number(v)
x = FLOOR(u * latt_leng) ! Pick random site, [0, latt_leng - 1]
y = FLOOR(v * latt_leng)
sum_nbr_spin = spin_of(x - 1, y) + spin_of(x + 1, y) + spin_of(x, y + 1) + spin_of(x, y - 1)
accept_prob = accept_prob_chart((spin_of(x, y) * sum_nbr_spin)/2) ! Sigma(SS) = spin_of(x, y) * sum_surrounding = -4, -2 , 0, 2, 4
call random_number(r) ![0, 1)
if (r < accept_prob) then
spin_of(x, y) = - spin_of(x, y) ! If random number < accept_prob => flip site
if (x == 0) then ! Update padding sites
spin_of(latt_leng, y) = spin_of(x, y)
else if (x == latt_leng - 1) then
spin_of(-1, y) = spin_of(x, y)
end if
if (y == 0) then
spin_of(x, latt_leng) = spin_of(x, y)
else if (y == latt_leng - 1) then
spin_of(x, -1) = spin_of(x, y)
end if
tot_M = tot_M + 2*spin_of(x, y) ! Update physical observables
sum_spin_nbr = spin_of(x + 1, y) + spin_of(x - 1, y) + spin_of(x, y + 1) + spin_of(x, y - 1)
tot_E = tot_E + (- EXCH_CONST) * spin_of(x, y) * sum_spin_nbr
tot_E2 = tot_E**2
end if
if (MOD(MC_step, latt_leng**2) == 0) then
if(first_open == 1) then
open (out_unit1, FILE = 'output_ising_model_fixed_T_E_change_plot.txt', action = "write", status = 'replace')
write (out_unit1,*) MC_step / latt_leng**2 , " ", tot_E
close(out_unit1)
open (out_unit2, FILE = 'output_ising_model_fixed_T_M_change_plot.txt', action = "write", status = 'replace')
write (out_unit2,*) MC_step / latt_leng**2, " ", tot_M
close(out_unit2)
first_open = -1
else
open (out_unit1, FILE = 'output_ising_model_fixed_T_E_change_plot.txt', action = "write", position = 'append')
write (out_unit1,*) MC_step / latt_leng**2, " ", tot_E
close(out_unit1)
open (out_unit2, FILE = 'output_ising_model_fixed_T_M_change_plot.txt', action = "write", position = 'append')
write (out_unit2,*) MC_step / latt_leng**2, " ", tot_M
close(out_unit2)
end if
end if
end do
end subroutine
subroutine compute_tot_E_M_E2(tot_E, tot_M, tot_E2)
use parameters
integer :: x, y, sum_spin_nbr
double precision, intent(out) :: tot_E, tot_M, tot_E2
tot_E = 0d0
tot_M = 0d0
tot_E2 = 0d0
do x = 0, latt_leng - 1
do y = 0, latt_leng - 1
tot_M = tot_M + spin_of(x, y)
sum_spin_nbr = spin_of(x + 1, y) + spin_of(x - 1, y) + spin_of(x, y + 1) + spin_of(x, y - 1)
tot_E = tot_E + (- EXCH_CONST) * spin_of(x, y) * sum_spin_nbr
end do
end do
tot_E = tot_E / 2
tot_E2 = tot_E**2
end subroutine
| src-fortran/mag_change_fixed_temp.f95 |
subroutine pot(symb,x,y,z,v,dvdx,dvdy,dvdz,natom,maxatom)
implicit real*8(a-h,o-z)
dimension x(maxatom),y(maxatom),z(maxatom)
dimension x2(maxatom),y2(maxatom),z2(maxatom)
dimension x3(maxatom),y3(maxatom),z3(maxatom)
dimension dvdx(maxatom),dvdy(maxatom),dvdz(maxatom)
dimension dvdx2(maxatom),dvdy2(maxatom),dvdz2(maxatom)
dimension dvdx3(maxatom),dvdy3(maxatom),dvdz3(maxatom)
parameter(autoev=27.2113961d0)
parameter(autocmi=219474.63067d0)
parameter(autoang=0.529177249d0)
character*2 symb(maxatom),symb2(maxatom),symb3(maxatom)
integer at(maxatom),at2(maxatom),at3(maxatom)
dimension tmpprint(50)
common/tmp/tmpprint
v=0.d0
v2=0.d0
v3=0.d0
do i=1,natom
symb2(i)="xx"
symb3(i)="xx"
x2(i)=0.d0
y2(i)=0.d0
z2(i)=0.d0
x3(i)=0.d0
y3(i)=0.d0
z3(i)=0.d0
dvdz2(i)=0.d0
dvdy2(i)=0.d0
dvdx2(i)=0.d0
dvdz3(i)=0.d0
dvdy3(i)=0.d0
dvdx3(i)=0.d0
dvdz(i)=0.d0
dvdy(i)=0.d0
dvdx(i)=0.d0
enddo
do i=1,natom
at(i)=0
if ((symb(i).eq."H").or.
& (symb(i).eq."h")) at(i)=1 ! hydrogen
if ((symb(i).eq."C").or.
& (symb(i).eq."c")) at(i)=2 ! carbon
if ((symb(i).eq."O").or.
& (symb(i).eq."o")) at(i)=4 ! oxygen
if ((symb(i).eq."HO").or.
& (symb(i).eq."Ho")) at(i)=5 ! OH H
if ((symb(i).eq."Oh").or.
& (symb(i).eq."oh")) at(i)=6 ! R-O-O*-H ; *this one
if ((symb(i).eq."He").or.
& (symb(i).eq."he").or.
& (symb(i).eq."HE")) at(i)=21 ! helium
if ((symb(i).eq."Ar").or.
& (symb(i).eq."ar").or.
& (symb(i).eq."AR")) at(i)=23 ! argon
if (at(i).eq.0) then ! atom not found
write(6,*)"Atom # ",i," (",symb(i),") not found"
stop
endif
enddo
natom2=0
natom3=0
do i=1,natom
if (at(i).le.20) then ! collect target atoms
natom2=natom2+1
x2(natom2)=x(i)
y2(natom2)=y(i)
z2(natom2)=z(i)
symb2(natom2)=symb(i)
at2(natom2)=at(i)
else ! collect bath atoms
natom3=natom3+1
x3(natom3)=x(i)
y3(natom3)=y(i)
z3(natom3)=z(i)
symb3(natom3)=symb(i)
at3(natom3)=at(i)
endif
enddo
c print *,natom,natom2,natom3
c if (natom3.ne.0)
c & call bath(at3,x3,y3,z3,v3,dvdx3,dvdy3,dvdz3,natom3,maxatom)
c if (natom2.ne.0)
c & call tinkerpot(symb2,x2,y2,z2,v2,dvdx2,dvdy2,dvdz2,
c & natom2,maxatom)
if (natom3.ne.0)
& call rgexp(at,x,y,z,v,dvdx,dvdy,dvdz,natom,maxatom)
tmpprint(1)=v ! interaction
v=v+v2+v3
natom2=0
natom3=0
do i=1,natom
if (at(i).le.20) then
natom2=natom2+1
c print *,i,dvdx2(i),dvdy2(i),dvdz2(i)
dvdx(i)=dvdx(i)+dvdx2(natom2)
dvdy(i)=dvdy(i)+dvdy2(natom2)
dvdz(i)=dvdz(i)+dvdz2(natom2)
else
natom3=natom3+1
dvdx(i)=dvdx(i)+dvdx3(natom3)
dvdy(i)=dvdy(i)+dvdy3(natom3)
dvdz(i)=dvdz(i)+dvdz3(natom3)
endif
enddo
return
end
subroutine bath(at,x,y,z,v,dvdx,dvdy,dvdz,natom,maxatom)
implicit real*8(a-h,o-z)
parameter(autoev=27.2113961d0)
parameter(autocmi=219474.63067d0)
dimension x(maxatom),y(maxatom),z(maxatom)
dimension dvdx(maxatom),dvdy(maxatom),dvdz(maxatom)
integer at(maxatom)
v=0.
do i=1,natom
dvdx(i)=0.d0
dvdy(i)=0.d0
dvdz(i)=0.d0
enddo
if (natom.eq.1) return
if (natom.gt.2) then
print *,"Can't handle more than 2 bath atoms"
stop
endif
if (natom.eq.2) then
dx=x(1)-x(2)
dy=y(1)-y(2)
dz=z(1)-z(2)
rr=dsqrt(dx*dx+dy*dy+dz*dz) ! au
if (at(1).eq.25.and.at(2).eq.25) then
! H2 bath
! From Hack's fit (eq 8 in Hack, Truhlar, JCP 110, 4315 (1999))
! to Kolos and Wolniewicz JCP 43, 2429 (1965)
! Rmin = 1.40121 au, Vmin = -4.74772265 eV relative to H+H
c1=139.7160d0 ! eV
c2=-123.8978d0 ! eV / bohr
c3=3.4031d0 ! 1 / bohr
c4=-6.8725d0 ! eV / bohr**2
c5=-23.0440d0 ! eV / bohr**3
c6=2.032d0 ! 1 / bohr
v=(c1+c2*rr)*dexp(-c3*rr)
& +(c4+c5*rr)*dexp(-c6*rr)*rr**2
c move zero from asymptote to minimum
v=v+4.74772265
c print *,rr,v
v=v/autoev
dvdr=((c1+c2*rr)*(-c3)+c2)*dexp(-c3*rr)
& +((c4+c5*rr)*(-c6)+c5)*dexp(-c6*rr)*rr**2
& +(c4+c5*rr)*dexp(-c6*rr)*rr*2.d0
dvdr=dvdr/autoev
elseif (at(1).eq.26.and.at(2).eq.26) then
! N2 bath
! fit to MRCI+Q/CBS(AQZ,A5Z) full valence
! agrees reasonably well with more complicated form of LeRoy (JCP 125, 164310 (2006))
! Jasper June 9, 2010
de=79845.d0 ! exp De in cm-1 (Ronin, Luanay, Larzillier, PRL 53, 159 (1984), as quoted by LeRoy)
re=1.097679d0 ! exp
c1=2.68872341 ! my fit
c2=0.240070803
c3=0.472261727
yy=rr*autoang-re
beta = c1+c2*yy+c3*yy**2
v = de*(1.d0-dexp(-beta*yy))**2-de ! A and cm-1
v=v/autocmi ! convert to au
dvdr = 2.d0*de*(1.d0-dexp(-beta*yy))*dexp(-beta*yy)*beta
dvdr=dvdr*autocmi/autocmi ! convert to au
! elseif (at(1).eq.??.and.at(2).eq.??) then
! OTHER DIATOMIC BATHS HERE
else
print *,"Don't know this diatomic bath"
stop
endif
dvdx(1) = dvdr*dx/rr
dvdx(2) = -dvdr*dx/rr
dvdy(1) = dvdr*dy/rr
dvdy(2) = -dvdr*dy/rr
dvdz(1) = dvdr*dz/rr
dvdz(2) = -dvdr*dz/rr
endif
return
end
subroutine rgexp(at,x,y,z,v,dvdx,dvdy,dvdz,natom,maxatom)
c Rare Gas exp6 potential subroutine
c loops over geometry and looks for Rg-X interactions
c returns the full Rg-target intermolecular potential and its derivatives
implicit real*8(a-h,o-z)
dimension x(maxatom),y(maxatom),z(maxatom)
dimension dvdx(maxatom),dvdy(maxatom),dvdz(maxatom)
parameter(autoev=27.2113961d0)
parameter(autocmi=219474.63067d0)
parameter(autokcal=627.509d0)
parameter(autoang=0.529177249d0)
integer at(maxatom)
logical troya,cutoff
v1=0.d0
v=0.d0
do i=1,natom
dvdz(i)=0.d0
dvdy(i)=0.d0
dvdx(i)=0.d0
enddo
do 1 i=1,natom
do 2 j=i+1,natom
m1=min(at(i),at(j))
m2=max(at(i),at(j))
troya=.false. ! do or don't use Troya's form
cutoff=.false. ! do or don't use cutoff
if (m1.ge.21) then ! two rare gases, skip this pair
go to 2
endif
if (m2.le.20) then ! no rare gas, skip this pair
go to 2
endif
if (m2.eq.21) then ! He-
if (m1.eq.1) then ! H
aa = 6.1097750785851623
bb = 0.24355296487319558
cc = 0.57130649739066741
rrc = 4.9487899410992764
cutoff=.true.
aa=(10.d0**aa)
elseif (m1.eq.2) then ! C
aa = 7.7760856959746087
bb = 0.18836634418774989
cc = 6.9083529160435804
rrc = 3.2519913327433088
cutoff=.true.
aa=(10.d0**aa)
elseif (m1.eq.4) then ! O
aa = 6.9354838709677420
bb = 0.23257240516373182
cc = 5.4971160008545183
rrc = 3.2503433332316050
cutoff=.true.
aa=(10.d0**aa)
elseif (m1.eq.5) then ! Ho
aa= 6.5426496169927058
bb = 0.21896114993743707
cc = 2.6139103366191594
rrc = 19.737327188940093
cutoff=.true.
aa=(10.d0**aa)
elseif (m1.eq.6) then ! Oh
aa = 6.9999389629810480
bb = 0.23460798974578081
cc = 6.2474440748313853
rrc = 3.3750724814600055
cutoff=.true.
aa=(10.d0**aa)
else
write(6,*)"Cant find a He-? interaction"
stop
endif
elseif (m2.eq.23) then ! Ar-
if (m1.eq.1) then ! H
aa= 6.4882045960875274
bb= 0.28126468703268531
cc= 7.3052156132694481
rrc= 3.3750724814600055
aa=(10.d0**aa)
cutoff=.true.
elseif (m1.eq.2) then ! C
aa= 9.0000000000000000
bb= 0.19531235694448684
cc= 7.7499313333536790
rrc= 3.2500686666463210
aa=(10.d0**aa)
cutoff=.true.
elseif (m1.eq.4) then ! O
aa= 8.4999847407452620
bb= 0.21405987731559192
cc= 8.0056459242530593
rrc= 3.2506179998168889
aa=(10.d0**aa)
cutoff=.true.
elseif (m1.eq.5) then ! Ho
aa= 6.4882045960875274
bb= 0.28126468703268531
cc= 7.3052156132694481
rrc= 3.3750724814600055
cutoff=.true.
aa=(10.d0**aa)
elseif (m1.eq.6) then ! Oh
aa= 8.4999847407452620
bb= 0.21405987731559192
cc= 8.0056459242530593
rrc= 3.2506179998168889
cutoff=.true.
aa=(10.d0**aa)
else
write(6,*)"Cant find a Ar-? interaction"
stop
endif
else
write(6,*)"Cant find a ?-? interaction"
stop
endif
dx=x(i)-x(j)
dy=y(i)-y(j)
dz=z(i)-z(j)
rr=dsqrt(dx*dx+dy*dy+dz*dz)
rra=rr*autoang
! NOTE CANNOT HAVE BOTH TROYA FORM AND CUTOFF FORM
if (troya) then ! Troya uses different form & units
v=aa*dexp(-rra*bb)+cc/rra**6
v=v/autokcal
dvdr = -aa*bb*dexp(-rra*bb)-6.d0*cc/rra**7
dvdr=dvdr/autokcal*autoang
elseif (cutoff) then ! cutoff 1/R**-6 at short distances
v=aa*dexp(-rra/bb)-(cc**6/(rra**6+rrc**6))
v=v/autocmi
dvdr = -aa/bb*dexp(-rra/bb)
& +6.d0*(cc**6)*(rra**5)/(rra**6+rrc**6)**2
dvdr=dvdr/autocmi*autoang
else
v=aa*dexp(-rra/bb)-(cc/rra)**6
v=v/autocmi
dvdr = -aa/bb*dexp(-rra/bb)+(6.d0/rra)*(cc/rra)**6
dvdr=dvdr/autocmi*autoang
endif
v1=v1+v
c print *,m1,m2,rra,v*autocmi,v1*autocmi
c derivs = sum over all bonds (DV/DRij * DRij/DXi = DV/DRij * (Xi-Xj)/Rij)
dvdx(i) = dvdx(i) + dvdr*dx/rr
dvdx(j) = dvdx(j) - dvdr*dx/rr
dvdy(i) = dvdy(i) + dvdr*dy/rr
dvdy(j) = dvdy(j) - dvdr*dy/rr
dvdz(i) = dvdz(i) + dvdr*dz/rr
dvdz(j) = dvdz(j) - dvdr*dz/rr
2 continue
1 continue
v=v1
c print *,'rgexp',v1
return
end
| src/potentials/roohT.f |
subroutine emcee_advance (ndim, nwalkers, a, pin, lpin, &
pout, lpout, accept)
! This subroutine advances an ensemble of walkers using the
! Goodman & Weare stretch move.
!
! Inputs
! ------
!
! ndim [integer]:
! The dimension of the parameter space.
!
! nwalkers [integer]:
! The number of walkers.
!
! a [double precision]:
! The proposal scale (a tuning parameter). Using `a=2` is almost
! always the right move.
!
! pin [double precision (ndim, nwalkers)]:
! The starting positions of the walkers in parameter space.
!
! lpin [double precision (nwalkers)]:
! The value of the log-probability function at positions `pin`.
!
! Outputs
! -------
!
! pout [double precision (ndim, nwalkers)]:
! The final positions of the walkers in parameter space.
!
! lpout [double precision (nwalkers)]:
! The value of the log-probability function at positions `pout`.
!
! accept [integer (nwalkers)]:
! A binary list indicating whether or not each proposal was
! accepted.
implicit none
integer, intent(in) :: ndim, nwalkers
double precision, intent(in) :: a
double precision, intent(in), dimension(ndim,nwalkers) :: pin
double precision, intent(in), dimension(nwalkers) :: lpin
double precision, intent(out), dimension(ndim,nwalkers) :: pout
double precision, intent(out), dimension(nwalkers) :: lpout
integer, intent(out), dimension(nwalkers) :: accept
integer :: k, ri
double precision :: r, z, lp, diff
double precision, dimension(ndim) :: q
do k=1,nwalkers
! Compute a random stretch factor.
call random_number(r)
z = (a - 1.d0) * r + 1.d0
z = z * z / a
! Select the helper walker.
call random_number(r)
ri = ceiling((nwalkers-1) * r)
if (ri .ge. k) then
ri = ri + 1
q = pin(:, ri+1)
else
q = pout(:, ri)
endif
! Compute the proposal position.
q = (1.d0 - z) * q + z * pin(:, k)
! Compute the new ln-probability.
call emcee_lnprob (ndim, q, lp)
diff = (ndim - 1.d0) * log(z) + lp - lpin(k)
! Accept or reject.
if (diff .ge. 0.d0) then
accept(k) = 1
else
call random_number(r)
if (diff .ge. log(r)) then
accept(k) = 1
else
accept(k) = 0
endif
endif
! Do the update.
if (accept(k) .eq. 1) then
pout(:, k) = q
lpout(k) = lp
else
pout(:, k) = pin(:, k)
lpout(k) = lpin(k)
endif
enddo
end subroutine
! See: http://gcc.gnu.org/onlinedocs/gfortran/RANDOM_005fSEED.html
subroutine init_random_seed ()
implicit none
integer, allocatable :: seed(:)
integer :: i, n, un, istat, dt(8), pid, t(2), s
integer(8) :: count, tms
call random_seed(size = n)
allocate(seed(n))
! First try if the OS provides a random number generator
open(newunit=un, file="/dev/urandom", access="stream", &
form="unformatted", action="read", status="old", iostat=istat)
if (istat == 0) then
read(un) seed
close(un)
else
! Fallback to XOR:ing the current time and pid. The PID is
! useful in case one launches multiple instances of the same
! program in parallel.
call system_clock(count)
if (count /= 0) then
t = transfer(count, t)
else
call date_and_time(values=dt)
tms = (dt(1) - 1970) * 365_8 * 24 * 60 * 60 * 1000 &
+ dt(2) * 31_8 * 24 * 60 * 60 * 1000 &
+ dt(3) * 24 * 60 * 60 * 60 * 1000 &
+ dt(5) * 60 * 60 * 1000 &
+ dt(6) * 60 * 1000 + dt(7) * 1000 &
+ dt(8)
t = transfer(tms, t)
end if
s = ieor(t(1), t(2))
pid = getpid() + 1099279 ! Add a prime
s = ieor(s, pid)
if (n >= 3) then
seed(1) = t(1) + 36269
seed(2) = t(2) + 72551
seed(3) = pid
if (n > 3) then
seed(4:) = s + 37 * (/ (i, i = 0, n - 4) /)
end if
else
seed = s + 37 * (/ (i, i = 0, n - 1 ) /)
end if
end if
call random_seed(put=seed)
end subroutine init_random_seed
| src/emcee.f95 |
subroutine tridig (u,n,a,b,c,d,kode,ier)
C...subroutine tridig 01/09/73
C...subroutine tridig 01/09/78
dimension u(n),a(n),b(n),c(n),d(n)
ier=0
al=0.
bt=0.
gm=1.
n1=n-1
if (b(1).ne.0.) goto 2
ier=1
return
2 do 5 i=1,n1
s=a(i)*al+b(i)
if(s.eq.0.) goto 4
s1=1./s
al=-c(i)*s1
bt=(d(i)-a(i)*bt)*s1
gm=-a(i)*gm*s1
a(i)=al
b(i)=bt
5 c(i)=gm
if (kode.eq.1) goto 8
u(n)=(d(n)-a(n)*bt)/(a(n)*al+b(n))
do 7 i=1,n1
7 u(n-i)=a(n-i)*u(n-i+1)+b(n-i)
return
8 t=1.
v=0.
do 9 i=1,n1
t=a(n-i)*t+c(n-i)
v=a(n-i)*v+b(n-i)
a(n-i)=t
9 b(n-i)=v
u(n)=(d(n)-c(n)*b(2)-a(n)*b(n-1))/(b(n)+c(n)*a(2)+a(n)*a(n-1))
do 10 i=1,n1
10 u(n-i)=a(n-i)*u(n)+b(n-i)
return
4 ier=2
return
end
| ftn/tridig.f |
module types
implicit none
private
public dp, i64
integer, parameter :: dp=kind(0.d0) ! double precision
integer, parameter :: i64 = selected_int_kind(18) ! At least 64-bit integer
end module
module utils
! Various utilities
use types, only: dp, i64
implicit none
private
public trace, mean, std, init_random_seed, randn, assert, stop_error, &
sysclock2ms
contains
subroutine stop_error(msg)
! Aborts the program with nonzero exit code
!
! The statement "stop msg" will return 0 exit code when compiled using
! gfortran. stop_error() uses the statement "stop 1" which returns an exit code
! 1 and a print statement to print the message.
!
! Example
! -------
!
! call stop_error("Invalid argument")
character(len=*) :: msg ! Message to print on stdout
print *, msg
stop 1
end subroutine
subroutine assert(condition)
! If condition == .false., it aborts the program.
!
! Arguments
! ---------
!
logical, intent(in) :: condition
!
! Example
! -------
!
! call assert(a == 5)
if (.not. condition) call stop_error("Assert failed.")
end subroutine
real(dp) function trace(A) result(t)
real(dp), intent(in) :: A(:, :)
integer :: i
t = 0
do i = 1, size(A, 1)
t = t + A(i, i)
end do
end function
real(dp) function mean(x) result(t)
real(dp), intent(in) :: x(:)
t = sum(x) / size(x)
end function
real(dp) function std(x) result(t)
real(dp), intent(in) :: x(:)
t = sqrt(mean(abs(x - mean(x))**2))
end function
subroutine init_random_seed()
integer :: i, n, clock
integer, allocatable :: seed(:)
call random_seed(size=n)
allocate(seed(n))
call system_clock(count=clock)
seed = clock + 37 * [ (i - 1, i = 1, n) ]
call random_seed(put=seed)
end subroutine
FUNCTION rnorm() RESULT( fn_val )
! This subroutine was taken from: http://jblevins.org/mirror/amiller/rnorm.f90
! Generate a random normal deviate using the polar method.
! Reference: Marsaglia,G. & Bray,T.A. 'A convenient method for generating
! normal variables', Siam Rev., vol.6, 260-264, 1964.
IMPLICIT NONE
REAL(dp) :: fn_val
! Local variables
REAL(dp) :: u, sum
REAL(dp), SAVE :: v, sln
LOGICAL, SAVE :: second = .FALSE.
REAL(dp), PARAMETER :: one = 1, vsmall = TINY( one )
IF (second) THEN
! If second, use the second random number generated on last call
second = .false.
fn_val = v*sln
ELSE
! First call; generate a pair of random normals
second = .true.
DO
CALL RANDOM_NUMBER( u )
CALL RANDOM_NUMBER( v )
u = SCALE( u, 1 ) - one
v = SCALE( v, 1 ) - one
sum = u*u + v*v + vsmall ! vsmall added to prevent LOG(zero) / zero
IF(sum < one) EXIT
END DO
sln = SQRT(- SCALE( LOG(sum), 1 ) / sum)
fn_val = u*sln
END IF
RETURN
END FUNCTION rnorm
subroutine randn(A)
real(dp), intent(out) :: A(:, :)
integer :: i, j
do j = 1, size(A, 2)
do i = 1, size(A, 1)
A(i, j) = rnorm()
end do
end do
end subroutine
! Convert a number of clock ticks, as returned by system_clock called
! with integer(i64) arguments, to milliseconds
function sysclock2ms(t)
integer(i64), intent(in) :: t
integer(i64) :: rate
real(dp) :: sysclock2ms, r
call system_clock(count_rate=rate)
r = 1000._dp / rate
sysclock2ms = t * r
end function sysclock2ms
end module
module bench
use utils, only: trace, randn, std, mean, stop_error
use types, only: dp
implicit none
private
public fib, parse_int, printfd, quicksort, mandelperf, pisum, randmatstat, randmatmul
contains
integer recursive function fib(n) result(r)
integer, intent(in) :: n
if (n < 2) then
r = n
else
r = fib(n-1) + fib(n-2)
end if
end function
integer function parse_int(s, base) result(n)
character(len=*), intent(in) :: s
integer, intent(in) :: base
integer :: i, d
character :: c
n = 0
do i = 1, len(s)
c = s(i:i)
d = 0
if (ichar(c) >= ichar('0') .and. ichar(c) <= ichar('9')) then
d = ichar(c) - ichar('0')
else if (ichar(c) >= ichar('A') .and. ichar(c) <= ichar('Z')) then
d = ichar(c) - ichar('A') + 10
else if (ichar(c) >= ichar('a') .and. ichar(c) <= ichar('z')) then
d = ichar(c) - ichar('a') + 10
else
call stop_error("parse_int 1")
end if
if (base <= d) call stop_error("parse_int 2")
n = n*base + d
end do
end function
subroutine printfd(n)
integer, intent(in) :: n
integer :: i , unit
open(unit=1, file="foo")
do i = 1, n
write(unit=1, fmt=*) i, i
end do
close(unit=1)
end subroutine
integer function mandel(z0) result(r)
complex(dp), intent(in) :: z0
complex(dp) :: c, z
integer :: n, maxiter
maxiter = 80
z = z0
c = z0
do n = 1, maxiter
if (abs(z) > 2) then
r = n-1
return
end if
z = z**2 + c
end do
r = maxiter
end function
integer function mandelperf() result(mandel_sum)
integer :: re, im
volatile :: mandel_sum
mandel_sum = 0
re = -20
do while (re <= 5)
im = -10
do while (im <= 10)
mandel_sum = mandel_sum + mandel(cmplx(re/10._dp, im/10._dp, dp))
im = im + 1
end do
re = re + 1
end do
end function
recursive subroutine quicksort(a, lo0, hi)
real(dp), intent(inout) :: a(:)
integer, intent(in) :: lo0, hi
integer :: i, j, lo
real(dp) :: pivot, t
lo = lo0
i = lo
j = hi
do while (i < hi)
pivot = a((lo+hi)/2)
do while (i <= j)
do while (a(i) < pivot)
i = i + 1
end do
do while (a(j) > pivot)
j = j - 1
end do
if (i <= j) then
t = a(i)
a(i) = a(j)
a(j) = t
i = i + 1
j = j - 1
end if
end do
if (lo < j) call quicksort(a, lo, j)
lo = i
j = hi
end do
end subroutine
real(dp) function pisum() result(s)
integer :: j, k
do j = 1, 500
s = 0
do k = 1, 10000
s = s + 1._dp / k**2
end do
end do
end function
subroutine randmatstat(t, s1, s2)
integer, intent(in) :: t
real(dp), intent(out) :: s1, s2
real(dp), allocatable, dimension(:, :) :: a, b, c, d, P, Q, X
real(dp), allocatable :: v(:), w(:)
integer :: n, i
n = 5
allocate(a(n, n), b(n, n), c(n, n), d(n, n))
allocate(P(4*n, n), Q(2*n, 2*n), X(2*n, 2*n))
allocate(v(t), w(t))
do i = 1, t
call randn(a)
call randn(b)
call randn(c)
call randn(d)
P(:n, :)=a; P(n+1:2*n, :)=b; P(2*n+1:3*n, :)=c; P(3*n+1:, :)=d
Q(:n, :n) = a; Q(n+1:, :n) = b
Q(:n, n+1: ) = c; Q(n+1:, n+1: ) = d
X = matmul(transpose(P), P)
X = matmul(X, X)
X = matmul(X, X)
v(i) = trace(X)
X = matmul(transpose(Q), Q)
X = matmul(X, X)
X = matmul(X, X)
w(i) = trace(X)
end do
s1 = std(v) / mean(v)
s2 = std(w) / mean(w)
end subroutine
subroutine randmatmul(n, C)
integer, intent(in) :: n
real(dp), intent(out), allocatable :: C(:, :)
real(dp), allocatable :: A(:, :), B(:, :)
allocate(A(n, n), B(n, n), C(n, n))
call random_number(A)
call random_number(B)
!C = matmul(A, B)
call dgemm('N','N',n,n,n,1.0d0,A,n,B,n,0.0d0,C,n)
end subroutine
end module
program perf
use types, only: dp, i64
use utils, only: assert, init_random_seed, sysclock2ms
use bench, only: fib, parse_int, printfd, quicksort, mandelperf, pisum, randmatstat, &
randmatmul
implicit none
integer, parameter :: NRUNS = 1000
integer :: i, f, n, m, k, k2
integer(i64) :: t1, t2, tmin
real(dp) :: pi, s1, s2
real(dp), allocatable :: C(:, :), d(:)
character(len=11) :: s
call init_random_seed()
tmin = huge(0_i64)
do i = 1, 5
call system_clock(t1)
do k = 1, NRUNS
f = fib(20)
end do
call system_clock(t2)
if (t2-t1 < tmin) tmin = t2-t1
end do
call assert(f == 6765)
print "('fortran,recursion_fibonacci,',f0.6)", sysclock2ms(tmin) / NRUNS
tmin = huge(0_i64)
do i = 1, 5
call system_clock(t1)
do k2 = 1, NRUNS
do k = 1, 1000
call random_number(s1)
n = int(s1*huge(n))
write(s, '(z0)') n
m = parse_int(s(:len_trim(s)), 16)
call assert(m == n)
end do
end do
call system_clock(t2)
if (t2-t1 < tmin) tmin = t2-t1
end do
print "('fortran,parse_integers,',f0.6)", sysclock2ms(tmin) / NRUNS
tmin = huge(0_i64)
do i = 1, 5
call system_clock(t1)
call printfd(100000)
call system_clock(t2)
if (t2-t1 < tmin) tmin = t2-t1
end do
print "('fortran,print_to_file,',f0.6)", sysclock2ms(tmin)
tmin = huge(0_i64)
do i = 1, 5
call system_clock(t1)
do k = 1, NRUNS
f = mandelperf()
end do
call system_clock(t2)
if (t2-t1 < tmin) tmin = t2-t1
end do
call assert(f == 14791)
print "('fortran,iteration_mandelbrot,',f0.6)", sysclock2ms(tmin) / NRUNS
tmin = huge(0_i64)
do i = 1, 5
call system_clock(t1)
do k = 1, NRUNS
allocate(d(5000))
call random_number(d)
call quicksort(d, 1, size(d))
deallocate(d)
end do
call system_clock(t2)
if (t2-t1 < tmin) tmin = t2-t1
end do
print "('fortran,recursion_quicksort,',f0.6)", sysclock2ms(tmin) / NRUNS
tmin = huge(0_i64)
do i = 1, 5
call system_clock(t1)
pi = pisum()
call system_clock(t2)
if (t2-t1 < tmin) tmin = t2-t1
end do
call assert(abs(pi - 1.644834071848065_dp) < 1e-6_dp)
print "('fortran,iteration_pi_sum,',f0.6)", sysclock2ms(tmin)
tmin = huge(0_i64)
do i = 1, 5
call system_clock(t1)
call randmatstat(1000, s1, s2)
call system_clock(t2)
if (t2-t1 < tmin) tmin = t2-t1
end do
! call assert(s1 > 0.5_dp .and. s1 < 1)
! call assert(s2 > 0.5_dp .and. s2 < 1)
print "('fortran,matrix_statistics,',f0.6)", sysclock2ms(tmin)
tmin = huge(0_i64)
do i = 1, 5
call system_clock(t1)
call randmatmul(1000, C)
call assert(C(1, 1) >= 0)
call system_clock(t2)
if (t2-t1 < tmin) tmin = t2-t1
end do
print "('fortran,matrix_multiply,',f0.6)", sysclock2ms(tmin)
end program
| test/perf/micro/perf.f90 |
*----------------------------------------------------------------------*
subroutine set_r12_general_targets(tgt_info,orb_info,env_type)
*----------------------------------------------------------------------*
* set targets needed in more or less all kinds of R12 calculations
*----------------------------------------------------------------------*
implicit none
include 'stdunit.h'
include 'opdim.h'
include 'mdef_target_info.h'
include 'def_orbinf.h'
include 'ifc_input.h'
include 'par_opnames_gen.h'
include 'par_formnames_gen.h'
include 'par_gen_targets.h'
include 'par_actions.h'
type(target_info), intent(inout) ::
& tgt_info
type(orbinf), intent(in) ::
& orb_info
integer ::
& hpvx_constr(2,ngastp,2),
& gas_constr(2,orb_info%ngas,2,2)
integer ::
& min_rank, max_rank, ansatz,
& isim, ncat, nint, icnt, nlab,
& isym, ms, msc, sym_arr(8),
& occ_def(ngastp,2,60), ndef, mode, trunc_type,
& ninproj, navoid, nconnect, nreplace,
& connect(20), idx_sv(20), iblkmin(20),
& iblkmax(20)
logical ::
& needed, r12fix, extend, truncate, frozen,frozen_old, pz_eval,
& pf12_trunc
character(len_target_name) ::
& me_label, medef_label, dia_label, mel_dia1,
& labels(20)
character(len_command_par) ::
& parameters(3)
character(20) ::
& approx, F_appr, K_appr, Z_appr, shell_typ
character(*), intent(in) ::
& env_type
*----------------------------------------------------------------------*
if (iprlvl.gt.0)
& write(lulog,*) 'setting general targets for R12 ...'
msc = +1 ! assuming closed shell
*----------------------------------------------------------------------*
* read input
*----------------------------------------------------------------------*
! set approx string
approx(1:20) = ' '
F_appr(1:20) = ' '
K_appr(1:20) = ' '
Z_appr(1:20) = ' '
call get_argument_value('method.R12','ansatz',ival=ansatz)
call get_argument_value('method.R12','approx',str=approx)
call get_argument_value('method.R12','F_appr',str=F_appr)
call get_argument_value('method.R12','K_appr',str=K_appr)
call get_argument_value('method.R12','Z_appr',str=Z_appr)
call get_argument_value('method.R12','minexc',ival=min_rank)
call get_argument_value('method.R12','maxexc',ival=max_rank)
call get_argument_value('method.R12','fixed',lval=r12fix)
call get_argument_value('method.R12','pz_eval',lval=pz_eval)
call get_argument_value('method.R12','extend',ival=mode)
call get_argument_value('method.R12','trunc',ival=trunc_type)
truncate = trunc_type.ge.0
if (is_keyword_set('method.truncate').gt.0) then
truncate = is_keyword_set('method.truncate').gt.0
call get_argument_value('method.truncate','trunc_type',
& ival=trunc_type)
end if
pf12_trunc = truncate.and.trunc_type.eq.0
! Frozen core?
frozen_old = .false.
frozen = .false.
shell_typ(1:len(shell_typ)) = ' '
if(is_keyword_set('orb_space.shell').gt.0)then
call get_argument_value('orb_space.shell','type',
& str=shell_typ)
frozen = trim(shell_typ).eq.'frozen'
endif
select case(trim(Z_appr))
case('direct')
write(lulog,*) 'direct RI evaluation of Z intermediate'
approx(14:17) = 'DRCT'
case('none','J2K3')
write(lulog,*) 'no approximations to Z intermediate made'
approx(14:17) = 'J2K3'
case default
if (Z_appr(1:1).ne.'J'.or.Z_appr(3:3).ne.'K'.or.
& (Z_appr(2:2).ne.'0'.and.
& Z_appr(2:2).ne.'1'.and.
& Z_appr(2:2).ne.'2').or.
& (Z_appr(4:4).ne.'0'.and.
& Z_appr(4:4).ne.'1'.and.
& Z_appr(4:4).ne.'2'.and.
& Z_appr(4:4).ne.'3')) then
call quit(0,'set_r12_general_targets',
& 'Z_appr unknown: "'//trim(Z_appr)//'"')
end if
write(lulog,*) 'approximation to Z intermediate: ',trim(Z_appr)
approx(14:17) = Z_appr(1:4)
end select
! actual processing moved to set_r12f_general_targets
extend = mode.gt.0
if(extend.and..not.r12fix)
& call quit(1,'set_r12_general_targets',
& 'Extension only valid for MP2-R12 with fixed C12')
! assemble approx string
select case(trim(F_appr))
case('none')
write(lulog,*) 'no approximations wrt. Fock made'
case('no_Z')
write(lulog,*) 'Z matrix omitted'
approx(4:6) = 'noZ'
case('GBC','EBC')
write(lulog,*)
& 'GBC/EBC are currently only possible be supplying the'
write(lulog,*)
& 'suitable integrals. Make that sure and restart w/o'
write(lulog,*)
& 'GBC/EBC flag'
call quit(0,'set_r12_general_targets','GBC/EBC?')
case default
call quit(0,'set_r12_general_targets',
& 'F_appr unknown: "'//trim(F_appr)//'"')
end select
select case(trim(K_appr))
case('none')
write(lulog,*) 'no approximations wrt. Xchange made'
case('HY1')
write(lulog,*) 'Y contribution omitted'
approx(8:10) = 'HY1'
case('HY2')
write(lulog,*) 'Y contribution approx with 1 CABS index'
approx(8:10) = 'HY2'
case default
call quit(0,'set_r12_general_targets',
& 'K_appr unknown: "'//trim(K_appr)//'"')
end select
*----------------------------------------------------------------------*
* Operators:
*----------------------------------------------------------------------*
! the formal R12 geminal: P12 r12|0>
call add_target(op_r12,ttype_op,.false.,tgt_info)
if(.not.extend)then
c min_rank = 2 ! 1 is a possibility
call r12gem_parameters(-1,parameters,
& 0,2,2,ansatz)
call set_rule(op_r12,ttype_op,DEF_R12GEMINAL,
& op_r12,1,1,
& parameters,1,tgt_info)
else
occ_def = 0
! 1
occ_def(IEXTR,1,1) = 2
occ_def(IHOLE,2,1) = 2
! 2
occ_def(IEXTR,1,2) = 2
occ_def(IPART,2,2) = 1
occ_def(IHOLE,2,2) = 1
ndef = 2
if(ansatz.gt.1)then
! 3
occ_def(IEXTR,1,3) = 1
occ_def(IPART,1,3) = 1
occ_def(IHOLE,2,3) = 2
! 4
occ_def(IEXTR,1,4) = 1
occ_def(IPART,1,4) = 1
occ_def(IPART,2,4) = 1
occ_def(IHOLE,2,4) = 1
ndef = 4
endif
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,1,(/ 0, 0/),ndef)
call set_rule(op_r12,ttype_op,DEF_OP_FROM_OCC,
& op_r12,1,1,
& parameters,2,tgt_info)
endif
! Only need coefficients if optimising the R12 contribution.
! the coefficients
call add_target(op_c12,ttype_op,.false.,tgt_info)
call xop_parameters(-1,parameters,
& .false.,min_rank,max_rank,0,max_rank+1)
call set_rule(op_c12,ttype_op,DEF_R12COEFF,
& op_c12,1,1,
& parameters,1,tgt_info)
! Lagrange multipliers associated with coefficients
call add_target(op_cba,ttype_op,.false.,tgt_info)
call set_dependency(op_cba,op_c12,tgt_info)
call cloneop_parameters(-1,parameters,
& op_c12,.true.) ! <- dagger=.true.
call set_rule(op_cba,ttype_op,CLONE_OP,
& op_cba,1,1,
& parameters,1,tgt_info)
if(extend)then
! T1' operators for extended MP2-F12.
call add_target(op_cex,ttype_op,.false.,tgt_info)
call xop_parameters(-1,parameters,
& .false.,1,1,0,2)
call set_rule(op_cex,ttype_op,DEF_EXCITATION,
& op_cex,1,1,
& parameters,1,tgt_info)
! The Lagrangian multipliers.
call add_target(op_cexbar,ttype_op,.false.,tgt_info)
call set_dependency(op_cexbar,op_cex,tgt_info)
call cloneop_parameters(-1,parameters,
& op_cex,.true.) ! <- dagger=.true.
call set_rule(op_cexbar,ttype_op,CLONE_OP,
& op_cexbar,1,1,
& parameters,1,tgt_info)
endif
if(.not.r12fix)then
! Preconditioner
call add_target(op_diar12,ttype_op,.false.,tgt_info)
call set_dependency(op_diar12,op_c12,tgt_info)
call cloneop_parameters(-1,parameters,
& op_c12,.false.) ! <- dagger=.false.
call set_rule(op_diar12,ttype_op,CLONE_OP,
& op_diar12,1,1,
& parameters,1,tgt_info)
endif
! Now: the operators associated with the actual R12 integrals:
! <pq'|r12|ij>
call add_target(op_rint,ttype_op,.false.,tgt_info)
call r12int_parameters(-1,parameters,
c & .false.,min_rank,2,0,2)
& 0,min_rank,2,0,4) ! 4: two externals for 2-el ops
call set_rule(op_rint,ttype_op,DEF_R12INT,
& op_rint,1,1,
& parameters,1,tgt_info)
! (pq)_frozen/(pq)_ae block of 2e-Hamiltonian
call add_target(op_g_x,ttype_op,.false.,tgt_info)
c min_rank = 2
cc call hop_parameters(-1,parameters,
cc & min_rank,2,3,.true.) ! 1-external at most
cc call set_rule(op_g_x,ttype_op,DEF_HAMILTONIAN,
cc & op_g_x,1,1,
cc & parameters,1,tgt_info)
c call r12int_parameters(-1,parameters,
c & 2,min_rank,2,0,3)
cc dbg
cc & 2,min_rank,2,0,5)
cc dbg
c call set_rule(op_g_x,ttype_op,DEF_R12INT,
c & op_g_x,1,1,
c & parameters,1,tgt_info)
ndef = 16
call set_gxx(occ_def)
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,1,(/ 2, 0/),ndef)
call set_rule(op_g_x,ttype_op,DEF_OP_FROM_OCC,
& op_g_x,1,1,
& parameters,2,tgt_info)
! ae/ae blocks of 2e-Hamilt. (formal)
call add_target('G-XX',ttype_op,.false.,tgt_info)
ndef = 16
call set_gxx(occ_def)
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,1,(/ 2, 2/),ndef)
call set_rule('G-XX',ttype_op,DEF_OP_FROM_OCC,
& 'G-XX',1,1,
& parameters,2,tgt_info)
! (pq)_frozen/(iq)_ae block of 2e-Hamiltonian (actual)
call add_target('G-Acore',ttype_op,.false.,tgt_info)
c min_rank = 2
occ_def = 0
ndef = 9
! 1
occ_def(IHOLE,1,1) = 2
occ_def(IHOLE,2,1) = 2
! 2
occ_def(IHOLE,1,2) = 2
occ_def(IHOLE,2,2) = 1
occ_def(IPART,2,2) = 1
! 3
occ_def(IHOLE,1,3) = 2
occ_def(IHOLE,2,3) = 1
occ_def(IEXTR,2,3) = 1
! 4
occ_def(IHOLE,1,4) = 1
occ_def(IPART,1,4) = 1
occ_def(IHOLE,2,4) = 2
! 5
occ_def(IHOLE,1,5) = 1
occ_def(IPART,1,5) = 1
occ_def(IHOLE,2,5) = 1
occ_def(IPART,2,5) = 1
! 6
occ_def(IHOLE,1,6) = 1
occ_def(IPART,1,6) = 1
occ_def(IHOLE,2,6) = 1
occ_def(IEXTR,2,6) = 1
! 7
occ_def(IPART,1,7) = 2
occ_def(IHOLE,2,7) = 2
! 8
occ_def(IPART,1,8) = 2
occ_def(IHOLE,2,8) = 1
occ_def(IPART,2,8) = 1
! 9
occ_def(IPART,1,9) = 2
occ_def(IHOLE,2,9) = 1
occ_def(IEXTR,2,9) = 1
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,1,(/ 0, 2/),ndef)
call set_rule('G-Acore',ttype_op,DEF_OP_FROM_OCC,
& 'G-Acore',1,1,
& parameters,2,tgt_info)
! auxiliary HX|HX list
call add_target('H-ext',ttype_op,.false.,tgt_info)
c min_rank = 2
occ_def = 0
ndef = 1
! 1
occ_def(IHOLE,1,1) = 1
occ_def(IEXTR,1,1) = 1
occ_def(IHOLE,2,1) = 1
occ_def(IEXTR,2,1) = 1
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,1,(/ 0, 2/),ndef)
call set_rule('H-ext',ttype_op,DEF_OP_FROM_OCC,
& 'H-ext',1,1,
& parameters,2,tgt_info)
! (jq)_ae/(ir)_ae block of 2e-Hamiltonian
call add_target('G-CAcore',ttype_op,.false.,tgt_info)
c min_rank = 2
occ_def = 0
ndef = 12
! 1
occ_def(IHOLE,1,1) = 2
occ_def(IHOLE,2,1) = 2
! 2
occ_def(IHOLE,1,2) = 2
occ_def(IHOLE,2,2) = 1
occ_def(IPART,2,2) = 1
! 3
occ_def(IHOLE,1,3) = 2
occ_def(IHOLE,2,3) = 1
occ_def(IEXTR,2,3) = 1
! 4
occ_def(IHOLE,1,4) = 1
occ_def(IPART,1,4) = 1
occ_def(IHOLE,2,4) = 2
! 5
occ_def(IHOLE,1,5) = 1
occ_def(IPART,1,5) = 1
occ_def(IHOLE,2,5) = 1
occ_def(IPART,2,5) = 1
! 6
occ_def(IHOLE,1,6) = 1
occ_def(IPART,1,6) = 1
occ_def(IHOLE,2,6) = 1
occ_def(IEXTR,2,6) = 1
! 7
occ_def(IHOLE,1,7) = 1
occ_def(IEXTR,1,7) = 1
occ_def(IHOLE,2,7) = 2
! 8
occ_def(IHOLE,1,8) = 1
occ_def(IEXTR,1,8) = 1
occ_def(IHOLE,2,8) = 1
occ_def(IPART,2,8) = 1
! 9
occ_def(IHOLE,1,9) = 1
occ_def(IEXTR,1,9) = 1
occ_def(IHOLE,2,9) = 1
occ_def(IEXTR,2,9) = 1
! 10
occ_def(IHOLE,1,10) = 2
occ_def(IPART,2,10) = 2
! 11
occ_def(IHOLE,1,11) = 1
occ_def(IPART,1,11) = 1
occ_def(IPART,2,11) = 2
! 12
occ_def(IHOLE,1,12) = 1
occ_def(IEXTR,1,12) = 1
occ_def(IPART,2,12) = 2
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,1,(/ 2, 2/),ndef)
call set_rule('G-CAcore',ttype_op,DEF_OP_FROM_OCC,
& 'G-CAcore',1,1,
& parameters,2,tgt_info)
! i,(a/x) block of Fock
call add_target('F-X',ttype_op,.false.,tgt_info)
occ_def = 0
ndef = 2
occ_def(IHOLE,1,1) = 1
occ_def(IPART,2,1) = 1
occ_def(IHOLE,1,2) = 1
occ_def(IEXTR,2,2) = 1
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,1,(/ 2, 0/),ndef)
call set_rule('F-X',ttype_op,DEF_OP_FROM_OCC,
& 'F-X',1,1,
& parameters,2,tgt_info)
! commutator integrals <ab|[T1+T2,r12]|ij>
call add_target(op_ttr,ttype_op,.false.,tgt_info)
call r12int_parameters(-1,parameters,
& 0,min_rank,2,0,2)
call set_rule(op_ttr,ttype_op,DEF_R12INT,
& op_ttr,1,1,
& parameters,1,tgt_info)
! A(f+k) modified integrals r12bar
call add_target(op_rintbar,ttype_op,.false.,tgt_info)
call r12int_parameters(-1,parameters,
& 0,min_rank,2,0,2)
call set_rule(op_rintbar,ttype_op,DEF_R12INT,
& op_rintbar,1,1,
& parameters,1,tgt_info)
! C(f+k) modified integrals r12bar+
call add_target(op_rdagbar,ttype_op,.false.,tgt_info)
call r12int_parameters(-1,parameters,
& 0,min_rank,2,0,2)
call set_rule(op_rdagbar,ttype_op,DEF_R12INT,
& op_rdagbar,1,1,
& parameters,1,tgt_info)
! C(f) modified integrals r12breve
call add_target(op_rintbreve,ttype_op,.false.,tgt_info)
occ_def = 0
ndef = 2
! 1
occ_def(IHOLE,1,1) = 1
occ_def(IPART,1,1) = 1
occ_def(IHOLE,2,1) = 2
! 2
occ_def(IHOLE,1,2) = 1
occ_def(IEXTR,1,2) = 1
occ_def(IHOLE,2,2) = 2
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,1,(/ 2, 0/),ndef)
call set_rule(op_rintbreve,ttype_op,DEF_OP_FROM_OCC,
& op_rintbreve,1,1,
& parameters,2,tgt_info)
! C k modified integrals r12tilde (cloning rint -> 2ext usually)
call add_target(op_rinttilde,ttype_op,.false.,tgt_info)
call set_dependency(op_rinttilde,op_rint,tgt_info)
call cloneop_parameters(-1,parameters,
& op_rint,.false.)
call set_rule(op_rinttilde,ttype_op,CLONE_OP,
& op_rinttilde,1,1,
& parameters,1,tgt_info)
! commutator integrals <kl|r12[T1+T2,r12]|ij>
call add_target(op_rttr,ttype_op,.false.,tgt_info)
call xop_parameters(-1,parameters,
& .false.,2,2,0,2)
call set_rule(op_rttr,ttype_op,DEF_R12INTERM,
& op_rttr,1,1,
& parameters,1,tgt_info)
! (G.R)^{ij}_{pq}
call add_target(op_gr,ttype_op,.false.,tgt_info)
occ_def = 0
! 1
occ_def(IHOLE,1,1) = 2
occ_def(IHOLE,2,2) = 2
! 2
occ_def(IHOLE,1,3) = 1
occ_def(IPART,1,3) = 1
occ_def(IHOLE,2,4) = 2
! 3
occ_def(IPART,1,5) = 2
occ_def(IHOLE,2,6) = 2
! 4
occ_def(IHOLE,1,7) = 1
occ_def(IEXTR,1,7) = 1
occ_def(IHOLE,2,8) = 2
! 5
occ_def(IPART,1,9) = 1
occ_def(IEXTR,1,9) = 1
occ_def(IHOLE,2,10) = 2
! 6
occ_def(IHOLE,1,11) = 2
occ_def(IHOLE,2,12) = 1
occ_def(IPART,2,12) = 1
! 7
occ_def(IHOLE,1,13) = 2
occ_def(IPART,2,14) = 2
call op_from_occ_parameters(-1,parameters,2,
& occ_def,7,2,(/ 0,0, 0, 0/),14)
call set_rule(op_gr,ttype_op,DEF_OP_FROM_OCC,
& op_gr,1,1,
& parameters,2,tgt_info)
! extended variant (formal)
call add_target(op_gr_x,ttype_op,.false.,tgt_info)
call op_from_occ_parameters(-1,parameters,2,
& occ_def,7,2,(/ 2, 0, 2, 0/),14)
call set_rule(op_gr_x,ttype_op,DEF_OP_FROM_OCC,
& op_gr_x,1,1,
& parameters,2,tgt_info)
! core list
ndef = 5
occ_def = 0
! 1
occ_def(IHOLE,1,1) = 2
occ_def(IHOLE,2,2) = 2
! 2
occ_def(IHOLE,1,3) = 1
occ_def(IPART,1,3) = 1
occ_def(IHOLE,2,4) = 2
! 3
occ_def(IHOLE,1,5) = 1
occ_def(IEXTR,1,5) = 1
occ_def(IHOLE,2,6) = 2
! 4
occ_def(IHOLE,1,7) = 2
occ_def(IHOLE,2,8) = 1
occ_def(IPART,2,8) = 1
! 5
occ_def(IHOLE,1,9) = 2
occ_def(IPART,2,10) = 2
call add_target('G.R-Ccore',ttype_op,.false.,tgt_info)
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,2,(/ 2, 0, 2, 0/),2*ndef)
call set_rule('G.R-Ccore',ttype_op,DEF_OP_FROM_OCC,
& 'G.R-Ccore',1,1,
& parameters,2,tgt_info)
c call set_dependency(op_gr,op_v_inter,tgt_info)
c call cloneop_parameters(-1,parameters,
c & op_v_inter,.false.) ! <- dagger=.false.
c call set_rule(op_gr,ttype_op,CLONE_OP,
c & op_gr,1,1,
c & parameters,1,tgt_info)
! V^{ij}_{pq}
call add_target(op_v_inter,ttype_op,.false.,tgt_info)
c call xop_parameters(-1,parameters,
c & .false.,2,2,0,2)
c call set_rule(op_v_inter,ttype_op,DEF_R12INTERM,
c & op_v_inter,1,1,
c & parameters,1,tgt_info)
occ_def = 0
! 1
occ_def(IHOLE,1,1) = 2
occ_def(IHOLE,2,2) = 2
! 2
occ_def(IHOLE,1,3) = 1
occ_def(IPART,1,3) = 1
occ_def(IHOLE,2,4) = 2
! 3
occ_def(IPART,1,5) = 2
occ_def(IHOLE,2,6) = 2
! 4
occ_def(IHOLE,1,7) = 1
occ_def(IEXTR,1,7) = 1
occ_def(IHOLE,2,8) = 2
! 5
occ_def(IPART,1,9) = 1
occ_def(IEXTR,1,9) = 1
occ_def(IHOLE,2,10) = 2
ndef = 1
if (is_keyword_set('method.CC').gt.0.and.pf12_trunc) ndef = 3
if (is_keyword_set('method.CC').gt.0.and..not.pf12_trunc) ndef = 5
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,2,(/ 0, 0, 0, 0/),10)
call set_rule(op_v_inter,ttype_op,DEF_OP_FROM_OCC,
& op_v_inter,1,1,
& parameters,2,tgt_info)
! extended variant (formal)
call add_target(op_v_x,ttype_op,.false.,tgt_info)
call op_from_occ_parameters(-1,parameters,2,
& occ_def,5,2,(/ 2, 0, 2, 0/),10)
call set_rule(op_v_x,ttype_op,DEF_OP_FROM_OCC,
& op_v_x,1,1,
& parameters,2,tgt_info)
! core contributions containing part
ndef = 3
occ_def = 0
! 1
occ_def(IHOLE,1,1) = 2
occ_def(IHOLE,2,2) = 2
! 2
occ_def(IHOLE,1,3) = 1
occ_def(IPART,1,3) = 1
occ_def(IHOLE,2,4) = 2
! 3
occ_def(IHOLE,1,5) = 1
occ_def(IEXTR,1,5) = 1
occ_def(IHOLE,2,6) = 2
call add_target('V-Ccore',ttype_op,.false.,tgt_info)
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,2,(/ 2, 0, 2, 0/),2*ndef)
call set_rule('V-Ccore',ttype_op,DEF_OP_FROM_OCC,
& 'V-Ccore',1,1,
& parameters,2,tgt_info)
c dbg
c call add_target(op_v_test,ttype_op,.false.,tgt_info)
cc call xop_parameters(-1,parameters,
cc & .false.,2,2,0,2)
cc call set_rule(op_v_inter,ttype_op,DEF_R12INTERM,
cc & op_v_inter,1,1,
cc & parameters,1,tgt_info)
c occ_def = 0
c ! 1
c occ_def(IHOLE,1,1) = 2
c occ_def(IHOLE,2,2) = 2
c ! 2
c occ_def(IHOLE,1,3) = 1
c occ_def(IPART,1,3) = 1
c occ_def(IHOLE,2,4) = 2
c ! 3
c occ_def(IPART,1,5) = 2
c occ_def(IHOLE,2,6) = 2
c ! 4
c occ_def(IHOLE,1,7) = 1
c occ_def(IEXTR,1,7) = 1
c occ_def(IHOLE,2,8) = 2
c ! 5
c occ_def(IPART,1,9) = 1
c occ_def(IEXTR,1,9) = 1
c occ_def(IHOLE,2,10) = 2
c
c call op_from_occ_parameters(-1,parameters,2,
c & occ_def,5,2,(/ 0, 0/),10)
c call set_rule(op_v_test,ttype_op,DEF_OP_FROM_OCC,
c & op_v_test,1,1,
c & parameters,2,tgt_info)
c dbg
! B intermediate
call add_target(op_b_inter,ttype_op,.false.,tgt_info)
call xop_parameters(-1,parameters,
& .false.,2,2,0,2)
call set_rule(op_b_inter,ttype_op,DEF_R12INTERM,
& op_b_inter,1,1,
& parameters,1,tgt_info)
! R12^{2} integrals
call add_target(op_ff,ttype_op,.false.,tgt_info)
c if (approx(1:1).eq.'A') then
call set_dependency(op_ff,op_b_inter,tgt_info)
call cloneop_parameters(-1,parameters,
& op_b_inter,.false.) ! <- dagger=.false.
call set_rule(op_ff,ttype_op,CLONE_OP,
& op_ff,1,1,
& parameters,1,tgt_info)
c if(is_keyword_set('method.CC').gt.0.and.(.not.truncate
c & .or.(truncate.and.trunc_type.gt.0)))then
! we also need this operator
call add_target('R.R-X',ttype_op,.false.,tgt_info)
occ_def = 0
! 1
occ_def(IHOLE,1,1) = 2
occ_def(IHOLE,2,2) = 2
! 2
occ_def(IHOLE,1,3) = 1
occ_def(IPART,1,3) = 1
occ_def(IHOLE,2,4) = 2
! 3
occ_def(IHOLE,1,5) = 1
occ_def(IEXTR,1,5) = 1
occ_def(IHOLE,2,6) = 2
! 4
occ_def(IHOLE,1,7) = 2
occ_def(IHOLE,2,8) = 1
occ_def(IPART,2,8) = 1
c ! 5
occ_def(IHOLE,1,9) = 2
occ_def(IHOLE,2,10) = 1
occ_def(IEXTR,2,10) = 1
call op_from_occ_parameters(-1,parameters,2,
c & occ_def,5,2,(/ 0, 2/),10)
& occ_def,5,2,(/ 2, 0/),10)
call set_rule('R.R-X',ttype_op,DEF_OP_FROM_OCC,
& 'R.R-X',1,1,
& parameters,2,tgt_info)
c end if
! {R12^2}BAR integrals
call add_target(op_ffbar,ttype_op,.false.,tgt_info)
call set_dependency(op_ffbar,op_b_inter,tgt_info)
call cloneop_parameters(-1,parameters,
& op_b_inter,.false.) ! <- dagger=.false.
call set_rule(op_ffbar,ttype_op,CLONE_OP,
& op_ffbar,1,1,
& parameters,1,tgt_info)
! X intermediate
call add_target(op_x_inter,ttype_op,.false.,tgt_info)
call xop_parameters(-1,parameters,
& .false.,2,2,0,2)
call set_rule(op_x_inter,ttype_op,DEF_R12INTERM,
& op_x_inter,1,1,
& parameters,1,tgt_info)
c dbg
c call add_target(op_x_test,ttype_op,.false.,tgt_info)
c call set_dependency(op_x_test,op_x_inter,tgt_info)
c call cloneop_parameters(-1,parameters,
c & op_x_inter,.false.) ! <- dagger=.false.
c call set_rule(op_x_test,ttype_op,CLONE_OP,
c & op_x_test,1,1,
c & parameters,1,tgt_info)
c dbg
! C intermediate
call add_target(op_c_inter,ttype_op,.false.,tgt_info)
occ_def = 0
! 1
c occ_def(IHOLE,1,1) = 1
c occ_def(IHOLE,1,2) = 1
c occ_def(IHOLE,2,2) = 2
! 2
c occ_def(IHOLE,1,3) = 1
c occ_def(IPART,1,4) = 1
c occ_def(IHOLE,2,4) = 2
c ! 3 - symmetrized: currently a problem
occ_def(IPART,1,1) = 2
occ_def(IHOLE,2,1) = 2
! 3 - not symmetrized:
c occ_def(IPART,1,5) = 1
c occ_def(IPART,1,6) = 1
c occ_def(IHOLE,2,6) = 2
call op_from_occ_parameters(-1,parameters,2,
& occ_def,1,1,(/ 0, 0/),6)
call set_rule(op_c_inter,ttype_op,DEF_OP_FROM_OCC,
& op_c_inter,1,1,
& parameters,2,tgt_info)
! P intermediate
call add_target(op_p_inter,ttype_op,.false.,tgt_info)
occ_def = 0
! 1
occ_def(IHOLE,1,1) = 2
occ_def(IHOLE,2,2) = 2
call op_from_occ_parameters(-1,parameters,2,
& occ_def,1,2,(/ 0, 0/),2)
call set_rule(op_p_inter,ttype_op,DEF_OP_FROM_OCC,
& op_p_inter,1,1,
& parameters,2,tgt_info)
c dbg
c call add_target(op_p_test,ttype_op,.false.,tgt_info)
c call set_dependency(op_p_test,op_p_inter,tgt_info)
c call cloneop_parameters(-1,parameters,
c & op_p_inter,.false.) ! <- dagger=.false.
c call set_rule(op_p_test,ttype_op,CLONE_OP,
c & op_p_test,1,1,
c & parameters,1,tgt_info)
c dbg
! R12^{2}*G12 integrals
call add_target(op_ffg,ttype_op,.false.,tgt_info)
call set_dependency(op_ffg,op_p_inter,tgt_info)
call cloneop_parameters(-1,parameters,
& op_p_inter,.false.) ! <- dagger=.false.
call set_rule(op_ffg,ttype_op,CLONE_OP,
& op_ffg,1,1,
& parameters,1,tgt_info)
! Z intermediate
call add_target(op_z_inter,ttype_op,.false.,tgt_info)
occ_def = 0
! 1
occ_def(IHOLE,1,1) = 2
occ_def(IHOLE,1,2) = 1
occ_def(IHOLE,2,2) = 1
occ_def(IHOLE,2,3) = 2
! 2
occ_def(IHOLE,1,4) = 2
occ_def(IHOLE,1,5) = 1
occ_def(IPART,2,5) = 1
occ_def(IHOLE,2,6) = 2
c ! 3
c occ_def(IHOLE,1,7) = 2
c occ_def(IPART,1,8) = 1
c occ_def(IHOLE,2,8) = 1
c occ_def(IHOLE,2,9) = 2
c ! 4
c occ_def(IHOLE,1,10) = 2
c occ_def(IPART,1,11) = 1
c occ_def(IPART,2,11) = 1
c occ_def(IHOLE,2,12) = 2
call op_from_occ_parameters(-1,parameters,2,
& occ_def,2,3,(/ 0,0,0,0,0,0/),6)
call set_rule(op_z_inter,ttype_op,DEF_OP_FROM_OCC,
& op_z_inter,1,1,
& parameters,2,tgt_info)
if(.not.frozen_old)then
! Non-anti-symmetrised Hamiltonian integrals.
call add_target(op_g_z,ttype_op,.false.,tgt_info)
occ_def = 0
! 1
occ_def(IHOLE,1,1) = 1
occ_def(IHOLE,2,1) = 1
occ_def(IHOLE,1,2) = 1
occ_def(IHOLE,2,2) = 1
! 2
occ_def(IHOLE,1,3) = 1
occ_def(IPART,2,3) = 1
occ_def(IHOLE,1,4) = 1
occ_def(IHOLE,2,4) = 1
! 3
occ_def(IHOLE,1,5) = 1
occ_def(IEXTR,2,5) = 1
occ_def(IHOLE,1,6) = 1
occ_def(IHOLE,2,6) = 1
! 4
occ_def(IHOLE,1,7) = 1
occ_def(IHOLE,2,7) = 1
occ_def(IHOLE,1,8) = 1
occ_def(IPART,2,8) = 1
! 5
occ_def(IHOLE,1,9) = 1
occ_def(IPART,2,9) = 1
occ_def(IHOLE,1,10) = 1
occ_def(IPART,2,10) = 1
! 6
occ_def(IHOLE,1,11) = 1
occ_def(IEXTR,2,11) = 1
occ_def(IHOLE,1,12) = 1
occ_def(IPART,2,12) = 1
! 7
occ_def(IHOLE,1,13) = 1
occ_def(IHOLE,2,13) = 1
occ_def(IPART,1,14) = 1
occ_def(IHOLE,2,14) = 1
! 8
occ_def(IHOLE,1,15) = 1
occ_def(IPART,2,15) = 1
occ_def(IPART,1,16) = 1
occ_def(IHOLE,2,16) = 1
! 9
occ_def(IHOLE,1,17) = 1
occ_def(IEXTR,2,17) = 1
occ_def(IPART,1,18) = 1
occ_def(IHOLE,2,18) = 1
! 10
occ_def(IHOLE,1,19) = 1
occ_def(IHOLE,2,19) = 1
occ_def(IPART,1,20) = 1
occ_def(IPART,2,20) = 1
! 11
occ_def(IHOLE,1,21) = 1
occ_def(IPART,2,21) = 1
occ_def(IPART,1,22) = 1
occ_def(IPART,2,22) = 1
! 12
occ_def(IHOLE,1,23) = 1
occ_def(IEXTR,2,23) = 1
occ_def(IPART,1,24) = 1
occ_def(IPART,2,24) = 1
! 13
occ_def(IHOLE,1,25) = 1
occ_def(IHOLE,2,25) = 1
occ_def(IHOLE,1,26) = 1
occ_def(IEXTR,2,26) = 1
! 14
occ_def(IHOLE,1,27) = 1
occ_def(IPART,2,27) = 1
occ_def(IHOLE,1,28) = 1
occ_def(IEXTR,2,28) = 1
! 15
occ_def(IHOLE,1,29) = 1
occ_def(IEXTR,2,29) = 1
occ_def(IHOLE,1,30) = 1
occ_def(IEXTR,2,30) = 1
! 16
occ_def(IHOLE,1,31) = 1
occ_def(IHOLE,2,31) = 1
occ_def(IPART,1,32) = 1
occ_def(IEXTR,2,32) = 1
! 17
occ_def(IHOLE,1,33) = 1
occ_def(IPART,2,33) = 1
occ_def(IPART,1,34) = 1
occ_def(IEXTR,2,34) = 1
! 18
occ_def(IHOLE,1,35) = 1
occ_def(IEXTR,2,35) = 1
occ_def(IPART,1,36) = 1
occ_def(IEXTR,2,36) = 1
! 19
occ_def(IHOLE,1,37) = 1
occ_def(IHOLE,2,37) = 1
occ_def(IEXTR,1,38) = 1
occ_def(IHOLE,2,38) = 1
! 20
occ_def(IHOLE,1,39) = 1
occ_def(IPART,2,39) = 1
occ_def(IEXTR,1,40) = 1
occ_def(IHOLE,2,40) = 1
! 21
occ_def(IHOLE,1,41) = 1
occ_def(IEXTR,2,41) = 1
occ_def(IEXTR,1,42) = 1
occ_def(IHOLE,2,42) = 1
! 22
occ_def(IHOLE,1,43) = 1
occ_def(IHOLE,2,43) = 1
occ_def(IEXTR,1,44) = 1
occ_def(IPART,2,44) = 1
! 23
occ_def(IHOLE,1,45) = 1
occ_def(IPART,2,45) = 1
occ_def(IEXTR,1,46) = 1
occ_def(IPART,2,46) = 1
! 24
occ_def(IHOLE,1,47) = 1
occ_def(IEXTR,2,47) = 1
occ_def(IEXTR,1,48) = 1
occ_def(IPART,2,48) = 1
! 25
occ_def(IHOLE,1,49) = 1
occ_def(IHOLE,2,49) = 1
occ_def(IEXTR,1,50) = 1
occ_def(IEXTR,2,50) = 1
! 26
occ_def(IHOLE,1,51) = 1
occ_def(IPART,2,51) = 1
occ_def(IEXTR,1,52) = 1
occ_def(IEXTR,2,52) = 1
call op_from_occ_parameters(-1,parameters,2,
& occ_def,26,2,(/2,2,2,2/),52)
call set_rule(op_g_z,ttype_op,DEF_OP_FROM_OCC,
& op_g_z,1,1,
& parameters,2,tgt_info)
endif
c dbg - test
call add_target('Z0',ttype_op,.false.,tgt_info)
ndef = 2
occ_def = 0
occ_def(IHOLE,1,2) = 1
occ_def(IPART,2,2) = 1
call op_from_occ_parameters(-1,parameters,2,
& occ_def,ndef,1,(/ 0, 0/),6)
call set_rule('Z0',ttype_op,DEF_OP_FROM_OCC,
& 'Z0',1,1,
& parameters,2,tgt_info)
c dbg
c dbg
call add_target(op_z_test,ttype_op,.false.,tgt_info)
call set_dependency(op_z_test,op_z_inter,tgt_info)
call cloneop_parameters(-1,parameters,
& op_z_inter,.false.) ! <- dagger=.false.
call set_rule(op_z_test,ttype_op,CLONE_OP,
& op_z_test,1,1,
& parameters,1,tgt_info)
c dbg
! inverse of B
call add_target(op_b_inv,ttype_op,.false.,tgt_info)
call set_dependency(op_b_inv,op_b_inter,tgt_info)
call cloneop_parameters(-1,parameters,
& op_b_inter,.false.) ! <- dagger=.false.
call set_rule(op_b_inv,ttype_op,CLONE_OP,
& op_b_inv,1,1,
& parameters,1,tgt_info)
! inverse of X
call add_target(op_x_inv,ttype_op,.false.,tgt_info)
call set_dependency(op_x_inv,op_x_inter,tgt_info)
call cloneop_parameters(-1,parameters,
& op_x_inter,.false.) ! <- dagger=.false.
call set_rule(op_x_inv,ttype_op,CLONE_OP,
& op_x_inv,1,1,
& parameters,1,tgt_info)
! Exchange operator, K.
call add_target(op_exchange,ttype_op,.false.,tgt_info)
call hop_parameters(-1,parameters,
& 1,1,2,.true.)
call set_rule(op_exchange,ttype_op,DEF_HAMILTONIAN,
& op_exchange,1,1,
& parameters,1,tgt_info)
! Hartree operator, F+K.
call add_target(op_hartree,ttype_op,.false.,tgt_info)
call hop_parameters(-1,parameters,
& 1,1,2,.true.)
call set_rule(op_hartree,ttype_op,DEF_HAMILTONIAN,
& op_hartree,1,1,
& parameters,1,tgt_info)
*----------------------------------------------------------------------*
* Formulae
*----------------------------------------------------------------------*
c ! R-bar intermediate
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_r12_r12bar
c labels(2) = op_rintbar
c labels(3) = op_rint
c labels(4) = op_rintx
c labels(5) = op_hartree
c ! for GBC: pass op_exchange instead
c call add_target(form_r12_r12bar,ttype_frm,.false.,tgt_info)
c call set_dependency(form_r12_r12bar,op_rintbar,tgt_info)
c call set_dependency(form_r12_r12bar,op_rint,tgt_info)
c call set_dependency(form_r12_r12bar,op_rintx,tgt_info)
c call set_dependency(form_r12_r12bar,op_hartree,tgt_info)
c call form_parameters(-1,
c & parameters,2,title_r12_rbar,ansatz,'RB'//approx)
c call set_rule(form_r12_r12bar,ttype_frm,DEF_R12INTM_CABS,
c & labels,5,1,
c & parameters,2,tgt_info)
c ! R-tilde intermediate
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_r12_r12tilde
c labels(2) = op_rinttilde
c labels(3) = op_rint
c labels(4) = op_rintx
c labels(5) = op_exchange
c call add_target(form_r12_r12tilde,ttype_frm,.false.,tgt_info)
c call set_dependency(form_r12_r12tilde,op_rinttilde,tgt_info)
c call set_dependency(form_r12_r12tilde,op_rint,tgt_info)
c call set_dependency(form_r12_r12tilde,op_rintx,tgt_info)
c call set_dependency(form_r12_r12tilde,op_exchange,tgt_info)
c call form_parameters(-1,
c & parameters,2,title_r12_rtilde,ansatz,'RT'//approx)
c call set_rule(form_r12_r12tilde,ttype_frm,DEF_R12INTM_CABS,
c & labels,5,1,
c & parameters,2,tgt_info)
! formal definition of V
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_vint
labels(2) = op_v_inter
labels(3) = op_ham
labels(4) = op_r12
call add_target(form_r12_vint,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_vint,op_v_inter,tgt_info)
call set_dependency(form_r12_vint,op_ham,tgt_info)
call set_dependency(form_r12_vint,op_r12,tgt_info)
call form_parameters(-1,
& parameters,2,title_r12_vint,0,'gxr')
call set_rule(form_r12_vint,ttype_frm,DEF_R12INTM_FORMAL,
& labels,4,1,
& parameters,2,tgt_info)
! CABS approximation to V
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_vcabs
labels(2) = op_v_inter
labels(3) = op_g_x !op_ham
labels(4) = op_rint
labels(5) = op_gr
! F12: op_gr
call add_target(form_r12_vcabs,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_vcabs,op_v_inter,tgt_info)
call set_dependency(form_r12_vcabs,op_gr,tgt_info)
call set_dependency(form_r12_vcabs,op_g_x,tgt_info)
call set_dependency(form_r12_vcabs,op_rint,tgt_info)
call form_parameters(-1,
& parameters,2,title_r12_vcabs,ansatz,'V '//approx)
call set_rule(form_r12_vcabs,ttype_frm,DEF_R12INTM_CABS,
& labels,5,1,
& parameters,2,tgt_info)
! replace formal G-X operator by H and
! additional G-Acore list (containing core contributions)
call set_dependency(form_r12_vcabs,op_ham,tgt_info)
nint = 1
labels(1) = form_r12_vcabs
labels(2) = form_r12_vcabs
labels(3) = op_g_x//'^+'
labels(4) = op_ham
if (frozen) then
call set_dependency(form_r12_vcabs,'G-Acore',tgt_info)
nint = 2
labels(5) = op_g_x//'^+'
labels(6) = 'G-Acore'
c else if (t1ext.eq.1) then
c call set_dependency(form_r12_vcabs,'H-ext',tgt_info)
c nint = 2
c labels(3) = op_g_x//'^+'
c labels(4) = 'H-ext'
c labels(5) = op_g_x//'^+'
c labels(6) = op_ham
end if
call form_parameters(-1,
& parameters,2,title_r12_vcabs,nint,'---')
call set_rule(form_r12_vcabs,ttype_frm,REPLACE,
& labels,2+nint*2,1,
& parameters,2,tgt_info)
! CABS approximation to V-Ccore
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'V-Ccore-CABS'
labels(2) = 'V-Ccore'
labels(3) = 'G-XX'
labels(4) = op_rint
labels(5) = op_gr_x
call add_target('V-Ccore-CABS',ttype_frm,.false.,tgt_info)
call set_dependency('V-Ccore-CABS',op_v_inter,tgt_info)
call set_dependency('V-Ccore-CABS',op_gr,tgt_info)
call set_dependency('V-Ccore-CABS','G-XX',tgt_info)
call set_dependency('V-Ccore-CABS',op_rint,tgt_info)
call form_parameters(-1,
& parameters,2,'V-Ccore-CABS',ansatz,'V '//approx)
call set_rule('V-Ccore-CABS',ttype_frm,DEF_R12INTM_CABS,
& labels,5,1,
& parameters,2,tgt_info)
! replace formal G-X operator by H and
! additional G-Acore list (containing core contributions)
call set_dependency('V-Ccore-CABS',op_gr_x,tgt_info)
call set_dependency('V-Ccore-CABS',op_ham,tgt_info)
call set_dependency('V-Ccore-CABS',op_ham,tgt_info)
call set_dependency('V-Ccore-CABS','G-Acore',tgt_info)
call set_dependency('V-Ccore-CABS','G-CAcore',tgt_info)
nint = 5
labels(1) = 'V-Ccore-CABS'
labels(2) = 'V-Ccore-CABS'
labels(3) = op_gr_x
labels(4) = op_gr
labels(5) = op_gr_x
labels(6) = 'G.R-Ccore'
labels(7) = 'G-XX^+'
labels(8) = op_ham
labels(9) = 'G-XX^+'
labels(10) = 'G-Acore'
labels(11) = 'G-XX^+'
labels(12) = 'G-CAcore'
call form_parameters(-1,
& parameters,2,title_r12_vcabs,nint,'---')
call set_rule('V-Ccore-CABS',ttype_frm,REPLACE,
& labels,2+nint*2,1,
& parameters,2,tgt_info)
! formal definition of X
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_xint
labels(2) = op_x_inter
c labels(3) = op_rba
labels(3) = op_r12
labels(4) = op_r12
call add_target(form_r12_xint,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_xint,op_x_inter,tgt_info)
call set_dependency(form_r12_xint,op_r12,tgt_info)
call form_parameters(-1,
& parameters,2,title_r12_xint,0,'rxr')
call set_rule(form_r12_xint,ttype_frm,DEF_R12INTM_FORMAL,
& labels,4,1,
& parameters,2,tgt_info)
! CABS approximation to X
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_xcabs
labels(2) = op_x_inter
labels(3) = op_rint
labels(4) = op_rint
labels(5) = op_ff
call add_target(form_r12_xcabs,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_xcabs,op_x_inter,tgt_info)
call set_dependency(form_r12_xcabs,op_ff,tgt_info)
call set_dependency(form_r12_xcabs,op_rint,tgt_info)
call form_parameters(-1,
& parameters,2,title_r12_xcabs,ansatz,'X '//approx)
call set_rule(form_r12_xcabs,ttype_frm,DEF_R12INTM_CABS,
& labels,5,1,
& parameters,2,tgt_info)
c dbg
c ! formal definition of X-test
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_x_test
c labels(2) = op_x_test
c labels(3) = op_r12
c labels(4) = op_r12
c call add_target(form_x_test,ttype_frm,.false.,tgt_info)
c call set_dependency(form_x_test,op_x_test,tgt_info)
c call set_dependency(form_x_test,op_r12,tgt_info)
c call form_parameters(-1,
c & parameters,2,title_x_test,0,'rxr')
c call set_rule(form_x_test,ttype_frm,DEF_R12INTM_FORMAL,
c & labels,4,1,
c & parameters,2,tgt_info)
c
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_x_test
c labels(2) = form_x_test
c labels(3) = op_r12
c labels(4) = op_rint
c call set_dependency(form_x_test,op_rint,tgt_info)
c call form_parameters(-1,
c & parameters,2,title_x_test,1,'---')
c call set_rule(form_x_test,ttype_frm,REPLACE,
c & labels,4,1,
c & parameters,2,tgt_info)
c dbg
! formal definition of B
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_bint
labels(2) = op_b_inter
c labels(3) = op_rba
labels(3) = op_r12
labels(4) = op_ham
labels(5) = op_r12
call add_target(form_r12_bint,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_bint,op_b_inter,tgt_info)
c call set_dependency(form_r12_bint,op_rba,tgt_info)
call set_dependency(form_r12_bint,op_ham,tgt_info)
call set_dependency(form_r12_bint,op_r12,tgt_info)
call form_parameters(-1,
& parameters,2,title_r12_bint,0,'rfxr')
call set_rule(form_r12_bint,ttype_frm,DEF_R12INTM_FORMAL,
& labels,5,1,
& parameters,2,tgt_info)
! CABS approximation to B
labels(1:20)(1:len_target_name) = ' '
labels(1) = form_r12_bcabs
labels(2) = op_b_inter
labels(3) = op_rint
labels(4) = op_ttr
labels(5) = op_rttr
nlab = 5
call add_target(form_r12_bcabs,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_bcabs,op_b_inter,tgt_info)
call set_dependency(form_r12_bcabs,op_rttr,tgt_info)
call set_dependency(form_r12_bcabs,op_rint,tgt_info)
if (approx(1:2).eq.'A''') then
call set_dependency(form_r12_bcabs,op_x_inter,tgt_info)
call set_dependency(form_r12_bcabs,form_r12_xcabs,tgt_info)
call set_dependency(form_r12_bcabs,op_ham,tgt_info)
labels(6) = op_x_inter
labels(7) = op_ham
nlab = 7
else if (approx(1:1).eq.'B') then
call set_dependency(form_r12_bcabs,op_x_inter,tgt_info)
call set_dependency(form_r12_bcabs,form_r12_xcabs,tgt_info)
call set_dependency(form_r12_bcabs,op_rintbar,tgt_info)
call set_dependency(form_r12_bcabs,op_rinttilde,tgt_info)
call set_dependency(form_r12_bcabs,op_ffbar,tgt_info)
call set_dependency(form_r12_bcabs,op_rintbreve,tgt_info)
labels(6) = op_x_inter
labels(7) = op_ham
labels(8) = op_rintbar
labels(9) = op_rinttilde
labels(10) = op_ffbar
labels(11) = '-'
labels(12) = op_rintbreve
nlab = 12
else if (approx(1:1).eq.'C') then
call set_dependency(form_r12_bcabs,op_rdagbar,tgt_info)
call set_dependency(form_r12_bcabs,op_rinttilde,tgt_info)
call set_dependency(form_r12_bcabs,op_ffbar,tgt_info)
call set_dependency(form_r12_bcabs,op_rintbreve,tgt_info)
labels(6) = '-'
labels(7) = '-'
labels(8) = op_rdagbar
labels(9) = op_rinttilde
labels(10) = op_ffbar
labels(11) = '-'
labels(12) = op_rintbreve
nlab = 12
end if
if (ansatz.gt.1) then
call set_dependency(form_r12_bcabs,op_c_inter,tgt_info)
labels(13) = op_c_inter
nlab = 13
end if
approx(12:12) = 'S' ! set symmetrization flag
call form_parameters(-1,
& parameters,2,title_r12_bcabs,ansatz,'B '//approx)
approx(12:12) = ' ' ! unset flag
call set_rule(form_r12_bcabs,ttype_frm,DEF_R12INTM_CABS,
& labels,nlab,1,
& parameters,2,tgt_info)
! formal definition of C intermediate
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_cint
labels(2) = op_c_inter
labels(3) = op_ham
labels(4) = op_r12
call add_target(form_r12_cint,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_cint,op_c_inter,tgt_info)
call set_dependency(form_r12_cint,op_r12,tgt_info)
call set_dependency(form_r12_cint,op_ham,tgt_info)
call form_parameters(-1,
c & parameters,2,title_r12_cint,0,'fxr')
& parameters,2,title_r12_cint,0,'fr')
call set_rule(form_r12_cint,ttype_frm,DEF_R12INTM_FORMAL,
& labels,4,1,
& parameters,2,tgt_info)
! CABS approximation to C intermediate
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_ccabs
labels(2) = op_c_inter
if (approx(1:1).eq.'B') then
labels(3) = op_rint
labels(4) = op_ham
labels(5) = op_ttr
labels(6) = op_rintbar
labels(7) = op_rinttilde
nlab = 7
else ! use this one for 3A and 3C:
labels(3) = op_rint
labels(4) = op_ham
nlab = 4
end if
call add_target(form_r12_ccabs,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_ccabs,op_c_inter,tgt_info)
call set_dependency(form_r12_ccabs,op_rint,tgt_info)
call set_dependency(form_r12_ccabs,op_ham,tgt_info)
call form_parameters(-1,
& parameters,2,title_r12_ccabs,ansatz,'C '//approx)
c & parameters,2,title_r12_ccabs,ansatz,'C '//
c & 'C ')
call set_rule(form_r12_ccabs,ttype_frm,DEF_R12INTM_CABS,
& labels,nlab,1,
& parameters,2,tgt_info)
! formal definition of P
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_pint
labels(2) = op_p_inter
labels(3) = op_r12
labels(4) = op_ham
labels(5) = op_r12
call add_target(form_r12_pint,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_pint,op_p_inter,tgt_info)
call set_dependency(form_r12_pint,op_ham,tgt_info)
call set_dependency(form_r12_pint,op_r12,tgt_info)
call form_parameters(-1,
& parameters,2,title_r12_pint,0,'P')
call set_rule(form_r12_pint,ttype_frm,DEF_R12INTM_FORMAL,
& labels,5,1,
& parameters,2,tgt_info)
if(.not.frozen_old)then
! CABS approximation to P
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_pcabs
labels(2) = op_p_inter
labels(3) = op_rint
labels(4) = op_rint ! dummy, unused
c labels(5) = op_gr
c labels(6) = op_v_inter
labels(5) = op_gr_x
labels(6) = op_v_x
labels(7) = op_ffg
call add_target(form_r12_pcabs,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_pcabs,op_p_inter,tgt_info)
call set_dependency(form_r12_pcabs,op_ffg,tgt_info)
c call set_dependency(form_r12_pcabs,op_gr,tgt_info)
call set_dependency(form_r12_pcabs,op_gr_x,tgt_info)
c call set_dependency(form_r12_pcabs,op_g_x,tgt_info)
call set_dependency(form_r12_pcabs,op_rint,tgt_info)
c call set_dependency(form_r12_pcabs,op_v_inter,tgt_info)
call set_dependency(form_r12_pcabs,op_v_x,tgt_info)
approx(12:12) = 'S' ! set symmetrization flag
call form_parameters(-1,
& parameters,2,title_r12_pcabs,ansatz,'P '//approx)
approx(12:12) = ' ' ! unset flag
call set_rule(form_r12_pcabs,ttype_frm,DEF_R12INTM_CABS,
& labels,7,1,
& parameters,2,tgt_info)
! replace formal operators by G.R-X and V-X
call set_dependency(form_r12_pcabs,op_gr,tgt_info)
call set_dependency(form_r12_pcabs,op_v_inter,tgt_info)
nint = 2
labels(1) = form_r12_pcabs
labels(2) = form_r12_pcabs
labels(3) = op_gr_x
labels(4) = op_gr
c labels(3) = op_gr_x//'^+'
c labels(4) = op_gr//'^+'
labels(5) = op_v_x//'^+'
labels(6) = op_v_inter//'^+'
if (frozen) then
nint = 4
call set_dependency(form_r12_pcabs,'G.R-Ccore',tgt_info)
call set_dependency(form_r12_pcabs,'V-Ccore',tgt_info)
c labels(7) = op_gr_x//'^+'
c labels(8) = 'G.R-Ccore^+'
labels(7) = op_gr_x
labels(8) = 'G.R-Ccore'
labels(9) = op_v_x//'^+'
labels(10) = 'V-Ccore^+'
end if
call form_parameters(-1,
& parameters,2,title_r12_pcabs,nint,'---')
call set_rule(form_r12_pcabs,ttype_frm,REPLACE,
& labels,2+nint*2,1,
& parameters,2,tgt_info)
endif
c dbg
c ! formal definition of P-test
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_p_test
c labels(2) = op_p_test
c labels(3) = op_r12
c labels(4) = op_ham
c labels(5) = op_r12
c call add_target(form_p_test,ttype_frm,.false.,tgt_info)
c call set_dependency(form_p_test,op_p_test,tgt_info)
c call set_dependency(form_p_test,op_ham,tgt_info)
c call set_dependency(form_p_test,op_r12,tgt_info)
c call form_parameters(-1,
c & parameters,2,title_p_test,0,'P')
c call set_rule(form_p_test,ttype_frm,DEF_R12INTM_FORMAL,
c & labels,5,1,
c & parameters,2,tgt_info)
c
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_p_test
c labels(2) = form_p_test
c labels(3) = op_r12
c labels(4) = op_rint
c call set_dependency(form_p_test,op_rint,tgt_info)
c call form_parameters(-1,
c & parameters,2,title_p_test,1,'---')
c call set_rule(form_p_test,ttype_frm,REPLACE,
c & labels,4,1,
c & parameters,2,tgt_info)
c
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_p_test
c labels(2) = form_p_test
c labels(3) = op_ham
c labels(4) = op_g_x
c call set_dependency(form_p_test,op_g_x,tgt_info)
c call form_parameters(-1,
c & parameters,2,title_p_test,1,'---')
c call set_rule(form_p_test,ttype_frm,REPLACE,
c & labels,4,1,
c & parameters,2,tgt_info)
c dbg
! formal definition of Z
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_zint
labels(2) = op_z_inter
labels(3) = op_r12
labels(4) = op_ham
labels(5) = op_r12
if(truncate.and.(trunc_type.eq.2.or.trunc_type.eq.3))then
call add_target(form_r12_zint,ttype_frm,.true.,tgt_info)
else
call add_target(form_r12_zint,ttype_frm,.false.,tgt_info)
endif
call set_dependency(form_r12_zint,op_z_inter,tgt_info)
call set_dependency(form_r12_zint,op_r12,tgt_info)
call set_dependency(form_r12_zint,op_ham,tgt_info)
call set_dependency(form_r12_zint,op_r12,tgt_info)
call form_parameters(-1,
& parameters,2,title_r12_zint,0,'Z')
call set_rule(form_r12_zint,ttype_frm,DEF_R12INTM_FORMAL,
& labels,5,1,
& parameters,2,tgt_info)
if(.not.frozen_old)then
! CABS approximation to Z.
labels(1:10)(1:len_target_name) = ' '
labels(1) = form_r12_zcabs
labels(2) = op_z_inter
labels(3) = op_rint
labels(4) = op_g_z
labels(5) = 'R.R-X'
call add_target(form_r12_zcabs,ttype_frm,.false.,tgt_info)
call set_dependency(form_r12_zcabs,op_z_inter,tgt_info)
call set_dependency(form_r12_zcabs,'R.R-X',tgt_info)
call set_dependency(form_r12_zcabs,op_rint,tgt_info)
call set_dependency(form_r12_zcabs,op_g_z,tgt_info)
c approx(12:12) = 'S' ! set symmetrization flag
call form_parameters(-1,
& parameters,2,title_r12_zcabs,ansatz,'Z '//approx)
c approx(12:12) = ' ' ! unset flag
call set_rule(form_r12_zcabs,ttype_frm,DEF_R12INTM_CABS,
& labels,5,1,
& parameters,2,tgt_info)
endif
c dbg - test
call add_target('Z0TEST-FRM',ttype_frm,.false.,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'Z0TEST-FRM'
labels(2) = 'Z0'
labels(3) = 'Z0'
labels(4) = op_z_inter
labels(5) = op_z_inter
labels(6) = op_z_inter
labels(7) = 'Z0'
idx_sv(1:5) = (/1,2,2,2,1/)
iblkmin(1:5) = -1
iblkmax(1:5) = -1
nconnect = 0
connect = 0
navoid = 0
ninproj = 0
call set_dependency('Z0TEST-FRM','Z0',tgt_info)
call set_dependency('Z0TEST-FRM',op_z_inter,tgt_info)
call expand_parameters(-1,
& parameters,3,
& 'XXX',5,idx_sv,iblkmin,iblkmax,
& connect,nconnect,
& 0,navoid,
& 0,ninproj)
call set_rule('Z0TEST-FRM',ttype_frm,EXPAND_OP_PRODUCT,
& labels,7,1,
& parameters,3,tgt_info)
c dbg
c dbg
c ! formal definition of Z-test
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_z_test
c labels(2) = op_z_test
c labels(3) = op_r12
cc labels(4) = op_ham ! Full
c labels(4) = op_g_z ! Coulomb or exchange
c labels(5) = op_r12
c call add_target(form_z_test,ttype_frm,.false.,tgt_info)
c call set_dependency(form_z_test,op_z_test,tgt_info)
cc call set_dependency(form_z_test,op_ham,tgt_info) ! Full
c call set_dependency(form_z_test,op_g_z,tgt_info) ! Coulomb or exchnage
c call set_dependency(form_z_test,op_r12,tgt_info)
c call form_parameters(-1,
cc & parameters,2,title_z_test,0,'Z') ! Full
c & parameters,2,title_z_test,0,'ZT') ! Coulomb or exchange.
c call set_rule(form_z_test,ttype_frm,DEF_R12INTM_FORMAL,
c & labels,5,1,
c & parameters,2,tgt_info)
c
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_z_test
c labels(2) = form_z_test
c labels(3) = op_r12
c labels(4) = op_rint
c call set_dependency(form_z_test,op_rint,tgt_info)
c call form_parameters(-1,
c & parameters,2,title_z_test,1,'---')
c call set_rule(form_z_test,ttype_frm,REPLACE,
c & labels,4,1,
c & parameters,2,tgt_info)
! Only if full.
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = form_z_test
c labels(2) = form_z_test
c labels(3) = op_ham
c labels(4) = op_g_x
c call set_dependency(form_z_test,op_g_x,tgt_info)
c call form_parameters(-1,
c & parameters,2,title_z_test,1,'---')
c call set_rule(form_z_test,ttype_frm,REPLACE,
c & labels,4,1,
c & parameters,2,tgt_info)
c dbg
*----------------------------------------------------------------------*
* Opt. Formulae
*----------------------------------------------------------------------*
! set V
labels(1:10)(1:len_target_name) = ' '
labels(1) = fopt_r12_vcabs
labels(2) = form_r12_vcabs
ncat = 1
nint = 0
call add_target(fopt_r12_vcabs,ttype_frm,.false.,tgt_info)
call set_dependency(fopt_r12_vcabs,form_r12_vcabs,tgt_info)
call set_dependency(fopt_r12_vcabs,mel_gr,tgt_info)
call set_dependency(fopt_r12_vcabs,mel_v_def,tgt_info)
c call set_dependency(fopt_r12_vcabs,mel_gintx,tgt_info)
call set_dependency(fopt_r12_vcabs,mel_ham,tgt_info)
call set_dependency(fopt_r12_vcabs,mel_rint,tgt_info)
if (frozen)
& call set_dependency(fopt_r12_vcabs,'G-Ac-INT',tgt_info)
call opt_parameters(-1,parameters,ncat,nint)
call set_rule(fopt_r12_vcabs,ttype_frm,OPTIMIZE,
& labels,ncat+nint+1,1,
& parameters,1,tgt_info)
! set V-Ccore
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'V-Ccore-OPT'
labels(2) = 'V-Ccore-CABS'
ncat = 1
nint = 0
call add_target('V-Ccore-OPT',ttype_frm,.false.,tgt_info)
call set_dependency('V-Ccore-OPT','V-Ccore-CABS',tgt_info)
call set_dependency('V-Ccore-OPT','G-Ac-INT',tgt_info)
call set_dependency('V-Ccore-OPT','G-CAc-INT',tgt_info)
call set_dependency('V-Ccore-OPT','G.R-Cc-INT',tgt_info)
call set_dependency('V-Ccore-OPT','DEF-V-Cc-INTER',tgt_info)
call set_dependency('V-Ccore-OPT',mel_rint,tgt_info)
call opt_parameters(-1,parameters,ncat,nint)
call set_rule('V-Ccore-OPT',ttype_frm,OPTIMIZE,
& labels,ncat+nint+1,1,
& parameters,1,tgt_info)
! set X
labels(1:10)(1:len_target_name) = ' '
labels(1) = fopt_r12_xcabs
labels(2) = form_r12_xcabs
ncat = 1
nint = 0
call add_target(fopt_r12_xcabs,ttype_frm,.false.,tgt_info)
call set_dependency(fopt_r12_xcabs,form_r12_xcabs,tgt_info)
call set_dependency(fopt_r12_xcabs,mel_x_def,tgt_info)
call set_dependency(fopt_r12_xcabs,mel_ff,tgt_info)
call set_dependency(fopt_r12_xcabs,mel_rint,tgt_info)
call opt_parameters(-1,parameters,ncat,nint)
call set_rule(fopt_r12_xcabs,ttype_frm,OPTIMIZE,
& labels,ncat+nint+1,1,
& parameters,1,tgt_info)
! set B
labels(1:10)(1:len_target_name) = ' '
labels(1) = fopt_r12_bcabs
labels(2) = form_r12_bcabs
ncat = 1
nint = 0
call add_target(fopt_r12_bcabs,ttype_frm,.false.,tgt_info)
call set_dependency(fopt_r12_bcabs,form_r12_bcabs,tgt_info)
call set_dependency(fopt_r12_bcabs,mel_b_def,tgt_info)
call set_dependency(fopt_r12_bcabs,mel_rttr,tgt_info)
call set_dependency(fopt_r12_bcabs,mel_ham,tgt_info)
call set_dependency(fopt_r12_bcabs,mel_rint,tgt_info)
if (approx(1:2).ne.'A '.and.approx(1:1).ne.'C') then
call set_dependency(fopt_r12_bcabs,mel_x_def,tgt_info)
if (approx(1:1).eq.'B') then
call set_dependency(form_r12_bcabs,mel_rinttilde,tgt_info)
call set_dependency(form_r12_bcabs,mel_rintbar,tgt_info)
call set_dependency(form_r12_bcabs,mel_ffbar,tgt_info)
call set_dependency(form_r12_bcabs,mel_rdagbar,tgt_info)
call set_dependency(form_r12_bcabs,mel_rintbreve,tgt_info)
end if
else if (approx(1:1).eq.'C') then
call set_dependency(form_r12_bcabs,mel_rdagbar,tgt_info)
call set_dependency(form_r12_bcabs,mel_rinttilde,tgt_info)
call set_dependency(form_r12_bcabs,mel_ffbar,tgt_info)
call set_dependency(form_r12_bcabs,mel_rdagbar,tgt_info)
call set_dependency(form_r12_bcabs,mel_rintbreve,tgt_info)
end if
if (ansatz.gt.1) then
call set_dependency(form_r12_bcabs,mel_c_def,tgt_info)
end if
call opt_parameters(-1,parameters,ncat,nint)
call set_rule(fopt_r12_bcabs,ttype_frm,OPTIMIZE,
& labels,ncat+nint+1,1,
& parameters,1,tgt_info)
if(.not.frozen_old)then
! set P
labels(1:10)(1:len_target_name) = ' '
labels(1) = fopt_r12_pcabs
labels(2) = form_r12_pcabs
ncat = 1
nint = 0
call add_target(fopt_r12_pcabs,ttype_frm,.false.,tgt_info)
call set_dependency(fopt_r12_pcabs,form_r12_pcabs,tgt_info)
call set_dependency(fopt_r12_pcabs,mel_p_def,tgt_info)
call set_dependency(fopt_r12_pcabs,mel_v_def,tgt_info)
call set_dependency(fopt_r12_pcabs,mel_rint,tgt_info)
c call set_dependency(fopt_r12_pcabs,mel_gintx,tgt_info)
call set_dependency(fopt_r12_pcabs,mel_ffg,tgt_info)
call set_dependency(fopt_r12_pcabs,mel_gr,tgt_info)
if (frozen) then
call set_dependency(fopt_r12_pcabs,'G.R-Cc-INT',tgt_info)
call set_dependency(fopt_r12_pcabs,'DEF-V-Cc-INTER',tgt_info)
end if
call opt_parameters(-1,parameters,ncat,nint)
call set_rule(fopt_r12_pcabs,ttype_frm,OPTIMIZE,
& labels,ncat+nint+1,1,
& parameters,1,tgt_info)
endif
if(.not.frozen_old)then
! set Z
labels(1:10)(1:len_target_name) = ' '
labels(1) = fopt_r12_zcabs
labels(2) = form_r12_zcabs
ncat = 1
nint = 0
call add_target(fopt_r12_zcabs,ttype_frm,.false.,tgt_info)
call set_dependency(fopt_r12_zcabs,form_r12_zcabs,tgt_info)
call set_dependency(fopt_r12_zcabs,mel_z_def,tgt_info)
call set_dependency(fopt_r12_zcabs,mel_rint,tgt_info)
call set_dependency(fopt_r12_zcabs,mel_gintz,tgt_info)
call set_dependency(fopt_r12_zcabs,'R.R-INTX',tgt_info)
call opt_parameters(-1,parameters,ncat,nint)
call set_rule(fopt_r12_zcabs,ttype_frm,OPTIMIZE,
& labels,ncat+nint+1,1,
& parameters,1,tgt_info)
endif
! set Z (direct eval)
call add_target('ZINT_R12_DIR',ttype_frm,.false.,tgt_info)
call set_dependency('ZINT_R12_DIR',form_r12_zint,tgt_info)
call set_dependency('ZINT_R12_DIR',mel_z_def,tgt_info)
call set_dependency('ZINT_R12_DIR',mel_rint,tgt_info)
call set_dependency('ZINT_R12_DIR',mel_ham,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'ZINT_R12_DIR'
labels(2) = form_r12_zint
labels(3) = op_r12
labels(4) = op_rint
labels(5) = op_r12//'^+'
labels(6) = op_rint//'^+'
nint = 2
call form_parameters(-1,
& parameters,2,'Z direct',nint,'---')
call set_rule('ZINT_R12_DIR',ttype_frm,REPLACE,
& labels,2+nint*2,1,
& parameters,2,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'ZINT_R12_DIR'
labels(2) = 'ZINT_R12_DIR'
ncat = 1
nint = 0
call opt_parameters(-1,parameters,ncat,nint)
call set_rule('ZINT_R12_DIR',ttype_frm,OPTIMIZE,
& labels,ncat+nint+1,1,
& parameters,1,tgt_info)
c dbg - test
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'Z0TEST-OPT'
labels(2) = 'Z0TEST-FRM'
ncat = 1
nint = 0
call add_target('Z0TEST-OPT',ttype_frm,.false.,tgt_info)
call set_dependency('Z0TEST-OPT','Z0TEST-FRM',tgt_info)
call set_dependency('Z0TEST-OPT',mel_z_def,tgt_info)
call set_dependency('Z0TEST-OPT','DEF-Z0TEST',tgt_info)
call opt_parameters(-1,parameters,ncat,nint)
call set_rule('Z0TEST-OPT',ttype_frm,OPTIMIZE,
& labels,ncat+nint+1,1,
& parameters,1,tgt_info)
c dbg
! set C intermediate
labels(1:10)(1:len_target_name) = ' '
labels(1) = fopt_r12_ccabs
labels(2) = form_r12_ccabs
ncat = 1
nint = 0
call add_target(fopt_r12_ccabs,ttype_frm,.false.,tgt_info)
call set_dependency(fopt_r12_ccabs,form_r12_ccabs,tgt_info)
call set_dependency(fopt_r12_ccabs,mel_c_def,tgt_info)
call opt_parameters(-1,parameters,ncat,nint)
call set_rule(fopt_r12_ccabs,ttype_frm,OPTIMIZE,
& labels,ncat+nint+1,1,
& parameters,1,tgt_info)
*----------------------------------------------------------------------*
* ME-lists
*----------------------------------------------------------------------*
! ----------------------------
! A) integrals to be imported:
! ----------------------------
! R12integrals
call add_target(mel_rint,ttype_opme,.false.,tgt_info)
call set_dependency(mel_rint,op_rint,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rint
labels(2) = op_rint
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_rint,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rint
call import_parameters(-1,parameters,'F12_INT',env_type)
call set_rule(mel_rint,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
c ! R12integrals (extended list)
c call add_target(mel_rintx,ttype_opme,.false.,tgt_info)
c call set_dependency(mel_rintx,op_rintx,tgt_info)
c ! (a) define
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = mel_rintx
c labels(2) = op_rintx
c call me_list_parameters(-1,parameters,
c & msc,0,1,0,0,.false.)
c call set_rule(mel_rintx,ttype_opme,DEF_ME_LIST,
c & labels,2,1,
c & parameters,1,tgt_info)
c ! (b) import
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = mel_rintx
c call import_parameters(-1,parameters,'F12_INT',env_type)
c call set_rule(mel_rintx,ttype_opme,IMPORT,
c & labels,1,1,
c & parameters,1,tgt_info)
! special one-electron integral list
call add_target('F-X-INT',ttype_opme,.false.,tgt_info)
call set_dependency('F-X-INT','F-X',tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'F-X-INT'
labels(2) = 'F-X'
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule('F-X-INT',ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'F-X-INT'
call import_parameters(-1,parameters,'F_INT',env_type)
call set_rule('F-X-INT',ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! special two-electron integral list
call add_target(mel_gintx,ttype_opme,.false.,tgt_info)
call set_dependency(mel_gintx,op_g_x,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_gintx
labels(2) = op_g_x
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_gintx,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_gintx
call import_parameters(-1,parameters,'G_INT',env_type)
call set_rule(mel_gintx,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! new special two-electron integral list
call add_target('G-Ac-INT',ttype_opme,.false.,tgt_info)
call set_dependency('G-Ac-INT','G-Acore',tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'G-Ac-INT'
labels(2) = 'G-Acore'
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule('G-Ac-INT',ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'G-Ac-INT'
call import_parameters(-1,parameters,'G_INT',env_type)
call set_rule('G-Ac-INT',ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! new special two-electron integral list (extended list with HX|HX block)
call add_target('H-ext-INT',ttype_opme,.false.,tgt_info)
call set_dependency('H-ext-INT','H-ext',tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'H-ext-INT'
labels(2) = 'H-ext'
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule('H-ext-INT',ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'H-ext-INT'
call import_parameters(-1,parameters,'G_INT',env_type)
call set_rule('H-ext-INT',ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! new additional two-electron integral list
call add_target('G-CAc-INT',ttype_opme,.false.,tgt_info)
call set_dependency('G-CAc-INT','G-CAcore',tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'G-CAc-INT'
labels(2) = 'G-CAcore'
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule('G-CAc-INT',ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'G-CAc-INT'
call import_parameters(-1,parameters,'G_INT',env_type)
call set_rule('G-CAc-INT',ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
if(.not.frozen_old)then
! special two-electron integral list 2
call add_target(mel_gintz,ttype_opme,.false.,tgt_info)
call set_dependency(mel_gintz,op_g_z,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_gintz
labels(2) = op_g_z
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.true.)
c & 0,0,1,0,0,.false.)
call set_rule(mel_gintz,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_gintz
call import_parameters(-1,parameters,'G_INT',env_type)
call set_rule(mel_gintz,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
endif
! [T1+T2,R12] integrals
call add_target(mel_ttr,ttype_opme,.false.,tgt_info)
call set_dependency(mel_ttr,op_ttr,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_ttr
labels(2) = op_ttr
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_ttr,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_ttr
call import_parameters(-1,parameters,'TTF_INT',env_type)
call set_rule(mel_ttr,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! R12[T1+T2,R12] intergrals (for f(R12))
call add_target(mel_rttr,ttype_opme,.false.,tgt_info)
call set_dependency(mel_rttr,op_rttr,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rttr
labels(2) = op_rttr
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_rttr,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rttr
call import_parameters(-1,parameters,'FTF_INT',env_type)
call set_rule(mel_rttr,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! R12^2 integrals
call add_target(mel_ff,ttype_opme,.false.,tgt_info)
call set_dependency(mel_ff,op_ff,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_ff
labels(2) = op_ff
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_ff,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_ff
call import_parameters(-1,parameters,'FF_INT',env_type)
call set_rule(mel_ff,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! R12^2 integrals II
call add_target('R.R-INTX',ttype_opme,.false.,tgt_info)
call set_dependency('R.R-INTX','R.R-X',tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'R.R-INTX'
labels(2) = 'R.R-X'
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule('R.R-INTX',ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'R.R-INTX'
call import_parameters(-1,parameters,'FF_INT',env_type)
call set_rule('R.R-INTX',ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! {R12^2}BAR integrals
call add_target(mel_ffbar,ttype_opme,.false.,tgt_info)
call set_dependency(mel_ffbar,op_ffbar,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_ffbar
labels(2) = op_ffbar
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_ffbar,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_ffbar
call import_parameters(-1,parameters,'FFBAR_INT',env_type)
call set_rule(mel_ffbar,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! G.R12 integrals (for f(R12))
call add_target(mel_gr,ttype_opme,.false.,tgt_info)
call set_dependency(mel_gr,op_gr,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_gr
labels(2) = op_gr
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_gr,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_gr
call import_parameters(-1,parameters,'FG_INT',env_type)
call set_rule(mel_gr,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
call add_target('G.R-Cc-INT',ttype_opme,.false.,tgt_info)
call set_dependency('G.R-Cc-INT','G.R-Ccore',tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'G.R-Cc-INT'
labels(2) = 'G.R-Ccore'
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule('G.R-Cc-INT',ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'G.R-Cc-INT'
call import_parameters(-1,parameters,'FG_INT',env_type)
call set_rule('G.R-Cc-INT',ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! R12^2*G integrals
call add_target(mel_ffg,ttype_opme,.false.,tgt_info)
call set_dependency(mel_ffg,op_ffg,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_ffg
labels(2) = op_ffg
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_ffg,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_ffg
call import_parameters(-1,parameters,'FFG_INT',env_type)
call set_rule(mel_ffg,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! R12BAR integrals
call add_target(mel_rintbar,ttype_opme,.false.,tgt_info)
call set_dependency(mel_rintbar,op_rintbar,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rintbar
labels(2) = op_rintbar
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_rintbar,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rintbar
call import_parameters(-1,parameters,'F12BAR_INT',env_type)
call set_rule(mel_rintbar,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! R12tilde integrals
call add_target(mel_rinttilde,ttype_opme,.false.,tgt_info)
call set_dependency(mel_rinttilde,op_rinttilde,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rinttilde
labels(2) = op_rinttilde
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_rinttilde,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rinttilde
call import_parameters(-1,parameters,'F12TLD_INT',env_type)
call set_rule(mel_rinttilde,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! R12BAR^+ integrals
call add_target(mel_rdagbar,ttype_opme,.false.,tgt_info)
call set_dependency(mel_rdagbar,op_rdagbar,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rdagbar
labels(2) = op_rdagbar
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_rdagbar,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rdagbar
call import_parameters(-1,parameters,'FDGBAR_INT',env_type)
call set_rule(mel_rdagbar,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! R12BREVE integrals
call add_target(mel_rintbreve,ttype_opme,.false.,tgt_info)
call set_dependency(mel_rintbreve,op_rintbreve,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_rintbreve
labels(2) = op_rintbreve
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_rintbreve,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
c ! OLD:
c ! (b) import
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = mel_rintbreve
c call import_parameters(-1,parameters,'F12BRV_INT',env_type)
c call set_rule(mel_rintbreve,ttype_opme,IMPORT,
c & labels,1,1,
c & parameters,1,tgt_info)
! (b) define formula
call set_dependency(mel_rintbreve,'F-X',tgt_info)
call set_dependency(mel_rintbreve,'F-X-INT',tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'BBRV_FRM'
labels(2) = op_rintbreve
labels(3) = op_rint
labels(4) = '-'
labels(5) = 'F-X'
call form_parameters(-1,
& parameters,2,'R12BREVE',3,'RV')
call set_rule(mel_rintbreve,ttype_frm,DEF_R12INTM_CABS,
& labels,5,1,
& parameters,2,tgt_info)
call form_parameters(-1,
& parameters,2,'stdout',0,'---')
call set_rule(mel_rintbreve,ttype_frm,PRINT_FORMULA,
& labels,1,0,
& parameters,2,tgt_info)
! (c) optimize formula
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'BBRV_OPT'
labels(2) = 'BBRV_FRM'
call opt_parameters(-1,parameters,1,0)
call set_rule(mel_rintbreve,ttype_frm,OPTIMIZE,
& labels,2,1,
& parameters,1,tgt_info)
! (d) evaluate
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'BBRV_OPT'
call set_rule(mel_rintbreve,ttype_opme,EVAL,
& labels,1,0,
& parameters,0,tgt_info)
! Exchange integrals, K.
call add_target(mel_exchange,ttype_opme,.false.,tgt_info)
call set_dependency(mel_exchange,op_exchange,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_exchange
labels(2) = op_exchange
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_exchange,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_exchange
call import_parameters(-1,parameters,'K_INT',env_type)
call set_rule(mel_exchange,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
! Hartree integrals, F+K.
call add_target(mel_hartree,ttype_opme,.false.,tgt_info)
call set_dependency(mel_hartree,op_hartree,tgt_info)
call set_dependency(mel_hartree,mel_exchange,tgt_info)
call set_dependency(mel_hartree,mel_ham,tgt_info)
! (a) define
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_hartree
labels(2) = op_hartree
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_hartree,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! (b) calculate
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_hartree
labels(2) = mel_ham
labels(3) = mel_exchange
call add_parameters(-1,parameters,2,(/1d0,1d0/),2)
call set_rule(mel_hartree,ttype_opme,ADD,
& labels,3,1,
& parameters,1,tgt_info)
! ----------------------------------------
! B) definition of lists for intermediates
! ----------------------------------------
! V-list
call add_target(mel_v_def,ttype_opme,.false.,tgt_info)
call set_dependency(mel_v_def,op_v_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_v_inter
labels(2) = op_v_inter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_v_def,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! V-Ccore-list
call add_target('DEF-V-Cc-INTER',ttype_opme,.false.,tgt_info)
call set_dependency('DEF-V-Cc-INTER','V-Ccore',tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'V-Cc-INTER'
labels(2) = 'V-Ccore'
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule('DEF-V-Cc-INTER',ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! X-list
call add_target(mel_x_def,ttype_opme,.false.,tgt_info)
call set_dependency(mel_x_def,op_x_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_x_inter
labels(2) = op_x_inter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_x_def,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
c dbg
c ! X-test
c call add_target(mel_x_test_def,ttype_opme,.false.,tgt_info)
c call set_dependency(mel_x_test_def,op_x_test,tgt_info)
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = mel_x_test
c labels(2) = op_x_test
c call me_list_parameters(-1,parameters,
c & msc,0,1,0,0,.false.)
c call set_rule(mel_x_test_def,ttype_opme,DEF_ME_LIST,
c & labels,2,1,
c & parameters,1,tgt_info)
c dbg
! B-list
call add_target(mel_b_def,ttype_opme,.false.,tgt_info)
call set_dependency(mel_b_def,op_b_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_b_inter
labels(2) = op_b_inter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_b_def,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! P-list
if(frozen_old)then
call add_target(mel_p_def,ttype_opme,.false.,tgt_info)
call set_dependency(mel_p_def,op_p_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_p_def
labels(2) = op_p_inter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_p_def,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_p_def
call import_parameters(-1,parameters,'P_LIST',env_type)
call set_rule(mel_p_def,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
else
call add_target(mel_p_def,ttype_opme,.false.,tgt_info)
call set_dependency(mel_p_def,op_p_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_p_inter
labels(2) = op_p_inter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_p_def,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
endif
c dbg
c ! P-test
c call add_target(mel_p_test_def,ttype_opme,.false.,tgt_info)
c call set_dependency(mel_p_test_def,op_p_test,tgt_info)
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = mel_p_test
c labels(2) = op_p_test
c call me_list_parameters(-1,parameters,
c & msc,0,1,0,0,.false.)
c call set_rule(mel_p_test_def,ttype_opme,DEF_ME_LIST,
c & labels,2,1,
c & parameters,1,tgt_info)
c dbg
! Z-list
if(frozen_old)then
call add_target(mel_z_def,ttype_opme,.false.,tgt_info)
call set_dependency(mel_z_def,op_z_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_z_def
labels(2) = op_z_inter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_z_def,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! import
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_z_def
call import_parameters(-1,parameters,'Z_LIST',env_type)
call set_rule(mel_z_def,ttype_opme,IMPORT,
& labels,1,1,
& parameters,1,tgt_info)
else
call add_target(mel_z_def,ttype_opme,.false.,tgt_info)
call set_dependency(mel_z_def,op_z_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_z_inter
labels(2) = op_z_inter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_z_def,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
endif
c dbg - test
call add_target('DEF-Z0TEST',ttype_opme,.false.,tgt_info)
call set_dependency('DEF-Z0TEST','Z0',tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = 'Z0TEST'
labels(2) = 'Z0'
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule('DEF-Z0TEST',ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
c dbg
c dbg
! Z-test
call add_target(mel_z_test_def,ttype_opme,.false.,tgt_info)
call set_dependency(mel_z_test_def,op_z_test,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_z_test
labels(2) = op_z_test
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_z_test_def,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
c dbg
! C-list
call add_target(mel_c_def,ttype_opme,.false.,tgt_info)
call set_dependency(mel_c_def,op_c_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_c_inter
labels(2) = op_c_inter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_c_def,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
! B^-1 for "diagonal"
call add_target(mel_b_inv,ttype_opme,.false.,tgt_info)
call set_dependency(mel_b_inv,op_b_inv,tgt_info)
call set_dependency(mel_b_inv,eval_r12_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_b_inv
labels(2) = op_b_inv ! actually, B^-1 should have the
c ! contravariant shape
c ! but as long as we do not formally
c ! calculate with
c ! this entity this does not matter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_b_inv,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
labels(1) = mel_b_inv ! output
labels(2) = mel_b_inter ! input
call form_parameters(-1,parameters,2,
& '---',0,'inverse')
call set_rule(mel_b_inv,ttype_opme,INVERT,
& labels,2,1,
& parameters,2,tgt_info)
if(.not.r12fix)then
! diagonal of B(ij) for testing
call add_target(mel_b_dia,ttype_opme,.false.,tgt_info)
call set_dependency(mel_b_dia,op_diar12,tgt_info)
call set_dependency(mel_b_dia,eval_r12_inter,tgt_info)
call set_dependency(mel_b_dia,mel_ham,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_b_dia
labels(2) = op_diar12
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_b_dia,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
labels(1) = mel_b_dia ! output
labels(2) = mel_ham ! input
labels(3) = mel_b_inter ! input
labels(4) = mel_x_inter ! input
call set_rule(mel_b_dia,ttype_opme,PRECONDITIONER,
& labels,4,1,
& parameters,1,tgt_info)
! X^-1 for testing
call add_target(mel_x_inv,ttype_opme,.false.,tgt_info)
call set_dependency(mel_x_inv,op_diar12,tgt_info)
call set_dependency(mel_x_inv,eval_r12_inter,tgt_info)
labels(1:10)(1:len_target_name) = ' '
labels(1) = mel_x_inv
labels(2) = op_x_inter
call me_list_parameters(-1,parameters,
& msc,0,1,0,0,.false.)
call set_rule(mel_x_inv,ttype_opme,DEF_ME_LIST,
& labels,2,1,
& parameters,1,tgt_info)
labels(1) = mel_x_inv ! output
labels(2) = mel_x_inter ! input
call form_parameters(-1,parameters,2,
& '---',0,'inverse')
call set_rule(mel_x_inv,ttype_opme,INVERT,
& labels,2,1,
& parameters,2,tgt_info)
endif
*----------------------------------------------------------------------*
* "phony" targets
*----------------------------------------------------------------------*
! test
c if(.not.pz_eval)then
call add_target(eval_r12_inter,ttype_gen,.false.,tgt_info)
c else
c call add_target(eval_r12_inter,ttype_gen,.true.,tgt_info)
c endif
call set_dependency(eval_r12_inter,mel_ham,tgt_info)
call set_dependency(eval_r12_inter,mel_rint,tgt_info)
call set_dependency(eval_r12_inter,mel_gintx,tgt_info)
call set_dependency(eval_r12_inter,mel_ttr,tgt_info)
call set_dependency(eval_r12_inter,mel_ff,tgt_info)
call set_dependency(eval_r12_inter,mel_gr,tgt_info)
c call set_dependency(eval_r12_inter,mel_v_def,tgt_info)
call set_dependency(eval_r12_inter,mel_x_def,tgt_info)
call set_dependency(eval_r12_inter,mel_b_def,tgt_info)
call set_dependency(eval_r12_inter,'EVAL_V',tgt_info)
if(is_keyword_set('method.CC').gt.0.and.(.not.truncate
& .or.(truncate.and.trunc_type.gt.0)))then
call set_dependency(eval_r12_inter,'EVAL_P',tgt_info)
call set_dependency(eval_r12_inter,'EVAL_Z',tgt_info)
c call set_dependency(eval_r12_inter,mel_ffg,tgt_info)
c if(.not.frozen_old)then
c call set_dependency(eval_r12_inter,mel_p_def,tgt_info)
c call set_dependency(eval_r12_inter,mel_z_def,tgt_info)
c call set_dependency(eval_r12_inter,fopt_r12_pcabs,tgt_info)
c call set_dependency(eval_r12_inter,fopt_r12_zcabs,tgt_info)
c call set_dependency(eval_r12_inter,mel_gintz,tgt_info)
c endif
endif
c call set_dependency(eval_r12_inter,fopt_r12_vcabs,tgt_info)
call set_dependency(eval_r12_inter,fopt_r12_xcabs,tgt_info)
call set_dependency(eval_r12_inter,fopt_r12_bcabs,tgt_info)
if (ansatz.ne.1)then
call set_dependency(eval_r12_inter,fopt_r12_ccabs,tgt_info)
call set_dependency(eval_r12_inter,mel_c_def,tgt_info)
endif
c labels(1:10)(1:len_target_name) = ' '
c labels(1) = fopt_r12_vcabs
c call set_rule(eval_r12_inter,ttype_opme,EVAL,
c & labels,1,0,
c & parameters,0,tgt_info)
labels(1) = fopt_r12_xcabs
call set_rule(eval_r12_inter,ttype_opme,EVAL,
& labels,1,0,
& parameters,0,tgt_info)
if (ansatz.ne.1) then
labels(1) = fopt_r12_ccabs
call set_rule(eval_r12_inter,ttype_opme,EVAL,
& labels,1,0,
& parameters,0,tgt_info)
end if
labels(1) = fopt_r12_bcabs
call set_rule(eval_r12_inter,ttype_opme,EVAL,
& labels,1,0,
& parameters,0,tgt_info)
c if(is_keyword_set('method.CC').gt.0.and.(.not.truncate
c & .or.(truncate.and.trunc_type.gt.0)))then
c if(.not.frozen_old)then
c labels(1) = fopt_r12_pcabs
c call set_rule(eval_r12_inter,ttype_opme,EVAL,
c & labels,1,0,
c & parameters,0,tgt_info)
c
c call set_dependency(eval_r12_inter,'R.R-INTX',tgt_info)
c labels(1) = fopt_r12_zcabs
c call set_rule(eval_r12_inter,ttype_opme,EVAL,
c & labels,1,0,
c & parameters,0,tgt_info)
c
c endif
c endif
call add_target('EVAL_V',ttype_gen,.false.,tgt_info)
call set_dependency('EVAL_V',fopt_r12_vcabs,tgt_info)
c call set_dependency('EVAL_V',mel_ham,tgt_info)
c call set_dependency('EVAL_V',mel_v_def,tgt_info)
c call set_dependency('EVAL_V',mel_rint,tgt_info)
c call set_dependency('EVAL_V',mel_gr,tgt_info)
labels(1) = fopt_r12_vcabs
call set_rule('EVAL_V',ttype_opme,EVAL,
& labels,1,0,
& parameters,0,tgt_info)
c call add_target('EVAL_P',ttype_gen,pz_eval,tgt_info)
call add_target('EVAL_P',ttype_gen,.false.,tgt_info)
call set_dependency('EVAL_P',fopt_r12_pcabs,tgt_info)
call set_dependency('EVAL_P',mel_p_def,tgt_info)
call set_dependency('EVAL_P',mel_rint,tgt_info)
call set_dependency('EVAL_P',mel_ffg,tgt_info)
call set_dependency('EVAL_P',mel_gr,tgt_info)
c call set_dependency('EVAL_P',eval_r12_inter,tgt_info)
if (frozen) then
call set_dependency('EVAL_P','V-Ccore-OPT',tgt_info)
labels(1) = 'V-Ccore-OPT'
call set_rule('EVAL_P',ttype_opme,EVAL,
& labels,1,0,
& parameters,0,tgt_info)
end if
labels(1) = fopt_r12_pcabs
call set_rule('EVAL_P',ttype_opme,EVAL,
& labels,1,0,
& parameters,0,tgt_info)
c call add_target('EVAL_Z',ttype_gen,pz_eval,tgt_info)
call add_target('EVAL_Z',ttype_gen,pz_eval,tgt_info)
call set_dependency('EVAL_Z',mel_z_def,tgt_info)
call set_dependency('EVAL_Z',mel_rint,tgt_info)
call set_dependency('EVAL_Z','R.R-INTX',tgt_info)
if (approx(14:17).eq.'DRCT') then
call set_dependency('EVAL_Z',mel_ham,tgt_info)
call set_dependency('EVAL_Z','ZINT_R12_DIR',tgt_info)
else
call set_dependency('EVAL_Z',mel_gintz,tgt_info)
call set_dependency('EVAL_Z',fopt_r12_zcabs,tgt_info)
end if
if (approx(14:17).eq.'DRCT') then
labels(1) = 'ZINT_R12_DIR'
else
labels(1) = fopt_r12_zcabs
end if
call set_rule('EVAL_Z',ttype_opme,EVAL,
& labels,1,0,
& parameters,0,tgt_info)
c dbg -- test
c call set_dependency('EVAL_Z','Z0TEST-OPT',tgt_info)
c labels(1) = 'Z0TEST-OPT'
c call set_rule('EVAL_Z',ttype_opme,EVAL,
c & labels,1,0,
c & parameters,0,tgt_info)
c dbg
return
contains
subroutine set_fvirt_constr(hpvx_constr,gas_constr)
implicit none
integer, intent(out) ::
& hpvx_constr(2,ngastp,2),
& gas_constr(2,orb_info%ngas,2,2)
integer ::
& idx
hpvx_constr(1:2,1:ngastp,1:2) = 0
gas_constr(1:2,1:orb_info%ngas,1:2,1:2) = 0
print *,'1: ',hpvx_constr
do idx = 1, ngastp
if (idx.eq.IHOLE.or.idx.eq.IVALE) cycle
hpvx_constr(2,idx,1:2) = 1
end do
do idx = 1, orb_info%ngas
if (orb_info%ihpvgas(idx,1).eq.IHOLE.or.
& orb_info%ihpvgas(idx,1).eq.IVALE) cycle
gas_constr(2,idx,1:2,1) = 1
end do
end subroutine
subroutine set_gxx(occ_def)
implicit none
integer, intent(out) ::
& occ_def(ngastp,2,*)
integer ::
& idxc, idxa, occ_c(ngastp), occ_a(ngastp)
occ_def(1:ngastp,1:2,1:4*4) = 0
ndef = 0
do idxc = 1, 4
occ_c = 0
if (idxc.eq.1) occ_c(IHOLE) = 2
if (idxc.eq.2) occ_c(IHOLE) = 1
if (idxc.eq.2) occ_c(IPART) = 1
if (idxc.eq.3) occ_c(IHOLE) = 1
if (idxc.eq.3) occ_c(IEXTR) = 1
if (idxc.eq.4) occ_c(IPART) = 2
do idxa = 1, 4
occ_a = 0
if (idxa.eq.1) occ_a(IHOLE) = 2
if (idxa.eq.2) occ_a(IHOLE) = 1
if (idxa.eq.2) occ_a(IPART) = 1
if (idxa.eq.3) occ_a(IHOLE) = 1
if (idxa.eq.3) occ_a(IEXTR) = 1
if (idxa.eq.4) occ_a(IPART) = 2
ndef = ndef+1
occ_def(1:ngastp,1,ndef) = occ_c(1:ngastp)
occ_def(1:ngastp,2,ndef) = occ_a(1:ngastp)
end do
end do
end subroutine set_gxx
end
| r12_spec/set_r12_general_targets.f |
SUBROUTINE TRTTEM ( TI, PG)
C****
C THIS ROUTINE COMPUTES THE THERMAL LOAD FOR THE ASSYMMETRIC RING ELE
C WITH A TRIANGULAR CROSS SECTION
C****
C ECPT (01) = ELEMENT ID I
C ECPT (02) = SIL A I
C ECPT (03) = SIL B I
C ECPT (04) = SIL C I
C ECPT (05) = MATERIAL ORIENTATION ANGLE(DEGREES)R
C ECPT (07) = MATERIAL ID I
C ECPT (08) TO ECPT (21) = PHI R
C ECPT (22) = COOR. SYS. FOR GRID POINT A I
C ECPT (23) = R-CORD OF GRID A R
C ECPT (24) = Z-CORD OF GRID A R
C ECPT (25) = 0.0 R
C ECPT (26) = CORD. SYS. GRID POINT B (NOT USED) I
C ECPT (27) = R-CORD OF GRID B R
C ECPT (28) = Z-CORD OF GRID B R
C ECPT (29) = 0.0 R
C ECPT (30) = CORD. SYS. GRID POINT C (NOT USED) I
C ECPT (31) = R-CORD OF GRID C R
C ECPT (32) = Z-CORD OF GRID C R
C ECPT (33) = 0.0 R
C ECPT (34) = EL. TEMPERATURE FOR MATERIAL R
C
DIMENSION R(3), Z(3), GABABQ(9,9),DELINT(12),TEO(21)
1, DTT(9),IGP(3),IECPT(34),ICS(3),PG(1),FIJ(9)
2, D(3) ,TL(9) ,TI(3)
C
C . ECPT COMMON BLOCK
COMMON /TRIMEX/ ECPT(34)
C
C . MATERIAL INPUT AND OUTPUT...
COMMON /MATIN/
1 MATIDC ,MATFLG
2, ELTEMP ,STRESS
3, SINTH ,COSTH
C
COMMON /MATOUT/
1 E(3) ,ANU(3)
2, RHO ,G(3)
3, ALF(3) ,TZERO ,GSUBE
4, MOSKP(9) ,SETMAT
COMMON /CONDAS/ CONSTS(5)
EQUIVALENCE (IECPT(1), ECPT(1)), (Z(1), Z1), (Z(2), Z2)
1, ( Z(3), Z3)
2, ( R(1), R1), ( R(2), R2), (R(3), R3)
EQUIVALENCE (CONSTS(1),PI), (CONSTS(4),DEGRAD)
C
C START EXECUTION
C
C STORE ECPT PARAMETERS IN LOCAL VARIABLES
IDEL = IECPT(1)
IGP(1) = IECPT(2)
IGP(2) = IECPT(3)
IGP(3) = IECPT(4)
MATID = IECPT(07)
ICS(1) = IECPT(22)
ICS(2) = IECPT(26)
ICS(3) = IECPT(30)
R(1) = ECPT(23)
R(2) = ECPT(27)
R(3) = ECPT(31)
Z(2) = ECPT(28)
D(2) = ECPT(29)
Z(1) = ECPT(24)
D(1) = ECPT(25)
Z(3) = ECPT(32)
D(3) = ECPT(33)
DGAMA = ECPT(05)
TEMPE = ECPT(34)
C
C COMPUTE THE ELEMENT COORDINATES
ZMIN = AMIN1(Z1, Z2, Z3)
Z1 = Z1 - ZMIN
Z2 = Z2 - ZMIN
Z3 = Z3 - ZMIN
C
C FORM THE TRANSFORMATION MATRIX GABABQ (9X9) FROM FIELD COORDINATES TO
C GRID POINT DEGREES OF FREEDOM
DO 300 I = 1,9
DO 300 J = 1,9
300 GABABQ (I,J) = 0.000
AA = R2 * Z3 + R1 * Z2 + Z1 * R3 - Z2 * R3 - R1 * Z3 - R2 * Z1
AA = 1.0E0 / AA
C1 = AA * ( R2 * Z3 - Z2 * R3)
C2 = - AA * ( Z3 - Z2 )
C3 = AA * ( R3 - R2 )
GABABQ (1,1) = C1
GABABQ (2,4) = C1
GABABQ (3,7) = C1
GABABQ (1,2) = C2
GABABQ (2,5) = C2
GABABQ (3,8) = C2
GABABQ (1,3) = C3
GABABQ(2,6) = C3
GABABQ(3,9) = C3
C1 = -AA * ( R1 * Z3 - Z1 * R3)
C2 = AA * ( Z3 - Z1 )
C3 = -AA * ( R3 - R1 )
GABABQ(4,1) = C1
GABABQ(4,2) = C2
GABABQ(4,3) = C3
GABABQ(5,4) = C1
GABABQ(5,5) = C2
GABABQ(5,6) = C3
GABABQ(6,7) = C1
GABABQ(6,8) = C2
GABABQ(6,9) = C3
C1 = AA * ( R1 * Z2 - Z1 * R2)
C2 = -AA * ( Z2 - Z1)
C3 = AA * ( R2 - R1 )
GABABQ(7,1) = C1
GABABQ(7,2) = C2
GABABQ(7,3) = C3
GABABQ(8,4) = C1
GABABQ(8,5) = C2
GABABQ(8,6) = C3
GABABQ(9,7) = C1
GABABQ(9,8) = C2
GABABQ(9,9) = C3
C
C LOCATE THE MATERIAL PROPERTIES IN THE MAT1 OR MAT3
DGAMR = DGAMA * DEGRAD
COSG = COS (DGAMR)
SING = SIN (DGAMR)
COSTH = COSG
SINTH = SING
MATIDC = MATID
MATFLG = 7
ELTEMP = TEMPE
CALL MAT (IDEL)
IF (SETMAT.EQ.2.0) GO TO 910
C
C . SET MATERIAL PROPERTIES IN LOCAL VARIABLES...
ER = E(1)
ET = E(2)
EZ = E(3)
VRO = ANU(1)
VOZ = ANU(2)
VZR = ANU(3)
GOR = G(1)
GZO = G(2)
GRZ = G(3)
VOR = VRO * ET / ER
VZO = VOZ * EZ / ET
VRZ = VZR * ER / EZ
DEL = 1.0E0 / (1.0E0 - VRO * VOR - VOZ * VZO - VZR * VRZ
1 - VRO * VOZ * VZR - VRZ * VOR * VZO )
C
C COMPUTE ELASTIC CONSTANTS MATRIX FROM MATERIAL TO ELEMENT AXIS
DO 510 I = 1,21
510 TEO (I) = 0.0E0
TEO (1) = ER * ( 1.0E0 - VOZ * VZO) * DEL
TEO (2) = ER * ( VZR + VZO * VOR ) * DEL
TEO (3) = EZ * ( 1.0E0 - VRO * VOR ) * DEL
TEO (4) = ER * ( VOR + VZR * VOZ) * DEL
TEO (5) = ET * (VZO + VRO * VZR ) * DEL
TEO (6) = ET * ( 1.0E0 - VRZ * VZR ) * DEL
TEO (10) = GRZ
TEO (15) = GOR
TEO (21) = GZO
C2 = COSG * COSG
C4 = C2 * C2
S2 = SING * SING
S4 = S2 * S2
C2S2 = C2 * S2
EE01 = TEO(1)*C4 + TEO(3)*S4 + (TEO(2) + 2.0E0*TEO(10))
1 * 2.0E0*C2S2
EE02 = TEO(2) * (S4+C4) + (TEO(1) + TEO(3) - 4.0E0*TEO(10))*C2S2
EE03 = TEO(4)*C2 + TEO(5)*S2
EE04 = SING*COSG * (TEO(1)*C2 - TEO(3)*S2 + (TEO(2) + 2.0E0
4 *TEO(10)) * (S2-C2))
EE08 = TEO(1)*S4 + TEO(3)*C4 + (2.0E0*TEO(2) + 4.0E0*TEO(10))
8 * C2S2
EE09 = TEO(4)*S2 + TEO(5)*C2
EE10 = SING*COSG * (TEO(1)*S2 - TEO(3)*C2 + (TEO(2) + 2.0E0
* * TEO(10)) * (C2 - S2))
EE15 = TEO(6)
EE16 = SING*COSG * (TEO(4) - TEO(5))
C
C COMPUTE HARMONIC COEFFICIENT
AJHO = IECPT(1) - (IECPT(1) /1000) * 1000 - 1
C
C . CALCULATE THE INTEGRAL VALUES IN DELINT...
C
C DELINT(4) = 0,0
C DELINT(5) = 0,1
C DELINT(6) = 1,0
C
DELINT(4) = AIS (3,0,0,R,Z)
DELINT(5) = AIS (3,0,1,R,Z)
DELINT(6) = AIS (3,1,0,R,Z)
C
T1 = EE01*ALF(1) + EE02*ALF(3) + EE03*ALF(2)
T2 = EE02*ALF(1) + EE08*ALF(3) + EE09*ALF(2)
T3 = EE03*ALF(1) + EE09*ALF(3) + EE15*ALF(2)
T4 = EE04*ALF(1) + EE10*ALF(3) + EE16*ALF(2)
C GENERATE DTT MATRIX
DTT (1) = DELINT (4) * T3
DTT (2) = DELINT (6) * ( T1 + T3 )
DTT (3) = DELINT (5) * T3 + DELINT(6) * T4
DTT (4) = AJHO * DTT (1)
DTT (5) = AJHO * DELINT (6)*T3
DTT (6) = AJHO * DELINT (5) * T3
DTT (7) = 0.0
DTT (8) = DELINT (6) * T4
DTT (9) = DELINT (6) * T2
C
C TRANSFORM THE THERMAL LOAD TO GRID POINT DEGREES OF FREEDOM
CALL GMMATS (GABABQ, 9, 9, 1, DTT, 9, 1, 0, FIJ)
T = TZERO
IF (AJHO.GT.0.0) T = 0.0
T = ((TI(1) + TI(2) + TI(3))/3.0E0 - T) * PI
IF ( AJHO .EQ. 0.0 ) T = T * 2.0E0
DO 959 I = 1, 9
959 TL(I) = T * FIJ(I)
C
C**** THE FOLLOWING CODE REMOVED. CORD.SYS. NOT POSSIBLE WITH RINGAX **
C.959 FIJ(I) = T*FIJ(I)
C.
C. LOCATE THE TRANSFORMATION MATRICES FOR THE THREE GRID POINTS
C. DO 750 I=1,81
C.750 AKI(I) = 0.0
C. DO 800 I = 1,3
C. CALL GBTRAN(ICS(I),IECPT(4*I+22),DTT(1)) **R,TH,Z NEEDED**
C. K=30*(I-1) + 1
C. DO 800 J=1,3
C. KK = K+9*(J-1)
C. JJ=3*(J-1)+1
C. AKI(KK) = DTT(JJ)
C. AKI(KK+1) = DTT(JJ+1)
C. AKI(KK+2) = DTT(JJ+2)
C.800 CONTINUE
C.
C. TRANSFORM THE THERMAL LOAD FROM BASIC TO LOCAL COORD...
C. CALL GMMATS (AKI(1),9,9,1, FIJ(1),9,1,0, TL(1))
C
C ADD THE ELEMENT THERMAL LOAD TO THE STRUCTURE THERMAL LOAD
K = 0
DO 900 I = 1, 3
L = IGP(I) - 1
DO 900 J = 1,3
K = K + 1
L = L + 1
PG(L) = PG(L) + TL(K)
900 CONTINUE
GO TO 920
910 CALL MESAGE (-30,37,ECPT(1))
920 RETURN
END
| mis/trttem.f |
*DECK CPEVLR
SUBROUTINE CPEVLR (N, M, A, X, C)
C***BEGIN PROLOGUE CPEVLR
C***SUBSIDIARY
C***PURPOSE Subsidiary to CPZERO
C***LIBRARY SLATEC
C***TYPE SINGLE PRECISION (CPEVLR-S)
C***AUTHOR (UNKNOWN)
C***SEE ALSO CPZERO
C***ROUTINES CALLED (NONE)
C***REVISION HISTORY (YYMMDD)
C 810223 DATE WRITTEN
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890831 Modified array declarations. (WRB)
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900402 Added TYPE section. (WRB)
C***END PROLOGUE CPEVLR
REAL A(*),C(*)
C***FIRST EXECUTABLE STATEMENT CPEVLR
NP1=N+1
DO 1 J=1,NP1
CI=0.0
CIM1=A(J)
MINI=MIN(M+1,N+2-J)
DO 1 I=1,MINI
IF(J .NE. 1) CI=C(I)
IF(I .NE. 1) CIM1=C(I-1)
C(I)=CIM1+X*CI
1 CONTINUE
RETURN
END
| slatec/src/cpevlr.f |
Subsets and Splits