text
stringlengths 12
986k
| repo_path
stringlengths 6
121
|
---|---|
SUBROUTINE SLAEIN( RIGHTV, NOINIT, N, H, LDH, WR, WI, VR, VI, B,
$ LDB, WORK, EPS3, SMLNUM, BIGNUM, INFO )
*
* -- LAPACK auxiliary routine (instrumented to count operations) --
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
* Courant Institute, Argonne National Lab, and Rice University
* September 30, 1994
*
* .. Scalar Arguments ..
LOGICAL NOINIT, RIGHTV
INTEGER INFO, LDB, LDH, N
REAL BIGNUM, EPS3, SMLNUM, WI, WR
* ..
* .. Array Arguments ..
REAL B( LDB, * ), H( LDH, * ), VI( * ), VR( * ),
$ WORK( * )
* ..
* Common block to return operation count.
* .. Common blocks ..
COMMON / LATIME / OPS, ITCNT
* ..
* .. Scalars in Common ..
REAL ITCNT, OPS
* ..
*
* Purpose
* =======
*
* SLAEIN uses inverse iteration to find a right or left eigenvector
* corresponding to the eigenvalue (WR,WI) of a real upper Hessenberg
* matrix H.
*
* Arguments
* =========
*
* RIGHTV (input) LOGICAL
* = .TRUE. : compute right eigenvector;
* = .FALSE.: compute left eigenvector.
*
* NOINIT (input) LOGICAL
* = .TRUE. : no initial vector supplied in (VR,VI).
* = .FALSE.: initial vector supplied in (VR,VI).
*
* N (input) INTEGER
* The order of the matrix H. N >= 0.
*
* H (input) REAL array, dimension (LDH,N)
* The upper Hessenberg matrix H.
*
* LDH (input) INTEGER
* The leading dimension of the array H. LDH >= max(1,N).
*
* WR (input) REAL
* WI (input) REAL
* The real and imaginary parts of the eigenvalue of H whose
* corresponding right or left eigenvector is to be computed.
*
* VR (input/output) REAL array, dimension (N)
* VI (input/output) REAL array, dimension (N)
* On entry, if NOINIT = .FALSE. and WI = 0.0, VR must contain
* a real starting vector for inverse iteration using the real
* eigenvalue WR; if NOINIT = .FALSE. and WI.ne.0.0, VR and VI
* must contain the real and imaginary parts of a complex
* starting vector for inverse iteration using the complex
* eigenvalue (WR,WI); otherwise VR and VI need not be set.
* On exit, if WI = 0.0 (real eigenvalue), VR contains the
* computed real eigenvector; if WI.ne.0.0 (complex eigenvalue),
* VR and VI contain the real and imaginary parts of the
* computed complex eigenvector. The eigenvector is normalized
* so that the component of largest magnitude has magnitude 1;
* here the magnitude of a complex number (x,y) is taken to be
* |x| + |y|.
* VI is not referenced if WI = 0.0.
*
* B (workspace) REAL array, dimension (LDB,N)
*
* LDB (input) INTEGER
* The leading dimension of the array B. LDB >= N+1.
*
* WORK (workspace) REAL array, dimension (N)
*
* EPS3 (input) REAL
* A small machine-dependent value which is used to perturb
* close eigenvalues, and to replace zero pivots.
*
* SMLNUM (input) REAL
* A machine-dependent value close to the underflow threshold.
*
* BIGNUM (input) REAL
* A machine-dependent value close to the overflow threshold.
*
* INFO (output) INTEGER
* = 0: successful exit
* = 1: inverse iteration did not converge; VR is set to the
* last iterate, and so is VI if WI.ne.0.0.
*
* =====================================================================
*
* .. Parameters ..
REAL ZERO, ONE, TENTH
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TENTH = 1.0E-1 )
* ..
* .. Local Scalars ..
CHARACTER NORMIN, TRANS
INTEGER I, I1, I2, I3, IERR, ITS, J
REAL ABSBII, ABSBJJ, EI, EJ, GROWTO, NORM, NRMSML,
$ OPST, REC, ROOTN, SCALE, TEMP, VCRIT, VMAX,
$ VNORM, W, W1, X, XI, XR, Y
* ..
* .. External Functions ..
INTEGER ISAMAX
REAL SASUM, SLAPY2, SNRM2
EXTERNAL ISAMAX, SASUM, SLAPY2, SNRM2
* ..
* .. External Subroutines ..
EXTERNAL SLADIV, SLATRS, SSCAL
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, MAX, REAL, SQRT
* ..
* .. Executable Statements ..
*
INFO = 0
***
* Initialize
OPST = 0
***
*
* GROWTO is the threshold used in the acceptance test for an
* eigenvector.
*
ROOTN = SQRT( REAL( N ) )
GROWTO = TENTH / ROOTN
NRMSML = MAX( ONE, EPS3*ROOTN )*SMLNUM
***
* Increment op count for computing ROOTN, GROWTO and NRMSML
OPST = OPST + 4
***
*
* Form B = H - (WR,WI)*I (except that the subdiagonal elements and
* the imaginary parts of the diagonal elements are not stored).
*
DO 20 J = 1, N
DO 10 I = 1, J - 1
B( I, J ) = H( I, J )
10 CONTINUE
B( J, J ) = H( J, J ) - WR
20 CONTINUE
***
OPST = OPST + N
***
*
IF( WI.EQ.ZERO ) THEN
*
* Real eigenvalue.
*
IF( NOINIT ) THEN
*
* Set initial vector.
*
DO 30 I = 1, N
VR( I ) = EPS3
30 CONTINUE
ELSE
*
* Scale supplied initial vector.
*
VNORM = SNRM2( N, VR, 1 )
CALL SSCAL( N, ( EPS3*ROOTN ) / MAX( VNORM, NRMSML ), VR,
$ 1 )
***
OPST = OPST + ( 3*N+2 )
***
END IF
*
IF( RIGHTV ) THEN
*
* LU decomposition with partial pivoting of B, replacing zero
* pivots by EPS3.
*
DO 60 I = 1, N - 1
EI = H( I+1, I )
IF( ABS( B( I, I ) ).LT.ABS( EI ) ) THEN
*
* Interchange rows and eliminate.
*
X = B( I, I ) / EI
B( I, I ) = EI
DO 40 J = I + 1, N
TEMP = B( I+1, J )
B( I+1, J ) = B( I, J ) - X*TEMP
B( I, J ) = TEMP
40 CONTINUE
ELSE
*
* Eliminate without interchange.
*
IF( B( I, I ).EQ.ZERO )
$ B( I, I ) = EPS3
X = EI / B( I, I )
IF( X.NE.ZERO ) THEN
DO 50 J = I + 1, N
B( I+1, J ) = B( I+1, J ) - X*B( I, J )
50 CONTINUE
END IF
END IF
60 CONTINUE
IF( B( N, N ).EQ.ZERO )
$ B( N, N ) = EPS3
***
* Increment op count for LU decomposition
OPS = OPS + ( N-1 )*( N+1 )
***
*
TRANS = 'N'
*
ELSE
*
* UL decomposition with partial pivoting of B, replacing zero
* pivots by EPS3.
*
DO 90 J = N, 2, -1
EJ = H( J, J-1 )
IF( ABS( B( J, J ) ).LT.ABS( EJ ) ) THEN
*
* Interchange columns and eliminate.
*
X = B( J, J ) / EJ
B( J, J ) = EJ
DO 70 I = 1, J - 1
TEMP = B( I, J-1 )
B( I, J-1 ) = B( I, J ) - X*TEMP
B( I, J ) = TEMP
70 CONTINUE
ELSE
*
* Eliminate without interchange.
*
IF( B( J, J ).EQ.ZERO )
$ B( J, J ) = EPS3
X = EJ / B( J, J )
IF( X.NE.ZERO ) THEN
DO 80 I = 1, J - 1
B( I, J-1 ) = B( I, J-1 ) - X*B( I, J )
80 CONTINUE
END IF
END IF
90 CONTINUE
IF( B( 1, 1 ).EQ.ZERO )
$ B( 1, 1 ) = EPS3
***
* Increment op count for UL decomposition
OPS = OPS + ( N-1 )*( N+1 )
***
*
TRANS = 'T'
*
END IF
*
NORMIN = 'N'
DO 110 ITS = 1, N
*
* Solve U*x = scale*v for a right eigenvector
* or U'*x = scale*v for a left eigenvector,
* overwriting x on v.
*
CALL SLATRS( 'Upper', TRANS, 'Nonunit', NORMIN, N, B, LDB,
$ VR, SCALE, WORK, IERR )
***
* Increment opcount for triangular solver, assuming that
* ops SLATRS = ops STRSV, with no scaling in SLATRS.
OPS = OPS + N*N
***
NORMIN = 'Y'
*
* Test for sufficient growth in the norm of v.
*
VNORM = SASUM( N, VR, 1 )
***
OPST = OPST + N
***
IF( VNORM.GE.GROWTO*SCALE )
$ GO TO 120
*
* Choose new orthogonal starting vector and try again.
*
TEMP = EPS3 / ( ROOTN+ONE )
VR( 1 ) = EPS3
DO 100 I = 2, N
VR( I ) = TEMP
100 CONTINUE
VR( N-ITS+1 ) = VR( N-ITS+1 ) - EPS3*ROOTN
***
OPST = OPST + 4
***
110 CONTINUE
*
* Failure to find eigenvector in N iterations.
*
INFO = 1
*
120 CONTINUE
*
* Normalize eigenvector.
*
I = ISAMAX( N, VR, 1 )
CALL SSCAL( N, ONE / ABS( VR( I ) ), VR, 1 )
***
OPST = OPST + ( 2*N+1 )
***
ELSE
*
* Complex eigenvalue.
*
IF( NOINIT ) THEN
*
* Set initial vector.
*
DO 130 I = 1, N
VR( I ) = EPS3
VI( I ) = ZERO
130 CONTINUE
ELSE
*
* Scale supplied initial vector.
*
NORM = SLAPY2( SNRM2( N, VR, 1 ), SNRM2( N, VI, 1 ) )
REC = ( EPS3*ROOTN ) / MAX( NORM, NRMSML )
CALL SSCAL( N, REC, VR, 1 )
CALL SSCAL( N, REC, VI, 1 )
***
OPST = OPST + ( 6*N+5 )
***
END IF
*
IF( RIGHTV ) THEN
*
* LU decomposition with partial pivoting of B, replacing zero
* pivots by EPS3.
*
* The imaginary part of the (i,j)-th element of U is stored in
* B(j+1,i).
*
B( 2, 1 ) = -WI
DO 140 I = 2, N
B( I+1, 1 ) = ZERO
140 CONTINUE
*
DO 170 I = 1, N - 1
ABSBII = SLAPY2( B( I, I ), B( I+1, I ) )
EI = H( I+1, I )
IF( ABSBII.LT.ABS( EI ) ) THEN
*
* Interchange rows and eliminate.
*
XR = B( I, I ) / EI
XI = B( I+1, I ) / EI
B( I, I ) = EI
B( I+1, I ) = ZERO
DO 150 J = I + 1, N
TEMP = B( I+1, J )
B( I+1, J ) = B( I, J ) - XR*TEMP
B( J+1, I+1 ) = B( J+1, I ) - XI*TEMP
B( I, J ) = TEMP
B( J+1, I ) = ZERO
150 CONTINUE
B( I+2, I ) = -WI
B( I+1, I+1 ) = B( I+1, I+1 ) - XI*WI
B( I+2, I+1 ) = B( I+2, I+1 ) + XR*WI
***
OPST = OPST + ( 4*( N-I )+6 )
***
ELSE
*
* Eliminate without interchanging rows.
*
IF( ABSBII.EQ.ZERO ) THEN
B( I, I ) = EPS3
B( I+1, I ) = ZERO
ABSBII = EPS3
END IF
EI = ( EI / ABSBII ) / ABSBII
XR = B( I, I )*EI
XI = -B( I+1, I )*EI
DO 160 J = I + 1, N
B( I+1, J ) = B( I+1, J ) - XR*B( I, J ) +
$ XI*B( J+1, I )
B( J+1, I+1 ) = -XR*B( J+1, I ) - XI*B( I, J )
160 CONTINUE
B( I+2, I+1 ) = B( I+2, I+1 ) - WI
***
OPST = OPST + ( 7*( N-I )+4 )
***
END IF
*
* Compute 1-norm of offdiagonal elements of i-th row.
*
WORK( I ) = SASUM( N-I, B( I, I+1 ), LDB ) +
$ SASUM( N-I, B( I+2, I ), 1 )
***
OPST = OPST + ( 2*( N-I )+4 )
***
170 CONTINUE
IF( B( N, N ).EQ.ZERO .AND. B( N+1, N ).EQ.ZERO )
$ B( N, N ) = EPS3
WORK( N ) = ZERO
*
I1 = N
I2 = 1
I3 = -1
ELSE
*
* UL decomposition with partial pivoting of conjg(B),
* replacing zero pivots by EPS3.
*
* The imaginary part of the (i,j)-th element of U is stored in
* B(j+1,i).
*
B( N+1, N ) = WI
DO 180 J = 1, N - 1
B( N+1, J ) = ZERO
180 CONTINUE
*
DO 210 J = N, 2, -1
EJ = H( J, J-1 )
ABSBJJ = SLAPY2( B( J, J ), B( J+1, J ) )
IF( ABSBJJ.LT.ABS( EJ ) ) THEN
*
* Interchange columns and eliminate
*
XR = B( J, J ) / EJ
XI = B( J+1, J ) / EJ
B( J, J ) = EJ
B( J+1, J ) = ZERO
DO 190 I = 1, J - 1
TEMP = B( I, J-1 )
B( I, J-1 ) = B( I, J ) - XR*TEMP
B( J, I ) = B( J+1, I ) - XI*TEMP
B( I, J ) = TEMP
B( J+1, I ) = ZERO
190 CONTINUE
B( J+1, J-1 ) = WI
B( J-1, J-1 ) = B( J-1, J-1 ) + XI*WI
B( J, J-1 ) = B( J, J-1 ) - XR*WI
***
OPST = OPST + ( 4*( J-1 )+6 )
***
ELSE
*
* Eliminate without interchange.
*
IF( ABSBJJ.EQ.ZERO ) THEN
B( J, J ) = EPS3
B( J+1, J ) = ZERO
ABSBJJ = EPS3
END IF
EJ = ( EJ / ABSBJJ ) / ABSBJJ
XR = B( J, J )*EJ
XI = -B( J+1, J )*EJ
DO 200 I = 1, J - 1
B( I, J-1 ) = B( I, J-1 ) - XR*B( I, J ) +
$ XI*B( J+1, I )
B( J, I ) = -XR*B( J+1, I ) - XI*B( I, J )
200 CONTINUE
B( J, J-1 ) = B( J, J-1 ) + WI
***
OPST = OPST + ( 7*( J-1 )+4 )
***
END IF
*
* Compute 1-norm of offdiagonal elements of j-th column.
*
WORK( J ) = SASUM( J-1, B( 1, J ), 1 ) +
$ SASUM( J-1, B( J+1, 1 ), LDB )
***
OPST = OPST + ( 2*( J-1 )+4 )
***
210 CONTINUE
IF( B( 1, 1 ).EQ.ZERO .AND. B( 2, 1 ).EQ.ZERO )
$ B( 1, 1 ) = EPS3
WORK( 1 ) = ZERO
*
I1 = 1
I2 = N
I3 = 1
END IF
*
DO 270 ITS = 1, N
SCALE = ONE
VMAX = ONE
VCRIT = BIGNUM
*
* Solve U*(xr,xi) = scale*(vr,vi) for a right eigenvector,
* or U'*(xr,xi) = scale*(vr,vi) for a left eigenvector,
* overwriting (xr,xi) on (vr,vi).
*
DO 250 I = I1, I2, I3
*
IF( WORK( I ).GT.VCRIT ) THEN
REC = ONE / VMAX
CALL SSCAL( N, REC, VR, 1 )
CALL SSCAL( N, REC, VI, 1 )
SCALE = SCALE*REC
VMAX = ONE
VCRIT = BIGNUM
END IF
*
XR = VR( I )
XI = VI( I )
IF( RIGHTV ) THEN
DO 220 J = I + 1, N
XR = XR - B( I, J )*VR( J ) + B( J+1, I )*VI( J )
XI = XI - B( I, J )*VI( J ) - B( J+1, I )*VR( J )
220 CONTINUE
ELSE
DO 230 J = 1, I - 1
XR = XR - B( J, I )*VR( J ) + B( I+1, J )*VI( J )
XI = XI - B( J, I )*VI( J ) - B( I+1, J )*VR( J )
230 CONTINUE
END IF
*
W = ABS( B( I, I ) ) + ABS( B( I+1, I ) )
IF( W.GT.SMLNUM ) THEN
IF( W.LT.ONE ) THEN
W1 = ABS( XR ) + ABS( XI )
IF( W1.GT.W*BIGNUM ) THEN
REC = ONE / W1
CALL SSCAL( N, REC, VR, 1 )
CALL SSCAL( N, REC, VI, 1 )
XR = VR( I )
XI = VI( I )
SCALE = SCALE*REC
VMAX = VMAX*REC
END IF
END IF
*
* Divide by diagonal element of B.
*
CALL SLADIV( XR, XI, B( I, I ), B( I+1, I ), VR( I ),
$ VI( I ) )
VMAX = MAX( ABS( VR( I ) )+ABS( VI( I ) ), VMAX )
VCRIT = BIGNUM / VMAX
***
OPST = OPST + 9
***
ELSE
DO 240 J = 1, N
VR( J ) = ZERO
VI( J ) = ZERO
240 CONTINUE
VR( I ) = ONE
VI( I ) = ONE
SCALE = ZERO
VMAX = ONE
VCRIT = BIGNUM
END IF
250 CONTINUE
***
* Increment op count for loop 260, assuming no scaling
OPS = OPS + 4*N*( N-1 )
***
*
* Test for sufficient growth in the norm of (VR,VI).
*
VNORM = SASUM( N, VR, 1 ) + SASUM( N, VI, 1 )
***
OPST = OPST + 2*N
***
IF( VNORM.GE.GROWTO*SCALE )
$ GO TO 280
*
* Choose a new orthogonal starting vector and try again.
*
Y = EPS3 / ( ROOTN+ONE )
VR( 1 ) = EPS3
VI( 1 ) = ZERO
*
DO 260 I = 2, N
VR( I ) = Y
VI( I ) = ZERO
260 CONTINUE
VR( N-ITS+1 ) = VR( N-ITS+1 ) - EPS3*ROOTN
***
OPST = OPST + 4
***
270 CONTINUE
*
* Failure to find eigenvector in N iterations
*
INFO = 1
*
280 CONTINUE
*
* Normalize eigenvector.
*
VNORM = ZERO
DO 290 I = 1, N
VNORM = MAX( VNORM, ABS( VR( I ) )+ABS( VI( I ) ) )
290 CONTINUE
CALL SSCAL( N, ONE / VNORM, VR, 1 )
CALL SSCAL( N, ONE / VNORM, VI, 1 )
***
OPST = OPST + ( 4*N+1 )
***
*
END IF
*
***
* Compute final op count
OPS = OPS + OPST
***
RETURN
*
* End of SLAEIN
*
END
| old/lapack-test/lapack-timing/EIG/EIGSRC/slaein.f |
use sim
implicit none
type(SeismicAnalysis_) :: seismic
type(FEMDomain_),target :: cube,original
type(IO_) :: f,response,history_A,history_V,history_U,input_wave
type(Math_) :: math
real(real64),allocatable :: disp_z(:,:)
real(real64) :: wave(200,2),T,Duration,dt
integer(int32) :: i,j,cases,stack_id,num_of_cases
num_of_cases = 4
! create Domain
call cube%create(meshtype="Cube3D",x_num=4,y_num=4,z_num=20)
call cube%resize(x=1.0d0,y=1.0d0,z=5.0d0)
call cube%move(z=-5.0d0)
! create Wave
T = 0.300d0
Duration = T * 10.0d0 ! sec.
dt = Duration/dble(size(wave,1))!/10.0d0
wave(:,:) = 0.0d0
do i=1,size(wave,1)
wave(i,1) = dt*dble(i)
wave(i,2) = sin(2.0d0*math%pi/T*wave(i,1) )
enddo
call input_wave%open("input_wave.txt" )
call input_wave%write(wave )
call input_wave%close()
original = cube
! set domain
seismic%femdomain => cube
! set wave
seismic%wave = wave
seismic%dt = dt
! run simulation
call seismic%init()
!call seismic%fixDisplacement(z_max = -4.99d0,direction="x")
call seismic%fixDisplacement(z_max = -4.99d0,direction="y")
call seismic%fixDisplacement(z_max = -4.99d0,direction="z")
call seismic%fixDisplacement(y_max = 0.0d0,direction="y")
call seismic%fixDisplacement(y_min = 1.0d0,direction="y")
call seismic%fixDisplacement(direction="z")
call seismic%femdomain%vtk("mesh_init" )
call seismic%loadWave(z_max=-4.50d0,direction="x",wavetype=WAVE_ACCEL)
seismic%Density(:) = 17000.0d0 !(N/m/m/m)
seismic%PoissonRatio(:) = 0.330d0
seismic%YoungModulus(:) = 25372853.0 !(N/m/m) Vs=121 m/s
!seismic%alpha = 0.0d0
seismic%a = 0.0d0
seismic%v = 0.0d0
seismic%u = 0.0d0
do i=1,199
!seismic%beta = 0.0d0
call history_A%open("history_A"//str(i)//".txt","w")
call history_V%open("history_V"//str(i)//".txt","w")
call history_U%open("history_U"//str(i)//".txt","w")
call seismic%run(timestep=[i,i+1],AccelLimit=10.0d0**8)
do j=1,seismic%femdomain%nn()
if(seismic%femdomain%position_x(j)/=0.0d0) cycle
if(seismic%femdomain%position_y(j)/=0.0d0) cycle
write(history_A%fh,*) real(dble(i)*dt),&
seismic%femdomain%position_z(j), real(seismic%A( (j-1)*3 + 1 ))
enddo
do j=1,seismic%femdomain%nn()
if(seismic%femdomain%position_x(j)/=0.0d0) cycle
if(seismic%femdomain%position_y(j)/=0.0d0) cycle
write(history_V%fh,*) real(dble(i)*dt),&
seismic%femdomain%position_z(j), real(seismic%V( (j-1)*3 + 1 ))
enddo
do j=1,seismic%femdomain%nn()
if(seismic%femdomain%position_x(j)/=0.0d0) cycle
if(seismic%femdomain%position_y(j)/=0.0d0) cycle
write(history_U%fh,*) real(dble(i)*dt),&
seismic%femdomain%position_z(j), real(seismic%U( (j-1)*3 + 1 ))
enddo
call history_A%close()
call history_V%close()
call history_U%close()
enddo
!print *, maxval(seismic%U)
seismic%femdomain%mesh%nodcoord = seismic%femdomain%mesh%nodcoord + (10.0d0**0)*&
reshape(seismic%a, seismic%femdomain%nn(),seismic%femdomain%nd() )
call seismic%femdomain%vtk("result")
!call response%open("T_A"//str(cases)//".txt")
!call response%write(T,seismic%maxA(1))
!call response%close()
end | Tutorial/sim/SeismicAnalysis.f90 |
!
! common routines for testing
!
module test_common
implicit none
integer, parameter, public :: dp = kind(1.d0) ! Common in the test routines.
character(len=*), parameter :: SAMPLE_DIR = '../samples'
character(len=*), parameter :: DEF_FNAME_OUT = SAMPLE_DIR//'/test_out.txt'
contains
! Print the stats info at the end of each subroutine-level testing
subroutine print_teststats(subname, nsuccess, ifailed)
character(*), intent(in) :: subname
integer, intent(in) :: nsuccess ! Number of succesful trials, i-th failure
integer, intent(in), optional :: ifailed ! i-th failure
if (present(ifailed)) then
write(*, '(" Tests(", a, "): Only succeeded in ", i3, " tests before failed at ", i3, "-th.")') &
trim(subname), nsuccess, ifailed
else
write(*, '(" Tests(", a, "): Succeeded in all ", i3, " tests.")') &
trim(subname), nsuccess
end if
end subroutine print_teststats
end module test_common
module test_alpin_misc_utils
use alpin_unittest
use alpin_err_exit
use test_common
use alpin_misc_utils
implicit none
contains
! run tests of routines in alpin_misc_utils.f90
!
! Returns 1 if error is raised (0 otherwise)
integer function run_test_alpin_misc_utils() result(ret_status)
character(*), parameter :: Subname = 'run_test_alpin_misc_utils'
integer, parameter :: TOT_NTESTS = 39
logical, dimension(TOT_NTESTS) :: ress
integer :: iloc
ret_status = 0 ! normal ends (n.b., returned value)
ress = [ &
assert_in_delta(180.0d0, rad2deg(PI), 1.0e5, Subname, ' rad2deg(PI)') &
, assert_in_delta(PI, deg2rad(180.0d0), 1.0e5, Subname, ' deg2rad(180.0)') &
, assert_equal ('00000001', dump_int_binary(1_1), Subname, 'dump_int_binary') &
, assert_equal ('01111111', dump_int_binary(127_1), Subname, 'dump_int_binary') &
, assert_equal ('11111111', dump_int_binary(-1_1), Subname, 'dump_int_binary') &
, assert_equal (3, int4_to_unsigned1(3), Subname, 'for (3(int4=>1))') &
, assert_equal(-1, int4_to_unsigned1(255), Subname, 'for (255(int4=>1))') &
, assert_equal(255, unsigned1_to_int4(-1_1), Subname, 'for (255(int1=>4))') &
, assert_equal ('00000000_00000000_00000000_01111111', dump_int_binary(127_4), Subname, 'dump_int_binary(127)') &
, assert_equal ('00000000_00000000_00000001_01111111', dump_int_binary(383_4), Subname, 'dump_int_binary(383)') &
, assert_equal ('11111111_11111111_11111111_11111111', dump_int_binary(-1_4), Subname, 'dump_int_binary(-1)') &
, assert_equal('c.d', trim(basename('/a/b/c.d')), Subname, 'basename(/a/b/c.d)') &
, assert_equal('c.d', trim(basename('c.d')), Subname, 'basename(c.d)') &
, assert_equal('abc', trim(basename('/x/abc/')), Subname, 'basename(/x/abc/)') &
, assert_equal('abc', trim(basename('/x/abc///')), Subname, 'basename(/x/abc///)') &
, assert_equal('/', trim(basename('/')), Subname, 'basename(/)') &
, assert_equal('/', trim(basename('//')), Subname, 'basename(//)') &
, assert_equal('0', trim(ladjusted_int(0_1)), Subname, 'ladjusted_int(0_1)') &
, assert_equal('-123', trim(ladjusted_int(-123_1)), Subname, 'ladjusted_int(-123_1)') &
, assert_equal('-123', trim(ladjusted_int(-123_2)), Subname, 'ladjusted_int(-123_2)') &
, assert_equal('-123', trim(ladjusted_int(-123_4)), Subname, 'ladjusted_int(-123_4)') &
, assert_equal('-123', trim(ladjusted_int(-123_8)), Subname, 'ladjusted_int(-123_8)') &
, assert_equal('-12345', trim(ladjusted_int(-12345_2)),Subname, 'ladjusted_int(-12345_2)') &
, assert_equal('-123456', trim(ladjusted_int(-123456)), Subname, 'ladjusted_int(-123456)') &
, assert_equal('-123456', trim(ladjusted_int(-123456)), Subname, 'ladjusted_int(-123456)') &
, assert_equal('''ab'', ''cdef'', ''ghi''', join_ary(['ab ','cdef','ghi ']), Subname, 'join_ary_chars()') &
, assert_equal('$ab$, $cdef$, $ghi$', join_ary(['ab ','cdef','ghi '],quote='$'), Subname, 'join_ary_chars()') &
, assert_equal('-123, 4, -56', join_ary([-123, 4, -56]), Subname, 'join_ary_int4()') &
, assert_equal('-123; 4; -56', join_ary([-123_2, 4_2, -56_2], '; '), Subname, 'join_ary_int2()') &
, assert_equal(1, findloc1(['X','Y','X'],'X'), Subname, 'findloc1_char') &
, assert_equal(3, findloc1(['X','Y','X'],'X',MASK=[.false.,.true.,.true.]), Subname, 'findloc1_char-mask') &
, assert_equal(3, findloc1(['X','Y','X'],'X',BACK=.true.), Subname, 'findloc1_char-back') &
, assert_equal(1, findloc1(['X','Y','X'],'X',MASK=[.true.,.true.,.false.],BACK=.true.), Subname, 'findloc1_char-ma-ba') &
, assert_equal(2, findloc1([9,8,7,6],8), Subname, 'findloc1_int4') &
, assert_equal(2, findloc1(int([9,8,7,6],kind=2),8), Subname, 'findloc1_int2_4') &
, assert_equal(2, findloc1(real([16,32,0,0,-1],kind=4),32.0), Subname, 'findloc1_real4') &
, assert_equal(2, findloc1(real([16,32,0,0,-1],kind=4),32.d0), Subname, 'findloc1_real4-2') &
, assert_equal(2, findloc1(real([16,32,0,0,-1],kind=8),32.0), Subname, 'findloc1_real8-1') &
, assert_equal(2, findloc1(real([16,32,0,0,-1],kind=8),32.d0), Subname, 'findloc1_real8-2') &
]
iloc = findloc1(ress, .false.) ! Similar to the standard way, but scalar: ilocs(:)=findloc(ress, .false.)
if (iloc == 0) then ! All passed
call print_teststats(Subname, nsuccess=TOT_NTESTS)
return
end if
! Failed
call print_teststats(Subname, nsuccess=iloc-1, ifailed=iloc)
ret_status = 1
end function run_test_alpin_misc_utils
end module test_alpin_misc_utils
module test_alpin_hash
use alpin_unittest
use alpin_err_exit
use test_common
use alpin_misc_utils
use alpin_hash
implicit none
contains
! run tests of routines in alpin_misc_utils.f90
!
! Returns 1 if error is raised (0 otherwise)
integer function run_test_alpin_hash() result(ret_status)
character(*), parameter :: Subname = 'run_test_alpin_hash'
integer, parameter :: TOT_NTESTS = 11
logical, dimension(TOT_NTESTS) :: ress
integer :: iloc
type(t_alpin_hash_logical), dimension(2) :: arlogi
type(t_alpin_hash_char), dimension(2) :: archar
type(t_alpin_hash_int4), dimension(2) :: arint4
type(t_alpin_hash_real8), dimension(2) :: arreal8
logical, dimension(2) :: is_undef
character(len=LEN_T_ALPIN_HASH), dimension(2) :: valchs
ret_status = 0 ! normal ends (n.b., returned value)
arlogi = [t_alpin_hash_logical(key='k1', val=.false.), t_alpin_hash_logical(key='k2', val=.true.)]
archar = [t_alpin_hash_char( key='k1', val='v1'), t_alpin_hash_char( key='k2', val='v2')]
arint4 = [t_alpin_hash_int4( key='k1', val=11), t_alpin_hash_int4( key='k2', val=22)]
arreal8= [t_alpin_hash_real8(key='k1', val=16.0), t_alpin_hash_real8(key='k2', val=32.0)]
call hashval_status('k2', archar, valchs(1), is_undef(1))
call hashval_status('naiyo', archar, valchs(2), is_undef(2))
ress = [ &
assert_not(is_undef(1), Subname, ' hashval_status()-1') &
, assert( is_undef(2), Subname, ' hashval_status()-2') &
, assert_equal('v2', valchs(1), Subname, ' hashval_status("k2")') &
, assert_equal('v2', trim(fetch_hashval('k2', archar)), Subname, ' fetch_hashval("k2")') & ! NOTE: without trim(), this causes either "malloc: *** set a breakpoint in malloc_error_break to debug" or "SIGSEGV: Segmentation fault - invalid memory reference."
! It seems that if a character as a returned value from a function is passed directly (i.e., without trim()) to a different function, it may cause a memory-related error.
, assert_equal('@', trim(fetch_hashval('naiyo', archar, undef='@')), Subname, ' fetch_hashval("naiyo","@")') &
, assert_equal('', trim(fetch_hashval('naiyo', archar)), Subname, ' fetch_hashval("naiyo")') &
, assert_equal(22, fetch_hashval('k2', arint4), Subname, ' fetch_hashval_i4("k2")') &
, assert_equal(79, fetch_hashval('naiyo', arint4, undef=79), Subname, ' fetch_hashval_i4("k2",79)') &
, assert(fetch_hashval('k2', arlogi), Subname, ' fetch_hashval_logi("k2")') &
, assert_in_delta(32.d0, fetch_hashval('k2', arreal8), 1e-8, Subname, ' fetch_hashval_real8("k2")') &
, assert_in_delta(79.d0, fetch_hashval('naiyo', arreal8, undef=79.d0), 1e-8, Subname, ' fetch_hashval_real8("k2",79)') &
]
iloc = findloc1(ress, .false.) ! Similar to the standard way, but scalar: ilocs(:)=findloc(ress, .false.)
if (iloc == 0) then ! All passed
call print_teststats(Subname, nsuccess=TOT_NTESTS)
return
end if
! Failed
call print_teststats(Subname, nsuccess=iloc-1, ifailed=iloc)
ret_status = 1
end function run_test_alpin_hash
end module test_alpin_hash
! -------------------------------------------------------------------
program testalpin
use test_alpin_misc_utils
use test_alpin_hash
implicit none
integer :: status = 0
status = status + run_test_alpin_misc_utils()
status = status + run_test_alpin_hash()
if (status .ne. 0) then
call EXIT(status) ! for gfortran, Lahey Fujitsu Fortran 95, etc
end if
end program testalpin
| test/testalpin.f90 |
subroutine zgefa(a,lda,n,ipvt,info)
integer lda,n,ipvt(1),info
complex*16 a(lda,1)
c
c zgefa factors a complex*16 matrix by gaussian elimination.
c
c zgefa is usually called by zgeco, but it can be called
c directly with a saving in time if rcond is not needed.
c (time for zgeco) = (1 + 9/n)*(time for zgefa) .
c
c on entry
c
c a complex*16(lda, n)
c the matrix to be factored.
c
c lda integer
c the leading dimension of the array a .
c
c n integer
c the order of the matrix a .
c
c on return
c
c a an upper triangular matrix and the multipliers
c which were used to obtain it.
c the factorization can be written a = l*u where
c l is a product of permutation and unit lower
c triangular matrices and u is upper triangular.
c
c ipvt integer(n)
c an integer vector of pivot indices.
c
c info integer
c = 0 normal value.
c = k if u(k,k) .eq. 0.0 . this is not an error
c condition for this subroutine, but it does
c indicate that zgesl or zgedi will divide by zero
c if called. use rcond in zgeco for a reliable
c indication of singularity.
c
c linpack. this version dated 08/14/78 .
c cleve moler, university of new mexico, argonne national lab.
c
c subroutines and functions
c
c blas zaxpy,zscal,izamax
c fortran dabs
c
c internal variables
c
complex*16 t
integer izamax,j,k,kp1,l,nm1
c
complex*16 zdum
double precision cabs1
double precision dreal,dimag
complex*16 zdumr,zdumi
dreal(zdumr) = zdumr
dimag(zdumi) = (0.0d0,-1.0d0)*zdumi
cabs1(zdum) = dabs(dreal(zdum)) + dabs(dimag(zdum))
c
c gaussian elimination with partial pivoting
c
info = 0
nm1 = n - 1
if (nm1 .lt. 1) go to 70
do 60 k = 1, nm1
kp1 = k + 1
c
c find l = pivot index
c
l = izamax(n-k+1,a(k,k),1) + k - 1
ipvt(k) = l
c
c zero pivot implies this column already triangularized
c
if (cabs1(a(l,k)) .eq. 0.0d0) go to 40
c
c interchange if necessary
c
if (l .eq. k) go to 10
t = a(l,k)
a(l,k) = a(k,k)
a(k,k) = t
10 continue
c
c compute multipliers
c
t = -(1.0d0,0.0d0)/a(k,k)
call zscal(n-k,t,a(k+1,k),1)
c
c row elimination with column indexing
c
do 30 j = kp1, n
t = a(l,j)
if (l .eq. k) go to 20
a(l,j) = a(k,j)
a(k,j) = t
20 continue
call zaxpy(n-k,t,a(k+1,k),1,a(k+1,j),1)
30 continue
go to 50
40 continue
info = k
50 continue
60 continue
70 continue
ipvt(n) = n
if (cabs1(a(n,n)) .eq. 0.0d0) info = n
return
end
| scipy/integrate/linpack_lite/zgefa.f |
! This file is part of toml-f.
!
! Copyright (C) 2019-2020 Sebastian Ehlert
!
! Licensed under either of Apache License, Version 2.0 or MIT license
! at your option; you may not use this file except in compliance with
! the License.
!
! 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.
!> Version information on TOML-Fortran
module tomlf_version
implicit none
private
public :: tomlf_version_string, tomlf_version_compact
!> String representation of the TOML-Fortran version
character(len=*), parameter :: tomlf_version_string = "0.2.0"
!> Major version number of the above TOML-Fortran version
integer, parameter :: major = 0
!> Minor version number of the above TOML-Fortran version
integer, parameter :: minor = 2
!> Patch version number of the above TOML-Fortran version
integer, parameter :: patch = 0
!> Compact numeric representation of the TOML-Fortran version
integer, parameter :: tomlf_version_compact = major*10000 + minor*100 + patch
end module tomlf_version
| src/tomlf/version.f90 |
SUBROUTINE WIND (ILFN) MLu
C
CHARACTER CA*1 MLu
C
DO 20 I=1,30000 MLu
READ (ILFN,10,ERR=100,END=100) CA MLu
10 FORMAT (A) MLu
20 CONTINUE MLu
C
100 CONTINUE MLu
BACKSPACE ILFN M
RETURN MLu
END MLu
| heclib/heclib_f/src/Support/wind.f |
! -*- Mode: Fortran; -*-
!
! (C) 2014 by Argonne National Laboratory.
! See COPYRIGHT in top-level directory.
!
subroutine MPI_Status_set_elements_f08(status, datatype, count, ierror)
use, intrinsic :: iso_c_binding, only : c_loc, c_associated
use, intrinsic :: iso_c_binding, only : c_int, c_ptr
use :: mpi_f08, only : MPI_Status, MPI_Datatype
use :: mpi_f08, only : MPI_STATUS_IGNORE, MPIR_C_MPI_STATUS_IGNORE, assignment(=)
use :: mpi_c_interface, only : c_Datatype
use :: mpi_c_interface, only : c_Status
use :: mpi_c_interface, only : MPIR_Status_set_elements_c
implicit none
type(MPI_Status), intent(inout), target :: status
type(MPI_Datatype), intent(in) :: datatype
integer, intent(in) :: count
integer, optional, intent(out) :: ierror
type(c_Status), target :: status_c
integer(c_Datatype) :: datatype_c
integer(c_int) :: count_c
integer(c_int) :: ierror_c
if (c_int == kind(0)) then
if (c_associated(c_loc(status), c_loc(MPI_STATUS_IGNORE))) then
ierror_c = MPIR_Status_set_elements_c(MPIR_C_MPI_STATUS_IGNORE, datatype%MPI_VAL, count)
else
ierror_c = MPIR_Status_set_elements_c(c_loc(status), datatype%MPI_VAL, count)
end if
else
datatype_c = datatype%MPI_VAL
count_c = count
if (c_associated(c_loc(status), c_loc(MPI_STATUS_IGNORE))) then
ierror_c = MPIR_Status_set_elements_c(MPIR_C_MPI_STATUS_IGNORE, datatype_c, count_c)
else
ierror_c = MPIR_Status_set_elements_c(c_loc(status_c), datatype_c, count_c)
status = status_c
end if
end if
if (present(ierror)) ierror = ierror_c
end subroutine MPI_Status_set_elements_f08
| src/binding/fortran/use_mpi_f08/wrappers_f/status_set_elements_f08ts.f90 |
program scatter_vector
include 'mpif.h'
integer ndims,xmax,ymax,nnodes,myid,totelem
parameter(ndims=2)
parameter(xmax=1000,ymax=1000)
parameter(niters=1)
parameter (totelem=xmax*ymax)
integer comm,ierr
integer status(MPI_STATUS_SIZE)
double precision,allocatable,dimension(:,:) :: A
double precision,allocatable,dimension(:) :: V,dindex1,dindex2,gV
integer,allocatable,dimension(:) :: index1,index2
integer,allocatable,dimension(:) :: lindex1,lindex2
!distribute each array into nnodes processors except gV and index1 and index2
! these last 3 arrays are global arrays. gv will hold the all local V's
! index1 and index2 will hold all the local lindex1's and lindex2's
! respectively
integer xb,yb,i,j,nitems,xbv
comm=MPI_COMM_WORLD
call MPI_init(ierr)
call MPI_COMM_RANK(comm,myid,ierr)
call MPI_COMM_SIZE(comm,nnodes,ierr)
!initialize the input matrixes A and allocate necessary spaces for A,B
!partition the matrix a in (block ,*) way
xb = xmax/nnodes
xbv = totelem/nnodes
!allocate necessary arrays
allocate(A(xb,ymax))
allocate(V(xbv))
allocate(gV(totelem))
allocate(index1(totelem))
allocate(index2(totelem))
allocate(dindex1(totelem))
allocate(dindex2(totelem))
allocate(lindex1(xbv))
allocate(lindex2(xbv))
!last processor is generating random index vectors index1 and index2
! and partition them onto processors and send to correspoding processor
!also last processor is generating random data vector V for each processor
if (myid == nnodes -1) then
call random_number(dindex1)
call random_number(dindex2)
index1 = xmax*dindex1 + 1
index2 = ymax*dindex2 + 1
do np = 0,nnodes-1
call random_number(V)
V = 1000000.0*V
if (np < nnodes-1) then
call MPI_SEND(V,xbv,MPI_DOUBLE_PRECISION,np,0,comm,ierr)
call MPI_SEND(index1(xbv*np+1),xbv,MPI_INTEGER,np,0,comm,ierr)
call MPI_SEND(index1(xbv*np+1),xbv,MPI_INTEGER,np,0,comm,ierr)
endif
enddo
lindex1 = index1((nnodes-1)*xbv+1:totelem)
lindex2 = index2((nnodes-1)*xbv+1:totelem)
else
call MPI_RECV(V,xbv,MPI_DOUBLE_PRECISION,nnodes-1,0,comm,status,ierr)
call MPI_RECV(lindex1,xbv,MPI_INTEGER,nnodes-1,0,comm,status,ierr)
call MPI_RECV(lindex1,xbv,MPI_INTEGER,nnodes-1,0,comm,status,ierr)
endif
!start timer .....
time_begin = MPI_Wtime()
do iter = 1,niters
!collect all the local V's in gV
call MPI_ALLGATHER(V,xbv,MPI_DOUBLE_PRECISION, &
gV,xbv,MPI_DOUBLE_PRECISION,comm,ierr)
!collect all the local arrays index1's and index2's in index1 and index2
call MPI_ALLGATHER(lindex1,xbv,MPI_INTEGER,index1,&
xbv,MPI_INTEGER,comm,ierr)
call MPI_ALLGATHER(lindex2,xbv,MPI_INTEGER,index2,&
xbv,MPI_INTEGER,comm,ierr)
ilb = myid*xbv+1
iub = (myid+1)*xbv
do i=1,totelem
!If I am holding the vector index 'index1(i)' in my local array
!I will get the gV(i)
if ((index1(i) .ge. ilb).and.(index1(i).le.iub)) then
A(index1(i)-ilb+1,index2(i)) = gV(i)
endif
enddo
enddo
! Stop timer
time_end = MPI_Wtime()
if (myid == 0) then
print *,'Elapsed time ',niters,'iterations for scatter'
print *,'For matrix with dimensions',xmax,ymax ,'is'
print *,time_end-time_begin ,'seconds'
endif
deallocate(a)
deallocate(v)
deallocate(gv)
deallocate(index1)
deallocate(index2)
deallocate(lindex1)
deallocate(lindex2)
deallocate(dindex1)
deallocate(dindex2)
call MPI_FINALIZE(ierr)
end
SUBROUTINE all_to_all_int(myprocid,nnodes,comm,fx,global_fx,xbv,totelem)
integer xbv,totelem
integer fx(xbv),global_fx(totelem)
integer myprocid,nnodes,comm
include 'mpif.h'
integer dest,source,nproc,dest_id,ierr
integer status(MPI_STATUS_SIZE)
do j=1,xbv
global_fx(xbv*myprocid+1+j) = fx(j)
enddo
nproc = nnodes
kcnt = myprocid
dest = mod(myprocid+1,nproc)
source = mod(myprocid-1+nproc,nproc)
do i=1,nproc-1
if (mod (myprocid,2) .eq. 0) then
call MPI_SEND(global_fx(kcnt*xbv+1),xbv,&
MPI_INTEGER,dest,0,comm,ierr)
else
ikcnt = mod(kcnt-1+nproc,nproc)
call MPI_RECV(global_fx(ikcnt*xbv+1),xbv, &
MPI_INTEGER,source,0,comm,status,ierr)
endif
if (mod (myprocid,2) .eq. 1) then
call MPI_SEND(global_fx(kcnt*xbv+1),xbv,&
MPI_INTEGER,dest,0,comm,ierr)
else
ikcnt = mod(kcnt-1+nproc,nproc)
call MPI_RECV(global_fx(ikcnt*xbv+1),xbv, &
MPI_INTEGER,source,0,comm,status,ierr)
endif
kcnt = ikcnt
enddo
return
end
SUBROUTINE all_to_all_float(myprocid,nnodes,comm,fx,global_fx,xbv,totelem)
integer xbv,totelem
double precision fx(xbv),global_fx(totelem)
integer myprocid,nnodes,comm
include 'mpif.h'
integer dest,source,nproc,dest_id,ierr
integer status(MPI_STATUS_SIZE)
do j=1,xbv
global_fx(xbv*myprocid+1+j) = fx(j)
enddo
nproc = nnodes
kcnt = myprocid
dest = mod(myprocid+1,nproc)
source = mod(myprocid-1+nproc,nproc)
do i=1,nproc-1
if (mod (myprocid,2) .eq. 0) then
call MPI_SEND(global_fx(kcnt*xbv+1),xbv,&
MPI_DOUBLE_PRECISION,dest,0,comm,ierr)
else
ikcnt = mod(kcnt-1+nproc,nproc)
call MPI_RECV(global_fx(ikcnt*xbv+1),xbv, &
MPI_DOUBLE_PRECISION,source,0,comm,status,ierr)
endif
if (mod (myprocid,2) .eq. 1) then
call MPI_SEND(global_fx(kcnt*xbv+1),xbv,&
MPI_DOUBLE_PRECISION,dest,0,comm,ierr)
else
ikcnt = mod(kcnt-1+nproc,nproc)
call MPI_RECV(global_fx(ikcnt*xbv+1),xbv, &
MPI_DOUBLE_PRECISION,source,0,comm,status,ierr)
endif
kcnt = ikcnt
enddo
return
end
| files/mpi/scatter_with_mpi.f |
c
c -------------------------------------------------------
c
subroutine fluxad(xfluxm,xfluxp,yfluxm,yfluxp,
1 svdflx,mptr,mitot,mjtot,
2 nvar,lenbc,lratiox,lratioy,ng,dtf,dx,dy)
c
implicit double precision (a-h,o-z)
include "call.i"
c :::::::::::::::::::: FLUXAD ::::::::::::::::::::::::::::::::::
c save fine grid fluxes at the border of the grid, for fixing
c up the adjacent coarse cells. at each edge of the grid, only
c save the plus or minus fluxes, as necessary. For ex., on
c left edge of fine grid, it is the minus xfluxes that modify the
c coarse cell.
c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
dimension xfluxm(mitot,mjtot,nvar), yfluxm(mitot,mjtot,nvar)
dimension xfluxp(mitot,mjtot,nvar), yfluxp(mitot,mjtot,nvar)
dimension svdflx(nvar,lenbc)
nx = mitot-2*ng
ny = mjtot-2*ng
nyc = ny/lratioy
nxc = nx/lratiox
c ::::: left side saved first
lind = 0
do 100 j=1,nyc
lind = lind + 1
jfine = (j-1)*lratioy + ng
do 110 ivar = 1, nvar
do 120 l=1,lratioy
svdflx(ivar,lind) = svdflx(ivar,lind) +
1 xfluxm(ng+1,jfine+l,ivar)*dtf*dy
c write(dbugunit,900)lind,xfluxm(1,jfine+l,ivar),
c . xfluxp(1,jfine+l,ivar)
900 format(' lind ', i4,' m & p ',2e15.7,' svd ',e15.7)
120 continue
110 continue
100 continue
c ::::: top side
c write(dbugunit,*)" saving top side "
do 200 i=1,nxc
lind = lind + 1
ifine = (i-1)*lratiox + ng
do 210 ivar = 1, nvar
do 220 l=1,lratiox
svdflx(ivar,lind) = svdflx(ivar,lind) +
1 yfluxp(ifine+l,mjtot-ng+1,ivar)*dtf*dx
c write(dbugunit,900)lind,yfluxm(ifine+l,mjtot-ng+1,
c . ivar),yfluxp(ifine+l,mjtot-ng+1,ivar),
c . svdflx(ivar,lind)
220 continue
210 continue
200 continue
c ::::: right side
do 300 j=1,nyc
lind = lind + 1
jfine = (j-1)*lratioy + ng
do 310 ivar = 1, nvar
do 320 l=1,lratioy
svdflx(ivar,lind) = svdflx(ivar,lind) +
1 xfluxp(mitot-ng+1,jfine+l,ivar)*dtf*dy
c write(dbugunit,900)lind,xfluxm(mitot-ng+1,jfine+l,
c ivar),xfluxp(mitot-ng+1,jfine+l,ivar)
320 continue
310 continue
300 continue
c ::::: bottom side
c write(dbugunit,*)" saving bottom side "
do 400 i=1,nxc
lind = lind + 1
ifine = (i-1)*lratiox + ng
do 410 ivar = 1, nvar
do 420 l=1,lratiox
svdflx(ivar,lind) = svdflx(ivar,lind) +
1 yfluxm(ifine+l,ng+1,ivar)*dtf*dx
c write(dbugunit,900)lind,yfluxm(ifine+l,ng+1,ivar),
c . yfluxp(ifine+l,ng+1,ivar),svdflx(ivar,lind)
420 continue
410 continue
400 continue
return
end
| amrclaw/2d/lib/fluxad.f |
SUBROUTINE gather_real(SEND,RECV,SIZE,root)
IMPLICIT NONE
include 'mpif.h'
INTEGER SIZE, ROOT
REAL*8 SEND(*), RECV(*)
INTEGER IERR
CALL MPI_GATHER(send,size,MPI_DOUBLE_PRECISION,
& recv,size,MPI_DOUBLE_PRECISION,ROOT,MPI_COMM_WORLD,IERR)
RETURN
END SUBROUTINE
SUBROUTINE gatherv_real( SEND, ssize, RECV,
& rsize, rdisp, root )
IMPLICIT NONE
include 'mpif.h'
INTEGER ssize, ROOT
INTEGER rsize(*), rdisp(*)
REAL*8 SEND(*), RECV(*)
INTEGER IERR
CALL MPI_GATHERV( send, ssize, MPI_DOUBLE_PRECISION,
& recv, rsize, rdisp, MPI_DOUBLE_PRECISION, ROOT,
& MPI_COMM_WORLD, IERR )
RETURN
END SUBROUTINE
| comm/gather.f |
c Wrappers allowing to link MacOSX's Accelerate framework to
c gfortran compiled code
c Accelerate BLAS is cblas (http://www.netlib.org/blas/blast-forum/cblas.tgz);
c these wrappers call the cblas functions via the C-functions defined
c in veclib_cabi.c
REAL FUNCTION WSDOT( N, SX, INCX, SY, INCY )
INTEGER INCX, INCY, N
REAL SX(*), SY(*)
REAL RESULT
EXTERNAL ACC_SDOT
CALL ACC_SDOT( N, SX, INCX, SY, INCY, RESULT )
WSDOT = RESULT
END FUNCTION
REAL FUNCTION WSDSDOT( N, SB, SX, INCX, SY, INCY )
REAL SB
INTEGER INCX, INCY, N
REAL SX(*), SY(*)
REAL RESULT
EXTERNAL ACC_SDSDOT
CALL ACC_SDSDOT( N, SB, SX, INCX, SY, INCY, RESULT )
WSDSDOT = RESULT
END FUNCTION
REAL FUNCTION WSASUM( N, SX, INCX )
INTEGER INCX, N
REAL SX(*)
REAL RESULT
EXTERNAL ACC_SASUM
CALL ACC_SASUM( N, SX, INCX, RESULT )
WSASUM = RESULT
END FUNCTION
REAL FUNCTION WSNRM2( N, SX, INCX )
INTEGER INCX, N
REAL SX(*)
REAL RESULT
EXTERNAL ACC_SNRM2
CALL ACC_SNRM2( N, SX, INCX, RESULT )
WSNRM2 = RESULT
END FUNCTION
REAL FUNCTION WSCASUM( N, CX, INCX )
INTEGER INCX, N
COMPLEX CX(*)
REAL RESULT
EXTERNAL ACC_SCASUM
CALL ACC_SCASUM( N, CX, INCX, RESULT )
WSCASUM = RESULT
END FUNCTION
REAL FUNCTION WSCNRM2( N, CX, INCX )
INTEGER INCX, N
COMPLEX CX(*)
REAL RESULT
EXTERNAL ACC_SCNRM2
CALL ACC_SCNRM2( N, CX, INCX, RESULT )
WSCNRM2 = RESULT
END FUNCTION
c The LAPACK in the Accelerate framework is a CLAPACK
c (www.netlib.org/clapack) and has hence a different interface than the
c modern Fortran LAPACK libraries. These wrappers here help to link
c Fortran code to Accelerate.
c This wrapper files covers all Lapack functions that are in all versions
c before Lapack 3.2 (Lapack 3.2 adds CLANHF and SLANSF that would be
c problematic, but those do not exist in OSX <= 10.6, and are actually not
c used in scipy)
REAL FUNCTION WCLANGB( NORM, N, KL, KU, AB, LDAB, WORK )
CHARACTER NORM
INTEGER KL, KU, LDAB, N
REAL WORK( * )
COMPLEX AB( LDAB, * )
EXTERNAL CLANGB
DOUBLE PRECISION CLANGB
WCLANGB = REAL(CLANGB( NORM, N, KL, KU, AB, LDAB, WORK ))
END FUNCTION
REAL FUNCTION WCLANGE( NORM, M, N, A, LDA, WORK )
CHARACTER NORM
INTEGER LDA, M, N
REAL WORK( * )
COMPLEX A( LDA, * )
EXTERNAL CLANGE
DOUBLE PRECISION CLANGE
WCLANGE = REAL(CLANGE( NORM, M, N, A, LDA, WORK ))
END FUNCTION
REAL FUNCTION WCLANGT( NORM, N, DL, D, DU )
CHARACTER NORM
INTEGER N
COMPLEX D( * ), DL( * ), DU( * )
EXTERNAL CLANGT
DOUBLE PRECISION CLANGT
WCLANGT = REAL(CLANGT( NORM, N, DL, D, DU ))
END FUNCTION
REAL FUNCTION WCLANHB( NORM, UPLO, N, K, AB, LDAB, WORK )
CHARACTER NORM, UPLO
INTEGER K, LDAB, N
REAL WORK( * )
COMPLEX AB( LDAB, * )
EXTERNAL CLANHB
DOUBLE PRECISION CLANHB
WCLANHB = REAL(CLANHB( NORM, UPLO, N, K, AB, LDAB, WORK ))
END FUNCTION
REAL FUNCTION WCLANHE( NORM, UPLO, N, A, LDA, WORK )
CHARACTER NORM, UPLO
INTEGER LDA, N
REAL WORK( * )
COMPLEX A( LDA, * )
EXTERNAL CLANHE
DOUBLE PRECISION CLANHE
WCLANHE = REAL(CLANHE( NORM, UPLO, N, A, LDA, WORK ))
END FUNCTION
REAL FUNCTION WCLANHP( NORM, UPLO, N, AP, WORK )
CHARACTER NORM, UPLO
INTEGER N
REAL WORK( * )
COMPLEX AP( * )
EXTERNAL CLANHP
DOUBLE PRECISION CLANHP
WCLANHP = REAL(CLANHP( NORM, UPLO, N, AP, WORK ))
END FUNCTION
REAL FUNCTION WCLANHS( NORM, N, A, LDA, WORK )
CHARACTER NORM
INTEGER LDA, N
REAL WORK( * )
COMPLEX A( LDA, * )
EXTERNAL CLANHS
DOUBLE PRECISION CLANHS
WCLANHS = REAL(CLANHS( NORM, N, A, LDA, WORK ))
END FUNCTION
REAL FUNCTION WCLANHT( NORM, N, D, E )
CHARACTER NORM
INTEGER N
REAL D( * )
COMPLEX E( * )
EXTERNAL CLANHT
DOUBLE PRECISION CLANHT
WCLANHT = REAL(CLANHT( NORM, N, D, E ))
END FUNCTION
REAL FUNCTION WCLANSB( NORM, UPLO, N, K, AB, LDAB, WORK )
CHARACTER NORM, UPLO
INTEGER K, LDAB, N
REAL WORK( * )
COMPLEX AB( LDAB, * )
EXTERNAL CLANSB
DOUBLE PRECISION CLANSB
WCLANSB = REAL(CLANSB( NORM, UPLO, N, K, AB, LDAB, WORK ))
END FUNCTION
REAL FUNCTION WCLANSP( NORM, UPLO, N, AP, WORK )
CHARACTER NORM, UPLO
INTEGER N
REAL WORK( * )
COMPLEX AP( * )
EXTERNAL CLANSP
DOUBLE PRECISION CLANSP
WCLANSP = REAL(CLANSP( NORM, UPLO, N, AP, WORK ))
END FUNCTION
REAL FUNCTION WCLANSY( NORM, UPLO, N, A, LDA, WORK )
CHARACTER NORM, UPLO
INTEGER LDA, N
REAL WORK( * )
COMPLEX A( LDA, * )
EXTERNAL CLANSY
DOUBLE PRECISION CLANSY
WCLANSY = REAL(CLANSY( NORM, UPLO, N, A, LDA, WORK ))
END FUNCTION
REAL FUNCTION WCLANTB( NORM, UPLO, DIAG, N, K, AB, LDAB, WORK )
CHARACTER DIAG, NORM, UPLO
INTEGER K, LDAB, N
REAL WORK( * )
COMPLEX AB( LDAB, * )
EXTERNAL CLANTB
DOUBLE PRECISION CLANTB
WCLANTB = REAL(CLANTB( NORM, UPLO, DIAG, N, K, AB, LDAB, WORK ))
END FUNCTION
REAL FUNCTION WCLANTP( NORM, UPLO, DIAG, N, AP, WORK )
CHARACTER DIAG, NORM, UPLO
INTEGER N
REAL WORK( * )
COMPLEX AP( * )
EXTERNAL CLANTP
DOUBLE PRECISION CLANTP
WCLANTP = REAL(CLANTP( NORM, UPLO, DIAG, N, AP, WORK ))
END FUNCTION
REAL FUNCTION WCLANTR( NORM, UPLO, DIAG, M, N, A, LDA, WORK )
CHARACTER DIAG, NORM, UPLO
INTEGER LDA, M, N
REAL WORK( * )
COMPLEX A( LDA, * )
EXTERNAL CLANTR
DOUBLE PRECISION CLANTR
WCLANTR = REAL(CLANTR( NORM, UPLO, DIAG, M, N, A, LDA, WORK ))
END FUNCTION
REAL FUNCTION WSCSUM1( N, CX, INCX )
INTEGER INCX, N
COMPLEX CX( * )
EXTERNAL SCSUM1
DOUBLE PRECISION SCSUM1
WSCSUM1 = REAL(SCSUM1( N, CX, INCX ))
END FUNCTION
REAL FUNCTION WSLANGB( NORM, N, KL, KU, AB, LDAB, WORK )
CHARACTER NORM
INTEGER KL, KU, LDAB, N
REAL AB( LDAB, * ), WORK( * )
EXTERNAL SLANGB
DOUBLE PRECISION SLANGB
WSLANGB = REAL(SLANGB( NORM, N, KL, KU, AB, LDAB, WORK ))
END FUNCTION
REAL FUNCTION WSLANGE( NORM, M, N, A, LDA, WORK )
CHARACTER NORM
INTEGER LDA, M, N
REAL A( LDA, * ), WORK( * )
EXTERNAL SLANGE
DOUBLE PRECISION SLANGE
WSLANGE = REAL(SLANGE( NORM, M, N, A, LDA, WORK ))
END FUNCTION
REAL FUNCTION WSLANGT( NORM, N, DL, D, DU )
CHARACTER NORM
INTEGER N
REAL D( * ), DL( * ), DU( * )
EXTERNAL SLANGT
DOUBLE PRECISION SLANGT
WSLANGT = REAL(SLANGT( NORM, N, DL, D, DU ))
END FUNCTION
REAL FUNCTION WSLANHS( NORM, N, A, LDA, WORK )
CHARACTER NORM
INTEGER LDA, N
REAL A( LDA, * ), WORK( * )
EXTERNAL SLANHS
DOUBLE PRECISION SLANHS
WSLANHS = REAL(SLANHS( NORM, N, A, LDA, WORK ))
END FUNCTION
REAL FUNCTION WSLANSB( NORM, UPLO, N, K, AB, LDAB, WORK )
CHARACTER NORM, UPLO
INTEGER K, LDAB, N
REAL AB( LDAB, * ), WORK( * )
EXTERNAL SLANSB
DOUBLE PRECISION SLANSB
WSLANSB = REAL(SLANSB( NORM, UPLO, N, K, AB, LDAB, WORK ))
END FUNCTION
REAL FUNCTION WSLANSP( NORM, UPLO, N, AP, WORK )
CHARACTER NORM, UPLO
INTEGER N
REAL AP( * ), WORK( * )
EXTERNAL SLANSP
DOUBLE PRECISION SLANSP
WSLANSP = REAL(SLANSP( NORM, UPLO, N, AP, WORK ))
END FUNCTION
REAL FUNCTION WSLANST( NORM, N, D, E )
CHARACTER NORM
INTEGER N
REAL D( * ), E( * )
EXTERNAL SLANST
DOUBLE PRECISION SLANST
WSLANST = REAL(SLANST( NORM, N, D, E ))
END FUNCTION
REAL FUNCTION WSLANSY( NORM, UPLO, N, A, LDA, WORK )
CHARACTER NORM, UPLO
INTEGER LDA, N
REAL A( LDA, * ), WORK( * )
EXTERNAL SLANSY
DOUBLE PRECISION SLANSY
WSLANSY = REAL(SLANSY( NORM, UPLO, N, A, LDA, WORK ))
END FUNCTION
REAL FUNCTION WSLANTB( NORM, UPLO, DIAG, N, K, AB, LDAB, WORK )
CHARACTER DIAG, NORM, UPLO
INTEGER K, LDAB, N
REAL AB( LDAB, * ), WORK( * )
EXTERNAL SLANTB
DOUBLE PRECISION SLANTB
WSLANTB = REAL(SLANTB( NORM, UPLO, DIAG, N, K, AB, LDAB, WORK ))
END FUNCTION
REAL FUNCTION WSLANTP( NORM, UPLO, DIAG, N, AP, WORK )
CHARACTER DIAG, NORM, UPLO
INTEGER N
REAL AP( * ), WORK( * )
EXTERNAL SLANTP
DOUBLE PRECISION SLANTP
WSLANTP = REAL(SLANTP( NORM, UPLO, DIAG, N, AP, WORK ))
END FUNCTION
REAL FUNCTION WSLANTR( NORM, UPLO, DIAG, M, N, A, LDA, WORK )
CHARACTER DIAG, NORM, UPLO
INTEGER LDA, M, N
REAL A( LDA, * ), WORK( * )
EXTERNAL SLANTR
DOUBLE PRECISION SLANTR
WSLANTR = REAL(SLANTR( NORM, UPLO, DIAG, M, N, A, LDA, WORK ))
END FUNCTION
REAL FUNCTION WSLAPY2( X, Y )
REAL X, Y
EXTERNAL SLAPY2
DOUBLE PRECISION SLAPY2
WSLAPY2 = REAL(SLAPY2( X, Y ))
END FUNCTION
REAL FUNCTION WSLAPY3( X, Y, Z )
REAL X, Y, Z
EXTERNAL SLAPY3
DOUBLE PRECISION SLAPY3
WSLAPY3 = REAL(SLAPY3( X, Y, Z ))
END FUNCTION
REAL FUNCTION WSLAMCH( CMACH )
CHARACTER CMACH
EXTERNAL SLAMCH
DOUBLE PRECISION SLAMCH
WSLAMCH = REAL(SLAMCH( CMACH ))
END FUNCTION
REAL FUNCTION WSLAMC3( A, B )
REAL A, B
EXTERNAL SLAMC3
DOUBLE PRECISION SLAMC3
WSLAMC3 = REAL(SLAMC3( A, B ))
END FUNCTION
| scipy/_build_utils/src/wrap_accelerate_f.f |
! Copyright (c) 2021-2022, University of Colorado Denver. All rights reserved.
!
! This file is part of <T>LAPACK.
! <T>LAPACK is free software: you can redistribute it and/or modify it under
! the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
subroutine ssymm ( &
layout, side, uplo, m, n, alpha, A, lda, B, ldb, beta, C, ldc )
use, intrinsic :: iso_c_binding
use constants, &
only: wp => sp, &
blas_size
implicit none
character :: layout, side, uplo
integer(blas_size) :: m, n, lda, ldb, ldc
real(wp) :: alpha, beta
real(wp), target :: A, B, C
character(c_char) :: c_layout, c_side, c_uplo
include "tblas.fi"
c_layout = layout
c_side = side
c_uplo = uplo
call ssymm_ ( &
c_layout, c_side, c_uplo, m, n, alpha, &
c_loc(A), lda, c_loc(B), ldb, beta, c_loc(C), ldc )
end subroutine
| src/blas/symm.f90 |
c read a few eigenvectors, a spectrum, and try to fit z
program fitz
include 'specarray.h'
parameter(NMAXVECTS=12)
parameter(NMAXSTEP=2*NLOGWMAX)
c scale sky by estimating read and photon noise ?
parameter (IFSCALENOISE=1)
c plot intermediate steps?
parameter (IFPLOTALL=0)
c read spectrum names from a file?
parameter (IFFILE=1)
c overplot the actual z, when known?
parameter (IFREALZ=1)
c max number of minima to find and zestimates to return
parameter (NMAXEST=12)
c real evects(NMAXVECTS,NLOGWMAX)
integer koffset,nvmax,nwlmax
real z
common /vectorfit/ koffset,z,nvmax,nwlmax,
$ evects(NMAXVECTS,NLOGWMAX)
real spec1(NWAVEMAX),espec1(NWAVEMAX)
real spec2(NLOGWMAX),espec2(NLOGWMAX)
real spec3(NLOGWMAX),espec3(NLOGWMAX)
real tmpspec(NLOGWMAX),wavelog(NLOGWMAX),wavelin(NWAVEMAX)
integer ifit(NLOGWMAX)
real wfit(NLOGWMAX),sfit(NLOGWMAX),efit(NLOGWMAX)
real rifit(NLOGWMAX),fitvect(NLOGWMAX)
real waverest1(NLOGWMAX)
real wrestlin(NWAVEMAX)
real zp1log(NMAXSTEP),zarr(NMAXSTEP)
real rnparr(NMAXSTEP)
integer indkarr(NMAXEST)
real diffarr(NMAXEST),zestarr(NMAXEST)
c real xpl(2),ypl(2)
c real zout(NLOGWMAX),zchisq(NLOGWMAX)
character sname*60,esname*60,vname*60
character answ*3,tlabel*60,xlabel*60
character fsname*60,fename*60,fzname*60
integer isize(7)
c stuff for svdfit
real uu(NLOGWMAX,NMAXVECTS)
real vv(NMAXVECTS,NMAXVECTS),ww(NMAXVECTS)
real acoeff(NMAXVECTS),evals(NMAXVECTS)
real chifit(NMAXSTEP),rchifit(NMAXSTEP)
external funcs
include 'pcredshift.h'
c call pgbeg(0,'?',2,2)
call pgbeg(0,'?',1,1)
call pgscf(2)
call pgsch(1.3)
write(*,'("Full continuum fit subtraction [1,y-yes]? ",$)')
read(*,'(a1)') answ
if (answ(1:1) .eq. '0' .or. answ(1:1) .eq. 'n' .or.
$ answ(1:1) .eq. 'N') then
ifcontsub = 0
else
ifcontsub = 1
end if
write(*,'("Do mean subtraction [1,y-yes]? ",$)')
read(*,'(a1)') answ
if (answ(1:1) .eq. '0' .or. answ(1:1) .eq. 'n' .or.
$ answ(1:1) .eq. 'N') then
ifmeansub = 0
else
ifmeansub = 1
end if
100 write(*,
$ '("Diameter for median smoothing, pixels [0,1=none]: ",$)')
read(*,'(a3)') answ
if (answ(1:3) .eq. ' ') then
ndiamed = 0
else
read(answ,*,err=100) ndiamed
end if
c write(*,
c $ '("Restwave spectrum region to use in PCA, min, max: ",$)')
c read(*,*) pcawmin,pcawmax
c pwminlog = log10(pcawmin)
c pwmaxlog = log10(pcawmax)
nvmax=NMAXVECTS
nwlmax=NLOGWMAX
c open file and read eigenvectors. nvects is returned as
c the # of vectors to use, nw is the actual # of wavelength pixels
call readevects(evects,nvmax,nwlmax,waverest1,nv,nw)
nwlog = nw
c figure out w0 and dw for the eigenvectors. This is in log w
c There is no check yet to make sure it's evenly spaced.
dwrlog = (waverest1(nw) - waverest1(1)) / (nwlog-1.)
w0rlog = waverest1(1) - dwrlog
do i=1,nwlog
wrestlin(i) = 10**waverest1(i)
end do
c write(*,*) "w0rlog, dwrlog = ", w0rlog,dwrlog
c plot the eigenvectors
call pgsubp(2,2)
do i=1,nv
do j=1,nwlog
tmpspec(j) = evects(i,j)
end do
call showspec(nwlog,waverest1,tmpspec)
write(tlabel,'(a,1x,i3)') "eigenvector",i-1
call pglabel("log wavelength"," ",tlabel)
end do
c call pgsubp(1,1)
call pgsubp(2,2)
200 continue
if (IFFILE .eq. 1) then
write(*,'("File with spectrum names: ",$)')
read(*,'(a)') fsname
open(10,file=fsname,status='old',err=200)
write(*,'("File with sky/rms names: ",$)')
read(*,'(a)') fename
open(11,file=fename,status='old',err=200)
if (IFREALZ .eq. 1) then
write(*,'("File with actual zs for plot [none]: ",$)')
read(*,'(a)') fzname
if (fzname(1:3) .ne. ' ') then
open(12,file=fzname,status='old',err=202)
ifzfile=1
else
c no actual z file
ifzfile=0
end if
202 continue
end if
end if
open(2,file='fitz.out',status='unknown')
open(3,file='fitz.out1',status='unknown')
open(4,file='fitz.out2',status='unknown')
220 continue
c open files and read spec and error, with wavelength calib.
if (IFFILE .eq. 1) then
read(10,'(a)',err=666,end=666) sname
read(11,'(a)',err=666,end=666) esname
zreal=1.0e6
if (IFREALZ .eq. 1 .and. ifzfile .eq. 1) then
read(12,*,err=222,end=222) zreal
end if
222 continue
else
write(*,'("fits file with spectrum [quit]: ",$)')
read(*,'(a)') sname
if (sname(1:3) .eq. ' ') go to 666
write(*,'("fits file with sky/rms [quit]: ",$)')
read(*,'(a)') esname
if (esname(1:3) .eq. ' ') go to 666
if (IFREALZ .eq. 1) then
write(*,'("actual z for plotting [none]: ",$)')
read(*,'(a)') fzname
zreal=1.0e6
if (fzname(1:3) .ne. ' ') then
read(fzname,*,err=232) zreal
end if
232 continue
end if
end if
call imopen(sname,1,imgs,ier)
if (ier .ne. 0) go to 220
call imgsiz(imgs,isize,idim,itype,ier)
c trim a buffer at end to get rid of the region where Marc encoded
c the slit number
ibuff2 = 25
nwspec = isize(1) - ibuff2
call imopen(esname,1,imge,ier)
c call imgsiz(imge,isize,idim,itype,ier)
if (ier .ne. 0) go to 220
call imgl1r(imgs,spec1,ier)
call imgl1r(imge,espec1,ier)
c find wavelength of pixel 0, and dw/dpix
call imgkwr(imgs,'CRPIX1',refpix,ier)
c if (ier .ne. 0) refpix = badset
if (ier .ne. 0) then
ier=0
refpix = 0.
end if
call imgkwr(imgs,'CRVAL1',refw,ier)
if (ier .ne. 0) refw = badset
call imgkwr(imgs,'CDELT1',dwsp,ier)
if (ier .ne. 0 .or. abs(dwsp) .lt. 1.e-3) then
ier=0
call imgkwr(imgs,'CD1_1',dwsp,ier)
if (ier .ne. 0) dwsp = badset
end if
if (refpix .gt. bad .and. refw .gt. bad .and. dwsp .gt. bad)
$ then
w0sp = refw - refpix*dwsp
c dws = dwsp
else
c we should really do something here
c w0s = badset
c dws = badset
write(*,
$ '("Couldnt get w0 and dw for ",a," enter w0,dw: ",$)') sname
read(*,*) w0sp,dwsp
end if
write(*,*) "w0sp, dwsp = ", w0sp,dwsp
call imclos(imgs,ier)
call imclos(imge,ier)
c zero out anything beyond the actual spectrum
do i=nwspec+1,nw
spec1(i) = 0.0
espec1(i) = 0.0
end do
c try to clean out bad values
badmax = 5000.
do i=1,nw
if(spec1(i) .lt. bad .or. spec1(i) .gt. badmax)
$ spec1(i) = badset
if(espec1(i) .lt. bad .or. espec1(i) .gt. badmax)
$ espec1(i) = badset
end do
c Figure out the ref wavelength for the log rebinning so that
c it falls on the wl scale of the eigenvectors.
tmp = log10(w0sp)
itmp = int( (tmp-w0rlog)/dwrlog )
w0log = w0rlog + dwrlog*itmp
c k0offset is the offset in integer index of log wavelength
c from the beginning of the eigenvectors to the spectrum to be fit.
k0offset = itmp
dwlog = dwrlog
c write(*,*) "w0log, dwlog = ", w0log,dwlog
c convert sky spectrum into std.dev spectrum. This might be better
c done after smoothing and log rebinning?
c Placeholder assumptions: 2x30 min exposures, 5 pixel diam
c extraction window.
if (IFSCALENOISE .eq. 1) then
nexp = 2
exptime = 30.*60.
c dpix = 5.
dpix = 1.
call scalenoise(espec1,nwspec,nexp,exptime,dpix,espec2)
else
c or if the sky spectrum is actually a rms/per pixel spectrum
c we could do nothing, or scale down by a factor of
c sqrt(#pixels). #pixels is most likely 7.
do i=1,nwspec
espec2(i) = espec1(i) / sqrt(7.0)
end do
end if
do i=1,nw
wavelin(i) = w0sp+i*dwsp
wavelog(i) = log10(wavelin(i))
end do
if (IFPLOTALL .ne. 0) then
call showspec(nwspec,wavelin,spec1)
call pgqci(indexc)
call pgsci(3)
call pgline(nwspec,wavelin,espec2)
call pgsci(indexc)
call pglabel("wavelength","counts","spectrum and error")
end if
c blank out? blankoutsky is supposed to run on a 2-d array
call blankoutsky(spec1,1,1,nwspec,wavelin)
cc find region of good data
c call findends(nwspec,spec1,imin,imax)
c imingood = imin
c nwspecgood = imax-imin+1
c median smooth
if (ndiamed .gt. 1) then
call medsmooth(nwspec,spec1,ndiamed,spec2)
c call medsmooth(nwspecgood,spec1(imingood),ndiamed,
c $ spec2(imingood))
c attempt to compensate the errors. I divided ndiamed by 2 as
c a hack since adjacent pixels are not independent (assume the #
C of indep measurements is about pixels/2 if well sampled)
tmp = sqrt(max(ndiamed/2.,1.))
do i=1,nwspec
espec2(i) = espec2(i) / tmp
end do
else
do i=1,nwspec
spec2(i) = spec1(i)
espec2(i) = espec2(i)
end do
end if
if (IFPLOTALL .ne. 0) then
call showspec(nwspec,wavelin,spec2)
call pglabel("wavelength","counts","median smoothed")
call pgqci(indexc)
call pgsci(3)
call pgline(nwspec,wavelin,espec2)
call pgsci(indexc)
end if
c log rebin both. log rebinning the std dev the same way is a
c total hack, thus it is better done on the variance
call logrebin(spec2,nwspec,w0sp,dwsp,nwlog,w0log,dwlog,spec3)
c call logrebin(spec2(imingood),nwspecgood,w0sp,dwsp,
c $ nwlog,w0log,dwlog,spec3)
c convert std dev to variance
do i=1,nwlog
espec3(i) = espec2(i)**2
end do
call logrebin(espec3,nwspec,w0sp,dwsp,nwlog,w0log,dwlog,espec2)
c call logrebin(espec3(imingood),nwspecgood,w0sp,dwsp,
c $ nwlog,w0log,dwlog,espec2)
c convert back
do i=1,nwlog
espec3(i) = sqrt(max(espec2(i),1.e-2))
end do
if (IFPLOTALL .ne. 0) then
call showspec(nwlog,wavelog,spec3)
call pglabel("log wavelength","counts","log rebinned")
call pgqci(indexc)
call pgsci(3)
call pgline(nwlog,wavelog,espec3)
call pgsci(indexc)
end if
c find&clean ends
call findends(nwlog,spec3,imin,imax)
call cleanends(nwlog,spec3,imin,imax)
write(*,*) "imin, imax = ", imin,imax
c continuum subtract
if (ifcontsub .ne. 0) then
contwrad = 100.*dwlog
call contsubmed(spec3,nwlog,dwlog,contwrad)
else
call contsubconst(spec3,nwlog)
end if
if (IFPLOTALL .ne. 0) then
call showspec(nwlog,wavelog,spec3)
call pgqci(indexc)
call pgsci(3)
call pgline(nwlog,wavelog,espec3)
call pgsci(indexc)
call pglabel("log wavelength","counts","continuum subtracted")
end if
c copy wave and spec to temp array, cleaning out bad points
npfit=0
do i=1,nwlog
if(spec3(i) .gt. bad .and. espec3(i) .gt. bad) then
npfit=npfit+1
ifit(npfit) = i
rifit(npfit) = real(i)
wfit(npfit) = w0log + i*dwlog
sfit(npfit) = spec3(i)
efit(npfit) = espec3(i)
end if
end do
write (*,*) npfit, " points to fit"
c if (IFPLOTALL .ne. 0) then
call showspec(npfit,wfit,sfit)
call pgqci(indexc)
call pgsci(3)
call pgline(npfit,wfit,efit)
call pgsci(indexc)
call pglabel("log wavelength","counts",
$ "spectrum and error to fit, "//sname)
c end if
c What are the good data regions? The spectrum was
c good from imin to imax (before cleanends). Eigenvector 1
c (actually the mean) is good from jmin to jmax.
do j=1,nwlog
spec2(j) = evects(1,j)
end do
call findends(nwlog,spec2,jmin,jmax)
c write(*,*) 'imin,imax,jmin,jmax, k0off: ',imin,imax,jmin,jmax,
c $ k0offset
c loop over steps in log w. the spectrum, indexed by i,
c is offset to the red of the eigenvectors, indexed by j,
c by k steps: j+k = i, k = i-j
c and note that the two scales are offset by k0offset, so when
c z=0, i=j-k0offset. Typically the spectrum starts redder
c than the eigenv. so k0offset>0. If we started at
c z=0, k would start at -koffset.
c log w = log wrest + log(1+z), so k*dwlog = log(1+z)
c Start with an offset of z=-0.01
kmin = int(log10(1-0.01)/dwlog) - k0offset
c For pos. redshift, i+k0offset>j (i is position in spectrum, j in evect)
c Go to the point where only 10 pts overlap, which doesn't
c depend on k0offset.
kmax = imax-10-jmin
nk=kmax-kmin+1
c write(*,*) "kmin, kmax: ",kmin,kmax
tmp1 = (kmin+k0offset)*dwlog
tmp2 = (kmax+k0offset)*dwlog
c write(*,*) "log(1+z): ",tmp1,tmp2," z: ",
c $ 10**tmp1-1.0,10**tmp2-1.0
c open(2,file='fitz.out1',status='unknown')
do k=kmin,kmax
c kindex is 1 when k=kmin
kindex = k-kmin+1
c for passing k to the funcs subroutine
koffset=k
zp1log(kindex) = (k+k0offset)*dwlog
zarr(kindex) = 10**zp1log(kindex) - 1.0
z = zarr(kindex)
c we should only use the data that overlaps the eigenvectors,
c the eigenvectors extend from jmin to jmax, and i=j+k.
c But, since we cleaned out bad points, the spectrum to fit
c is no longer evenly spaced in dwlog, so ifitmax is not
c trivial to calculate. Bummer!
c that is, what I've been calling "i" is the index of spec3(i),
c and the contents of ifit() and rifit(), but it is not the
c index of ifit
iminorig = jmin+k
imaxorig = jmax+k
c now find the corresponding index of ifit - i.e.
c we want iminfit where ifit(iminfit) >= iminorig. Confused yet?
call findindex(npfit,ifit,iminorig,imaxorig,iminfit,imaxfit)
npfittmp = imaxfit-iminfit+1
rnparr(kindex) = real(npfittmp)
c write(*,*) "iminfit,imaxfit: ",iminfit,imaxfit,npfittmp
c now we gotta only use the matching points in the eigenvectors,
c which is a PITA. Actually we've solved this through the way
c that funcs() works.
c do fit using svdfit or something like it.
c Each of the functions will be an eigenvector
c call bigsvdfit(wfit,sfit,efit,npfit,acoeff,nv,uu,vv,ww,
c $ nwlmax,nvmax,chisq1,funcs)
c call bigsvdfit(rifit,sfit,efit,npfit,acoeff,nv,uu,vv,ww,
c $ nwlmax,nvmax,chisq1,funcs)
call bigsvdfit(rifit(iminfit),sfit(iminfit),efit(iminfit),
$ npfittmp,acoeff,nv,uu,vv,ww,nwlmax,nvmax,chisq1,funcs)
chifit(kindex) = chisq1
c to get rid of division by zero when there were no points
c to fit.
rchifit(kindex) = chisq1/max(real(npfittmp),1.e-4)
c write(2,*) k,kindex,npfittmp,zp1log(kindex),zarr(kindex),
c $ chifit(kindex),rchifit(kindex)
end do
c close(2)
c find the absolute minimum in chi-squared. there are probably
c better ways to do this in the long run
c call findabsmin(nk,chifit,indkmin,chimin)
c call findabsmin(nk,rchifit,indkrmin,rchimin)
c try finding the point with the biggest drop below "continuum"
c i.e. deepest local minimum
call findlocmin(nk,chifit,indkmin,chimin,chiminavg)
call findlocmin(nk,rchifit,indkrmin,rchimin,rchiminavg)
c find the n deepest local minima in chi squared
nfind=5
call findmultmin(nk,chifit,nfind,indkarr,diffarr)
zmin=zarr(indkmin)
zrmin=zarr(indkrmin)
do i=1,nfind
zestarr(i) = zarr(indkarr(i))
end do
write(*,*) "chisq min at ",indkmin,zmin,chimin,chiminavg
write(*,*) "reduced chisq min at ",indkrmin,zrmin,rchimin,
$ rchiminavg
c write stuff to output files.
c 2 - fitz.out gets # of z-estimates, z-estimates, spec name
c 3 - fitz.out1 gets specname(truncated), z(deepest chisq min) ,
c z(deepest rchisq min), chi-min, chi-"continuum",
c rchi-min, rchi-"continuum"
c 4 - fitz.out2 gets for each z-est: k-index, z-est, depth in chisq
c write(3,'(a,f7.4,3x,f7.4)') sname,zmin,zrmin
write(3,'(a25,2(3x,f7.4),3x,4(1x,1pe10.3))')
$ sname,zmin,zrmin,chimin,chiminavg,rchimin,rchiminavg
write(2,'(i2,$)') nfind
do i=1,nfind
write(2,'(2x,f7.4$)') zestarr(i)
write(4,'(i5,2x,f7.4,2x,f9.1,$)') indkarr(i),zestarr(i),
$ diffarr(i)
end do
write(2,'(2x,a25)') sname
write(4,'(2x,a25)') sname
c plot
c call showspec(nk,zp1log,chifit)
c call plotz(log10(1.+zreal),log10(1.+zmin),log10(1+zrmin))
c write(xlabel,1010) "log(1+z)",zreal,zmin,zrmin
c call pglabel(xlabel,"chi-squared",sname)
call showspec(nk,zarr,chifit)
call plotz(zreal,zmin,zrmin)
write(xlabel,1010) "z",zreal,zmin,zrmin
call pglabel(xlabel,"chi-squared",sname)
call showspec(nk,zarr,rchifit)
call plotz(zreal,zmin,zrmin)
write(xlabel,1010) "z",zreal,zmin,zrmin
call pglabel(xlabel,"reduced chi-squared",sname)
1010 format(a,", z=",f7.4," zest1=",f7.4," zest2=",f7.4)
c call showspec(nk,zarr,rnparr)
c call pglabel("z","number of points in fit",sname)
c calculate the fit at chimin. Redo the fit to get the coeffs
c for the best-fit spectrum
koffset=indkmin+kmin-1
call findindex(npfit,ifit,jmin+koffset,jmax+koffset,
$ iminfit,imaxfit)
npfittmp=imaxfit-iminfit+1
c write(*,*) "iminfit,imaxfit: ",iminfit,imaxfit,npfittmp
c call bigsvdfit(rifit,sfit,efit,npfit,acoeff,nv,uu,vv,ww,
c $ nwlmax,nvmax,chisq1,funcs)
call bigsvdfit(rifit(iminfit),sfit(iminfit),efit(iminfit),
$ npfittmp,acoeff,nv,uu,vv,ww,nwlmax,nvmax,chisq1,funcs)
write(*,*) "coeffs ",(acoeff(i),i=1,nv)
do i=1,npfit
call funcs(rifit(i),evals,nv)
fitvect(i) = 0.0
do j=1,nv
fitvect(i) = fitvect(i) + acoeff(j)*evals(j)
end do
end do
call showspec(npfit,wfit,sfit)
call pglabel("log wavelength","counts"," ")
call pgmtxt('T',2.5,0.0,0.0,sname)
call pgmtxt('T',1.5,0.0,0.0,"spectrum and best fits")
call pgqci(indexc)
call pgsci(3)
call pgline(npfit,wfit,fitvect)
write(tlabel,'(a,f7.4)') "chi-sq, z=",zmin
call pgmtxt('T',2.5,1.0,1.0,tlabel)
call pgsci(indexc)
c calculate the fit at rchimin
koffset=indkrmin+kmin-1
call findindex(npfit,ifit,jmin+koffset,jmax+koffset,
$ iminfit,imaxfit)
npfittmp=imaxfit-iminfit+1
c call bigsvdfit(rifit,sfit,efit,npfit,acoeff,nv,uu,vv,ww,
c $ nwlmax,nvmax,chisq1,funcs)
call bigsvdfit(rifit(iminfit),sfit(iminfit),efit(iminfit),
$ npfittmp,acoeff,nv,uu,vv,ww,nwlmax,nvmax,chisq1,funcs)
c write(*,*) "coeffs ",(acoeff(i),i=1,nv)
do i=1,npfit
call funcs(rifit(i),evals,nv)
fitvect(i) = 0.0
do j=1,nv
fitvect(i) = fitvect(i) + acoeff(j)*evals(j)
end do
end do
call pgqci(indexc)
call pgsci(2)
call pgline(npfit,wfit,fitvect)
write(tlabel,'(a,f7.4)') "red.chisq, z=",zrmin
call pgmtxt('T',1.5,1.0,1.0,tlabel)
call pgsci(indexc)
go to 220
666 continue
close(2)
close(3)
close(4)
close(10)
close(11)
if (ifzfile .ne. 0) close(12)
call pgend()
end
cccccccccccccccccccc
c funcs returns the values of the nv eigenvectors
c evaluated at position xfit, in the array evals
c if svdfit is called with argument wfit, xfit is the
c log wavelength.
c if svdfit is called with argument rifit, xfit is the
c index in the log wavelength array, as a real.
c
subroutine funcs(xfit,evals,nv)
include 'specarray.h'
c having NMAXVECTS in here as well as fitz is a bad kludge
parameter(NMAXVECTS=12)
real evals(nv)
common /vectorfit/ koffset,z,nvmax,nwlmax,
$ evects(NMAXVECTS,NLOGWMAX)
c find the index corresponding to the position xfit
c and retrieve the eigenvector values
c this is for use with rifit
ispec = nint(xfit)
jvect = ispec-koffset
if(jvect .ge. 1 .and. jvect .le. nwlmax) then
do i=1,nv
evals(i) = evects(i,jvect)
end do
else
do i=1,nv
evals(i) = 0.0
end do
end if
return
end
cccccccccccccccccccccccccccccccccccccccc
c Draw vertical lines for the actual z and z-estimates
c on the chi-squared plots.
subroutine plotz(zreal,zest1,zest2)
real xpl(2),ypl(2)
integer indexc,indexls
ypl(1) = -100.
ypl(2) = 1.0e10
call pgqci(indexc)
call pgqls(indexls)
c call pgsls(1)
xpl(1) = zreal
xpl(2) = zreal
call pgsci(4)
call pgsls(5)
call pgline(2,xpl,ypl)
xpl(1) = zest1
xpl(2) = zest1
call pgsci(3)
call pgsls(4)
call pgline(2,xpl,ypl)
xpl(1) = zest2
xpl(2) = zest2
call pgsci(2)
call pgsls(3)
call pgline(2,xpl,ypl)
call pgsci(indexc)
call pgsls(indexls)
return
end
| fitz.f |
!
! Copyright 2018 SALMON developers
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
!-----------------------------------------------------------------------------------------
subroutine eh_finalize(grid,tmp)
use inputoutput, only: utime_from_au,ulength_from_au,uenergy_from_au,unit_system,iperiodic,&
ae_shape1,ae_shape2,e_impulse,sysname,nt_em,nenergy,de, &
directory,iobs_num_em,iobs_samp_em
use salmon_parallel, only: nproc_id_global
use salmon_communication, only: comm_is_root
use salmon_maxwell, only:fdtd_grid,fdtd_tmp
implicit none
type(fdtd_grid) :: grid
type(fdtd_tmp) :: tmp
integer :: ii
real(8),parameter :: pi=3.141592653589793d0
character(128) :: save_name
!output linear response(matter dipole pm and current jm are outputted: pm = -dip and jm = -curr)
if(ae_shape1=='impulse'.or.ae_shape2=='impulse') then
if(iperiodic==0) then
!output time-dependent dipole data
if(comm_is_root(nproc_id_global)) then
save_name=trim(adjustl(directory))//'/'//trim(adjustl(sysname))//'_p.data'
open(tmp%ifn,file=save_name)
select case(unit_system)
case('au','a.u.')
write(tmp%ifn,'(A)') "# time[a.u.], dipoleMoment(x,y,z)[a.u.]"
case('A_eV_fs')
write(tmp%ifn,'(A)') "# time[fs], dipoleMoment(x,y,z)[Ang.]"
end select
do ii=1,nt_em
write(tmp%ifn, '(E13.5)',advance="no") tmp%time_lr(ii)*utime_from_au
write(tmp%ifn, '(3E16.6e3)',advance="yes") -tmp%dip_lr(ii,:)*ulength_from_au
end do
close(tmp%ifn)
end if
!output lr data
call eh_fourier(nt_em,nenergy,grid%dt,de,tmp%time_lr,tmp%dip_lr(:,1),tmp%fr_lr(:,1),tmp%fi_lr(:,1))
call eh_fourier(nt_em,nenergy,grid%dt,de,tmp%time_lr,tmp%dip_lr(:,2),tmp%fr_lr(:,2),tmp%fi_lr(:,2))
call eh_fourier(nt_em,nenergy,grid%dt,de,tmp%time_lr,tmp%dip_lr(:,3),tmp%fr_lr(:,3),tmp%fi_lr(:,3))
if(comm_is_root(nproc_id_global)) then
save_name=trim(adjustl(directory))//'/'//trim(adjustl(sysname))//'_lr.data'
open(tmp%ifn,file=save_name)
select case(unit_system)
case('au','a.u.')
write(tmp%ifn,'(A)') "# energy[a.u.], Re[alpha](x,y,z)[a.u.], Im[alpha](x,y,z)[a.u.], df/dE(x,y,z)[a.u.]"
case('A_eV_fs')
write(tmp%ifn,'(A)') "# energy[eV], Re[alpha](x,y,z)[Ang.**3], Im[alpha](x,y,z)[Ang.**3], df/dE(x,y,z)[1/eV]"
end select
do ii=0,nenergy
write(tmp%ifn, '(E13.5)',advance="no") dble(ii)*de*uenergy_from_au
write(tmp%ifn, '(3E16.6e3)',advance="no") tmp%fr_lr(ii,:)/(-e_impulse)*(ulength_from_au**3.0d0)
write(tmp%ifn, '(3E16.6e3)',advance="no") tmp%fi_lr(ii,:)/(-e_impulse)*(ulength_from_au**3.0d0)
write(tmp%ifn, '(3E16.6e3)',advance="yes") 2.0d0*dble(ii)*de/pi*tmp%fi_lr(ii,:)/(-e_impulse)/uenergy_from_au
end do
close(tmp%ifn)
end if
elseif(iperiodic==3) then
!output time-dependent dipole data
if(comm_is_root(nproc_id_global)) then
save_name=trim(adjustl(directory))//'/'//trim(adjustl(sysname))//'_current.data'
open(tmp%ifn,file=save_name)
select case(unit_system)
case('au','a.u.')
write(tmp%ifn,'(A)') "# time[a.u.], current(x,y,z)[a.u.]"
case('A_eV_fs')
write(tmp%ifn,'(A)') "# time[fs], current(x,y,z)[A/Ang.^2]"
end select
do ii=1,nt_em
write(tmp%ifn, '(E13.5)',advance="no") tmp%time_lr(ii)*utime_from_au
write(tmp%ifn, '(3E16.6e3)',advance="yes") -tmp%curr_lr(ii,:)*tmp%uAperm_from_au/ulength_from_au
end do
close(tmp%ifn)
end if
!output lr data
call eh_fourier(nt_em,nenergy,grid%dt,de,tmp%time_lr,tmp%curr_lr(:,1),tmp%fr_lr(:,1),tmp%fi_lr(:,1))
call eh_fourier(nt_em,nenergy,grid%dt,de,tmp%time_lr,tmp%curr_lr(:,2),tmp%fr_lr(:,2),tmp%fi_lr(:,2))
call eh_fourier(nt_em,nenergy,grid%dt,de,tmp%time_lr,tmp%curr_lr(:,3),tmp%fr_lr(:,3),tmp%fi_lr(:,3))
if(comm_is_root(nproc_id_global)) then
save_name=trim(adjustl(directory))//'/'//trim(adjustl(sysname))//'_lr.data'
open(tmp%ifn,file=save_name)
select case(unit_system)
case('au','a.u.')
write(tmp%ifn,'(A)') "# energy[a.u.], Re[epsilon](x,y,z), Im[epsilon](x,y,z)"
case('A_eV_fs')
write(tmp%ifn,'(A)') "# energy[eV], Re[epsilon](x,y,z), Im[epsilon](x,y,z)"
end select
do ii=1,nenergy
write(tmp%ifn, '(E13.5)',advance="no") dble(ii)*de*uenergy_from_au
write(tmp%ifn, '(3E16.6e3)',advance="no") 1.0d0-4.0d0*pi*tmp%fi_lr(ii,:)/(-e_impulse)/(dble(ii)*de)
write(tmp%ifn, '(3E16.6e3)',advance="yes") 4.0d0*pi*tmp%fr_lr(ii,:)/(-e_impulse)/(dble(ii)*de)
end do
end if
end if
end if
!observation
if(iobs_num_em>0) then
if(comm_is_root(nproc_id_global)) then
!make information file
open(tmp%ifn,file=trim(directory)//"/obs0_info.data")
write(tmp%ifn,'(A,A14)') 'unit_system =',trim(unit_system)
write(tmp%ifn,'(A,I14)') 'iperiodic =',iperiodic
write(tmp%ifn,'(A,ES14.5)') 'dt_em =',grid%dt*utime_from_au
write(tmp%ifn,'(A,I14)') 'nt_em =',(tmp%iter_end-tmp%iter_sta+1)
write(tmp%ifn,'(A,ES14.5,A,ES14.5,A,ES14.5)') 'al_em =',&
grid%rlsize(1)*ulength_from_au,', ',&
grid%rlsize(2)*ulength_from_au,', ',&
grid%rlsize(3)*ulength_from_au
write(tmp%ifn,'(A,ES14.5,A,ES14.5,A,ES14.5)') 'dl_em =',&
grid%hgs(1)*ulength_from_au,', ',&
grid%hgs(2)*ulength_from_au,', ',&
grid%hgs(3)*ulength_from_au
write(tmp%ifn,'(A,I14,A,I14,A,I14)') 'lg_sta =',&
grid%lg_sta(1),', ',grid%lg_sta(2),', ',grid%lg_sta(3)
write(tmp%ifn,'(A,I14,A,I14,A,I14)') 'lg_end =',&
grid%lg_end(1),', ',grid%lg_end(2),', ',grid%lg_end(3)
write(tmp%ifn,'(A,I14)') 'iobs_num_em =',iobs_num_em
write(tmp%ifn,'(A,I14)') 'iobs_samp_em =',iobs_samp_em
write(tmp%ifn,'(A,ES14.5)') 'e_max =',tmp%e_max
write(tmp%ifn,'(A,ES14.5)') 'h_max =',tmp%h_max
close(tmp%ifn)
end if
end if
!deallocate
deallocate(tmp%ex_y,tmp%c1_ex_y,tmp%c2_ex_y,tmp%ex_z,tmp%c1_ex_z,tmp%c2_ex_z,&
tmp%ey_z,tmp%c1_ey_z,tmp%c2_ey_z,tmp%ey_x,tmp%c1_ey_x,tmp%c2_ey_x,&
tmp%ez_x,tmp%c1_ez_x,tmp%c2_ez_x,tmp%ez_y,tmp%c1_ez_y,tmp%c2_ez_y,&
tmp%hx_y,tmp%c1_hx_y,tmp%c2_hx_y,tmp%hx_z,tmp%c1_hx_z,tmp%c2_hx_z,&
tmp%hy_z,tmp%c1_hy_z,tmp%c2_hy_z,tmp%hy_x,tmp%c1_hy_x,tmp%c2_hy_x,&
tmp%hz_x,tmp%c1_hz_x,tmp%c2_hz_x,tmp%hz_y,tmp%c1_hz_y,tmp%c2_hz_y)
!write end
if(comm_is_root(nproc_id_global)) then
write(*,*) "-------------------------------------------------------"
write(*,*) "**************************"
write(*,*) "FDTD end"
write(*,*) "**************************"
end if
end subroutine eh_finalize
!=========================================================================================
!= Fourier transformation in eh ==========================================================
subroutine eh_fourier(nt,ne,dt,de,ti,ft,fr,fi)
use inputoutput, only: wf_em
implicit none
integer,intent(in) :: nt,ne
real(8),intent(in) :: dt,de
real(8),intent(in) :: ti(nt),ft(nt)
real(8),intent(out) :: fr(0:ne),fi(0:ne)
integer :: ie,it
real(8) :: ft_wf(nt)
real(8) :: hw
complex(8),parameter :: zi=(0.d0,1.d0)
complex(8) :: zf
!apply window function
if(wf_em=='y') then
do it=1,nt
ft_wf(it)=ft(it)*( 1.0d0 -3.0d0*(ti(it)/maxval(ti(:)))**2.0d0 +2.0d0*(ti(it)/maxval(ti(:)))**3.0d0 )
end do
else
ft_wf(:)=ft(:)
end if
!Fourier transformation
do ie=0,ne
hw=dble(ie)*de; zf=(0.0d0,0.0d0);
!$omp parallel
!$omp do private(it) reduction( + : zf )
do it=1,nt
zf=zf+exp(zi*hw*ti(it))*ft_wf(it)
end do
!$omp end do
!$omp end parallel
zf=zf*dt; fr(ie)=real(zf,8); fi(ie)=aimag(zf)
end do
end subroutine eh_fourier
| src/maxwell/eh_finalize.f90 |
subroutine ed_gf_cluster_scalar(zeta,gf)
complex(8) :: zeta
complex(8),dimension(Nlat,Nlat,Nspin,Nspin,Norb,Norb),intent(inout) :: gf
complex(8) :: green
integer :: ispin
integer :: ilat,jlat
integer :: iorb,jorb
integer :: iexc,Nexc
integer :: ichan,Nchannel,istate,Nstates
integer :: i,is,js
complex(8) :: weight,de
real(8) :: chan4
!
if(.not.allocated(impGmatrix))stop "ed_gf_cluster ERROR: impGmatrix not allocated!"
!
if(ed_gf_symmetric)then
chan4=0.d0
else
chan4=1.d0
endif
gf = zero
!
do ilat=1,Nlat
do jlat=1,Nlat
do iorb=1,Norb
do jorb=1,Norb
do ispin=1,Nspin
!
green = zero
Nstates = size(impGmatrix(ilat,jlat,ispin,ispin,iorb,jorb)%state)
do istate=1,Nstates
Nchannel = size(impGmatrix(ilat,jlat,ispin,ispin,iorb,jorb)%state(istate)%channel)
do ichan=1,Nchannel
Nexc = size(impGmatrix(ilat,jlat,ispin,ispin,iorb,jorb)%state(istate)%channel(ichan)%poles)
if(Nexc .ne. 0)then
do iexc=1,Nexc
weight = impGmatrix(ilat,jlat,ispin,ispin,iorb,jorb)%state(istate)%channel(ichan)%weight(iexc)
de = impGmatrix(ilat,jlat,ispin,ispin,iorb,jorb)%state(istate)%channel(ichan)%poles(iexc)
green = green + weight/(zeta-de)
enddo
endif
enddo
enddo
gf(ilat,jlat,ispin,ispin,iorb,jorb) = green
enddo
enddo
enddo
enddo
enddo
do ispin=1,Nspin
do iorb=1,Norb
do jorb=1,Norb
do ilat=1,Nlat
do jlat=1,Nlat
if(ilat==jlat .and. iorb==jorb)cycle
gf(ilat,jlat,ispin,ispin,iorb,jorb) = 0.5d0*(gf(ilat,jlat,ispin,ispin,iorb,jorb) &
- (one-chan4*xi)*gf(ilat,ilat,ispin,ispin,iorb,iorb) - (one-chan4*xi)*gf(jlat,jlat,ispin,ispin,jorb,jorb))
enddo
enddo
enddo
enddo
enddo
!
end subroutine ed_gf_cluster_scalar
subroutine ed_gf_cluster_array(zeta,gf)
complex(8),dimension(:) :: zeta
complex(8),dimension(Nlat,Nlat,Nspin,Nspin,Norb,Norb,size(zeta)),intent(inout) :: gf
complex(8),dimension(Nlat,Nlat,Nspin,Nspin,Norb,Norb) :: green
integer :: ispin
integer :: ilat,jlat
integer :: iorb,jorb
integer :: iexc,Nexc
integer :: ichan,Nchannel,istate,Nstates
integer :: i,is,js
real(8) :: weight,de
!
if(.not.allocated(impGmatrix))stop "ed_gf_cluster ERROR: impGmatrix not allocated!"
!
gf = zero
do i=1,size(zeta)
call ed_gf_cluster_scalar(zeta(i),green)
gf(:,:,:,:,:,:,i) = green
enddo
!
end subroutine ed_gf_cluster_array
| ED_IO/gf_cluster.f90 |
module model_initialiser
contains
! remesher:
! Function based on the origianl REMESH function
! Input (in COMMON blocks):
! H(,) - array of independent variables (in unnamed COMMON)
! DH(,) - list of changes in independent variables (in unnamed COMMON)
! KH - current number of meshpoints in H(,)
! Input options:
! KH2 - new number of meshpoints for this model
! JCH - switch to determine whether to construct new mesh spacing function
! and initialise composition or not.
! BMS - Total mass in the binary (EV)
! TM - New mass of the star
! P1 - New rotational period of the star (solid body)
! ECC - New eccentricity of the binary
! OA - New orbital angular momentum
! JSTAR - Labels which if the stars to initislise variables for
! JF - Switch to decide which variables to recompute
! TODO: this could be split up into different subroutines for each of the
! individual tasks.
subroutine remesher( kh2, jch, bms, tm, p1, ecc, oa, jstar, jf )
use real_kind
use constants
use mesh
use init_dat
use settings
use control
use atomic_data
use test_variables
use eostate_types
use structure_functions
use current_model_properties
use structure_variables
use accretion_abundances
use indices
implicit none
integer, intent(in) :: kh2, jch, jstar, jf
real(double), intent(in) :: bms, tm, p1, ecc, oa
integer :: nm_current, nm_next, nm_target
integer :: ik, ikk, ih, i
integer :: jo
integer :: ksv, kt5
type(init_dat_settings) :: initdat
real(double) :: nh(nvar,nm), ndh(nvar,nm), nndh(nvar,nm)
real(double) :: q1, q2, dk, dty, vd, dtb, ageb, pcrit, wcrit, w1
real(double) :: si, vma, hpc
logical :: equilibrium
logical :: newmesh
real(double) :: var(nvar), dvar(nvar), fn1(nfunc)
real(double) :: qa(NM)
type(eostate) :: eos
real(double) :: xh0, xhe0, xc0, xn0, xo0, xne0, xmg0, xsi0, xfe0
real(double) :: che
real(double) :: xh, xhe, xc, xn, xo, xne, xmg, xsi, xfe
real(double) :: r
real(double) :: qq ! Determines mesh-point metric: mesh-point interval
real(double) :: qm ! Determines mesh-point metric: derivative of mesh spacing function wrt mass
real(double) :: phim ! Derivative of gravitational potential with respect to m**(2/3)
real(double) :: gmr ! Effective gravity at the surface(?)
real(double) :: m3 ! m^(1/3), m is the mass coordinate
! Backup current settings so we can restore them when we're done
dtb = dt
ageb = age
call push_init_dat(initdat, kh2, ksv, kt5, jch)
! Change settings to a reasonable set of defaults
call load_basic_init_dat(ik, ksv, kt5, ik)
kop = initdat%kop
kx = 0; ky = 0; kz = 0; kth = 0
cmi = 0.0
crd = 0.0d0
kt1 = 100
kt2 = 0
kt3 = 0
kt4 = 100
kt5 = 100
ksv = 100
joc = 1
jter = 0
! Set initial composition.
! The composition variables are NOT the actual mass fractions if we
! use non-integer atomic masses, so we have to compute what they are
! The composition variables used in the code are baryon number fractions
! We calculate this even if we don't want to do a ZAMS run because we need to
! know the baryon number densities of Fe, Si and Mg.
! Note that the actual abundances of Si and Fe are forced to by non-zero.
! This is because the EoS becomes poorly defined if there are not enough free
! electrons. It has no impact on the opacity and only a small impact on the
! mean molecular weight and the mass loss rate.
che = 1.0d0 - ch - czs
cn = 1.0d0 - cc - co - cne - cmg - csi - cfe
xh0 = ch*cbn(1)/can(1)
xhe0 = che*cbn(2)/can(2)
xc0 = cc*czs*cbn(3)/can(3)
xn0 = cn*czs*cbn(4)/can(4)
xo0 = co*czs*cbn(5)/can(5)
xne0 = cne*czs*cbn(6)/can(6)
xmg0 = cmg*czs*cbn(7)/can(7)
xsi0 = csi*czs*cbn(8)/can(8)
xfe0 = cfe*czs*cbn(9)/can(9)
xh = xh0
xhe = xhe0
xc = xc0
xn = xn0
xo = xo0
xne = xne0
xmg = xmg0
xsi = max(xsi0, csi*1.0d-4)
xfe = max(xfe0, cfe*1.0d-4)
vma = xh + xhe + xc + xn + xo + xne + xmg + xsi + xfe
xh = xh / vma
xhe = xhe / vma
xc = xc / vma
xn = xn / vma
xo = xo / vma
xne = xne / vma
xfe = xfe / vma
xsi = xsi / vma
xmg = xmg / vma
! Initialise composition variables
h(VAR_MG24, 1:kh) = xmg
h(VAR_SI28, 1:kh) = xsi
h(VAR_FE56, 1:kh) = xfe
if ( jch >= 4 ) then
h(VAR_H1,1:kh) = xh
h(VAR_O16,1:kh) = xo
h(VAR_HE4,1:kh) = xhe
h(VAR_C12,1:kh) = xc
h(VAR_NE20,1:kh) = xne
h(VAR_N14,1:kh) = xn
end if
! We should always do this for Mg24, since that's never stored
if (use_mg24_eqn) then
do ik=1, kh
xmg = h(VAR_H1,ik) + h(VAR_HE4, ik) + h(VAR_C12, ik) + h(VAR_O16, ik) + h(VAR_NE20, ik) + h(VAR_N14, ik) + xfe + xsi
h(VAR_MG24,ik) = max(0.0d0, 1.0 - xmg)
end do
end if
! Now we must also convert the abundances of the accreted material. If not
! set from init.dat, set from initial abundances.
!> \todo FIXME: this will cause problems if we ever need to call REMESH twice in
!! the same run
!<
x1ac = x1ac*cbn(1)/can(1)
x4ac = x4ac*cbn(2)/can(2)
x12ac = x12ac*cbn(3)/can(3)
x14ac = x14ac*cbn(4)/can(4)
x16ac = x16ac*cbn(5)/can(5)
x20ac = x20ac*cbn(6)/can(6)
x24ac = x24ac*cbn(7)/can(7)
if (x1ac < 0.0) x1ac = xh0
if (x4ac < 0.0) x4ac = xhe0
if (x12ac < 0.0) x12ac = xc0
if (x14ac < 0.0) x14ac = xn0
if (x16ac < 0.0) x16ac = xo0
if (x20ac < 0.0) x20ac = xne0
if (x24ac < 0.0) x24ac = xmg0
vma = x1ac + x4ac + x12ac + x14ac + x16ac + x20ac + x24ac + xfe + xsi
x1ac = x1ac / vma
x4ac = x4ac / vma
x12ac = x12ac / vma
x14ac = x14ac / vma
x16ac = x16ac / vma
x20ac = x20ac / vma
x24ac = x24ac / vma
! make sure XH is 1-everything else and abundancies sum to 1
x1ac = max(0.0d0, 1.0d0-(x4ac+x12ac+x14ac+x16ac+x20ac+x24ac+xfe0+xsi0))
! Initialise accretion abundances for both stars
xac(1, 1:2) = x1ac
xac(2, 1:2) = x4ac
xac(3, 1:2) = x12ac
xac(4, 1:2) = x14ac
xac(5, 1:2) = x16ac
xac(6, 1:2) = x20ac
xac(7, 1:2) = x24ac
! Set initial values of some other variables
! Typical mass-scale for the interior (needed for mesh spacing function)
mc(jstar) = tm ! New mass after remesh
var(:) = h(:, kh)
dvar(:) = 0.0d0
call funcs1 ( kh, -2, var(:), dvar(:), fn1(:), eos, px=sx(:,2))
hpc = sqrt(eos%p/(cg * eos%rho * eos%rho))
mc(jstar) = 3.5d-33 * eos%rho * hpc**3
! Initialise binary (orbital) parameters
h(VAR_HORB, 1:kh) = oa ! New orbital angular momentum
h(VAR_ECC, 1:kh) = ecc ! New eccentricity
h(VAR_BMASS, 1:kh) = bms ! New total binary mass
! First: change the number of meshpoints or the mesh spacing function
! Determine if we need to calculate a new mesh (independent of the number
! of meshpoints)
newmesh = .false.
if (jch>3) newmesh = .true.
! Set new number of meshpoints
nm_current = kh
nm_target = kh2
nm_next = nm_target
print *, 'nremesh from', nm_current, 'to', nm_target
do while(newmesh .or. nm_current /= nm_next)
newmesh = .false.
print *, 'trying ', nm_next
! Store old model, so we can go back if needed
nh(:,1:nm_current) = h(:,1:nm_current)
ndh(:,1:nm_current) = dh(:,1:nm_current)
! Find values of mesh spacing function
do ik=1, nm_current
var(:) = h(:, ik)
call funcs1 ( ik, -2, var(:), dvar(:), fn1(:)) ! Calculate stuff
qa(ik) = qq ! Store mesh spacing function
end do
! Interpolate model onto new mesh
! Find values of mesh spacing function at the external points
! Needed to calculate the new mesh, where the meshspacing gradient is
! constant.
q1 = qa(1)
q2 = (nm_next - 1.0d0)/(qa(nm_current) - qa(1))
do ik = 1, nm_current
qa(ik) = (qa(ik) - q1)*q2 + 1.0d0 ! Adjust meshspacing
end do
ih = 1
do ik = 1, nm_next
dk = 0.0d0
if ( ik == nm_next ) ih = nm_current
if ( ik /= 1 .and. ik /= nm_next ) then
! Find the proper value for the meshspacing function at
! this meshpoint
do i = 1, 50
! Sanity check: abort if we're running out of the mesh
! boundary
if ( ih+1 > nm_current) then
write (0, *) &
'remesh running outside mesh boundary, aborting'
stop
end if
if ( ik >= qa(ih + 1) ) ih = ih + 1
if ( ik < qa(ih + 1) ) exit ! Break loop
end do
dk = (ik - qa(ih))/(qa(ih + 1) - qa(ih))
end if
! Linear interpolation for new H and DH
h(:, ik) = nh(:, ih) + dk*(nh(:, ih + 1) - nh(:, ih))
nndh(:, ik) = ndh(:, ih) + dk*(ndh(:, ih + 1) - ndh(:, ih))
end do
!H(6, 1:KH) = 1.0/Q2 ! Gradient of mesh spacing
! Now see if the model will converge properly if we let the code iterate
dty = dt/csy
jo = 0
jnn = 0
kh = nm_next
call printb ( jo, 1, 22 )
age = age - dty
call nextdt ( dty, jo, 22 )
jnn = 1
dh(:, 1:nm_next) = 0.0d0
call solver(20, id, kt5, jo)
if (jo == 0) then
print *, 'converged ok'
! If yes, pick next number of meshpoints
nm_current = nm_next
nm_next = nm_target
h(:,1:nm_current) = h(:,1:nm_current) + dh(:,1:nm_current)
else
! If no, pick a smaller number of meshpoints in between the current value
! and the target and try again.
nm_next = (nm_current+nm_next)/2
print *, 'cannot converge, reduce to ', nm_next
! Restore backup copies of H and DH
h(:,1:nm_current) = nh(:,1:nm_current)
dh(:,1:nm_current) = ndh(:,1:nm_current)
end if
end do
print *, 'nremesh finished with ', nm_current, '(wanted ', nm_target,')'
if (nm_current < nm_target) then
print *, '*** nremesh failed ***'
stop
end if
dh(:, 1:nm_current) = nndh(:,1:nm_current)
dh(:, 1:nm_current) = 0.0
kh = nm_current
! Second: scale the mass
vd = tm/h(VAR_MASS, 1)
vd = 1.0
print *, 'scaling mass by factor', vd
do while (abs(1.0d0 - vd) > 0.1)
vd = max(0.9d0,min(vd, 1.1d0))
h(VAR_MASS, 1:kh) = vd*h(VAR_MASS, 1:kh) ! Scale mass
kth = 1
jhold = 4
equilibrium = equilibrate_model(kt5)
if (.not. equilibrium) then !H(:,1:nm_current) = NH(:,1:nm_current)
print *, '*** failed ***'
stop
end if
vd = tm/h(VAR_MASS, 1)
end do
h(VAR_MASS, 1:kh) = vd*h(VAR_MASS, 1:kh) ! Scale mass
! Third: scale the surface rotation rate
! Make the whole star rotate with the surface rate, if desired
! Convert rotational period -> rotation rate
forall (ik=1:kh) h(VAR_OMEGA, ik) = 2.0*cpi/(h(VAR_OMEGA, ik) * csday)
if (start_with_rigid_rotation) h(VAR_OMEGA,2:kh) = h(VAR_OMEGA,1)
! Now scale the surface rate, similar to the way the mass is scaled
! If we forced the star to rigid rotation before then this will set the
! rotation profile throughout the entire star
wcrit = sqrt(cg*tm/exp(3*h(VAR_LNR, 1)))
pcrit = 2.0*cpi/wcrit/csday
w1 = 2.0*cpi/p1/csday
print *, 'scaling rotation rate by factor', w1/h(13, 1)
! For rotation rates within 1/4 of critical be a bit more careful. Here we
! need to approach the desired rate smoothly, adjusting the structure of
! the star at each step.
!> \todo FIXME: This should be more akin to the bit that updates the code on the
!! new mesh, ie, not necessarily bring the star into equilibrium.
!<
if (wcrit/w1 < 4.0) then
call set_solid_rotation
print *, 'Period', p1, 'close to critical rate', pcrit
vd = 0.25*wcrit/h(VAR_OMEGA,1)
h(VAR_OMEGA, 1:kh) = vd*h(VAR_OMEGA, 1:kh) ! Scale rotation rate
kth = 1
equilibrium = converge_model(kt5)
do while (equilibrium .and. abs(w1 - h(VAR_OMEGA,1)) > 1.0d-6)
vd = max(0.9d0,min(vd, 1.1d0))
h(VAR_OMEGA, 1:kh) = vd*h(VAR_OMEGA, 1:kh)
jhold = 4
equilibrium = converge_model(kt5)
vd = w1/h(VAR_OMEGA, 1)
if (.not. equilibrium) then
print *, '*** failed ***'
stop
end if
end do
end if
vd = w1/h(VAR_OMEGA, 1)
h(VAR_OMEGA, 1:kh) = vd*h(VAR_OMEGA, 1:kh) ! Scale rotational period
! Compute moment of inertia and surface potential
if (jf /= 2) then
q2 = h(VAR_QK,1)
h(VAR_QK, 1:kh) = 1.0d0
h(VAR_INERT, 1:kh) = 1.0d0 ! Moment of Inertia
h(VAR_PHI, 1:kh) = 0.0d0 ! Gravitational potential
do ik = 2, kh
ikk = kh + 2 - ik
var(:) = h(:, ik)
call funcs1 ( ik, -2, var(:), dvar(:), fn1(:), px=sx(:,ikk))
qq = sx(85, ikk)
qm = sx(86, ikk)
phim = sx(87, ikk)
m3 = sx(89, ikk)
r = sqrt(abs(exp(2.0d0*var(7)) - ct(8)))
h(VAR_INERT, ik) = h(VAR_INERT, ik - 1) + r*r*m3/(abs(qm))
h(VAR_PHI, ik) = h(VAR_PHI, ik - 1) + phim/abs(qm)
end do
gmr = sx(88, kh+1)
h(VAR_QK, 1:kh) = q2
h(VAR_PHIS, 1:kh) = - gmr ! Potential at the stellar surface
si = h(VAR_INERT, kh) ! Total moment of inertia
do ik = 1, kh
h(VAR_INERT, ik) = (si - h(VAR_INERT, ik))*abs(q2) ! Moment of inertia of interior
h(VAR_PHI, ik) = - gmr - h(VAR_PHI, ik)*abs(q2) ! Gravitational potential
end do
end if
! Total angular momentum integration
h(VAR_TAM, 1:kh) = h(VAR_INERT, 1:kh)*h(VAR_OMEGA, 1)
if (relax_loaded_model) then
kth = 1
jhold = 4
print *, 'equilibrating...'
equilibrium = equilibrate_model(kt5)
if (.not. equilibrium) then
print *, '*** failed ***'
stop
end if
print *, 'done'
dh(:, 1:kh) = 0.0
end if
! Restore old init.dat
call pop_init_dat(initdat, ik, ksv, kt5, ik)
dt = dtb
age = ageb
print *, 'Remesh done'
end subroutine remesher
function converge_model(kt5)
use real_kind
use mesh
use constants
use test_variables
implicit none
logical :: converge_model
integer, intent(in) :: kt5
real(double) :: dty
integer :: jo
jo = 0
dty = dt/csy
call solver(20, id, kt5, jo)
if (jo == 0) then
age = 0.0d0
call printb ( jo, 1, 22 )
h(:,1:kh) = h(:,1:kh) + dh(:,1:kh)
call nextdt ( dty, jo, 22 )
end if
converge_model = (jo == 0)
end function converge_model
function equilibrate_model(kt5)
use real_kind
use mesh
use constants
use test_variables
implicit none
logical :: equilibrate_model
integer, intent(in) :: kt5
real(double) :: dty
integer :: i, jo
jo = 0
do i=1, 40
dty = dt/csy
call solver(20, id, kt5, jo)
if (jo /= 0) exit
age = 0.0d0
call printb ( jo, 1, 22 )
h(:,1:kh) = h(:,1:kh) + dh(:,1:kh)
call nextdt ( dty, jo, 22 )
if (abs(lth) < 1.0d-8 .or. lth < 0.0d0) exit
end do
equilibrate_model = .false.
if (lth < 1.0d-6 .and. jo == 0) equilibrate_model = .true.
end function equilibrate_model
end module model_initialiser
| src/amuse/community/evtwin/src/trunk/code/nremesh.f90 |
SUBROUTINE MF_LGTORI
& (xintg,r,drdc,nderiv)
implicit complex (a-h,o-z)
real omega,wavenr,
& rmax,xmgsq,cthrsh,cmgsq,delta(4)
common/mf_flag/iexact,iovflo,kexact,lowg,nodivd,noevct,
& nofinl,nointg,nomesh,notlin
& /mf_lgfl/lgflag(4)
& /mf_mode/theta,c,s,csq,ssq,omega,wavenr,ideriv
& /mf_rmtx/x(4),dxdc(4),dxdh(4),dhdxdc(4)
dimension xintg(8),r(4),drdc(4)
data delta/1.0,0.0,0.0,1.0/,cthrsh/0.03/,rmax/50.0/
cmgsq=REAL(c)**2+AIMAG(c)**2
do i=1,4
if (lgflag(i) .eq. 0) then
xmgsq=REAL(xintg(i))**2+AIMAG(xintg(i))**2
if ((xmgsq .gt. rmax**2 .and. cmgsq .ge. cthrsh**2)
& .or.
& (xmgsq .gt. 1.e3*rmax**2 .and. cmgsq .lt. cthrsh**2))
& then
iovflo=1
RETURN
end if
x(i)=xintg(i)
if (nderiv .eq. 1) dxdc(i)=xintg(i+4)
else
if (ABS(REAL(xintg(i))) .gt. 10.) then
iovflo=1
RETURN
end if
r(i)=EXP(xintg(i))
x(i)=(r(i)+delta(i))/c
if (nderiv .eq. 1) then
dlnrdc=xintg(i+4)
drdc(i)=r(i)*dlnrdc
dxdc(i)=(drdc(i)-x(i))/c
end if
end if
end do
RETURN
END ! MF_LGTORI
| LWPCv21/lib/mf_lgtori.for |
C$Procedure ZZRYTPDT ( DSK, ray touches planetodetic element )
SUBROUTINE ZZRYTPDT ( VERTEX, RAYDIR, BOUNDS,
. CORPAR, MARGIN, NXPTS, XPT )
C$ Abstract
C
C SPICE Private routine intended solely for the support of SPICE
C routines. Users should not call this routine directly due to the
C volatile nature of this routine.
C
C Find nearest intersection to a given ray's vertex of the ray and
C a planetodetic volume element. If the vertex is inside the
C element, the vertex is considered to be the solution.
C
C In the computation performed by this routine, ellipsoidal
C surfaces are used, instead of surfaces of constant altitude, to
C define boundaries of planetodetic volume elements. The element
C defined by the input boundaries is contained in the element
C bounded by the input latitude and longitude boundaries and by the
C ellipsoidal surfaces.
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 DSK
C
C$ Keywords
C
C GEOMETRY
C INTERCEPT
C INTERSECTION
C RAY
C SURFACE
C TOPOGRAPHY
C
C$ Declarations
IMPLICIT NONE
INCLUDE 'dsktol.inc'
DOUBLE PRECISION VERTEX ( 3 )
DOUBLE PRECISION RAYDIR ( 3 )
DOUBLE PRECISION BOUNDS ( 2, 3 )
DOUBLE PRECISION CORPAR ( * )
DOUBLE PRECISION MARGIN
INTEGER NXPTS
DOUBLE PRECISION XPT ( 3 )
INTEGER LONIDX
PARAMETER ( LONIDX = 1 )
INTEGER LATIDX
PARAMETER ( LATIDX = 2 )
INTEGER ALTIDX
PARAMETER ( ALTIDX = 3 )
C$ Brief_I/O
C
C VARIABLE I/O DESCRIPTION
C -------- --- --------------------------------------------------
C VERTEX I Ray's vertex.
C RAYDIR I Ray's direction vector.
C BOUNDS I Bounds of planetodetic volume element.
C CORPAR I Coordinate parameters.
C MARGIN I Margin used for element expansion.
C NXPTS O Number of intercept points.
C XPT O Intercept.
C LONIDX P Longitude index.
C LATIDX P Latitude index.
C ALTIDX P Altitude index.
C
C$ Detailed_Input
C
C VERTEX,
C RAYDIR are, respectively, the vertex and direction vector of
C the ray to be used in the intercept computation.
C
C Both the vertex and ray direction must be represented
C in the reference frame to which the planetodetic
C volume element boundaries correspond. The vertex is
C considered to be an offset from the center of the
C reference frame associated with the element.
C
C BOUNDS is a 2x3 array containing the bounds of a planetodetic
C volume element. Normally this is the coverage boundary
C of a DSK segment. In the element
C
C BOUNDS(I,J)
C
C J is the coordinate index. J is one of
C
C { LONIDX, LATIDX, ALTIDX }
C
C I is the bound index.
C
C I = 1 -> lower bound
C I = 2 -> upper bound
C
C If the longitude upper bound is not greater than the
C longitude lower bound, a value greater than the upper
C bound by 2*pi is used for the comparison.
C
C RE,
C F are, respectively, the equatorial radius and
C flattening coefficient associated with the
C planetodetic coordinate system in which the input
C volume element is described.
C
C
C MARGIN is a scale factor used to effectively expand the
C segment boundaries so as to include intersections
C that lie slightly outside the volume element.
C
C
C$ Detailed_Output
C
C XPT is the intercept of the ray on the surface described
C by the segment, if such an intercept exists. If the
C ray intersects the surface at multiple points, the
C one closest to the ray's vertex is selected. XPT is
C valid if and only if FOUND is .TRUE.
C
C XPT is expressed in the reference frame associated
C with the inputs VERTEX and RAYDIR. XPT represents
C an offset from the origin of the coordinate system.
C
C XPT is valid only if NXPTS is set to 1.
C
C
C NXPTS is the number of intercept points of the ray and
C the volume element.
C
C Currently there are only two possible values for
C NXPTS:
C
C 1 for an intersection
C 0 for no intersection
C
C If the vertex is inside the element, NXPTS is
C set to 1.
C
C$ Parameters
C
C LONIDX is the index of longitude in the second dimension of
C BOUNDS.
C
C LATIDX is the index of latitude in the second dimension of
C BOUNDS.
C
C ALTIDX is the index of altitude in the second dimension of
C BOUNDS.
C$ Exceptions
C
C 1) If MARGIN is negative, the error SPICE(VALUEOUTOFRANGE)
C is signaled.
C
C 2) If the input ray direction vector is zero, the error
C SPICE(ZEROVECTOR) will be signaled.
C
C 3) Any errors that occur while calculating the ray-surface
C intercept will be signaled by routines in the call tree
C of this routine.
C
C$ Files
C
C None. However, the input segment boundaries normally have
C been obtained from a loaded DSK file.
C
C$ Particulars
C
C This routine sits on top of data DSK type-specific ray-segment
C intercept routines such as DSKX02.
C
C$ Examples
C
C See usage in ZZDSKBUX.
C
C$ Restrictions
C
C This is a private routine. It is meant to be used only by the DSK
C subsystem.
C
C$ Literature_References
C
C None.
C
C$ Author_and_Institution
C
C N.J. Bachman (JPL)
C
C$ Version
C
C- SPICELIB Version 1.0.0, 19-JAN-2017 (NJB)
C
C-&
C$ Index_Entries
C
C find intercept of ray on planetodetic volume element
C
C-&
C
C SPICELIB functions
C
DOUBLE PRECISION DPMAX
DOUBLE PRECISION HALFPI
DOUBLE PRECISION VDIST
DOUBLE PRECISION VDOT
DOUBLE PRECISION VNORM
DOUBLE PRECISION VSEP
LOGICAL FAILED
LOGICAL RETURN
LOGICAL VZERO
LOGICAL ZZPDPLTC
C
C Local parameters
C
C
C Altitude expansion factor:
C
DOUBLE PRECISION RADFAC
PARAMETER ( RADFAC = 1.1D0 )
C
C Element boundary indices:
C
INTEGER WEST
PARAMETER ( WEST = 1 )
INTEGER EAST
PARAMETER ( EAST = 2 )
INTEGER SOUTH
PARAMETER ( SOUTH = 1 )
INTEGER NORTH
PARAMETER ( NORTH = 2 )
INTEGER LOWER
PARAMETER ( LOWER = 1 )
INTEGER UPPER
PARAMETER ( UPPER = 2 )
INTEGER NONE
PARAMETER ( NONE = 0 )
C
C Local variables
C
DOUBLE PRECISION AMNALT
DOUBLE PRECISION AMXALT
DOUBLE PRECISION ANGLE
DOUBLE PRECISION APEX ( 3 )
DOUBLE PRECISION DIST
DOUBLE PRECISION EASTB ( 3 )
DOUBLE PRECISION EBACK ( 3 )
DOUBLE PRECISION EMAX
DOUBLE PRECISION EMIN
DOUBLE PRECISION ENDPT2 ( 3 )
DOUBLE PRECISION F
DOUBLE PRECISION LONCOV
DOUBLE PRECISION MAXALT
DOUBLE PRECISION MAXLAT
DOUBLE PRECISION MAXLON
DOUBLE PRECISION MAXR
DOUBLE PRECISION MINALT
DOUBLE PRECISION MINLAT
DOUBLE PRECISION MINLON
DOUBLE PRECISION MNDIST
DOUBLE PRECISION NEGDIR ( 3 )
DOUBLE PRECISION PMAX
DOUBLE PRECISION PMIN
DOUBLE PRECISION RE
DOUBLE PRECISION RP
DOUBLE PRECISION S
DOUBLE PRECISION SRFX ( 3 )
DOUBLE PRECISION UDIR ( 3 )
DOUBLE PRECISION VTXANG
DOUBLE PRECISION VTXLVL
DOUBLE PRECISION VTXOFF ( 3 )
DOUBLE PRECISION WBACK ( 3 )
DOUBLE PRECISION WESTB ( 3 )
DOUBLE PRECISION XPT2 ( 3 )
DOUBLE PRECISION XINCPT
DOUBLE PRECISION YINCPT
DOUBLE PRECISION Z ( 3 )
INTEGER NX
LOGICAL FOUND
LOGICAL INSIDE
LOGICAL XIN
LOGICAL XVAL1
LOGICAL XVAL2
C
C Saved variables
C
SAVE Z
C
C Initial values
C
DATA Z / 0.D0, 0.D0, 1.D0 /
IF ( RETURN() ) THEN
RETURN
END IF
CALL CHKIN ( 'ZZRYTPDT' )
IF ( MARGIN .LT. 0.D0 ) THEN
CALL SETMSG ( 'Margin must be non-negative but was #.' )
CALL ERRDP ( '#', MARGIN )
CALL SIGERR ( 'SPICE(VALUEOUTOFRANGE)' )
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( VZERO(RAYDIR) ) THEN
CALL SETMSG ( 'The ray''s direction was the zero vector.' )
CALL SIGERR ( 'SPICE(ZEROVECTOR)' )
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
C
C Determine whether the vertex is inside the element.
C
CALL ZZINPDT ( VERTEX, BOUNDS, CORPAR, MARGIN, NONE, INSIDE )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( INSIDE ) THEN
C
C We know the answer.
C
NXPTS = 1
CALL VEQU ( VERTEX, XPT )
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
C
C Get semi-axis lengths of the reference spheroid.
C
RE = CORPAR(1)
F = CORPAR(2)
RP = RE * ( 1.D0 - F )
C
C Extract the segment's coordinate bounds into easily
C readable variables.
C
MINALT = BOUNDS( LOWER, ALTIDX )
MAXALT = BOUNDS( UPPER, ALTIDX )
C
C Normalize the longitude bounds. After this step, the bounds will
C be in order and differ by no more than 2*pi.
C
CALL ZZNRMLON( BOUNDS(WEST,LONIDX), BOUNDS(EAST,LONIDX), ANGMRG,
. MINLON, MAXLON )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
MINLAT = BOUNDS( SOUTH, LATIDX )
MAXLAT = BOUNDS( NORTH, LATIDX )
C
C Compute adjusted altitude bounds, taking margin into
C account.
C
AMNALT = MINALT - MARGIN * ABS(MINALT)
AMXALT = MAXALT + MARGIN * ABS(MAXALT)
C
C Generate semi-axis lengths of inner and outer bounding
C ellipsoids.
C
IF ( RE .GE. RP ) THEN
C
C The reference spheroid is oblate.
C
CALL ZZELLBDS ( RE, RP, AMXALT, AMNALT,
. EMAX, PMAX, EMIN, PMIN )
ELSE
C
C The reference spheroid is prolate.
C
CALL ZZELLBDS ( RP, RE, AMXALT, AMNALT,
. PMAX, EMAX, PMIN, EMIN )
END IF
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
C
C The vertex is outside the element.
C
C Indicate no intersection to start.
C
NXPTS = 0
C
C We'll use a unit length copy of the ray's direction vector.
C
CALL VHAT ( RAYDIR, UDIR )
C
C Initialize the distance to the closest solution. We'll keep track
C of this quantity in order to compare competing solutions.
C
MNDIST = DPMAX()
C
C Find the intersection of the ray and outer bounding ellipsoid, if
C possible. Often this intersection is the closest to the vertex.
C If the intersection exists and is on the boundary of the element,
C it's a winner.
C
CALL SURFPT ( VERTEX, UDIR, EMAX, EMAX, PMAX, SRFX, FOUND )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( .NOT. FOUND ) THEN
C
C There are no intersections. The ray cannot hit the volume
C element.
C
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
C
C The ray hits the outer bounding ellipsoid. See whether
C the longitude and latitude are within bounds, taking
C the margin into account. Exclude the altitude coordinate
C from testing.
C
CALL ZZINPDT ( SRFX, BOUNDS, CORPAR, MARGIN, ALTIDX, XIN )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( XIN ) THEN
C
C This solution is a candidate.
C
CALL VEQU ( SRFX, XPT )
NXPTS = 1
C
C Find the level surface parameter of the vertex relative
C to the adjusted outer bounding ellipsoid.
C
VTXLVL = ( VERTEX(1)/EMAX )**2
. + ( VERTEX(2)/EMAX )**2
. + ( VERTEX(3)/PMAX )**2
IF ( VTXLVL .GT. 1.D0 ) THEN
C
C The vertex is outside this ellipsoid, and the DSK segment
C lies within the ellipsoid.
C
C No other intersection can be closer to the vertex;
C we don't need to check the other surfaces.
C
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
ELSE
C
C We have a possible solution.
C
MNDIST = VDIST( VERTEX, XPT )
END IF
END IF
C
C So far there may be a candidate solution. We'll try the latitude
C boundaries next.
C
C For testing intersections with the latitude boundaries, we'll
C need a far endpoint for the line segment on which to perform the
C test.
C
MAXR = MAX ( EMAX, PMAX )
S = VNORM(VERTEX) + RADFAC * MAXR
CALL VLCOM ( 1.D0, VERTEX, S, UDIR, ENDPT2 )
C
C Now try the upper latitude bound. We can skip this test
C if the upper bound is pi/2 radians.
C
IF ( MAXLAT .LT. HALFPI() ) THEN
C
C Let ANGLE be the angular separation of the surface of latitude
C MAXLAT and the +Z axis. Note that the surface might be the
C lower nappe of the cone.
C
ANGLE = MAX ( 0.D0, HALFPI() - MAXLAT )
C
C Compute the Z coordinate of the apex of the latitude cone.
C
CALL ZZELNAXX ( RE, RP, MAXLAT, XINCPT, YINCPT )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
APEX(1) = 0.D0
APEX(2) = 0.D0
APEX(3) = YINCPT
C
C Find the offset of the ray's vertex from the cone's apex,
C and find the angular separation of the offset from the +Z
C axis. This separation enables us to compare the latitude of
C the vertex to the latitude boundary without making a RECGEO
C call to compute the planetodetic coordinates of the vertex.
C
C (The comparison will be done later.)
C
CALL VSUB ( VERTEX, APEX, VTXOFF )
VTXANG = VSEP ( VTXOFF, Z )
C
C Check for intersection of the ray with the latitude cone.
C
CALL INCNSG ( APEX, Z, ANGLE, VERTEX, ENDPT2, NX, SRFX, XPT2 )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
C
C Unlike the case of latitudinal coordinates, for planetodetic
C coordinates, the surface of the latitude cone does not
C coincide with the set of points having that latitude (which is
C equal to pi/2 - the cone's angular separation from the +Z
C axis). The subset of the cone having the specified latitude is
C truncated by the X-Y plane. If we ignore round-off errors, we
C can assert that the Z-coordinate of a point having the given
C planetodetic latitude must match the direction of the nappe of
C the cone: positive if ANGLE < pi/2, negative if ANGLE > pi/2,
C and 0 if ANGLE = pi/2.
C
C However, we cannot ignore round-off errors. For a cone having
C angle from its central axis of nearly pi/2, it's possible for
C a valid ray-cone intercept to be on the "wrong" side of the
C X-Y plane due to round-off errors. So we use a more robust
C check to determine whether an intercept should be considered
C to have the same latitude as the cone.
C
C Check all intercepts.
C
IF ( NX .GT. 0 ) THEN
C
C Check the first intercept.
C
XVAL1 = ZZPDPLTC( RE, F, SRFX, MAXLAT )
XVAL2 = .FALSE.
IF ( NX .EQ. 2 ) THEN
C
C Check the second intercept.
C
XVAL2 = ZZPDPLTC( RE, F, XPT2, MAXLAT )
END IF
IF ( XVAL1 .AND. ( .NOT. XVAL2 ) ) THEN
NX = 1
ELSE IF ( XVAL2 .AND. (.NOT. XVAL1 ) ) THEN
C
C Only the second solution is valid. Overwrite
C the first.
C
NX = 1
CALL VEQU( XPT2, SRFX )
ELSE IF ( ( .NOT. XVAL1 ) .AND. ( .NOT. XVAL2 ) ) THEN
C
C Neither solution is valid.
C
NX = 0
END IF
END IF
IF ( NX .GE. 1 ) THEN
C
C The ray intercept SRFX lies on the upper latitude boundary.
C
C See whether SRFX meets the longitude and proxy altitude
C constraints.
C
CALL ZZINPDT ( SRFX, BOUNDS, CORPAR, MARGIN, LATIDX, XIN )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( XIN ) THEN
C
C SRFX is a candidate solution.
C
DIST = VDIST( VERTEX, SRFX )
IF ( DIST .LT. MNDIST ) THEN
CALL VEQU ( SRFX, XPT )
NXPTS = 1
IF ( VTXANG .LT. ANGLE ) THEN
IF ( ( MAXLAT .LT. 0.D0 )
. .OR. ( VERTEX(3) .GT. 0.D0 ) ) THEN
C
C If MAXLAT is negative, the vertex offset
C being outside the cone is enough to
C guarantee the planetodetic latitude of the
C vertex is greater than that of the cone.
C
C If MAXLAT is non-negative, the angle of the
C vertex offset relative to the +Z axis is not
C enough; we need the vertex to lie above the
C X-Y plane as well.
C
C Getting here means one of these conditions
C was met.
C
C Since the latitude of the vertex is greater
C than MAXLAT, this is the best solution, since
C the volume element is on the other side of the
C maximum latitude boundary.
C
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
END IF
C
C This is the best solution seen so far, but we
C need to check the remaining boundaries.
C
MNDIST = DIST
END IF
END IF
IF ( NX .EQ. 2 ) THEN
C
C Check the second solution as well.
C
CALL ZZINPDT ( XPT2, BOUNDS, CORPAR,
. MARGIN, LATIDX, XIN )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( XIN ) THEN
C
C XPT2 is a candidate solution.
C
DIST = VDIST( VERTEX, XPT2 )
IF ( DIST .LT. MNDIST ) THEN
CALL VEQU ( XPT2, XPT )
NXPTS = 1
MNDIST = DIST
C
C This is the best solution seen so far.
C However, it's not necessarily the best
C solution. So we continue.
C
END IF
END IF
END IF
C
C We've handled the second root, if any.
C
END IF
C
C We're done with the upper latitude boundary.
C
END IF
C
C Try the lower latitude bound. We can skip this test if the lower
C bound is -pi/2 radians.
C
IF ( MINLAT .GT. -HALFPI() ) THEN
C
C Let ANGLE be the angular separation of the surface
C of latitude MINLAT and the +Z axis. Note that the
C surface might be the lower nappe of the cone.
C
ANGLE = HALFPI() - MINLAT
C Compute the Z coordinate of the apex of the latitude cone.
C
CALL ZZELNAXX ( RE, RP, MINLAT, XINCPT, YINCPT )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
APEX(1) = 0.D0
APEX(2) = 0.D0
APEX(3) = YINCPT
CALL INCNSG ( APEX, Z, ANGLE, VERTEX,
. ENDPT2, NX, SRFX, XPT2 )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
C
C Find the offset of the ray's vertex from the cone's apex,
C and find the angular separation of the offset from the +Z
C axis. This separation enables us to compare the latitude of
C the vertex to the latitude boundary without making a RECGEO
C call to compute the planetodetic coordinates of the vertex.
C
C (The comparison will be done later.)
C
CALL VSUB ( VERTEX, APEX, VTXOFF )
VTXANG = VSEP ( VTXOFF, Z )
C
C Check whether the latitude of the intercept can be
C considered to match that of the cone.
C
IF ( NX .GT. 0 ) THEN
C
C Check the first intercept.
C
XVAL1 = ZZPDPLTC( RE, F, SRFX, MINLAT )
XVAL2 = .FALSE.
IF ( NX .EQ. 2 ) THEN
C
C Check the second intercept.
C
XVAL2 = ZZPDPLTC( RE, F, XPT2, MINLAT )
END IF
IF ( XVAL1 .AND. ( .NOT. XVAL2 ) ) THEN
NX = 1
ELSE IF ( XVAL2 .AND. (.NOT. XVAL1 ) ) THEN
C
C Only the second solution is valid. Overwrite
C the first.
C
NX = 1
CALL VEQU( XPT2, SRFX )
ELSE IF ( ( .NOT. XVAL1 ) .AND. ( .NOT. XVAL2 ) ) THEN
C
C Neither solution is valid.
C
NX = 0
END IF
END IF
IF ( NX .GE. 1 ) THEN
C
C The ray intercept SRFX lies on the lower latitude boundary.
C
C See whether SRFX meets the longitude and proxy altitude
C constraints.
C
CALL ZZINPDT ( SRFX, BOUNDS, CORPAR, MARGIN, LATIDX, XIN )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( XIN ) THEN
C
C SRFX is a candidate solution.
C
DIST = VDIST( VERTEX, SRFX )
IF ( DIST .LT. MNDIST ) THEN
CALL VEQU ( SRFX, XPT )
NXPTS = 1
IF ( VTXANG .GT. ANGLE ) THEN
IF ( ( MINLAT .GT. 0.D0 )
. .OR. ( VERTEX(3) .LT. 0.D0 ) ) THEN
C
C If MINLAT is positive, the vertex offset
C being outside the cone is enough to
C guarantee the planetodetic latitude of the
C vertex is less than that of the cone.
C
C If MINLAT is non-positive, the angle of the
C vertex offset relative to the +Z axis is not
C enough; we need the vertex to lie below the
C X-Y plane as well.
C
C Getting here means one of these conditions
C was met.
C
C Since the latitude of the vertex is less than
C than MINLAT, this is the best solution, since
C the volume element is on the other side of the
C minimum latitude boundary.
C
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
END IF
C
C This is the best solution seen so far, but we
C need to check the remaining boundaries.
MNDIST = DIST
END IF
END IF
IF ( NX .EQ. 2 ) THEN
C
C Check the second solution as well.
C
CALL ZZINPDT ( XPT2, BOUNDS, CORPAR,
. MARGIN, LATIDX, XIN )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( XIN ) THEN
C
C XPT2 is a candidate solution.
C
DIST = VDIST( VERTEX, XPT2 )
IF ( DIST .LT. MNDIST ) THEN
CALL VEQU ( XPT2, XPT )
NXPTS = 1
MNDIST = DIST
C
C This is the best solution seen so far.
C However, it's not necessarily the best
C solution. So we continue.
C
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
END IF
END IF
END IF
C
C We're done with the lower latitude boundary.
C
END IF
C
C Perform longitude boundary checks if the coverage is not
C 2*pi radians. Note that MAXLON > MINLON at this point.
C
LONCOV = MAXLON - MINLON
IF ( COS(LONCOV) .LT. 1.D0 ) THEN
C
C We have distinct longitude boundaries. Go to work.
C
C
C Check the longitude boundaries. Try the plane of western
C longitude first.
C
CALL VPACK ( SIN(MINLON), -COS(MINLON), 0.D0, WESTB )
S = RADFAC * ( VNORM(VERTEX) + MAXR )
CALL ZZINRYPL ( VERTEX, UDIR, WESTB, 0.D0, S, NX, SRFX )
IF ( NX .EQ. 1 ) THEN
C
C We have one point of intersection. Determine whether it's a
C candidate solution. Don't use longitude in the following
C inclusion test. Note that we'll perform a separate check
C later in place of the longitude check.
C
CALL ZZINPDT ( SRFX, BOUNDS, CORPAR, MARGIN, LONIDX, XIN )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( XIN ) THEN
C
C Make sure the intercept is not too far on the
C "wrong" side of the Z axis.
C
CALL UCRSS ( WESTB, Z, WBACK )
IF ( VDOT(SRFX, WBACK) .LT. (MARGIN*MAXR) ) THEN
C
C The intercept is either on the same side of the Z
C axis as the west face of the segment, or is very
C close to the Z axis.
C
DIST = VDIST( VERTEX, SRFX )
IF ( DIST .LT. MNDIST ) THEN
C
C Record the intercept, distance, and surface index.
C
CALL VEQU ( SRFX, XPT )
NXPTS = 1
MNDIST = DIST
END IF
END IF
END IF
END IF
C
C We're done with the western boundary.
C
C
C Try the plane of eastern longitude next.
C
CALL VPACK ( -SIN(MAXLON), COS(MAXLON), 0.D0, EASTB )
CALL ZZINRYPL ( VERTEX, UDIR, EASTB, 0.D0, S, NX, SRFX )
IF ( NX .EQ. 1 ) THEN
C
C We have one point of intersection. Determine whether it's a
C candidate solution.
C
CALL ZZINPDT ( SRFX, BOUNDS, CORPAR, MARGIN, LONIDX, XIN )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( XIN ) THEN
C
C Make sure the intercept is not too far on the "wrong"
C side of the Z axis.
C
CALL UCRSS ( Z, EASTB, EBACK )
IF ( VDOT(SRFX, EBACK) .LT. (MARGIN*MAXR) ) THEN
C
C The intercept is either on the same side of the Z
C axis as the east face of the segment, or is very
C close to the Z axis.
C
DIST = VDIST( VERTEX, SRFX )
IF ( DIST .LT. MNDIST ) THEN
C
C Record the intercept, distance, and surface index.
C
CALL VEQU ( SRFX, XPT )
NXPTS = 1
MNDIST = DIST
END IF
END IF
END IF
END IF
END IF
C
C End of longitude boundary checks.
C
C
C Find the intersection of the ray and lower bounding
C ellipsoid, if possible.
C
CALL SURFPT ( VERTEX, UDIR, EMIN, EMIN, PMIN, SRFX, FOUND )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( FOUND ) THEN
C
C See whether this solution is in the element.
C
CALL ZZINPDT ( SRFX, BOUNDS, CORPAR, MARGIN, ALTIDX, XIN )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( XIN ) THEN
DIST = VDIST( VERTEX, SRFX )
IF ( DIST .LT. MNDIST ) THEN
C
C Record the intercept, distance, and surface index.
C
CALL VEQU ( SRFX, XPT )
NXPTS = 1
MNDIST = DIST
END IF
END IF
END IF
C
C Unlike the outer ellipsoid, either intersection of the ray with
C the inner ellipsoid might be a valid solution. We'll test for the
C case where the intersection farther from the ray's vertex is the
C correct one.
C
CALL VMINUS( UDIR, NEGDIR )
CALL SURFPT ( ENDPT2, NEGDIR, EMIN, EMIN, PMIN, SRFX, FOUND )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( FOUND ) THEN
CALL ZZINPDT ( SRFX, BOUNDS, CORPAR, MARGIN, ALTIDX, XIN )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END IF
IF ( XIN ) THEN
DIST = VDIST( VERTEX, SRFX )
IF ( DIST .LT. MNDIST ) THEN
C
C Record the intercept, distance, and surface index.
C
CALL VEQU ( SRFX, XPT )
NXPTS = 1
C
C There's no need to update MNDIST at this point.
C
END IF
END IF
END IF
C
C NXPTS and XPT are set.
C
CALL CHKOUT ( 'ZZRYTPDT' )
RETURN
END
| source/nasa_f/zzrytpdt.f |
SUBROUTINE TG_VI2F ( vdtm, idtm, fdtm, lnth, iret )
C************************************************************************
C* DE_VI2F *
C* *
C* This subroutine converts a forecast valid time of the form *
C* YYMMDD/HHNN and an initial GEMPAK time of the form yymmdd/hhnn *
C* into a proper GEMPAK forecast time stamp of the form *
C* yymmdd/hhnnFhhhnn. *
C* *
C* TG_VI2F ( VDTM, IDTM, FDTM, LNTH, IRET ) *
C* *
C* Input parameters: *
C* VDTM CHAR* Valid GEMPAK time, YYMMDD/HHNN *
C* IDTM CHAR* Init. GEMPAK time, yymmdd/hhnn *
C* *
C* Output parameters: *
C* FDTM CHAR* Forecast time, yymmdd/hhnn *
C* LNTH INTEGER Length of string FDTM *
C* IRET INTEGER Return code *
C* 0 = normal return *
C* -1 = invalid date or time *
C* -3 = invalid forecast time *
C** *
C* Log: *
C* T. Lee/SAIC 1/05 *
C************************************************************************
CHARACTER*(*) vdtm, idtm, fdtm
CHARACTER sfh*3, snn*2
C------------------------------------------------------------------------
iret = 0
lnth = 0
C
C* Return if VDTM or IDTM is blank,
C
IF ( ( vdtm .eq. ' ' ) .or. ( idtm .eq. ' ' ) ) THEN
iret = -1
fdtm = ' '
RETURN
END IF
C
C* Compute the difference between valid time and initial time.
C
CALL TG_DIFF ( vdtm, idtm, nmin, iret )
IF ( iret .ne. 0 ) RETURN
C
IF ( ( nmin .lt. 0 ) .or. ( nmin .ge. 60000 ) ) THEN
iret = -3
RETURN
END IF
C
ifh = nmin / 60
nn = MOD ( nmin, 60 )
WRITE ( sfh, 50, IOSTAT = ier ) ifh
50 FORMAT ( I3.3 )
WRITE ( snn, 60, IOSTAT = ier ) nn
60 FORMAT ( I2.2 )
C
C* Construct the forecast time stamp.
C
CALL ST_LSTR ( idtm, lstr, ier )
fdtm = idtm ( :lstr ) // 'F' // sfh // snn
C
CALL ST_LSTR ( fdtm, lnth, ier )
C*
RETURN
END
| gempak/source/gemlib/tg/tgvi2f.f |
! Copyright (c) 2013, 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.
!
! Tests F2003 defined I/O (recursive read)
module person_module
logical rslt(10), expect(10)
integer :: cnt
type :: person
character(len=20) :: name
integer :: age
contains
procedure :: my_read => rf
procedure :: my_write => wf
generic :: READ(FORMATTED) => my_read
generic :: WRITE(FORMATTED) => my_write
end type
type, extends(person) :: employee
integer id
real salary
contains
procedure :: my_read => rf2
procedure :: my_write => wf2
end type
contains
recursive subroutine rf(dtv, unit, iotype, vlist, iostat, iomsg)
class(person), intent(inout) :: dtv
integer, intent(in) :: unit
character(len=*),intent(in) :: iotype
integer, intent(in) :: vlist(:)
integer, intent(out) :: iostat
character (len=*), intent(inout) :: iomsg
character(len=9) :: pfmt
read (unit, *, iostat=iostat) dtv%name, dtv%age
if (iostat .eq. 0) then
cnt = cnt + 1
rslt(cnt) = dtv%age .eq. 40+(cnt-1)
read(unit, *) dtv
endif
end subroutine
subroutine wf(dtv, unit, iotype, vlist, iostat, iomsg)
class(person), intent(inout) :: dtv
integer, intent(in) :: unit
character(len=*),intent(in) :: iotype
integer, intent(in) :: vlist(:)
integer, intent(out) :: iostat
character (len=*), intent(inout) :: iomsg
character(len=9) :: pfmt
write (unit, *) dtv%name, dtv%age
end subroutine
subroutine wf2(dtv, unit, iotype, vlist, iostat, iomsg)
class(employee), intent(inout) :: dtv
integer, intent(in) :: unit
character(len=*),intent(in) :: iotype
integer, intent(in) :: vlist(:)
integer, intent(out) :: iostat
character (len=*), intent(inout) :: iomsg
character(len=9) :: pfmt
write (unit, *) dtv%name, dtv%age, dtv%id, dtv%salary
end subroutine
recursive subroutine rf2(dtv, unit, iotype, vlist, iostat, iomsg)
class(employee), intent(inout) :: dtv
integer, intent(in) :: unit
character(len=*),intent(in) :: iotype
integer, intent(in) :: vlist(:)
integer, intent(out) :: iostat
character (len=*), intent(inout) :: iomsg
character(len=9) :: pfmt
read (unit, *, iostat=iostat) dtv%name, dtv%age, dtv%id, dtv%salary
if (iostat .eq. 0) then
cnt = cnt + 1
rslt(cnt) = dtv%id .eq. 100+(cnt-1)
read(unit, *) dtv
endif
end subroutine
end module
use person_module
integer id, members
type(employee) :: chairman
chairman%name='myname'
chairman%age=40
chairman%id = 100
chairman%salary = 0
rslt = .false.
expect = .true.
open(11, file='io16.output', status='replace')
do i=1,10
write(11, *) chairman
chairman%id = chairman%id + 1
enddo
cnt = 0
open(11, file='io16.output', position='rewind')
read(11, *) chairman
close(11)
call check(rslt, expect, 10)
end
| test/f90_correct/src/io16.f90 |
subroutine blue(value,hexrep,bfrac)
C%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
C %
C Copyright (C) 1996, The Board of Trustees of the Leland Stanford %
C Junior University. All rights reserved. %
C %
C The programs in GSLIB are distributed in the hope that they will be %
C useful, but WITHOUT ANY WARRANTY. No author or distributor accepts %
C responsibility to anyone for the consequences of using them or for %
C whether they serve any particular purpose or work at all, unless he %
C says so in writing. Everyone is granted permission to copy, modify %
C and redistribute the programs in GSLIB, but only under the condition %
C that this notice and the above copyright notice remain intact. %
C %
C%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c-----------------------------------------------------------------------
c
c Provided with a real value ``value'' this subroutine returns the blue
c portion of the color specification.
c
c Note common block "color" and call to "hexa"
c
c-----------------------------------------------------------------------
real value
character hexrep*2,hexa*2
common /color/ cmin,cmax,cint(4),cscl
hexrep = '00'
if(value.lt.cint(2))then
c
c Scale it between (255,255):
c
integ = 255
else if((value.ge.cint(2)).and.(value.lt.cint(3)))then
c
c Scale it between (255,0):
c
integ = int((cint(3)-value)/(cint(3)-cint(2))*255.)
if(integ.gt.255) integ = 255
if(integ.lt.0) integ = 0
else if(value.ge.cint(3))then
c
c Scale it between (0,0):
c
integ = 0
end if
c
c Establish coding and return:
c
bfrac = real(integ) / 255.
hexrep = hexa(integ)
return
end
| visim/visim_src/gslib/blue.f |
SUBROUTINE DEG2CHR(DEGS,LATLON,CHAR)
C******************************************************************
C# SUB DEG2CHR(DEGS,LATLON,CHAR) Degrees to CHARACTER (xxxNxx'xx")
C Convert degrees to characters for output.
C DEGS = input degrees (may be -180 to 180 or 0 to 360)
C LATLON=0= latitude format xxxNxx'xx"
C =1= longitude format xxxExx'xx"
c =2= latitude format xx.xxN
c =3= longitude format xxx.xxE
C CHAR = CHARACTER*10 output
C******************************************************************
CHARACTER*(*) CHAR
CHARACTER*1 NSEW
DEG=DEGS
IF(DEG.GT.180.) DEG=DEG-360.
modd=mod(latlon,2)
IF(modd.EQ.0 .AND. DEG.GE.0.) NSEW='N'
IF(modd.EQ.0 .AND. DEG.LT.0.) NSEW='S'
IF(modd.NE.0 .AND. DEG.GE.0.) NSEW='E'
IF(modd.NE.0 .AND. DEG.LT.0.) NSEW='W'
D=ABS(DEG)
IDEG=D
D=(D-IDEG)*60.
MIN=D
ISEC=(D-MIN)*60. + .5
IF(ISEC.LT.60) GO TO 10
ISEC=0
MIN=MIN+1
IF(MIN.LT.60) GO TO 10
MIN=MIN-60
IDEG=IDEG+1
10 if(latlon.le.1) then
WRITE(CHAR,11) IDEG,NSEW,MIN,ISEC
11 format(i3,a1,i2,1h',i2,1h")
else
WRITE(CHAR,'(f6.2,a1)') abs(DEG),NSEW
end if
RETURN
END
| src/voa_lib/deg2chr.for |
!
! Copyright 2019-2020 SALMON developers
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
module jellium
implicit none
contains
!===========================================================================================
!= check condition =========================================================================
subroutine check_condition_jm
use salmon_global, only: yn_md, yn_opt, yn_out_pdos, yn_out_tm, yn_out_rvf_rt, nelem, natom, nelec, spin, xc, &
yn_periodic, layout_multipole, shape_file_jm, num_jm, sphere_nion_jm, &
method_singlescale
use parallelization, only: nproc_id_global
use communication, only: comm_is_root
implicit none
call condition_yn_jm(yn_md, 'yn_md', 'n')
call condition_yn_jm(yn_opt, 'yn_opt', 'n')
call condition_yn_jm(yn_out_pdos, 'yn_out_pdos', 'n')
call condition_yn_jm(yn_out_tm, 'yn_out_tm', 'n')
call condition_yn_jm(yn_out_rvf_rt,'yn_out_rvf_rt','n')
call condition_int_jm(nelem,'nelem',1)
call condition_int_jm(natom,'natom',1)
if(yn_periodic=='n'.and.layout_multipole/=1) then
if(comm_is_root(nproc_id_global)) &
write(*,'("For yn_jm = y and yn_periodic = n, layout_multipole must be 1.")')
stop
end if
if(mod(nelec,2)/=0) then
if(comm_is_root(nproc_id_global)) write(*,'("For yn_jm = y, nelec must be even number.")')
stop
end if
if(trim(spin)/='unpolarized') then
if(comm_is_root(nproc_id_global)) write(*,'("For yn_jm = y, spin must be even unpolarized.")')
stop
end if
if(trim(xc)/='pz') then
if(comm_is_root(nproc_id_global)) write(*,'("For yn_jm = y, xc must be pz.")')
stop
end if
if(trim(method_singlescale)/='3d') then
if(comm_is_root(nproc_id_global)) write(*,'("For yn_jm = y, method_singlescale must be 3d.")')
stop
end if
if (trim(shape_file_jm)=='none' .and. nelec/=sum(sphere_nion_jm(:)))then
if(comm_is_root(nproc_id_global)) &
write(*,'("For yn_jm = y and shape_file_jm = none, nelec must be sum(sphere_nion_jm).")')
stop
end if
if(num_jm<1) then
if(comm_is_root(nproc_id_global)) write(*,'("For yn_jm = y, num_jm must be larger than 0.")')
stop
end if
return
contains
!+ CONTAINED IN check_condition_jm +++++++++++++++++++++++++++++++++++++++++++++++++++++++
!+ check condition for y/n +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
subroutine condition_yn_jm(tar,name,ans)
implicit none
character(1),intent(in) :: tar
character(*),intent(in) :: name
character(1),intent(in) :: ans
if (tar/=ans) then
if(comm_is_root(nproc_id_global)) write(*,'("For yn_jm = y, ",A," must be ",A,".")') name,ans
stop
end if
return
end subroutine condition_yn_jm
!+ CONTAINED IN check_condition_jm +++++++++++++++++++++++++++++++++++++++++++++++++++++++
!+ check condition for integer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
subroutine condition_int_jm(tar,name,ans)
implicit none
integer, intent(in) :: tar
character(*),intent(in) :: name
integer, intent(in) :: ans
if (tar/=ans) then
if(comm_is_root(nproc_id_global)) write(*,'("For yn_jm = y, ",A," must be ",I4,".")') name,ans
stop
end if
return
end subroutine condition_int_jm
end subroutine check_condition_jm
!===========================================================================================
!= meke positive back ground charge density ================================================
subroutine make_rho_jm(lg,mg,info,system,rho_jm)
use salmon_global, only: shape_file_jm, num_jm, rs_bohr_jm, sphere_nion_jm, sphere_loc_jm, &
yn_charge_neutral_jm, yn_output_dns_jm, yn_periodic, nelec, unit_system
use inputoutput, only: ulength_from_au
use structures, only: s_rgrid, s_dft_system, s_parallel_info, s_scalar, allocate_scalar
use parallelization, only: nproc_id_global, nproc_group_global
use communication, only: comm_is_root, comm_summation
use common_maxwell, only: input_shape_em
use write_file3d, only: write_cube
use math_constants, only: pi
implicit none
type(s_rgrid), intent(in) :: lg, mg
type(s_parallel_info), intent(in) :: info
type(s_dft_system), intent(in) :: system
type(s_scalar), intent(inout) :: rho_jm
type(s_scalar) :: work_l1,work_l2
integer,allocatable :: imedia(:,:,:)
integer :: ii, ix, iy, iz, nelec_sum, mod_nelec
real(8),allocatable :: dens(:), radi(:), mod_rs_bohr_jm(:)
real(8) :: rab, charge_sum, charge_error
character(60) :: suffix
character(30) :: phys_quantity
!set density
allocate(dens(num_jm)); dens(:)=0.0d0;
do ii=1,num_jm
dens(ii) = 1.0d0/(4.0d0*pi/3.0*(rs_bohr_jm(ii)**3.0d0))
end do
!make rho_jm
if (trim(shape_file_jm)=='none')then
!**************************************************************************************!
!*** rho_jm is generated by spherecal shapes ******************************************!
!**************************************************************************************!
!allocate radius
allocate(radi(num_jm)); radi(:)=0.0d0;
!make spheres
do ii=1,num_jm
!set radius
radi(ii) = ( dble(sphere_nion_jm(ii))/dens(ii)/(4.0d0*pi/3.0) )**(1.0d0/3.0d0)
!make ii-th sphere
do iz=mg%is(3),mg%ie(3)
do iy=mg%is(2),mg%ie(2)
do ix=mg%is(1),mg%ie(1)
rab = sqrt( (lg%coordinate(ix,1)-sphere_loc_jm(ii,1))**2.0d0 &
+(lg%coordinate(iy,2)-sphere_loc_jm(ii,2))**2.0d0 &
+(lg%coordinate(iz,3)-sphere_loc_jm(ii,3))**2.0d0 )
if(rab<=radi(ii)) rho_jm%f(ix,iy,iz)=dens(ii)
end do
end do
end do
end do
!set total electron number
nelec_sum = sum(sphere_nion_jm(:))
else
!**************************************************************************************!
!*** rho_jm is generated by cube file *************************************************!
!**************************************************************************************!
!input shape
allocate(imedia(mg%is(1):mg%ie(1),mg%is(2):mg%ie(2),mg%is(3):mg%ie(3))); imedia(:,:,:)=0;
if(comm_is_root(nproc_id_global)) write(*,*)
if(comm_is_root(nproc_id_global)) write(*,*) "**************************"
if(index(shape_file_jm,".cube", back=.true.)/=0) then
if(comm_is_root(nproc_id_global)) then
write(*,*) "shape file is inputed by .cube format."
end if
call input_shape_em(shape_file_jm,600,mg%is,mg%ie,lg%is,lg%ie,0,imedia,'cu')
elseif(index(shape_file_jm,".mp", back=.true.)/=0) then
if(comm_is_root(nproc_id_global)) then
write(*,*) "shape file is inputed by .mp format."
write(*,*) "This version works for only .cube format.."
end if
stop
else
if(comm_is_root(nproc_id_global)) then
write(*,*) "shape file must be .cube or .mp formats."
end if
stop
end if
if(comm_is_root(nproc_id_global)) write(*,*) "**************************"
!make rho_jm from shape file
do iz=mg%is(3),mg%ie(3)
do iy=mg%is(2),mg%ie(2)
do ix=mg%is(1),mg%ie(1)
if(imedia(ix,iy,iz)>0) rho_jm%f(ix,iy,iz)=dens(imedia(ix,iy,iz))
end do
end do
end do
!set total electron number
nelec_sum = nelec
end if
!check charge neutrality
call check_neutral_jm(charge_sum,charge_error,nelec_sum)
!propose modified parameter & stop
!or modify parameters
allocate(mod_rs_bohr_jm(num_jm)); mod_rs_bohr_jm(:)=0.0d0;
if(charge_error>=2.0d0/dble(nelec))then
!stop & propose modified parameter
mod_nelec = int(charge_sum)
if(mod(mod_nelec,2)/=0) mod_nelec=mod_nelec+1
if(comm_is_root(nproc_id_global))then
write(*,*)
write(*,'("Charge nertrality error is",E23.15E3,".")') charge_error
write(*,'("To improve charge nertrality, change nelec to",I9,".")') mod_nelec
end if
stop
else
!modify parameters and recheck neutrality
if(yn_charge_neutral_jm=='y')then
rho_jm%f(:,:,:) = rho_jm%f(:,:,:) * ( dble(nelec)/charge_sum )
dens(:) = dens(:) * ( dble(nelec)/charge_sum )
mod_rs_bohr_jm(:) = ( 1.0d0/(4.0d0*pi/3.0*dens(:)) )**(1.0d0/3.0d0)
call check_neutral_jm(charge_sum,charge_error,nelec_sum)
end if
end if
!output cube file
if(yn_output_dns_jm=='y') then
call allocate_scalar(lg,work_l1); call allocate_scalar(lg,work_l2);
do iz=mg%is(3),mg%ie(3)
do iy=mg%is(2),mg%ie(2)
do ix=mg%is(1),mg%ie(1)
work_l1%f(ix,iy,iz) = rho_jm%f(ix,iy,iz)
end do
end do
end do
call comm_summation(work_l1%f,work_l2%f,lg%num(1)*lg%num(2)*lg%num(3),nproc_group_global)
suffix = "dns_jellium"; phys_quantity = "pbcd";
call write_cube(lg,103,suffix,phys_quantity,work_l2%f,system)
end if
!write information
if(comm_is_root(nproc_id_global))then
write(*,*)
write(*,*) '****************** Jellium information ******************'
if(trim(shape_file_jm)=='none')then
write(*,'(" Positive background charge density is generated by spherecal shapes:")')
do ii=1,num_jm
write(*, '(A,I3,A,E23.15E3)') ' Radius of sphere(',ii,') =', radi(ii)*ulength_from_au
end do
write(*,*) " in the unit system, ",trim(unit_system),"."
else
write(*,'(" Positive background charge density is generated by shape file.")')
end if
if(sum(mod_rs_bohr_jm(:))==0.0d0) then
write(*,'(" Wigner-Seitz radius is set as follows:")')
do ii=1,num_jm
write(*, '(A,I3,A,E23.15E3)') ' rs_bohr_jm(',ii,') =', rs_bohr_jm(ii)
end do
else
write(*,'(" To keep charge neutrality, Wigner-Seitz radius is modified as follows:")')
do ii=1,num_jm
write(*, '(A,I3,A,E23.15E3)') ' mod_rs_bohr_jm(',ii,') =', mod_rs_bohr_jm(ii)
end do
end if
write(*,*) " in the atomic unit(Bohr)."
write(*,'(A,E23.15E3," %")') ' Chrge neutrality error =', charge_error
if(yn_periodic=='y') then
write(*,*)
write(*,'(" For yn_jm = y and yn_periodic=y, this version still cannot output Total Energy.")')
write(*,*)
end if
write(*,*) '*********************************************************'
write(*,*)
end if
!change sign in view of electron density
rho_jm%f(:,:,:) = -rho_jm%f(:,:,:)
return
contains
!+ CONTAINED IN make_rho_jm ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!+ check charge neutrality +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
subroutine check_neutral_jm(sum_c,err,num_e)
implicit none
real(8), intent(inout) :: sum_c
real(8), intent(out) :: err
integer, intent(in) :: num_e
real(8) :: sum_tmp
sum_tmp = 0.0d0; sum_c = 0.0d0;
!$omp parallel
!$omp do private(ix,iy,iz) reduction( + : sum_tmp )
do iz=mg%is(3),mg%ie(3)
do iy=mg%is(2),mg%ie(2)
do ix=mg%is(1),mg%ie(1)
sum_tmp = sum_tmp + rho_jm%f(ix,iy,iz)
end do
end do
end do
!$omp end do
!$omp end parallel
call comm_summation(sum_tmp,sum_c,info%icomm_r)
sum_c = sum_c * system%hvol
err = abs( (sum_c - dble(num_e)) / dble(num_e) )
return
end subroutine check_neutral_jm
end subroutine make_rho_jm
end module jellium
| src/atom/jellium.f90 |
! Loop recovery fails. Might be due to semantics not providing the
! necessary preconditions
c%2.3
subroutine s234 (ntimes,ld,n,ctime,dtime,a,b,c,d,e,aa,bb,cc)
c
c loop interchange
c if loop to do loop, interchanging with if loop necessary
c
integer ntimes, ld, n, i, nl, j
real a(n), b(n), c(n), d(n), e(n), aa(ld,n), bb(ld,n), cc(ld,n)
real t1, t2, second, chksum, ctime, dtime, cs2d
! call init(ld,n,a,b,c,d,e,aa,bb,cc,'s234 ')
! t1 = second()
do 1 nl = 1,ntimes/n
i = 1
11 if(i.gt.n) goto 10
j = 2
21 if(j.gt.n) goto 20
aa(i,j) = aa(i,j-1) + bb(i,j-1) * cc(i,j-1)
j = j + 1
goto 21
20 i = i + 1
goto 11
10 continue
! call dummy(ld,n,a,b,c,d,e,aa,bb,cc,1.)
1 continue
! t2 = second() - t1 - ctime - ( dtime * float(ntimes/n) )
! chksum = cs2d(n,aa)
! call check (chksum,(ntimes/n)*n*(n-1),n,t2,'s234 ')
return
end
| packages/PIPS/validation/Transformations/S234.f |
!*==ctrevc3.f90 processed by SPAG 7.51RB at 20:08 on 3 Mar 2022
!> \brief \b CTREVC3
!
! =========== DOCUMENTATION ===========
!
! Online html documentation available at
! http://www.netlib.org/lapack/explore-html/
!
!> \htmlonly
!> Download CTREVC3 + dependencies
!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctrevc3.f">
!> [TGZ]</a>
!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctrevc3.f">
!> [ZIP]</a>
!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctrevc3.f">
!> [TXT]</a>
!> \endhtmlonly
!
! Definition:
! ===========
!
! SUBROUTINE CTREVC3( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR,
! LDVR, MM, M, WORK, LWORK, RWORK, LRWORK, INFO)
!
! .. Scalar Arguments ..
! CHARACTER HOWMNY, SIDE
! INTEGER INFO, LDT, LDVL, LDVR, LWORK, M, MM, N
! ..
! .. Array Arguments ..
! LOGICAL SELECT( * )
! REAL RWORK( * )
! COMPLEX T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),
! $ WORK( * )
! ..
!
!
!> \par Purpose:
! =============
!>
!> \verbatim
!>
!> CTREVC3 computes some or all of the right and/or left eigenvectors of
!> a complex upper triangular matrix T.
!> Matrices of this type are produced by the Schur factorization of
!> a complex general matrix: A = Q*T*Q**H, as computed by CHSEQR.
!>
!> The right eigenvector x and the left eigenvector y of T corresponding
!> to an eigenvalue w are defined by:
!>
!> T*x = w*x, (y**H)*T = w*(y**H)
!>
!> where y**H denotes the conjugate transpose of the vector y.
!> The eigenvalues are not input to this routine, but are read directly
!> from the diagonal of T.
!>
!> This routine returns the matrices X and/or Y of right and left
!> eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an
!> input matrix. If Q is the unitary factor that reduces a matrix A to
!> Schur form T, then Q*X and Q*Y are the matrices of right and left
!> eigenvectors of A.
!>
!> This uses a Level 3 BLAS version of the back transformation.
!> \endverbatim
!
! Arguments:
! ==========
!
!> \param[in] SIDE
!> \verbatim
!> SIDE is CHARACTER*1
!> = 'R': compute right eigenvectors only;
!> = 'L': compute left eigenvectors only;
!> = 'B': compute both right and left eigenvectors.
!> \endverbatim
!>
!> \param[in] HOWMNY
!> \verbatim
!> HOWMNY is CHARACTER*1
!> = 'A': compute all right and/or left eigenvectors;
!> = 'B': compute all right and/or left eigenvectors,
!> backtransformed using the matrices supplied in
!> VR and/or VL;
!> = 'S': compute selected right and/or left eigenvectors,
!> as indicated by the logical array SELECT.
!> \endverbatim
!>
!> \param[in] SELECT
!> \verbatim
!> SELECT is LOGICAL array, dimension (N)
!> If HOWMNY = 'S', SELECT specifies the eigenvectors to be
!> computed.
!> The eigenvector corresponding to the j-th eigenvalue is
!> computed if SELECT(j) = .TRUE..
!> Not referenced if HOWMNY = 'A' or 'B'.
!> \endverbatim
!>
!> \param[in] N
!> \verbatim
!> N is INTEGER
!> The order of the matrix T. N >= 0.
!> \endverbatim
!>
!> \param[in,out] T
!> \verbatim
!> T is COMPLEX array, dimension (LDT,N)
!> The upper triangular matrix T. T is modified, but restored
!> on exit.
!> \endverbatim
!>
!> \param[in] LDT
!> \verbatim
!> LDT is INTEGER
!> The leading dimension of the array T. LDT >= max(1,N).
!> \endverbatim
!>
!> \param[in,out] VL
!> \verbatim
!> VL is COMPLEX array, dimension (LDVL,MM)
!> On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must
!> contain an N-by-N matrix Q (usually the unitary matrix Q of
!> Schur vectors returned by CHSEQR).
!> On exit, if SIDE = 'L' or 'B', VL contains:
!> if HOWMNY = 'A', the matrix Y of left eigenvectors of T;
!> if HOWMNY = 'B', the matrix Q*Y;
!> if HOWMNY = 'S', the left eigenvectors of T specified by
!> SELECT, stored consecutively in the columns
!> of VL, in the same order as their
!> eigenvalues.
!> Not referenced if SIDE = 'R'.
!> \endverbatim
!>
!> \param[in] LDVL
!> \verbatim
!> LDVL is INTEGER
!> The leading dimension of the array VL.
!> LDVL >= 1, and if SIDE = 'L' or 'B', LDVL >= N.
!> \endverbatim
!>
!> \param[in,out] VR
!> \verbatim
!> VR is COMPLEX array, dimension (LDVR,MM)
!> On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
!> contain an N-by-N matrix Q (usually the unitary matrix Q of
!> Schur vectors returned by CHSEQR).
!> On exit, if SIDE = 'R' or 'B', VR contains:
!> if HOWMNY = 'A', the matrix X of right eigenvectors of T;
!> if HOWMNY = 'B', the matrix Q*X;
!> if HOWMNY = 'S', the right eigenvectors of T specified by
!> SELECT, stored consecutively in the columns
!> of VR, in the same order as their
!> eigenvalues.
!> Not referenced if SIDE = 'L'.
!> \endverbatim
!>
!> \param[in] LDVR
!> \verbatim
!> LDVR is INTEGER
!> The leading dimension of the array VR.
!> LDVR >= 1, and if SIDE = 'R' or 'B', LDVR >= N.
!> \endverbatim
!>
!> \param[in] MM
!> \verbatim
!> MM is INTEGER
!> The number of columns in the arrays VL and/or VR. MM >= M.
!> \endverbatim
!>
!> \param[out] M
!> \verbatim
!> M is INTEGER
!> The number of columns in the arrays VL and/or VR actually
!> used to store the eigenvectors.
!> If HOWMNY = 'A' or 'B', M is set to N.
!> Each selected eigenvector occupies one column.
!> \endverbatim
!>
!> \param[out] WORK
!> \verbatim
!> WORK is COMPLEX array, dimension (MAX(1,LWORK))
!> \endverbatim
!>
!> \param[in] LWORK
!> \verbatim
!> LWORK is INTEGER
!> The dimension of array WORK. LWORK >= max(1,2*N).
!> For optimum performance, LWORK >= N + 2*N*NB, where NB is
!> the optimal blocksize.
!>
!> If LWORK = -1, then a workspace query is assumed; the routine
!> only calculates the optimal size of the WORK array, returns
!> this value as the first entry of the WORK array, and no error
!> message related to LWORK is issued by XERBLA.
!> \endverbatim
!>
!> \param[out] RWORK
!> \verbatim
!> RWORK is REAL array, dimension (LRWORK)
!> \endverbatim
!>
!> \param[in] LRWORK
!> \verbatim
!> LRWORK is INTEGER
!> The dimension of array RWORK. LRWORK >= max(1,N).
!>
!> If LRWORK = -1, then a workspace query is assumed; the routine
!> only calculates the optimal size of the RWORK array, returns
!> this value as the first entry of the RWORK array, and no error
!> message related to LRWORK is issued by XERBLA.
!> \endverbatim
!>
!> \param[out] INFO
!> \verbatim
!> INFO is INTEGER
!> = 0: successful exit
!> < 0: if INFO = -i, the i-th argument had an illegal value
!> \endverbatim
!
! Authors:
! ========
!
!> \author Univ. of Tennessee
!> \author Univ. of California Berkeley
!> \author Univ. of Colorado Denver
!> \author NAG Ltd.
!
!> \date November 2017
!
! @generated from ztrevc3.f, fortran z -> c, Tue Apr 19 01:47:44 2016
!
!> \ingroup complexOTHERcomputational
!
!> \par Further Details:
! =====================
!>
!> \verbatim
!>
!> The algorithm used in this program is basically backward (forward)
!> substitution, with scaling to make the the code robust against
!> possible overflow.
!>
!> Each eigenvector is normalized so that the element of largest
!> magnitude has magnitude 1; here the magnitude of a complex number
!> (x,y) is taken to be |x| + |y|.
!> \endverbatim
!>
! =====================================================================
SUBROUTINE CTREVC3(Side,Howmny,Select,N,T,Ldt,Vl,Ldvl,Vr,Ldvr,Mm, &
& M,Work,Lwork,Rwork,Lrwork,Info)
IMPLICIT NONE
!*--CTREVC3250
!
! -- LAPACK computational routine (version 3.8.0) --
! -- LAPACK is a software package provided by Univ. of Tennessee, --
! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
! November 2017
!
! .. Scalar Arguments ..
CHARACTER Howmny , Side
INTEGER Info , Ldt , Ldvl , Ldvr , Lwork , Lrwork , M , Mm , N
! ..
! .. Array Arguments ..
LOGICAL Select(*)
REAL Rwork(*)
COMPLEX T(Ldt,*) , Vl(Ldvl,*) , Vr(Ldvr,*) , Work(*)
! ..
!
! =====================================================================
!
! .. Parameters ..
REAL ZERO , ONE
PARAMETER (ZERO=0.0E+0,ONE=1.0E+0)
COMPLEX CZERO , CONE
PARAMETER (CZERO=(0.0E+0,0.0E+0),CONE=(1.0E+0,0.0E+0))
INTEGER NBMIN , NBMAX
PARAMETER (NBMIN=8,NBMAX=128)
! ..
! .. Local Scalars ..
LOGICAL allv , bothv , leftv , lquery , over , rightv , somev
INTEGER i , ii , is , j , k , ki , iv , maxwrk , nb
REAL ovfl , remax , scale , smin , smlnum , ulp , unfl
COMPLEX cdum
! ..
! .. External Functions ..
LOGICAL LSAME
INTEGER ILAENV , ICAMAX
REAL SLAMCH , SCASUM
EXTERNAL LSAME , ILAENV , ICAMAX , SLAMCH , SCASUM
! ..
! .. External Subroutines ..
EXTERNAL XERBLA , CCOPY , CLASET , CSSCAL , CGEMM , CGEMV , &
& CLATRS , CLACPY , SLABAD
! ..
! .. Intrinsic Functions ..
INTRINSIC ABS , REAL , CMPLX , CONJG , AIMAG , MAX
! ..
! .. Statement Functions ..
REAL CABS1
! ..
! .. Statement Function definitions ..
CABS1(cdum) = ABS(REAL(cdum)) + ABS(AIMAG(cdum))
! ..
! .. Executable Statements ..
!
! Decode and test the input parameters
!
bothv = LSAME(Side,'B')
rightv = LSAME(Side,'R') .OR. bothv
leftv = LSAME(Side,'L') .OR. bothv
!
allv = LSAME(Howmny,'A')
over = LSAME(Howmny,'B')
somev = LSAME(Howmny,'S')
!
! Set M to the number of columns required to store the selected
! eigenvectors.
!
IF ( somev ) THEN
M = 0
DO j = 1 , N
IF ( Select(j) ) M = M + 1
ENDDO
ELSE
M = N
ENDIF
!
Info = 0
nb = ILAENV(1,'CTREVC',Side//Howmny,N,-1,-1,-1)
maxwrk = N + 2*N*nb
Work(1) = maxwrk
Rwork(1) = N
lquery = (Lwork==-1 .OR. Lrwork==-1)
IF ( .NOT.rightv .AND. .NOT.leftv ) THEN
Info = -1
ELSEIF ( .NOT.allv .AND. .NOT.over .AND. .NOT.somev ) THEN
Info = -2
ELSEIF ( N<0 ) THEN
Info = -4
ELSEIF ( Ldt<MAX(1,N) ) THEN
Info = -6
ELSEIF ( Ldvl<1 .OR. (leftv .AND. Ldvl<N) ) THEN
Info = -8
ELSEIF ( Ldvr<1 .OR. (rightv .AND. Ldvr<N) ) THEN
Info = -10
ELSEIF ( Mm<M ) THEN
Info = -11
ELSEIF ( Lwork<MAX(1,2*N) .AND. .NOT.lquery ) THEN
Info = -14
ELSEIF ( Lrwork<MAX(1,N) .AND. .NOT.lquery ) THEN
Info = -16
ENDIF
IF ( Info/=0 ) THEN
CALL XERBLA('CTREVC3',-Info)
RETURN
ELSEIF ( lquery ) THEN
RETURN
ENDIF
!
! Quick return if possible.
!
IF ( N==0 ) RETURN
!
! Use blocked version of back-transformation if sufficient workspace.
! Zero-out the workspace to avoid potential NaN propagation.
!
IF ( over .AND. Lwork>=N+2*N*NBMIN ) THEN
nb = (Lwork-N)/(2*N)
nb = MIN(nb,NBMAX)
CALL CLASET('F',N,1+2*nb,CZERO,CZERO,Work,N)
ELSE
nb = 1
ENDIF
!
! Set the constants to control overflow.
!
unfl = SLAMCH('Safe minimum')
ovfl = ONE/unfl
CALL SLABAD(unfl,ovfl)
ulp = SLAMCH('Precision')
smlnum = unfl*(N/ulp)
!
! Store the diagonal elements of T in working array WORK.
!
DO i = 1 , N
Work(i) = T(i,i)
ENDDO
!
! Compute 1-norm of each column of strictly upper triangular
! part of T to control overflow in triangular solver.
!
Rwork(1) = ZERO
DO j = 2 , N
Rwork(j) = SCASUM(j-1,T(1,j),1)
ENDDO
!
IF ( rightv ) THEN
!
! ============================================================
! Compute right eigenvectors.
!
! IV is index of column in current block.
! Non-blocked version always uses IV=NB=1;
! blocked version starts with IV=NB, goes down to 1.
! (Note the "0-th" column is used to store the original diagonal.)
iv = nb
is = M
DO ki = N , 1 , -1
IF ( somev ) THEN
IF ( .NOT.Select(ki) ) CYCLE
ENDIF
smin = MAX(ulp*(CABS1(T(ki,ki))),smlnum)
!
! --------------------------------------------------------
! Complex right eigenvector
!
Work(ki+iv*N) = CONE
!
! Form right-hand side.
!
DO k = 1 , ki - 1
Work(k+iv*N) = -T(k,ki)
ENDDO
!
! Solve upper triangular system:
! [ T(1:KI-1,1:KI-1) - T(KI,KI) ]*X = SCALE*WORK.
!
DO k = 1 , ki - 1
T(k,k) = T(k,k) - T(ki,ki)
IF ( CABS1(T(k,k))<smin ) T(k,k) = smin
ENDDO
!
IF ( ki>1 ) THEN
CALL CLATRS('Upper','No transpose','Non-unit','Y',ki-1,T,&
& Ldt,Work(1+iv*N),scale,Rwork,Info)
Work(ki+iv*N) = scale
ENDIF
!
! Copy the vector x or Q*x to VR and normalize.
!
IF ( .NOT.over ) THEN
! ------------------------------
! no back-transform: copy x to VR and normalize.
CALL CCOPY(ki,Work(1+iv*N),1,Vr(1,is),1)
!
ii = ICAMAX(ki,Vr(1,is),1)
remax = ONE/CABS1(Vr(ii,is))
CALL CSSCAL(ki,remax,Vr(1,is),1)
!
DO k = ki + 1 , N
Vr(k,is) = CZERO
ENDDO
!
ELSEIF ( nb==1 ) THEN
! ------------------------------
! version 1: back-transform each vector with GEMV, Q*x.
IF ( ki>1 ) CALL CGEMV('N',N,ki-1,CONE,Vr,Ldvr, &
& Work(1+iv*N),1,CMPLX(scale), &
& Vr(1,ki),1)
!
ii = ICAMAX(N,Vr(1,ki),1)
remax = ONE/CABS1(Vr(ii,ki))
CALL CSSCAL(N,remax,Vr(1,ki),1)
!
ELSE
! ------------------------------
! version 2: back-transform block of vectors with GEMM
! zero out below vector
DO k = ki + 1 , N
Work(k+iv*N) = CZERO
ENDDO
!
! Columns IV:NB of work are valid vectors.
! When the number of vectors stored reaches NB,
! or if this was last vector, do the GEMM
IF ( (iv==1) .OR. (ki==1) ) THEN
CALL CGEMM('N','N',N,nb-iv+1,ki+nb-iv,CONE,Vr,Ldvr, &
& Work(1+(iv)*N),N,CZERO,Work(1+(nb+iv)*N),N)
! normalize vectors
DO k = iv , nb
ii = ICAMAX(N,Work(1+(nb+k)*N),1)
remax = ONE/CABS1(Work(ii+(nb+k)*N))
CALL CSSCAL(N,remax,Work(1+(nb+k)*N),1)
ENDDO
CALL CLACPY('F',N,nb-iv+1,Work(1+(nb+iv)*N),N,Vr(1,ki)&
& ,Ldvr)
iv = nb
ELSE
iv = iv - 1
ENDIF
ENDIF
!
! Restore the original diagonal elements of T.
!
DO k = 1 , ki - 1
T(k,k) = Work(k)
ENDDO
!
is = is - 1
ENDDO
ENDIF
!
IF ( leftv ) THEN
!
! ============================================================
! Compute left eigenvectors.
!
! IV is index of column in current block.
! Non-blocked version always uses IV=1;
! blocked version starts with IV=1, goes up to NB.
! (Note the "0-th" column is used to store the original diagonal.)
iv = 1
is = 1
DO ki = 1 , N
!
IF ( somev ) THEN
IF ( .NOT.Select(ki) ) CYCLE
ENDIF
smin = MAX(ulp*(CABS1(T(ki,ki))),smlnum)
!
! --------------------------------------------------------
! Complex left eigenvector
!
Work(ki+iv*N) = CONE
!
! Form right-hand side.
!
DO k = ki + 1 , N
Work(k+iv*N) = -CONJG(T(ki,k))
ENDDO
!
! Solve conjugate-transposed triangular system:
! [ T(KI+1:N,KI+1:N) - T(KI,KI) ]**H * X = SCALE*WORK.
!
DO k = ki + 1 , N
T(k,k) = T(k,k) - T(ki,ki)
IF ( CABS1(T(k,k))<smin ) T(k,k) = smin
ENDDO
!
IF ( ki<N ) THEN
CALL CLATRS('Upper','Conjugate transpose','Non-unit','Y',&
& N-ki,T(ki+1,ki+1),Ldt,Work(ki+1+iv*N),scale, &
& Rwork,Info)
Work(ki+iv*N) = scale
ENDIF
!
! Copy the vector x or Q*x to VL and normalize.
!
IF ( .NOT.over ) THEN
! ------------------------------
! no back-transform: copy x to VL and normalize.
CALL CCOPY(N-ki+1,Work(ki+iv*N),1,Vl(ki,is),1)
!
ii = ICAMAX(N-ki+1,Vl(ki,is),1) + ki - 1
remax = ONE/CABS1(Vl(ii,is))
CALL CSSCAL(N-ki+1,remax,Vl(ki,is),1)
!
DO k = 1 , ki - 1
Vl(k,is) = CZERO
ENDDO
!
ELSEIF ( nb==1 ) THEN
! ------------------------------
! version 1: back-transform each vector with GEMV, Q*x.
IF ( ki<N ) CALL CGEMV('N',N,N-ki,CONE,Vl(1,ki+1),Ldvl, &
& Work(ki+1+iv*N),1,CMPLX(scale), &
& Vl(1,ki),1)
!
ii = ICAMAX(N,Vl(1,ki),1)
remax = ONE/CABS1(Vl(ii,ki))
CALL CSSCAL(N,remax,Vl(1,ki),1)
!
ELSE
! ------------------------------
! version 2: back-transform block of vectors with GEMM
! zero out above vector
! could go from KI-NV+1 to KI-1
DO k = 1 , ki - 1
Work(k+iv*N) = CZERO
ENDDO
!
! Columns 1:IV of work are valid vectors.
! When the number of vectors stored reaches NB,
! or if this was last vector, do the GEMM
IF ( (iv==nb) .OR. (ki==N) ) THEN
CALL CGEMM('N','N',N,iv,N-ki+iv,CONE,Vl(1,ki-iv+1), &
& Ldvl,Work(ki-iv+1+(1)*N),N,CZERO, &
& Work(1+(nb+1)*N),N)
! normalize vectors
DO k = 1 , iv
ii = ICAMAX(N,Work(1+(nb+k)*N),1)
remax = ONE/CABS1(Work(ii+(nb+k)*N))
CALL CSSCAL(N,remax,Work(1+(nb+k)*N),1)
ENDDO
CALL CLACPY('F',N,iv,Work(1+(nb+1)*N),N,Vl(1,ki-iv+1),&
& Ldvl)
iv = 1
ELSE
iv = iv + 1
ENDIF
ENDIF
!
! Restore the original diagonal elements of T.
!
DO k = ki + 1 , N
T(k,k) = Work(k)
ENDDO
!
is = is + 1
ENDDO
ENDIF
!
!
! End of CTREVC3
!
END SUBROUTINE CTREVC3
| src/complex/ctrevc3.f90 |
active component C {
async command C opcode "abc"
}
| compiler/tools/fpp-check/test/command/bad_opcode.fpp |
c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine make_set
c---------------------------------------------------------------------
c---------------------------------------------------------------------
c---------------------------------------------------------------------
c This function allocates space for a set of cells and fills the set
c such that communication between cells on different nodes is only
c nearest neighbor
c---------------------------------------------------------------------
include 'header.h'
include 'mpinpb.h'
integer p, i, j, c, dir, size, excess, ierr,ierrcode
c---------------------------------------------------------------------
c compute square root; add small number to allow for roundoff
c (note: this is computed in setup_mpi.f also, but prefer to do
c it twice because of some include file problems).
c---------------------------------------------------------------------
ncells = dint(dsqrt(dble(no_nodes) + 0.00001d0))
c---------------------------------------------------------------------
c this makes coding easier
c---------------------------------------------------------------------
p = ncells
c---------------------------------------------------------------------
c determine the location of the cell at the bottom of the 3D
c array of cells
c---------------------------------------------------------------------
cell_coord(1,1) = mod(node,p)
cell_coord(2,1) = node/p
cell_coord(3,1) = 0
c---------------------------------------------------------------------
c set the cell_coords for cells in the rest of the z-layers;
c this comes down to a simple linear numbering in the z-direct-
c ion, and to the doubly-cyclic numbering in the other dirs
c---------------------------------------------------------------------
do c=2, p
cell_coord(1,c) = mod(cell_coord(1,c-1)+1,p)
cell_coord(2,c) = mod(cell_coord(2,c-1)-1+p,p)
cell_coord(3,c) = c-1
end do
c---------------------------------------------------------------------
c offset all the coordinates by 1 to adjust for Fortran arrays
c---------------------------------------------------------------------
do dir = 1, 3
do c = 1, p
cell_coord(dir,c) = cell_coord(dir,c) + 1
end do
end do
c---------------------------------------------------------------------
c slice(dir,n) contains the sequence number of the cell that is in
c coordinate plane n in the dir direction
c---------------------------------------------------------------------
do dir = 1, 3
do c = 1, p
slice(dir,cell_coord(dir,c)) = c
end do
end do
c---------------------------------------------------------------------
c fill the predecessor and successor entries, using the indices
c of the bottom cells (they are the same at each level of k
c anyway) acting as if full periodicity pertains; note that p is
c added to those arguments to the mod functions that might
c otherwise return wrong values when using the modulo function
c---------------------------------------------------------------------
i = cell_coord(1,1)-1
j = cell_coord(2,1)-1
predecessor(1) = mod(i-1+p,p) + p*j
predecessor(2) = i + p*mod(j-1+p,p)
predecessor(3) = mod(i+1,p) + p*mod(j-1+p,p)
successor(1) = mod(i+1,p) + p*j
successor(2) = i + p*mod(j+1,p)
successor(3) = mod(i-1+p,p) + p*mod(j+1,p)
c---------------------------------------------------------------------
c now compute the sizes of the cells
c---------------------------------------------------------------------
do dir= 1, 3
c---------------------------------------------------------------------
c set cell_coord range for each direction
c---------------------------------------------------------------------
size = grid_points(dir)/p
excess = mod(grid_points(dir),p)
do c=1, ncells
if (cell_coord(dir,c) .le. excess) then
cell_size(dir,c) = size+1
cell_low(dir,c) = (cell_coord(dir,c)-1)*(size+1)
cell_high(dir,c) = cell_low(dir,c)+size
else
cell_size(dir,c) = size
cell_low(dir,c) = excess*(size+1)+
> (cell_coord(dir,c)-excess-1)*size
cell_high(dir,c) = cell_low(dir,c)+size-1
endif
if (cell_size(dir, c) .le. 2) then
write(*,50)
50 format(' Error: Cell size too small. Min size is 3')
ierrcode = 1
call MPI_Abort(mpi_comm_world,ierrcode,ierr)
stop
endif
end do
end do
return
end
c---------------------------------------------------------------------
c---------------------------------------------------------------------
| bench/synthetics/NAS/NPB3.3.1/NPB3.3-MPI/BT/make_set.f |
module vegetables_utilities_m
use iso_varying_string, only: varying_string, operator(//)
use strff, only: add_hanging_indentation, join, strff_to_string => to_string, NEWLINE
implicit none
private
public :: to_string, equals_within_absolute, equals_within_relative
interface to_string
module procedure double_array_to_string
module procedure double_matrix_to_string
module procedure double_tensor_to_string
module procedure integer_array_to_string
module procedure integer_matrix_to_string
module procedure integer_tensor_to_string
end interface
contains
pure function double_array_to_string(array) result(string)
double precision, intent(in) :: array(:)
type(varying_string) :: string
string = "[" // join(strff_to_string(array), ", ") // "]"
end function
pure function double_matrix_to_string(matrix) result(string)
double precision, intent(in) :: matrix(:,:)
type(varying_string) :: string
integer :: i
string = add_hanging_indentation( &
"[" // join([(to_string(matrix(i,:)), i = 1, size(matrix, dim=1))], "," // NEWLINE) // "]", &
1)
end function
pure function double_tensor_to_string(tensor) result(string)
double precision, intent(in) :: tensor(:,:,:)
type(varying_string) :: string
integer :: i
string = add_hanging_indentation( &
"[" // join([(to_string(tensor(i,:,:)), i = 1, size(tensor, dim=1))], "," // NEWLINE) // "]", &
1)
end function
pure function integer_array_to_string(array) result(string)
integer, intent(in) :: array(:)
type(varying_string) :: string
string = "[" // join(strff_to_string(array), ", ") // "]"
end function
pure function integer_matrix_to_string(matrix) result(string)
integer, intent(in) :: matrix(:,:)
type(varying_string) :: string
integer :: i
string = add_hanging_indentation( &
"[" // join([(to_string(matrix(i,:)), i = 1, size(matrix, dim=1))], "," // NEWLINE) // "]", &
1)
end function
pure function integer_tensor_to_string(tensor) result(string)
integer, intent(in) :: tensor(:,:,:)
type(varying_string) :: string
integer :: i
string = add_hanging_indentation( &
"[" // join([(to_string(tensor(i,:,:)), i = 1, size(tensor, dim=1))], "," // NEWLINE) // "]", &
1)
end function
elemental function equals_within_absolute(expected, actual, tolerance)
double precision, intent(in) :: expected
double precision, intent(in) :: actual
double precision, intent(in) :: tolerance
logical :: equals_within_absolute
equals_within_absolute = abs(expected - actual) <= tolerance
end function
elemental function equals_within_relative(expected, actual, tolerance)
double precision, intent(in) :: expected
double precision, intent(in) :: actual
double precision, intent(in) :: tolerance
logical :: equals_within_relative
double precision, parameter :: MACHINE_TINY = tiny(0.0d0)
equals_within_relative = &
(abs(expected) <= MACHINE_TINY .and. abs(actual) <= MACHINE_TINY) &
.or. (abs(expected - actual) / abs(expected) <= tolerance)
end function
end module
| src/vegetables/utilities_m.f90 |
module occa_uva_m
! occa/c/uva.h
use occa_types_m
implicit none
interface
! bool occaIsManaged(void *ptr);
logical(kind=C_bool) function occaIsManaged(ptr) &
bind(C, name="occaIsManaged")
import C_void_ptr, C_bool
implicit none
type(C_void_ptr), value :: ptr
end function
! void occaStartManaging(void *ptr);
subroutine occaStartManaging(ptr) bind(C, name="occaStartManaging")
import C_void_ptr
implicit none
type(C_void_ptr), value :: ptr
end subroutine
! void occaStopManaging(void *ptr);
subroutine occaStopManaging(ptr) bind(C, name="occaStopManaging")
import C_void_ptr
implicit none
type(C_void_ptr), value :: ptr
end subroutine
! void occaSyncToDevice(void *ptr, const occaUDim_t bytes);
subroutine occaSyncToDevice(ptr, bytes) bind(C, name="occaSyncToDevice")
import C_void_ptr, occaUDim_t
implicit none
type(C_void_ptr), value :: ptr
integer(occaUDim_t), value :: bytes
end subroutine
! void occaSyncToHost(void *ptr, const occaUDim_t bytes);
subroutine occaSyncToHost(ptr, bytes) bind(C, name="occaSyncToHost")
import C_void_ptr, occaUDim_t
implicit none
type(C_void_ptr), value :: ptr
integer(occaUDim_t), value :: bytes
end subroutine
! bool occaNeedsSync(void *ptr);
logical(kind=C_bool) function occaNeedsSync(ptr) &
bind(C, name="occaNeedsSync")
import C_void_ptr, C_bool
implicit none
type(C_void_ptr), value :: ptr
end function
! void occaSync(void *ptr);
subroutine occaSync(ptr) bind(C, name="occaSync")
import C_void_ptr
implicit none
type(C_void_ptr), value :: ptr
end subroutine
! void occaDontSync(void *ptr);
subroutine occaDontSync(ptr) bind(C, name="occaDontSync")
import C_void_ptr
implicit none
type(C_void_ptr), value :: ptr
end subroutine
! void occaFreeUvaPtr(void *ptr);
subroutine occaFreeUvaPtr(ptr) bind(C, name="occaFreeUvaPtr")
import C_void_ptr
implicit none
type(C_void_ptr), value :: ptr
end subroutine
end interface
end module occa_uva_m
| 3rd_party/occa/src/fortran/occa_uva_m.f90 |
program gen_constants
implicit none
include 'mpif.h'
call output("MPI_BYTE ", MPI_BYTE)
! Older versions of OpenMPI (such as those used by default by
! Travis) do not define MPI_WCHAR and the MPI_*INT*_T types for
! Fortran. We thus don't require them (yet).
! call output("MPI_WCHAR ", MPI_WCHAR)
! call output("MPI_INT8_T ", MPI_INT8_T)
! call output("MPI_UINT8_T ", MPI_UINT8_T)
! call output("MPI_INT16_T ", MPI_INT16_T)
! call output("MPI_UINT16_T ", MPI_UINT16_T)
! call output("MPI_INT32_T ", MPI_INT32_T)
! call output("MPI_UINT32_T ", MPI_UINT32_T)
! call output("MPI_INT64_T ", MPI_INT64_T)
! call output("MPI_UINT64_T ", MPI_UINT64_T)
call output("MPI_INTEGER1 ", MPI_INTEGER1)
call output("MPI_INTEGER2 ", MPI_INTEGER2)
call output("MPI_INTEGER4 ", MPI_INTEGER4)
call output("MPI_INTEGER8 ", MPI_INTEGER8)
call output("MPI_REAL4 ", MPI_REAL4)
call output("MPI_REAL8 ", MPI_REAL8)
call output("MPI_COMPLEX8 ", MPI_COMPLEX8)
call output("MPI_COMPLEX16 ", MPI_COMPLEX16)
call output("MPI_COMM_NULL ", MPI_COMM_NULL)
call output("MPI_COMM_SELF ", MPI_COMM_SELF)
call output("MPI_COMM_WORLD ", MPI_COMM_WORLD)
call output("MPI_COMM_TYPE_SHARED", MPI_COMM_TYPE_SHARED)
call output("MPI_OP_NULL ", MPI_OP_NULL)
call output("MPI_BAND ", MPI_BAND)
call output("MPI_BOR ", MPI_BOR)
call output("MPI_BXOR ", MPI_BXOR)
call output("MPI_LAND ", MPI_LAND)
call output("MPI_LOR ", MPI_LOR)
call output("MPI_LXOR ", MPI_LXOR)
call output("MPI_MAX ", MPI_MAX)
call output("MPI_MAXLOC ", MPI_MAXLOC)
call output("MPI_MIN ", MPI_MIN)
call output("MPI_NO_OP ", MPI_NO_OP)
call output("MPI_MINLOC ", MPI_MINLOC)
call output("MPI_PROD ", MPI_PROD)
call output("MPI_REPLACE ", MPI_REPLACE)
call output("MPI_SUM ", MPI_SUM)
call output("MPI_REQUEST_NULL", MPI_REQUEST_NULL)
call output("MPI_INFO_NULL ", MPI_INFO_NULL)
call output("MPI_STATUS_SIZE ", MPI_STATUS_SIZE)
call output("MPI_ERROR ", MPI_ERROR)
call output("MPI_SOURCE ", MPI_SOURCE)
call output("MPI_TAG ", MPI_TAG)
call output("MPI_ANY_SOURCE ", MPI_ANY_SOURCE)
call output("MPI_ANY_TAG ", MPI_ANY_TAG)
call output("MPI_TAG_UB ", MPI_TAG_UB)
call output("MPI_UNDEFINED ", MPI_UNDEFINED)
call output("MPI_INFO_NULL ", MPI_INFO_NULL)
call output("MPI_LOCK_EXCLUSIVE", MPI_LOCK_EXCLUSIVE)
call output("MPI_LOCK_SHARED ", MPI_LOCK_SHARED)
contains
subroutine output(name, value)
character*(*) name
integer value
print '("const ",a," = Cint(",i0,")")', name, value
end subroutine output
end program gen_constants
| deps/gen_constants.f90 |
subroutine clawpack46_set_capacity(mx,my,mbc,dx,dy,
& area,mcapa,maux,aux)
implicit none
integer mbc, mx, my, maux, mcapa
double precision dx, dy
double precision aux(1-mbc:mx+mbc,1-mbc:my+mbc, maux)
double precision area(-mbc:mx+mbc+1,-mbc:my+mbc+1)
integer i,j
double precision dxdy
dxdy = dx*dy
do j = 1-mbc,my+mbc
do i = 1-mbc,mx+mbc
aux(i,j,mcapa) = area(i,j)/dxdy
enddo
enddo
end
| src/solvers/fc2d_clawpack4.6/fortran_source/clawpack46_set_capacity.f |
SUBROUTINE G0SSHD(SURFAS,ISTRTX,ISTOPX,NPTSX,
& ISTRTY,ISTOPY,NPTSY)
C
C ------------------------------------------------
C ROUTINE NO. ( 367) VERSION (A9.1) 13:JAN:94
C ------------------------------------------------
C
PARAMETER (ISZARR= 1200, JSZARR= 600)
REAL SURFAS(NPTSX,NPTSY),XPOS(JSZARR),YPOS(JSZARR),
& RDATA(1),XADDPT(3),YADDPT(3),SXPT(4),SYPT(4),SZPT(4)
INTEGER IPTRS(JSZARR),IDATA(1)
LOGICAL ERRON
C
COMMON /T0INTS/ XLINE1(2),YLINE1(2),XLINE2(2),YLINE2(2)
COMMON /T0SAN1/ SINAZA,COSAZA,SINTLT,COSTLT
COMMON /T0SAXE/ INDAXE,XAXORG,YAXORG,XAXDEL,YAXDEL
COMMON /T0SCHN/ LSTFRE(ISZARR),IFPNTR(ISZARR),IBPNTR(ISZARR),
& SXPOS(ISZARR),SYPOS(ISZARR),ISPNTR
COMMON /T0SCOM/ XLEN,YLEN,SCALE,XSHIFT,YSHIFT,SURMIN,SURMAX
COMMON /T0SDL1/ DELTXR,DELTYR,DELTZR,DELTXC,DELTYC,DELTZC,
& VSCALE,ZSCALE,ITPBTM,IQDRNT
COMMON /T0SIND/ ISURIN
COMMON /T0SKOL/ HUESHD,JKOLS,KOLSTA
COMMON /T0SLIT/ ALIGHT,BLIGHT,CLIGHT
COMMON /T0SREF/ AMBINT,DIFFUS,SPECT
COMMON /T3ERRS/ ERRON,NUMERR
C
DATA RDATA /0.0/
C
C
C INITIALISE THE CHAINED LIST
C
DO 100 ISET= 1,ISZARR
LSTFRE(ISET)= 0
IFPNTR(ISET)= 0
IBPNTR(ISET)= 0
100 CONTINUE
C
LSTFRE(1)= 1
ISPNTR= 1
INDC= -1
IF (IQDRNT.EQ.1) THEN
ISTRTA= ISTRTX
ISTOPA= ISTOPX
INCA= 1
ISTRTB= ISTRTY
ISTOPB= ISTOPY
SHPOS= MAX(MIN(SURFAS(ISTRTA,ISTRTB),SURMAX),SURMIN)
INCB= 1
IDIR= 0
ELSE IF (IQDRNT.EQ.2) THEN
ISTRTA= ISTOPY
ISTOPA= ISTRTY
INCA= -1
ISTRTB= ISTRTX
ISTOPB= ISTOPX
SHPOS= MAX(MIN(SURFAS(ISTRTB,ISTRTA),SURMAX),SURMIN)
INCB= 1
IDIR= 1
ELSE IF (IQDRNT.EQ.3) THEN
ISTRTA= ISTOPX
ISTOPA= ISTRTX
INCA= -1
ISTRTB= ISTOPY
ISTOPB= ISTRTY
SHPOS= MAX(MIN(SURFAS(ISTRTA,ISTRTB),SURMAX),SURMIN)
INCB= -1
IDIR= 0
ELSE
ISTRTA= ISTRTY
ISTOPA= ISTOPY
INCA= 1
ISTRTB= ISTOPX
ISTOPB= ISTRTX
SHPOS= MAX(MIN(SURFAS(ISTRTB,ISTRTA),SURMAX),SURMIN)
INCB= -1
IDIR= 1
ENDIF
C
SXPOS(1)= XSHIFT
SYPOS(1)= VSCALE*SHPOS+YSHIFT
C
DO 200 JJ= ISTRTB,ISTOPB-INCB,INCB
INDC= INDC+1
INDC1= INDC+1
INDR= -1
IF (IDIR.EQ.0) THEN
SHPOS1= MAX(MIN(SURFAS(ISTRTA,JJ),SURMAX),SURMIN)
SHPOS2= MAX(MIN(SURFAS(ISTRTA,JJ+INCB),SURMAX),SURMIN)
ELSE
SHPOS1= MAX(MIN(SURFAS(JJ,ISTRTA),SURMAX),SURMIN)
SHPOS2= MAX(MIN(SURFAS(JJ+INCB,ISTRTA),SURMAX),SURMIN)
ENDIF
C
SXPOS1= INDC*DELTXC+XSHIFT
SYPOS1= INDC*DELTYC+VSCALE*SHPOS1+YSHIFT
SZPT(1)= INDC*DELTZC-ZSCALE*SHPOS1
SXPOS2= INDC1*DELTXC+XSHIFT
SYPOS2= INDC1*DELTYC+VSCALE*SHPOS2+YSHIFT
SZPT(2)= INDC1*DELTZC-ZSCALE*SHPOS2
C
DO 200 II= ISTRTA,ISTOPA-INCA,INCA
INDR= INDR+1
INDR1= INDR+1
IF (IDIR.EQ.0) THEN
SHPOS3= MAX(MIN(SURFAS(II+INCA,JJ+INCB),SURMAX),SURMIN)
SHPOS4= MAX(MIN(SURFAS(II+INCA,JJ),SURMAX),SURMIN)
ELSE
SHPOS3= MAX(MIN(SURFAS(JJ+INCB,II+INCA),SURMAX),SURMIN)
SHPOS4= MAX(MIN(SURFAS(JJ,II+INCA),SURMAX),SURMIN)
ENDIF
C
SXPOS3= INDR1*DELTXR+INDC1*DELTXC+XSHIFT
SYPOS3= INDR1*DELTYR+INDC1*DELTYC+VSCALE*SHPOS3+YSHIFT
SZPT(3)= INDR1*DELTZR+INDC1*DELTZC-ZSCALE*SHPOS3
SXPOS4= INDR1*DELTXR+INDC*DELTXC+XSHIFT
SYPOS4= INDR1*DELTYR+INDC*DELTYC+VSCALE*SHPOS4+YSHIFT
SZPT(4)= INDR1*DELTZR+INDC*DELTZC-ZSCALE*SHPOS4
C
IF (ITPBTM.EQ.0) GO TO 13
IF (INDR1.EQ.1) CALL G0SADD(SXPOS2,SYPOS2)
IF (INDC.EQ.0) CALL G0SADD(SXPOS4,SYPOS4)
C
SXPT(1)= SXPOS1
SXPT(2)= SXPOS2
SXPT(3)= SXPOS3
SXPT(4)= SXPOS4
SYPT(1)= SYPOS1
SYPT(2)= SYPOS2
SYPT(3)= SYPOS3
SYPT(4)= SYPOS4
C
C ASSEMBLE THE POLYLINE DEFINING THE TOP
C OF THE VISIBLE REGION.
C
CALL G0SCPT(SXPOS2,IFSTPT)
NXTPOI= ISPNTR
IF (IFSTPT.NE.0) NXTPOI= IFPNTR(IFSTPT)
C
XPOS(1)= SXPOS(IFSTPT)
YPOS(1)= SYPOS(IFSTPT)
IPTRS(1)= IFSTPT
XPOS(2)= SXPOS(NXTPOI)
YPOS(2)= SYPOS(NXTPOI)
IPTRS(2)= NXTPOI
LSTSIZ= 2
INDEX3= 1
IF (XPOS(2).LE.SXPOS3) INDEX3= 2
C
CALL G0SCPT(SXPOS4,LSTPNT)
IF (SXPOS4.GT.SXPOS(LSTPNT)) LSTPNT= IFPNTR(LSTPNT)
1 IF (NXTPOI.EQ.LSTPNT) GO TO 2
C
LSTSIZ= LSTSIZ+1
IF (LSTSIZ.GT.JSZARR) GO TO 901
C
NXTPOI= IFPNTR(NXTPOI)
XPOS(LSTSIZ)= SXPOS(NXTPOI)
IF (XPOS(LSTSIZ).LE.SXPOS3) INDEX3= LSTSIZ
C
YPOS(LSTSIZ)= SYPOS(NXTPOI)
IPTRS(LSTSIZ)= NXTPOI
GO TO 1
C
2 INDEX2= INDEX3
IF (XPOS(INDEX3).LT.SXPOS3) INDEX2= INDEX2+1
C
LFLAG= 0
C
C CHECK THE VISIBILITY OF THE LINE END POINTS.
C SET 'IVIS' TO -1 IF THE POINT IS INVISIBLE,
C 0 FOR COINCIDENCE AND
C 1 IF THE POINT IS VISIBLE.
C
C IVIS AND IVIS1 CAN EACH TAKE ONE OF THREE VALUES.
C THEREFORE THERE ARE NINE COMBINATIONS OR CASES.
C
C CASE IVIS IVIS1 IVIS+IVIS1
C
C 1 -1 -1 -2
C 2 -1 0 -1
C 3 -1 1 0
C 4 0 -1 -1
C 5 0 0 0
C 6 0 1 1
C 7 1 -1 0
C 8 1 0 1
C 9 1 1 2
C
YVAL= (SXPOS2-XPOS(1))*(YPOS(2)-YPOS(1))/
& (XPOS(2)-XPOS(1))+YPOS(1)
IVIS2= 0
IF (SYPOS2.GT.YVAL) IVIS2= 1
IF (SYPOS2.LT.YVAL) IVIS2= -1
C
YVAL= (SXPOS3-XPOS(INDEX3))*(YPOS(INDEX3+1)-YPOS(INDEX3))/
& (XPOS(INDEX3+1)-XPOS(INDEX3))+YPOS(INDEX3)
IVIS3= 0
IF (SYPOS3.GT.YVAL) IVIS3= 1
IF (SYPOS3.LT.YVAL) IVIS3= -1
C
YVAL= (SXPOS4-XPOS(LSTSIZ-1))*(YPOS(LSTSIZ)-YPOS(LSTSIZ-1))/
& (XPOS(LSTSIZ)-XPOS(LSTSIZ-1))+YPOS(LSTSIZ-1)
IVIS4= 0
IF (SYPOS4.GT.YVAL) IVIS4= 1
IF (SYPOS4.LT.YVAL) IVIS4= -1
C
C PROCESS THE FIRST LINE SECTION.
C
XINT1= SXPOS2
YINT1= SYPOS2
INDADD= 0
INDST= 1
IVISL= IVIS2
IVIS= -IVIS2
IND= 1
3 IND= IND+1
IF (IND.GT.INDEX2) GO TO 7
C
YVAL= (XPOS(IND)-SXPOS2)*(SYPOS3-SYPOS2)/
& (SXPOS3-SXPOS2)+SYPOS2
IVIS1= 0
IF (YPOS(IND).GT.YVAL) IVIS1= 1
IF (YPOS(IND).LT.YVAL) IVIS1= -1
IF (IND.EQ.INDEX2) IVIS1= -IVIS3
IF (IVIS.EQ.0) GO TO 6
IF (IVIS+IVIS1.NE.0) GO TO 4
C
C CASES 3 AND 7
C
C FIND INTERSECTION ON LINE IND-1 TO IND
C
XLINE1(1)= XINT1
YLINE1(1)= YINT1
XLINE1(2)= SXPOS3
YLINE1(2)= SYPOS3
XLINE2(1)= XPOS(IND-1)
YLINE2(1)= YPOS(IND-1)
XLINE2(2)= XPOS(IND)
YLINE2(2)= YPOS(IND)
CALL G0INTR(ICODE,XINT2,YINT2)
INDADD= INDADD+1
XADDPT(INDADD)= XINT2
YADDPT(INDADD)= YINT2
XINT1= XINT2
YINT1= YINT2
IF (IVIS.NE.1) THEN
C
C CASE 3
C
CALL G0SHAD(XPOS,YPOS,INDST,IND-1,XADDPT,YADDPT,INDADD,
& SXPT,SYPT,SZPT)
C
INDADD= 0
CALL G0SDEL(IPTRS(IND-1))
ELSE
C
C CASE7
C
INDST= IND
ENDIF
C
GO TO 5
C
C CASES 1, 2, 8 AND 9
C
4 IF (IVIS.LT.0.AND.XPOS(IND).LE.SXPOS3)
C
C CASES 1 AND 2
C
& CALL G0SDEL(IPTRS(IND-1))
IF (IVIS1.NE.0) GO TO 6
C
C CASES 2 AND 8
C
IF (IVIS.NE.1) THEN
C
C CASE 2
C
CALL G0SHAD(XPOS,YPOS,INDST,IND,XADDPT,YADDPT,INDADD,
& SXPT,SYPT,SZPT)
C
INDADD= 0
ENDIF
C
C CASES 2 AND 8
C
INDST= IND
XINT1= XPOS(IND)
YINT1= YPOS(IND)
C
C CASES 2, 3, 7 AND 8
C
5 CALL G0SADD(XINT1,YINT1)
C
C ALL CASES
C
6 IVISL= -IVIS1
IVISAV= IVIS
IVIS= IVIS1
GO TO 3
C
7 IF (IVISL+IVIS3.GT.0) THEN
IF (IVISAV.GE.0.AND.INDEX2.GT.INDEX3) LFLAG= 1
C
INDADD= INDADD+1
XADDPT(INDADD)= SXPOS3
YADDPT(INDADD)= SYPOS3
CALL G0SADD(SXPOS3,SYPOS3)
ENDIF
C
C PROCESS THE SECOND LINE SECTION.
C
XINT1= SXPOS3
YINT1= SYPOS3
IVISL= IVIS3
IVIS= -IVIS3
IND= INDEX3
8 IND= IND+1
IF (IND.GT.LSTSIZ) GO TO 12
C
YVAL= (XPOS(IND)-SXPOS3)*(SYPOS4-SYPOS3)/
& (SXPOS4-SXPOS3)+SYPOS3
IVIS1= 0
IF (YPOS(IND).GT.YVAL) IVIS1= 1
IF (YPOS(IND).LT.YVAL) IVIS1= -1
IF (IND.EQ.LSTSIZ) IVIS1= -IVIS4
IF (IVIS.EQ.0) GO TO 11
IF (IVIS+IVIS1.NE.0) GO TO 9
C
C CASES 3 AND 7
C
C FIND INTERSECTION ON LINE IND-1 TO IND
C
XLINE1(1)= XINT1
YLINE1(1)= YINT1
XLINE1(2)= SXPOS4
YLINE1(2)= SYPOS4
XLINE2(1)= XPOS(IND-1)
YLINE2(1)= YPOS(IND-1)
XLINE2(2)= XPOS(IND)
YLINE2(2)= YPOS(IND)
CALL G0INTR(ICODE,XINT2,YINT2)
INDADD= INDADD+1
XADDPT(INDADD)= XINT2
YADDPT(INDADD)= YINT2
XINT1= XINT2
YINT1= YINT2
IF (IVIS.NE.1) THEN
C
C CASE 3
C
CALL G0SHAD(XPOS,YPOS,INDST,IND-1,XADDPT,YADDPT,INDADD,
& SXPT,SYPT,SZPT)
C
INDADD= 0
IF (LFLAG.EQ.0)
& CALL G0SDEL(IPTRS(IND-1))
C
LFLAG= 0
ELSE
C
C CASE7
C
INDST= IND
ENDIF
C
GO TO 10
C
C CASES 1, 2, 8 AND 9
C
9 IF (IVIS.LT.0.AND.LFLAG.EQ.0)
C
C CASES 1 AND 2
C
& CALL G0SDEL(IPTRS(IND-1))
C
LFLAG= 0
IF (IVIS1.NE.0) GO TO 11
C
C CASES 2 AND 8
C
IF (IVIS.NE.1) THEN
C
C CASE 2
C
CALL G0SHAD(XPOS,YPOS,INDST,IND,XADDPT,YADDPT,INDADD,
& SXPT,SYPT,SZPT)
C
INDADD= 0
ENDIF
C
C CASES 2 AND 8
C
INDST= IND
XINT1= XPOS(IND)
YINT1= YPOS(IND)
C
C CASES 2, 3, 7 AND 8
C
10 CALL G0SADD(XINT1,YINT1)
C
C ALL CASES
C
11 IVISL= -IVIS1
IVIS= IVIS1
GO TO 8
C
12 IF (IVISL.EQ.0) CALL G0SDEL(IPTRS(LSTSIZ))
C
GO TO 14
C
C FILL THE BASE.
C
13 IF (INDC.EQ.0) THEN
YBAS1= INDR*DELTYR+VSCALE*SURMIN+YSHIFT
YBAS4= YBAS1+DELTYR
IDATA(1)= 0
CALL G3LINK(5,13,-1,IDATA,RDATA)
PRODNL= SINAZA*ALIGHT-COSAZA*SINTLT*BLIGHT-
& COSAZA*COSTLT*CLIGHT
PROD= AMBINT+DIFFUS*MIN(MAX(PRODNL,0.0),1.0)
IDATA(1)= NINT(PROD*JKOLS)+KOLSTA
CALL G3LINK(5,3,-1,IDATA,RDATA)
CALL POSITN(SXPOS1,SYPOS1)
CALL JOIN(SXPOS1,YBAS1)
CALL JOIN(SXPOS4,YBAS4)
CALL JOIN(SXPOS4,SYPOS4)
CALL JOIN(SXPOS1,SYPOS1)
CALL G3LINK(5,4,0,IDATA,RDATA)
ENDIF
C
IF (INDR.EQ.0) THEN
YBAS1= INDC*DELTYC+VSCALE*SURMIN+YSHIFT
YBAS2= YBAS1+DELTYC
IDATA(1)= 0
CALL G3LINK(5,13,-1,IDATA,RDATA)
PRODNL= -COSAZA*ALIGHT-SINAZA*SINTLT*BLIGHT-
& SINAZA*COSTLT*CLIGHT
PROD= AMBINT+DIFFUS*MIN(MAX(PRODNL,0.0),1.0)
IDATA(1)= NINT(PROD*JKOLS)+KOLSTA
CALL G3LINK(5,3,-1,IDATA,RDATA)
CALL POSITN(SXPOS1,SYPOS1)
CALL JOIN(SXPOS1,YBAS1)
CALL JOIN(SXPOS2,YBAS2)
CALL JOIN(SXPOS2,SYPOS2)
CALL JOIN(SXPOS1,SYPOS1)
CALL G3LINK(5,4,0,IDATA,RDATA)
ENDIF
C
14 SXPOS1= SXPOS4
SYPOS1= SYPOS4
SZPT(1)= SZPT(4)
SXPOS2= SXPOS3
SYPOS2= SYPOS3
SZPT(2)= SZPT(3)
200 CONTINUE
C
IF (ITPBTM.EQ.0) RETURN
C
YEND1= VSCALE*SURMIN+YSHIFT
XEND2= INDC1*DELTXC+XSHIFT
YEND2= INDC1*DELTYC+VSCALE*SURMIN+YSHIFT
XEND4= INDR1*DELTXR+XSHIFT
YEND4= INDR1*DELTYR+VSCALE*SURMIN+YSHIFT
IF (INDAXE.NE.0) THEN
C
C DRAW BASE LINES.
C
CALL POSITN(XEND2,YEND2)
CALL JOIN(XSHIFT,YEND1)
CALL JOIN(XEND4,YEND4)
CALL G0SAX1(ISTRTX,ISTOPX,ISTRTY,ISTOPY,
& XEND2,XEND4,YEND1,YEND2,YEND4)
ENDIF
C
IF (ISURIN.NE.0) CALL G0SIND(XEND2,XEND4,YEND2,YEND4)
C
RETURN
C
901 NUMERR= 41
IF (ERRON) CALL G0ERMS
STOP
END
| src/lib/g0sshd.f |
Robbens Department Store is the real deal: it is a time warp to a clothing stores department store of the 1950’s. The building ceiling drops from front to back, about 15’ where you enter to barely 7’ in the back of the store, creating an odd cavelike effect. You are likely to be greeted and served by Robby Robben when you enter. The store was originally owned and operated by his mother, Mildred Robben, until her retirement in 2000.
It is packed – stacked to the ceiling, merchandise hanging from walls, slumping display shelves with heaps of shirts, hats, pants. There are odd countryesque wall hangings (“The worst day fishin’ is better than the best day workin’), kids’ toys, belt buckles, all scattered somewhat randomly around the shop. Some of the merchandise looks as though it has been there since the 1950’s.
The main inventory is western clothing and work clothes. Robben’s carries a full line of genuine Stetson hats, as well as other cowboy hats and boots; Ben Davis work clothes in all sizes; shoes and work boots made in America; Levi trousers and Arrow dress shirts. They will specialorder sizes not in stock. Robben’s rents tuxedos. Cub and Boy Scouting scout supplies are available.
| lab/davisWiki/Robben%27s_Department_Store.f |
SUBROUTINE PCC_SIN(NR,ICORE,AC,BC,CC,R,CDC)
ccccccccccccccccccccccccccccccccccccccccccc
cccccc Replace the original full core charge CDC/r inside r(icore),
cccccc with a form ac*sin(bc*r), match the original charge at r(icore)
cccccc for its value and slop. The purpose is to generate a smoother
cccccc core charge to be used in plane wave calculation
cccccc
cccccc Lin-Wang Wang, Feb. 28, 2001
cccccc Actually, it should be called: PCC_SIN(xxxx)
cccccc
cccccc
ccccccccc This subroutine returns a pseudo core of
ccccccccc cdc(r)=ac*r*sin(bc*r) inside r(icore)
ccccccccc instead of the original
ccccccccc cdc(r)=r^2 * exp(ac+bc*r^2+cc*r^4) inside r(icore)
ccccccccc
ccccccccc This new pseudo-core is softer than
ccccccccc the original exp. core, and uses smaller Ecut in
ccccccccc PEtot calculation. For PEtot calculation, we suggest
ccccccccc this pseudo-core for "pe" calculation (for no GGA pseudopotential).
ccccccccc Lin-Wang Wang, Feb. 28, 2001
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
PARAMETER (NN = 5)
DIMENSION R(NR),CDC(NR),
. DR_K(-NN:NN),DDR_K(-NN:NN),
. CDC_SCA(ICORE-NN:ICORE+NN)
tpfive=2.5d0
pi=4*datan(1.d0)
cccccccccccccccccccccccccccccccccccccccccccc
cdcp = (cdc(icore+1)-cdc(icore))/(r(icore+1)-r(icore))
tanb = cdc(icore)/(r(icore)*cdcp-cdc(icore))
rbold = tpfive
do 500 i = 1, 50
rbnew = pi + datan(tanb*rbold)
if (abs(rbnew-rbold) .lt. .00001D0) then
bc = rbnew/r(icore)
ac = cdc(icore)/(r(icore)*sin(rbnew))
do 490 j = 1, icore
cdc(j) = ac*r(j)*sin(bc*r(j))
490 continue
write(*,*) "r(icore),ac,bc", r(icore), ac, bc
write(*,*) "**************"
write(*,*) "**** USING sin(bc*r) for core charge ***"
write(*,*) "**************"
c
go to 530
c
else
rbold = rbnew
end if
500 continue
write(*,*) "SHOULD NEVER BE HERE, fail to find core charge"
Write(*,*) "inside PCC_EXP.f, stop"
stop
530 continue
cc=1.d0
return
end
| PSEUDO/source/pcc_sin.f |
!***********************************************************************
! Integrated Water Flow Model (IWFM)
! Copyright (C) 2005-2021
! State of California, Department of Water Resources
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License
! as published by the Free Software Foundation; either version 2
! of the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
! (http://www.gnu.org/copyleft/gpl.html)
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
!
! For tecnical support, e-mail: [email protected]
!***********************************************************************
MODULE Class_StrmGWConnector_v40
USE MessageLogger , ONLY: SetLastMessage , &
LogMessage , &
MessageArray , &
iWarn , &
iFatal
USE IOInterface , ONLY: GenericFileType
USE GeneralUtilities , ONLY: StripTextUntilCharacter , &
IntToText , &
CleanSpecialCharacters , &
ConvertID_To_Index
USE Package_Discretization
USE Package_Misc , ONLY: AbstractFunctionType , &
f_iStrmComp , &
f_iGWComp , &
f_rSmoothMaxP
USE Class_BaseStrmGWConnector , ONLY: BaseStrmGWConnectorType , &
iDisconnectAtTopOfBed , &
iDisconnectAtBottomOfBed
USE Package_Matrix , ONLY: MatrixType
IMPLICIT NONE
! ******************************************************************
! ******************************************************************
! ******************************************************************
! ***
! *** VARIABLE DEFINITIONS
! ***
! ******************************************************************
! ******************************************************************
! ******************************************************************
! -------------------------------------------------------------
! --- PUBLIC ENTITIES
! -------------------------------------------------------------
PRIVATE
PUBLIC :: StrmGWConnector_v40_Type
! -------------------------------------------------------------
! --- STREAM-GW CONNECTOR TYPE
! -------------------------------------------------------------
TYPE,EXTENDS(BaseStrmGWConnectorType) :: StrmGWConnector_v40_Type
PRIVATE
CONTAINS
PROCEDURE,PASS :: Simulate => StrmGWConnector_v40_Simulate
PROCEDURE,PASS :: CompileConductance => StrmGWConnector_v40_CompileConductance
END TYPE StrmGWConnector_v40_Type
! -------------------------------------------------------------
! --- MISC. ENTITIES
! -------------------------------------------------------------
INTEGER,PARAMETER :: ModNameLen = 27
CHARACTER(LEN=ModNameLen),PARAMETER :: ModName = 'Class_StrmGWConnector_v40::'
CONTAINS
! -------------------------------------------------------------
! --- COMPILE CONDUCTANCE FOR STREAM-GW CONNECTOR
! -------------------------------------------------------------
SUBROUTINE StrmGWConnector_v40_CompileConductance(Connector,InFile,AppGrid,Stratigraphy,NStrmNodes,iStrmNodeIDs,UpstrmNodes,DownstrmNodes,BottomElevs,iStat)
CLASS(StrmGWConnector_v40_Type) :: Connector
TYPE(GenericFileType) :: InFile
TYPE(AppGridType),INTENT(IN) :: AppGrid
TYPE(StratigraphyType),INTENT(IN) :: Stratigraphy
INTEGER,INTENT(IN) :: NStrmNodes,iStrmNodeIDs(NStrmNodes),UpstrmNodes(:),DownstrmNodes(:)
REAL(8),INTENT(IN) :: BottomElevs(:)
INTEGER,INTENT(OUT) :: iStat
!Local variables
CHARACTER(LEN=ModNameLen+38) :: ThisProcedure = ModName // 'StrmGWConnector_v40_CompileConductance'
INTEGER :: indxReach,indxNode,iGWNode,iGWUpstrmNode,iUpstrmNode, &
iDownstrmNode,iNode,ErrorCode,iLayer,iStrmNodeID, &
iGWNodeID,iInteractionType
REAL(8) :: B_DISTANCE,F_DISTANCE,CA,CB,FACTK,FACTL, &
DummyArray(NStrmNodes,4)
REAL(8),DIMENSION(NStrmNodes) :: BedThick,WetPerimeter,Conductivity
CHARACTER :: ALine*500,TimeUnitConductance*6
LOGICAL :: lProcessed(NStrmNodes)
INTEGER,ALLOCATABLE :: iGWNodes(:)
!Initialize
iStat = 0
lProcessed = .FALSE.
CALL Connector%GetAllGWNodes(iGWNodes)
!Read data
CALL InFile%ReadData(FACTK,iStat) ; IF (iStat .EQ. -1) RETURN
CALL InFile%ReadData(ALine,iStat) ; IF (iStat .EQ. -1) RETURN
CALL CleanSpecialCharacters(ALine)
TimeUnitConductance = ADJUSTL(StripTextUntilCharacter(ALine,'/'))
CALL InFile%ReadData(FACTL,iStat) ; IF (iStat .EQ. -1) RETURN
CALL InFile%ReadData(DummyArray,iStat) ; IF (iStat .EQ. -1) RETURN
!Assumption for stream-aquifer disconnection
CALL InFile%ReadData(iInteractionType,iStat)
IF (iStat .EQ. 0) THEN
CALL Connector%SetInteractionType(iInteractionType,iStat)
IF (iStat .EQ. -1) RETURN
ELSE
iStat = 0
END IF
DO indxNode=1,NStrmNodes
iStrmNodeID = INT(DummyArray(indxNode,1))
CALL ConvertID_To_Index(iStrmNodeID,iStrmNodeIDs,iNode)
IF (iNode .EQ. 0) THEN
CALL SetLastMessage('Stream node '//TRIM(IntToText(iStrmNodeID))//' listed for stream bed parameters is not in the model!',iFatal,ThisProcedure)
iStat = -1
RETURN
END IF
IF (lProcessed(iNode)) THEN
CALL SetLastMessage('Stream bed parameters for stream node '//TRIM(IntToText(iStrmNodeID))//' are defined more than once!',iFatal,ThisProcedure)
iStat = -1
RETURN
END IF
lProcessed(iNode) = .TRUE.
Conductivity(iNode) = DummyArray(indxNode,2)*FACTK
BedThick(iNode) = DummyArray(indxNode,3)*FACTL
WetPerimeter(iNode) = DummyArray(indxNode,4)*FACTL
END DO
!Compute conductance
DO indxReach=1,SIZE(UpstrmNodes)
iUpstrmNode = UpstrmNodes(indxReach)
iDownstrmNode = DownstrmNodes(indxReach)
B_DISTANCE = 0.0
DO indxNode=iUpstrmNode+1,iDownstrmNode
iGWUpstrmNode = iGWNodes(indxNode-1)
iGWNode = iGWNodes(indxNode)
iLayer = Connector%iLayer(indxNode)
IF (Connector%iInteractionType .EQ. iDisconnectAtBottomOfBed) THEN
IF (BottomElevs(indxNode)-BedThick(indxNode) .LT. Stratigraphy%BottomElev(iGWNode,iLayer)) THEN
iStrmNodeID = iStrmNodeIDs(indxNode)
iGWNodeID = AppGrid%AppNode(iGWNode)%ID
BedThick(indxNode) = BottomElevs(indxNode) - Stratigraphy%BottomElev(iGWNode,iLayer)
MessageArray(1) = 'Stream bed thickness at stream node ' // TRIM(IntToText(iStrmNodeID)) // ' and GW node '// TRIM(IntToText(iGWNodeID)) // ' penetrates into second active aquifer layer!'
MessageArray(2) = 'It is adjusted to penetrate only into the top active layer.'
CALL LogMessage(MessageArray(1:2),iWarn,ThisProcedure)
END IF
END IF
CA = AppGrid%X(iGWUpstrmNode) - AppGrid%X(iGWNode)
CB = AppGrid%Y(iGWUpstrmNode) - AppGrid%Y(iGWNode)
F_DISTANCE = SQRT(CA*CA + CB*CB)/2d0
Conductivity(indxNode-1) = Conductivity(indxNode-1)*WetPerimeter(indxNode-1)*(F_DISTANCE+B_DISTANCE)/BedThick(indxNode-1)
B_DISTANCE = F_DISTANCE
END DO
Conductivity(iDownstrmNode) = Conductivity(iDownstrmNode)*WetPerimeter(iDownstrmNode)*B_DISTANCE/BedThick(iDownstrmNode)
END DO
!Allocate memory
ALLOCATE (Connector%Conductance(NStrmNodes) , Connector%rBedThickness(NStrmNodes) , Connector%StrmGWFlow(NStrmNodes) , STAT=ErrorCode)
IF (ErrorCode .NE. 0) THEN
CALL SetLastMessage('Error allocating memory for stream-gw connection data!',iFatal,ThisProcedure)
iStat = -1
RETURN
END IF
!Store information
Connector%Conductance = Conductivity
Connector%rBedThickness = BedThick
Connector%TimeUnitConductance = TimeUnitConductance
Connector%StrmGWFlow = 0.0
IF (Connector%iInteractionType .EQ. iDisconnectAtBottomOfBed) THEN
Connector%rDisconnectElev = BottomElevs - Connector%rBedThickness
ELSE
Connector%rDisconnectElev = BottomElevs
END IF
!Clear memory
DEALLOCATE (iGWNodes , STAT=ErrorCode)
END SUBROUTINE StrmGWConnector_v40_CompileConductance
! -------------------------------------------------------------
! --- SIMULATE STREAM-GW INTERACTION
! -------------------------------------------------------------
SUBROUTINE StrmGWConnector_v40_Simulate(Connector,iNNodes,rGWHeads,rStrmHeads,rAvailableFlows,Matrix,WetPerimeterFunction,rMaxElevs)
CLASS(StrmGWConnector_v40_Type) :: Connector
INTEGER,INTENT(IN) :: iNNodes
REAL(8),INTENT(IN) :: rGWHeads(:),rStrmHeads(:),rAvailableFlows(:)
TYPE(MatrixType) :: Matrix
CLASS(AbstractFunctionType),OPTIONAL,INTENT(IN) :: WetPerimeterFunction(:) !Not used in this version
REAL(8),OPTIONAL,INTENT(IN) :: rMaxElevs(:) !Not used in this version
!Local variables
INTEGER :: iGWNode,iNodes_Connect(2),iNodes_RHS(2),indxStrm
REAL(8) :: Conductance,rUpdateCOEFF(2),rUpdateCOEFF_Keep(2),rUpdateRHS(2),rDiff_GW,rGWHead, &
rDiffGWSQRT,rStrmGWFlow,rStrmGWFlowAdj,rStrmGWFlowAdjSQRT,rDStrmGWFlowAdj,rFractionForGW, &
rNodeAvailableFlow
INTEGER,PARAMETER :: iCompIDs(2) = [f_iStrmComp , f_iGWComp]
!Update matrix equations
DO indxStrm=1,SIZE(rStrmHeads)
!Corresponding GW node and conductance
iGWNode = (Connector%iLayer(indxStrm)-1) * iNNodes + Connector%iGWNode(indxStrm)
Conductance = Connector%Conductance(indxStrm)
rFractionForGW = Connector%rFractionForGW(indxStrm)
!Head differences
rGWHead = rGWHeads(indxStrm)
rDiff_GW = rGWHead - Connector%rDisconnectElev(indxStrm)
rDiffGWSQRT = SQRT(rDiff_GW*rDiff_GW + f_rSmoothMaxP)
!Available flow for node
rNodeAvailableFlow = rAvailableFlows(indxStrm)
!Calculate stream-gw interaction and update of Jacobian
!--------------------------------------------
rStrmGWFlow = Conductance * (rStrmHeads(indxStrm) - MAX(rGWHead,Connector%rDisconnectElev(indxStrm)))
!Stream is gaining; no need to worry about drying stream (i.e. stream-gw flow is not a function of upstream flows)
IF (rStrmGWFlow .LT. 0.0) THEN
Connector%StrmGWFlow(indxStrm) = rStrmGWFlow
iNodes_Connect(1) = indxStrm
iNodes_Connect(2) = iGWNode
!Update Jacobian - entries for stream node
rUpdateCOEFF_Keep(1) = Conductance
rUpdateCOEFF_Keep(2) = -0.5d0 * Conductance * (1d0+rDiff_GW/rDiffGWSQRT)
rUpdateCOEFF = rUpdateCOEFF_Keep
CALL Matrix%UpdateCOEFF(f_iStrmComp,indxStrm,2,iCompIDs,iNodes_Connect,rUpdateCOEFF)
!Update Jacobian - entries for groundwater node
rUpdateCOEFF = -rFractionForGW * rUpdateCOEFF_Keep
CALL Matrix%UpdateCOEFF(f_iGWComp,iGWNode,2,iCompIDs,iNodes_Connect,rUpdateCOEFF)
!Stream is losing; we need to limit stream loss to available flow
ELSE
rStrmGWFlowAdj = rNodeAvailableFlow - rStrmGWFlow
rStrmGWFlowAdjSQRT = SQRT(rStrmGWFlowAdj*rStrmGWFlowAdj + f_rSmoothMaxP)
rDStrmGWFlowAdj = 0.5d0 * (1d0 + rStrmGWFlowAdj / rStrmGWFlowAdjSQRT)
iNodes_Connect(1) = indxStrm
iNodes_Connect(2) = iGWNode
!Update Jacobian - entries for stream node
rUpdateCOEFF_Keep(1) = Conductance * rDStrmGWFlowAdj
rUpdateCOEFF_Keep(2) = -0.5d0 * Conductance * (1d0+rDiff_GW/rDiffGWSQRT) * rDStrmGWFlowAdj
rUpdateCOEFF = rUpdateCOEFF_Keep
CALL Matrix%UpdateCOEFF(f_iStrmComp,indxStrm,2,iCompIDs,iNodes_Connect,rUpdateCOEFF)
!Update Jacobian - entries for groundwater node
rUpdateCOEFF = -rFractionForGW * rUpdateCOEFF_Keep
CALL Matrix%UpdateCOEFF(f_iGWComp,iGWNode,2,iCompIDs,iNodes_Connect,rUpdateCOEFF)
!Store flow exchange
Connector%StrmGWFlow(indxStrm) = MIN(rNodeAvailableFlow , rStrmGWFlow)
END IF
!Update RHS
iNodes_RHS(1) = indxStrm
iNodes_RHS(2) = iGWNode
rUpdateRHS(1) = Connector%StrmGWFlow(indxStrm)
rUpdateRHS(2) = -Connector%StrmGWFlow(indxStrm) * rFractionForGW
CALL Matrix%UpdateRHS(iCompIDs,iNodes_RHS,rUpdateRHS)
END DO
END SUBROUTINE StrmGWConnector_v40_Simulate
END MODULE | code/SourceCode/Package_ComponentConnectors/StrmGWConnector/Class_StrmGWConnector_v40.f90 |
FUNCTION dayear(dd,mm,yyyy)
!
IMPLICIT NONE
!
! Function arguments
!
INTEGER :: dd,mm,yyyy
INTEGER :: dayear
!
! Local variables
!
INTEGER :: difdat
!
! + + + purpose + + +
! given a date in dd/mm/yyyy format,
! dayear will return the number of days
! from the first of that year.
!
! + + + keywords + + +
! date, utility
!
! + + + argument declarations + + +
!
! + + + argument definitions + + +
! dayear - returns the number of days from the first of that year
! dd - day
! mm - month
! yyyy - year
!
! + + + local variable definitions + + +
! difdat - the number of days between two dates. a function. This
! variable holds the value returned by the Diffdat function.
! Debe assumed this definition
! + + + function declarations + + +
!
! + + + end specifications + + +
!
! get the difference in days + 1
!
dayear = difdat(1,1,yyyy,dd,mm,yyyy) + 1
!
END FUNCTION dayear
| Project Documents/Source Code Original/Dayear.f90 |
! { dg-do compile }
! { dg-options "-Wunused-dummy-argument -Wunused-parameter" }
! PR 48847 - we used to generate a warning for g(), and none for h()
program main
contains
function f(g,h)
interface
real function g()
end function g
end interface
interface
real function h() ! { dg-warning "Unused dummy argument" }
end function h
end interface
real :: f
f = g()
end function f
end program main
| validation_tests/llvm/f18/gfortran.dg/warn_unused_dummy_argument_3.f90 |
!
! Parallel Sparse BLAS version 3.5
! (C) Copyright 2006-2018
! Salvatore Filippone
! Alfredo Buttari
!
! 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. The name of the PSBLAS group or the names of its contributors may
! not be used to endorse or promote products derived from this
! software without specific 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 PSBLAS GROUP OR ITS 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.
!
!
!
!
! File: psi_i_crea_index.f90
!
! Subroutine: psb_crea_index
! Converts a list of data exchanges from build format to assembled format.
! See psi_desc_index for a description of the formats.
! Works by first finding a suitable ordering for the data exchanges,
! then doing the actual conversion.
!
! Arguments:
! desc_a - type(psb_desc_type) The descriptor; in this context only the index
! mapping parts are used.
! index_in(:) - integer The index list, build format
! index_out(:) - integer(psb_ipk_), allocatable The index list, assembled format
! nxch - integer The number of data exchanges on the calling process
! nsnd - integer Total send buffer size on the calling process
! nrcv - integer Total receive buffer size on the calling process
!
!
subroutine psi_i_crea_index(desc_a,index_in,index_out,nxch,nsnd,nrcv,info)
use psb_realloc_mod
use psb_desc_mod
use psb_error_mod
use psb_penv_mod
use psb_timers_mod
use psi_mod, psb_protect_name => psi_i_crea_index
implicit none
type(psb_desc_type), intent(in) :: desc_a
integer(psb_ipk_), intent(out) :: info,nxch,nsnd,nrcv
integer(psb_ipk_), intent(in) :: index_in(:)
integer(psb_ipk_), allocatable, intent(inout) :: index_out(:)
! ....local scalars...
type(psb_ctxt_type) :: ctxt
integer(psb_ipk_) :: me, np, mode, err_act, dl_lda, ldl
! ...parameters...
integer(psb_ipk_), allocatable :: length_dl(:), loc_dl(:),&
& c_dep_list(:), dl_ptr(:)
integer(psb_ipk_) :: dlmax, dlavg
integer(psb_ipk_),parameter :: root=psb_root_,no_comm=-1
integer(psb_ipk_) :: debug_level, debug_unit
character(len=20) :: name
logical, parameter :: do_timings=.false., shuffle_dep_list=.false.
integer(psb_ipk_), save :: idx_phase1=-1, idx_phase2=-1, idx_phase3=-1
integer(psb_ipk_), save :: idx_phase21=-1, idx_phase22=-1, idx_phase13=-1
info = psb_success_
name='psi_crea_index'
call psb_erractionsave(err_act)
debug_unit = psb_get_debug_unit()
debug_level = psb_get_debug_level()
ctxt = desc_a%get_ctxt()
call psb_info(ctxt,me,np)
if (np == -1) then
info = psb_err_context_error_
call psb_errpush(info,name)
goto 9999
endif
if ((do_timings).and.(idx_phase1==-1)) &
& idx_phase1 = psb_get_timer_idx("PSI_CREA_INDEX: phase1 ")
if ((do_timings).and.(idx_phase2==-1)) &
& idx_phase2 = psb_get_timer_idx("PSI_CREA_INDEX: phase2")
if ((do_timings).and.(idx_phase3==-1)) &
& idx_phase3 = psb_get_timer_idx("PSI_CREA_INDEX: phase3")
if ((do_timings).and.(idx_phase21==-1)) &
& idx_phase21 = psb_get_timer_idx("PSI_CREA_INDEX: phase21 ")
if ((do_timings).and.(idx_phase22==-1)) &
& idx_phase22 = psb_get_timer_idx("PSI_CREA_INDEX: phase22")
!!$ if ((do_timings).and.(idx_phase13==-1)) &
!!$ & idx_phase13 = psb_get_timer_idx("PSI_CREA_INDEX: phase13")
! ...extract dependence list (ordered list of identifer process
! which every process must communcate with...
if (debug_level >= psb_debug_inner_) &
& write(debug_unit,*) me,' ',trim(name),': calling extract_loc_dl'
mode = 1
if (do_timings) call psb_tic(idx_phase1)
call psi_extract_loc_dl(ctxt,&
& desc_a%is_bld(), desc_a%is_upd(),&
& index_in, loc_dl,length_dl,info)
dlmax = maxval(length_dl(:))
dlavg = (sum(length_dl(:))+np-1)/np
if (do_timings) call psb_toc(idx_phase1)
if (do_timings) call psb_tic(idx_phase2)
if (choose_sorting(dlmax,dlavg,np)) then
if (do_timings) call psb_tic(idx_phase21)
call psi_bld_glb_dep_list(ctxt,&
& loc_dl,length_dl,c_dep_list,dl_ptr,info)
if (info /= 0) then
write(0,*) me,trim(name),' From bld_glb_list ',info
end if
if (do_timings) call psb_toc(idx_phase21)
if (do_timings) call psb_tic(idx_phase22)
call psi_sort_dl(dl_ptr,c_dep_list,length_dl,ctxt,info)
if (info /= 0) then
write(0,*) me,trim(name),' From sort_dl ',info
end if
ldl = length_dl(me)
loc_dl = c_dep_list(dl_ptr(me):dl_ptr(me)+ldl-1)
if (do_timings) call psb_toc(idx_phase22)
else
! Do nothing
ldl = length_dl(me)
loc_dl = loc_dl(1:ldl)
if (shuffle_dep_list) then
!
! Apply a random shuffle to the dependency list
! should improve the behaviour
!
block
! Algorithm 3.4.2P from TAOCP vol 2.
integer(psb_ipk_) :: tmp
integer :: j,k
real :: u
do j=ldl,2,-1
call random_number(u)
k = min(j,floor(j*u)+1)
tmp = loc_dl(k)
loc_dl(k) = loc_dl(j)
loc_dl(j) = tmp
end do
end block
end if
end if
if (do_timings) call psb_toc(idx_phase2)
if (do_timings) call psb_tic(idx_phase3)
if(debug_level >= psb_debug_inner_)&
& write(debug_unit,*) me,' ',trim(name),': calling psi_desc_index',ldl,':',loc_dl(1:ldl)
! Do the actual format conversion.
if (dlmax == 0) then
! There is a sufficiently large number of cases
! where the initial exchange list is empty that
! it's worthwhile to take a shortcut.
call psb_realloc(ione,index_out,info)
index_out(1) = -1
else
call psi_desc_index(desc_a,index_in,loc_dl,ldl,nsnd,nrcv,index_out,info)
endif
if(debug_level >= psb_debug_inner_) &
& write(debug_unit,*) me,' ',trim(name),': out of psi_desc_index',&
& size(index_out)
nxch = ldl
if(info /= psb_success_) then
call psb_errpush(psb_err_from_subroutine_,name,a_err='psi_desc_index')
goto 9999
end if
if (do_timings) call psb_toc(idx_phase3)
if (allocated(length_dl)) deallocate(length_dl,stat=info)
if (info /= 0) then
info = psb_err_alloc_dealloc_
goto 9999
end if
if(debug_level >= psb_debug_inner_) &
& write(debug_unit,*) me,' ',trim(name),': done'
call psb_erractionrestore(err_act)
return
9999 call psb_error_handler(ctxt,err_act)
return
contains
function choose_sorting(dlmax,dlavg,np) result(val)
implicit none
integer(psb_ipk_), intent(in) :: dlmax,dlavg,np
logical :: val
val = .not.(((dlmax>(26*4)).or.((dlavg>=(26*2)).and.(np>=128))))
val = (dlmax<16)
!val = .true.
val = .false.
end function choose_sorting
end subroutine psi_i_crea_index
| base/internals/psi_crea_index.f90 |
!########################################################################
!PURPOSE : Diagonalize the Effective Impurity Problem
!|{ImpUP1,...,ImpUPN},BathUP>|{ImpDW1,...,ImpDWN},BathDW>
!########################################################################
module ED_DIAG
USE SF_CONSTANTS
USE SF_LINALG, only: eigh
USE SF_TIMER, only: start_timer,stop_timer,eta
USE SF_IOTOOLS, only:reg,free_unit
!
USE ED_INPUT_VARS
USE ED_VARS_GLOBAL
USE ED_SETUP
USE ED_HAMILTONIAN
!
implicit none
private
public :: diagonalize_impurity
contains
!+-------------------------------------------------------------------+
!PURPOSE : diagonalize the Hamiltonian in each sector and find the
! spectrum DOUBLE COMPLEX
!+------------------------------------------------------------------+
subroutine diagonalize_impurity
integer :: nup,ndw,isector,dim
integer :: sz,nt
integer :: i,j,unit
real(8),dimension(Nsectors) :: e0
real(8) :: egs
logical :: Tflag
!
e0=1000.d0
write(LOGfile,"(A)")"Diagonalize impurity H:"
call start_timer()
!
!
sector: do isector=1,Nsectors
!
Dim = getdim(isector)
!
if(ed_verbose==3)then
nup = getnup(isector)
ndw = getndw(isector)
write(LOGfile,"(A,I4,A6,I2,A6,I2,A6,I15)")"Solving sector:",isector,", nup:",nup,", ndw:",ndw,", dim=",getdim(isector)
elseif(ed_verbose==1.OR.ed_verbose==2)then
call eta(isector,Nsectors,LOGfile)
endif
!
call setup_Hv_sector(isector)
call ed_buildH_c(espace(isector)%M)
call delete_Hv_sector()
call eigh(espace(isector)%M,espace(isector)%e,'V','U')
if(dim==1)espace(isector)%M=one
!
e0(isector)=minval(espace(isector)%e)
!
enddo sector
!
call stop_timer(LOGfile)
!
!Get the ground state energy and rescale energies
egs=minval(e0)
forall(isector=1:Nsectors)espace(isector)%e = espace(isector)%e - egs
!
!Get the partition function Z
zeta_function=0.d0;zeta_function=0.d0
do isector=1,Nsectors
dim=getdim(isector)
do i=1,dim
zeta_function=zeta_function+exp(-beta*espace(isector)%e(i))
enddo
enddo
!
write(LOGfile,"(A)")"DIAG resume:"
open(free_unit(unit),file='egs'//reg(ed_file_suffix)//".ed",position='append')
do isector=1,Nsectors
if(e0(isector)/=0d0)cycle
nup = getnup(isector)
ndw = getndw(isector)
write(LOGfile,"(A,F20.12,2I4)")'Egs =',e0(isector),nup,ndw
write(unit,"(F20.12,2I4)")e0(isector),nup,ndw
enddo
write(LOGfile,"(A,F20.12)")'Z =',zeta_function
close(unit)
return
end subroutine diagonalize_impurity
end MODULE ED_DIAG
| FED_DIAG.f90 |
# List HDL source code files in folder hdl/
<FPGA_TOP>.v
| templates/hdl.f |
C
C
C
SUBROUTINE COPYC
I (LEN, ZIP,
O X)
C
C + + + PURPOSE + + +
C Copy the character array ZIP of size LEN to
C the character array X of size LEN.
C
C + + + DUMMY ARGUMENTS + + +
INTEGER LEN
CHARACTER(1)ZIP(LEN),X(LEN)
C
C + + + ARGUMENT DEFINITIONS + + +
C LEN - size of character arrays
C ZIP - input character array
C X - output character array
C
C + + + END SPECIFICATIONS + + +
C
X = ZIP
C
RETURN
END
C
C
C
SUBROUTINE COPYD
I (LEN, ZIP,
O X)
C
C + + + PURPOSE + + +
C Copy the double precision array ZIP of size LEN
C to the double precision array X.
C
C + + + DUMMY ARGUMENTS + + +
INTEGER LEN
DOUBLE PRECISION ZIP(LEN), X(LEN)
C
C + + + ARGUMENT DEFINITIONS + + +
C LEN - size of arrays
C ZIP - input array of size LEN
C X - output array of size LEN
C
C + + + END SPECIFICATIONS + + +
C
X = ZIP
C
RETURN
END
C
C
C
SUBROUTINE COPYI
I (LEN, ZIP,
O X)
C
C + + + PURPOSE + + +
C Copy the integer array ZIP of size LEN to
C the integer array X.
C
C + + + DUMMY ARGUMENTS + + +
INTEGER LEN
INTEGER ZIP(LEN), X(LEN)
C
C + + + ARGUMENT DEFINITIONS + + +
C LEN - size of arrays
C ZIP - input array of size LEN
C X - output array of size LEN
C
C + + + END SPECIFICATIONS + + +
C
X = ZIP
C
RETURN
END
C
C
C
SUBROUTINE COPYR
I (LEN, ZIP,
O X)
C
C + + + PURPOSE + + +
C Copy the real array ZIP of size LEN to the
C real array X.
C
C + + + DUMMY ARGUMENTS + + +
INTEGER LEN
REAL ZIP(LEN), X(LEN)
C
C + + + ARGUMENT DEFINITIONS + + +
C LEN - size of arrays
C ZIP - input array of size LEN
C X - output array of size LEN
C
C + + + END SPECIFICATIONS + + +
C
X = ZIP
C
RETURN
END
C
C
C
SUBROUTINE ZIPC
I (LEN, ZIP,
O X)
C
C Fill the character array X of size LEN with
C the given value ZIP.
C
C + + + DUMMY ARGUMENTS + + +
INTEGER LEN
CHARACTER(1)ZIP,X(LEN)
C
C + + + ARGUMENT DEFINITIONS + + +
C LEN - size of character array
C ZIP - character to fill array
C X - character array to be filled
C
C + + + END SPECIFICATIONS + + +
C
X = ZIP
C
RETURN
END
C
C
C
SUBROUTINE ZIPD
I (LEN, ZIP,
O X)
C
C + + + PURPOSE + + +
C Fill the double precision array X of size LEN
C with the given value ZIP.
C
C + + + DUMMY ARGUMENTS + + +
INTEGER LEN
DOUBLE PRECISION ZIP, X(LEN)
C
C + + + ARGUMENT DEFINITIONS + + +
C LEN - size of array
C ZIP - value to fill array
C X - output array of size LEN
C
C + + + END SPECIFICATIONS + + +
C
X = ZIP
C
RETURN
END
C
C
C
SUBROUTINE ZIPI
I (LEN, ZIP,
O X)
C
C + + + PURPOSE + + +
C Fill the integer array X of size LEN with
C the given value ZIP.
C
C + + + DUMMY ARGUMENTS + + +
INTEGER LEN, ZIP
INTEGER X(LEN)
C
C + + + ARGUMENT DEFINITIONS + + +
C LEN - size of array
C ZIP - value to fill array
C X - output array of size LEN
C
C + + + END SPECIFICATIONS + + +
C
X = ZIP
C
RETURN
END
C
C
C
SUBROUTINE ZIPR
I (LEN, ZIP,
O X)
C
C + + + PURPOSE + + +
C Fill the real array X of size LEN with the
C given value ZIP.
C
C + + + DUMMY ARGUMENTS + + +
INTEGER LEN
REAL ZIP, X(LEN)
C
C + + + ARGUMENT DEFINITIONS + + +
C LEN - size of array
C ZIP - value to fill array
C X - output array of size LEN
C
C + + + END SPECIFICATIONS + + +
C
X = ZIP
C
RETURN
END
| wdm_support/UTCP90.f |
program demo_which
use M_io, only : which
implicit none
write(*,*)'ls is ',which('ls')
write(*,*)'dir is ',which('dir')
write(*,*)'install is ',which('install')
end program demo_which
| example/demo_which.f90 |
!--------------------------------------------------------------------------------
!M+
! NAME:
! netCDF_Variable_Utility
!
! PURPOSE:
! Module containing utility routines for netCDF file variable access.
!
! CATEGORY:
! netCDF
!
! LANGUAGE:
! Fortran-95
!
! CALLING SEQUENCE:
! USE netCDF_Variable_Utility
!
! MODULES:
! Type_Kinds: Module containing data type kind definitions.
!
! Message_Handler: Module to define error codes and handle error
! conditions
! USEs: FILE_UTILITY module
!
! netcdf: Module supplied with the Fortran 90 version of the
! netCDF libraries (at least v3.5.0).
! See http://www.unidata.ucar.edu/packages/netcdf
!
! CONTAINS:
! Get_netCDF_Variable: Function to retrieve a netCDF file variable
! by name. This function is simply a wrapper
! for some of the NetCDF library functions to
! simplify the retrieval of variable data with
! error checking.
!
! Put_netCDF_Variable: Function to write a netCDF file variable
! by name. This function is simply a wrapper
! for some of the NetCDF library functions to
! simplify the writing of variable data with
! error checking.
!
! EXTERNALS:
! None.
!
! COMMON BLOCKS:
! None.
!
! CREATION HISTORY:
! Written by: Paul van Delst, CIMSS/SSEC, 20-Nov-2000
! [email protected]
!
! Copyright (C) 2000, 2004 Paul van Delst
!
!M-
!--------------------------------------------------------------------------------
MODULE netCDF_Variable_Utility
! --------------------
! Declare modules used
! --------------------
USE Type_Kinds
USE Message_Handler
USE netcdf
! -----------------------
! Disable implicit typing
! -----------------------
IMPLICIT NONE
! ----------
! Visibility
! ----------
PRIVATE
PUBLIC :: Get_netCDF_Variable
PUBLIC :: Put_netCDF_Variable
! ---------------------
! Procedure overloading
! ---------------------
! -- Functions to get variable data
INTERFACE Get_netCDF_Variable
! -- Byte integer specific functions
MODULE PROCEDURE get_scalar_Byte
MODULE PROCEDURE get_rank1_Byte
MODULE PROCEDURE get_rank2_Byte
MODULE PROCEDURE get_rank3_Byte
MODULE PROCEDURE get_rank4_Byte
MODULE PROCEDURE get_rank5_Byte
MODULE PROCEDURE get_rank6_Byte
MODULE PROCEDURE get_rank7_Byte
! -- Short integer specific functions
MODULE PROCEDURE get_scalar_Short
MODULE PROCEDURE get_rank1_Short
MODULE PROCEDURE get_rank2_Short
MODULE PROCEDURE get_rank3_Short
MODULE PROCEDURE get_rank4_Short
MODULE PROCEDURE get_rank5_Short
MODULE PROCEDURE get_rank6_Short
MODULE PROCEDURE get_rank7_Short
! -- Long integer specific functions
MODULE PROCEDURE get_scalar_Long
MODULE PROCEDURE get_rank1_Long
MODULE PROCEDURE get_rank2_Long
MODULE PROCEDURE get_rank3_Long
MODULE PROCEDURE get_rank4_Long
MODULE PROCEDURE get_rank5_Long
MODULE PROCEDURE get_rank6_Long
MODULE PROCEDURE get_rank7_Long
! -- Single precision float specific functions
MODULE PROCEDURE get_scalar_Single
MODULE PROCEDURE get_rank1_Single
MODULE PROCEDURE get_rank2_Single
MODULE PROCEDURE get_rank3_Single
MODULE PROCEDURE get_rank4_Single
MODULE PROCEDURE get_rank5_Single
MODULE PROCEDURE get_rank6_Single
MODULE PROCEDURE get_rank7_Single
! -- Double precision float specific functions
MODULE PROCEDURE get_scalar_Double
MODULE PROCEDURE get_rank1_Double
MODULE PROCEDURE get_rank2_Double
MODULE PROCEDURE get_rank3_Double
MODULE PROCEDURE get_rank4_Double
MODULE PROCEDURE get_rank5_Double
MODULE PROCEDURE get_rank6_Double
MODULE PROCEDURE get_rank7_Double
! -- Character specific functions
MODULE PROCEDURE get_scalar_Character
MODULE PROCEDURE get_rank1_Character
MODULE PROCEDURE get_rank2_Character
MODULE PROCEDURE get_rank3_Character
MODULE PROCEDURE get_rank4_Character
MODULE PROCEDURE get_rank5_Character
MODULE PROCEDURE get_rank6_Character
MODULE PROCEDURE get_rank7_Character
END INTERFACE Get_netCDF_Variable
! -- Functions to put variable data
INTERFACE Put_netCDF_Variable
! -- Byte integer specific functions
MODULE PROCEDURE put_scalar_Byte
MODULE PROCEDURE put_rank1_Byte
MODULE PROCEDURE put_rank2_Byte
MODULE PROCEDURE put_rank3_Byte
MODULE PROCEDURE put_rank4_Byte
MODULE PROCEDURE put_rank5_Byte
MODULE PROCEDURE put_rank6_Byte
MODULE PROCEDURE put_rank7_Byte
! -- Short integer specific functions
MODULE PROCEDURE put_scalar_Short
MODULE PROCEDURE put_rank1_Short
MODULE PROCEDURE put_rank2_Short
MODULE PROCEDURE put_rank3_Short
MODULE PROCEDURE put_rank4_Short
MODULE PROCEDURE put_rank5_Short
MODULE PROCEDURE put_rank6_Short
MODULE PROCEDURE put_rank7_Short
! -- Long integer specific functions
MODULE PROCEDURE put_scalar_Long
MODULE PROCEDURE put_rank1_Long
MODULE PROCEDURE put_rank2_Long
MODULE PROCEDURE put_rank3_Long
MODULE PROCEDURE put_rank4_Long
MODULE PROCEDURE put_rank5_Long
MODULE PROCEDURE put_rank6_Long
MODULE PROCEDURE put_rank7_Long
! -- Single precision float specific functions
MODULE PROCEDURE put_scalar_Single
MODULE PROCEDURE put_rank1_Single
MODULE PROCEDURE put_rank2_Single
MODULE PROCEDURE put_rank3_Single
MODULE PROCEDURE put_rank4_Single
MODULE PROCEDURE put_rank5_Single
MODULE PROCEDURE put_rank6_Single
MODULE PROCEDURE put_rank7_Single
! -- Double precision float specific functions
MODULE PROCEDURE put_scalar_Double
MODULE PROCEDURE put_rank1_Double
MODULE PROCEDURE put_rank2_Double
MODULE PROCEDURE put_rank3_Double
MODULE PROCEDURE put_rank4_Double
MODULE PROCEDURE put_rank5_Double
MODULE PROCEDURE put_rank6_Double
MODULE PROCEDURE put_rank7_Double
! -- Character specific functions
MODULE PROCEDURE put_scalar_Character
MODULE PROCEDURE put_rank1_Character
MODULE PROCEDURE put_rank2_Character
MODULE PROCEDURE put_rank3_Character
MODULE PROCEDURE put_rank4_Character
MODULE PROCEDURE put_rank5_Character
MODULE PROCEDURE put_rank6_Character
MODULE PROCEDURE put_rank7_Character
END INTERFACE Put_netCDF_Variable
! -----------------
! Module parameters
! -----------------
! -- Module RCS Id string
CHARACTER( * ), PRIVATE, PARAMETER :: MODULE_RCS_ID = &
CONTAINS
FUNCTION get_scalar_Byte( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific output
INTEGER( Byte ), INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(scalar Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
START = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_scalar_Byte
FUNCTION get_scalar_Short( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific output
INTEGER( Short ), INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(scalar Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
START = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_scalar_Short
FUNCTION get_scalar_Long( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific output
INTEGER( Long ), INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(scalar Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
START = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_scalar_Long
FUNCTION get_scalar_Single( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific output
REAL( Single ), INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(scalar Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
START = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_scalar_Single
FUNCTION get_scalar_Double( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific output
REAL( Double ), INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(scalar Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
START = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_scalar_Double
FUNCTION get_scalar_CHARACTER( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific output
CHARACTER( * ), INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(scalar CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: DimID
CHARACTER( NF90_MAX_NAME ) :: DimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = DimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
DimID(1), &
Len = String_Length, &
Name = DimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( DimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Determine the maximum possible string length
String_Length = MIN( String_Length, LEN( Variable_Value ) )
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
! -- Clear the output variable string (to prevent
! -- possible random characters in unused portion)
Variable_Value = ' '
! -- Fill the variable
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value( 1:String_Length ), &
Start = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_scalar_CHARACTER
FUNCTION get_rank1_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Byte ), DIMENSION( : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank1 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank1_Byte
FUNCTION get_rank2_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Byte ), DIMENSION( :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank2 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank2_Byte
FUNCTION get_rank3_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Byte ), DIMENSION( :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank3 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank3_Byte
FUNCTION get_rank4_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Byte ), DIMENSION( :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank4 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank4_Byte
FUNCTION get_rank5_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Byte ), DIMENSION( :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank5 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank5_Byte
FUNCTION get_rank6_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Byte ), DIMENSION( :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank6 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank6_Byte
FUNCTION get_rank7_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Byte ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank7 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank7_Byte
FUNCTION get_rank1_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Short ), DIMENSION( : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank1 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank1_Short
FUNCTION get_rank2_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Short ), DIMENSION( :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank2 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank2_Short
FUNCTION get_rank3_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Short ), DIMENSION( :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank3 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank3_Short
FUNCTION get_rank4_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Short ), DIMENSION( :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank4 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank4_Short
FUNCTION get_rank5_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Short ), DIMENSION( :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank5 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank5_Short
FUNCTION get_rank6_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Short ), DIMENSION( :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank6 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank6_Short
FUNCTION get_rank7_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Short ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank7 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank7_Short
FUNCTION get_rank1_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Long ), DIMENSION( : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank1 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank1_Long
FUNCTION get_rank2_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Long ), DIMENSION( :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank2 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank2_Long
FUNCTION get_rank3_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Long ), DIMENSION( :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank3 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank3_Long
FUNCTION get_rank4_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Long ), DIMENSION( :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank4 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank4_Long
FUNCTION get_rank5_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Long ), DIMENSION( :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank5 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank5_Long
FUNCTION get_rank6_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Long ), DIMENSION( :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank6 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank6_Long
FUNCTION get_rank7_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
INTEGER( Long ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank7 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank7_Long
FUNCTION get_rank1_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Single ), DIMENSION( : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank1 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank1_Single
FUNCTION get_rank2_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Single ), DIMENSION( :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank2 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank2_Single
FUNCTION get_rank3_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Single ), DIMENSION( :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank3 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank3_Single
FUNCTION get_rank4_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Single ), DIMENSION( :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank4 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank4_Single
FUNCTION get_rank5_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Single ), DIMENSION( :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank5 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank5_Single
FUNCTION get_rank6_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Single ), DIMENSION( :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank6 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank6_Single
FUNCTION get_rank7_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Single ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank7 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank7_Single
FUNCTION get_rank1_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Double ), DIMENSION( : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank1 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank1_Double
FUNCTION get_rank2_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Double ), DIMENSION( :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank2 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank2_Double
FUNCTION get_rank3_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Double ), DIMENSION( :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank3 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank3_Double
FUNCTION get_rank4_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Double ), DIMENSION( :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank4 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank4_Double
FUNCTION get_rank5_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Double ), DIMENSION( :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank5 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank5_Double
FUNCTION get_rank6_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Double ), DIMENSION( :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank6 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank6_Double
FUNCTION get_rank7_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
REAL( Double ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank7 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -----------------------------
! Fill optional return argument
! -----------------------------
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL display_message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank7_Double
FUNCTION get_rank1_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
CHARACTER( * ), DIMENSION( : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank1 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
! -- Clear the output variable string array (to prevent
! -- possible random characters in unused portion)
Variable_Value = ' '
! -- Fill the variable
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank1_CHARACTER
FUNCTION get_rank2_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
CHARACTER( * ), DIMENSION( :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank2 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
! -- Clear the output variable string array (to prevent
! -- possible random characters in unused portion)
Variable_Value = ' '
! -- Fill the variable
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank2_CHARACTER
FUNCTION get_rank3_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
CHARACTER( * ), DIMENSION( :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank3 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
! -- Clear the output variable string array (to prevent
! -- possible random characters in unused portion)
Variable_Value = ' '
! -- Fill the variable
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank3_CHARACTER
FUNCTION get_rank4_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
CHARACTER( * ), DIMENSION( :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank4 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
! -- Clear the output variable string array (to prevent
! -- possible random characters in unused portion)
Variable_Value = ' '
! -- Fill the variable
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank4_CHARACTER
FUNCTION get_rank5_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
CHARACTER( * ), DIMENSION( :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank5 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
! -- Clear the output variable string array (to prevent
! -- possible random characters in unused portion)
Variable_Value = ' '
! -- Fill the variable
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank5_CHARACTER
FUNCTION get_rank6_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
CHARACTER( * ), DIMENSION( :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank6 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
! -- Clear the output variable string array (to prevent
! -- possible random characters in unused portion)
Variable_Value = ' '
! -- Fill the variable
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank6_CHARACTER
FUNCTION get_rank7_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Output
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific output
CHARACTER( * ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( OUT ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Get_netCDF_Variable(rank7 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
! -- Clear the output variable string array (to prevent
! -- possible random characters in unused portion)
Variable_Value = ' '
! -- Fill the variable
NF90_Status = NF90_GET_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error reading variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION get_rank7_CHARACTER
FUNCTION put_scalar_Byte( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific input
INTEGER( Byte ), INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(scalar Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_scalar_Byte
FUNCTION put_scalar_Short( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific input
INTEGER( Short ), INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(scalar Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_scalar_Short
FUNCTION put_scalar_Long( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific input
INTEGER( Long ), INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(scalar Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_scalar_Long
FUNCTION put_scalar_Single( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific input
REAL( Single ), INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(scalar Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_scalar_Single
FUNCTION put_scalar_Double( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific input
REAL( Double ), INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(scalar Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_scalar_Double
FUNCTION put_scalar_CHARACTER( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type specific input
CHARACTER( * ), INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(scalar CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: DimID
CHARACTER( NF90_MAX_NAME ) :: DimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = DimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
DimID(1), &
Len = String_Length, &
Name = DimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( DimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Determine the maximum possible string length
String_Length = MIN( String_Length, LEN( Variable_Value ) )
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value( 1:String_Length ), &
Start = Start )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_scalar_CHARACTER
FUNCTION put_rank1_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Byte ), DIMENSION( : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank1 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank1_Byte
FUNCTION put_rank2_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Byte ), DIMENSION( :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank2 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank2_Byte
FUNCTION put_rank3_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Byte ), DIMENSION( :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank3 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank3_Byte
FUNCTION put_rank4_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Byte ), DIMENSION( :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank4 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank4_Byte
FUNCTION put_rank5_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Byte ), DIMENSION( :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank5 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank5_Byte
FUNCTION put_rank6_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Byte ), DIMENSION( :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank6 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank6_Byte
FUNCTION put_rank7_Byte ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Byte ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank7 Byte)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank7_Byte
FUNCTION put_rank1_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Short ), DIMENSION( : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank1 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank1_Short
FUNCTION put_rank2_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Short ), DIMENSION( :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank2 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank2_Short
FUNCTION put_rank3_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Short ), DIMENSION( :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank3 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank3_Short
FUNCTION put_rank4_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Short ), DIMENSION( :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank4 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank4_Short
FUNCTION put_rank5_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Short ), DIMENSION( :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank5 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank5_Short
FUNCTION put_rank6_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Short ), DIMENSION( :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank6 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank6_Short
FUNCTION put_rank7_Short ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Short ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank7 Short)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank7_Short
FUNCTION put_rank1_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Long ), DIMENSION( : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank1 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank1_Long
FUNCTION put_rank2_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Long ), DIMENSION( :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank2 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank2_Long
FUNCTION put_rank3_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Long ), DIMENSION( :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank3 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank3_Long
FUNCTION put_rank4_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Long ), DIMENSION( :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank4 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank4_Long
FUNCTION put_rank5_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Long ), DIMENSION( :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank5 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank5_Long
FUNCTION put_rank6_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Long ), DIMENSION( :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank6 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank6_Long
FUNCTION put_rank7_Long ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
INTEGER( Long ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank7 Long)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank7_Long
FUNCTION put_rank1_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Single ), DIMENSION( : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank1 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank1_Single
FUNCTION put_rank2_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Single ), DIMENSION( :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank2 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank2_Single
FUNCTION put_rank3_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Single ), DIMENSION( :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank3 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank3_Single
FUNCTION put_rank4_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Single ), DIMENSION( :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank4 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank4_Single
FUNCTION put_rank5_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Single ), DIMENSION( :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank5 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank5_Single
FUNCTION put_rank6_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Single ), DIMENSION( :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank6 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank6_Single
FUNCTION put_rank7_Single ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Single ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank7 Single)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank7_Single
FUNCTION put_rank1_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Double ), DIMENSION( : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank1 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank1_Double
FUNCTION put_rank2_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Double ), DIMENSION( :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank2 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank2_Double
FUNCTION put_rank3_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Double ), DIMENSION( :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank3 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank3_Double
FUNCTION put_rank4_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Double ), DIMENSION( :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank4 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank4_Double
FUNCTION put_rank5_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Double ), DIMENSION( :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank5 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank5_Double
FUNCTION put_rank6_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Double ), DIMENSION( :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank6 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank6_Double
FUNCTION put_rank7_Double ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
REAL( Double ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank7 Double)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank7_Double
FUNCTION put_rank1_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
CHARACTER( * ), DIMENSION( : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank1 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank1_CHARACTER
FUNCTION put_rank2_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
CHARACTER( * ), DIMENSION( :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank2 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank2_CHARACTER
FUNCTION put_rank3_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
CHARACTER( * ), DIMENSION( :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank3 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank3_CHARACTER
FUNCTION put_rank4_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
CHARACTER( * ), DIMENSION( :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank4 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank4_CHARACTER
FUNCTION put_rank5_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
CHARACTER( * ), DIMENSION( :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank5 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank5_CHARACTER
FUNCTION put_rank6_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
CHARACTER( * ), DIMENSION( :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank6 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank6_CHARACTER
FUNCTION put_rank7_CHARACTER ( &
NC_FileID, & ! Input
Variable_Name, & ! Input
Variable_Value, & ! Input
Start, & ! Optional input
Count, & ! Optional input
Stride, & ! Optional input
Map, & ! Optional input
Variable_ID, & ! Optional output
Message_Log ) & ! Error messaging
RESULT ( Error_Status )
!#--------------------------------------------------------------------------#
!# -- TYPE DECLARATIONS -- #
!#--------------------------------------------------------------------------#
! ---------
! Arguments
! ---------
! -- Input
INTEGER, INTENT( IN ) :: NC_FileID
CHARACTER( * ), INTENT( IN ) :: Variable_Name
! -- Type and rank specific input
CHARACTER( * ), DIMENSION( :, :, :, :, :, :, : ), &
INTENT( IN ) :: Variable_Value
! -- Optional input
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Start
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Count
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Stride
INTEGER, DIMENSION( : ), OPTIONAL, INTENT( IN ) :: Map
! -- Optional output
INTEGER, OPTIONAL, INTENT( OUT ) :: Variable_ID
! -- Error messaging
CHARACTER( * ), OPTIONAL, INTENT( IN ) :: Message_Log
! ---------------
! Function result
! ---------------
INTEGER :: Error_Status
! ----------------
! Local parameters
! ----------------
CHARACTER( * ), PARAMETER :: ROUTINE_NAME = 'Put_netCDF_Variable(rank7 CHARACTER)'
! ---------------
! Local variables
! ---------------
INTEGER :: NF90_Status
INTEGER :: varID
INTEGER, DIMENSION( NF90_MAX_VAR_DIMS ) :: dimID
CHARACTER( NF90_MAX_NAME ) :: dimNAME
INTEGER :: String_Length
!#--------------------------------------------------------------------------#
!# -- ASSIGN A SUCCESSFUL RETURN STATUS -- #
!#--------------------------------------------------------------------------#
Error_Status = SUCCESS
!#--------------------------------------------------------------------------#
!# -- GET THE VARIABLE ID -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_INQ_VARID( NC_FileID, &
TRIM( Variable_Name ), &
varID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable ID for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
IF ( PRESENT( Variable_ID ) ) Variable_ID = varID
!#--------------------------------------------------------------------------#
!# -- DETERMINE THE STRING LENGTH -- #
!#--------------------------------------------------------------------------#
! -- Get the dimension IDs
NF90_Status = NF90_INQUIRE_VARIABLE( NC_FileID, &
varID, &
DimIDs = dimID )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Get the first dimension value.
! -- This is the string length.
NF90_Status = NF90_INQUIRE_DIMENSION( NC_FileID, &
dimID(1), &
Len = String_Length, &
Name = dimNAME )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error inquiring variable '// &
TRIM( Variable_Name )//' dimension '// &
TRIM( dimNAME )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
! -- Make sure they match
IF ( String_Length /= LEN( Variable_Value ) ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Input '// &
TRIM( Variable_Name )// &
' string length different from netCDF dataset.', &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
!#--------------------------------------------------------------------------#
!# -- PUT THE VARIABLE VALUE -- #
!#--------------------------------------------------------------------------#
NF90_Status = NF90_PUT_VAR( NC_FileID, &
varID, &
Variable_Value, &
Start = Start, &
Count = Count, &
Stride = Stride, &
Map = Map )
IF ( NF90_Status /= NF90_NOERR ) THEN
Error_Status = FAILURE
CALL Display_Message( ROUTINE_NAME, &
'Error writing variable value for '// &
TRIM( Variable_Name )// &
' - '// &
TRIM( NF90_STRERROR( NF90_Status ) ), &
Error_Status, &
Message_Log = Message_Log )
RETURN
END IF
END FUNCTION put_rank7_CHARACTER
END MODULE netCDF_Variable_Utility
!-------------------------------------------------------------------------------
! -- MODIFICATION HISTORY --
!-------------------------------------------------------------------------------
!
!
! $Date: 2006/07/26 21:39:05 $
!
! $Revision: 1.2 $
!
! $Name: $
!
! $State: Exp $
!
! $Log: netCDF_Variable_Utility.f90,v $
! Revision 1.2 2006/07/26 21:39:05 wd20pd
! Additional replacement of "Error_Handler" string with "Message_Handler"
! in documentaiton blocks.
!
! Revision 1.1 2006/06/08 21:47:55 wd20pd
! Initial checkin.
!
! Revision 1.9 2006/05/02 16:58:03 dgroff
! *** empty log message ***
!
! Revision 1.8 2005/01/11 18:49:42 paulv
! - Regenerated from updated pp files.
!
! Revision 1.6 2003/05/16 15:28:19 paulv
! - Added correct dimension indices for Variable_Value test in the
! character Get() and Put() functions.
!
! Revision 1.5 2003/02/28 22:13:37 paulv
! - Completed addition of character typed functions for netCDF variable
! extraction. Partially tested.
!
! Revision 1.4 2003/02/19 13:34:10 paulv
! - Added functions to allow character variable scalar and array data to
! be retrieved from a netCDF dataset.
!
! Revision 1.3 2002/12/23 21:16:13 paulv
! - Added Put_netCDF_Variable() functions.
!
! Revision 1.2 2002/05/20 17:59:01 paulv
! - Updated header documentation.
!
! Revision 1.1 2002/05/20 17:03:57 paulv
! Initial checkin. Routines not yet tested.
!
!
!
!
| src/Utility/netCDF/netCDF_Variable_Utility.f90 |
C***********************************************************************
C Module: asetup.f
C
C Copyright (C) 2002 Mark Drela, Harold Youngren
C
C This program is free software; you can redistribute it and/or modify
C it under the terms of the GNU General Public License as published by
C the Free Software Foundation; either version 2 of the License, or
C (at your option) any later version.
C
C This program is distributed in the hope that it will be useful,
C but WITHOUT ANY WARRANTY; without even the implied warranty of
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C GNU General Public License for more details.
C
C You should have received a copy of the GNU General Public License
C along with this program; if not, write to the Free Software
C Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
C***********************************************************************
SUBROUTINE SETUP
C
C...PURPOSE To set up the vortex lattice calculation.
C
C Additional geometry data is calculated.
C An AIC matrix is assembled and solutions
C obtained for 0 deg and 90 deg angle of attack
C (for later superposition in AERO). The matrix
C defining normalwash at the bound vortex midpoints
C is calculated. This is used to define the bound vortex
C normalwash for 0 and 90 deg angles of attack (used
C for superposition in AERO).
C
C...INPUT Global Data in labelled commons, defining configuration
C
C...OUTPUT GAM(i,1..3) Vortex strengths for unit VINF1,2,3
C GAM(i,4..6) Vortex strengths for unit WROT1,2,3
C W Normalwash at vortex midpoints for GAM
C
C...COMMENTS
C
INCLUDE 'AVL.INC'
REAL WORK(NVMAX)
C
AMACH = MACH
BETM = SQRT(1.0 - AMACH**2)
C
C
IF(.NOT.LAIC) THEN
WRITE(*,*) ' Building normalwash AIC matrix...'
CALL VVOR(BETM,IYSYM,YSYM,IZSYM,ZSYM,VRCORE,
& NVOR,RV1,RV2,NSURFV,CHORDV,
& NVOR,RC , NSURFV,.FALSE.,
& WC_GAM,NVMAX)
DO I = 1, NVOR
DO J = 1, NVOR
AICN(I,J) = WC_GAM(1,I,J)*ENC(1,I)
& + WC_GAM(2,I,J)*ENC(2,I)
& + WC_GAM(3,I,J)*ENC(3,I)
LVNC(I) = .TRUE.
ccc write(*,*) i, j, aicn(i,j) !@@@
ENDDO
ENDDO
C----- process each surface which does not shed a wake
DO 10 N = 1, NSURF
IF(LFWAKE(N)) GO TO 10
C------- go over TE control points on this surface
J1 = JFRST(N)
JN = JFRST(N) + NJ(N)-1
C
DO J = J1, JN
I1 = IJFRST(J)
IV = IJFRST(J) + NVSTRP(J) - 1
C--------- clear system row for TE control point
DO JV = 1, NVOR
AICN(IV,JV) = 0.
ENDDO
LVNC(IV) = .FALSE.
C--------- set sum_strip(Gamma) = 0 for this strip
DO JV = I1, IV
AICN(IV,JV) = 1.0
ENDDO
ENDDO
10 CONTINUE
C
CC...Holdover from HPV hydro project for forces near free surface
CC...Eliminates excluded vortices from eqns which are below z=Zsym
C CALL MUNGEA
C
WRITE(*,*) ' Factoring normalwash AIC matrix...'
CALL LUDCMP(NVMAX,NVOR,AICN,IAPIV,WORK)
C
LAIC = .TRUE.
ENDIF
C
C
IF(.NOT.LSRD) THEN
WRITE(*,*) ' Building source+doublet strength AIC matrix...'
CALL SRDSET(BETM,XYZREF,
& NBODY,LFRST,NLMAX,
& NL,RL,RADL,
& SRC_U,DBL_U)
WRITE(*,*) ' Building source+doublet velocity AIC matrix...'
NU = 6
CALL VSRD(BETM,IYSYM,YSYM,IZSYM,ZSYM,SRCORE,
& NBODY,LFRST,NLMAX,
& NL,RL,RADL,
& NU,SRC_U,DBL_U,
& NVOR,RC,
& WCSRD_U,NVMAX)
LSRD = .TRUE.
ENDIF
C
IF(.NOT.LVEL) THEN
WRITE(*,*) ' Building bound-vortex velocity matrix...'
CALL VVOR(BETM,IYSYM,YSYM,IZSYM,ZSYM,VRCORE,
& NVOR,RV1,RV2,NSURFV,CHORDV,
& NVOR,RV , NSURFV,.TRUE.,
& WV_GAM,NVMAX)
C
NU = 6
CALL VSRD(BETM,IYSYM,YSYM,IZSYM,ZSYM,SRCORE,
& NBODY,LFRST,NLMAX,
& NL,RL,RADL,
& NU,SRC_U,DBL_U,
& NVOR,RV ,
& WVSRD_U,NVMAX)
C
LVEL = .TRUE.
ENDIF
C
RETURN
END ! SETUP
SUBROUTINE GUCALC
INCLUDE 'AVL.INC'
REAL RROT(3), VUNIT(3), WUNIT(3)
C
C---- setup BC's at control points for unit freestream,rotation vectors,
C and back-substitute to obtain corresponding vortex circulations
C
C---- go over freestream velocity components u,v,w = f(V,beta,alpha)
DO 10 IU = 1, 3
C------ go over all control points
DO I = 1, NVOR
IF(LVNC(I)) THEN
C--------- this c.p. has V.n equation...
VUNIT(1) = 0.
VUNIT(2) = 0.
VUNIT(3) = 0.
IF(LVALBE(I)) THEN
C---------- direct freestream influence is enabled for this c.p.
VUNIT(IU) = VUNIT(IU) + 1.0
ENDIF
C--------- always add on indirect freestream influence via BODY sources and doublets
VUNIT(1) = VUNIT(1) + WCSRD_U(1,I,IU)
VUNIT(2) = VUNIT(2) + WCSRD_U(2,I,IU)
VUNIT(3) = VUNIT(3) + WCSRD_U(3,I,IU)
C--------- set r.h.s. for V.n equation
GAM_U_0(I,IU) = -DOT(ENC(1,I),VUNIT)
DO N = 1, NCONTROL
GAM_U_D(I,IU,N) = -DOT(ENC_D(1,I,N),VUNIT)
ENDDO
DO N = 1, NDESIGN
GAM_U_G(I,IU,N) = -DOT(ENC_G(1,I,N),VUNIT)
ENDDO
ELSE
C--------- just clear r.h.s.
GAM_U_0(I,IU) = 0.
DO N = 1, NCONTROL
GAM_U_D(I,IU,N) = 0.
ENDDO
DO N = 1, NDESIGN
GAM_U_G(I,IU,N) = 0.
ENDDO
ENDIF
ENDDO
CALL BAKSUB(NVMAX,NVOR,AICN,IAPIV,GAM_U_0(1,IU))
DO N = 1, NCONTROL
CALL BAKSUB(NVMAX,NVOR,AICN,IAPIV,GAM_U_D(1,IU,N))
ENDDO
DO N = 1, NDESIGN
CALL BAKSUB(NVMAX,NVOR,AICN,IAPIV,GAM_U_G(1,IU,N))
ENDDO
10 CONTINUE
C
C---- go over freestream rotation components p,q,r
DO 20 IU = 4, 6
C------ go over all control points
DO I = 1, NVOR
IF(LVNC(I)) THEN
C--------- this c.p. has V.n equation
WUNIT(1) = 0.
WUNIT(2) = 0.
WUNIT(3) = 0.
IF(LVALBE(I)) THEN
C---------- direct freestream influence is enabled for this c.p.
WUNIT(IU-3) = WUNIT(IU-3) + 1.0
ENDIF
RROT(1) = RC(1,I) - XYZREF(1)
RROT(2) = RC(2,I) - XYZREF(2)
RROT(3) = RC(3,I) - XYZREF(3)
CALL CROSS(RROT,WUNIT,VUNIT)
C--------- always add on indirect freestream influence via BODY sources and doublets
VUNIT(1) = VUNIT(1) + WCSRD_U(1,I,IU)
VUNIT(2) = VUNIT(2) + WCSRD_U(2,I,IU)
VUNIT(3) = VUNIT(3) + WCSRD_U(3,I,IU)
C--------- set r.h.s. for V.n equation
GAM_U_0(I,IU) = -DOT(ENC(1,I),VUNIT)
DO N = 1, NCONTROL
GAM_U_D(I,IU,N) = -DOT(ENC_D(1,I,N),VUNIT)
ENDDO
DO N = 1, NDESIGN
GAM_U_G(I,IU,N) = -DOT(ENC_G(1,I,N),VUNIT)
ENDDO
ELSE
C--------- just clear r.h.s.
GAM_U_0(I,IU) = 0.
DO N = 1, NCONTROL
GAM_U_D(I,IU,N) = 0.
ENDDO
DO N = 1, NDESIGN
GAM_U_G(I,IU,N) = 0.
ENDDO
ENDIF
ENDDO
CALL BAKSUB(NVMAX,NVOR,AICN,IAPIV,GAM_U_0(1,IU))
DO N = 1, NCONTROL
CALL BAKSUB(NVMAX,NVOR,AICN,IAPIV,GAM_U_D(1,IU,N))
ENDDO
DO N = 1, NDESIGN
CALL BAKSUB(NVMAX,NVOR,AICN,IAPIV,GAM_U_G(1,IU,N))
ENDDO
20 CONTINUE
C
RETURN
END ! GUCALC
SUBROUTINE GDCALC(NQDEF,LQDEF,ENC_Q,GAM_Q)
INCLUDE 'AVL.INC'
LOGICAL LQDEF(*)
REAL ENC_Q(3,NVMAX,*), GAM_Q(NVMAX,*)
C
C
REAL RROT(3), VROT(3), VC(3)
C
IF(NQDEF.EQ.0) RETURN
C
C---- Setup variational BC's at the control points
DO 100 IQ = 1, NQDEF
C------ don't bother if this control variable is undefined
IF(.NOT.LQDEF(IQ)) GO TO 100
C
DO I = 1, NVOR
IF(LVNC(I)) THEN
IF(LVALBE(I)) THEN
RROT(1) = RC(1,I) - XYZREF(1)
RROT(2) = RC(2,I) - XYZREF(2)
RROT(3) = RC(3,I) - XYZREF(3)
CALL CROSS(RROT,WROT,VROT)
DO K = 1, 3
VC(K) = VINF(K)
& + VROT(K)
ENDDO
ELSE
VC(1) = 0.
VC(2) = 0.
VC(3) = 0.
ENDIF
DO K = 1, 3
VC(K) = VC(K)
& + WCSRD_U(K,I,1)*VINF(1)
& + WCSRD_U(K,I,2)*VINF(2)
& + WCSRD_U(K,I,3)*VINF(3)
& + WCSRD_U(K,I,4)*WROT(1)
& + WCSRD_U(K,I,5)*WROT(2)
& + WCSRD_U(K,I,6)*WROT(3)
ENDDO
C
GAM_Q(I,IQ) = -DOT(ENC_Q(1,I,IQ),VC)
ELSE
GAM_Q(I,IQ) = 0.
ENDIF
ENDDO
C********************************************************************
C...Holdover from HPV hydro project for forces near free surface
C...Eliminates excluded vortex equations for strips with z<Zsym
ccc CALL MUNGEB(GAM_Q(1,IQ))
C********************************************************************
C
CALL BAKSUB(NVMAX,NVOR,AICN,IAPIV,GAM_Q(1,IQ))
100 CONTINUE
C
RETURN
END ! GDCALC
SUBROUTINE MUNGEA
C
C...PURPOSE To remove hidden vortex equations in AIC matrix
C
C...OUTPUT A(.,.) AIC matrix with affected rows replaced with 1 on diagonal
C
C
INCLUDE 'AVL.INC'
C
DO 30 J = 1, NSTRIP
IF (.NOT. LSTRIPOFF(J)) GO TO 30
I1 = IJFRST(J)
DO 20 K = 1, NVSTRP(J)
II = I1+K-1
DO 10 I = 1, NVOR
AICN(II,I) = 0.0
10 CONTINUE
AICN(II,II) = 1.0
20 CONTINUE
30 CONTINUE
C
RETURN
END
SUBROUTINE MUNGEB(B)
C
C...PURPOSE To remove hidden vortex equations in RHS's
C
C...OUTPUT B(.) RHS vector with affected rows replaced with 0
C
INCLUDE 'AVL.INC'
REAL B(NVMAX)
C
DO 30 J = 1, NSTRIP
IF (.NOT. LSTRIPOFF(J)) GO TO 30
I1 = IJFRST(J)
DO 20 K = 1, NVSTRP(J)
II = I1+K-1
B(II) = 0.
20 CONTINUE
30 CONTINUE
C
RETURN
END
SUBROUTINE GAMSUM
INCLUDE 'AVL.INC'
C--------------------------------------------------
C Sums AIC components to get GAM, SRC, DBL
C--------------------------------------------------
C
C---- Set vortex strengths
DO I = 1, NVOR
DO IU = 1, 6
GAM_U(I,IU) = GAM_U_0(I,IU)
DO N = 1, NCONTROL
GAM_U(I,IU) = GAM_U(I,IU) + GAM_U_D(I,IU,N)*DELCON(N)
ENDDO
DO N = 1, NDESIGN
GAM_U(I,IU) = GAM_U(I,IU) + GAM_U_G(I,IU,N)*DELDES(N)
ENDDO
ENDDO
DO N = 1, NCONTROL
GAM_D(I,N) = GAM_U_D(I,1,N)*VINF(1)
& + GAM_U_D(I,2,N)*VINF(2)
& + GAM_U_D(I,3,N)*VINF(3)
& + GAM_U_D(I,4,N)*WROT(1)
& + GAM_U_D(I,5,N)*WROT(2)
& + GAM_U_D(I,6,N)*WROT(3)
ENDDO
DO N = 1, NDESIGN
GAM_G(I,N) = GAM_U_G(I,1,N)*VINF(1)
& + GAM_U_G(I,2,N)*VINF(2)
& + GAM_U_G(I,3,N)*VINF(3)
& + GAM_U_G(I,4,N)*WROT(1)
& + GAM_U_G(I,5,N)*WROT(2)
& + GAM_U_G(I,6,N)*WROT(3)
ENDDO
GAM(I) = GAM_U(I,1)*VINF(1)
& + GAM_U(I,2)*VINF(2)
& + GAM_U(I,3)*VINF(3)
& + GAM_U(I,4)*WROT(1)
& + GAM_U(I,5)*WROT(2)
& + GAM_U(I,6)*WROT(3)
c DO N = 1, NCONTROL
c GAM(I) = GAM(I) + GAM_D(I,N)*DELCON(N)
c ENDDO
c DO N = 1, NDESIGN
c GAM(I) = GAM(I) + GAM_G(I,N)*DELDES(N)
c ENDDO
END DO
C
C---- Set source and doublet strengths
DO L = 1, NLNODE
SRC(L) = SRC_U(L,1)*VINF(1)
& + SRC_U(L,2)*VINF(2)
& + SRC_U(L,3)*VINF(3)
& + SRC_U(L,4)*WROT(1)
& + SRC_U(L,5)*WROT(2)
& + SRC_U(L,6)*WROT(3)
DO K = 1, 3
DBL(K,L) = DBL_U(K,L,1)*VINF(1)
& + DBL_U(K,L,2)*VINF(2)
& + DBL_U(K,L,3)*VINF(3)
& + DBL_U(K,L,4)*WROT(1)
& + DBL_U(K,L,5)*WROT(2)
& + DBL_U(K,L,6)*WROT(3)
ENDDO
ENDDO
C
RETURN
END ! GAMSUM
SUBROUTINE VELSUM
INCLUDE 'AVL.INC'
C--------------------------------------------------
C Sums AIC components to get WC, WV
C--------------------------------------------------
C
DO I = 1, NVOR
DO K = 1, 3
WC(K,I) = WCSRD_U(K,I,1)*VINF(1)
& + WCSRD_U(K,I,2)*VINF(2)
& + WCSRD_U(K,I,3)*VINF(3)
& + WCSRD_U(K,I,4)*WROT(1)
& + WCSRD_U(K,I,5)*WROT(2)
& + WCSRD_U(K,I,6)*WROT(3)
WV(K,I) = WVSRD_U(K,I,1)*VINF(1)
& + WVSRD_U(K,I,2)*VINF(2)
& + WVSRD_U(K,I,3)*VINF(3)
& + WVSRD_U(K,I,4)*WROT(1)
& + WVSRD_U(K,I,5)*WROT(2)
& + WVSRD_U(K,I,6)*WROT(3)
DO J = 1, NVOR
WC(K,I) = WC(K,I) + WC_GAM(K,I,J)*GAM(J)
WV(K,I) = WV(K,I) + WV_GAM(K,I,J)*GAM(J)
ENDDO
C
DO N = 1, NUMAX
WC_U(K,I,N) = WCSRD_U(K,I,N)
WV_U(K,I,N) = WVSRD_U(K,I,N)
DO J = 1, NVOR
WC_U(K,I,N) = WC_U(K,I,N) + WC_GAM(K,I,J)*GAM_U(J,N)
WV_U(K,I,N) = WV_U(K,I,N) + WV_GAM(K,I,J)*GAM_U(J,N)
ENDDO
ENDDO
C
ENDDO
ENDDO
C
RETURN
END ! VELSUM
SUBROUTINE WSENS
INCLUDE 'AVL.INC'
C---------------------------------------------------
C Computes induced-velocity sensitivities
C to control and design changes
C---------------------------------------------------
C
DO I = 1, NVOR
DO K = 1, 3
DO N = 1, NCONTROL
WC_D(K,I,N) = 0.
WV_D(K,I,N) = 0.
DO J = 1, NVOR
WC_D(K,I,N) = WC_D(K,I,N) + WC_GAM(K,I,J)*GAM_D(J,N)
WV_D(K,I,N) = WV_D(K,I,N) + WV_GAM(K,I,J)*GAM_D(J,N)
ENDDO
ENDDO
C
DO N = 1, NDESIGN
WC_G(K,I,N) = 0.
WV_G(K,I,N) = 0.
DO J = 1, NVOR
WC_G(K,I,N) = WC_G(K,I,N) + WC_GAM(K,I,J)*GAM_G(J,N)
WV_G(K,I,N) = WV_G(K,I,N) + WV_GAM(K,I,J)*GAM_G(J,N)
ENDDO
ENDDO
ENDDO
ENDDO
C
RETURN
END ! WSENS
| third_party/avl/src/asetup.f |
PROGRAM test_message
use mpi
use ghex_mod
use ghex_message_mod
implicit none
integer(8) :: msg_size = 16, i
type(ghex_message) :: msg
integer(1), dimension(:), pointer :: msg_data
msg = ghex_message_new(msg_size, GhexAllocatorHost)
msg_data => ghex_message_data(msg)
msg_data(1:msg_size) = (/(i, i=1,msg_size,1)/)
print *, "values: ", msg_data
! cleanup
call ghex_free(msg)
END PROGRAM test_message
| tests/bindings/test_f_message.f90 |
MODULE bc_module
use rgrid_module, only: Ngrid,Igrid
use parallel_module
use bc_mol_module, only: init_bcset_mol
use bc_variables, only: fdinfo_send,fdinfo_recv,n_neighbor,www,Md &
,sbuf,rbuf,TYPE_MAIN,zero
use watch_module
use bcset_1_module, only: bcset_1
use bcset_3_module, only: bcset_3
implicit none
PRIVATE
PUBLIC :: init_bcset
PUBLIC :: bcset
PUBLIC :: bcset_1
PUBLIC :: bcset_3
PUBLIC :: n_neighbor, fdinfo_send, fdinfo_recv
PUBLIC :: www
CONTAINS
SUBROUTINE bcset(ib1,ib2,ndepth,idir)
implicit none
integer,intent(IN) :: ib1,ib2,ndepth,idir
integer :: a1,a2,a3,b1,b2,b3,nb,ns,ms,mt
integer :: m,n,ndata,i1,i2,i3,ib,ierr
integer :: c1,c2,c3,d1,d2,d3,irank,nreq,itags,itagr,ireq(36)
integer :: i,j,l
integer :: istatus(mpi_status_size,123)
a1=Igrid(1,1)
b1=Igrid(2,1)
a2=Igrid(1,2)
b2=Igrid(2,2)
a3=Igrid(1,3)
b3=Igrid(2,3)
nb=ib2-ib1+1
nreq=0
!(1) [sender][2]-->[1][receiver]
if ( idir==0 .or. idir==1 .or. idir==2 ) then
do n=1,n_neighbor(1)
if ( ndepth==1 ) then
ndata = fdinfo_recv(10,n,1)*nb
else
ndata = fdinfo_recv(9,n,1)*nb
end if
if ( ndata<1 ) cycle
irank = fdinfo_recv(8,n,1)
itagr = 10
nreq = nreq + 1
call mpi_irecv(rbuf(1,n,1),ndata,TYPE_MAIN,irank,itagr &
,comm_grid,ireq(nreq),ierr)
end do
do n=1,n_neighbor(2)
if ( ndepth==1 ) then
c1=b1
d1=b1
j=fdinfo_send(10,n,2)*nb
else
c1=fdinfo_send(1,n,2)
d1=fdinfo_send(2,n,2)
j=fdinfo_send(9,n,2)*nb
end if
c2=fdinfo_send(3,n,2) ; d2=fdinfo_send(4,n,2)
c3=fdinfo_send(5,n,2) ; d3=fdinfo_send(6,n,2)
if ( j<1 ) cycle
ndata=0
do ib=ib1,ib2
do i3=c3,d3
do i2=c2,d2
do i1=c1,d1
ndata=ndata+1
sbuf(ndata,n,2)=www(i1,i2,i3,ib)
end do
end do
end do
end do
if ( ndata/=j ) stop
irank = fdinfo_send(7,n,2)
itags = 10
nreq = nreq + 1
call mpi_isend(sbuf(1,n,2),ndata,TYPE_MAIN,irank,itags &
,comm_grid,ireq(nreq),ierr)
end do
end if
! call mpi_waitall(nreq,ireq,istatus,ierr) ; nreq=0
!(3) [sender][4]-->[3][receiver]
if ( idir==0 .or. idir==3 .or. idir==4 ) then
do n=1,n_neighbor(3)
if ( ndepth==1 ) then
ndata = fdinfo_recv(10,n,3)*nb
else
ndata = fdinfo_recv(9,n,3)*nb
end if
if ( ndata<1 ) cycle
irank = fdinfo_recv(8,n,3)
itagr = 30
nreq = nreq + 1
call mpi_irecv(rbuf(1,n,3),ndata,TYPE_MAIN,irank,itagr &
,comm_grid,ireq(nreq),ierr)
end do
do n=1,n_neighbor(4)
if ( ndepth==1 ) then
c2=b2
d2=b2
j=fdinfo_send(10,n,4)*nb
else
c2=fdinfo_send(3,n,4)
d2=fdinfo_send(4,n,4)
j=fdinfo_send(9,n,4)*nb
end if
c1=fdinfo_send(1,n,4) ; d1=fdinfo_send(2,n,4)
c3=fdinfo_send(5,n,4) ; d3=fdinfo_send(6,n,4)
if ( j<1 ) cycle
ndata=0
do ib=ib1,ib2
do i3=c3,d3
do i2=c2,d2
do i1=c1,d1
ndata=ndata+1
sbuf(ndata,n,4)=www(i1,i2,i3,ib)
end do
end do
end do
end do
if ( ndata/=j ) stop
irank = fdinfo_send(7,n,4)
itags = 30
nreq = nreq + 1
call mpi_isend(sbuf(1,n,4),ndata,TYPE_MAIN,irank,itags &
,comm_grid,ireq(nreq),ierr)
end do
end if
! call mpi_waitall(nreq,ireq,istatus,ierr) ; nreq=0
!(5) [sender][6]-->[5][receiver]
if ( idir==0 .or. idir==5 .or. idir==6 ) then
do n=1,n_neighbor(5)
if ( ndepth==1 ) then
ndata = fdinfo_recv(10,n,5)*nb
else
ndata = fdinfo_recv(9,n,5)*nb
end if
if ( ndata<1 ) cycle
irank = fdinfo_recv(8,n,5)
itagr = 50
nreq = nreq + 1
call mpi_irecv(rbuf(1,n,5),ndata,TYPE_MAIN,irank,itagr &
,comm_grid,ireq(nreq),ierr)
end do
do n=1,n_neighbor(6)
if ( ndepth==1 ) then
c3=b3
d3=b3
j=fdinfo_send(10,n,6)*nb
else
c3=fdinfo_send(5,n,6)
d3=fdinfo_send(6,n,6)
j=fdinfo_send(9,n,6)*nb
end if
c1=fdinfo_send(1,n,6) ; d1=fdinfo_send(2,n,6)
c2=fdinfo_send(3,n,6) ; d2=fdinfo_send(4,n,6)
if ( j<1 ) cycle
ndata=0
do ib=ib1,ib2
do i3=c3,d3
do i2=c2,d2
do i1=c1,d1
ndata=ndata+1
sbuf(ndata,n,6)=www(i1,i2,i3,ib)
end do
end do
end do
end do
if ( ndata/=j ) stop
irank = fdinfo_send(7,n,6)
itags = 50
nreq = nreq + 1
call mpi_isend(sbuf(1,n,6),ndata,TYPE_MAIN,irank,itags &
,comm_grid,ireq(nreq),ierr)
end do
end if
! call mpi_waitall(nreq,ireq,istatus,ierr) ; nreq=0
!(2) [receiver][2]<--[1][sender]
if ( idir==0 .or. idir==1 .or. idir==2 ) then
do n=1,n_neighbor(2)
if ( ndepth==1 ) then
ndata = fdinfo_recv(10,n,2)*nb
else
ndata = fdinfo_recv(9,n,2)*nb
end if
if ( ndata<1 ) cycle
irank = fdinfo_recv(8,n,2)
itagr = 20
nreq = nreq + 1
call mpi_irecv(rbuf(1,n,2),ndata,TYPE_MAIN,irank,itagr &
,comm_grid,ireq(nreq),ierr)
end do
do n=1,n_neighbor(1)
if ( ndepth==1 ) then
c1=a1
d1=a1
j=fdinfo_send(10,n,1)*nb
else
c1=fdinfo_send(1,n,1)
d1=fdinfo_send(2,n,1)
j=fdinfo_send(9,n,1)*nb
end if
c2=fdinfo_send(3,n,1) ; d2=fdinfo_send(4,n,1)
c3=fdinfo_send(5,n,1) ; d3=fdinfo_send(6,n,1)
if ( j<1 ) cycle
ndata=0
do ib=ib1,ib2
do i3=c3,d3
do i2=c2,d2
do i1=c1,d1
ndata=ndata+1
sbuf(ndata,n,1)=www(i1,i2,i3,ib)
end do
end do
end do
end do
if ( ndata/=j ) stop
irank = fdinfo_send(7,n,1)
itags = 20
nreq = nreq + 1
call mpi_isend(sbuf(1,n,1),ndata,TYPE_MAIN,irank,itags &
,comm_grid,ireq(nreq),ierr)
end do
end if
! call mpi_waitall(nreq,ireq,istatus,ierr) ; nreq=0
!(4) [receiver][4]<--[3][sender]
if ( idir==0 .or. idir==3 .or. idir==4 ) then
do n=1,n_neighbor(4)
if ( ndepth==1 ) then
ndata = fdinfo_recv(10,n,4)*nb
else
ndata = fdinfo_recv(9,n,4)*nb
end if
if ( ndata<1 ) cycle
irank = fdinfo_recv(8,n,4)
itagr = 40
nreq = nreq + 1
call mpi_irecv(rbuf(1,n,4),ndata,TYPE_MAIN,irank,itagr &
,comm_grid,ireq(nreq),ierr)
end do
do n=1,n_neighbor(3)
if ( ndepth==1 ) then
c2=a2
d2=a2
j=fdinfo_send(10,n,3)*nb
else
c2=fdinfo_send(3,n,3)
d2=fdinfo_send(4,n,3)
j=fdinfo_send(9,n,3)*nb
end if
c1=fdinfo_send(1,n,3) ; d1=fdinfo_send(2,n,3)
c3=fdinfo_send(5,n,3) ; d3=fdinfo_send(6,n,3)
if ( j<1 ) cycle
ndata=0
do ib=ib1,ib2
do i3=c3,d3
do i2=c2,d2
do i1=c1,d1
ndata=ndata+1
sbuf(ndata,n,3)=www(i1,i2,i3,ib)
end do
end do
end do
end do
if ( ndata/=j ) stop
irank = fdinfo_send(7,n,3)
itags = 40
nreq = nreq + 1
call mpi_isend(sbuf(1,n,3),ndata,TYPE_MAIN,irank,itags &
,comm_grid,ireq(nreq),ierr)
end do
end if
! call mpi_waitall(nreq,ireq,istatus,ierr) ; nreq=0
!(6) [receiver][6]<--[5][sender]
if ( idir==0 .or. idir==5 .or. idir==6 ) then
do n=1,n_neighbor(6)
if ( ndepth==1 ) then
ndata = fdinfo_recv(10,n,6)*nb
else
ndata = fdinfo_recv(9,n,6)*nb
end if
if ( ndata<1 ) cycle
irank = fdinfo_recv(8,n,6)
itagr = 60
nreq = nreq + 1
call mpi_irecv(rbuf(1,n,6),ndata,TYPE_MAIN,irank,itagr &
,comm_grid,ireq(nreq),ierr)
end do
do n=1,n_neighbor(5)
if ( ndepth==1 ) then
c3=a3
d3=a3
j=fdinfo_send(10,n,5)*nb
else
c3=fdinfo_send(5,n,5)
d3=fdinfo_send(6,n,5)
j=fdinfo_send(9,n,5)*nb
end if
c1=fdinfo_send(1,n,5) ; d1=fdinfo_send(2,n,5)
c2=fdinfo_send(3,n,5) ; d2=fdinfo_send(4,n,5)
if ( j<1 ) cycle
ndata=0
do ib=ib1,ib2
do i3=c3,d3
do i2=c2,d2
do i1=c1,d1
ndata=ndata+1
sbuf(ndata,n,5)=www(i1,i2,i3,ib)
end do
end do
end do
end do
if ( ndata/=j ) stop
irank = fdinfo_send(7,n,5)
itags = 60
nreq = nreq + 1
call mpi_isend(sbuf(1,n,5),ndata,TYPE_MAIN,irank,itags &
,comm_grid,ireq(nreq),ierr)
end do
end if
call mpi_waitall(nreq,ireq,istatus,ierr) ; nreq=0
do m=1,6
do n=1,n_neighbor(m)
c1=fdinfo_recv(1,n,m)
d1=fdinfo_recv(2,n,m)
c2=fdinfo_recv(3,n,m)
d2=fdinfo_recv(4,n,m)
c3=fdinfo_recv(5,n,m)
d3=fdinfo_recv(6,n,m)
if ( Md>ndepth .and. ndepth==1 ) then
if ( fdinfo_recv(10,n,m)<1 ) cycle
select case(m)
case(1)
c1=a1-1
d1=c1
case(2)
c1=b1+1
d1=c1
case(3)
c2=a2-1
d2=c2
case(4)
c2=b2+1
d2=c2
case(5)
c3=a3-1
d3=c3
case(6)
c3=b3+1
d3=c3
end select
else
if ( fdinfo_recv(9,n,m)<1 ) cycle
end if
i=0
do ib=ib1,ib2
do i3=c3,d3
do i2=c2,d2
do i1=c1,d1
i=i+1
www(i1,i2,i3,ib)=rbuf(i,n,m)
end do
end do
end do
end do
end do
end do
return
END SUBROUTINE bcset
SUBROUTINE init_bcset( Md_in, SYStype )
implicit none
integer,intent(IN) :: Md_in, SYStype
Md = Md_in
select case( SYStype )
case default
call init_bcset_sol
case( 1 )
call init_bcset_mol(Md,Ngrid(1),np_grid,myrank_g,comm_grid,pinfo_grid)
end select
call allocate_bcset
END SUBROUTINE init_bcset
SUBROUTINE init_bcset_sol
implicit none
integer :: a1,a2,a3,b1,b2,b3,a1b,b1b,a2b,b2b,a3b,b3b
integer,allocatable :: map_grid_2_pinfo(:,:,:,:)
integer,allocatable :: ireq(:)
integer :: i,i1,i2,i3,m,n,j,j1,j2,j3,nc,m1,m2,m3
integer :: jrank,ip,fp,ns,irank,nreq,itags,itagr,ierr
integer :: ML1,ML2,ML3
integer :: istatus(MPI_STATUS_SIZE,123)
call write_border( 80, " init_bcset_sol(start)" )
ML1 = Ngrid(1)
ML2 = Ngrid(2)
ML3 = Ngrid(3)
a1b=Igrid(1,1) ; b1b=Igrid(2,1)
a2b=Igrid(1,2) ; b2b=Igrid(2,2)
a3b=Igrid(1,3) ; b3b=Igrid(2,3)
a1=-Md ; b1=Ngrid(1)-1+Md
a2=-Md ; b2=Ngrid(2)-1+Md
a3=-Md ; b3=Ngrid(3)-1+Md
allocate( map_grid_2_pinfo(a1:b1,a2:b2,a3:b3,2) )
map_grid_2_pinfo(:,:,:,:)=0
do i=0,np_grid-1
i1=pinfo_grid(1,i)
m1=pinfo_grid(2,i)
i2=pinfo_grid(3,i)
m2=pinfo_grid(4,i)
i3=pinfo_grid(5,i)
m3=pinfo_grid(6,i)
do j3=i3,i3+m3-1
do j2=i2,i2+m2-1
do j1=i1,i1+m1-1
map_grid_2_pinfo(j1,j2,j3,1)=i
map_grid_2_pinfo(j1,j2,j3,2)=pinfo_grid(7,i)
end do
end do
end do
end do
do i3=a3,b3
j3=mod(i3+ML3,ML3)
do i2=a2,b2
j2=mod(i2+ML2,ML2)
do i1=a1,b1
j1=mod(i1+ML1,ML1)
map_grid_2_pinfo(i1,i2,i3,1)=map_grid_2_pinfo(j1,j2,j3,1)
map_grid_2_pinfo(i1,i2,i3,2)=map_grid_2_pinfo(j1,j2,j3,2)
end do
end do
end do
do i=2,6,2
n=minval( pinfo_grid(i,0:np_grid-1) )
do nc=1,Md
if ( nc*n >= Md ) exit
end do
if ( nc<1 .or. Md<nc ) stop
n_neighbor(i-1)=nc
n_neighbor(i) =nc
end do
n=maxval(n_neighbor(:))
allocate( fdinfo_send(10,n,6) ) ; fdinfo_send=0
allocate( fdinfo_recv(10,n,6) ) ; fdinfo_recv=0
fdinfo_send(7,:,:)=MPI_PROC_NULL
fdinfo_recv(8,:,:)=MPI_PROC_NULL
jrank=map_grid_2_pinfo(a1b-1,a2b,a3b,1)
ip=a1b-1
fp=ip
nc=1
ns=(b2b-a2b+1)*(b3b-a3b+1)
fdinfo_recv(1,nc,1)=ip
fdinfo_recv(2,nc,1)=fp
fdinfo_recv(3,nc,1)=a2b
fdinfo_recv(4,nc,1)=b2b
fdinfo_recv(5,nc,1)=a3b
fdinfo_recv(6,nc,1)=b3b
fdinfo_recv(7,nc,1)=myrank_g
fdinfo_recv(8,nc,1)=jrank
fdinfo_recv(9,nc,1)=ns
fdinfo_recv(10,nc,1)=ns
do i=a1b-2,a1b-Md,-1
irank=map_grid_2_pinfo(i,a2b,a3b,1)
if ( irank/=jrank ) then
jrank=irank
nc=nc+1
fp=i
end if
fdinfo_recv(1,nc,1)=i
fdinfo_recv(2,nc,1)=fp
fdinfo_recv(3,nc,1)=a2b
fdinfo_recv(4,nc,1)=b2b
fdinfo_recv(5,nc,1)=a3b
fdinfo_recv(6,nc,1)=b3b
fdinfo_recv(7,nc,1)=myrank_g
fdinfo_recv(8,nc,1)=jrank
fdinfo_recv(9,nc,1)=(fp-i+1)*ns
end do
jrank=map_grid_2_pinfo(b1b+1,a2b,a3b,1)
ip=b1b+1
fp=ip
nc=1
ns=(b2b-a2b+1)*(b3b-a3b+1)
fdinfo_recv(1,nc,2)=ip
fdinfo_recv(2,nc,2)=fp
fdinfo_recv(3,nc,2)=a2b
fdinfo_recv(4,nc,2)=b2b
fdinfo_recv(5,nc,2)=a3b
fdinfo_recv(6,nc,2)=b3b
fdinfo_recv(7,nc,2)=myrank_g
fdinfo_recv(8,nc,2)=jrank
fdinfo_recv(9,nc,2)=ns
fdinfo_recv(10,nc,2)=ns
do i=b1b+1,b1b+Md
irank=map_grid_2_pinfo(i,a2b,a3b,1)
if ( irank/=jrank ) then
jrank=irank
nc=nc+1
ip=i
end if
fdinfo_recv(1,nc,2)=ip
fdinfo_recv(2,nc,2)=i
fdinfo_recv(3,nc,2)=a2b
fdinfo_recv(4,nc,2)=b2b
fdinfo_recv(5,nc,2)=a3b
fdinfo_recv(6,nc,2)=b3b
fdinfo_recv(7,nc,2)=myrank_g
fdinfo_recv(8,nc,2)=jrank
fdinfo_recv(9,nc,2)=(i-ip+1)*ns
end do
jrank=map_grid_2_pinfo(a1b,a2b-1,a3b,1)
ip=a2b-1
fp=ip
nc=1
ns=(b1b-a1b+1)*(b3b-a3b+1)
fdinfo_recv(1,nc,3)=a1b
fdinfo_recv(2,nc,3)=b1b
fdinfo_recv(3,nc,3)=ip
fdinfo_recv(4,nc,3)=fp
fdinfo_recv(5,nc,3)=a3b
fdinfo_recv(6,nc,3)=b3b
fdinfo_recv(7,nc,3)=myrank_g
fdinfo_recv(8,nc,3)=jrank
fdinfo_recv(9,nc,3)=ns
fdinfo_recv(10,nc,3)=ns
do i=a2b-2,a2b-Md,-1
irank=map_grid_2_pinfo(a1b,i,a3b,1)
if ( irank/=jrank ) then
jrank=irank
nc=nc+1
fp=i
end if
fdinfo_recv(1,nc,3)=a1b
fdinfo_recv(2,nc,3)=b1b
fdinfo_recv(3,nc,3)=i
fdinfo_recv(4,nc,3)=fp
fdinfo_recv(5,nc,3)=a3b
fdinfo_recv(6,nc,3)=b3b
fdinfo_recv(7,nc,3)=myrank_g
fdinfo_recv(8,nc,3)=jrank
fdinfo_recv(9,nc,3)=(fp-i+1)*ns
end do
jrank=map_grid_2_pinfo(a1b,b2b+1,a3b,1)
ip=b2b+1
fp=ip
nc=1
ns=(b1b-a1b+1)*(b3b-a3b+1)
fdinfo_recv(1,nc,4)=a1b
fdinfo_recv(2,nc,4)=b1b
fdinfo_recv(3,nc,4)=ip
fdinfo_recv(4,nc,4)=fp
fdinfo_recv(5,nc,4)=a3b
fdinfo_recv(6,nc,4)=b3b
fdinfo_recv(7,nc,4)=myrank_g
fdinfo_recv(8,nc,4)=jrank
fdinfo_recv(9,nc,4)=ns
fdinfo_recv(10,nc,4)=ns
do i=b2b+1,b2b+Md
irank=map_grid_2_pinfo(a1b,i,a3b,1)
if ( irank/=jrank ) then
jrank=irank
nc=nc+1
ip=i
end if
fdinfo_recv(1,nc,4)=a1b
fdinfo_recv(2,nc,4)=b1b
fdinfo_recv(3,nc,4)=ip
fdinfo_recv(4,nc,4)=i
fdinfo_recv(5,nc,4)=a3b
fdinfo_recv(6,nc,4)=b3b
fdinfo_recv(7,nc,4)=myrank_g
fdinfo_recv(8,nc,4)=jrank
fdinfo_recv(9,nc,4)=(i-ip+1)*ns
end do
jrank=map_grid_2_pinfo(a1b,a2b,a3b-1,1)
ip=a3b-1
fp=ip
nc=1
ns=(b2b-a2b+1)*(b1b-a1b+1)
fdinfo_recv(1,nc,5)=a1b
fdinfo_recv(2,nc,5)=b1b
fdinfo_recv(3,nc,5)=a2b
fdinfo_recv(4,nc,5)=b2b
fdinfo_recv(5,nc,5)=ip
fdinfo_recv(6,nc,5)=fp
fdinfo_recv(7,nc,5)=myrank_g
fdinfo_recv(8,nc,5)=jrank
fdinfo_recv(9,nc,5)=ns
fdinfo_recv(10,nc,5)=ns
do i=a3b-2,a3b-Md,-1
irank=map_grid_2_pinfo(a1b,a2b,i,1)
if ( irank/=jrank ) then
jrank=irank
nc=nc+1
fp=i
end if
fdinfo_recv(1,nc,5)=a1b
fdinfo_recv(2,nc,5)=b1b
fdinfo_recv(3,nc,5)=a2b
fdinfo_recv(4,nc,5)=b2b
fdinfo_recv(5,nc,5)=i
fdinfo_recv(6,nc,5)=fp
fdinfo_recv(7,nc,5)=myrank_g
fdinfo_recv(8,nc,5)=jrank
fdinfo_recv(9,nc,5)=(fp-i+1)*ns
end do
jrank=map_grid_2_pinfo(a1b,a2b,b3b+1,1)
ip=b3b+1
fp=ip
nc=1
ns=(b2b-a2b+1)*(b1b-a1b+1)
fdinfo_recv(1,nc,6)=a1b
fdinfo_recv(2,nc,6)=b1b
fdinfo_recv(3,nc,6)=a2b
fdinfo_recv(4,nc,6)=b2b
fdinfo_recv(5,nc,6)=ip
fdinfo_recv(6,nc,6)=fp
fdinfo_recv(7,nc,6)=myrank_g
fdinfo_recv(8,nc,6)=jrank
fdinfo_recv(9,nc,6)=ns
fdinfo_recv(10,nc,6)=ns
do i=b3b+1,b3b+Md
irank=map_grid_2_pinfo(a1b,a2b,i,1)
if ( irank/=jrank ) then
jrank=irank
nc=nc+1
ip=i
end if
fdinfo_recv(1,nc,6)=a1b
fdinfo_recv(2,nc,6)=b1b
fdinfo_recv(3,nc,6)=a2b
fdinfo_recv(4,nc,6)=b2b
fdinfo_recv(5,nc,6)=ip
fdinfo_recv(6,nc,6)=i
fdinfo_recv(7,nc,6)=myrank_g
fdinfo_recv(8,nc,6)=jrank
fdinfo_recv(9,nc,6)=(i-ip+1)*ns
end do
deallocate( map_grid_2_pinfo )
n=maxval(n_neighbor)*6*2
allocate( ireq(n) ) ; ireq(:)=0
nreq=0
do j=1,6
do i=1,n_neighbor(j)
irank=fdinfo_recv(8,i,j)
select case(j)
case(1,3,5)
itags=10*(j+1)+i
itagr=10*j+i
case(2,4,6)
itags=10*(j-1)+i
itagr=10*j+i
end select
nreq=nreq+1
call mpi_irecv(fdinfo_send(1,i,j),10,mpi_integer,irank &
,itagr,comm_grid,ireq(nreq),ierr)
nreq=nreq+1
call mpi_isend(fdinfo_recv(1,i,j),10,mpi_integer,irank &
,itags,comm_grid,ireq(nreq),ierr)
end do
end do
call mpi_waitall(nreq,ireq,istatus,ierr)
deallocate( ireq )
do i=1,6
do n=1,n_neighbor(i)
select case(i)
case(1,2)
fdinfo_send(1,n,i)=mod(fdinfo_send(1,n,i)+ML1,ML1)
fdinfo_send(2,n,i)=mod(fdinfo_send(2,n,i)+ML1,ML1)
case(3,4)
fdinfo_send(3,n,i)=mod(fdinfo_send(3,n,i)+ML2,ML2)
fdinfo_send(4,n,i)=mod(fdinfo_send(4,n,i)+ML2,ML2)
case(5,6)
fdinfo_send(5,n,i)=mod(fdinfo_send(5,n,i)+ML3,ML3)
fdinfo_send(6,n,i)=mod(fdinfo_send(6,n,i)+ML3,ML3)
end select
end do
end do
call write_border( 80, " init_bcset_sol(end)" )
END SUBROUTINE init_bcset_sol
SUBROUTINE allocate_bcset
implicit none
integer :: a1,a2,a3,b1,b2,b3
a1=Igrid(1,1)-Md ; a2=Igrid(1,2)-Md ; a3=Igrid(1,3)-Md
b1=Igrid(2,1)+Md ; b2=Igrid(2,2)+Md ; b3=Igrid(2,3)+Md
if ( allocated(www) ) deallocate(www)
allocate( www(a1:b1,a2:b2,a3:b3,MB_d) )
www(:,:,:,:)=zero
a1=maxval( n_neighbor(1:6) )
a2=maxval( fdinfo_send(9,1:a1,1:6) )*MB_d
a3=maxval( fdinfo_recv(9,1:a1,1:6) )*MB_d
if ( allocated(sbuf) ) deallocate(sbuf)
if ( allocated(rbuf) ) deallocate(rbuf)
allocate( sbuf(a2,a1,6) )
allocate( rbuf(a3,a1,6) )
sbuf(:,:,:)=zero
rbuf(:,:,:)=zero
END SUBROUTINE allocate_bcset
END MODULE bc_module
| src/bc/bc_module.f90 |
subroutine plots_stop_cfmt(p,wt,wt2)
c--- routine to provide a plotting interface that produces the plots
c--- for both single top processes (2->2 and 2->3)
c--- of Campbell, Frederix, Maltoni and Tramontano
implicit none
include 'constants.f'
include 'jetlabel.f'
include 'nplot.f'
include 'process.f'
include 'first.f'
integer i,n,nplotmax,jet(2),jetswap,ibbar,inotb,ilight1,ilight2
double precision p(mxpart,4),wt,wt2,getet,
. pttop,etatop,ytop,bwgt,
. pt,etarap,yrap,ptthree,etarapthree,yrapthree,
. wtbbar,wtnotb,wtlight1,wtlight2,
. wtbbar2,wtnotb2,wtlight12,wtlight22,
. ptmin,ptmax,ptbin,rapmin,rapmax,rapbin
character*4 tag
logical jetmerge
common/jetmerge/jetmerge
common/btagging/bwgt
common/nplotmax/nplotmax
!$omp threadprivate(/jetmerge/)
ccccc!$omp threadprivate(/nplotmax/)
c--- on the first call, initialize histograms
if (first) then
tag='book'
pttop=-1d0
etatop=1d3
ytop=1d3
ibbar=6
inotb=7
ilight1=6
ilight2=7
goto 99
else
tag='plot'
endif
c--- check that this routine is being used for one of the envisaged
c--- processes and, if so, initialize variables accordingly
if (case .eq. 'bq_tpq') then
if (jets .gt. 0) then
do i=1,jets
jet(i)=5+i ! jets start with parton 6 when removebr=.true.
enddo
pttop=ptthree(3,4,5,p)
etatop=etarapthree(3,4,5,p)
ytop=yrapthree(3,4,5,p)
endif
elseif (case .eq. 'qg_tbq') then
if (jets .gt. 0) then
do i=1,jets
jet(i)=4+i ! jets start with parton 5
enddo
pttop=pt(3,p)
etatop=etarap(3,p)
ytop=yrap(3,p)
endif
else
write(6,*) 'This plotting routine is not suitable for'
write(6,*) 'the process that you are calculating.'
stop
endif
c--- there are at most two jets; reorder them according to pt if two
if (jets .eq. 2) then
if (pt(jet(2),p) .gt. pt(jet(1),p)) then
jetswap=jet(1)
jet(1)=jet(2)
jet(2)=jetswap
endif
endif
c--- initialize all variabels to zero
ibbar=0
inotb=0
ilight1=0
ilight2=0
c--- Extract index to b~ (b for t~) in the 2->2 process
c--- Events should be plotted with weight = wt*bwgt instead of just wt
c--- (adapted from original code in nplotter.f by Z. Sullivan)
if (case .eq. 'bq_tpq') then
c--- 1) Ascertain the identity of the jets
if (jets .gt. 0) then
c--- There are 2 cases:
c--- If no merging, then only if jetlabel(i)=='pp' is it the b~.
do i=1,jets
if (jetlabel(jet(i)-5).eq.'pp') then
ibbar=jet(i)
elseif (jetlabel(jet(i)-5).eq.'qj') then
inotb=jet(i)
endif
enddo
c--- If merging occurred, then it matters whether the merged
c--- jet was already a bq or not.
if (jetmerge) then
ibbar=jet(1) ! b~ was merged into jet(1)
endif
endif
c--- 2) Assign weights for histogramming
c--- there are three cases
if (jets .eq. 1) then
if (jetlabel(1) .eq. 'qj') then
c--- 1) only one jet, that is definitely not a b
c--- jetlabel = (qj)
ibbar=0
c inotb already set above
wtnotb=wt
wtnotb2=wt2
elseif (jetlabel(1) .eq. 'pp') then
c--- 2) only one jet, that could be a b
c--- jetlabel = (pp)
c ibbar already set above
inotb=ibbar
wtbbar=wt*bwgt
wtnotb=wt*(1d0-bwgt)
wtbbar2=wt2*bwgt**2
wtnotb2=wt2*(1d0-bwgt)**2
endif
c--- 3) two jets, one of which could be a b
c--- jetlabel = (qj,pp) OR (pp,qj)
elseif (jets .eq. 2) then
c ibbar already set above
c inotb already set above
wtbbar=wt*bwgt
wtnotb=wt*bwgt
wtbbar2=wt2*bwgt**2
wtnotb2=wt2*bwgt**2
ilight1=jet(1) ! they are ordered according to pt
ilight2=jet(2) ! they are ordered according to pt
wtlight1=wt*(1d0-bwgt)
wtlight2=wtlight1
wtlight12=wt2*(1d0-bwgt)**2
wtlight22=wtlight12
elseif (jets .eq. 0) then
c--- nothing to set: all variables=0, only occurs when notag=1
continue
else
write(6,*) 'Error: there should be 1 or 2 jets, instead ',jets
stop
endif
endif
c--- Simpler manipulations for the 2->3 process
if (case .eq. 'qg_tbq') then
ibbar=4
wtbbar=wt
wtbbar2=wt2
if (jets .gt. 0) then
ilight1=jet(1)
wtlight1=wt
wtlight12=wt2
endif
if (jets .gt. 1) then
ilight2=jet(2)
wtlight2=wt
wtlight22=wt2
endif
c--- inotb should remain equal to zero
endif
99 continue
n=1
c--- fill plots
c--- available veriables are
c--- pttop,eta,ytop: pt, pseudo-rapidity and rapidity of the top quark
call bookplot(n,tag,'pt(top) ',pttop,wt,wt2,0d0,200d0,5d0,'log')
n=n+1
call bookplot(n,tag,'eta(top)',etatop,wt,wt2,-8d0,8d0,0.5d0,'lin')
n=n+1
call bookplot(n,tag,'y(top) ',ytop,wt,wt2,-8d0,8d0,0.5d0,'lin')
n=n+1
c--- more complicated procedure for these plots, due to 2->2 process
c--- pt and rapidity of the b-quark and other jets
c--- Note that the order is important (due to histogram finalizing):
c--- all plots for jet 1, all for bottom quark, all for jet 2
c--- set the ranges and bin sizes here
ptmin=0d0
ptmax=200d0
ptbin=2d0
rapmin=-5d0
rapmax=+5d0
rapbin=0.2d0
c--- 1) leading jet that isn't a b
c--- first account for events with only one non b jet (always occurs)
c--- (always occurs, except if notag=1)
c--- [pt]
if (inotb .ne. 0) then
call bookplot(n,tag,'pt(jet 1)',
. pt(inotb,p),wtnotb,wtnotb2,ptmin,ptmax,ptbin,'log')
endif
c--- then account for events with two non b jets (only if ilight1>0)
if (ilight1 .ne. 0) then
call bookplot(n,tag,'pt(jet 1)',
. pt(ilight1,p),wtlight1,wtlight12,ptmin,ptmax,ptbin,'log')
endif
n=n+1
c--- [rapidity]
if (inotb .ne. 0) then
call bookplot(n,tag,'eta(jet 1)',
. etarap(inotb,p),wtnotb,wtnotb2,rapmin,rapmax,rapbin,'lin')
endif
c--- then account for events with two non b jets (only if ilight1>0)
if (ilight1 .ne. 0) then
call bookplot(n,tag,'eta(jet 1)',
. etarap(ilight1,p),wtlight1,wtlight12,rapmin,rapmax,rapbin,'lin')
endif
n=n+1
c--- 2) b jet (only if ibbar>0)
c--- [pt]
if (ibbar .ne. 0) then
call bookplot(n,tag,'pt(bottom)',
. pt(ibbar,p),wtbbar,wtbbar2,ptmin,ptmax,ptbin,'log')
endif
n=n+1
c--- [pt] with |rapidity| < 2.8 (plot for CDF)
if (ibbar .ne. 0) then
if ((abs(etarap(ibbar,p)) .lt. 2.8d0).or.(tag .eq. 'book')) then
call bookplot(n,tag,'pt(bottom) with |eta(bottom)| < 2.8',
. pt(ibbar,p),wtbbar,wtbbar2,ptmin,ptmax,ptbin,'log')
endif
endif
n=n+1
c--- [rapidity]
if (ibbar .ne. 0) then
call bookplot(n,tag,'eta(bottom)',
. etarap(ibbar,p),wtbbar,wtbbar2,rapmin,rapmax,rapbin,'lin')
endif
n=n+1
c--- [rapidity] < 2.8 and pt > 20 GeV (plot for acceptance in CDF)
if (ibbar .ne. 0) then
if ((pt(ibbar,p) .gt. 20d0).or.(tag .eq. 'book')) then
call bookplot(n,tag,'eta(bottom) with pt(bottom)>20 GeV',
. etarap(ibbar,p),wtbbar,wtbbar2,-2.8d0,2.801d0,rapbin,'lin')
endif
endif
n=n+1
c--- [rapidity] < 2.8 and pt > 20 GeV (plot for acceptance in CDF)
if (ibbar .ne. 0) then
if ((getet(p(ibbar,4),p(ibbar,1),p(ibbar,2),p(ibbar,3)).gt.20d0)
. .or.(tag .eq. 'book')) then
call bookplot(n,tag,'eta(bottom) with Et(bottom)>20 GeV',
. etarap(ibbar,p),wtbbar,wtbbar2,-2.8d0,2.801d0,rapbin,'lin')
endif
endif
n=n+1
c--- 3) subleading jet that isn't a b (only if ilight2>0)
c--- [pt]
if (ilight2 .ne. 0) then
call bookplot(n,tag,'pt(jet 2)',
. pt(ilight2,p),wtlight2,wtlight22,ptmin,ptmax,ptbin,'log')
endif
n=n+1
c--- [rapidity]
if (ilight2 .ne. 0) then
call bookplot(n,tag,'eta(jet 2)',
. etarap(ilight2,p),wtlight2,wtlight22,rapmin,rapmax,rapbin,'lin')
endif
n=n+1
c--- copied from nplotter.f
n=n-1
if (n .gt. maxhisto) then
write(6,*) 'WARNING - TOO MANY HISTOGRAMS!'
write(6,*) n,' > ',maxhisto,', which is the built-in maximum.'
write(6,*) 'To use more histograms, change the value of the'
write(6,*) 'constant MAXHISTO in src/Inc/nplot.f then do:'
write(6,*)
write(6,*) ' make clean; make to recompile from scratch.'
write(6,*)
stop
endif
c--- set the maximum number of plots, on the first call
if (first) then
first=.false.
nplotmax=n
endif
return
end
| MCFM-JHUGen/src/User/plots_stop_cfmt.f |
subroutine interp2(x,y,v,n1,n2,a,b,NZ)
implicit none
integer*4::n1,n2;
integer*4,dimension(1)::sx,sy;
real*8(n2,n1)::v;
real*8(n1):: x;
real*8(n2):: y;
real*8(1,1):: NZ1,v1,v2,v3,v4,v5;
real*8(1):: x1,x2,x3,y1,y2,y3
real*8::a,b,NZ
sx=minloc(abs(x-a));sy=minloc(abs(y-b));
y1=y(sy);x1=x(sx);
y2=y(sy-1);x2=x(sx-1);y3=y(sy+1);x3=x(sx+1);
v1=v(sy,sx);v2=v(sy,sx-1);v3=v(sy-1,sx);v4=v(sy+1,sx);
v5=v(sy,sx+1);
if((y1(1)>b).AND.(x1(1)>a))then
NZ1=v1(1,1)-(v1(1,1)-v2(1,1))/(x1(1)-x2(1))*(x1(1)-a)&
&-(v1(1,1)-v3(1,1))/(y1(1)-y2(1))*(y1(1)-b);
else if((y1(1)<=b).AND.(x1(1)>a))then
NZ1=v1(1,1)-(v1(1,1)-v2(1,1))/(x1(1)-x2(1))*(x1(1)-a)&
&-(v4(1,1)-v1(1,1))/(y3(1)-y1(1))*(y1(1)-b);
else if(y1(1)>b.AND.x1(1)<=a)then
NZ1=v1(1,1)-(v5(1,1)-v1(1,1))/(x3(1)-x1(1))*(x1(1)-a)&
&-(v1(1,1)-v3(1,1))/(y1(1)-y2(1))*(y1(1)-b);
else
NZ1=v1(1,1)-(v5(1,1)-v1(1,1))/(x3(1)-x1(1))*(x1(1)-a)&
&-(v4(1,1)-v1(1,1))/(y3(1)-y1(1))*(y1(1)-b);
end if
NZ=NZ1(1,1);
return;
end subroutine
| 11/mathlib/interp2.f90 |
! { dg-do compile }
! Checks the fix for PR33241, in which the assumed character
! length of the parameter was never filled in with that of
! the initializer.
!
! Contributed by Victor Prosolin <[email protected]>
!
PROGRAM fptest
IMPLICIT NONE
CHARACTER (LEN=*), DIMENSION(1), PARAMETER :: var = 'a'
CALL parsef (var)
contains
SUBROUTINE parsef (Var)
IMPLICIT NONE
CHARACTER (LEN=*), DIMENSION(:), INTENT(in) :: Var
END SUBROUTINE parsef
END PROGRAM fptest
| validation_tests/llvm/f18/gfortran.dg/char_length_10.f90 |
subroutine amrex_fort_avg_nd_to_cc (lo, hi, ncomp, &
cc, ccl1, ccl2, ccl3, cch1, cch2, cch3, &
nd, ndl1, ndl2, ndl3, ndh1, ndh2, ndh3 ) bind(c)
use amrex_fort_module, only : amrex_real
implicit none
integer :: lo(3),hi(3), ncomp
integer :: ccl1, ccl2, ccl3, cch1, cch2, cch3
integer :: ndl1, ndl2, ndl3, ndh1, ndh2, ndh3
real(amrex_real) :: cc(ccl1:cch1, ccl2:cch2, ccl3:cch3, ncomp)
real(amrex_real) :: nd(ndl1:ndh1, ndl2:ndh2, ndl3:ndh3, ncomp)
! Local variables
integer :: i,j,k,n
do n = 1, ncomp
do k=lo(3),hi(3)
do j=lo(2),hi(2)
do i=lo(1),hi(1)
cc(i,j,k,n) = 0.125_amrex_real * ( nd(i,j ,k ,n) + nd(i+1,j ,k ,n) &
+ nd(i,j+1,k ,n) + nd(i+1,j+1,k ,n) &
+ nd(i,j ,k+1,n) + nd(i+1,j ,k+1,n) &
+ nd(i,j+1,k+1,n) + nd(i+1,j+1,k+1,n) )
end do
end do
end do
end do
end subroutine amrex_fort_avg_nd_to_cc
! ***************************************************************************************
! subroutine bl_avg_eg_to_cc
! ***************************************************************************************
subroutine bl_avg_eg_to_cc (lo, hi, &
cc, ccl1, ccl2, ccl3, cch1, cch2, cch3, &
Ex, Exl1, Exl2, Exl3, Exh1, Exh2, Exh3, &
Ey, Eyl1, Eyl2, Eyl3, Eyh1, Eyh2, Eyh3, &
Ez, Ezl1, Ezl2, Ezl3, Ezh1, Ezh2, Ezh3)
use amrex_fort_module, only : amrex_real
implicit none
integer :: lo(3),hi(3)
integer :: ccl1, ccl2, ccl3, cch1, cch2, cch3
integer :: Exl1, Exl2, Exl3, Exh1, Exh2, Exh3
integer :: Eyl1, Eyl2, Eyl3, Eyh1, Eyh2, Eyh3
integer :: Ezl1, Ezl2, Ezl3, Ezh1, Ezh2, Ezh3
real(amrex_real) :: cc(ccl1:cch1, ccl2:cch2, ccl3:cch3, 3)
real(amrex_real) :: Ex(Exl1:Exh1, Exl2:Exh2, Exl3:Exh3)
real(amrex_real) :: Ey(Eyl1:Eyh1, Eyl2:Eyh2, Eyl3:Eyh3)
real(amrex_real) :: Ez(Ezl1:Ezh1, Ezl2:Ezh2, Ezl3:Ezh3)
! Local variables
integer :: i,j,k
do k=lo(3),hi(3)
do j=lo(2),hi(2)
do i=lo(1),hi(1)
cc(i,j,k,1) = 0.25d0 * ( Ex(i,j,k) + Ex(i,j+1,k) + Ex(i,j,k+1) + Ex(i,j+1,k+1) )
cc(i,j,k,2) = 0.25d0 * ( Ey(i,j,k) + Ey(i+1,j,k) + Ey(i,j,k+1) + Ey(i+1,j,k+1) )
cc(i,j,k,3) = 0.25d0 * ( Ez(i,j,k) + Ez(i+1,j,k) + Ez(i,j+1,k) + Ez(i+1,j+1,k) )
enddo
enddo
enddo
end subroutine bl_avg_eg_to_cc
! ***************************************************************************************
! subroutine bl_avg_fc_to_cc
! ***************************************************************************************
subroutine bl_avg_fc_to_cc (lo, hi, &
cc, ccl1, ccl2, ccl3, cch1, cch2, cch3, &
fx, fxl1, fxl2, fxl3, fxh1, fxh2, fxh3, &
fy, fyl1, fyl2, fyl3, fyh1, fyh2, fyh3, &
fz, fzl1, fzl2, fzl3, fzh1, fzh2, fzh3, &
dx, problo, coord_type)
use amrex_fort_module, only : amrex_real
implicit none
integer :: lo(3),hi(3), coord_type
integer :: ccl1, ccl2, ccl3, cch1, cch2, cch3
integer :: fxl1, fxl2, fxl3, fxh1, fxh2, fxh3
integer :: fyl1, fyl2, fyl3, fyh1, fyh2, fyh3
integer :: fzl1, fzl2, fzl3, fzh1, fzh2, fzh3
real(amrex_real) :: cc(ccl1:cch1, ccl2:cch2, ccl3:cch3, 3)
real(amrex_real) :: fx(fxl1:fxh1, fxl2:fxh2, fxl3:fxh3)
real(amrex_real) :: fy(fyl1:fyh1, fyl2:fyh2, fyl3:fyh3)
real(amrex_real) :: fz(fzl1:fzh1, fzl2:fzh2, fzl3:fzh3)
real(amrex_real) :: dx(3), problo(3)
! Local variables
integer :: i,j,k
do k=lo(3),hi(3)
do j=lo(2),hi(2)
do i=lo(1),hi(1)
cc(i,j,k,1) = 0.5d0 * ( fx(i,j,k) + fx(i+1,j,k) )
cc(i,j,k,2) = 0.5d0 * ( fy(i,j,k) + fy(i,j+1,k) )
cc(i,j,k,3) = 0.5d0 * ( fz(i,j,k) + fz(i,j,k+1) )
enddo
enddo
enddo
end subroutine bl_avg_fc_to_cc
! ***************************************************************************************
! subroutine bl_avg_cc_to_fc
! ***************************************************************************************
subroutine bl_avg_cc_to_fc (xlo, xhi, ylo, yhi, zlo, zhi, &
fx, fxl1, fxl2, fxl3, fxh1, fxh2, fxh3, &
fy, fyl1, fyl2, fyl3, fyh1, fyh2, fyh3, &
fz, fzl1, fzl2, fzl3, fzh1, fzh2, fzh3, &
cc, ccl1, ccl2, ccl3, cch1, cch2, cch3, &
dx, problo, coord_type)
use amrex_fort_module, only : amrex_real
implicit none
integer :: xlo(3),xhi(3), ylo(3),yhi(3), zlo(3), zhi(3), coord_type
integer :: fxl1, fxl2, fxl3, fxh1, fxh2, fxh3
integer :: fyl1, fyl2, fyl3, fyh1, fyh2, fyh3
integer :: fzl1, fzl2, fzl3, fzh1, fzh2, fzh3
integer :: ccl1, ccl2, ccl3, cch1, cch2, cch3
real(amrex_real) :: cc(ccl1:cch1, ccl2:cch2, ccl3:cch3)
real(amrex_real) :: fx(fxl1:fxh1, fxl2:fxh2, fxl3:fxh3)
real(amrex_real) :: fy(fyl1:fyh1, fyl2:fyh2, fyl3:fyh3)
real(amrex_real) :: fz(fzl1:fzh1, fzl2:fzh2, fzl3:fzh3)
real(amrex_real) :: dx(3), problo(3)
! Local variables
integer :: i,j,k
do k=xlo(3),xhi(3)
do j=xlo(2),xhi(2)
do i=xlo(1),xhi(1)
fx(i,j,k) = 0.5d0 * (cc(i-1,j,k) + cc(i,j,k))
enddo
enddo
end do
do k=ylo(3),yhi(3)
do j=ylo(2),yhi(2)
do i=ylo(1),yhi(1)
fy(i,j,k) = 0.5d0 * (cc(i,j-1,k) + cc(i,j,k))
enddo
enddo
end do
do k=zlo(3),zhi(3)
do j=zlo(2),zhi(2)
do i=zlo(1),zhi(1)
fz(i,j,k) = 0.5d0 * (cc(i,j,k-1) + cc(i,j,k))
enddo
enddo
end do
end subroutine bl_avg_cc_to_fc
! ***************************************************************************************
! subroutine bl_avgdown_faces
! ***************************************************************************************
subroutine bl_avgdown_faces (lo, hi, &
f, f_l1, f_l2, f_l3, f_h1, f_h2, f_h3, &
c, c_l1, c_l2, c_l3, c_h1, c_h2, c_h3, &
ratio,idir,nc)
use amrex_fort_module, only : amrex_real
implicit none
integer :: lo(3),hi(3)
integer :: f_l1, f_l2, f_l3, f_h1, f_h2, f_h3
integer :: c_l1, c_l2, c_l3, c_h1, c_h2, c_h3
integer :: ratio(3), idir, nc
real(amrex_real) :: f(f_l1:f_h1, f_l2:f_h2, f_l3:f_h3, nc)
real(amrex_real) :: c(c_l1:c_h1, c_l2:c_h2, c_l3:c_h3, nc)
! Local variables
integer :: i, j, k, n, facx, facy, facz, iref, jref, kref, ii, jj, kk
real(amrex_real) :: facInv
facx = ratio(1)
facy = ratio(2)
facz = ratio(3)
if (idir .eq. 0) then
facInv = 1.d0 / (facy*facz)
do n = 1, nc
do k = lo(3), hi(3)
kk = k * facz
do j = lo(2), hi(2)
jj = j * facy
do i = lo(1), hi(1)
ii = i * facx
c(i,j,k,n) = 0.d0
do kref = 0, facz-1
do jref = 0, facy-1
c(i,j,k,n) = c(i,j,k,n) + f(ii,jj+jref,kk+kref,n)
end do
end do
c(i,j,k,n) = c(i,j,k,n) * facInv
end do
end do
end do
end do
else if (idir .eq. 1) then
facInv = 1.d0 / (facx*facz)
do n = 1, nc
do k = lo(3), hi(3)
kk = k * facz
do j = lo(2), hi(2)
jj = j * facy
do i = lo(1), hi(1)
ii = i * facx
c(i,j,k,n) = 0.d0
do kref = 0, facz-1
do iref = 0, facx-1
c(i,j,k,n) = c(i,j,k,n) + f(ii+iref,jj,kk+kref,n)
end do
end do
c(i,j,k,n) = c(i,j,k,n) * facInv
end do
end do
end do
end do
else
facInv = 1.d0 / (facx*facy)
do n = 1, nc
do k = lo(3), hi(3)
kk = k * facz
do j = lo(2), hi(2)
jj = j * facy
do i = lo(1), hi(1)
ii = i * facx
c(i,j,k,n) = 0.d0
do jref = 0, facy-1
do iref = 0, facx-1
c(i,j,k,n) = c(i,j,k,n) + f(ii+iref,jj+jref,kk,n)
end do
end do
c(i,j,k,n) = c(i,j,k,n) * facInv
end do
end do
end do
end do
end if
end subroutine bl_avgdown_faces
! ***************************************************************************************
! subroutine bl_avgdown_faces
! ***************************************************************************************
subroutine bl_avgdown_edges (lo, hi, &
f, f_l1, f_l2, f_l3, f_h1, f_h2, f_h3, &
c, c_l1, c_l2, c_l3, c_h1, c_h2, c_h3, &
ratio,idir,nc)
use amrex_fort_module, only : amrex_real
implicit none
integer :: lo(3),hi(3)
integer :: f_l1, f_l2, f_l3, f_h1, f_h2, f_h3
integer :: c_l1, c_l2, c_l3, c_h1, c_h2, c_h3
integer :: ratio(3), idir, nc
real(amrex_real) :: f(f_l1:f_h1, f_l2:f_h2, f_l3:f_h3, nc)
real(amrex_real) :: c(c_l1:c_h1, c_l2:c_h2, c_l3:c_h3, nc)
! Local variables
integer :: i, j, k, n, facx, facy, facz, iref, jref, kref, ii, jj, kk
real(amrex_real) :: facInv
facx = ratio(1)
facy = ratio(2)
facz = ratio(3)
if (idir .eq. 0) then
facInv = 1.d0 / facx
do n = 1, nc
do k = lo(3), hi(3)
kk = k * facz
do j = lo(2), hi(2)
jj = j * facy
do i = lo(1), hi(1)
ii = i * facx
c(i,j,k,n) = 0.d0
do iref = 0, facx-1
c(i,j,k,n) = c(i,j,k,n) + f(ii+iref,jj,kk,n)
end do
c(i,j,k,n) = c(i,j,k,n) * facInv
end do
end do
end do
end do
else if (idir .eq. 1) then
facInv = 1.d0 / facy
do n = 1, nc
do k = lo(3), hi(3)
kk = k * facz
do j = lo(2), hi(2)
jj = j * facy
do i = lo(1), hi(1)
ii = i * facx
c(i,j,k,n) = 0.d0
do jref = 0, facy-1
c(i,j,k,n) = c(i,j,k,n) + f(ii,jj+jref,kk,n)
end do
c(i,j,k,n) = c(i,j,k,n) * facInv
end do
end do
end do
end do
else
facInv = 1.d0 / facz
do n = 1, nc
do k = lo(3), hi(3)
kk = k * facz
do j = lo(2), hi(2)
jj = j * facy
do i = lo(1), hi(1)
ii = i * facx
c(i,j,k,n) = 0.d0
do kref = 0, facz-1
c(i,j,k,n) = c(i,j,k,n) + f(ii,jj,kk+kref,n)
end do
c(i,j,k,n) = c(i,j,k,n) * facInv
end do
end do
end do
end do
end if
end subroutine bl_avgdown_edges
! ***************************************************************************************
! subroutine bl_avgdown
! ***************************************************************************************
subroutine bl_avgdown (lo,hi,&
fine,f_l1,f_l2,f_l3,f_h1,f_h2,f_h3, &
crse,c_l1,c_l2,c_l3,c_h1,c_h2,c_h3, &
lrat,ncomp)
use amrex_fort_module, only : amrex_real
implicit none
integer f_l1,f_l2,f_l3,f_h1,f_h2,f_h3
integer c_l1,c_l2,c_l3,c_h1,c_h2,c_h3
integer lo(3), hi(3)
integer lrat(3), ncomp
real(amrex_real) crse(c_l1:c_h1,c_l2:c_h2,c_l3:c_h3,ncomp)
real(amrex_real) fine(f_l1:f_h1,f_l2:f_h2,f_l3:f_h3,ncomp)
integer :: i, j, k, ii, jj, kk, n, iref, jref, kref
real(amrex_real) :: volfrac
volfrac = 1.d0 / dble(lrat(1)*lrat(2)*lrat(3))
do n = 1, ncomp
do k = lo(3), hi(3)
kk = k * lrat(3)
do j = lo(2), hi(2)
jj = j * lrat(2)
do i = lo(1), hi(1)
ii = i * lrat(1)
crse(i,j,k,n) = 0.d0
do kref = 0, lrat(3)-1
do jref = 0, lrat(2)-1
do iref = 0, lrat(1)-1
crse(i,j,k,n) = crse(i,j,k,n) + fine(ii+iref,jj+jref,kk+kref,n)
end do
end do
end do
crse(i,j,k,n) = volfrac * crse(i,j,k,n)
end do
end do
end do
end do
end subroutine bl_avgdown
subroutine bl_avgdown_nodes (lo,hi,&
fine,f_l1,f_l2,f_l3,f_h1,f_h2,f_h3, &
crse,c_l1,c_l2,c_l3,c_h1,c_h2,c_h3, &
lrat,ncomp)
use amrex_fort_module, only : amrex_real
implicit none
integer f_l1,f_l2,f_l3,f_h1,f_h2,f_h3
integer c_l1,c_l2,c_l3,c_h1,c_h2,c_h3
integer lo(3), hi(3)
integer lrat(3), ncomp
real(amrex_real) crse(c_l1:c_h1,c_l2:c_h2,c_l3:c_h3,ncomp)
real(amrex_real) fine(f_l1:f_h1,f_l2:f_h2,f_l3:f_h3,ncomp)
integer :: i, j, k, ii, jj, kk, n
do n = 1, ncomp
do k = lo(3), hi(3)
kk = k * lrat(3)
do j = lo(2), hi(2)
jj = j * lrat(2)
do i = lo(1), hi(1)
ii = i * lrat(1)
crse(i,j,k,n) = fine(ii,jj,kk,n)
end do
end do
end do
end do
end subroutine bl_avgdown_nodes
subroutine amrex_compute_divergence (lo, hi, divu, dlo, dhi, u, ulo, uhi, &
v, vlo, vhi, w, wlo, whi, dxinv) bind(c)
use amrex_fort_module, only : amrex_real
implicit none
integer, dimension(3), intent(in) :: lo, hi, dlo, dhi, ulo, uhi, vlo, vhi, wlo, whi
real(amrex_real), intent(inout) :: divu(dlo(1):dhi(1),dlo(2):dhi(2),dlo(3):dhi(3))
real(amrex_real), intent(in ) :: u(ulo(1):uhi(1),ulo(2):uhi(2),ulo(3):uhi(3))
real(amrex_real), intent(in ) :: v(vlo(1):vhi(1),vlo(2):vhi(2),vlo(3):vhi(3))
real(amrex_real), intent(in ) :: w(wlo(1):whi(1),wlo(2):whi(2),wlo(3):whi(3))
real(amrex_real), intent(in) :: dxinv(3)
integer :: i,j,k
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
divu(i,j,k) = dxinv(1) * (u(i+1,j,k)-u(i,j,k)) &
+ dxinv(2) * (v(i,j+1,k)-v(i,j,k)) &
+ dxinv(3) * (w(i,j,k+1)-w(i,j,k))
end do
end do
end do
end subroutine amrex_compute_divergence
| Src/Base/AMReX_MultiFabUtil_3d.f90 |
! RUN: bbc %s -emit-fir --canonicalize -o - | FileCheck %s
! CHECK-LABEL pause_test
subroutine pause_test()
! CHECK: fir.call @_Fortran{{.*}}PauseStatement()
! CHECK-NEXT: return
pause
end subroutine
| flang/test/Lower/pause-statement.f90 |
SUBROUTINE SKALE (N, MSTAR, KD, Z, XI, SCALE, DSCALE)
C
C**********************************************************************
C
C purpose
C provide a proper scaling of the state variables, used
C to control the damping factor for a newton iteration [2].
C
C variables
C
C n = number of mesh subintervals
C mstar = number of unknomns in z(u(x))
C kd = number of unknowns in dmz
C z = the global unknown vector
C xi = the current mesh
C scale = scaling vector for z
C dscale = scaling vector for dmz
C
C**********************************************************************
C
IMPLICIT REAL*8 (A-H,O-Z)
DIMENSION Z(MSTAR,1), SCALE(MSTAR,1), DSCALE(KD,1)
DIMENSION XI(1), BASM(5)
C
COMMON /COLORD/ K, NCOMP, ID1, ID2, MMAX, M(20)
C
BASM(1) = 1.D0
DO 50 J=1,N
IZ = 1
H = XI(J+1) - XI(J)
DO 10 L = 1, MMAX
BASM(L+1) = BASM(L) * H / DFLOAT(L)
10 CONTINUE
DO 40 ICOMP = 1, NCOMP
SCAL = (DABS(Z(IZ,J)) + DABS(Z(IZ,J+1))) * .5D0 + 1.D0
MJ = M(ICOMP)
DO 20 L = 1, MJ
SCALE(IZ,J) = BASM(L) / SCAL
IZ = IZ + 1
20 CONTINUE
SCAL = BASM(MJ+1) / SCAL
DO 30 IDMZ = ICOMP, KD, NCOMP
DSCALE(IDMZ,J) = SCAL
30 CONTINUE
40 CONTINUE
50 CONTINUE
NP1 = N + 1
DO 60 IZ = 1, MSTAR
SCALE(IZ,NP1) = SCALE(IZ,N)
60 CONTINUE
RETURN
END
| src/f2cl/packages/colnew/skale.f |
program simple_example
use fregex
implicit none
type(regex_t) :: re
type(match_t) :: match
character(:), allocatable :: string
character(:), allocatable :: pattern
! Operations
pattern = "(.+)([\+\-\*\/]{1})(.+)"
string = "1/sin(x)"
call re % compile(pattern)
call re % match(string)
if (size(re % matches) > 0) then
match = re % matches(1) ! Gets the first match
print*, "string: ", string
print*, "pattern: ", pattern
print*, "First Group: ", match % groups(1) % content ! 1
print*, "Second Group: ", match % groups(2) % content ! /
print*, "Third Group: ", match % groups(3) % content ! sin(x)
end if
end program
| app/simple_example.f90 |
subroutine nsc_pr_iniunk(a)
!DESCRIPTION
! This routine sets up the initial conditions for the pressure,
! velocity and temperature fields.
! If this is a restart, initial conditions are loaded somewhere else
! but Dirichlet boundary conditions are still loaded here.
!-----------------------------------------------------------------------
use typre
use Mod_NSCompressiblePrimitive
use Mod_NSCompressibleSubroutines
use Mod_NscExacso
implicit none
class(NSCompressiblePrimitiveProblem) :: a
type(NscExacso) :: exacso
integer(ip) :: icomp,ipoin,idime,ndime,npoin
real(rp) :: energ,acvis,actco,accph,accvh
real(rp) :: expre, extem
!Exact Values
real(rp), allocatable :: exprg(:),exvel(:),exveg(:,:),exteg(:)
!Nodal coordinates
real(rp), pointer :: coord(:) => NULL()
call a%Mesh%GetNdime(ndime)
call a%Mesh%GetNpoin(npoin)
call a%GetPhysicalParameters(acvis,actco,accph,accvh)
if(accph-accvh<zensi) then
call runend('Nsc_iniunk: Gas constant is negative')
end if
do ipoin=1,npoin
if((a%kfl_fixno(1,ipoin)==1) .or. (a%kfl_fixno(1,ipoin) == 0)) then
a%press(ipoin,a%ncomp) = a%bvess(1,ipoin,1)
end if
if((a%kfl_fixno(ndime+2,ipoin)==1) .or. (a%kfl_fixno(ndime+2,ipoin)==0)) then
a%tempe(ipoin,a%ncomp) = a%bvess(ndime+2,ipoin,1)
end if
a%densf(ipoin,1) = (a%press(ipoin,a%ncomp)+a%relpre)/((accph-accvh)*(a%tempe(ipoin,a%ncomp)+a%reltem))
do idime=1,ndime
if((a%kfl_fixno(idime+1,ipoin)==1) .or. (a%kfl_fixno(idime+1,ipoin) == 0)) then
a%veloc(idime,ipoin,a%ncomp) = a%bvess(idime+1,ipoin,1)
a%momen(idime,ipoin,1) = a%densf(ipoin,1)*a%bvess(idime+1,ipoin,1)
end if
end do
call nsc_ComputeEnergy(ndime,accvh,(a%tempe(ipoin,a%ncomp)+a%reltem),a%veloc(:,ipoin,a%ncomp),energ)
a%energ(ipoin,1) = a%densf(ipoin,1)*energ
end do
if(minval(a%densf(:,1))<(-zensi)) then
call runend('Nsc_iniunk: Initial density is negative')
end if
if(a%kfl_incnd==1) then
call runend('Nsc_iniunk: Initial conditions not implemented')
end if
if(a%kfl_exacs/=0) then
! Allocate exact components
call a%Memor%alloc(ndime,exprg,'exprg','nsc_iniunk')
call a%Memor%alloc(ndime,exvel,'exvel','nsc_iniunk')
call a%Memor%alloc(ndime,ndime,exveg,'exveg','nsc_iniunk')
call a%Memor%alloc(ndime,exteg,'exteg','nsc_iniunk')
do ipoin = 1,npoin
call a%Mesh%GetPointCoord(ipoin,coord)
call exacso%nsc_ComputeSolution(ndime,coord,a)
call exacso%nsc_GetPressure(ndime,expre,exprg)
call exacso%nsc_GetVelocity(ndime,exvel,exveg)
call exacso%nsc_GetTemperature(ndime,extem,exteg)
a%press(ipoin,a%ncomp) = expre
do idime=1,ndime
a%veloc(idime,ipoin,a%ncomp) = exvel(idime)
end do
a%tempe(ipoin,a%ncomp) = extem
end do
! Allocate exact components
call a%Memor%dealloc(ndime,exprg,'exprg','nsc_iniunk')
call a%Memor%dealloc(ndime,exvel,'exvel','nsc_iniunk')
call a%Memor%dealloc(ndime,ndime,exveg,'exveg','nsc_iniunk')
call a%Memor%dealloc(ndime,exteg,'exteg','nsc_iniunk')
end if
!Assign var(n,i,*) <-- var(n-1,*,*), initial guess after initialization (or reading restart)
do icomp = 1,a%ncomp-1
a%press(1:npoin,icomp) = a%press(1:npoin,a%ncomp)
a%veloc(1:ndime,1:npoin,icomp) = a%veloc(1:ndime,1:npoin,a%ncomp)
a%tempe(1:npoin,icomp) = a%tempe(1:npoin,a%ncomp)
enddo
call a%Ifconf
end subroutine nsc_pr_iniunk
| Sources/modules/nscomp/PrimitiveUnknowns/nsc_pr_iniunk.f90 |
less_toxic(y1,h1).
less_toxic(hh1,w1).
less_toxic(ee1,b1).
less_toxic(m1,cc1).
less_toxic(bb1,z1).
less_toxic(ff1,v1).
less_toxic(ll1,b1).
less_toxic(o1,jj1).
less_toxic(j1,dd1).
less_toxic(n1,cc1).
less_toxic(w1,aa1).
less_toxic(q1,l1).
less_toxic(m1,l1).
less_toxic(bb1,aa1).
less_toxic(b1,i1).
less_toxic(ee1,l1).
less_toxic(ee1,jj1).
less_toxic(m1,w1).
less_toxic(q1,d1).
less_toxic(cc1,l1).
less_toxic(kk1,v1).
less_toxic(n1,t1).
less_toxic(b1,d1).
less_toxic(o1,a1).
less_toxic(b1,aa1).
less_toxic(f1,d1).
less_toxic(j1,i1).
less_toxic(n1,aa1).
less_toxic(n1,u1).
less_toxic(o1,i1).
less_toxic(o1,e1).
less_toxic(w1,v1).
less_toxic(ff1,t1).
less_toxic(cc1,z1).
less_toxic(g1,l1).
less_toxic(o1,l1).
less_toxic(y1,p1).
less_toxic(ii1,t1).
less_toxic(x1,f1).
less_toxic(hh1,aa1).
less_toxic(bb1,h1).
less_toxic(hh1,e1).
less_toxic(k1,cc1).
less_toxic(m1,b1).
less_toxic(kk1,z1).
less_toxic(ee1,e1).
less_toxic(s1,t1).
less_toxic(o1,d1).
less_toxic(ll1,jj1).
less_toxic(r1,l1).
less_toxic(ff1,e1).
less_toxic(i1,c1).
less_toxic(g1,jj1).
less_toxic(bb1,dd1).
less_toxic(ff1,d1).
less_toxic(w1,h1).
less_toxic(a1,p1).
less_toxic(p1,c1).
less_toxic(j1,b1).
less_toxic(ee1,u1).
less_toxic(cc1,f1).
less_toxic(ll1,l1).
less_toxic(ff1,w1).
less_toxic(f1,c1).
less_toxic(j1,c1).
less_toxic(g1,aa1).
less_toxic(n1,f1).
less_toxic(x1,l1).
less_toxic(b1,u1).
less_toxic(kk1,c1).
less_toxic(cc1,u1).
less_toxic(o1,w1).
less_toxic(y1,cc1).
less_toxic(ee1,t1).
less_toxic(b1,h1).
less_toxic(ee1,h1).
less_toxic(b1,p1).
less_toxic(x1,cc1).
less_toxic(ee1,dd1).
less_toxic(j1,u1).
less_toxic(x1,v1).
less_toxic(o1,u1).
less_toxic(r1,cc1).
less_toxic(j1,t1).
less_toxic(g1,v1).
less_toxic(x1,u1).
less_toxic(e1,p1).
less_toxic(w1,dd1).
less_toxic(ff1,a1).
less_toxic(bb1,w1).
less_toxic(ff1,aa1).
less_toxic(bb1,v1).
less_toxic(r1,z1).
less_toxic(bb1,d1).
less_toxic(ll1,cc1).
less_toxic(y1,u1).
less_toxic(s1,i1).
less_toxic(k1,t1).
less_toxic(kk1,cc1).
less_toxic(o1,p1).
less_toxic(k1,e1).
less_toxic(y1,t1).
less_toxic(n1,v1).
less_toxic(ii1,i1).
less_toxic(o1,v1).
less_toxic(ee1,p1).
less_toxic(x1,dd1).
less_toxic(l1,f1).
less_toxic(x1,aa1).
less_toxic(j1,z1).
less_toxic(j1,l1).
less_toxic(a1,d1).
less_toxic(cc1,aa1).
less_toxic(hh1,u1).
less_toxic(ff1,b1).
less_toxic(s1,z1).
less_toxic(r1,u1).
less_toxic(ee1,d1).
less_toxic(n1,jj1).
less_toxic(y1,a1).
less_toxic(s1,a1).
less_toxic(hh1,dd1).
less_toxic(ff1,p1).
less_toxic(o1,cc1).
less_toxic(k1,h1).
less_toxic(w1,a1).
less_toxic(q1,z1).
less_toxic(q1,a1).
less_toxic(m1,c1).
less_toxic(kk1,w1).
less_toxic(ff1,z1).
less_toxic(cc1,t1).
less_toxic(u1,d1).
less_toxic(b1,e1).
less_toxic(ll1,f1).
less_toxic(kk1,l1).
less_toxic(r1,t1).
less_toxic(ll1,h1).
less_toxic(cc1,jj1).
less_toxic(hh1,t1).
less_toxic(q1,cc1).
less_toxic(ll1,w1).
less_toxic(ii1,aa1).
less_toxic(g1,u1).
less_toxic(ii1,c1).
less_toxic(ff1,dd1).
less_toxic(hh1,l1).
less_toxic(m1,e1).
less_toxic(ee1,v1).
less_toxic(bb1,u1).
less_toxic(j1,d1).
less_toxic(g1,dd1).
less_toxic(ii1,a1).
less_toxic(y1,dd1).
less_toxic(q1,aa1).
less_toxic(ii1,e1).
less_toxic(k1,a1).
less_toxic(cc1,i1).
less_toxic(kk1,p1).
less_toxic(s1,b1).
less_toxic(ee1,cc1).
less_toxic(x1,z1).
less_toxic(x1,t1).
less_toxic(r1,e1).
less_toxic(y1,f1).
less_toxic(o1,aa1).
less_toxic(ee1,w1).
less_toxic(bb1,a1).
less_toxic(o1,t1).
less_toxic(n1,h1).
less_toxic(k1,l1).
less_toxic(ll1,i1).
less_toxic(k1,b1).
less_toxic(q1,t1).
less_toxic(k1,p1).
less_toxic(b1,t1).
less_toxic(q1,f1).
less_toxic(dd1,d1).
less_toxic(l1,c1).
less_toxic(w1,f1).
less_toxic(ii1,b1).
less_toxic(kk1,t1).
less_toxic(ii1,w1).
less_toxic(g1,h1).
less_toxic(bb1,c1).
less_toxic(u1,c1).
less_toxic(y1,d1).
less_toxic(n1,dd1).
less_toxic(b1,v1).
less_toxic(aa1,c1).
less_toxic(hh1,h1).
less_toxic(s1,p1).
less_toxic(g1,t1).
less_toxic(y1,b1).
less_toxic(n1,z1).
less_toxic(hh1,z1).
less_toxic(ll1,c1).
less_toxic(e1,d1).
less_toxic(r1,dd1).
less_toxic(cc1,dd1).
less_toxic(w1,d1).
less_toxic(y1,v1).
less_toxic(jj1,c1).
less_toxic(r1,h1).
less_toxic(hh1,c1).
less_toxic(s1,d1).
less_toxic(b1,c1).
less_toxic(q1,w1).
less_toxic(jj1,d1).
less_toxic(a1,c1).
less_toxic(m1,f1).
less_toxic(s1,jj1).
less_toxic(k1,d1).
less_toxic(hh1,v1).
less_toxic(bb1,f1).
less_toxic(r1,aa1).
less_toxic(ee1,i1).
less_toxic(j1,a1).
less_toxic(m1,d1).
less_toxic(n1,w1).
less_toxic(v1,c1).
less_toxic(j1,e1).
less_toxic(cc1,c1).
less_toxic(aa1,p1).
less_toxic(ii1,u1).
less_toxic(m1,dd1).
less_toxic(k1,u1).
less_toxic(cc1,e1).
less_toxic(ee1,aa1).
less_toxic(hh1,p1).
less_toxic(v1,d1).
less_toxic(x1,a1).
less_toxic(x1,b1).
less_toxic(l1,d1).
less_toxic(y1,w1).
less_toxic(r1,d1).
less_toxic(x1,e1).
less_toxic(u1,f1).
less_toxic(n1,p1).
less_toxic(w1,z1).
less_toxic(r1,a1).
less_toxic(x1,jj1).
less_toxic(j1,p1).
less_toxic(s1,aa1).
less_toxic(ll1,aa1).
less_toxic(ll1,e1).
less_toxic(s1,w1).
less_toxic(m1,jj1).
less_toxic(cc1,v1).
less_toxic(kk1,i1).
less_toxic(t1,f1).
less_toxic(w1,l1).
less_toxic(n1,d1).
less_toxic(r1,b1).
less_toxic(dd1,p1).
less_toxic(kk1,d1).
less_toxic(m1,a1).
less_toxic(ll1,z1).
less_toxic(g1,w1).
less_toxic(kk1,u1).
less_toxic(k1,jj1).
less_toxic(t1,p1).
less_toxic(h1,c1).
less_toxic(cc1,p1).
less_toxic(y1,l1).
less_toxic(y1,jj1).
less_toxic(w1,jj1).
less_toxic(j1,v1).
less_toxic(ll1,p1).
less_toxic(w1,p1).
less_toxic(k1,i1).
less_toxic(s1,dd1).
less_toxic(n1,a1).
less_toxic(s1,l1).
less_toxic(q1,p1).
less_toxic(s1,f1).
less_toxic(r1,v1).
less_toxic(aa1,d1).
less_toxic(x1,w1).
less_toxic(ii1,dd1).
less_toxic(bb1,p1).
less_toxic(n1,c1).
less_toxic(ff1,i1).
less_toxic(p1,f1).
less_toxic(hh1,jj1).
less_toxic(b1,dd1).
less_toxic(q1,e1).
less_toxic(ll1,a1).
less_toxic(v1,p1).
less_toxic(r1,i1).
less_toxic(n1,b1).
less_toxic(ee1,c1).
less_toxic(r1,jj1).
less_toxic(hh1,d1).
less_toxic(x1,d1).
less_toxic(b1,z1).
less_toxic(g1,c1).
less_toxic(m1,aa1).
less_toxic(ii1,v1).
less_toxic(bb1,t1).
less_toxic(n1,e1).
less_toxic(b1,f1).
less_toxic(ii1,z1).
less_toxic(hh1,f1).
less_toxic(ff1,u1).
less_toxic(kk1,dd1).
less_toxic(ii1,p1).
less_toxic(j1,jj1).
less_toxic(g1,b1).
less_toxic(aa1,f1).
less_toxic(g1,i1).
less_toxic(i1,f1).
less_toxic(q1,b1).
less_toxic(r1,f1).
less_toxic(ff1,cc1).
less_toxic(m1,u1).
less_toxic(g1,d1).
less_toxic(y1,z1).
less_toxic(ii1,d1).
less_toxic(hh1,a1).
less_toxic(n1,l1).
less_toxic(j1,w1).
less_toxic(s1,h1).
less_toxic(t1,d1).
less_toxic(q1,v1).
less_toxic(ee1,z1).
less_toxic(o1,dd1).
less_toxic(z1,d1).
less_toxic(bb1,jj1).
less_toxic(y1,aa1).
less_toxic(w1,kk1).
less_toxic(v1,x1).
less_toxic(f1,ee1).
less_toxic(dd1,ll1).
less_toxic(t1,q1).
less_toxic(cc1,g1).
less_toxic(h1,q1).
less_toxic(i1,o1).
less_toxic(h1,ff1).
less_toxic(f1,m1).
less_toxic(d1,k1).
less_toxic(f1,i1).
less_toxic(jj1,kk1).
less_toxic(d1,p1).
less_toxic(h1,b1).
less_toxic(u1,ff1).
less_toxic(a1,ii1).
less_toxic(l1,ii1).
less_toxic(a1,g1).
less_toxic(e1,ii1).
less_toxic(e1,j1).
less_toxic(i1,cc1).
less_toxic(p1,g1).
less_toxic(cc1,m1).
less_toxic(d1,ff1).
less_toxic(w1,y1).
less_toxic(c1,h1).
less_toxic(p1,i1).
less_toxic(u1,kk1).
less_toxic(cc1,k1).
less_toxic(l1,j1).
less_toxic(d1,dd1).
less_toxic(p1,z1).
less_toxic(b1,y1).
less_toxic(d1,ee1).
less_toxic(t1,bb1).
less_toxic(e1,kk1).
less_toxic(p1,m1).
less_toxic(p1,r1).
less_toxic(u1,bb1).
less_toxic(h1,m1).
less_toxic(z1,r1).
less_toxic(u1,b1).
less_toxic(u1,ii1).
less_toxic(b1,kk1).
less_toxic(z1,ll1).
less_toxic(a1,ll1).
less_toxic(p1,a1).
less_toxic(v1,kk1).
less_toxic(c1,m1).
less_toxic(c1,s1).
less_toxic(i1,j1).
less_toxic(t1,w1).
less_toxic(t1,r1).
less_toxic(v1,j1).
less_toxic(f1,q1).
less_toxic(dd1,n1).
less_toxic(aa1,b1).
less_toxic(f1,k1).
less_toxic(f1,cc1).
less_toxic(jj1,s1).
less_toxic(jj1,g1).
less_toxic(e1,k1).
less_toxic(e1,ff1).
less_toxic(f1,u1).
less_toxic(jj1,y1).
less_toxic(w1,n1).
less_toxic(f1,p1).
less_toxic(dd1,bb1).
less_toxic(a1,q1).
less_toxic(e1,b1).
less_toxic(cc1,s1).
| foldsCreator/files/datasets/alzheimer_toxic_0.2noisy/train9.f |
*----------------------------------------------------------------------*
subroutine print_op_info(lulog,modestr,op_info)
*----------------------------------------------------------------------*
implicit none
include 'mdef_operator_info.h'
integer, intent(in) ::
& lulog
character(*), intent(in) ::
& modestr
type(operator_info), intent(in) ::
& op_info
integer ::
& idx
type(operator_array), pointer ::
& op_arr(:)
type(me_list_array), pointer ::
& mel_arr(:)
select case(trim(modestr))
case('op','ops','operator','operators')
op_arr => op_info%op_arr
write(lulog,*) 'Number of operators defined: ',op_info%nops
write(lulog,'(x,40("-"))')
write(lulog,*)
& ' idx op vtx blk current list'
write(lulog,'(x,40("-"))')
do idx = 1, op_info%nops
write(lulog,'(2x,i3,a8,3x,i1,2x,i2,2x,a16)')
& idx,trim(op_arr(idx)%op%name),
& op_arr(idx)%op%njoined, op_arr(idx)%op%n_occ_cls,
& trim(op_arr(idx)%op%assoc_list)
end do
write(lulog,'(x,40("-"))')
case('mel','me_list','lists','ME-lists')
mel_arr => op_info%mel_arr
write(lulog,*) 'Number of lists defined: ',op_info%nmels
write(lulog,'(x,78("-"))')
write(lulog,*)
& ' idx list sym spn length op. '//
& ' file'
write(lulog,'(x,78("-"))')
do idx = 1, op_info%nmels
if (associated(mel_arr(idx)%mel%fhand)) then
write(lulog,'(2x,i3,a16,2x,i1,x,i2,x,i12,x,a8,x,a29)')
& idx,trim(mel_arr(idx)%mel%label),
& mel_arr(idx)%mel%gamt,
& mel_arr(idx)%mel%mst,
& mel_arr(idx)%mel%len_op,
& trim(mel_arr(idx)%mel%op%name),
& trim(mel_arr(idx)%mel%fhand%name)
else
write(lulog,'(2x,i3,a16,2x,i1,x,i2,x,i12,a8)')
& idx,trim(mel_arr(idx)%mel%label),
& mel_arr(idx)%mel%gamt,
& mel_arr(idx)%mel%mst,
& mel_arr(idx)%mel%len_op,
& trim(mel_arr(idx)%mel%op%name)
end if
end do
write(lulog,'(x,78("-"))')
end select
return
end
| operators/print_op_info.f |
!! Copyright (C) Stichting Deltares, 2012-2016.
!!
!! This program is free software: you can redistribute it and/or modify
!! it under the terms of the GNU General Public License version 3,
!! as published by the Free Software Foundation.
!!
!! This program is distributed in the hope that it will be useful,
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!! GNU General Public License for more details.
!!
!! You should have received a copy of the GNU General Public License
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
!!
!! contact: [email protected]
!! Stichting Deltares
!! P.O. Box 177
!! 2600 MH Delft, The Netherlands
!!
!! All indications and logos of, and references to registered trademarks
!! of Stichting Deltares remain the property of Stichting Deltares. All
!! rights reserved.
subroutine read_sub_procgrid( notot , syname , GridPs , isysg , ierr )
! Deltares Software Centre
!>\file
!> read the SUBSTANCE_PROCESSGRID information and update the isysg array
!>
!> several input possibilities exist:
!> - ALL indicates that all substances should work on the grid that will be mentioned
!> - a series of substances IDs indicating that those will work on the mentioned grid
!> then a grid name is required, to specify the grid where the substances work on.
! Created : Somewhere 2003 by Jan van Beek as layerd bed special
! Modified : May 2011 by Leo Postma merge with standard version
! global declarations
use grids
use rd_token ! for the reading of tokens
use timers ! performance timers
implicit none
! declaration of arguments
integer , intent(in ) :: notot !< nr of substances
character(20) , intent(in ) :: syname(notot) !< substance names
type(GridPointerColl) , intent(in ) :: GridPs !< collection of all grid definitions
integer , intent(inout) :: isysg (notot) !< process gridnr of substances
integer , intent(inout) :: ierr !< cummulative error count
! local declarations
integer :: itoken ! integer token from input
integer :: idummy ! dummy which content is not used
real :: adummy ! dummy which content is not used
character(len=255) :: ctoken ! character token from input
character :: cdummy ! dummy which content is not used
integer :: itype ! type of input to be needded
integer :: ierr2 ! local error indication
integer :: sysused(notot) ! work array substance selection
integer :: isys ! index substance
integer :: i_grid ! index grid in collection
integer(4) :: ithndl = 0
if (timon) call timstrt( "read_sub_procgrid", ithndl )
! some init
sysused = 0
write ( lunut , 2000 )
! read input
do
if ( gettoken( ctoken, ierr2 ) .gt. 0 ) goto 1000
select case (ctoken)
case ('ALL') ! use all substances
sysused = 1
write ( lunut , 2030 )
case default
call zoek( ctoken, notot, syname, 20, isys ) ! use this substance
if ( isys .gt. 0 ) then
sysused(isys) = 1
write ( lunut , 2040 ) syname(isys)
else
i_grid = gridpointercollfind( GridPs, ctoken )
if ( i_grid .gt. 0 ) then ! use this grid, input is ready
write ( lunut , 2050 ) trim(ctoken)
exit
else ! unrecognised token
write ( lunut , 2020 ) trim(ctoken)
goto 1000
endif
endif
end select
enddo
! update the isysg array for all substances used in this block
do isys = 1 , notot
if ( sysused(isys) .eq. 1 ) isysg(isys) = i_grid
enddo
if (timon) call timstop( ithndl )
return
1000 write ( lunut, 2010 )
ierr = ierr + 1
if (timon) call timstop( ithndl )
return
2000 format (/' Reading SUBSTANCE_PROCESSGRID information:')
2010 format ( ' ERROR, reading SUBSTANCE_PROCESSGRID information.')
2020 format ( ' ERROR, unrecognized token: ',A)
2030 format ( ' Processgrid will be used for ALL substances')
2040 format ( ' Processgrid will be used for substance: ',A)
2050 format ( ' Processgrid for these substances is: ',A)
end
| docker/water/delft3d/tags/v6686/src/engines_gpl/waq/packages/waq_io/src/waq_io/read_sub_procgrid.f |
MODULE caldyn_gcm_mod
use mod_misc
PRIVATE
TYPE(t_message) :: req_ps, req_mass, req_theta_rhodz, req_u, req_qu
public compute_caldyn_vert
CONTAINS
SUBROUTINE compute_caldyn_vert(u,theta,rhodz,convm, wflux,wwuu, dps,dtheta_rhodz,du)
use prec
use mod_misc
IMPLICIT NONE
REAL(rstd),INTENT(IN) :: u(iim*3*jjm,llm)
REAL(rstd),INTENT(IN) :: theta(iim*jjm,llm)
REAL(rstd),INTENT(IN) :: rhodz(iim*jjm,llm)
REAL(rstd),INTENT(INOUT) :: convm(iim*jjm,llm) ! mass flux convergence
REAL(rstd),INTENT(INOUT) :: wflux(iim*jjm,llm+1) ! vertical mass flux (kg/m2/s)
REAL(rstd),INTENT(INOUT) :: wwuu(iim*3*jjm,llm+1)
REAL(rstd),INTENT(INOUT) :: du(iim*3*jjm,llm)
REAL(rstd),INTENT(INOUT) :: dtheta_rhodz(iim*jjm,llm)
REAL(rstd),INTENT(INOUT) :: dps(iim*jjm)
! temporary variable
INTEGER :: i,j,ij,l
REAL(rstd) :: p_ik, exner_ik
!!$!!$KERN INTEGER,SAVE ::ij_omp_begin, ij_omp_end
!!$!!$KERN!$OMP THREADPRIVATE(ij_omp_begin, ij_omp_end)
!!$!!$KERN LOGICAL,SAVE :: first=.TRUE.
LOGICAL,SAVE :: first=.false.
!$OMP THREADPRIVATE(first)
CALL trace_start("compute_geopot")
!!$!!##KERNEL: this section is never called when kernelize.
!!$!!$KERN IF (first) THEN
!!$!!$KERN first=.FALSE.
!!$!!$KERN CALL distrib_level(ij_end-ij_begin+1,ij_omp_begin,ij_omp_end)
!!$!!$KERN ij_omp_begin=ij_omp_begin+ij_begin-1
!!$!!$KERN ij_omp_end=ij_omp_end+ij_begin-1
!!$!!$KERN ENDIF
! REAL(rstd) :: wwuu(iim*3*jjm,llm+1) ! tmp var, don't know why but gain 30% on the whole code in opemp
! need to be understood
! wwuu=wwuu_out
CALL trace_start("compute_caldyn_vert")
!$OMP BARRIER
!!! cumulate mass flux convergence from top to bottom
! IF (is_omp_level_master) THEN
DO l = llm-1, 1, -1
! IF (caldyn_conserv==energy) CALL test_message(req_qu)
!!$OMP DO SCHEDULE(STATIC)
!DIR$ SIMD
DO ij=ij_omp_begin,ij_omp_end
convm(ij,l) = convm(ij,l) + convm(ij,l+1)
ENDDO
ENDDO
! ENDIF
!$OMP BARRIER
! FLUSH on convm
!!!!!!!!!!!!!!!!!!!!!!!!!
! compute dps
IF (is_omp_first_level) THEN
!DIR$ SIMD
DO ij=ij_begin,ij_end
! dps/dt = -int(div flux)dz
dps(ij) = convm(ij,1) * g
ENDDO
ENDIF
!!! Compute vertical mass flux (l=1,llm+1 done by caldyn_BC)
DO l=ll_beginp1,ll_end
! IF (caldyn_conserv==energy) CALL test_message(req_qu)
!DIR$ SIMD
DO ij=ij_begin,ij_end
! w = int(z,ztop,div(flux)dz) + B(eta)dps/dt
! => w>0 for upward transport
wflux( ij, l ) = bp(l) * convm( ij, 1 ) - convm( ij, l )
ENDDO
ENDDO
!--> flush wflux
!$OMP BARRIER
DO l=ll_begin,ll_endm1
!DIR$ SIMD
DO ij=ij_begin,ij_end
dtheta_rhodz(ij, l ) = dtheta_rhodz(ij, l ) - 0.5 * ( wflux(ij,l+1) * (theta(ij,l) + theta(ij,l+1)))
ENDDO
ENDDO
DO l=ll_beginp1,ll_end
!DIR$ SIMD
DO ij=ij_begin,ij_end
dtheta_rhodz(ij, l ) = dtheta_rhodz(ij, l ) + 0.5 * ( wflux(ij,l ) * (theta(ij,l-1) + theta(ij,l) ) )
ENDDO
ENDDO
! Compute vertical transport
DO l=ll_beginp1,ll_end
!DIR$ SIMD
DO ij=ij_begin,ij_end
wwuu(ij+u_right,l) = 0.5*( wflux(ij,l) + wflux(ij+t_right,l)) * (u(ij+u_right,l) - u(ij+u_right,l-1))
wwuu(ij+u_lup,l) = 0.5* ( wflux(ij,l) + wflux(ij+t_lup,l)) * (u(ij+u_lup,l) - u(ij+u_lup,l-1))
wwuu(ij+u_ldown,l) = 0.5*( wflux(ij,l) + wflux(ij+t_ldown,l)) * (u(ij+u_ldown,l) - u(ij+u_ldown,l-1))
ENDDO
ENDDO
!--> flush wwuu
!$OMP BARRIER
! Add vertical transport to du
DO l=ll_begin,ll_end
!DIR$ SIMD
DO ij=ij_begin,ij_end
du(ij+u_right, l ) = du(ij+u_right,l) - (wwuu(ij+u_right,l+1)+ wwuu(ij+u_right,l)) / (rhodz(ij,l)+rhodz(ij+t_right,l))
du(ij+u_lup, l ) = du(ij+u_lup,l) - (wwuu(ij+u_lup,l+1) + wwuu(ij+u_lup,l)) / (rhodz(ij,l)+rhodz(ij+t_lup,l))
du(ij+u_ldown, l ) = du(ij+u_ldown,l) - (wwuu(ij+u_ldown,l+1)+ wwuu(ij+u_ldown,l)) / (rhodz(ij,l)+rhodz(ij+t_ldown,l))
ENDDO
ENDDO
! DO l=ll_beginp1,ll_end
!!DIR$ SIMD
! DO ij=ij_begin,ij_end
! wwuu_out(ij+u_right,l) = wwuu(ij+u_right,l)
! wwuu_out(ij+u_lup,l) = wwuu(ij+u_lup,l)
! wwuu_out(ij+u_ldown,l) = wwuu(ij+u_ldown,l)
! ENDDO
! ENDDO
CALL trace_end("compute_caldyn_vert")
END SUBROUTINE compute_caldyn_vert
END MODULE caldyn_gcm_mod
| kernels/DYNAMICO/comp_caldyn_vert/src/caldyn_gcm.f90 |
module occa_base_m
! occa/c/base.h
use occa_types_m
implicit none
interface
! ---[ Globals & Flags ]----------------
! occaProperties occaSettings();
type(occaProperties) function occaSettings() bind(C, name="occaSettings")
import occaProperties
end function
! void occaPrintModeInfo();
pure subroutine occaPrintModeInfo() bind(C, name="occaPrintModeInfo")
end subroutine
! ======================================
! ---[ Device ]-------------------------
! occaDevice occaHost();
type(occaDevice) function occaHost() bind(C, name="occaHost")
import occaDevice
end function
! occaDevice occaGetDevice();
type(occaDevice) function occaGetDevice() bind(C, name="occaGetDevice")
import occaDevice
end function
! void occaSetDevice(occaDevice device);
subroutine occaSetDevice(device) bind(C, name="occaSetDevice")
import occaDevice
implicit none
type(occaDevice), value :: device
end subroutine
! void occaSetDeviceFromString(const char *info);
subroutine occaSetDeviceFromString(info) &
bind(C, name="occaSetDeviceFromString")
import C_char
implicit none
character(len=1,kind=C_char), dimension(*), intent(in) :: info
end subroutine
! occaProperties occaDeviceProperties();
type(occaProperties) function occaDeviceProperties() &
bind(C, name="occaDeviceProperties")
import occaProperties
end function
! void occaLoadKernels(const char *library);
subroutine occaLoadKernels(library) bind(C, name="occaLoadKernels")
import C_char
implicit none
character(len=1,kind=C_char), dimension(*), intent(in) :: library
end subroutine
! void occaFinish();
subroutine occaFinish() bind(C, name="occaFinish")
end subroutine
! occaStream occaCreateStream(occaProperties props);
type(occaStream) function occaCreateStream(props) &
bind(C, name="occaCreateStream")
import occaStream, occaProperties
implicit none
type(occaProperties), value :: props
end function
! occaStream occaGetStream();
type(occaStream) function occaGetStream() bind(C, name="occaGetStream")
import occaStream
end function
! void occaSetStream(occaStream stream);
subroutine occaSetStream(stream) bind(C, name="occaSetStream")
import occaStream
implicit none
type(occaStream), value :: stream
end subroutine
! occaStreamTag occaTagStream();
type(occaStreamTag) function occaTagStream() bind(C, name="occaTagStream")
import occaStreamTag
end function
! void occaWaitForTag(occaStreamTag tag);
subroutine occaWaitForTag(tag) bind(C, name="occaWaitForTag")
import occaStreamTag
implicit none
type(occaStreamTag), value :: tag
end subroutine
! double occaTimeBetweenTags(occaStreamTag startTag, occaStreamTag endTag);
real(C_double) function occaTimeBetweenTags(startTag, endTag) &
bind(C, name="occaTimeBetweenTags")
import occaStreamTag, C_double
implicit none
type(occaStreamTag), value :: startTag, endTag
end function
! ======================================
! ---[ Kernel ]-------------------------
! occaKernel occaBuildKernel(const char *filename,
! const char *kernelName,
! const occaProperties props);
type(occaKernel) function occaBuildKernel(filename, &
kernelName, &
props) &
bind(C, name="occaBuildKernel")
import C_char, occaKernel, occaProperties
implicit none
character(len=1,kind=C_char), dimension(*), intent(in) :: filename, &
kernelName
type(occaProperties), value, intent(in) :: props
end function
! occaKernel occaBuildKernelFromString(const char *source,
! const char *kernelName,
! const occaProperties props);
type(occaKernel) function occaBuildKernelFromString(str, &
kernelName, &
props) &
bind(C, name="occaBuildKernelFromString")
import C_char, occaKernel, occaProperties
implicit none
character(len=1,kind=C_char), dimension(*), intent(in) :: str, &
kernelName
type(occaProperties), value, intent(in) :: props
end function
! occaKernel occaBuildKernelFromBinary(const char *filename,
! const char *kernelName,
! const occaProperties props);
type(occaKernel) function occaBuildKernelFromBinary(filename, &
kernelName, &
props) &
bind(C, name="occaBuildKernelFromBinary")
import C_char, occaKernel, occaProperties
implicit none
character(len=1,kind=C_char), dimension(*), intent(in) :: filename, &
kernelName
type(occaProperties), value, intent(in) :: props
end function
! ======================================
! ---[ Memory ]-------------------------
! occaMemory occaMalloc(const occaUDim_t bytes,
! const void *src,
! occaProperties props);
type(occaMemory) function occaMalloc(bytes, src, props) &
bind(C, name="occaMalloc")
import occaMemory, occaUDim_t, C_void_ptr, occaProperties
implicit none
integer(occaUDim_t), value, intent(in) :: bytes
type(C_void_ptr), value, intent(in) :: src
type(occaProperties), value :: props
end function
! occaMemory occaTypedMalloc(const occaUDim_t entries,
! const occaDtype type,
! const void *src,
! occaProperties props);
type(occaMemory) function occaTypedMalloc(entries, type, src, props) &
bind(C, name="occaTypedMalloc")
import occaMemory, occaUDim_t, occaDtype, C_void_ptr, occaProperties
implicit none
integer(occaUDim_t), value, intent(in) :: entries
type(occaDtype), value, intent(in) :: type
type(C_void_ptr), value, intent(in) :: src
type(occaProperties), value :: props
end function
! void* occaUMalloc(const occaUDim_t bytes,
! const void *src,
! occaProperties props);
type(C_void_ptr) function occaUMalloc(bytes, src, props) &
bind(C, name="occaUMalloc")
import occaUDim_t, C_void_ptr, occaProperties
implicit none
integer(occaUDim_t), value, intent(in) :: bytes
type(C_void_ptr), value, intent(in) :: src
type(occaProperties), value :: props
end function
! void* occaTypedUMalloc(const occaUDim_t entries,
! const occaDtype type,
! const void *src,
! occaProperties props);
type(C_void_ptr) function occaTypedUMalloc(entries, type, src, props) &
bind(C, name="occaTypedUMalloc")
import occaUDim_t, occaDtype, C_void_ptr, occaProperties
implicit none
integer(occaUDim_t), value, intent(in) :: entries
type(occaDtype), value, intent(in) :: type
type(C_void_ptr), value, intent(in) :: src
type(occaProperties), value :: props
end function
! ======================================
end interface
end module occa_base_m
| src/fortran/occa_base_m.f90 |
module stpvwnd10mmod
!$$$ module documentation block
! . . . .
! module: stpvwnd10mmod module for stpvwnd10m
! prgmmr:
!
! abstract: module for stpvwnd10m
!
! program history log:
! 2016-05-05 pondeca
! 2017-03-19 yang - modify code to use polymorphic obsNode
!
! subroutines included:
! sub stpvwnd10m
!
! attributes:
! language: f90
! machine:
!
!$$$ end documentation block
use m_obsNode , only: obsNode
use m_vwnd10mNode, only: vwnd10mNode
use m_vwnd10mNode, only: vwnd10mNode_typecast
use m_vwnd10mNode, only: vwnd10mNode_nextcast
implicit none
PRIVATE
PUBLIC stpvwnd10m
contains
subroutine stpvwnd10m(vwnd10mhead,rval,sval,out,sges,nstep)
!$$$ subprogram documentation block
! . . . .
! subprogram: stpvwnd10m calculate penalty and contribution to stepsize
!
! abstract: calculate penalty and contribution to stepsize for 10m-vwind
! with addition of nonlinear qc
!
! program history log:
! 2016-05-05 pondeca
!
! input argument list:
! vwnd10mhead
! rvwnd10m - search direction for vwnd10m
! svwnd10m - analysis increment for vwnd10m
! sges - step size estimate (nstep)
! nstep - number of stepsizes (==0 means use outer iteration values)
!
! output argument list:
! out(1:nstep) - contribution to penalty for conventional vwnd10m - sges(1:nstep)
!
! attributes:
! language: f90
! machine: ibm RS/6000 SP
!
!$$$
use kinds, only: r_kind,i_kind,r_quad
use qcmod, only: nlnqc_iter,varqc_iter
use constants, only: half,one,two,tiny_r_kind,cg_term,zero_quad
use gsi_bundlemod, only: gsi_bundle
use gsi_bundlemod, only: gsi_bundlegetpointer
implicit none
! Declare passed variables
class(obsNode),pointer ,intent(in ) :: vwnd10mhead
integer(i_kind) ,intent(in ) :: nstep
real(r_quad),dimension(max(1,nstep)),intent(inout) :: out
type(gsi_bundle) ,intent(in ) :: rval,sval
real(r_kind),dimension(max(1,nstep)),intent(in ) :: sges
! Declare local variables
integer(i_kind) j1,j2,j3,j4,kk,ier,istatus
real(r_kind) w1,w2,w3,w4
real(r_kind) val,val2
real(r_kind) cg_vwnd10m,vwnd10m,wgross,wnotgross
real(r_kind),dimension(max(1,nstep)):: pen
real(r_kind) pg_vwnd10m
real(r_kind),pointer,dimension(:) :: svwnd10m
real(r_kind),pointer,dimension(:) :: rvwnd10m
type(vwnd10mNode), pointer :: vwnd10mptr
out=zero_quad
! If no vwnd10m data return
if(.not. associated(vwnd10mhead))return
! Retrieve pointers
! Simply return if any pointer not found
ier=0
call gsi_bundlegetpointer(sval,'vwnd10m',svwnd10m,istatus);ier=istatus+ier
call gsi_bundlegetpointer(rval,'vwnd10m',rvwnd10m,istatus);ier=istatus+ier
if(ier/=0)return
! vwnd10mptr => vwnd10mhead
vwnd10mptr => vwnd10mNode_typecast(vwnd10mhead)
do while (associated(vwnd10mptr))
if(vwnd10mptr%luse)then
if(nstep > 0)then
j1=vwnd10mptr%ij(1)
j2=vwnd10mptr%ij(2)
j3=vwnd10mptr%ij(3)
j4=vwnd10mptr%ij(4)
w1=vwnd10mptr%wij(1)
w2=vwnd10mptr%wij(2)
w3=vwnd10mptr%wij(3)
w4=vwnd10mptr%wij(4)
val =w1*rvwnd10m(j1)+w2*rvwnd10m(j2)+w3*rvwnd10m(j3)+w4*rvwnd10m(j4)
val2=w1*svwnd10m(j1)+w2*svwnd10m(j2)+w3*svwnd10m(j3)+w4*svwnd10m(j4)-vwnd10mptr%res
do kk=1,nstep
vwnd10m=val2+sges(kk)*val
pen(kk)= vwnd10m*vwnd10m*vwnd10mptr%err2
end do
else
pen(1)=vwnd10mptr%res*vwnd10mptr%res*vwnd10mptr%err2
end if
! Modify penalty term if nonlinear QC
if (nlnqc_iter .and. vwnd10mptr%pg > tiny_r_kind .and. &
vwnd10mptr%b > tiny_r_kind) then
pg_vwnd10m=vwnd10mptr%pg*varqc_iter
cg_vwnd10m=cg_term/vwnd10mptr%b
wnotgross= one-pg_vwnd10m
wgross = pg_vwnd10m*cg_vwnd10m/wnotgross
do kk=1,max(1,nstep)
pen(kk)= -two*log((exp(-half*pen(kk)) + wgross)/(one+wgross))
end do
endif
out(1) = out(1)+pen(1)*vwnd10mptr%raterr2
do kk=2,nstep
out(kk) = out(kk)+(pen(kk)-pen(1))*vwnd10mptr%raterr2
end do
end if
! vwnd10mptr => vwnd10mptr%llpoint
vwnd10mptr => vwnd10mNode_nextcast(vwnd10mptr)
end do
return
end subroutine stpvwnd10m
end module stpvwnd10mmod
| GEOSaana_GridComp/GSI_GridComp/stpvwnd10m.f90 |
SUBROUTINE SFFTFU( X, Y, N, M, ITYPE )
c
c Decimation-in-time radix-2 split-radix complex FFT
c
c Arguments:
c X - real part of data sequence (in/out)
c Y - imag part of data sequence (in/out)
c N,M - integers such that N = 2**M (in)
c ITYPE - integer transform type (in)
c ITYPE .ne. -1 --> forward transform
c ITYPE .eq. -1 --> backward transform
c
c The forward transform computes
c X(k) = sum_{j=0}^{N-1} x(j)*exp(-2ijk*pi/N)
c
c The backward transform computes
c x(j) = (1/N) * sum_{k=0}^{N-1} X(k)*exp(2ijk*pi/N)
c
c
c Here is the original program header...
c
C-------------------------------------------------------------C
C A Duhamel-Hollman Split-Radix DIT FFT C
C Reference: Electronics Letters, January 5, 1984 C
C Complex input and output in data arrays X and Y C
C Length is N = 2**M C
C C
C H.V. Sorensen Rice University Dec 1984 C
C-------------------------------------------------------------C
c
c ... Scalar arguments ...
INTEGER N, M, ITYPE
c ... Array arguments ...
REAL X(*), Y(*)
c ... Local scalars ...
INTEGER I, J, K, N1, N2, N4, IS, ID, I0, I1, I2, I3
REAL TWOPI, A, A3, E, XT, R1, R2, R3, S1, S2
REAL CC1, CC3, SS1, SS3
c ... Parameters ...
PARAMETER ( TWOPI = 6.283185307179586476925287 )
c ... Intrinsic functions ...
INTRINSIC SIN, COS
c
c ... Exe. statements ...
c
c ... Quick return ...
IF ( N .EQ. 1 ) RETURN
c
c ... Conjugate if necessary ...
IF ( ITYPE .EQ. -1 ) THEN
DO 1, I = 1, N
Y(I) = - Y(I)
1 CONTINUE
ENDIF
c
c ... Bit reversal permutation ...
100 J = 1
N1 = N - 1
DO 104, I = 1, N1
IF ( I .GE. J ) GOTO 101
XT = X(J)
X(J) = X(I)
X(I) = XT
XT = Y(J)
Y(J) = Y(I)
Y(I) = XT
101 K = N / 2
102 IF ( K .GE. J ) GOTO 103
J = J - K
K = K / 2
GOTO 102
103 J = J + K
104 CONTINUE
c
c ... Length two transforms ...
IS = 1
ID = 4
70 DO 60, I0 = IS, N, ID
I1 = I0 + 1
R1 = X(I0)
X(I0) = R1 + X(I1)
X(I1) = R1 - X(I1)
R1 = Y(I0)
Y(I0) = R1 + Y(I1)
Y(I1) = R1 - Y(I1)
60 CONTINUE
IS = 2 * ID - 1
ID = 4 * ID
IF ( IS .LT. N ) GOTO 70
c
c ... L shaped butterflies ...
N2 = 2
DO 10, K = 2, M
N2 = N2 * 2
N4 = N2 / 4
E = TWOPI / N2
A = 0.0
DO 20, J = 1, N4
A3 = 3 * A
CC1 = COS( A )
SS1 = SIN( A )
CC3 = COS( A3 )
SS3 = SIN( A3 )
A = J * E
IS = J
ID = 2 * N2
40 DO 30, I0 = IS, N-1, ID
I1 = I0 + N4
I2 = I1 + N4
I3 = I2 + N4
R1 = X(I2) * CC1 + Y(I2) * SS1
S1 = Y(I2) * CC1 - X(I2) * SS1
R2 = X(I3) * CC3 + Y(I3) * SS3
S2 = Y(I3) * CC3 - X(I3) * SS3
R3 = R1 + R2
R2 = R1 - R2
R1 = S1 + S2
S2 = S1 - S2
X(I2) = X(I0) - R3
X(I0) = X(I0) + R3
X(I3) = X(I1) - S2
X(I1) = X(I1) + S2
Y(I2) = Y(I0) - R1
Y(I0) = Y(I0) + R1
Y(I3) = Y(I1) + R2
Y(I1) = Y(I1) - R2
30 CONTINUE
IS = 2 * ID - N2 + J
ID = 4 * ID
IF ( IS .LT. N ) GOTO 40
20 CONTINUE
10 CONTINUE
c
c ... Conjugate and normalize if necessary ...
IF ( ITYPE .EQ. -1 ) THEN
DO 2, I = 1, N
Y(I) = - Y(I) / N
X(I) = X(I) / N
2 CONTINUE
ENDIF
c
RETURN
c
c ... End of subroutine SFFTFU ...
c
END
| benchees/sorensen/sfftfu.f |
program t
integer,dimension(3)::i=(/1,2,3/)
where (i>1) i=i*2
print *,i
end program t
| tests/t0116x/t.f |
! Overload fill value functions
interface nf90_def_var_fill
module procedure nf90_def_var_fill_OneByteInt, &
nf90_def_var_fill_TwoByteInt, &
nf90_def_var_fill_FourByteInt, &
nf90_def_var_fill_EightByteInt, &
nf90_def_var_fill_FourByteReal, &
nf90_def_var_fill_EightByteReal
end interface
interface nf90_inq_var_fill
module procedure nf90_inq_var_fill_OneByteInt, &
nf90_inq_var_fill_TwoByteInt, &
nf90_inq_var_fill_FourByteInt, &
nf90_inq_var_fill_EightByteInt, &
nf90_inq_var_fill_FourByteReal, &
nf90_inq_var_fill_EightByteReal
end interface
| fortran/netcdf4_overloads.f90 |
Module mo_model
use mo_kind , only: dp, i4
implicit none
private
public :: getrange
public :: model
interface model
module procedure model_1d, model_0d
end interface model
! module variables
integer(i4) :: npara = 3
contains
function GetRange()
implicit none
real(dp), dimension(npara,2) :: GetRange ! min value and max value of parameter
real(dp), parameter :: my_pi = 3.141592653589793238462643383279502884197_dp
GetRange(1,:) = (/ -my_pi, my_pi /) ! min & max parameter 1
GetRange(2,:) = (/ -my_pi, my_pi /) ! min & max parameter 2
GetRange(3,:) = (/ -my_pi, my_pi /) ! min & max parameter 3
end function GetRange
function model_1d(paraset,x)
implicit none
real(dp), dimension(npara), intent(in) :: paraset ! parameter set
real(dp), dimension(:), intent(in) :: x ! variables
real(dp), dimension(size(x)) :: model_1d ! modeled output
! local variables
real(dp), parameter :: my_b = 2.0_dp
model_1d(:) = sin(paraset(1)) + x(:)*(sin(paraset(2)))**2 + my_b * paraset(3)**4 * sin(paraset(1))
end function model_1d
function model_0d(paraset,x)
implicit none
real(dp), dimension(npara), intent(in) :: paraset ! parameter set
real(dp), intent(in) :: x ! variables
real(dp) :: model_0d ! modeled output
! local variables
real(dp), parameter :: my_b = 2.0_dp
model_0d = sin(paraset(1)) + x*(sin(paraset(2)))**2 + my_b * paraset(3)**4 * sin(paraset(1))
end function model_0d
end Module mo_model
| test/test_mo_sobol_index/mo_model.f90 |
module constants
!==================================================================
! This module contains all the non-modifiable parameters and
! all quantities which never change throughout a simulation.
!==================================================================
!Import parameters:
use parameters
integer,parameter:: nxm1=nx-1, nym1=ny-1, nzm1=nz-1
!Generic double precision numerical constants:
double precision,parameter:: zero=0.d0, one=1.d0
double precision,parameter:: two=2.d0, three=3.d0
double precision,parameter:: four=4.d0, six=6.d0
double precision,parameter:: f12=one/two, f13=one/three, f14=one/four
double precision,parameter:: f16=one/six, f56=5.d0/six, f112=one/12.d0
double precision,parameter:: small=1.d-12, oms=one-small
!---------------------------------------------------------------------
!Domain half widths and edge values:
double precision,parameter:: hlx=ellx/two, hlxi=one/hlx, xmin=-hlx
double precision,parameter:: hly=elly/two, hlyi=one/hly, ymin=-hly
double precision,parameter:: zmin=-ellz/two, zmax=zmin+ellz
!Grid lengths and their inverses:
double precision,parameter:: dx=ellx/dble(nx), dxi=dble(nx)/(ellx*oms)
double precision,parameter:: dy=elly/dble(ny), dyi=dble(ny)/(elly*oms)
double precision,parameter:: dz=ellz/dble(nz), dzi=dble(nz)/(ellz*oms)
!Grid cell volume:
double precision,parameter:: vcell=dx*dy*dz
!---------------------------------------------------------------------
!Number of grid cells:
integer,parameter:: ncell=nx*ny*(nz+1)
end module
| merging_standalone/3d/constants.f90 |
module timeman
implicit none
CONTAINS
! print statements in this module use 1100-1200
!! time tracking funcs and subs
subroutine initialize_t1
!sets t1, the beginning of a new repetative operation
use timevars, only: t1
call cpu_time(t1)
end subroutine initialize_t1
subroutine timeupdate( chtype,ndone,ntotal )
!uses t1 and new t2 to give update on time for new repetative operation
use MCvars, only: numPartsperj
use timevars, only: t1
integer :: ndone,ntotal, orda,ordm
real(8) :: t2, ave,maxv,eps=0.0000000001d0
character(*) :: chtype
call cpu_time(t2)
if(chtype=='radMC' .or. chtype=='radWood' .or. chtype=='KLWood' .or. chtype=='GaussKL') then
1101 format(A9," ",f6.1,"% of ",i7," time/est:",f7.2,"/",f7.2," min h/r-ave/max: ",f3.1,"E",i1,"/",f3.1,"E",i1)
ave = real(sum(numPartsperj),8)/ndone+eps
orda= int(floor(log(ave)/log(10d0)*10.0)/10.0)
maxv= real(maxval(numPartsperj),8)+eps
ordm= int(floor(log(maxv)/log(10d0)))
write(*,1101) chtype,real(ndone,8)/ntotal*100d0,ntotal,(t2-t1)/60.0d0,(t2-t1)*ntotal/ndone/60.0d0, &
ave/(10.0**orda),orda,maxv/(10.0**ordm),ordm
else
1100 format(A9," ",f6.1,"% of ",i7," time/est:",f7.2,"/",f7.2," min")
write(*,1100) chtype,real(ndone,8)/ntotal*100d0,ntotal,(t2-t1)/60.0d0,(t2-t1)*ntotal/ndone/60.0d0
endif
end subroutine
end module timeman
| mods/timeman.f90 |
Describe Western ScreechOwl here.
There are several screech owls residing in Davis, The biggest and loudest so far appears to reside in East Davis near Poleline / Eighth (maybe he lives in cemetery)
SKREEEEEEEEEEEEEEEEEE Daubert
| lab/davisWiki/Western_Screech-Owl.f |
subroutine Curve2Mask(dhgrid, n, sampling, profile, nprofile, NP, &
centralmeridian, exitstatus)
!------------------------------------------------------------------------------
!
! Given a list of coordinates of a SINGLE CLOSED CURVE, this routine
! will fill the interior and exterior with 0s and 1s. The value at the
! north pole (either 0 or 1) is specified by the input parameter NP.
!
! Calling Parameters
!
! IN
! profile Latitude (:,1) and longitude (:,2) coordinates of a
! single close curve having dimension (nprofile, 2).
! nprofile Number of coordinates in the vector profile.
! np Value of the output function at the North Pole, which
! can be either 0 or 1.
! n Number of latitude bands in the output Driscoll and
! Healy sampled grid.
! sampling 1 sets the number of longitude bands equal to 1,
! whereas 2 sets the number to twice that of n.
! centralmeridian If 1, the curve is assumed to pass through the
! central meridian: passing from < 360 degrees
! to > 0 degrees. The curve makes a complete
! circle about the planet in longitude. default
! is zero.
!
! OUT
! dhgrid A Driscoll and Healy sampled grid specifiying whether
! the point is in the curve (1), or outside of it (0).
!
! OPTIONAL (OUT)
! exitstatus If present, instead of executing a STOP when an error
! is encountered, the variable exitstatus will be
! returned describing the error.
! 0 = No errors;
! 1 = Improper dimensions of input array;
! 2 = Improper bounds for input variable;
! 3 = Error allocating memory;
! 4 = File IO error.
!
! Copyright (c) 2005-2019, SHTOOLS
! All rights reserved.
!
!------------------------------------------------------------------------------
use ftypes
implicit none
integer, intent(out) :: dhgrid(:,:)
real(dp), intent(in) :: profile(:,:)
integer, intent(in) :: n, sampling, nprofile, np
integer, intent(in), optional :: centralmeridian
integer, intent(out), optional :: exitstatus
integer, parameter :: maxcross = 2000
integer :: i, j, k, k_loc, nlat, nlong, numcross, next, ind1, ind2, cm
real(dp) :: lat_int, long_int, lon, cross(maxcross), cross_sort(maxcross)
if (present(exitstatus)) exitstatus = 0
nlat = n
lat_int = 180.0_dp / dble(nlat)
dhgrid = 0
if (mod(n,2) /= 0) then
print*, "Error --- Curve2Mask"
print*, "N must be even"
print*, "N = ", n
if (present(exitstatus)) then
exitstatus = 2
return
else
stop
end if
end if
if (sampling == 1) then
nlong = nlat
long_int = 2.0_dp * lat_int
else if (sampling == 2) then
nlong = 2 * nlat
long_int = lat_int
else
print*, "Error --- Curve2Mask"
print*, "SAMPLING of DHGRID must be 1 (equally sampled) or 2 (equally spaced)."
print*, "SAMPLING = ", sampling
if (present(exitstatus)) then
exitstatus = 2
return
else
stop
end if
end if
if (NP /= 1 .and. NP /= 0) then
print*, "Error --- Curve2Mask"
print*, "NP must be 0 if the North pole is outside of curve,"
print*, "or 1 if the North pole is inside of the curve."
print*, "NP = ", np
if (present(exitstatus)) then
exitstatus = 2
return
else
stop
end if
end if
if (size(dhgrid(1,:)) < nlong .or. size(dhgrid(:,1)) < nlat ) then
print*, "Error --- Curve2Mask"
print*, "DHGRID must be dimensioned as (NLAT, NLONG)."
print*, "NLAT = ", nlat
print*, "NLONG = ", nlong
print*, "Size of GRID = ", size(dhgrid(:,1)), size(dhgrid(1,:))
if (present(exitstatus)) then
exitstatus = 1
return
else
stop
end if
end if
if (size(profile(:,1)) < nprofile .or. size(profile(1,:)) < 2) then
print*, "Error --- Curve2Mask"
print*, "PROFILE must be dimensioned as (NPROFILE, 2)."
print*, "Dimension of NPROFILE = ", size(profile(:,1)), &
size(profile(1,:))
if (present(exitstatus)) then
exitstatus = 1
return
else
stop
end if
end if
if (present(centralmeridian)) then
if (centralmeridian /= 0 .and. centralmeridian /= 1) then
print*, "Error --- Curve2Mask"
print*, "CENTRALMERIDIAN must be either 0 or 1."
print*, "Input value is ", centralmeridian
if (present(exitstatus)) then
exitstatus = 2
return
else
stop
end if
end if
cm = centralmeridian
else
cm = 0
end if
!--------------------------------------------------------------------------
!
! Start at 90N and 0E. Determine where the curve crosses this longitude
! band, sort the values, and then set the pixels between zero crossings
! to either 0 or 1.
!
!--------------------------------------------------------------------------
do j = 1, nlong
lon = dble(j-1) * long_int
numcross = 0
do i = 1, nprofile - 1
if (profile(i,2) <= lon .and. profile(i+1,2) > lon) then
numcross = numcross + 1
if (numcross > maxcross) then
print*, "Error --- Curve2Mask"
print*, "Internal variable MAXCROSS needs to be increased."
print*, "MAXCROSS = ", maxcross
if (present(exitstatus)) then
exitstatus = 5
return
else
stop
end if
end if
cross(numcross) = profile(i,1) + (profile(i+1,1)-profile(i,1)) &
/ (profile(i+1,2)-profile(i,2)) &
* (lon - profile(i,2))
else if (profile(i,2) > lon .and. profile(i+1,2) <= lon) then
numcross = numcross + 1
if (numcross > maxcross) then
print*, "Error --- Curve2Mask"
print*, "Internal variable MAXCROSS needs to be increased."
print*, "MAXCROSS = ", maxcross
if (present(exitstatus)) then
exitstatus = 5
return
else
stop
end if
end if
cross(numcross) = profile(i+1,1) + &
(profile(i,1)-profile(i+1,1)) / &
(profile(i,2)-profile(i+1,2)) &
* (lon - profile(i+1,2))
end if
end do
! do first and last points
if (cm == 0) then
if (profile(nprofile,2) <= lon .and. profile(1,2) > lon) then
numcross = numcross + 1
if (numcross > maxcross) then
print*, "Error --- Curve2Mask"
print*, "Internal variable MAXCROSS needs to be increased."
print*, "MAXCROSS = ", maxcross
if (present(exitstatus)) then
exitstatus = 5
return
else
stop
end if
end if
cross(numcross) = profile(nprofile,1) + &
(profile(1,1)-profile(nprofile,1)) / &
(profile(1,2)-profile(nprofile,2)) * &
(lon - profile(nprofile,2))
else if (profile(nprofile,2) > lon .and. profile(1,2) <= lon) then
numcross = numcross + 1
if (numcross > maxcross) then
print*, "Error --- Curve2Mask"
print*, "Internal variable MAXCROSS needs to be increased."
print*, "MAXCROSS = ", maxcross
if (present(exitstatus)) then
exitstatus = 5
return
else
stop
end if
end if
cross(numcross) = profile(1,1) + &
(profile(nprofile,1)-profile(1,1)) / &
(profile(nprofile,2)-profile(1,2)) &
* (lon - profile(1,2))
end if
end if
if (numcross > 0) then ! sort crossings by decreasing latitude
do k = 1, numcross
k_loc = maxloc(cross(1:numcross), 1)
cross_sort(k) = cross(k_loc)
cross(k_loc) = -999.0_dp
end do
end if
if (numcross == 0) then
dhgrid(1:nlat, j) = np
else if (numcross == 1) then
ind1 = int( (90.0_dp - cross_sort(1)) / lat_int) + 1
dhgrid(1:ind1, j) = np
if (ind1 == nlat) then
cycle
else if (np == 0) then
dhgrid(ind1+1:nlat, j) = 1
else
dhgrid(ind1+1:nlat, j) = 0
end if
else
ind1 = 1
next = np
do k = 1, numcross
ind2 = int( (90.0_dp - cross_sort(k)) / lat_int) + 1
if (ind2 >= ind1) dhgrid(ind1:ind2, j) = next
if (next == 0) then
next = 1
else
next = 0
end if
ind1 = ind2 + 1
end do
if (ind1 <= nlat) dhgrid(ind1:nlat, j) = next
end if
end do
end subroutine Curve2Mask
| src/Curve2Mask.f95 |
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 SMOGS2 (xscr, yscr, isbnd, x, y, numel,
$ link, nlink, numnp, nscr)
C=======================================================================
C***********************************************************************
C SUBROUTINE SMOGS = MESH SMOOTHING BY LAPLACE-S USING GAUSS-SEIDEL
C***********************************************************************
real x(*), y(*), xscr(*), yscr(*)
integer numel, nlink, link(nlink, *)
logical isbnd(*)
integer nscr(*)
if (nlink .ne. 4) return
do 20 iel = 1, numel
n1 = link(1, iel)
n2 = link(2, iel)
n3 = link(3, iel)
n4 = link(4, iel)
if (.not. isbnd(n1)) then
xscr(n1) = xscr(n1) + x(n2) + x(n4)
yscr(n1) = yscr(n1) + y(n2) + y(n4)
nscr(n1) = nscr(n1) + 2
end if
if (.not. isbnd(n2)) then
xscr(n2) = xscr(n2) + x(n1) + x(n3)
yscr(n2) = yscr(n2) + y(n1) + y(n3)
nscr(n2) = nscr(n2) + 2
end if
if (.not. isbnd(n3)) then
xscr(n3) = xscr(n3) + x(n2) + x(n4)
yscr(n3) = yscr(n3) + y(n2) + y(n4)
nscr(n3) = nscr(n3) + 2
end if
if (.not. isbnd(n4)) then
xscr(n4) = xscr(n4) + x(n1) + x(n3)
yscr(n4) = yscr(n4) + y(n1) + y(n3)
nscr(n4) = nscr(n4) + 2
end if
20 continue
return
end
| packages/seacas/applications/grepos/gp_smogs2.f |
! Program to test the stack variable size limit.
program stack
call sub1
call sub2 (1)
contains
! Local variables larger than 32768 in byte size shall be placed in static
! storage area, while others be put on stack by default.
subroutine sub1
real a, b(32768/4), c(32768/4+1)
integer m, n(1024,4), k(1024,1024)
a = 10.0
b = 20.0
c = 30.0
m = 10
n = 20
k = 30
if ((a .ne. 10.0).or.(b(1) .ne. 20.0).or.(c(1) .ne. 30.0)) call abort
if ((m .ne. 10).or.(n(256,4) .ne. 20).or.(k(1,1024) .ne. 30)) call abort
end subroutine
! Local variables defined in recursive subroutine are always put on stack.
recursive subroutine sub2 (n)
real a (32769)
a (1) = 42
if (n .ge. 1) call sub2 (n-1)
if (a(1) .ne. 42) call abort
a (1) = 0
end subroutine
end
| gcc-gcc-7_3_0-release/gcc/testsuite/gfortran.fortran-torture/execute/stack_varsize.f90 |
subroutine many_args(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a20, a21, a22,&
a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37,&
a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49)
implicit none
integer, intent(in) :: a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a20, a21, a22,&
a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37,&
a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49
end subroutine many_args
| tests/compile/many_args.f90 |
*
* $Id$
*
*======================================================================
*
* DISCLAIMER
*
* This material was prepared as an account of work sponsored by an
* agency of the United States Government. Neither the United States
* Government nor the United States Department of Energy, nor Battelle,
* nor any of their employees, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
* ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY,
* COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
* SOFTWARE, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT
* INFRINGE PRIVATELY OWNED RIGHTS.
*
* ACKNOWLEDGMENT
*
* This software and its documentation were produced with Government
* support under Contract Number DE-AC06-76RLO-1830 awarded by the United
* States Department of Energy. The Government retains a paid-up
* non-exclusive, irrevocable worldwide license to reproduce, prepare
* derivative works, perform publicly and display publicly by or for the
* Government, including the right to distribute to other Government
* contractors.
*
*======================================================================
*
* -- PEIGS routine (version 2.1) --
* Pacific Northwest Laboratory
* July 28, 1995
*
*======================================================================
real function samax(n,dx,incx)
c
c returns the max of the absolute values.
real dx(*),dtemp
integer i,incx,n,nincx
c
samax = 0.0
dtemp = 0.0
if( n.le.0 .or. incx.le.0 )return
if(incx.ne.1) then
c
c code for increment not equal to 1
c
nincx = n*incx
do 10 i = 1,nincx,incx
dtemp = max( dtemp, abs(dx(i)) )
10 continue
else
c code for increment equal to 1
c
do 20 i = 1, n
dtemp = max( dtemp, abs(dx(i)) )
20 continue
endif
samax = dtemp
return
end
| src/peigs/src/f77/samax.f |
c=======================================================================
c
c subroutine EMPCOVEXP
c
c Empirical Exponentially Weighted Covariance matrix and mean
c
c n
c ---
c cov(i,j) = (1 - L) \ L^(k-1)*[X(k,i) - rho(i)] * [X(k,j) - rho(j)]
c /
c ---
c k=1
c
c-----------------------------------------------------------------------
SUBROUTINE empcovexp ( n, p, lambda, X, rho, XR, cov, info )
c-----------------------------------------------------------------------
c
c INPUT
c n : number of value(s) (n > 1) integer
c p : number of asset(s) (p >= 1) integer
c lambda: exponetial parameter integer
c X : matrix of values (n*p) double
c rho : mean vector (n) double
c
c OUTPUT
c XR : relative [X(.,j) - rho(j)] (n*p) double
c cov : empirical covariance matrix (p*p) double
c info : diagnostic argument integer
c
c CALL
c cove : covariance matrix from centred values : X - E(X)
c (input matrix n*m, result : full symetric matrix m*m)
c
c-----------------------------------------------------------------------
c
IMPLICIT NONE
c
c arguments i/o
INTEGER n, p, info
DOUBLE PRECISION lambda, X(n,*), rho(*), cov(p,*), XR(n,*)
c
c local variables
INTEGER i, j
DOUBLE PRECISION mean
c
c external subroutines
EXTERNAL cove
c
c-----------------------------------------------------------------------
c
c initialization
info = 0
c
c relative return(s)
DO j = 1,p
mean = rho(j)
DO i = 1,n
XR(i, j) = X(i,j) - mean
ENDDO
ENDDO
c
c computation of sum on k of XR(k,i) * XR(k,j)
CALL cove ( n, p, XR, lambda, cov, info )
c
RETURN
END
| src/math/analysis/cov/empcovexp.f |
! { dg-do compile }
! { dg-options "-std=f95" }
! Test for PROCEDURE statements with the -std=f95 flag.
! Contributed by Janus Weil <[email protected]>
program p
procedure():: proc ! { dg-error "Fortran 2003: PROCEDURE statement" }
end program
| validation_tests/llvm/f18/gfortran.dg/proc_decl_4.f90 |
! chk_protected.f90
! Check: does the compiler support the PROTECTED attribute?
!
module protected_var
implicit none
integer, protected :: readonly = 123
end module protected_var
program chk_protected
use protected_var
implicit none
write( *, '(a,i0)' ) 'Value of the protected variable: ', readonly
write( *, '(a,i0)' ) 'Expected value: ', 123
write( *, '(a)' ) '(This only confirms syntactical support for the attribute)'
end program chk_protected
| chkfeatures/chk_protected.f90 |
program MC_ex01_p04
use mc_randoms
implicit none
real(rk)::a
real(rk),allocatable::p_lcg(:,:),p_pm(:,:),p_mt(:,:)
integer::i
!Initialize
call seed_lcg(int(15,ik))
call seed_pm(int(7895,ik))
call init_genrand64(int(431,ik))
allocate(p_lcg(100,2),p_pm(100,2),p_mt(100,2))
!100 points
do i=1, 100
p_lcg(i,1)=rand_lcg()
p_lcg(i,2)=rand_lcg()
p_pm(i,1)=rand_pm()
p_pm(i,2)=rand_pm()
p_mt(i,1)=genrand64_real3()
p_mt(i,2)=genrand64_real3()
end do
!Adjust the interval
p_lcg=p_lcg*2-1
p_pm=p_pm*2-1
p_mt=p_mt*2-1
!Save the data
!LCG
open(1,action="write",file="data_lcg100.txt",status="replace")
do i=1,100
write(1,*) p_lcg(i,1), p_lcg(i,2)
end do
close(1)
!PM
open(1,action="write",file="data_pm100.txt",status="replace")
do i=1,100
write(1,*) p_pm(i,1), p_pm(i,2)
end do
close(1)
!MT
open(1,action="write",file="data_mt100.txt",status="replace")
do i=1,100
write(1,*) p_mt(i,1), p_mt(i,2)
end do
close(1)
deallocate(p_lcg,p_pm,p_mt)
!Data for 10000 points
allocate(p_lcg(10000,2),p_pm(10000,2),p_mt(10000,2))
!10000points
do i=1, 10000
p_lcg(i,1)=rand_lcg()
p_lcg(i,2)=rand_lcg()
p_pm(i,1)=rand_pm()
p_pm(i,2)=rand_pm()
p_mt(i,1)=genrand64_real3()
p_mt(i,2)=genrand64_real3()
end do
!Adjust the interval
p_lcg=p_lcg*2-1
p_pm=p_pm*2-1
p_mt=p_mt*2-1
!Save the data
!LCG
open(1,action="write",file="data_lcg10000.txt",status="replace")
do i=1,10000
write(1,*) p_lcg(i,1), p_lcg(i,2)
end do
close(1)
!PM
open(1,action="write",file="data_pm10000.txt",status="replace")
do i=1,10000
write(1,*) p_pm(i,1), p_pm(i,2)
end do
close(1)
!MT
open(1,action="write",file="data_mt10000.txt",status="replace")
do i=1,10000
write(1,*) p_mt(i,1), p_mt(i,2)
end do
close(1)
!Region [-0.01,0.01] Seed 1
!LCG
i=1
do
if(i>1000) exit
a=rand_lcg()
if(a<=0.01.and.a>=-0.01) then
p_lcg(i,1)=a
do
a=rand_lcg()
if(a<=0.01.and.a>=-0.01) then
p_lcg(i,2)=a
exit
end if
end do
i=i+1
end if
end do
!PM
i=1
do
if(i>1000) exit
a=rand_pm()
if(a<=0.01.and.a>=-0.01) then
p_pm(i,1)=a
do
a=rand_pm()
if(a<=0.01.and.a>=-0.01) then
p_pm(i,2)=a
exit
end if
end do
i=i+1
end if
end do
!MT
i=1
do
if(i>1000) exit
a=genrand64_real3()
if(a<=0.01.and.a>=-0.01) then
p_mt(i,1)=a
do
a=genrand64_real3()
if(a<=0.01.and.a>=-0.01) then
p_mt(i,2)=a
exit
end if
end do
i=i+1
end if
end do
!Save the data
!LCG
open(1,action="write",file="data_lcg_region1.txt",status="replace")
do i=1,1000
write(1,*) p_lcg(i,1), p_lcg(i,2)
end do
close(1)
!PM
open(1,action="write",file="data_pm_region1.txt",status="replace")
do i=1,1000
write(1,*) p_pm(i,1), p_pm(i,2)
end do
close(1)
!MT
open(1,action="write",file="data_mt_region1.txt",status="replace")
do i=1,1000
write(1,*) p_mt(i,1), p_mt(i,2)
end do
close(1)
!Region [-0.01,0.01] Seed 2
call seed_lcg(int(8239,ik))
call seed_pm(int(46,ik))
call init_genrand64(int(20010,ik))
!LCG
i=1
do
if(i>1000) exit
a=rand_lcg()
if(a<=0.01.and.a>=-0.01) then
p_lcg(i,1)=a
do
a=rand_lcg()
if(a<=0.01.and.a>=-0.01) then
p_lcg(i,2)=a
exit
end if
end do
i=i+1
end if
end do
!PM
i=1
do
if(i>1000) exit
a=rand_pm()
if(a<=0.01.and.a>=-0.01) then
p_pm(i,1)=a
do
a=rand_pm()
if(a<=0.01.and.a>=-0.01) then
p_pm(i,2)=a
exit
end if
end do
i=i+1
end if
end do
!MT
i=1
do
if(i>1000) exit
a=genrand64_real3()
if(a<=0.01.and.a>=-0.01) then
p_mt(i,1)=a
do
a=genrand64_real3()
if(a<=0.01.and.a>=-0.01) then
p_mt(i,2)=a
exit
end if
end do
i=i+1
end if
end do
!Save the data
!LCG
open(1,action="write",file="data_lcg_region2.txt",status="replace")
do i=1,1000
write(1,*) p_lcg(i,1), p_lcg(i,2)
end do
close(1)
!PM
open(1,action="write",file="data_pm_region2.txt",status="replace")
do i=1,1000
write(1,*) p_pm(i,1), p_pm(i,2)
end do
close(1)
!MT
open(1,action="write",file="data_mt_region2.txt",status="replace")
do i=1,1000
write(1,*) p_mt(i,1), p_mt(i,2)
end do
close(1)
end program MC_ex01_p04 | Nico_Toikka_ex1/p04/points/ex04.f95 |
PROGRAM FM821
C***********************************************************************00010821
C***** FORTRAN 77 00020821
C***** FM821 00030821
C***** YDCOS - (190) 00040821
C***** 00050821
C***********************************************************************00060821
C***** GENERAL PURPOSE ANS REF 00070821
C***** TEST INTRINSIC FUNCTION DCOS 15.3 00080821
C***** TABLE 5 00090821
C***** 00100821
CBB** ********************** BBCCOMNT **********************************00110821
C**** 00120821
C**** 1978 FORTRAN COMPILER VALIDATION SYSTEM 00130821
C**** VERSION 2.1 00140821
C**** 00150821
C**** 00160821
C**** SUGGESTIONS AND COMMENTS SHOULD BE FORWARDED TO 00170821
C**** NATIONAL INSTITUTE OF STANDARDS AND TECHNOLOGY 00180821
C**** SOFTWARE STANDARDS VALIDATION GROUP 00190821
C**** BUILDING 225 RM A266 00200821
C**** GAITHERSBURG, MD 20899 00210821
C**** 00220821
C**** 00230821
C**** 00240821
CBE** ********************** BBCCOMNT **********************************00250821
C***** 00260821
C***** S P E C I F I C A T I O N S SEGMENT 190 00270821
DOUBLE PRECISION AVD, BVD, PIVD, DVCORR 00280821
C***** 00290821
CBB** ********************** BBCINITA **********************************00300821
C**** SPECIFICATION STATEMENTS 00310821
C**** 00320821
CHARACTER ZVERS*13, ZVERSD*17, ZDATE*17, ZPROG*5, ZCOMPL*20, 00330821
1 ZNAME*20, ZTAPE*10, ZPROJ*13, REMRKS*31, ZTAPED*13 00340821
CBE** ********************** BBCINITA **********************************00350821
CBB** ********************** BBCINITB **********************************00360821
C**** INITIALIZE SECTION 00370821
DATA ZVERS, ZVERSD, ZDATE 00380821
1 /'VERSION 2.1 ', '93/10/21*21.02.00', '*NO DATE*TIME'/ 00390821
DATA ZCOMPL, ZNAME, ZTAPE 00400821
1 /'*NONE SPECIFIED*', '*NO COMPANY NAME*', '*NO TAPE*'/ 00410821
DATA ZPROJ, ZTAPED, ZPROG 00420821
1 /'*NO PROJECT*', '*NO TAPE DATE', 'XXXXX'/ 00430821
DATA REMRKS /' '/ 00440821
C**** THE FOLLOWING 9 COMMENT LINES (CZ01, CZ02, ...) CAN BE REPLACED 00450821
C**** FOR IDENTIFYING THE TEST ENVIRONMENT 00460821
C**** 00470821
CZ01 ZVERS = 'VERSION OF THE COMPILER VALIDATION SYSTEM' 00480821
CZ02 ZVERSD = 'CREATION DATE/TIME OF THE COMPILER VALIDATION SYSTEM' 00490821
CZ03 ZPROG = 'PROGRAM NAME' 00500821
CZ04 ZDATE = 'DATE OF TEST' 00510821
CZ05 ZCOMPL = 'COMPILER IDENTIFICATION' 00520821
CZ06 ZPROJ = 'PROJECT NUMBER/IDENTIFICATION' 00530821
CZ07 ZNAME = 'NAME OF USER' 00540821
CZ08 ZTAPE = 'TAPE OWNER/ID' 00550821
CZ09 ZTAPED = 'DATE TAPE COPIED' 00560821
C 00570821
IVPASS = 0 00580821
IVFAIL = 0 00590821
IVDELE = 0 00600821
IVINSP = 0 00610821
IVTOTL = 0 00620821
IVTOTN = 0 00630821
ICZERO = 0 00640821
C 00650821
C I01 CONTAINS THE LOGICAL UNIT NUMBER FOR THE CARD READER. 00660821
I01 = 05 00670821
C I02 CONTAINS THE LOGICAL UNIT NUMBER FOR THE PRINTER. 00680821
I02 = 06 00690821
C 00700821
CX010 REPLACED BY FEXEC X-010 CONTROL CARD (CARD-READER UNIT NUMBER). 00710821
C THE CX010 CARD IS FOR OVERRIDING THE PROGRAM DEFAULT I01 = 5 00720821
CX011 REPLACED BY FEXEC X-011 CONTROL CARD. CX011 IS FOR SYSTEMS 00730821
C REQUIRING ADDITIONAL STATEMENTS FOR FILES ASSOCIATED WITH CX010. 00740821
C 00750821
CX020 REPLACED BY FEXEC X-020 CONTROL CARD (PRINTER UNIT NUMBER). 00760821
C THE CX020 CARD IS FOR OVERRIDING THE PROGRAM DEFAULT I02= 6 00770821
CX021 REPLACED BY FEXEC X-021 CONTROL CARD. CX021 IS FOR SYSTEMS 00780821
C REQUIRING ADDITIONAL STATEMENTS FOR FILES ASSOCIATED WITH CX020. 00790821
C 00800821
CBE** ********************** BBCINITB **********************************00810821
NUVI = I02 00820821
IVTOTL = 19 00830821
ZPROG = 'FM821' 00840821
CBB** ********************** BBCHED0A **********************************00850821
C**** 00860821
C**** WRITE REPORT TITLE 00870821
C**** 00880821
WRITE (I02, 90002) 00890821
WRITE (I02, 90006) 00900821
WRITE (I02, 90007) 00910821
WRITE (I02, 90008) ZVERS, ZVERSD 00920821
WRITE (I02, 90009) ZPROG, ZPROG 00930821
WRITE (I02, 90010) ZDATE, ZCOMPL 00940821
CBE** ********************** BBCHED0A **********************************00950821
C***** 00960821
C***** HEADER FOR SEGMENT 190 00970821
WRITE(NUVI,19000) 00980821
19000 FORMAT(" "/" YDCOS - (190) INTRINSIC FUNCTIONS" // 00990821
1 " DCOS (DOUBLE PRECISION COSINE)" // 01000821
2 " ANS REF. - 15.3" ) 01010821
CBB** ********************** BBCHED0B **********************************01020821
C**** WRITE DETAIL REPORT HEADERS 01030821
C**** 01040821
WRITE (I02,90004) 01050821
WRITE (I02,90004) 01060821
WRITE (I02,90013) 01070821
WRITE (I02,90014) 01080821
WRITE (I02,90015) IVTOTL 01090821
CBE** ********************** BBCHED0B **********************************01100821
C***** 01110821
PIVD = 3.1415926535897932384626434D0 01120821
C***** 01130821
CT001* TEST 1 ZERO (0.0), SINCE COS(0)=1 01140821
IVTNUM = 1 01150821
BVD = 0.0D0 01160821
AVD = DCOS(BVD) 01170821
IF (AVD - 0.9999999995D+00) 20010, 10010, 40010 01180821
40010 IF (AVD - 0.1000000001D+01) 10010, 10010, 20010 01190821
10010 IVPASS = IVPASS + 1 01200821
WRITE (NUVI, 80002) IVTNUM 01210821
GO TO 0011 01220821
20010 IVFAIL = IVFAIL + 1 01230821
DVCORR = 1.00000000000000000000D+00 01240821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 01250821
0011 CONTINUE 01260821
CT002* TEST 2 VALUES NEAR PI 01270821
IVTNUM = 2 01280821
AVD = DCOS(PIVD) 01290821
IF (AVD + 0.1000000001D+01) 20020, 10020, 40020 01300821
40020 IF (AVD + 0.9999999995D+00) 10020, 10020, 20020 01310821
10020 IVPASS = IVPASS + 1 01320821
WRITE (NUVI, 80002) IVTNUM 01330821
GO TO 0021 01340821
20020 IVFAIL = IVFAIL + 1 01350821
DVCORR = -1.00000000000000000000D+00 01360821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 01370821
0021 CONTINUE 01380821
CT003* TEST 3 PI - 1/16 01390821
IVTNUM = 3 01400821
BVD = 3.07909265358979323846D0 01410821
AVD = DCOS(BVD) 01420821
IF (AVD + 0.9980475112D+00) 20030, 10030, 40030 01430821
40030 IF (AVD + 0.9980475102D+00) 10030, 10030, 20030 01440821
10030 IVPASS = IVPASS + 1 01450821
WRITE (NUVI, 80002) IVTNUM 01460821
GO TO 0031 01470821
20030 IVFAIL = IVFAIL + 1 01480821
DVCORR = -0.99804751070009914963D+00 01490821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 01500821
0031 CONTINUE 01510821
CT004* TEST 4 PI + 1/32 01520821
IVTNUM = 4 01530821
AVD = DCOS(3.17284265358979323846D0) 01540821
IF (AVD + 0.9995117590D+00) 20040, 10040, 40040 01550821
40040 IF (AVD + 0.9995117580D+00) 10040, 10040, 20040 01560821
10040 IVPASS = IVPASS + 1 01570821
WRITE (NUVI, 80002) IVTNUM 01580821
GO TO 0041 01590821
20040 IVFAIL = IVFAIL + 1 01600821
DVCORR = -0.99951175848513636924D+00 01610821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 01620821
0041 CONTINUE 01630821
CT005* TEST 5 VALUES NEAR 2*PI 01640821
IVTNUM = 5 01650821
BVD = PIVD * 2.0D0 01660821
AVD = DCOS(BVD) 01670821
IF (AVD - 0.9999999995D+00) 20050, 10050, 40050 01680821
40050 IF (AVD - 0.1000000001D+01) 10050, 10050, 20050 01690821
10050 IVPASS = IVPASS + 1 01700821
WRITE (NUVI, 80002) IVTNUM 01710821
GO TO 0051 01720821
20050 IVFAIL = IVFAIL + 1 01730821
DVCORR = 1.00000000000000000000D+00 01740821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 01750821
0051 CONTINUE 01760821
CT006* TEST 6 VALUES NEAR 2*PI 01770821
IVTNUM = 6 01780821
BVD = (2.0D0 * PIVD) - 1.0D0 / 64.0D0 01790821
AVD = DCOS(BVD) 01800821
IF (AVD - 0.9998779316D+00) 20060, 10060, 40060 01810821
40060 IF (AVD - 0.9998779327D+00) 10060, 10060, 20060 01820821
10060 IVPASS = IVPASS + 1 01830821
WRITE (NUVI, 80002) IVTNUM 01840821
GO TO 0061 01850821
20060 IVFAIL = IVFAIL + 1 01860821
DVCORR = 0.99987793217100665474D+00 01870821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 01880821
0061 CONTINUE 01890821
CT007* TEST 7 VALUES NEAR 2*PI 01900821
IVTNUM = 7 01910821
BVD = (2.0D0 * PIVD) + 1.0D0 / 128.0D0 01920821
AVD = DCOS(BVD) 01930821
IF (AVD - 0.9999694820D+00) 20070, 10070, 40070 01940821
40070 IF (AVD - 0.9999694831D+00) 10070, 10070, 20070 01950821
10070 IVPASS = IVPASS + 1 01960821
WRITE (NUVI, 80002) IVTNUM 01970821
GO TO 0071 01980821
20070 IVFAIL = IVFAIL + 1 01990821
DVCORR = 0.99996948257709511331D+00 02000821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 02010821
0071 CONTINUE 02020821
CT008* TEST 8 AN EXPRESSION PRESENTED TO DCOS 02030821
IVTNUM = 8 02040821
BVD = 350.0D1 02050821
AVD = DCOS(BVD / 100.0D1) 02060821
IF (AVD + 0.9364566878D+00) 20080, 10080, 40080 02070821
40080 IF (AVD + 0.9364566868D+00) 10080, 10080, 20080 02080821
10080 IVPASS = IVPASS + 1 02090821
WRITE (NUVI, 80002) IVTNUM 02100821
GO TO 0081 02110821
20080 IVFAIL = IVFAIL + 1 02120821
DVCORR = -0.93645668729079633770D+00 02130821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 02140821
0081 CONTINUE 02150821
CT009* TEST 9 A NEGATIVE ARGUMENT 02160821
IVTNUM = 9 02170821
BVD = -1.5D0 02180821
AVD = DCOS(BVD) 02190821
IF (AVD - 0.7073720163D-01) 20090, 10090, 40090 02200821
40090 IF (AVD - 0.7073720171D-01) 10090, 10090, 20090 02210821
10090 IVPASS = IVPASS + 1 02220821
WRITE (NUVI, 80002) IVTNUM 02230821
GO TO 0091 02240821
20090 IVFAIL = IVFAIL + 1 02250821
DVCORR = 0.070737201667702910088D+00 02260821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 02270821
0091 CONTINUE 02280821
CT010* TEST 10 LARGE VALUES TO CHECK ARGUMENT REDUCTION 02290821
IVTNUM = 10 02300821
AVD = DCOS(200.0D0) 02310821
IF (AVD - 0.4871876747D+00) 20100, 10100, 40100 02320821
40100 IF (AVD - 0.4871876753D+00) 10100, 10100, 20100 02330821
10100 IVPASS = IVPASS + 1 02340821
WRITE (NUVI, 80002) IVTNUM 02350821
GO TO 0101 02360821
20100 IVFAIL = IVFAIL + 1 02370821
DVCORR = 0.48718767500700591035D+00 02380821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 02390821
0101 CONTINUE 02400821
CT011* TEST 11 LARGE VALUES TO CHECK ARGUMENT REDUCTION 02410821
IVTNUM = 11 02420821
AVD = DCOS(-31416.0D0) 02430821
IF (AVD - 0.9973027257D+00) 20110, 10110, 40110 02440821
40110 IF (AVD - 0.9973027268D+00) 10110, 10110, 20110 02450821
10110 IVPASS = IVPASS + 1 02460821
WRITE (NUVI, 80002) IVTNUM 02470821
GO TO 0111 02480821
20110 IVFAIL = IVFAIL + 1 02490821
DVCORR = 0.99730272627420107808D+00 02500821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 02510821
0111 CONTINUE 02520821
CT012* TEST 12 VALUES NEAR PI/2 02530821
IVTNUM = 12 02540821
AVD = DCOS(1.57079632679489661923D0) 02550821
IF (AVD + 0.5000000000D-09) 20120, 10120, 40120 02560821
40120 IF (AVD - 0.5000000000D-09) 10120, 10120, 20120 02570821
10120 IVPASS = IVPASS + 1 02580821
WRITE (NUVI, 80002) IVTNUM 02590821
GO TO 0121 02600821
20120 IVFAIL = IVFAIL + 1 02610821
DVCORR = 0.00000000000000000000D+00 02620821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 02630821
0121 CONTINUE 02640821
CT013* TEST 13 (PI / 2) - 1/32 02650821
IVTNUM = 13 02660821
BVD = (1.53954632679489661923D0) 02670821
AVD = DCOS(BVD) 02680821
IF (AVD - 0.3124491397D-01) 20130, 10130, 40130 02690821
40130 IF (AVD - 0.3124491400D-01) 10130, 10130, 20130 02700821
10130 IVPASS = IVPASS + 1 02710821
WRITE (NUVI, 80002) IVTNUM 02720821
GO TO 0131 02730821
20130 IVFAIL = IVFAIL + 1 02740821
DVCORR = 0.031244913985326078739D+00 02750821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 02760821
0131 CONTINUE 02770821
CT014* TEST 14 (PI / 2) + 1/16 02780821
IVTNUM = 14 02790821
AVD = DCOS(1.63329632679489661923D0) 02800821
IF (AVD + 0.6245931788D-01) 20140, 10140, 40140 02810821
40140 IF (AVD + 0.6245931781D-01) 10140, 10140, 20140 02820821
10140 IVPASS = IVPASS + 1 02830821
WRITE (NUVI, 80002) IVTNUM 02840821
GO TO 0141 02850821
20140 IVFAIL = IVFAIL + 1 02860821
DVCORR = -0.062459317842380198585D+00 02870821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 02880821
0141 CONTINUE 02890821
CT015* TEST 15 VALUES NEAR 3*PI/2 02900821
IVTNUM = 15 02910821
BVD = 3.0D0 * PIVD / 2.0D0 02920821
AVD = DCOS(BVD) 02930821
IF (AVD + 0.5000000000D-09) 20150, 10150, 40150 02940821
40150 IF (AVD - 0.5000000000D-09) 10150, 10150, 20150 02950821
10150 IVPASS = IVPASS + 1 02960821
WRITE (NUVI, 80002) IVTNUM 02970821
GO TO 0151 02980821
20150 IVFAIL = IVFAIL + 1 02990821
DVCORR = 0.00000000000000000000D+00 03000821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 03010821
0151 CONTINUE 03020821
CT016* TEST 16 VALUES NEAR 3*PI/2 03030821
IVTNUM = 16 03040821
BVD = (3.0D0 * PIVD / 2.0D0) + 1.0D0 / 16.0D0 03050821
AVD = DCOS(BVD) 03060821
IF (AVD - 0.6245931781D-01) 20160, 10160, 40160 03070821
40160 IF (AVD - 0.6245931788D-01) 10160, 10160, 20160 03080821
10160 IVPASS = IVPASS + 1 03090821
WRITE (NUVI, 80002) IVTNUM 03100821
GO TO 0161 03110821
20160 IVFAIL = IVFAIL + 1 03120821
DVCORR = 0.062459317842380198585D+00 03130821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 03140821
0161 CONTINUE 03150821
CT017* TEST 17 VALUES NEAR 3*PI/2 03160821
IVTNUM = 17 03170821
BVD = (3.0D0 * PIVD / 2.0D0) - 1.0D0 / 512.0D0 03180821
AVD = DCOS(BVD) 03190821
IF (AVD + 0.1953123760D-02) 20170, 10170, 40170 03200821
40170 IF (AVD + 0.1953123757D-02) 10170, 10170, 20170 03210821
10170 IVPASS = IVPASS + 1 03220821
WRITE (NUVI, 80002) IVTNUM 03230821
GO TO 0171 03240821
20170 IVFAIL = IVFAIL + 1 03250821
DVCORR = -0.0019531237582368040269D+00 03260821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 03270821
0171 CONTINUE 03280821
CT018* TEST 18 ARGUMENT OF LOW MAGNITUDE 03290821
IVTNUM = 18 03300821
BVD = -3.1415926535898D-35 03310821
AVD = DCOS(BVD) 03320821
IF (AVD - 0.9999999995D+00) 20180, 10180, 40180 03330821
40180 IF (AVD - 0.1000000001D+01) 10180, 10180, 20180 03340821
10180 IVPASS = IVPASS + 1 03350821
WRITE (NUVI, 80002) IVTNUM 03360821
GO TO 0181 03370821
20180 IVFAIL = IVFAIL + 1 03380821
DVCORR = 1.00000000000000000000D+00 03390821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 03400821
0181 CONTINUE 03410821
CT019* TEST 19 THE FUNCTION APPLIED TWICE 03420821
IVTNUM = 19 03430821
AVD = DCOS(PIVD / 4.0D0) * DCOS(3.0D0 * PIVD / 4.0D0) 03440821
IF (AVD + 0.5000000003D+00) 20190, 10190, 40190 03450821
40190 IF (AVD + 0.4999999997D+00) 10190, 10190, 20190 03460821
10190 IVPASS = IVPASS + 1 03470821
WRITE (NUVI, 80002) IVTNUM 03480821
GO TO 0191 03490821
20190 IVFAIL = IVFAIL + 1 03500821
DVCORR = -0.5000000000000000000000D+00 03510821
WRITE (NUVI, 80031) IVTNUM, AVD, DVCORR 03520821
0191 CONTINUE 03530821
C***** 03540821
CBB** ********************** BBCSUM0 **********************************03550821
C**** WRITE OUT TEST SUMMARY 03560821
C**** 03570821
IVTOTN = IVPASS + IVFAIL + IVDELE + IVINSP 03580821
WRITE (I02, 90004) 03590821
WRITE (I02, 90014) 03600821
WRITE (I02, 90004) 03610821
WRITE (I02, 90020) IVPASS 03620821
WRITE (I02, 90022) IVFAIL 03630821
WRITE (I02, 90024) IVDELE 03640821
WRITE (I02, 90026) IVINSP 03650821
WRITE (I02, 90028) IVTOTN, IVTOTL 03660821
CBE** ********************** BBCSUM0 **********************************03670821
CBB** ********************** BBCFOOT0 **********************************03680821
C**** WRITE OUT REPORT FOOTINGS 03690821
C**** 03700821
WRITE (I02,90016) ZPROG, ZPROG 03710821
WRITE (I02,90018) ZPROJ, ZNAME, ZTAPE, ZTAPED 03720821
WRITE (I02,90019) 03730821
CBE** ********************** BBCFOOT0 **********************************03740821
CBB** ********************** BBCFMT0A **********************************03750821
C**** FORMATS FOR TEST DETAIL LINES 03760821
C**** 03770821
80000 FORMAT (" ",2X,I3,4X,"DELETED",32X,A31) 03780821
80002 FORMAT (" ",2X,I3,4X," PASS ",32X,A31) 03790821
80004 FORMAT (" ",2X,I3,4X,"INSPECT",32X,A31) 03800821
80008 FORMAT (" ",2X,I3,4X," FAIL ",32X,A31) 03810821
80010 FORMAT (" ",2X,I3,4X," FAIL ",/," ",15X,"COMPUTED= " , 03820821
1I6,/," ",15X,"CORRECT= " ,I6) 03830821
80012 FORMAT (" ",2X,I3,4X," FAIL ",/," ",16X,"COMPUTED= " , 03840821
1E12.5,/," ",16X,"CORRECT= " ,E12.5) 03850821
80018 FORMAT (" ",2X,I3,4X," FAIL ",/," ",16X,"COMPUTED= " , 03860821
1A21,/," ",16X,"CORRECT= " ,A21) 03870821
80020 FORMAT (" ",16X,"COMPUTED= " ,A21,1X,A31) 03880821
80022 FORMAT (" ",16X,"CORRECT= " ,A21,1X,A31) 03890821
80024 FORMAT (" ",16X,"COMPUTED= " ,I6,16X,A31) 03900821
80026 FORMAT (" ",16X,"CORRECT= " ,I6,16X,A31) 03910821
80028 FORMAT (" ",16X,"COMPUTED= " ,E12.5,10X,A31) 03920821
80030 FORMAT (" ",16X,"CORRECT= " ,E12.5,10X,A31) 03930821
80050 FORMAT (" ",48X,A31) 03940821
CBE** ********************** BBCFMT0A **********************************03950821
CBB** ********************** BBCFMAT1 **********************************03960821
C**** FORMATS FOR TEST DETAIL LINES - FULL LANGUAGE 03970821
C**** 03980821
80031 FORMAT (" ",2X,I3,4X," FAIL ",/," ",16X,"COMPUTED= " , 03990821
1D17.10,/," ",16X,"CORRECT= " ,D17.10) 04000821
80033 FORMAT (" ",16X,"COMPUTED= " ,D17.10,10X,A31) 04010821
80035 FORMAT (" ",16X,"CORRECT= " ,D17.10,10X,A31) 04020821
80037 FORMAT (" ",16X,"COMPUTED= " ,"(",E12.5,", ",E12.5,")",6X,A31) 04030821
80039 FORMAT (" ",16X,"CORRECT= " ,"(",E12.5,", ",E12.5,")",6X,A31) 04040821
80041 FORMAT (" ",16X,"COMPUTED= " ,"(",F12.5,", ",F12.5,")",6X,A31) 04050821
80043 FORMAT (" ",16X,"CORRECT= " ,"(",F12.5,", ",F12.5,")",6X,A31) 04060821
80045 FORMAT (" ",2X,I3,4X," FAIL ",/," ",16X,"COMPUTED= " , 04070821
1"(",F12.5,", ",F12.5,")"/," ",16X,"CORRECT= " , 04080821
2"(",F12.5,", ",F12.5,")") 04090821
CBE** ********************** BBCFMAT1 **********************************04100821
CBB** ********************** BBCFMT0B **********************************04110821
C**** FORMAT STATEMENTS FOR PAGE HEADERS 04120821
C**** 04130821
90002 FORMAT ("1") 04140821
90004 FORMAT (" ") 04150821
90006 FORMAT (" ",20X,"NATIONAL INSTITUTE OF STANDARDS AND TECHNOLOGY" )04160821
90007 FORMAT (" ",19X,"FORTRAN COMPILER VALIDATION SYSTEM" ) 04170821
90008 FORMAT (" ",21X,A13,A17) 04180821
90009 FORMAT (" ",/," *",A5,"BEGIN*",12X,"TEST RESULTS - " ,A5,/) 04190821
90010 FORMAT (" ",8X,"TEST DATE*TIME= " ,A17," - COMPILER= " ,A20) 04200821
90013 FORMAT (" "," TEST ","PASS/FAIL " ,6X,"DISPLAYED RESULTS" , 04210821
1 7X,"REMARKS",24X) 04220821
90014 FORMAT (" ","----------------------------------------------" , 04230821
1 "---------------------------------" ) 04240821
90015 FORMAT (" ",48X,"THIS PROGRAM HAS " ,I3," TESTS",/) 04250821
C**** 04260821
C**** FORMAT STATEMENTS FOR REPORT FOOTINGS 04270821
C**** 04280821
90016 FORMAT (" ",/," *",A5,"END*",14X,"END OF TEST - " ,A5,/) 04290821
90018 FORMAT (" ",A13,13X,A20," * ",A10,"/", 04300821
1 A13) 04310821
90019 FORMAT (" ","FOR OFFICIAL USE ONLY " ,35X,"COPYRIGHT 1982" ) 04320821
C**** 04330821
C**** FORMAT STATEMENTS FOR RUN SUMMARY 04340821
C**** 04350821
90020 FORMAT (" ",21X,I5," TESTS PASSED" ) 04360821
90022 FORMAT (" ",21X,I5," TESTS FAILED" ) 04370821
90024 FORMAT (" ",21X,I5," TESTS DELETED" ) 04380821
90026 FORMAT (" ",21X,I5," TESTS REQUIRE INSPECTION" ) 04390821
90028 FORMAT (" ",21X,I5," OF ",I3," TESTS EXECUTED" ) 04400821
CBE** ********************** BBCFMT0B **********************************04410821
C***** 04420821
C***** END OF TEST SEGMENT 190 04430821
STOP 04440821
END 04450821
04460821
| Fortran/UnitTests/fcvs21_f95/FM821.f |
c=======================================================================
c
c subroutine COVL
c
c Empirical Covariance matrix with different data length (cf. covm.f)
c
c-----------------------------------------------------------------------
SUBROUTINE covl ( n, p, length, x, dwork, cov, info )
c-----------------------------------------------------------------------
c
c INPUT
c n : number of values integer
c p : number of assets (p > 0) integer
c length : lenght of each asset hist. (p) integer
c x : assets values (n*p) double
c
c WORKSPACE
c dwork : (p*(1 + n + p) + 2*n) double
c
c OUTPUT
c cov : covariance matrix (p*p) double
c info : = 0 successful exit integer
c
c CALL
c EVIMAX : maximum of a vector (integers)
c YMP : copy a sub-block of a vectorized matrix in a vectorized matrix
c COVMVM : covariance matrix and the mean vector
c VARIAN : variance
c
c-----------------------------------------------------------------------
c
IMPLICIT NONE
c
c arguments i/o
INTEGER n, p, info
INTEGER length(*)
DOUBLE PRECISION x(n,*), cov(p,*)
c
c workspaces
DOUBLE PRECISION dwork(*)
c
c local variables
INTEGER i, j, l, izero, iun, ideux, maxlength, lmin,
& pdwork, pdr, pdw, pdv, pdm
PARAMETER ( izero = 0, iun = 1, ideux = 2 )
c
c intrinsic functions
INTRINSIC min
c
c-----------------------------------------------------------------------
c
c initialization
info = 0
c
c pointers for double precision work space : dwork
c -------------------------------------------------
pdwork = 1
pdr = pdwork
c pdr : pointer for sub-values, needs (n*2)
pdw = pdr + ( 2*n )
c pdw : pointer for dwork COVMVM, needs ( n*p)
pdv = pdw + ( n*p )
c pdv : pointer for rho (in COVM), needs (p)
pdm = pdv + ( p )
c pdm : pointer for covariance, needs (p*p)
c
c Total size of dwork array = p*(1 + n + p) + 2*n
c
c-----------------------------------------------------------------------
c
c find the max length of assets history
CALL EVIMAX ( p, length, maxlength )
IF (maxlength .GT. n) THEN
info = -100001
RETURN
ENDIF
c
c covariance matrix
DO i = 1,p-1
DO j = i+1,p
c
c covariance of two assets (on the smallest length)
lmin = min(length(i), length(j))
CALL YMP ( n, p, x, lmin, iun, iun, i,
& dwork(pdr), info )
CALL YMP ( n, p, x, lmin, iun, iun, j,
& dwork(pdr + lmin), info )
c YMP : info = 0 by construction
CALL covmvm ( lmin, ideux, dwork(pdr), dwork(pdw),
& dwork(pdv), dwork(pdm), info)
IF (info .lt. 0) RETURN
c
c writing in full covariance matrix of non-diagonal elements
c of 2x2 matrix
cov(j,i) = dwork(pdm + 1)
cov(i,j) = dwork(pdm + 2)
ENDDO
ENDDO
c
c computing variance (with all values)
DO i = 1,p
l = length(i)
CALL VARIAN ( l, x(1,i), cov(i,i), info )
IF (info .LT. 0) RETURN
ENDDO
RETURN
END
| src/math/analysis/cov/covl.f |
subroutine rpt2(ixy,imp,maxm,meqn,mwaves,maux,mbc,mx,ql,qr,aux1,aux2,aux3,asdq,bmasdq,bpasdq)
! ============================================================================
! Solves transverse Riemann problem for the multilayer shallow water
! equations in 2D with topography and wind forcing:
! (rho_1 h_1)_t + (rho_1 h_1 u_1)_x + (rho_1 h_1 v_1)_y = 0
! (rho_1 h_1 u_1)_t + (rho_1 h_1 u_1^2 + 1/2 g rho_1 h_1^2)_x + (rho_1 h_1 u_1 v_1)_y = -g rho_1 h_1(r(h_2)_x + B_x)
! (rho_1 h_1 v_1)_t + (rho_1 h_1 u_1 v_1)_x + (rho_1 h_1 v_1^2 + 1/2 g rho_1 h_1^2)_y = -g rho_1 h_1(r(h_2)_y + B_y)
! (rho_2 h_2)_t + (rho_2 h_2 u_2)_x + (rho_2 h_2 v_2)_y = 0
! (rho_2 h_2 u_2)_t + (rho_2 h_2 u_2^2 + 1/2 g rho_2 h_2^2)_x + (rho_2 h_2 u_2 v_2)_y = -g rho_2 h_2(h_1 + B)_x
! (rho_2 h_2 v_2)_t + (rho_2 h_2 u_2 v_2)_x + (rho_2 h_2 v_2^2 + 1/2 g rho_2 h_2^2)_y = -g rho_2 h_2(h_1 + B)_y
!
! On input, ql contains the state vector at the left edge of each cell and qr
! contains the state vector at the right edge of each cell
!
! | |
! qr(i-1)|ql(i) qr(i)|ql(i+1)
! ----------|------------|----------
! i-1 i i+1
!
! The i-1/2 Riemann problem has left state qr(i-1) and right state ql(i)
!
! If ixy == 1 then the sweep direction is x, ixy == 2 implies the y direction
! if imp == 1 then the split is in the negative direction, imp == 2 positive
!
! Kyle T. Mandli (10-13-2010)
! ==============================================================================
! Note that this version does not work with PyClaw due to missing parameters
! from the modules.
! ==============================================================================
use amr_module, only: mcapa
use geoclaw_module, only: g => grav, rho, earth_radius, pi
use multilayer_module, only: num_layers, eigen_method, inundation_method
use multilayer_module, only: eigen_func, inundation_eigen_func
use multilayer_module, only: dry_tolerance, aux_layer_index
implicit none
! Input arguments
integer, intent(in) :: ixy,maxm,meqn,mwaves,mbc,mx,imp,maux
double precision, dimension(meqn,1-mbc:maxm+mbc), intent(in) :: ql,qr
double precision, dimension(meqn,1-mbc:maxm+mbc), intent(inout) :: asdq
double precision, dimension(maux,1-mbc:maxm+mbc), intent(in) :: aux1,aux2,aux3
! Ouput
double precision, dimension(meqn,1-mbc:maxm+mbc), intent(out) :: bmasdq,bpasdq
! Local storage
integer :: i,j,m,mw,n_index,t_index,info
double precision :: dxdcm,dxdcp
double precision, dimension(3) :: b
double precision, dimension(6) :: s,delta,pivot
double precision, dimension(6,6) :: eig_vec,A
! Single layer solver storage
double precision :: ql_sl(3),qr_sl(3)
double precision :: aux1_sl(3,2),aux2_sl(3,2),aux3_sl(3,2)
double precision :: asdq_sl(3),bmasdq_sl(3),bpasdq_sl(3)
double precision :: ts(6),teig_vec(6,6)
integer :: layer_index
logical :: dry_state_l(2),dry_state_r(2)
double precision :: h(2),hu(2),hv(2),u(2),v(2),h_hat(2),gamma
double precision :: alpha(4)
! Output array intializations
bmasdq = 0.d0
bpasdq = 0.d0
! Normal and transverse sweep directions
if (ixy == 1) then
n_index = 2
t_index = 3
else
n_index = 3
t_index = 2
endif
! ========================================================================
! Loop over each cell and decompose fluctuations into transverse waves
! if ixy == 1, and imp == 1 splitting amdq into up and down going
! if ixy == 1, and imp == 2 splitting apdq into up and down going
! if ixy == 2, and imp == 1 splitting bmdq into left and right going
! if ixy == 2, and imp == 2 splitting bpdq into left and right going
! ========================================================================
do i=2-mbc,mx+mbc
! Parse states and pick out important states
do j=1,2
layer_index = 3*(j-1)
! Solving in the left grid cell (A^-\Delta Q)
if (imp == 1) then
h(j) = qr(layer_index + 1,i-1) / rho(j)
hu(j) = qr(layer_index + n_index,i-1) / rho(j)
hv(j) = qr(layer_index + t_index,i-1) / rho(j)
b(3) = aux3(1,i-1)
b(2) = aux2(1,i-1)
b(1) = aux1(1,i-1)
h_hat(1) = aux2(aux_layer_index,i-1)
h_hat(2) = aux2(aux_layer_index+1,i-1)
! Solving in the right grid cell (A^+ \Delta Q)
else
h(j) = ql(layer_index + 1,i) / rho(j)
hu(j) = ql(layer_index + n_index,i) / rho(j)
hv(j) = ql(layer_index + t_index,i) / rho(j)
b(3) = aux3(1,i)
b(2) = aux2(1,i)
b(1) = aux1(1,i)
h_hat = aux2(aux_layer_index:aux_layer_index+1,i)
endif
if (h(j) < dry_tolerance(j)) then
u(j) = 0.d0
v(j) = 0.d0
else
u(j) = hu(j) / h(j)
v(j) = hv(j) / h(j)
endif
enddo
! ====================================================================
! Check for dry states in the bottom layer,
! This is if we are right next to a wall, use single layer solver
if (h(1) < dry_tolerance(1) .or. h(2) < dry_tolerance(2)) then
! Storage for single layer rpt2
if (h(1) < dry_tolerance(1)) then
ql_sl = ql(1:3,i) / rho(1)
qr_sl = qr(1:3,i-1) / rho(1)
asdq_sl = asdq(1:3,i) / rho(1)
else if (h(2) < dry_tolerance(2)) then
ql_sl = ql(4:6,i) / rho(2)
qr_sl = qr(4:6,i-1) / rho(2)
asdq_sl = asdq(4:6,i) / rho(2)
else
print *, "Invalid dry-state found."
print *, " h = ", h
stop
end if
aux1_sl = aux1(1:3,i-1:i)
aux2_sl = aux2(1:3,i-1:i)
aux3_sl = aux3(1:3,i-1:i)
! Call solve
call rpt2_single_layer(ixy,imp,ql_sl,qr_sl,aux1_sl,aux2_sl, &
aux3_sl,asdq_sl,bmasdq_sl,bpasdq_sl)
if (h(1) < dry_tolerance(1)) then
bmasdq(1:3,i) = bmasdq_sl * rho(1)
bpasdq(1:3,i) = bpasdq_sl * rho(1)
else if (h(2) < dry_tolerance(2)) then
bmasdq(4:6,i) = bmasdq_sl * rho(2)
bpasdq(4:6,i) = bpasdq_sl * rho(2)
end if
cycle
endif
! ====================================================================
! Two-layers with no dry states in the vicinity
! Compute eigenvector matrix - Linearized system
if (eigen_method == 1) then
call eigen_func(h_hat,h_hat,v,v,u,u,t_index,n_index,s,eig_vec)
else
call eigen_func(h,h,v,v,u,u,t_index,n_index,s,eig_vec)
endif
! ====================================================================
! Solve projection onto eigenvectors - Use LAPACK's dgesv routine
! N - (int) - Number of linear equations (6)
! NRHS - (int) - Number of right hand sides (1)
! A - (dp(6,6)) - Coefficient matrix, in this case eig_vec
! LDA - (int) - Leading dimension of A (6)
! IPIV - (int(N)) - Pivot indices
! B - (dp(LDB,NRHS)) - RHS of equations (delta)
! LDB - (int) - Leading dimension of B (6)
! INFO - (int) - Status of result
! Note that the solution (betas) are in delta after the call
delta = asdq(:,i) ! This is what we are splitting up
A = eig_vec ! We need to do this as the return matrix is modified and
! we have to use eig_vec again to compute fwaves
call dgesv(6,1,A,6,pivot,delta,6,info)
if (.not.(info == 0)) then
print "(a,i2,a,i2)","In transverse solver: ixy=",ixy," imp=",imp
print "(a,i3)"," Error solving R beta = delta,",info
print "(a,i3)"," Location: ",i
print "(a,6d16.8)"," Eigenspeeds: ",s(:)
print "(a)"," Eigenvectors:"
do j=1,6
print "(a,6d16.8)"," ",(eig_vec(j,mw),mw=1,6)
enddo
print "(6d16.8)",h,hu,hv
stop
endif
! Handle lat-long coordinate systems
if (mcapa > 0) then
if (ixy == 2) then
dxdcp=(earth_radius*pi/180.d0)
dxdcm = dxdcp
else
if (imp == 1) then
dxdcp = earth_radius*pi*cos(aux3(3,i-1))/180.d0
dxdcm = earth_radius*pi*cos(aux1(3,i-1))/180.d0
else
dxdcp = earth_radius*pi*cos(aux3(3,i))/180.d0
dxdcm = earth_radius*pi*cos(aux1(3,i))/180.d0
endif
endif
else
dxdcp = 1.d0
dxdcm = 1.d0
endif
! ====================================================================
! Determine transverse fluctuations
! We also check to see if the fluctuation would enter a dry cell and
! skip that split if this is true
do mw=1,mwaves
if (s(mw) > 0.d0) then
if (h(2) + b(2) < b(3)) then
bpasdq(1:3,i) = bpasdq(1:3,i) + dxdcp * s(mw) * delta(mw) * eig_vec(1:3,mw)
else
bpasdq(:,i) = bpasdq(:,i) + dxdcp * s(mw) * delta(mw) * eig_vec(:,mw)
endif
else if (s(mw) < 0.d0) then
if (h(2) + b(2) < b(1)) then
bmasdq(1:3,i) = bmasdq(1:3,i) + dxdcm * s(mw) * delta(mw) * eig_vec(1:3,mw)
else
bmasdq(:,i) = bmasdq(:,i) + dxdcm * s(mw) * delta(mw) * eig_vec(:,mw)
endif
endif
enddo
enddo
end subroutine rpt2
subroutine rpt2_single_layer(ixy,imp,ql,qr,aux1,aux2,aux3,asdq,bmasdq,bpasdq)
! Single layer point-wise transverse Riemann solver using an einfeldt Jacobian
! Note that there have been some changes to variable definitions in this
! routine from the original vectorized one.
!
! Adapted from geoclaw 4-23-2011
use amr_module, only: mcapa
use geoclaw_module, only: g => grav, earth_radius, pi
use multilayer_module, only: num_layers, eigen_method, inundation_method
use multilayer_module, only: dry_tolerance
implicit none
integer, parameter :: meqn = 3
integer, parameter :: mwaves = 3
integer, intent(in) :: ixy,imp
real(kind=8), intent(in) :: ql(meqn) ! = ql(i,meqn)
real(kind=8), intent(in) :: qr(meqn) ! = qr(i-1,meqn)
real(kind=8), intent(in out) :: asdq(meqn)
real(kind=8), intent(in out) :: bmasdq(meqn)
real(kind=8), intent(in out) :: bpasdq(meqn)
! Since we need two values of aux, 1 = i-1 and 2 = i
real(kind=8), intent(in) :: aux1(2,3)
real(kind=8), intent(in) :: aux2(2,3)
real(kind=8), intent(in) :: aux3(2,3)
real(kind=8) :: s(3)
real(kind=8) :: r(3,3)
real(kind=8) :: beta(3)
real(kind=8) :: abs_tol
real(kind=8) :: hl,hr,hul,hur,hvl,hvr,vl,vr,ul,ur,bl,br
real(kind=8) :: uhat,vhat,hhat,roe1,roe3,s1,s2,s3,s1l,s3r
real(kind=8) :: delf1,delf2,delf3,dxdcd,dxdcu
real(kind=8) :: dxdcm,dxdcp,topo1,topo3,eta,tol
integer :: m,mw,mu,mv
tol = dry_tolerance(1)
abs_tol = tol
if (ixy.eq.1) then
mu = 2
mv = 3
else
mu = 3
mv = 2
endif
hl=qr(1)
hr=ql(1)
hul=qr(mu)
hur=ql(mu)
hvl=qr(mv)
hvr=ql(mv)
!===========determine velocity from momentum===========================
if (hl.lt.abs_tol) then
hl=0.d0
ul=0.d0
vl=0.d0
else
ul=hul/hl
vl=hvl/hl
endif
if (hr.lt.abs_tol) then
hr=0.d0
ur=0.d0
vr=0.d0
else
ur=hur/hr
vr=hvr/hr
endif
do mw=1,mwaves
s(mw)=0.d0
beta(mw)=0.d0
do m=1,meqn
r(m,mw)=0.d0
enddo
enddo
dxdcp = 1.d0
dxdcm = 1.d0
if (hl.le.dry_tolerance(1).and.hr.le.dry_tolerance(1)) go to 90
!check and see if cell that transverse waves are going in is high and dry
if (imp.eq.1) then
eta = qr(1) + aux2(1,1)
topo1 = aux1(1,1)
topo3 = aux3(1,1)
else
eta = ql(1) + aux2(1,2)
topo1 = aux1(1,2)
topo3 = aux3(1,2)
endif
if (eta.lt.max(topo1,topo3)) go to 90
if (mcapa > 0) then
if (ixy.eq.2) then
dxdcp=(earth_radius*pi/180.d0)
dxdcm = dxdcp
else
if (imp.eq.1) then
dxdcp = earth_radius*pi*cos(aux3(3,1))/180.d0
dxdcm = earth_radius*pi*cos(aux1(3,1))/180.d0
else
dxdcp = earth_radius*pi*cos(aux3(3,2))/180.d0
dxdcm = earth_radius*pi*cos(aux1(3,2))/180.d0
endif
endif
endif
!=====Determine some speeds necessary for the Jacobian=================
vhat=(vr*dsqrt(hr))/(dsqrt(hr)+dsqrt(hl)) + &
(vl*dsqrt(hl))/(dsqrt(hr)+dsqrt(hl))
uhat=(ur*dsqrt(hr))/(dsqrt(hr)+dsqrt(hl)) + &
(ul*dsqrt(hl))/(dsqrt(hr)+dsqrt(hl))
hhat=(hr+hl)/2.d0
roe1=vhat-dsqrt(g*hhat)
roe3=vhat+dsqrt(g*hhat)
s1l=vl-dsqrt(g*hl)
s3r=vr+dsqrt(g*hr)
s1=dmin1(roe1,s1l)
s3=dmax1(roe3,s3r)
s2=0.5d0*(s1+s3)
s(1)=s1
s(2)=s2
s(3)=s3
!=======================Determine asdq decomposition (beta)============
delf1=asdq(1)
delf2=asdq(mu)
delf3=asdq(mv)
beta(1) = (s3*delf1/(s3-s1))-(delf3/(s3-s1))
beta(2) = -s2*delf1 + delf2
beta(3) = (delf3/(s3-s1))-(s1*delf1/(s3-s1))
!======================End =================================================
!=====================Set-up eigenvectors===================================
r(1,1) = 1.d0
r(2,1) = s2
r(3,1) = s1
r(1,2) = 0.d0
r(2,2) = 1.d0
r(3,2) = 0.d0
r(1,3) = 1.d0
r(2,3) = s2
r(3,3) = s3
!============================================================================
90 continue
!============= compute fluctuations==========================================
do m=1,meqn
bmasdq(m)=0.0d0
bpasdq(m)=0.0d0
enddo
do mw=1,3
if (s(mw).lt.0.d0) then
bmasdq(1) =bmasdq(1) + dxdcm*s(mw)*beta(mw)*r(1,mw)
bmasdq(mu)=bmasdq(mu)+ dxdcm*s(mw)*beta(mw)*r(2,mw)
bmasdq(mv)=bmasdq(mv)+ dxdcm*s(mw)*beta(mw)*r(3,mw)
elseif (s(mw).gt.0.d0) then
bpasdq(1) =bpasdq(1) + dxdcp*s(mw)*beta(mw)*r(1,mw)
bpasdq(mu)=bpasdq(mu)+ dxdcp*s(mw)*beta(mw)*r(2,mw)
bpasdq(mv)=bpasdq(mv)+ dxdcp*s(mw)*beta(mw)*r(3,mw)
endif
enddo
end subroutine rpt2_single_layer
| src/rpt2_layered_shallow_water.f90 |
SUBROUTINE RU_PLVL ( field, above, level, pres, iret )
C************************************************************************
C* RU_PLVL *
C* *
C* This subroutine gets the level number and pressure from a group *
C* which is in the form LLPPP. LL must be the same integer, repeated; *
C* for example, 11 corresponds to level 1. *
C* *
C* RU_PLVL ( FIELD, ABOVE, LEVEL, PRES, IRET ) *
C* *
C* Input parameters: *
C* FIELD CHAR* Input field *
C* ABOVE LOGICAL Above 100 mb flag *
C* *
C* Output parameters: *
C* LEVEL INTEGER Level number *
C* -1 = level not found *
C* 0 = valid surface level *
C* 1 - 9 = valid levels *
C* PRES REAL Pressure *
C* IRET INTEGER Return code *
C* 0 = normal return *
C** *
C* Log: *
C* M. desJardins/GSFC 6/86 *
C************************************************************************
INCLUDE 'GEMPRM.PRM'
C*
LOGICAL above
CHARACTER*(*) field
CHARACTER clev(10)*2
CHARACTER cc*2
DATA clev / '00','11','22','33','44','55','66',
+ '77','88','99' /
C------------------------------------------------------------------------
iret = 0
level = -1
pres = RMISSD
C
C* Check first two character for level number.
C
cc = field ( 1:2 )
DO i = 1, 10
IF ( cc .eq. clev (i) ) level = i - 1
END DO
C
C* If a level was found, decode the pressure.
C
IF ( level .ne. -1 ) THEN
CALL ST_INTG ( field (3:5), ipres, ier )
C
C* Save the pressure if it could be decoded.
C
IF ( ier .eq. 0 ) THEN
C
C* Pressures above 100 mb are in tenths; below 100 mb are
C* in units.
C
IF ( above ) THEN
pres = FLOAT ( ipres ) / 10.
ELSE
pres = FLOAT ( ipres )
IF ( pres .lt. 100. ) pres = pres + 1000.
END IF
C
C* If the pressure is missing, reset the level to -1.
C
ELSE
level = -1
END IF
END IF
C*
RETURN
END
| gempak/source/bridge/ru/ruplvl.f |
! Run with -np 5 and s = 18. Sometimes MPI_Barrier doesn't help if the output
! buffer is not flushed on time.
program scatterv
use mpi_f08
implicit none
type(MPI_Comm) :: comm
integer :: my_rank, n_ranks, root
integer :: s, i, remainder, quotient, displacement, count, rank, b, e
integer, allocatable :: rbuf(:), sbuf(:)
integer, allocatable :: counts(:), displacements(:)
call MPI_Init()
comm = MPI_COMM_WORLD
call MPI_Comm_size(comm, n_ranks)
call MPI_Comm_rank(comm, my_rank)
root = 0
! Read-in `s` on rank 0, allocate sbuf(s) only on rank 0 and later vector-
! scatter it to other ranks.
s = 0
if (my_rank == root) read *, s
allocate(sbuf(s))
if (my_rank == root) sbuf(:) = [ (i, i = 1, s) ]
call MPI_Bcast(s, 1, MPI_INTEGER, root, comm)
remainder = modulo(s, n_ranks)
quotient = (s - remainder) / n_ranks
allocate(counts(0:n_ranks - 1))
allocate(displacements(0:n_ranks - 1))
displacement = 0
do rank = 0, n_ranks - 1
if (rank < remainder) then
counts(rank) = quotient + 1
else
counts(rank) = quotient
end if
displacements(rank) = displacement
displacement = displacement + counts(rank)
if (rank == my_rank) then
count = counts(rank)
b = displacements(rank) + 1
e = displacements(rank) + count
end if
end do
allocate(rbuf(b:e), source=0)
call print_vals()
call MPI_Scatterv(sbuf, counts, displacements, MPI_INTEGER, &
rbuf, count, MPI_INTEGER, root, comm)
call print_vals()
if (allocated(sbuf)) deallocate(sbuf)
if (allocated(rbuf)) deallocate(rbuf)
if (allocated(counts)) deallocate(counts)
if (allocated(displacements)) deallocate(displacements)
call MPI_Finalize()
contains
!---------------------------------------------------------------------------
subroutine print_vals()
integer :: rank
do rank = 0, n_ranks - 1
if (rank == my_rank) then
print "(a, i0, a, *(i2, 1x))", "Rank ", rank, ", sbuf(:)=", sbuf
end if
call MPI_Barrier(comm)
end do
do rank = 0, n_ranks - 1
if (rank == my_rank) then
print "(a, i0, a, *(i2, 1x))", "Rank ", rank, ", rbuf(:)=", rbuf
end if
call MPI_Barrier(comm)
end do
if (my_rank == 0) print *
end subroutine print_vals
!---------------------------------------------------------------------------
end program scatterv
| Lecture_12/collectives/scatterv.f90 |
module bc_state_turbo_interface_steady
#include <messenger.h>
use mod_kinds, only: rk,ik
use mod_constants, only: ZERO, ONE, TWO, HALF, ME, CYLINDRICAL, &
XI_MIN, XI_MAX, ETA_MIN, ETA_MAX, ZETA_MIN, ZETA_MAX, PI
use mod_fluid, only: gam, Rgas, cp
use type_point, only: point_t
use type_mesh, only: mesh_t
use type_bc_state, only: bc_state_t
use bc_giles_HB_base, only: giles_HB_base_t
use type_bc_patch, only: bc_patch_t
use type_chidg_worker, only: chidg_worker_t
use type_properties, only: properties_t
use type_face_info, only: face_info_t, face_info_constructor
use type_element_info, only: element_info_t
use ieee_arithmetic, only: ieee_is_nan
use mpi_f08, only: mpi_comm
use DNAD_D
implicit none
!> Name: inlet - 3D Giles
!!
!! Options:
!! : Average Pressure
!!
!! Behavior:
!!
!! References:
!!
!! @author Nathan A. Wukie
!! @date 2/8/2018
!!
!---------------------------------------------------------------------------------
type, public, extends(giles_HB_base_t) :: turbo_interface_steady_t
contains
procedure :: init ! Set-up bc state with options/name etc.
procedure :: compute_bc_state ! boundary condition function implementation
procedure :: compute_absorbing_interface
procedure :: apply_nonreflecting_condition
end type turbo_interface_steady_t
!*********************************************************************************
contains
!>
!!
!! @author Nathan A. average_pressure
!! @date 2/8/2017
!!
!--------------------------------------------------------------------------------
subroutine init(self)
class(turbo_interface_steady_t), intent(inout) :: self
! Set name, family
call self%set_name('Steady Turbo Interface')
call self%set_family('Inlet')
! Add functions
call self%bcproperties%add('Pitch A', 'Required')
call self%bcproperties%add('Pitch B', 'Required')
end subroutine init
!********************************************************************************
!>
!!
!! @author Nathan A. Wukie
!! @date 2/8/2018
!!
!! @param[in] worker Interface for geometry, cache, integration, etc.
!! @param[inout] prop properties_t object containing equations and material_t objects
!!
!-------------------------------------------------------------------------------------------
subroutine compute_bc_state(self,worker,prop,bc_comm)
class(turbo_interface_steady_t), intent(inout) :: self
type(chidg_worker_t), intent(inout) :: worker
class(properties_t), intent(inout) :: prop
type(mpi_comm), intent(in) :: bc_comm
! Storage at quadrature nodes
type(AD_D), allocatable, dimension(:) :: &
density_bc, mom1_bc, mom2_bc, mom3_bc, energy_bc, pressure_bc, vel1_bc, vel2_bc, vel3_bc, &
grad1_density_m, grad1_mom1_m, grad1_mom2_m, grad1_mom3_m, grad1_energy_m, &
grad2_density_m, grad2_mom1_m, grad2_mom2_m, grad2_mom3_m, grad2_energy_m, &
grad3_density_m, grad3_mom1_m, grad3_mom2_m, grad3_mom3_m, grad3_energy_m
type(AD_D), allocatable, dimension(:,:) :: &
density_check_real_gq, vel1_check_real_gq, vel2_check_real_gq, vel3_check_real_gq, pressure_check_real_gq, &
density_check_imag_gq, vel1_check_imag_gq, vel2_check_imag_gq, vel3_check_imag_gq, pressure_check_imag_gq
type(AD_D), allocatable, dimension(:,:,:) :: &
density_check_real_m, vel1_check_real_m, vel2_check_real_m, vel3_check_real_m, pressure_check_real_m, c_check_real_m, &
density_check_imag_m, vel1_check_imag_m, vel2_check_imag_m, vel3_check_imag_m, pressure_check_imag_m, c_check_imag_m, &
density_hat_real_m, vel1_hat_real_m, vel2_hat_real_m, vel3_hat_real_m, pressure_hat_real_m, c_hat_real_m, &
density_hat_imag_m, vel1_hat_imag_m, vel2_hat_imag_m, vel3_hat_imag_m, pressure_hat_imag_m, c_hat_imag_m, &
density_check_real_p, vel1_check_real_p, vel2_check_real_p, vel3_check_real_p, pressure_check_real_p, c_check_real_p, &
density_check_imag_p, vel1_check_imag_p, vel2_check_imag_p, vel3_check_imag_p, pressure_check_imag_p, c_check_imag_p, &
density_hat_real_p, vel1_hat_real_p, vel2_hat_real_p, vel3_hat_real_p, pressure_hat_real_p, c_hat_real_p, &
density_hat_imag_p, vel1_hat_imag_p, vel2_hat_imag_p, vel3_hat_imag_p, pressure_hat_imag_p, c_hat_imag_p, &
density_hat_real_abs, vel1_hat_real_abs, vel2_hat_real_abs, vel3_hat_real_abs, pressure_hat_real_abs, &
density_hat_imag_abs, vel1_hat_imag_abs, vel2_hat_imag_abs, vel3_hat_imag_abs, pressure_hat_imag_abs, &
density_hat_real_gq, vel1_hat_real_gq, vel2_hat_real_gq, vel3_hat_real_gq, pressure_hat_real_gq, &
density_hat_imag_gq, vel1_hat_imag_gq, vel2_hat_imag_gq, vel3_hat_imag_gq, pressure_hat_imag_gq, &
density_grid_m, vel1_grid_m, vel2_grid_m, vel3_grid_m, pressure_grid_m, c_grid_m, &
density_grid_p, vel1_grid_p, vel2_grid_p, vel3_grid_p, pressure_grid_p, c_grid_p
type(AD_D), allocatable, dimension(:) :: r
character(1) :: side
! Interpolate interior solution to face quadrature nodes
grad1_density_m = worker%get_field('Density' , 'grad1', 'face interior')
grad2_density_m = worker%get_field('Density' , 'grad2', 'face interior')
grad3_density_m = worker%get_field('Density' , 'grad3', 'face interior')
grad1_mom1_m = worker%get_field('Momentum-1', 'grad1', 'face interior')
grad2_mom1_m = worker%get_field('Momentum-1', 'grad2', 'face interior')
grad3_mom1_m = worker%get_field('Momentum-1', 'grad3', 'face interior')
grad1_mom2_m = worker%get_field('Momentum-2', 'grad1', 'face interior')
grad2_mom2_m = worker%get_field('Momentum-2', 'grad2', 'face interior')
grad3_mom2_m = worker%get_field('Momentum-2', 'grad3', 'face interior')
grad1_mom3_m = worker%get_field('Momentum-3', 'grad1', 'face interior')
grad2_mom3_m = worker%get_field('Momentum-3', 'grad2', 'face interior')
grad3_mom3_m = worker%get_field('Momentum-3', 'grad3', 'face interior')
grad1_energy_m = worker%get_field('Energy' , 'grad1', 'face interior')
grad2_energy_m = worker%get_field('Energy' , 'grad2', 'face interior')
grad3_energy_m = worker%get_field('Energy' , 'grad3', 'face interior')
! Store boundary gradient state. Grad(Q_bc). Do this here, before we
! compute any transformations for cylindrical.
call worker%store_bc_state('Density' , grad1_density_m, 'grad1')
call worker%store_bc_state('Density' , grad2_density_m, 'grad2')
call worker%store_bc_state('Density' , grad3_density_m, 'grad3')
call worker%store_bc_state('Momentum-1', grad1_mom1_m, 'grad1')
call worker%store_bc_state('Momentum-1', grad2_mom1_m, 'grad2')
call worker%store_bc_state('Momentum-1', grad3_mom1_m, 'grad3')
call worker%store_bc_state('Momentum-2', grad1_mom2_m, 'grad1')
call worker%store_bc_state('Momentum-2', grad2_mom2_m, 'grad2')
call worker%store_bc_state('Momentum-2', grad3_mom2_m, 'grad3')
call worker%store_bc_state('Momentum-3', grad1_mom3_m, 'grad1')
call worker%store_bc_state('Momentum-3', grad2_mom3_m, 'grad2')
call worker%store_bc_state('Momentum-3', grad3_mom3_m, 'grad3')
call worker%store_bc_state('Energy' , grad1_energy_m, 'grad1')
call worker%store_bc_state('Energy' , grad2_energy_m, 'grad2')
call worker%store_bc_state('Energy' , grad3_energy_m, 'grad3')
! Get primitive variables at (radius,theta,time) grid.
call self%get_q_side(worker,bc_comm,'A', &
density_grid_m, &
vel1_grid_m, &
vel2_grid_m, &
vel3_grid_m, &
pressure_grid_m)
c_grid_m = sqrt(gam*pressure_grid_m/density_grid_m)
! Compute Fourier decomposition of temporal data at points
! on the spatial transform grid.
! q_check(r,theta,omega) = DFT(q)[time]
call self%compute_temporal_dft(worker,bc_comm, &
density_grid_m, &
vel1_grid_m, &
vel2_grid_m, &
vel3_grid_m, &
pressure_grid_m, &
c_grid_m, &
density_check_real_m, density_check_imag_m, &
vel1_check_real_m, vel1_check_imag_m, &
vel2_check_real_m, vel2_check_imag_m, &
vel3_check_real_m, vel3_check_imag_m, &
pressure_check_real_m, pressure_check_imag_m, &
c_check_real_m, c_check_imag_m)
! Compute Fourier decomposition in theta at set of radial
! stations for each temporal mode:
! q_hat(r,m,omega) = DFT(q_check)[theta]
call self%compute_spatial_dft(worker,bc_comm,'A', &
density_check_real_m, density_check_imag_m, &
vel1_check_real_m, vel1_check_imag_m, &
vel2_check_real_m, vel2_check_imag_m, &
vel3_check_real_m, vel3_check_imag_m, &
pressure_check_real_m, pressure_check_imag_m, &
c_check_real_m, c_check_imag_m, &
density_hat_real_m, density_hat_imag_m, &
vel1_hat_real_m, vel1_hat_imag_m, &
vel2_hat_real_m, vel2_hat_imag_m, &
vel3_hat_real_m, vel3_hat_imag_m, &
pressure_hat_real_m, pressure_hat_imag_m, &
c_hat_real_m, c_hat_imag_m)
! Get exterior perturbation
call self%get_q_side(worker,bc_comm,'B', &
density_grid_p, &
vel1_grid_p, &
vel2_grid_p, &
vel3_grid_p, &
pressure_grid_p)
c_grid_p = sqrt(gam*pressure_grid_p/density_grid_p)
! Compute Fourier decomposition of temporal data at points
! on the spatial transform grid.
! q_check(r,theta,omega) = DFT(q)[time]
call self%compute_temporal_dft(worker,bc_comm, &
density_grid_p, &
vel1_grid_p, &
vel2_grid_p, &
vel3_grid_p, &
pressure_grid_p, &
c_grid_p, &
density_check_real_p, density_check_imag_p, &
vel1_check_real_p, vel1_check_imag_p, &
vel2_check_real_p, vel2_check_imag_p, &
vel3_check_real_p, vel3_check_imag_p, &
pressure_check_real_p, pressure_check_imag_p, &
c_check_real_p, c_check_imag_p)
! Compute Fourier decomposition in theta at set of radial
! stations for each temporal mode:
! q_hat(r,m,omega) = DFT(q_check)[theta]
call self%compute_spatial_dft(worker,bc_comm,'B', &
density_check_real_p, density_check_imag_p, &
vel1_check_real_p, vel1_check_imag_p, &
vel2_check_real_p, vel2_check_imag_p, &
vel3_check_real_p, vel3_check_imag_p, &
pressure_check_real_p, pressure_check_imag_p, &
c_check_real_p, c_check_imag_p, &
density_hat_real_p, density_hat_imag_p, &
vel1_hat_real_p, vel1_hat_imag_p, &
vel2_hat_real_p, vel2_hat_imag_p, &
vel3_hat_real_p, vel3_hat_imag_p, &
pressure_hat_real_p, pressure_hat_imag_p, &
c_hat_real_p, c_hat_imag_p)
! Compute q_abs = f(q_p,q_m)
side = self%get_face_side(worker)
call self%compute_absorbing_interface(worker,bc_comm,side, &
density_hat_real_m, density_hat_imag_m, &
vel1_hat_real_m, vel1_hat_imag_m, &
vel2_hat_real_m, vel2_hat_imag_m, &
vel3_hat_real_m, vel3_hat_imag_m, &
pressure_hat_real_m, pressure_hat_imag_m, &
c_hat_real_m, c_hat_imag_m, &
density_hat_real_p, density_hat_imag_p, &
vel1_hat_real_p, vel1_hat_imag_p, &
vel2_hat_real_p, vel2_hat_imag_p, &
vel3_hat_real_p, vel3_hat_imag_p, &
pressure_hat_real_p, pressure_hat_imag_p, &
c_hat_real_p, c_hat_imag_p, &
density_hat_real_abs, density_hat_imag_abs, &
vel1_hat_real_abs, vel1_hat_imag_abs, &
vel2_hat_real_abs, vel2_hat_imag_abs, &
vel3_hat_real_abs, vel3_hat_imag_abs, &
pressure_hat_real_abs, pressure_hat_imag_abs)
! q_abs(r_gq) = I(q_abs(r_aux))
call self%interpolate_raux_to_rgq(worker,bc_comm, &
density_hat_real_abs, density_hat_imag_abs, &
vel1_hat_real_abs, vel1_hat_imag_abs, &
vel2_hat_real_abs, vel2_hat_imag_abs, &
vel3_hat_real_abs, vel3_hat_imag_abs, &
pressure_hat_real_abs, pressure_hat_imag_abs, &
density_hat_real_gq, density_hat_imag_gq, &
vel1_hat_real_gq, vel1_hat_imag_gq, &
vel2_hat_real_gq, vel2_hat_imag_gq, &
vel3_hat_real_gq, vel3_hat_imag_gq, &
pressure_hat_real_gq, pressure_hat_imag_gq)
! Reconstruct primitive variables at quadrature nodes from absorbing Fourier modes
! via inverse transform.
! q_check(rgq,theta,omega) = IDFT(q_hat)[m]
call self%compute_spatial_idft_gq(worker,bc_comm,side, &
density_hat_real_gq, density_hat_imag_gq, &
vel1_hat_real_gq, vel1_hat_imag_gq, &
vel2_hat_real_gq, vel2_hat_imag_gq, &
vel3_hat_real_gq, vel3_hat_imag_gq, &
pressure_hat_real_gq, pressure_hat_imag_gq, &
density_check_real_gq, density_check_imag_gq, &
vel1_check_real_gq, vel1_check_imag_gq, &
vel2_check_real_gq, vel2_check_imag_gq, &
vel3_check_real_gq, vel3_check_imag_gq, &
pressure_check_real_gq, pressure_check_imag_gq)
! q(rgq,theta,t) = IDFT(q_check)[omega]
call self%compute_temporal_idft_gq(worker,bc_comm, &
density_check_real_gq, density_check_imag_gq, &
vel1_check_real_gq, vel1_check_imag_gq, &
vel2_check_real_gq, vel2_check_imag_gq, &
vel3_check_real_gq, vel3_check_imag_gq, &
pressure_check_real_gq, pressure_check_imag_gq, &
density_bc, vel1_bc, vel2_bc, vel3_bc, pressure_bc)
!
! Form conserved variables
!
density_bc = density_bc
mom1_bc = density_bc*vel1_bc
mom2_bc = density_bc*vel2_bc
mom3_bc = density_bc*vel3_bc
energy_bc = pressure_bc/(gam - ONE) + HALF*(mom1_bc*mom1_bc + mom2_bc*mom2_bc + mom3_bc*mom3_bc)/density_bc
!
! Account for cylindrical. Convert tangential momentum back to angular momentum.
!
if (worker%coordinate_system() == 'Cylindrical') then
r = worker%coordinate('1','boundary')
mom2_bc = mom2_bc * r
end if
!
! Store boundary condition state. q_bc
!
call worker%store_bc_state('Density' , density_bc, 'value')
call worker%store_bc_state('Momentum-1', mom1_bc, 'value')
call worker%store_bc_state('Momentum-2', mom2_bc, 'value')
call worker%store_bc_state('Momentum-3', mom3_bc, 'value')
call worker%store_bc_state('Energy' , energy_bc, 'value')
end subroutine compute_bc_state
!*********************************************************************************
!> DANIEL'S FORMULATION
!!
!!
!!
!!
!--------------------------------------------------------------------------------
subroutine compute_absorbing_interface(self,worker,bc_comm,side, &
density_real_m, density_imag_m, &
vel1_real_m, vel1_imag_m, &
vel2_real_m, vel2_imag_m, &
vel3_real_m, vel3_imag_m, &
pressure_real_m, pressure_imag_m, &
c_real_m, c_imag_m, &
density_real_p, density_imag_p, &
vel1_real_p, vel1_imag_p, &
vel2_real_p, vel2_imag_p, &
vel3_real_p, vel3_imag_p, &
pressure_real_p, pressure_imag_p, &
c_real_p, c_imag_p, &
density_real_abs, density_imag_abs, &
vel1_real_abs, vel1_imag_abs, &
vel2_real_abs, vel2_imag_abs, &
vel3_real_abs, vel3_imag_abs, &
pressure_real_abs, pressure_imag_abs)
class(turbo_interface_steady_t), intent(inout) :: self
type(chidg_worker_t), intent(inout) :: worker
type(mpi_comm), intent(in) :: bc_comm
character(1), intent(in) :: side
type(AD_D), intent(inout) :: density_real_m(:,:,:)
type(AD_D), intent(inout) :: density_imag_m(:,:,:)
type(AD_D), intent(inout) :: vel1_real_m(:,:,:)
type(AD_D), intent(inout) :: vel1_imag_m(:,:,:)
type(AD_D), intent(inout) :: vel2_real_m(:,:,:)
type(AD_D), intent(inout) :: vel2_imag_m(:,:,:)
type(AD_D), intent(inout) :: vel3_real_m(:,:,:)
type(AD_D), intent(inout) :: vel3_imag_m(:,:,:)
type(AD_D), intent(inout) :: pressure_real_m(:,:,:)
type(AD_D), intent(inout) :: pressure_imag_m(:,:,:)
type(AD_D), intent(inout) :: c_real_m(:,:,:)
type(AD_D), intent(inout) :: c_imag_m(:,:,:)
type(AD_D), intent(inout) :: density_real_p(:,:,:)
type(AD_D), intent(inout) :: density_imag_p(:,:,:)
type(AD_D), intent(inout) :: vel1_real_p(:,:,:)
type(AD_D), intent(inout) :: vel1_imag_p(:,:,:)
type(AD_D), intent(inout) :: vel2_real_p(:,:,:)
type(AD_D), intent(inout) :: vel2_imag_p(:,:,:)
type(AD_D), intent(inout) :: vel3_real_p(:,:,:)
type(AD_D), intent(inout) :: vel3_imag_p(:,:,:)
type(AD_D), intent(inout) :: pressure_real_p(:,:,:)
type(AD_D), intent(inout) :: pressure_imag_p(:,:,:)
type(AD_D), intent(inout) :: c_real_p(:,:,:)
type(AD_D), intent(inout) :: c_imag_p(:,:,:)
type(AD_D), allocatable, intent(inout) :: density_real_abs(:,:,:)
type(AD_D), allocatable, intent(inout) :: density_imag_abs(:,:,:)
type(AD_D), allocatable, intent(inout) :: vel1_real_abs(:,:,:)
type(AD_D), allocatable, intent(inout) :: vel1_imag_abs(:,:,:)
type(AD_D), allocatable, intent(inout) :: vel2_real_abs(:,:,:)
type(AD_D), allocatable, intent(inout) :: vel2_imag_abs(:,:,:)
type(AD_D), allocatable, intent(inout) :: vel3_real_abs(:,:,:)
type(AD_D), allocatable, intent(inout) :: vel3_imag_abs(:,:,:)
type(AD_D), allocatable, intent(inout) :: pressure_real_abs(:,:,:)
type(AD_D), allocatable, intent(inout) :: pressure_imag_abs(:,:,:)
type(AD_D), allocatable, dimension(:,:,:) :: &
a1_real, a2_real, a3_real, a4_real, a5_real, &
a1_imag, a2_imag, a3_imag, a4_imag, a5_imag, &
a1_real_m, a2_real_m, a3_real_m, a4_real_m, a5_real_m, &
a1_imag_m, a2_imag_m, a3_imag_m, a4_imag_m, a5_imag_m, &
a1_real_p, a2_real_p, a3_real_p, a4_real_p, a5_real_p, &
a1_imag_p, a2_imag_p, a3_imag_p, a4_imag_p, a5_imag_p
type(AD_D), allocatable, dimension(:) :: density_bar, vel1_bar, vel2_bar, vel3_bar, pressure_bar, c_bar
real(rk), allocatable, dimension(:,:) :: unorm
print*, 'WARNING: Inconsistent use of Pitch A in eigenvalue calc'
density_bar = (density_real_m(:,1,1) + density_real_p(:,1,1))/TWO
vel1_bar = (vel1_real_m(:,1,1) + vel1_real_p(:,1,1))/TWO
vel2_bar = (vel2_real_m(:,1,1) + vel2_real_p(:,1,1))/TWO
vel3_bar = (vel3_real_m(:,1,1) + vel3_real_p(:,1,1))/TWO
pressure_bar = (pressure_real_m(:,1,1) + pressure_real_p(:,1,1))/TWO
c_bar = (c_real_m(:,1,1) + c_real_p(:,1,1))/TWO
! Project interior to eigenmodes
call self%primitive_to_eigenmodes(worker,bc_comm,'A', &
density_bar, vel1_bar, vel2_bar, vel3_bar, pressure_bar, c_bar, &
density_real_m, density_imag_m, &
vel1_real_m, vel1_imag_m, &
vel2_real_m, vel2_imag_m, &
vel3_real_m, vel3_imag_m, &
pressure_real_m, pressure_imag_m, &
a1_real_m, a1_imag_m, &
a2_real_m, a2_imag_m, &
a3_real_m, a3_imag_m, &
a4_real_m, a4_imag_m, &
a5_real_m, a5_imag_m)
! Project exterior to eigenmodes
call self%primitive_to_eigenmodes(worker,bc_comm,'B', &
density_bar, vel1_bar, vel2_bar, vel3_bar, pressure_bar, c_bar, &
density_real_p, density_imag_p, &
vel1_real_p, vel1_imag_p, &
vel2_real_p, vel2_imag_p, &
vel3_real_p, vel3_imag_p, &
pressure_real_p, pressure_imag_p, &
a1_real_p, a1_imag_p, &
a2_real_p, a2_imag_p, &
a3_real_p, a3_imag_p, &
a4_real_p, a4_imag_p, &
a5_real_p, a5_imag_p)
! Allocate and zero absorbing modes
a1_real = ZERO*a1_real_m
a1_imag = ZERO*a1_real_m
a2_real = ZERO*a1_real_m
a2_imag = ZERO*a1_real_m
a3_real = ZERO*a1_real_m
a3_imag = ZERO*a1_real_m
a4_real = ZERO*a1_real_m
a4_imag = ZERO*a1_real_m
a5_real = ZERO*a1_real_m
a5_imag = ZERO*a1_real_m
call self%apply_nonreflecting_condition(worker,bc_comm,side, &
density_bar, vel1_bar, vel2_bar, vel3_bar, pressure_bar, c_bar, &
a1_real_m, a1_imag_m, &
a2_real_m, a2_imag_m, &
a3_real_m, a3_imag_m, &
a4_real_m, a4_imag_m, &
a5_real_m, a5_imag_m, &
a1_real_p, a1_imag_p, &
a2_real_p, a2_imag_p, &
a3_real_p, a3_imag_p, &
a4_real_p, a4_imag_p, &
a5_real_p, a5_imag_p, &
a1_real, a1_imag, &
a2_real, a2_imag, &
a3_real, a3_imag, &
a4_real, a4_imag, &
a5_real, a5_imag)
! To initialize average and storage
density_real_abs = density_real_m
density_imag_abs = density_imag_m
vel1_real_abs = vel1_real_m
vel1_imag_abs = vel1_imag_m
vel2_real_abs = vel2_real_m
vel2_imag_abs = vel2_imag_m
vel3_real_abs = vel3_real_m
vel3_imag_abs = vel3_imag_m
pressure_real_abs = pressure_real_m
pressure_imag_abs = pressure_imag_m
! Convert back to primitive variables
call self%eigenmodes_to_primitive(worker,bc_comm,side, &
density_bar, vel1_bar, vel2_bar, vel3_bar, pressure_bar, c_bar, &
a1_real, a1_imag, &
a2_real, a2_imag, &
a3_real, a3_imag, &
a4_real, a4_imag, &
a5_real, a5_imag, &
density_real_abs, density_imag_abs, &
vel1_real_abs, vel1_imag_abs, &
vel2_real_abs, vel2_imag_abs, &
vel3_real_abs, vel3_imag_abs, &
pressure_real_abs, pressure_imag_abs)
! Update space-time average as average of 'A' and 'B'
density_real_abs(:,1,1) = (density_real_m(:,1,1) + density_real_p(:,1,1))/TWO
vel1_real_abs(:,1,1) = (vel1_real_m(:,1,1) + vel1_real_p(:,1,1))/TWO
vel2_real_abs(:,1,1) = (vel2_real_m(:,1,1) + vel2_real_p(:,1,1))/TWO
vel3_real_abs(:,1,1) = (vel3_real_m(:,1,1) + vel3_real_p(:,1,1))/TWO
pressure_real_abs(:,1,1) = (pressure_real_m(:,1,1) + pressure_real_p(:,1,1))/TWO
! Zero imaginary part
density_imag_abs(:,1,1) = ZERO
vel1_imag_abs(:,1,1) = ZERO
vel2_imag_abs(:,1,1) = ZERO
vel3_imag_abs(:,1,1) = ZERO
pressure_imag_abs(:,1,1) = ZERO
end subroutine compute_absorbing_interface
!********************************************************************************
!>
!!
!!
!!
!-----------------------------------------------------------------------------------
subroutine apply_nonreflecting_condition(self,worker,bc_comm,side, &
density_bar_r, vel1_bar_r, vel2_bar_r, vel3_bar_r, pressure_bar_r, c_bar_r, &
a1_real_m, a1_imag_m, &
a2_real_m, a2_imag_m, &
a3_real_m, a3_imag_m, &
a4_real_m, a4_imag_m, &
a5_real_m, a5_imag_m, &
a1_real_p, a1_imag_p, &
a2_real_p, a2_imag_p, &
a3_real_p, a3_imag_p, &
a4_real_p, a4_imag_p, &
a5_real_p, a5_imag_p, &
a1_real, a1_imag, &
a2_real, a2_imag, &
a3_real, a3_imag, &
a4_real, a4_imag, &
a5_real, a5_imag)
class(turbo_interface_steady_t), intent(inout) :: self
type(chidg_worker_t), intent(inout) :: worker
type(mpi_comm), intent(in) :: bc_comm
character(1), intent(in) :: side
type(AD_D), intent(in) :: density_bar_r(:)
type(AD_D), intent(in) :: vel1_bar_r(:)
type(AD_D), intent(in) :: vel2_bar_r(:)
type(AD_D), intent(in) :: vel3_bar_r(:)
type(AD_D), intent(in) :: pressure_bar_r(:)
type(AD_D), intent(in) :: c_bar_r(:)
type(AD_D), intent(inout) :: a1_real_m(:,:,:)
type(AD_D), intent(inout) :: a1_imag_m(:,:,:)
type(AD_D), intent(inout) :: a2_real_m(:,:,:)
type(AD_D), intent(inout) :: a2_imag_m(:,:,:)
type(AD_D), intent(inout) :: a3_real_m(:,:,:)
type(AD_D), intent(inout) :: a3_imag_m(:,:,:)
type(AD_D), intent(inout) :: a4_real_m(:,:,:)
type(AD_D), intent(inout) :: a4_imag_m(:,:,:)
type(AD_D), intent(inout) :: a5_real_m(:,:,:)
type(AD_D), intent(inout) :: a5_imag_m(:,:,:)
type(AD_D), intent(inout) :: a1_real_p(:,:,:)
type(AD_D), intent(inout) :: a1_imag_p(:,:,:)
type(AD_D), intent(inout) :: a2_real_p(:,:,:)
type(AD_D), intent(inout) :: a2_imag_p(:,:,:)
type(AD_D), intent(inout) :: a3_real_p(:,:,:)
type(AD_D), intent(inout) :: a3_imag_p(:,:,:)
type(AD_D), intent(inout) :: a4_real_p(:,:,:)
type(AD_D), intent(inout) :: a4_imag_p(:,:,:)
type(AD_D), intent(inout) :: a5_real_p(:,:,:)
type(AD_D), intent(inout) :: a5_imag_p(:,:,:)
type(AD_D), allocatable, intent(inout) :: a1_real(:,:,:)
type(AD_D), allocatable, intent(inout) :: a1_imag(:,:,:)
type(AD_D), allocatable, intent(inout) :: a2_real(:,:,:)
type(AD_D), allocatable, intent(inout) :: a2_imag(:,:,:)
type(AD_D), allocatable, intent(inout) :: a3_real(:,:,:)
type(AD_D), allocatable, intent(inout) :: a3_imag(:,:,:)
type(AD_D), allocatable, intent(inout) :: a4_real(:,:,:)
type(AD_D), allocatable, intent(inout) :: a4_imag(:,:,:)
type(AD_D), allocatable, intent(inout) :: a5_real(:,:,:)
type(AD_D), allocatable, intent(inout) :: a5_imag(:,:,:)
integer(ik) :: iradius, itheta, ntheta, itime
type(AD_D) :: beta, B3_real, B3_imag, B4_real, B4_imag, &
density_bar, vel1_bar, vel2_bar, vel3_bar, pressure_bar, c_bar
! NOTE the amplitude strategy here is for 1d characteristics. The unsteady amplitudes
! have diffferent propagation directions so the logic will be different.
if (side=='A') then
! Extrapolate amplitudes from upstream
a1_real = a1_real_m
a1_imag = a1_imag_m
a2_real = a2_real_m
a2_imag = a2_imag_m
a3_real = a3_real_m
a3_imag = a3_imag_m
a4_real = a4_real_m
a4_imag = a4_imag_m
! Zero amplitudes from downstream
a5_real = ZERO*a5_real_p
a5_imag = ZERO*a5_imag_p
! ! Adjust steady modes based on Giles' original steady formulation.
! itime = 1 ! Time-constant
! do iradius = 1,size(a1_real_m,1)
! ! Get average parts
! density_bar = density_bar_r(iradius)
! vel1_bar = vel1_bar_r(iradius)
! vel2_bar = vel2_bar_r(iradius)
! vel3_bar = vel3_bar_r(iradius)
! pressure_bar = pressure_bar_r(iradius)
! c_bar = sqrt(gam*pressure_bar/density_bar)
!
! ! starting with 2 here because the first mode is treated with 1D characteristics
! ntheta = size(a1_real_m,2)
! do itheta = 2,ntheta
! ! Account for sign(mode) in the calculation of beta. The second half of the
! ! modes are negative frequencies.
! if (itheta <= (ntheta-1)/2 + 1) then
! beta = sqrt(c_bar*c_bar - (vel3_bar*vel3_bar + vel2_bar*vel2_bar))
! else if (itheta > (ntheta-1)/2 + 1) then
! beta = -sqrt(c_bar*c_bar - (vel3_bar*vel3_bar + vel2_bar*vel2_bar))
! end if
!
! ! The imaginary part of beta has already been accounted for in
! ! the expressions for B2 and B3
! B3_real = -TWO*vel3_bar*vel2_bar/(vel2_bar*vel2_bar + beta*beta)
! B3_imag = -TWO*beta*vel3_bar/(vel2_bar*vel2_bar + beta*beta)
!
! B4_real = (beta*beta - vel2_bar*vel2_bar)/(beta*beta + vel2_bar*vel2_bar)
! B4_imag = -TWO*beta*vel2_bar/(beta*beta + vel2_bar*vel2_bar)
!
! a5_real(iradius,itheta,itime) = (B3_real*a3_real_m(iradius,itheta,itime) - B3_imag*a3_imag_m(iradius,itheta,itime)) & ! A3*c3 (real)
! - (B4_real*a4_real_m(iradius,itheta,itime) - B4_imag*a4_imag_m(iradius,itheta,itime)) ! A4*c4 (real)
! a5_imag(iradius,itheta,itime) = (B3_imag*a3_real_m(iradius,itheta,itime) + B3_real*a3_imag_m(iradius,itheta,itime)) & ! A3*c3 (imag)
! - (B4_imag*a4_real_m(iradius,itheta,itime) + B4_real*a4_imag_m(iradius,itheta,itime)) ! A4*c4 (imag)
! end do !itheta
! end do !iradius
else if (side=='B') then
! Zero amplitudes from upsteady
! a1_real(:,:,1) = ZERO
! a1_imag(:,:,1) = ZERO
! a2_real(:,:,1) = ZERO
! a2_imag(:,:,1) = ZERO
! a3_real(:,:,1) = ZERO
! a3_imag(:,:,1) = ZERO
! a4_real(:,:,1) = ZERO
! a4_imag(:,:,1) = ZERO
!
! a5_real(:,:,1) = a5_real_p(:,:,1)
! a5_imag(:,:,1) = a5_imag_p(:,:,1)
! Zero incoming amplitudes
a1_real = ZERO
a1_imag = ZERO
a2_real = ZERO
a2_imag = ZERO
a3_real = ZERO
a3_imag = ZERO
a5_real = ZERO
a5_imag = ZERO
! Extrapolate outgoing amplitudes
a4_real = a4_real_p
a4_imag = a4_imag_p
! itime = 1 ! Time-constant
! do iradius = 1,size(a1_real_m,1)
! ! Get average parts
! density_bar = density_bar_r(iradius)
! vel1_bar = vel1_bar_r(iradius)
! vel2_bar = vel2_bar_r(iradius)
! vel3_bar = vel3_bar_r(iradius)
! pressure_bar = pressure_bar_r(iradius)
! c_bar = sqrt(gam*pressure_bar/density_bar)
!
! ! starting with 2 here because the first mode is treated with 1D characteristics
! ntheta = size(a1_real_m,2)
! do itheta = 2,ntheta
! ! Account for sign(mode) in the calculation of beta. The second half of the
! ! modes are negative frequencies.
! if (itheta <= (ntheta-1)/2 + 1) then
! beta = sqrt(c_bar*c_bar - (vel3_bar*vel3_bar + vel2_bar*vel2_bar))
! else if (itheta > (ntheta-1)/2 + 1) then
! beta = -sqrt(c_bar*c_bar - (vel3_bar*vel3_bar + vel2_bar*vel2_bar))
! end if
!
!
! B3_real = -vel2_bar/(c_bar + vel3_bar)
! B3_imag = -beta/(c_bar + vel3_bar)
!
! B4_real = (vel2_bar*vel2_bar - beta*beta)/((c_bar + vel3_bar)**TWO)
! B4_imag = TWO*vel2_bar*beta/((c_bar + vel3_bar)**TWO)
!
!
! a1_real(iradius,itheta,itime) = ZERO
! a1_imag(iradius,itheta,itime) = ZERO
! a2_real(iradius,itheta,itime) = ZERO
! a2_imag(iradius,itheta,itime) = ZERO
!
! a3_real(iradius,itheta,itime) = (B3_real*a5_real_p(iradius,itheta,itime) - B3_imag*a5_imag_p(iradius,itheta,itime))
! a3_imag(iradius,itheta,itime) = (B3_imag*a5_real_p(iradius,itheta,itime) + B3_real*a5_imag_p(iradius,itheta,itime))
!
! a4_real(iradius,itheta,itime) = (B4_real*a5_real_p(iradius,itheta,itime) - B4_imag*a5_imag_p(iradius,itheta,itime))
! a4_imag(iradius,itheta,itime) = (B4_imag*a5_real_p(iradius,itheta,itime) + B4_real*a5_imag_p(iradius,itheta,itime))
!
! end do !itheta
! end do !iradius
else
call chidg_signal(FATAL,"turbo_interface_steady%apply_nonreflecting_condition: invalid input for argument 'side': 'A' or 'B'")
end if
end subroutine apply_nonreflecting_condition
!********************************************************************************
end module bc_state_turbo_interface_steady
| src/equations/fluid/bc/nonlocal/bc_state_turbo_interface_steady.f90 |
*DECK BQR
SUBROUTINE BQR (NM, N, MB, A, T, R, IERR, NV, RV)
C***BEGIN PROLOGUE BQR
C***PURPOSE Compute some of the eigenvalues of a real symmetric
C matrix using the QR method with shifts of origin.
C***LIBRARY SLATEC (EISPACK)
C***CATEGORY D4A6
C***TYPE SINGLE PRECISION (BQR-S)
C***KEYWORDS EIGENVALUES, EISPACK
C***AUTHOR Smith, B. T., et al.
C***DESCRIPTION
C
C This subroutine is a translation of the ALGOL procedure BQR,
C NUM. MATH. 16, 85-92(1970) by Martin, Reinsch, and Wilkinson.
C HANDBOOK FOR AUTO. COMP., VOL II-LINEAR ALGEBRA, 266-272(1971).
C
C This subroutine finds the eigenvalue of smallest (usually)
C magnitude of a REAL SYMMETRIC BAND matrix using the
C QR algorithm with shifts of origin. Consecutive calls
C can be made to find further eigenvalues.
C
C On INPUT
C
C NM must be set to the row dimension of the two-dimensional
C array parameter, A, as declared in the calling program
C dimension statement. NM is an INTEGER variable.
C
C N is the order of the matrix A. N is an INTEGER variable.
C N must be less than or equal to NM.
C
C MB is the (half) band width of the matrix, defined as the
C number of adjacent diagonals, including the principal
C diagonal, required to specify the non-zero portion of the
C lower triangle of the matrix. MB is an INTEGER variable.
C MB must be less than or equal to N on first call.
C
C A contains the lower triangle of the symmetric band input
C matrix stored as an N by MB array. Its lowest subdiagonal
C is stored in the last N+1-MB positions of the first column,
C its next subdiagonal in the last N+2-MB positions of the
C second column, further subdiagonals similarly, and finally
C its principal diagonal in the N positions of the last column.
C Contents of storages not part of the matrix are arbitrary.
C On a subsequent call, its output contents from the previous
C call should be passed. A is a two-dimensional REAL array,
C dimensioned A(NM,MB).
C
C T specifies the shift (of eigenvalues) applied to the diagonal
C of A in forming the input matrix. What is actually determined
C is the eigenvalue of A+TI (I is the identity matrix) nearest
C to T. On a subsequent call, the output value of T from the
C previous call should be passed if the next nearest eigenvalue
C is sought. T is a REAL variable.
C
C R should be specified as zero on the first call, and as its
C output value from the previous call on a subsequent call.
C It is used to determine when the last row and column of
C the transformed band matrix can be regarded as negligible.
C R is a REAL variable.
C
C NV must be set to the dimension of the array parameter RV
C as declared in the calling program dimension statement.
C NV is an INTEGER variable.
C
C On OUTPUT
C
C A contains the transformed band matrix. The matrix A+TI
C derived from the output parameters is similar to the
C input A+TI to within rounding errors. Its last row and
C column are null (if IERR is zero).
C
C T contains the computed eigenvalue of A+TI (if IERR is zero),
C where I is the identity matrix.
C
C R contains the maximum of its input value and the norm of the
C last column of the input matrix A.
C
C IERR is an INTEGER flag set to
C Zero for normal return,
C J if the J-th eigenvalue has not been
C determined after a total of 30 iterations.
C
C RV is a one-dimensional REAL array of dimension NV which is
C at least (2*MB**2+4*MB-3), used for temporary storage. The
C first (3*MB-2) locations correspond to the ALGOL array B,
C the next (2*MB-1) locations correspond to the ALGOL array H,
C and the final (2*MB**2-MB) locations correspond to the MB
C by (2*MB-1) ALGOL array U.
C
C NOTE. For a subsequent call, N should be replaced by N-1, but
C MB should not be altered even when it exceeds the current N.
C
C Calls PYTHAG(A,B) for SQRT(A**2 + B**2).
C
C Questions and comments should be directed to B. S. Garbow,
C Applied Mathematics Division, ARGONNE NATIONAL LABORATORY
C ------------------------------------------------------------------
C
C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
C system Routines - EISPACK Guide, Springer-Verlag,
C 1976.
C***ROUTINES CALLED PYTHAG
C***REVISION HISTORY (YYMMDD)
C 760101 DATE WRITTEN
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890831 Modified array declarations. (WRB)
C 890831 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 920501 Reformatted the REFERENCES section. (WRB)
C***END PROLOGUE BQR
C
INTEGER I,J,K,L,M,N,II,IK,JK,JM,KJ,KK,KM,LL,MB,MK,MN,MZ
INTEGER M1,M2,M3,M4,NI,NM,NV,ITS,KJ1,M21,M31,IERR,IMULT
REAL A(NM,*),RV(*)
REAL F,G,Q,R,S,T,SCALE
REAL PYTHAG
C
C***FIRST EXECUTABLE STATEMENT BQR
IERR = 0
M1 = MIN(MB,N)
M = M1 - 1
M2 = M + M
M21 = M2 + 1
M3 = M21 + M
M31 = M3 + 1
M4 = M31 + M2
MN = M + N
MZ = MB - M1
ITS = 0
C .......... TEST FOR CONVERGENCE ..........
40 G = A(N,MB)
IF (M .EQ. 0) GO TO 360
F = 0.0E0
C
DO 50 K = 1, M
MK = K + MZ
F = F + ABS(A(N,MK))
50 CONTINUE
C
IF (ITS .EQ. 0 .AND. F .GT. R) R = F
IF (R + F .LE. R) GO TO 360
IF (ITS .EQ. 30) GO TO 1000
ITS = ITS + 1
C .......... FORM SHIFT FROM BOTTOM 2 BY 2 MINOR ..........
IF (F .GT. 0.25E0 * R .AND. ITS .LT. 5) GO TO 90
F = A(N,MB-1)
IF (F .EQ. 0.0E0) GO TO 70
Q = (A(N-1,MB) - G) / (2.0E0 * F)
S = PYTHAG(Q,1.0E0)
G = G - F / (Q + SIGN(S,Q))
70 T = T + G
C
DO 80 I = 1, N
80 A(I,MB) = A(I,MB) - G
C
90 DO 100 K = M31, M4
100 RV(K) = 0.0E0
C
DO 350 II = 1, MN
I = II - M
NI = N - II
IF (NI .LT. 0) GO TO 230
C .......... FORM COLUMN OF SHIFTED MATRIX A-G*I ..........
L = MAX(1,2-I)
C
DO 110 K = 1, M3
110 RV(K) = 0.0E0
C
DO 120 K = L, M1
KM = K + M
MK = K + MZ
RV(KM) = A(II,MK)
120 CONTINUE
C
LL = MIN(M,NI)
IF (LL .EQ. 0) GO TO 135
C
DO 130 K = 1, LL
KM = K + M21
IK = II + K
MK = MB - K
RV(KM) = A(IK,MK)
130 CONTINUE
C .......... PRE-MULTIPLY WITH HOUSEHOLDER REFLECTIONS ..........
135 LL = M2
IMULT = 0
C .......... MULTIPLICATION PROCEDURE ..........
140 KJ = M4 - M1
C
DO 170 J = 1, LL
KJ = KJ + M1
JM = J + M3
IF (RV(JM) .EQ. 0.0E0) GO TO 170
F = 0.0E0
C
DO 150 K = 1, M1
KJ = KJ + 1
JK = J + K - 1
F = F + RV(KJ) * RV(JK)
150 CONTINUE
C
F = F / RV(JM)
KJ = KJ - M1
C
DO 160 K = 1, M1
KJ = KJ + 1
JK = J + K - 1
RV(JK) = RV(JK) - RV(KJ) * F
160 CONTINUE
C
KJ = KJ - M1
170 CONTINUE
C
IF (IMULT .NE. 0) GO TO 280
C .......... HOUSEHOLDER REFLECTION ..........
F = RV(M21)
S = 0.0E0
RV(M4) = 0.0E0
SCALE = 0.0E0
C
DO 180 K = M21, M3
180 SCALE = SCALE + ABS(RV(K))
C
IF (SCALE .EQ. 0.0E0) GO TO 210
C
DO 190 K = M21, M3
190 S = S + (RV(K)/SCALE)**2
C
S = SCALE * SCALE * S
G = -SIGN(SQRT(S),F)
RV(M21) = G
RV(M4) = S - F * G
KJ = M4 + M2 * M1 + 1
RV(KJ) = F - G
C
DO 200 K = 2, M1
KJ = KJ + 1
KM = K + M2
RV(KJ) = RV(KM)
200 CONTINUE
C .......... SAVE COLUMN OF TRIANGULAR FACTOR R ..........
210 DO 220 K = L, M1
KM = K + M
MK = K + MZ
A(II,MK) = RV(KM)
220 CONTINUE
C
230 L = MAX(1,M1+1-I)
IF (I .LE. 0) GO TO 300
C .......... PERFORM ADDITIONAL STEPS ..........
DO 240 K = 1, M21
240 RV(K) = 0.0E0
C
LL = MIN(M1,NI+M1)
C .......... GET ROW OF TRIANGULAR FACTOR R ..........
DO 250 KK = 1, LL
K = KK - 1
KM = K + M1
IK = I + K
MK = MB - K
RV(KM) = A(IK,MK)
250 CONTINUE
C .......... POST-MULTIPLY WITH HOUSEHOLDER REFLECTIONS ..........
LL = M1
IMULT = 1
GO TO 140
C .......... STORE COLUMN OF NEW A MATRIX ..........
280 DO 290 K = L, M1
MK = K + MZ
A(I,MK) = RV(K)
290 CONTINUE
C .......... UPDATE HOUSEHOLDER REFLECTIONS ..........
300 IF (L .GT. 1) L = L - 1
KJ1 = M4 + L * M1
C
DO 320 J = L, M2
JM = J + M3
RV(JM) = RV(JM+1)
C
DO 320 K = 1, M1
KJ1 = KJ1 + 1
KJ = KJ1 - M1
RV(KJ) = RV(KJ1)
320 CONTINUE
C
350 CONTINUE
C
GO TO 40
C .......... CONVERGENCE ..........
360 T = T + G
C
DO 380 I = 1, N
380 A(I,MB) = A(I,MB) - G
C
DO 400 K = 1, M1
MK = K + MZ
A(N,MK) = 0.0E0
400 CONTINUE
C
GO TO 1001
C .......... SET ERROR -- NO CONVERGENCE TO
C EIGENVALUE AFTER 30 ITERATIONS ..........
1000 IERR = N
1001 RETURN
END
| slatec/src/bqr.f |
!==============================================================================!
subroutine Turb_Mod_Vis_T_Rsm(turb)
!------------------------------------------------------------------------------!
! Computes the turbulent viscosity for RSM models ('EBM' and 'HJ'). !
! If hybrid option is used turbulent diffusivity is modeled by vis_t. !
! Otherwise, vis_t is used as false diffusion in order to increase !
! stability of computation. !
!------------------------------------------------------------------------------!
implicit none
!---------------------------------[Arguments]----------------------------------!
type(Turb_Type), target :: turb
!-----------------------------------[Locals]-----------------------------------!
type(Field_Type), pointer :: flow
type(Grid_Type), pointer :: grid
type(Var_Type), pointer :: u, v, w
type(Var_Type), pointer :: kin, eps
type(Var_Type), pointer :: uu, vv, ww, uv, uw, vw
integer :: c
real :: cmu_mod
!==============================================================================!
! Dimensions: !
! !
! production p_kin [m^2/s^3] | rate-of-strain shear [1/s] !
! dissipation eps % n [m^2/s^3] | turb. visc. vis_t [kg/(m*s)] !
! wall shear s. tau_wall [kg/(m*s^2)]| dyn visc. viscosity [kg/(m*s)] !
! density density [kg/m^3] | turb. kin en. kin % n [m^2/s^2] !
! cell volume vol [m^3] | length lf [m] !
! left hand s. A [kg/s] | right hand s. b [kg*m^2/s^3]!
! wall visc. vis_w [kg/(m*s)] | kinematic viscosity [m^2/s] !
! thermal cap. capacity[m^2/(s^2*K)]| therm. conductivity [kg*m/(s^3*K)]!
!------------------------------------------------------------------------------!
! Take aliases
flow => turb % pnt_flow
grid => flow % pnt_grid
call Field_Mod_Alias_Momentum(flow, u, v, w)
call Turb_Mod_Alias_K_Eps (turb, kin, eps)
call Turb_Mod_Alias_Stresses (turb, uu, vv, ww, uv, uw, vw)
call Calculate_Shear_And_Vorticity(flow)
do c = 1, grid % n_cells
kin % n(c) = 0.5*max(uu % n(c) + vv % n(c) + ww % n(c), TINY)
cmu_mod = max(-( uu % n(c) * u % x(c) &
+ vv % n(c) * v % y(c) &
+ ww % n(c) * w % z(c) &
+ uv % n(c) * (v % x(c) + u % y(c)) &
+ uw % n(c) * (u % z(c) + w % x(c)) &
+ vw % n(c) * (v % z(c) + w % y(c))) &
/ (kin % n(c) * turb % t_scale(c) * flow % shear(c)**2 + TINY), 0.0)
cmu_mod = min(0.12, cmu_mod)
turb % vis_t(c) = cmu_mod * flow % density(c) &
* kin % n(c) * turb % t_scale(c)
turb % vis_t(c) = max(turb % vis_t(c), TINY)
end do
call Grid_Mod_Exchange_Cells_Real(grid, turb % vis_t)
end subroutine
| Sources/Process/Turb_Mod/Vis_T_Rsm.f90 |
!> IMPACT
!! \author Rolf Henniger, Institute of Fluid Dynamics, ETH Zurich ([email protected])
!! \date Mai 2005 - Dec 2011
!> \brief module providing functions to initiliaze and apply RestrictionOp
module cmod_RestrictionOp
use iso_c_binding
use mpi
implicit none
contains
subroutine MG_getCRVS( &
iimax, &
BC_L, &
BC_U, &
dd, &
Nf, &
bL, &
bU, &
xf, &
cR ) bind( c, name='MG_getCRVS' )
implicit none
integer(c_int), intent(in) :: iimax
integer(c_int), intent(in) :: BC_L
integer(c_int), intent(in) :: BC_U
integer(c_int), intent(in) :: dd
integer(c_int), intent(in) :: Nf
integer(c_int), intent(in) :: bL, bU
real(c_double), intent(in) :: xf( bL:(Nf+bU) )
real(c_double), intent(out) :: cR(-1:1,1:iimax)
real(c_double) :: h(1:2)
integer(c_int) :: i, ii
cR = 0.
!====================================================================================
!=== Restriktion, linienweise, 1d ===================================================
!====================================================================================
do i = 1, iimax
if( 1==dd ) then
cR(-1,i) = 0.
cR( 0,i) = 1.
cR( 1,i) = 0.
else
ii = dd*(i-1)+1
h( 1 ) = xf(ii ) - xf(ii-1)
h( 2 ) = xf(ii+1) - xf(ii )
cR(-1,i) = h(2)/( h(1) + h(2) )/2. ! 1./4. for equi
cR( 0,i) = 1./2.
cR( 1,i) = h(1)/( h(1) + h(2) )/2. ! 1./4/ for equi
end if
end do
if( BC_L > 0 ) then
cR(-1,1) = 0.
cR( 0,1) = 1.
cR( 1,1) = 0.
end if
if (BC_L == -2) then
cR( 1,1) = cR( 1,1) + cR(-1,1)
cR(-1,1) = 0.
end if
if (BC_U > 0) then
cR(-1,iimax) = 0.
cR( 0,iimax) = 1.
cR( 1,iimax) = 0.
end if
if (BC_U == -2) then
cR(-1,iimax) = cR( 1,iimax) + cR(-1,iimax)
cR( 1,iimax) = 0.
end if
end subroutine MG_getCRVS
subroutine MG_getCRS( &
iimax, &
BC_L, &
BC_U, &
dd, &
Nf, &
bL, &
bU, &
xf, &
cR ) bind( c, name='MG_getCRS' )
implicit none
integer(c_int), intent(in) :: iimax
integer(c_int), intent(in) :: BC_L
integer(c_int), intent(in) :: BC_U
integer(c_int), intent(in) :: dd
integer(c_int), intent(in) :: Nf
integer(c_int), intent(in) :: bL, bU
real(c_double), intent(in) :: xf( bL:(Nf+bU) )
real(c_double), intent(out) :: cR(-1:1,1:iimax)
real(c_double) :: h(1:2)
integer(c_int) :: i, ii
cR = 0.
!====================================================================================
!=== Restriktion, linienweise, 1d ===================================================
!====================================================================================
do i = 1, iimax
if( 1==dd ) then
cR(-1,i) = 0.
cR( 0,i) = 1.
cR( 1,i) = 0.
else
ii = dd*(i-1)+1
h( 1 ) = xf(ii ) - xf(ii-1)
h( 2 ) = xf(ii+1) - xf(ii )
cR(-1,i) = h(2)/( h(1) + h(2) )/2. ! 1./4. for equi
cR( 0,i) = 1./2.
cR( 1,i) = h(1)/( h(1) + h(2) )/2. ! 1./4/ for equi
end if
end do
if( BC_L > 0 ) then
!cR( 1,1) = cR(1,1) + cR(-1,1) ! equivalent to 0.5 0.5
cR(-1,1) = 0.
cR( 0,1) = 0.5
cR( 1,1) = 0.5
end if
if (BC_L == -2) then
cR( 1,1) = cR( 1,1) + cR(-1,1)
cR(-1,1) = 0.
end if
if (BC_U > 0) then
cR(-1,iimax) = 0.5
cR( 0,iimax) = 0.5
cR( 1,iimax) = 0.
end if
if (BC_U == -2) then
cR(-1,iimax) = cR( 1,iimax) + cR(-1,iimax)
cR( 1,iimax) = 0.
end if
!! this has proven very good for generated rhs + random init
!! for testing
if( BC_L > 0 ) then
cR(-1,1) = 0.
cR( 0,1) = 1.
cR( 1,1) = 0.
end if
if (BC_L == -2) then
cR( 1,1) = cR( 1,1) + cR(-1,1)
cR(-1,1) = 0.
end if
if (BC_U > 0) then
cR(-1,iimax) = 0.
cR( 0,iimax) = 1.
cR( 1,iimax) = 0.
end if
if (BC_U == -2) then
cR(-1,iimax) = cR( 1,iimax) + cR(-1,iimax)
cR( 1,iimax) = 0.
end if
end subroutine MG_getCRS
!> \brief ugly corner handling
!! \deprecated
subroutine MG_RestrictCorners( &
Nc, &
bLc,bUc, &
BCL, BCU, &
phif ) bind( c, name='MG_RestrictCorners' )
implicit none
integer(c_int), intent(in) :: Nc(3)
integer(c_int), intent(in) :: bLc(3)
integer(c_int), intent(in) :: bUc(3)
integer(c_int), intent(in) :: BCL(3)
integer(c_int), intent(in) :: BCU(3)
real(c_double), intent(inout) :: phif (bLc(1):(Nc(1)+bUc(1)),bLc(2):(Nc(2)+bUc(2)),bLc(3):(Nc(3)+bUc(3)))
!if (BC(1,1,g) > 0 .and. BC(1,2,g) > 0) fine1( 1 , 1 ,1:NN(3,g)) = (fine1(2 ,1 ,1:NN(3,g)) + fine1(1 ,2 ,1:NN(3,g)))/2.
!if (BC(1,1,g) > 0 .and. BC(2,2,g) > 0) fine1( 1 , NN(2,g),1:NN(3,g)) = (fine1(2 ,NN(2,g),1:NN(3,g)) + fine1(1 ,NN(2,g)-1,1:NN(3,g)))/2.
!if (BC(2,1,g) > 0 .and. BC(1,2,g) > 0) fine1( NN(1,g), 1 ,1:NN(3,g)) = (fine1(NN(1,g)-1,1 ,1:NN(3,g)) + fine1(NN(1,g),2 ,1:NN(3,g)))/2.
!if (BC(2,1,g) > 0 .and. BC(2,2,g) > 0) fine1( NN(1,g), NN(2,g),1:NN(3,g)) = (fine1(NN(1,g)-1,NN(2,g),1:NN(3,g)) + fine1(NN(1,g),NN(2,g)-1,1:NN(3,g)))/2.
if (BCL(1) > 0 .and. BCL(2) > 0) phif( 1, 1, 1:Nc(3) ) = ( phif(1+1, 1, 1:Nc(3)) + phif(1 , 1+1, 1:Nc(3)) )/2.
if (BCL(1) > 0 .and. BCU(2) > 0) phif( 1, Nc(2), 1:Nc(3) ) = ( phif(1+1, Nc(2), 1:Nc(3)) + phif(1 , Nc(2)-1, 1:Nc(3)) )/2.
if (BCU(1) > 0 .and. BCL(2) > 0) phif( Nc(1), 1, 1:Nc(3) ) = ( phif(Nc(1)-1, 1, 1:Nc(3)) + phif(Nc(1), 1+1, 1:Nc(3)) )/2.
if (BCU(1) > 0 .and. BCU(2) > 0) phif( Nc(1), Nc(2), 1:Nc(3) ) = ( phif(Nc(1)-1, Nc(2), 1:Nc(3)) + phif(Nc(1), Nc(2)-1, 1:Nc(3)) )/2.
!if (BC(1,1,g) > 0 .and. BC(1,3,g) > 0) fine1( 1 ,1:NN(2,g), 1 ) = (fine1(2 ,1:NN(2,g),1 ) + fine1(1 ,1:NN(2,g),2 ))/2.
!if (BC(1,1,g) > 0 .and. BC(2,3,g) > 0) fine1( 1 ,1:NN(2,g), NN(3,g)) = (fine1(2 ,1:NN(2,g),NN(3,g)) + fine1(1 ,1:NN(2,g),NN(3,g)-1))/2.
!if (BC(2,1,g) > 0 .and. BC(1,3,g) > 0) fine1( NN(1,g),1:NN(2,g), 1 ) = (fine1(NN(1,g)-1,1:NN(2,g),1 ) + fine1(NN(1,g),1:NN(2,g),2 ))/2.
!if (BC(2,1,g) > 0 .and. BC(2,3,g) > 0) fine1( NN(1,g),1:NN(2,g), NN(3,g)) = (fine1(NN(1,g)-1,1:NN(2,g),NN(3,g)) + fine1(NN(1,g),1:NN(2,g),NN(3,g)-1))/2.
if (BCL(1) > 0 .and. BCL(3) > 0) phif( 1, 1:Nc(2), 1 ) = ( phif(1+1, 1:Nc(2), 1 ) + phif(1, 1:Nc(2), 1+1) )/2.
if (BCL(1) > 0 .and. BCU(3) > 0) phif( 1, 1:Nc(2), Nc(3) ) = ( phif(1+1, 1:Nc(2), Nc(3)) + phif(1, 1:Nc(2), Nc(3)-1) )/2.
if (BCU(1) > 0 .and. BCL(3) > 0) phif( Nc(1), 1:Nc(2), 1 ) = ( phif(Nc(1)-1, 1:Nc(2), 1 ) + phif(Nc(1), 1:Nc(2), 1+1) )/2.
if (BCU(1) > 0 .and. BCU(3) > 0) phif( Nc(1), 1:Nc(2), Nc(3) ) = ( phif(Nc(1)-1, 1:Nc(2), Nc(3)) + phif(Nc(1), 1:Nc(2), Nc(3)-1) )/2.
!if (BC(1,2,g) > 0 .and. BC(1,3,g) > 0) fine1(1:NN(1,g), 1 , 1 ) = (fine1(1:NN(1,g),2 ,1 ) + fine1(1:NN(1,g),1 ,2 ))/2.
!if (BC(1,2,g) > 0 .and. BC(2,3,g) > 0) fine1(1:NN(1,g), 1 , NN(3,g)) = (fine1(1:NN(1,g),2 ,NN(3,g)) + fine1(1:NN(1,g),1 ,NN(3,g)-1))/2.
!if (BC(2,2,g) > 0 .and. BC(1,3,g) > 0) fine1(1:NN(1,g), NN(2,g), 1 ) = (fine1(1:NN(1,g),NN(2,g)-1,1 ) + fine1(1:NN(1,g),NN(2,g),2 ))/2.
!if (BC(2,2,g) > 0 .and. BC(2,3,g) > 0) fine1(1:NN(1,g), NN(2,g), NN(3,g)) = (fine1(1:NN(1,g),NN(2,g)-1,NN(3,g)) + fine1(1:NN(1,g),NN(2,g),NN(3,g)-1))/2.
if (BCL(2) > 0 .and. BCL(3) > 0) phif( 1:Nc(1), 1, 1 ) = ( phif(1:Nc(1), 1+1, 1 ) + phif(1:Nc(1), 1, 1+1 ) )/2.
if (BCL(2) > 0 .and. BCU(3) > 0) phif( 1:Nc(1), 1, Nc(3) ) = ( phif(1:Nc(1), 1+1, Nc(3)) + phif(1:Nc(1), 1, Nc(3)-1) )/2.
if (BCU(2) > 0 .and. BCL(3) > 0) phif( 1:Nc(1), Nc(2), 1 ) = ( phif(1:Nc(1), Nc(2)-1, 1 ) + phif(1:Nc(1), Nc(2), 1+1 ) )/2.
if (BCU(2) > 0 .and. BCU(3) > 0) phif( 1:Nc(1), Nc(2), Nc(3) ) = ( phif(1:Nc(1), Nc(2)-1, Nc(3)) + phif(1:Nc(1), Nc(2), Nc(3)-1) )/2.
end subroutine MG_RestrictCorners
!> \note: - für allgemeine di, dj, dk geeignet
!! - überlappende Schicht in Blöcken wird (der Einfachheit
!! halber) ebenfalls ausgetauscht, ist aber im Prinzip
!! redundant (genauer: phiC(S1R:N1R,S2R:N2R,S3R:N3R) = ...).
!! - Motivation für diese kurze Routine ist die Möglichkeit,
!! auch Varianten wie Full-Weighting etc. ggf. einzubauen,
!! ansonsten könnte sie auch eingespaart werden.
!! - Die Block-überlappenden Stirnflächen werden ebenfalls
!! mitverarbeitet, aber eigentlich nicht gebraucht
!! (erleichtert die Programmierung), so dass eine
!! Initialisierung notwendig ist. Dies wiederum bedingt die
!! INTENT(inout)-Deklaration.
subroutine MG_restrictHW( &
dimens, &
Nf, &
bLf,bUf, &
Nc, &
bLc,bUc, &
iimax, &
dd, &
cR1,cR2,cR3, &
phif, &
phic ) bind(c,name='MG_restrictHW')
implicit none
integer(c_int), intent(in) :: dimens
integer(c_int), intent(in) :: Nf(3)
integer(c_int), intent(in) :: bLf(3)
integer(c_int), intent(in) :: bUf(3)
integer(c_int), intent(in) :: Nc(3)
integer(c_int), intent(in) :: bLc(3)
integer(c_int), intent(in) :: bUc(3)
integer(c_int), intent(in) :: iimax(3)
integer(c_int), intent(in) :: dd(3)
real(c_double), intent(in) :: cR1 ( -1:1, 1:iimax(1) )
real(c_double), intent(in) :: cR2 ( -1:1, 1:iimax(2) )
real(c_double), intent(in) :: cR3 ( -1:1, 1:iimax(3) )
real(c_double), intent(in) :: phif (bLf(1):(Nf(1)+bUf(1)),bLf(2):(Nf(2)+bUf(2)),bLf(3):(Nf(3)+bUf(3)))
real(c_double), intent(out) :: phic (bLc(1):(Nc(1)+bUc(1)),bLc(2):(Nc(2)+bUc(2)),bLc(3):(Nc(3)+bUc(3)))
integer(c_int) :: i, ii
integer(c_int) :: j, jj
integer(c_int) :: k, kk
if (dimens == 3) then
do kk = 1, iimax(3)
k = dd(3)*(kk-1)+1
do jj = 1, iimax(2)
j = dd(2)*(jj-1)+1
do ii = 1, iimax(1)
i = dd(1)*(ii-1)+1
phic(ii,jj,kk) = ((cR1( 0,ii)+cR2( 0,jj)+cR3( 0,kk))*phif(i ,j ,k ) + &
& cR1(-1,ii) *phif(i-1,j ,k ) + &
& cR1( 1,ii) *phif(i+1,j ,k ) + &
& cR2(-1,jj) *phif(i ,j-1,k ) + &
& cR2( 1,jj) *phif(i ,j+1,k ) + &
& cR3(-1,kk)*phif(i ,j ,k-1) + &
& cR3( 1,kk)*phif(i ,j ,k+1)) / 3.
end do
end do
end do
else
k = 1
kk = 1
do jj = 1, iimax(2)
j = dd(2)*(jj-1)+1
do ii = 1, iimax(1)
i = dd(1)*(ii-1)+1
phic(ii,jj,kk) = ((cR1( 0,ii)+cR2(0,jj))*phif(i ,j ,k) + &
& cR1(-1,ii) *phif(i-1,j ,k) + &
& cR1( 1,ii) *phif(i+1,j ,k) + &
& cR2(-1,jj)*phif(i ,j-1,k) + &
& cR2( 1,jj)*phif(i ,j+1,k)) / 2.
end do
end do
end if
end subroutine MG_restrictHW
subroutine MG_RestrictGather( &
Nc, &
bLc,bUc, &
bCL_loc, &
bCL_glo, &
iimax, &
n_gather, &
participate_yes, &
rankc2, &
comm2, &
recvR, &
dispR, &
sizsR, &
offsR, &
phic ) bind(c,name='MG_RestrictGather')
implicit none
integer(c_int), intent(in) :: Nc(3)
integer(c_int), intent(in) :: bLc(3)
integer(c_int), intent(in) :: bUc(3)
integer(c_int), intent(in) :: bCL_loc(3)
integer(c_int), intent(in) :: bCL_glo(3)
integer(c_int), intent(in) :: iimax(3)
integer(c_int), intent(in) :: n_gather(3)
logical(c_bool), intent(in) :: participate_yes
integer(c_int), intent(in) :: rankc2
integer(c_int), intent(in) :: comm2
integer(c_int), intent(in) :: recvR( 1:n_gather(1)*n_gather(2)*n_gather(3) )
integer(c_int), intent(in) :: dispR( 1:n_gather(1)*n_gather(2)*n_gather(3) )
integer(c_int), intent(in) :: sizsR(1:3, 1:n_gather(1)*n_gather(2)*n_gather(3) )
integer(c_int), intent(in) :: offsR(1:3, 1:n_gather(1)*n_gather(2)*n_gather(3) )
real(c_double),intent(inout) :: phic (bLc(1):(Nc(1)+bUc(1)),bLc(2):(Nc(2)+bUc(2)),bLc(3):(Nc(3)+bUc(3)))
integer(c_int) :: i, ii
integer(c_int) :: j, jj
integer(c_int) :: k, kk
integer(c_int) :: merror
real(c_double), allocatable :: sendbuf(:,:,:)
integer(c_int) :: sizsg(1:3), offsg(1:3), dispg
real(c_double) :: recvbuf( 1:( Nc(1)*Nc(2)*Nc(3)*3 ) )
integer(c_int) :: SS(3)
!if (n_gather(1)*n_gather(2)*n_gather(3) > 1) then
SS(:) = 1
if( 0<BCL_loc(1) ) SS(1) = 0
if( 0<BCL_loc(2) ) SS(2) = 0
if( 0<BCL_loc(3) ) SS(3) = 0
! Anmerkung: Besser nicht fest allocieren um Speicherplatz zu sparen, ODER
! gleich "phic" verwenden!
allocate(sendbuf(SS(1):iimax(1),SS(2):iimax(2),SS(3):iimax(3)))
do kk = SS(3), iimax(3)
do jj = SS(2), iimax(2)
do ii = SS(1), iimax(1)
sendbuf(ii,jj,kk) = phic(ii,jj,kk)
end do
end do
end do
call MPI_GATHERv( &
sendbuf, & ! starting address of send buffer (choice)
(iimax(1)-SS(1)+1)*(iimax(2)-SS(2)+1)*(iimax(3)-SS(3)+1), & ! of elements in send buffer
MPI_REAL8, & ! data type of send buffer elements
recvbuf, & ! address of receive buffer
recvR, & ! non-negative integer array (of length group size) containing the number of elements that are received from each process
dispR, & ! integer array (of length group size). Entry i specifies the displacement (relative to recvbuf) at which to place the incoming data from process i
MPI_REAL8, & ! data type of receive buffer elements (handle)
rankc2, & ! rank of receiving process
comm2, & ! communicator
merror)
deallocate(sendbuf)
if( participate_yes ) then
do k = 1, n_gather(3)
do j = 1, n_gather(2)
do i = 1, n_gather(1)
sizsg(1:3) = sizsR(1:3,i+(j-1)*n_gather(1)+(k-1)*n_gather(1)*n_gather(2))
offsg(1:3) = offsR(1:3,i+(j-1)*n_gather(1)+(k-1)*n_gather(1)*n_gather(2))
dispg = dispR( i+(j-1)*n_gather(1)+(k-1)*n_gather(1)*n_gather(2))
if( 1==i .and. 0<BCL_glo(1) ) offsg(1) = -1
if( 1==j .and. 0<BCL_glo(2) ) offsg(2) = -1
if( 1==k .and. 0<BCL_glo(3) ) offsg(3) = -1
do kk = 1, sizsg(3)
do jj = 1, sizsg(2)
do ii = 1, sizsg(1)
phic(ii+offsg(1),jj+offsg(2),kk+offsg(3)) = recvbuf(dispg+ii+(jj-1)*sizsg(1)+(kk-1)*sizsg(1)*sizsg(2))
end do
end do
end do
end do
end do
end do
end if
end subroutine MG_RestrictGather
!> restriction
!! \note - für allgemeine di, dj, dk geeignet!
!! - überlappende Schicht in Blöcken wird (der Einfachheit halber) ebenfalls ausgetauscht, ist
!! aber im Prinzip redundant (genauer: phiC(S1R:N1R,S2R:N2R,S3R:N3R) = ...).
!! - Motivation für diese kurze Routine ist die Möglichkeit, auch Varianten wie Full-Weighting
!! etc. ggf. einzubauen, ansonsten könnte sie auch eingespaart werden.
!! - Die Block-überlappenden Stirnflächen werden ebenfalls mitverarbeitet, aber eigentlich
!! nicht gebraucht (erleichtert die Programmierung), so dass eine Initialisierung notwendig
!! ist. Dies wiederum bedingt die INTENT(inout)-Deklaration.
subroutine MG_restrictFW( &
dimens, &
Nf, &
bLf,bUf, &
Nc, &
bLc,bUc, &
iimax, &
dd, &
cR1,cR2,cR3, &
phif, &
phic ) bind(c,name='MG_restrictFW')
implicit none
integer(c_int), intent(in) :: dimens
integer(c_int), intent(in) :: Nf(3)
integer(c_int), intent(in) :: bLf(3)
integer(c_int), intent(in) :: bUf(3)
integer(c_int), intent(in) :: Nc(3)
integer(c_int), intent(in) :: bLc(3)
integer(c_int), intent(in) :: bUc(3)
integer(c_int), intent(in) :: iimax(3)
integer(c_int), intent(in) :: dd(3)
real(c_double), intent(in) :: cR1 ( -1:1, 1:iimax(1) )
real(c_double), intent(in) :: cR2 ( -1:1, 1:iimax(2) )
real(c_double), intent(in) :: cR3 ( -1:1, 1:iimax(3) )
real(c_double), intent(in) :: phif (bLf(1):(Nf(1)+bUf(1)),bLf(2):(Nf(2)+bUf(2)),bLf(3):(Nf(3)+bUf(3)))
real(c_double), intent(out) :: phic (bLc(1):(Nc(1)+bUc(1)),bLc(2):(Nc(2)+bUc(2)),bLc(3):(Nc(3)+bUc(3)))
integer(c_int) :: i, ii
integer(c_int) :: j, jj
integer(c_int) :: k, kk
if( dimens == 3 ) then
do kk = 1, iimax(3)
k = dd(3)*(kk-1)+1
do jj = 1, iimax(2)
j = dd(2)*(jj-1)+1
do ii = 1, iimax(1)
i = dd(1)*(ii-1)+1
phic(ii,jj,kk) = &
& cR1(-1,ii)*cR2(-1,jj)*cR3(-1,kk)*phif(i-1,j-1,k-1) + &
& cR1( 0,ii)*cR2(-1,jj)*cR3(-1,kk)*phif(i ,j-1,k-1) + &
& cR1(+1,ii)*cR2(-1,jj)*cR3(-1,kk)*phif(i+1,j-1,k-1) + &
!
& cR1(-1,ii)*cR2( 0,jj)*cR3(-1,kk)*phif(i-1,j ,k-1) + &
& cR1( 0,ii)*cR2( 0,jj)*cR3(-1,kk)*phif(i ,j ,k-1) + &
& cR1(+1,ii)*cR2( 0,jj)*cR3(-1,kk)*phif(i+1,j ,k-1) + &
!
& cR1(-1,ii)*cR2(+1,jj)*cR3(-1,kk)*phif(i-1,j+1,k-1) + &
& cR1( 0,ii)*cR2(+1,jj)*cR3(-1,kk)*phif(i ,j+1,k-1) + &
& cR1(+1,ii)*cR2(+1,jj)*cR3(-1,kk)*phif(i+1,j+1,k-1) + &
!
& cR1(-1,ii)*cR2(-1,jj)*cR3( 0,kk)*phif(i-1,j-1,k ) + &
& cR1( 0,ii)*cR2(-1,jj)*cR3( 0,kk)*phif(i ,j-1,k ) + &
& cR1(+1,ii)*cR2(-1,jj)*cR3( 0,kk)*phif(i+1,j-1,k ) + &
!
& cR1(-1,ii)*cR2( 0,jj)*cR3( 0,kk)*phif(i-1,j ,k ) + &
& cR1( 0,ii)*cR2( 0,jj)*cR3( 0,kk)*phif(i ,j ,k ) + &
& cR1(+1,ii)*cR2( 0,jj)*cR3( 0,kk)*phif(i+1,j ,k ) + &
!
& cR1(-1,ii)*cR2(+1,jj)*cR3( 0,kk)*phif(i-1,j+1,k ) + &
& cR1( 0,ii)*cR2(+1,jj)*cR3( 0,kk)*phif(i ,j+1,k ) + &
& cR1(+1,ii)*cR2(+1,jj)*cR3( 0,kk)*phif(i+1,j+1,k ) + &
!
!
& cR1(-1,ii)*cR2(-1,jj)*cR3(+1,kk)*phif(i-1,j-1,k+1) + &
& cR1( 0,ii)*cR2(-1,jj)*cR3(+1,kk)*phif(i ,j-1,k+1) + &
& cR1(+1,ii)*cR2(-1,jj)*cR3(+1,kk)*phif(i+1,j-1,k+1) + &
!
& cR1(-1,ii)*cR2( 0,jj)*cR3(+1,kk)*phif(i-1,j ,k+1) + &
& cR1( 0,ii)*cR2( 0,jj)*cR3(+1,kk)*phif(i ,j ,k+1) + &
& cR1(+1,ii)*cR2( 0,jj)*cR3(+1,kk)*phif(i+1,j ,k+1) + &
!
& cR1(-1,ii)*cR2(+1,jj)*cR3(+1,kk)*phif(i-1,j+1,k+1) + &
& cR1( 0,ii)*cR2(+1,jj)*cR3(+1,kk)*phif(i ,j+1,k+1) + &
& cR1(+1,ii)*cR2(+1,jj)*cR3(+1,kk)*phif(i+1,j+1,k+1)
end do
end do
end do
else
k = 1
kk = 1
do jj = 1, iimax(2)
j = dd(2)*(jj-1)+1
do ii = 1, iimax(1)
i = dd(1)*(ii-1)+1
phic(ii,jj,kk) = &
& cR1(-1,ii)*cR2(-1,jj)*phif(i-1,j-1,k) + &
& cR1( 0,ii)*cR2(-1,jj)*phif(i ,j-1,k) + &
& cR1(+1,ii)*cR2(-1,jj)*phif(i+1,j-1,k) + &
!
& cR1(-1,ii)*cR2( 0,jj)*phif(i-1,j ,k) + &
& cR1( 0,ii)*cR2( 0,jj)*phif(i ,j ,k) + &
& cR1(+1,ii)*cR2( 0,jj)*phif(i+1,j ,k) + &
!
& cR1(-1,ii)*cR2(+1,jj)*phif(i-1,j+1,k) + &
& cR1( 0,ii)*cR2(+1,jj)*phif(i ,j+1,k) + &
& cR1(+1,ii)*cR2(+1,jj)*phif(i+1,j+1,k)
end do
end do
end if
end subroutine MG_restrictFW
!!> \note - Null-Setzen am Rand nicht notwendig!
!!! - Da nur in Richtung der jeweiligen Geschwindigkeitskomponente
!!! gemittelt wird, muss nicht die spezialisierte Helmholtz-Variante
!!! aufgerufen werden.
!!! - Austauschrichtung ist invers zu ex1, ex2, ex3. Bei mehreren Blöcken
!!! wird auch der jeweils redundante "überlappende" Punkt aufgrund der
!!! zu grossen Intervallgrenzen (1:iimax) zwar berechnet, aber aufgrund
!!! des Einweg-Austauschs falsch berechnet! Dieses Vorgehen wurde
!!! bislang aus übersichtsgründen vorgezogen, macht aber eine
!!! Initialisierung notwendig.
!!! Dabei werden Intervalle der Form 0:imax anstelle von 1:imax
!!! bearbeitet, da hier nur die das feinste Geschwindigkeitsgitter
!!! behandelt wird!
!!! - INTENT(inout) ist bei den feinen Gittern notwendig, da Ghost-Werte
!!! ausgetauscht werden müssen.
!!! - Zuviele Daten werden ausgetauscht; eigentlich müsste in der
!!! Grenzfläche nur jeder 4. Punkt behandelt werden (4x zuviel!).
!!! Leider etwas unschön, könnte aber durch eine spezialisierte
!!! Austauschroutine behandelt werden, da das übergeben von Feldern mit
!!! Intervallen von b1L:(iimax+b1U) nur sehr schlecht funktionieren
!!! würde (d.h. mit Umkopieren).
!subroutine MG_restrictFWV( &
!dimens, &
!dir, &
!Nf, &
!bLf,bUf, &
!SSf,NNf, &
!Nc, &
!bLc,bUc, &
!SSc,NNc, &
!iimax, &
!dd, &
!cRV, &
!cR1,cR2,cR3, &
!phif, &
!phic ) bind (c,name='MG_restrictFWV')
!implicit none
!integer(c_int), intent(in) :: dimens
!integer(c_int), intent(in) :: dir
!integer(c_int), intent(in) :: Nf(1:3)
!integer(c_int), intent(in) :: bLf(1:3)
!integer(c_int), intent(in) :: bUf(1:3)
!integer(c_int), intent(in) :: SSf(1:3)
!integer(c_int), intent(in) :: NNf(1:3)
!integer(c_int), intent(in) :: Nc(1:3)
!integer(c_int), intent(in) :: bLc(1:3)
!integer(c_int), intent(in) :: bUc(1:3)
!integer(c_int), intent(in) :: SSc(1:3)
!integer(c_int), intent(in) :: NNc(1:3)
!integer(c_int), intent(in) :: iimax(1:3)
!integer(c_int), intent(in) :: dd(1:3)
!real(c_double), intent(in) :: cRV ( 1:2, 0:iimax(dir) )
!real(c_double), intent(in) :: cR1 ( -1:1, 1:iimax(1) )
!real(c_double), intent(in) :: cR2 ( -1:1, 1:iimax(2) )
!real(c_double), intent(in) :: cR3 ( -1:1, 1:iimax(3) )
!real(c_double), intent(in) :: phif (bLf(1):(Nf(1)+bUf(1)),bLf(2):(Nf(2)+bUf(2)),bLf(3):(Nf(3)+bUf(3)))
!real(c_double), intent(out) :: phic (bLc(1):(Nc(1)+bUc(1)),bLc(2):(Nc(2)+bUc(2)),bLc(3):(Nc(3)+bUc(3)))
!integer(c_int) :: i, ii
!integer(c_int) :: j, jj
!integer(c_int) :: k, kk
!! TEST!!! Test schreiben, um n_gather(:,2) .GT. 1 hier zu vermeiden!
!! Gleiches gilt natürlich für die Interpolation.
!!====================================================================================
!if( 1==dir ) then
!if( 2==dimens ) then
!!write(*,*)
!!do kk = SSc(3), iimax(3)
!!k = kk
!!do jj = SSc(2), iimax(2)
!!j = dd(2)*(jj-1)+1
!!do ii = SSc(1), iimax(1)
!!!i = max( dd(1)*(ii-1)+1, 0 )
!!i = dd(1)*(ii-1)+1
!!!write(*,*) jj, j
!!if( 1==dd(1) ) then
!!!phic(ii,jj,kk) = &
!!!& cR2( -1, jj)*phif(i,j-1,k ) + &
!!!& cR2( 0, jj)*phif(i,j ,k ) + &
!!!& cR2( +1, jj)*phif(i,j+1,k )
!!!!
!!else
!!!phic(ii,jj,kk) = &
!!!& cRV(1,ii)*cR2(-1,jj)*phif(i ,j-1,k ) + &
!!!& cRV(2,ii)*cR2(-1,jj)*phif(i+1,j-1,k ) + &
!!!!
!!!& cRV(1,ii)*cR2( 0,jj)*phif(i ,j ,k ) + &
!!!& cRV(2,ii)*cR2( 0,jj)*phif(i+1,j ,k ) + &
!!!!
!!!& cRV(1,ii)*cR2(+1,jj)*phif(i ,j+1,k ) + &
!!!& cRV(2,ii)*cR2(+1,jj)*phif(i+1,j+1,k )
!!!!
!!end if
!!end do
!!end do
!!end do
!else
!do kk = SSc(3), iimax(3)
!k = dd(3)*(kk-1)+1
!do jj = SSc(2), iimax(2)
!j = dd(2)*(jj-1)+1
!do ii = SSc(1), iimax(1)
!!i = max( dd(1)*(ii-1)+1, 0 )
!i = dd(1)*(ii-1)+1
!if( 1==dd(1) ) then
!!phic(ii,jj,kk) = &
!!& cR2( -1, jj)*cR3(-1,kk)*phif(i,j-1,k-1) + &
!!& cR2( 0, jj)*cR3(-1,kk)*phif(i,j ,k-1) + &
!!& cR2( +1, jj)*cR3(-1,kk)*phif(i,j+1,k-1) + &
!!!
!!& cR2( -1, jj)*cR3( 0,kk)*phif(i,j-1,k ) + &
!!& cR2( 0, jj)*cR3( 0,kk)*phif(i,j ,k ) + &
!!& cR2( +1, jj)*cR3( 0,kk)*phif(i,j+1,k ) + &
!!!
!!& cR2( -1, jj)*cR3(+1,kk)*phif(i,j-1,k+1) + &
!!& cR2( 0, jj)*cR3(+1,kk)*phif(i,j ,k+1) + &
!!& cR2( +1, jj)*cR3(+1,kk)*phif(i,j+1,k+1)
!else
!!phic(ii,jj,kk) = &
!!& cRV(1,ii)*cR2(-1,jj)*cR3(-1,kk)*phif(i ,j-1,k-1) + &
!!& cRV(2,ii)*cR2(-1,jj)*cR3(-1,kk)*phif(i+1,j-1,k-1) + &
!!!
!!& cRV(1,ii)*cR2( 0,jj)*cR3(-1,kk)*phif(i ,j ,k-1) + &
!!& cRV(2,ii)*cR2( 0,jj)*cR3(-1,kk)*phif(i+1,j ,k-1) + &
!!!
!!& cRV(1,ii)*cR2(+1,jj)*cR3(-1,kk)*phif(i ,j+1,k-1) + &
!!& cRV(2,ii)*cR2(+1,jj)*cR3(-1,kk)*phif(i+1,j+1,k-1) + &
!!!
!!& cRV(1,ii)*cR2(-1,jj)*cR3( 0,kk)*phif(i ,j-1,k ) + &
!!& cRV(2,ii)*cR2(-1,jj)*cR3( 0,kk)*phif(i+1,j-1,k ) + &
!!!
!!& cRV(1,ii)*cR2( 0,jj)*cR3( 0,kk)*phif(i ,j ,k ) + &
!!& cRV(2,ii)*cR2( 0,jj)*cR3( 0,kk)*phif(i+1,j ,k ) + &
!!!
!!& cRV(1,ii)*cR2(+1,jj)*cR3( 0,kk)*phif(i ,j+1,k ) + &
!!& cRV(2,ii)*cR2(+1,jj)*cR3( 0,kk)*phif(i+1,j+1,k ) + &
!!!
!!& cRV(1,ii)*cR2(-1,jj)*cR3(+1,kk)*phif(i ,j-1,k+1) + &
!!& cRV(2,ii)*cR2(-1,jj)*cR3(+1,kk)*phif(i+1,j-1,k+1) + &
!!!
!!& cRV(1,ii)*cR2( 0,jj)*cR3(+1,kk)*phif(i ,j ,k+1) + &
!!& cRV(2,ii)*cR2( 0,jj)*cR3(+1,kk)*phif(i+1,j ,k+1) + &
!!!
!!& cRV(1,ii)*cR2(+1,jj)*cR3(+1,kk)*phif(i ,j+1,k+1) + &
!!& cRV(2,ii)*cR2(+1,jj)*cR3(+1,kk)*phif(i+1,j+1,k+1)
!end if
!end do
!end do
!end do
!end if
!end if
!!====================================================================================
!if( 2==dir ) then
!!if( 2==dimens ) then
!!do kk = SSc(3), iimax(3)
!!k = kk
!!do jj = SSc(2), iimax(2)
!!!j = dd(2)*(jj-1)+1
!!j = dd(2)*(jj-1)+1
!!do ii = SSc(1), iimax(1)
!!i = dd(1)*(ii-1)+1
!!if( 1==dd(2) ) then
!!phic(ii,jj,kk) = &
!!& cR1( -1, ii)*phif(i-1,j,k ) + &
!!& cR1( 0, ii)*phif(i ,j,k ) + &
!!& cR1( +1, ii)*phif(i+1,j,k )
!!else
!!phic(ii,jj,kk) = &
!!& cR1(-1,ii)*cRV(1,jj)*phif(i-1,j ,k ) + &
!!& cR1( 0,ii)*cRV(1,jj)*phif(i ,j ,k ) + &
!!& cR1(+1,ii)*cRV(1,jj)*phif(i+1,j ,k ) + &
!!!
!!& cR1(-1,ii)*cRV(2,jj)*phif(i-1,j+1,k ) + &
!!& cR1( 0,ii)*cRV(2,jj)*phif(i ,j+1,k ) + &
!!& cR1(+1,ii)*cRV(2,jj)*phif(i+1,j+1,k )
!!end if
!!end do
!!end do
!!end do
!!else
!!do kk = SSc(3), iimax(3)
!!k = dd(3)*(kk-1)+1
!!do jj = SSc(2), iimax(2)
!!j = dd(2)*(jj-1)+1
!!do ii = SSc(1), iimax(1)
!!i = dd(1)*(ii-1)+1
!!if( 1==dd(2) ) then
!!phic(ii,jj,kk) = &
!!& cR1( -1, ii)*cR3(-1,kk)*phif(i-1,j,k-1) + &
!!& cR1( 0, ii)*cR3(-1,kk)*phif(i ,j,k-1) + &
!!& cR1( +1, ii)*cR3(-1,kk)*phif(i+1,j,k-1) + &
!!!
!!& cR1( -1, ii)*cR3( 0,kk)*phif(i-1,j,k ) + &
!!& cR1( 0, ii)*cR3( 0,kk)*phif(i ,j,k ) + &
!!& cR1( +1, ii)*cR3( 0,kk)*phif(i+1,j,k ) + &
!!!
!!& cR1( -1, ii)*cR3(+1,kk)*phif(i-1,j,k+1) + &
!!& cR1( 0, ii)*cR3(+1,kk)*phif(i ,j,k+1) + &
!!& cR1( +1, ii)*cR3(+1,kk)*phif(i+1,j,k+1)
!!else
!!phic(ii,jj,kk) = &
!!& cR1(-1,ii)*cRV(1,jj)*cR3(-1,kk)*phif(i-1,j ,k-1) + &
!!& cR1( 0,ii)*cRV(1,jj)*cR3(-1,kk)*phif(i ,j ,k-1) + &
!!& cR1(+1,ii)*cRV(1,jj)*cR3(-1,kk)*phif(i+1,j ,k-1) + &
!!!
!!& cR1(-1,ii)*cRV(2,jj)*cR3(-1,kk)*phif(i-1,j+1,k-1) + &
!!& cR1( 0,ii)*cRV(2,jj)*cR3(-1,kk)*phif(i ,j+1,k-1) + &
!!& cR1(+1,ii)*cRV(2,jj)*cR3(-1,kk)*phif(i+1,j+1,k-1) + &
!!!
!!& cR1(-1,ii)*cRV(1,jj)*cR3( 0,kk)*phif(i-1,j ,k ) + &
!!& cR1( 0,ii)*cRV(1,jj)*cR3( 0,kk)*phif(i ,j ,k ) + &
!!& cR1(+1,ii)*cRV(1,jj)*cR3( 0,kk)*phif(i+1,j ,k ) + &
!!!
!!& cR1(-1,ii)*cRV(2,jj)*cR3( 0,kk)*phif(i-1,j+1,k ) + &
!!& cR1( 0,ii)*cRV(2,jj)*cR3( 0,kk)*phif(i ,j+1,k ) + &
!!& cR1(+1,ii)*cRV(2,jj)*cR3( 0,kk)*phif(i+1,j+1,k ) + &
!!!
!!& cR1(-1,ii)*cRV(1,jj)*cR3(+1,kk)*phif(i-1,j ,k+1) + &
!!& cR1( 0,ii)*cRV(1,jj)*cR3(+1,kk)*phif(i ,j ,k+1) + &
!!& cR1(+1,ii)*cRV(1,jj)*cR3(+1,kk)*phif(i+1,j ,k+1) + &
!!!
!!& cR1(-1,ii)*cRV(2,jj)*cR3(+1,kk)*phif(i-1,j+1,k+1) + &
!!& cR1( 0,ii)*cRV(2,jj)*cR3(+1,kk)*phif(i ,j+1,k+1) + &
!!& cR1(+1,ii)*cRV(2,jj)*cR3(+1,kk)*phif(i+1,j+1,k+1)
!!end if
!!end do
!!end do
!!end do
!!end if
!end if
!!====================================================================================
!if( 3==dimens .and. dir==3 ) then
!do kk = SSc(3), iimax(3)
!k = dd(3)*(kk-1)+1
!do jj = SSc(2), iimax(2)
!j = dd(2)*(jj-1)+1
!do ii = SSc(1), iimax(1)
!i = dd(1)*(ii-1)+1
!if( 1==dd(3) ) then
!phic(ii,jj,kk) = &
!& cR1(-1,ii)*cR2(-1,jj)*phif(i-1,j-1,k) + &
!& cR1( 0,ii)*cR2(-1,jj)*phif(i ,j-1,k) + &
!& cR1(+1,ii)*cR2(-1,jj)*phif(i+1,j-1,k) + &
!!
!& cR1(-1,ii)*cR2( 0,jj)*phif(i-1,j ,k) + &
!& cR1( 0,ii)*cR2( 0,jj)*phif(i ,j ,k) + &
!& cR1(+1,ii)*cR2( 0,jj)*phif(i+1,j ,k) + &
!!
!& cR1(-1,ii)*cR2(+1,jj)*phif(i-1,j+1,k) + &
!& cR1( 0,ii)*cR2(+1,jj)*phif(i ,j+1,k) + &
!& cR1(+1,ii)*cR2(+1,jj)*phif(i+1,j+1,k)
!else
!phic(ii,jj,kk) = &
!& cR1(-1,ii)*cR2(-1,jj)*cRV(1,kk)*phif(i-1,j-1,k ) + &
!& cR1( 0,ii)*cR2(-1,jj)*cRV(1,kk)*phif(i ,j-1,k ) + &
!& cR1(+1,ii)*cR2(-1,jj)*cRV(1,kk)*phif(i+1,j-1,k ) + &
!!
!& cR1(-1,ii)*cR2(-1,jj)*cRV(2,kk)*phif(i-1,j-1,k+1) + &
!& cR1( 0,ii)*cR2(-1,jj)*cRV(2,kk)*phif(i ,j-1,k+1) + &
!& cR1(+1,ii)*cR2(-1,jj)*cRV(2,kk)*phif(i+1,j-1,k+1) + &
!!
!& cR1(-1,ii)*cR2( 0,jj)*cRV(1,kk)*phif(i-1,j ,k ) + &
!& cR1( 0,ii)*cR2( 0,jj)*cRV(1,kk)*phif(i ,j ,k ) + &
!& cR1(+1,ii)*cR2( 0,jj)*cRV(1,kk)*phif(i+1,j ,k ) + &
!!
!& cR1(-1,ii)*cR2( 0,jj)*cRV(2,kk)*phif(i-1,j ,k+1) + &
!& cR1( 0,ii)*cR2( 0,jj)*cRV(2,kk)*phif(i ,j ,k+1) + &
!& cR1(+1,ii)*cR2( 0,jj)*cRV(2,kk)*phif(i+1,j ,k+1) + &
!!
!& cR1(-1,ii)*cR2(+1,jj)*cRV(1,kk)*phif(i-1,j+1,k ) + &
!& cR1( 0,ii)*cR2(+1,jj)*cRV(1,kk)*phif(i ,j+1,k ) + &
!& cR1(+1,ii)*cR2(+1,jj)*cRV(1,kk)*phif(i+1,j+1,k ) + &
!!
!& cR1(-1,ii)*cR2(+1,jj)*cRV(2,kk)*phif(i-1,j+1,k+1) + &
!& cR1( 0,ii)*cR2(+1,jj)*cRV(2,kk)*phif(i ,j+1,k+1) + &
!& cR1(+1,ii)*cR2(+1,jj)*cRV(2,kk)*phif(i+1,j+1,k+1)
!end if
!end do
!end do
!end do
!end if
!!===========================================================================================
!end subroutine MG_restrictFWV
end module cmod_RestrictionOp
| src/src_f/cmod_RestrictionOp.f90 |
c ======================================================================
c User Subroutine VUMAT for Johnson-Cook model.
c All rights of reproduction or distribution in any form are reserved.
c By Irfan Habeeb CN (PhD, Technion - IIT)
c ======================================================================
subroutine vumat(
C Read only -
1 nblock, ndir, nshr, nstatev, nfieldv, nprops, lanneal,
2 stepTime, totalTime, dt, cmname, coordMp, charLength,
3 props, density, strainInc, relSpinInc,
4 tempOld, stretchOld, defgradOld, fieldOld,
5 stressOld, stateOld, enerInternOld, enerInelasOld,
6 tempNew, stretchNew, defgradNew, fieldNew,
C Write only -
7 stressNew, stateNew, enerInternNew, enerInelasNew)
C
include 'vaba_param.inc'
C
dimension props(nprops), density(nblock), coordMp(nblock,*),
1 charLength(nblock), strainInc(nblock,ndir+nshr),
2 relSpinInc(nblock,nshr), tempOld(nblock),
3 stretchOld(nblock,ndir+nshr),
4 defgradOld(nblock,ndir+nshr+nshr),
5 fieldOld(nblock,nfieldv), stressOld(nblock,ndir+nshr),
6 stateOld(nblock,nstatev), enerInternOld(nblock),
7 enerInelasOld(nblock), tempNew(nblock),
8 stretchNew(nblock,ndir+nshr),
9 defgradNew(nblock,ndir+nshr+nshr),
1 fieldNew(nblock,nfieldv),
2 stressNew(nblock,ndir+nshr), stateNew(nblock,nstatev),
3 enerInternNew(nblock), enerInelasNew(nblock)
character*80 cmname
integer k, k1, k2, iter
real*8 E, nu, A, B, C, m, n, rate0, Tr, Tm, rho, TQ, Cp, WH,
1 sigeqv, f, epbar, ep, dep, eprateN, sighyd, sigyT, sigyN, dPwork,
2 trInc, fT, fs, fN, fNs, sigdotp, epbarN, tempT, tempN, dWork,
3 mu, alamda, tol,
4 cmat(6,6), sTrial(6), sNew(6), devS(6), sTem(6), rd(6),
5 L(6,6), sOld(6), sT(6), np(6)
c input parameters
E = props(1) ! Young's modulus
nu = props(2) ! Poisson's ratio
A = props(3) ! JC parameters
B = props(4)
C = props(5)
n = props(6)
m = props(7)
rate0 = props(8)
Tr = props(9) ! reference temperature
Tm = props(10) ! melting temperature
rho = props(11) ! density
TQ = props(12) ! Taylor-Q heat ener. from plastic deform.
Cp = props(13) ! specific heat
WH = props(14) ! work - heat conversion factor
c tolerance of the effe. stress, strain accuracy: ep ~ 1e-9
tol = E*1e-9 ! strain accuracy or 1e-9
Niter = 50 ! max number of N-R iterations
c lame's parameters
mu = E/(2.d0*(1.d0+nu))
alamda = E*nu/((1.d0 + nu) * (1.d0 - 2.d0*nu))
c stiffness matrix
cmat = 0.d0
do k1 = 1, ndir
do k2 = 1, ndir
cmat(k1, k2) = alamda
end do
cmat(k1, k1) = alamda + 2.d0*mu
end do
do k1 = ndir+1, ndir+nshr
cmat(k1, k1) = 2.d0*mu
end do
C -------------------- simulation first step & later -------------------
do 30 k = 1, nblock
if (stateOld(k, 1) .eq. 0.d0) then
go to 10
else
go to 20
end if
C----------------------------- initial state ---------------------------
10 trInc = sum(strainInc(k, 1:3))
do k1 = 1, ndir
stressNew(k, k1) = stressOld(k, k1) + alamda*trInc +
1 2.d0*mu*strainInc(k, k1)
end do
do k1 = ndir+1, ndir+nshr
stressNew(k, k1) = stressOld(k, k1) +
1 2.d0*mu*strainInc(k, k1)
end do
stateNew(k, 1) = 1.d0 ! initiation check
stateNew(k, 2) = 0.d0 ! plastic strain
stateNew(k, 3) = Tr ! initial temperature
stateNew(k, 4) = 0.d0 ! yield stress
stateNew(k, 5) = 0.d0 ! plastic strain incre. last step
stateNew(k, 6) = 1 ! number of iterations
tempNew(k) = Tr
go to 30
C-------------------------- 2nd step and later -------------------------
20 epbar = stateOld(k, 2)
tempT = stateOld(k, 3)
sigyT = stateOld(k, 4)
sOld(1:6) = stressOld(k, 1:6)
trInc = sum(strainInc(k, 1:3))
do k1 = 1, ndir
sT(k1) = stressOld(k,k1) +alamda*trInc +2.d0*mu*strainInc(k, k1)
end do
do k1 = ndir+1, ndir+nshr
sT(k1) = stressOld(k, k1) + 2.d0*mu*strainInc(k, k1)
end do
c to get the vector for radial reduction
sighyd = sum(sT(1:ndir))/3.d0
devS(1:ndir) = sT(1:ndir) - sighyd
devS(ndir+1:ndir+nshr) = sT(ndir+1:ndir+nshr)
c equivalent stress
sigeqv = sqrt(3.d0/2.d0 *(devS(1)**2.d0 + devS(2)**2.d0 +
1 devS(3)**2.d0 + 2.d0*devS(4)**2.d0 + 2.d0*devS(5)**2.d0 +
2 2.d0*devS(6)**2.d0 ))
c rd is constant over the iterations
if (sigeqv .gt. 0.d0) then
rd = (3.d0*devS)/(2.d0*sigeqv)
else
rd = 0.d0
end if
sTem = matmul(cmat, rd)
c initial value of the plastic strain increment and the bounds
ep = 0.d0 ! initial plast. strain incre.
epmin = 0.d0
epmax = sigeqv/(2.d0*mu) !max(1.d-5, 3.d0*1.d-5)
c NR - iteration starts
iter = 0 ! number of iterations
do while (iter .lt. Niter)
iter = iter + 1
if (iter .gt. Niter-1.) then
print*, 'too many iterations, iter = ', iter
call XPLB_EXIT
end if
epbarN = epbar + ep
eprateN = ep/dt
tempN = tempT ! temperature is updated at the end
c updating stress
sNew = sT - ep*sTem
sighyd = sum(sNew(1:ndir))/3.d0
c deviatoric stress
devS(1:ndir) = sNew(1:ndir) - sighyd
devS(ndir+1:ndir+nshr) = sNew(ndir+1:ndir+nshr)
c equivalent stress
sigeqv = sqrt(3.d0/2.d0 *(devS(1)**2.d0 + devS(2)**2.d0 +
1 devS(3)**2.d0 + 2.d0*devS(4)**2.d0 + 2.d0*devS(5)**2.d0 +
2 2.d0*devS(6)**2.d0 ))
c evaluating new yield stress for the increment 'ep'
call func_syield(A, B, epbarN, n, Tr, Tm, tempN, m, C, eprateN,
1 rate0, sigyN)
if (sigyN .lt. sigyT) sigyN = sigyT
f = sigeqv - sigyN
if (abs(f) .lt. tol) exit ! out of the iteration
c elastic criteria, ep = 0 & f < 0
if ((ep .eq. 0.d0) .and. (f .lt. 0.d0)) go to 12
c rearranging the margins and new plastic strain increm.
if ((f .ge. 0.d0) .and. (ep .ge. epmin)) epmin = ep
if ((f .lt. 0.d0) .and. (ep .lt. epmax)) epmax = ep
ep = 0.5d0 * (epmax + epmin)
c restoring the plastic strain increment from the last step
if (iter .eq. 1) ep = stateOld(k, 5)
end do
12 stressNew(k, 1:6) = sNew(1:6)
c work, plastic work and temp
dWork = dot_product( 0.5d0*(sOld(1:6) + sNew(1:6)),
1 strainInc(k, 1:6))
dPwork = 0.5d0 * ep * sigeqv
enerInternNew(k) = enerInternOld(k) + dWork/rho
enerInelasNew(k) = enerInelasOld(k) + dPwork/rho
c updating state variables
stateNew(k, 1) = 1.d0 ! to flag the initial step
stateNew(k, 2) = epbarN ! plastic strain
stateNew(k, 3) = tempT + WH*TQ*dPwork/rho/Cp ! temperature
stateNew(k, 4) = sigyN ! yield stress
stateNew(k, 5) = ep ! plastic strain incre.
stateNew(k, 6) = stateOld(k, 6) + iter ! number of iterations
30 continue
return
end
c ----------------------------------------------------------------------
subroutine func_syield(A, B, epbar, n, Tr, Tm, T, m, C, rate,
1 rate0, sigbar)
include 'vaba_param.inc'
real*8 A, B, epbar, n, Tr, Tm, T, theta, m, C, rate, rate0, sigbar
if (T < Tr) then
theta = 0.d0
else if (T > Tm) then
theta = 1.d0
else
theta = (T - Tr)/(Tm - Tr)
end if
if (rate == 0.d0) then
rate = rate0
end if
sigbar = (A + B*epbar**n)*(1.d0 - theta**m)*
1 (1.d0 + C*log(rate/rate0))
end subroutine
c ----------------------------------------------------------------------
| vumat_JC.for |
C
C
C Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved.
C
C This program is free software; you can redistribute it and/or modify it
C under the terms of version 2.1 of the GNU Lesser General Public License
C as published by the Free Software Foundation.
C
C This program is distributed in the hope that it would be useful, but
C WITHOUT ANY WARRANTY; without even the implied warranty of
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C
C Further, this software is distributed without any warranty that it is
C free of the rightful claim of any third person regarding infringement
C or the like. Any license provided herein, whether implied or
C otherwise, applies only to this software file. Patent licenses, if
C any, provided herein do not apply to combinations of this program with
C other software, or any other product whatsoever.
C
C You should have received a copy of the GNU Lesser General Public
C License along with this program; if not, write the Free Software
C Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
C USA.
C
C Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
C Mountain View, CA 94043, or:
C
C http://www.sgi.com
C
C For further information regarding this notice, see:
C
C http://oss.sgi.com/projects/GenInfo/NoticeExplan
C
C
SUBROUTINE VXGCTI(FPN,DEST,ISB,NUM,IER,INC)
C
C The VXDCTI subroutine converts Cray 64-bit single-precision
C floating-point numbers to VAX G_format single-precision
C floating-point numbers. Numbers that produce an underflow when
C converted to VAX format are converted to 32 binary zeros. Numbers
C that are in overflow on the CRAY are converted to a "reserved"
C floating-point representation with the sign bit set if negative.
C Numbers that are valid on the CRAY but overflow on the VAX are
C converted to the most positive possible number or most negative
C possible number, depending on the sign.
C
C Presently, you must supply a parameter which, in the future,
C will contain a nonzero value if any numbers converted produced
C an overflow. No such indication will be given for underflow.
C
REAL FPN(1) ! Variable or array of any length and
C ! type real, containing Cray 64-bit,
C ! single-precision, floating-point
C ! numbers to convert.
C
INTEGER DEST(1) ! Variable or array of type real to
C ! contain the converted values.
C
INTEGER ISB ! Byte number at which to begin
C ! storing the converted results. Type
C ! integer variable, expression, or
C ! constant. Bytes are numbered from
C ! 1, beginning at the leftmost byte
C ! position of DEST.
C
INTEGER NUM ! Number of Cray floating-point
C ! numbers to convert. Type integer
C ! variable, expression, or constant.
C
INTEGER IER ! Overflow indicator of type
C ! integer. Value is 0 if all Cray
C ! values convert to VAX values without
C ! overflow. Value is nonzero if one
C ! or more Cray values overflowed in
C ! the conversion.
C
INTEGER INC ! Memory increment for fetching the
C ! number to be converted. Optional
C ! parameter of type integer variable,
C ! expression, or constant. Default
C ! value is 1.
INTEGER ITEMP(64), JTEMP(32)
CDIR$ VFUNCTION VG64O
INTEGER VG64O
IF (NUMARG() .EQ. 5) THEN
JNC = 1
ELSE IF (NUMARG() .EQ. 6) THEN
JNC = INC
ELSE
CALL ABORT('VAX conversion routine called with incorrect number
+of arguments')
ENDIF
IF (NUM .LT. 0) THEN
CALL ABORT('Invalid input to VAX conversion routine')
ENDIF
NUMC = NUM
JSB = ISB
J = 1
IER = 0
IF (NUM .EQ. 0) RETURN
40 CONTINUE
NUMP = MIN0(NUMC,64)
CDIR$ SHORTLOOP
DO 80 I = 1, NUMP
ITEMP(I) = VG64O(DBLE(FPN(J)))
J = J + JNC
80 CONTINUE
CALL VXMOVE00(ITEMP,1,NUMP*8,DEST,JSB)
JSB = JSB + 8*NUMP
NUMC = NUMC - NUMP
IF (NUMC .GT. 0) GO TO 40
RETURN
CDIR$ ID "@(#) libu/vms/vxgcti.f 92.0 10/08/98 14:57:41"
END
| osprey/libu/vms/vxgcti.f |
C--------------------------------------------------------------
C All the routines in this file were updated on 9 Feb 2015 to
C reverse the dimensions of "clcntr"/"c" (from "k x n" to
C "n x k") so that the calling C routine could have the
C dimensions be K x N.
C--------------------------------------------------------------
C NCLFORTSTART
subroutine kmns136 (dat, m, n, clcntr, k, ic1, nc
+ ,iter, iseed, wss, ier)
implicit none
c ! INPUT
integer m, n, k, iter, iseed
double precision dat(m,n)
c ! INPUT/OUTPUT
integer ic1(m), nc(k), ier
double precision clcntr(n,k), wss(k)
C NCLEND
c ! LOCAL WORK ARRAYS
integer ic2(m), ncp(k), itran(k), live(k)
double precision an1(k), an2(k), d(m)
integer nv, kk, mm
c Currently: two methods to set the seed
c . iseed=1 pick 1st k elements of the dat array
c . iseed=2 'randomly' sample the dat array
do kk=1,k
if (iseed.eq.1) then
mm = kk
else
mm = m/kk
end if
do nv=1,n
clcntr(nv,kk) = dat(mm,nv)
c c c print *,"mm=", mm," kk=",kk," nv=",nv," clc=",clcntr(kk,nv)
end do
end do
call kmns (dat,m,n,clcntr,k,ic1,ic2,nc,an1,an2,ncp,d
& ,itran,live,iter,wss,ier )
return
end
c*********************************************************************72
subroutine kmns ( a, m, n, c, k, ic1, ic2, nc, an1, an2, ncp, d
& ,itran, live, iter, wss, ifault )
c
cc KMNS carries out the K-means algorithm.
c
c Discussion:
c
c This routine attempts to divide M points in N-dimensional space into
c K clusters so that the within cluster sum of squares is minimized.
c
c Modified:
c
c 13 February 2008
c
c Author:
c
c Original FORTRAN77 version by John Hartigan, Manchek Wong.
c Modifications by John Burkardt.
c
c Reference:
c
c John Hartigan, Manchek Wong,
c Algorithm AS 136:
c A K-Means Clustering Algorithm,
c Applied Statistics,
c Volume 28, Number 1, 1979, pages 100-108.
c
c Parameters:
c
c Input, double precision A(M,N), the points.
c
c Input, integer M, the number of points.
c
c Input, integer N, the number of spatial dimensions (aka, variables).
c
c Input/output, double precision C(N,K), the cluster centers.
c
c Input, integer K, the number of clusters.
c
c Output, integer IC1(M), the cluster to which each point is assigned.
c
c Workspace, integer IC2(M), used to store the cluster which each point
c is most likely to be transferred to at each step.
c
c Output, integer NC(K), the number of points in each cluster.
c
c Workspace, double precision AN1(K).
c
c Workspace, double precision AN2(K).
c
c Workspace, integer NCP(K).
c
c Workspace, double precision D(M).
c
c Workspace, integer ITRAN(K).
c
c Workspace, integer LIVE(K).
c
c Input, integer ITER, the maximum number of iterations allowed.
c
c Output, double precision WSS(K), the within-cluster sum of squares
c of each cluster.
c
c Output, integer IFAULT, error indicator.
c 0, no error was detected.
c 1, at least one cluster is empty after the initial assignment.
c A better set of initial cluster centers is needed.
c 2, the allowed maximum number off iterations was exceeded.
c 3, K is less than or equal to 1, or greater than or equal to M.
c
implicit none
integer k
integer m
integer n
double precision a(m,n)
double precision aa
double precision an1(k)
double precision an2(k)
double precision c(n,k)
double precision d(m)
double precision da
double precision db
double precision dc
double precision dt(2)
integer i
integer ic1(m)
integer ic2(m)
integer ifault
integer ii
integer ij
integer il
integer indx
integer iter
integer itran(k)
integer j
integer l
integer live(k)
integer nc(k)
integer ncp(k)
double precision r8_huge
double precision temp
double precision wss(k)
ifault = 0
if ( k .le. 1 .or. m .le. k ) then
ifault = 3
return
end if
c
c For each point I, find its two closest centers, IC1(I) and
c IC2(I). Assign the point to IC1(I).
c
do i = 1, m
ic1(i) = 1
ic2(i) = 2
do il = 1, 2
dt(il) = 0.0D+00
do j = 1, n
da = a(i,j) - c(j,il)
dt(il) = dt(il) + da * da
end do
end do
if ( dt(2) .lt. dt(1) ) then
ic1(i) = 2
ic2(i) = 1
temp = dt(1)
dt(1) = dt(2)
dt(2) = temp
end if
do l = 3, k
db = 0.0D+00
do j = 1, n
dc = a(i,j) - c(j,l)
db = db + dc * dc
end do
if ( db .lt. dt(2) ) then
if ( dt(1) .le. db ) then
dt(2) = db
ic2(i) = l
else
dt(2) = dt(1)
ic2(i) = ic1(i)
dt(1) = db
ic1(i) = l
end if
end if
end do
end do
c
c Update cluster centers to be the average of points contained within them.
c
do l = 1, k
nc(l) = 0
do j = 1, n
c(j,l) = 0.0D+00
end do
end do
do i = 1, m
l = ic1(i)
nc(l) = nc(l) + 1
do j = 1, n
c(j,l) = c(j,l) + a(i,j)
end do
end do
c
c Check to see if there is any empty cluster at this stage.
c
ifault = 1
do l = 1, k
if ( nc(l) .eq. 0 ) then
ifault = 1
return
end if
end do
ifault = 0
do l = 1, k
aa = dble ( nc(l) )
do j = 1, n
c(j,l) = c(j,l) / aa
end do
c
c Initialize AN1, AN2, ITRAN and NCP.
c
c AN1(L) = NC(L) / (NC(L) - 1)
c AN2(L) = NC(L) / (NC(L) + 1)
c ITRAN(L) = 1 if cluster L is updated in the quick-transfer stage,
c = 0 otherwise
c
c In the optimal-transfer stage, NCP(L) stores the step at which
c cluster L is last updated.
c
c In the quick-transfer stage, NCP(L) stores the step at which
c cluster L is last updated plus M.
c
an2(l) = aa / ( aa + 1.0D+00 )
if ( 1.0D+00 .lt. aa ) then
an1(l) = aa / ( aa - 1.0D+00 )
else
an1(l) = r8_huge ( )
end if
itran(l) = 1
ncp(l) = -1
end do
indx = 0
ifault = 2
do ij = 1, iter
c
c In this stage, there is only one pass through the data. Each
c point is re-allocated, if necessary, to the cluster that will
c induce the maximum reduction in within-cluster sum of squares.
c
call optra ( a, m, n, c, k, ic1, ic2, nc, an1, an2, ncp, d,
& itran, live, indx )
c
c Stop if no transfer took place in the last M optimal transfer steps.
c
if ( indx .eq. m ) then
ifault = 0
go to 150
end if
c
c Each point is tested in turn to see if it should be re-allocated
c to the cluster to which it is most likely to be transferred,
c IC2(I), from its present cluster, IC1(I). Loop through the
c data until no further change is to take place.
c
call qtran ( a, m, n, c, k, ic1, ic2, nc, an1, an2, ncp, d,
& itran, indx )
c
c If there are only two clusters, there is no need to re-enter the
c optimal transfer stage.
c
if ( k .eq. 2 ) then
ifault = 0
go to 150
end if
c
c NCP has to be set to 0 before entering OPTRA.
c
do l = 1, k
ncp(l) = 0
end do
end do
150 continue
c
c If the maximum number of iterations was taken without convergence,
c IFAULT is 2 now. This may indicate unforeseen looping.
c
if ( ifault == 2 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'KMNS - Warning!'
write ( *, '(a)' ) ' Maximum number of iterations reached'
write ( *, '(a)' ) ' without convergence.'
end if
c
c Compute the within-cluster sum of squares for each cluster.
c
do l = 1, k
wss(l) = 0.0D+00
do j = 1, n
c(j,l) = 0.0D+00
end do
end do
do i = 1, m
ii = ic1(i)
do j = 1, n
c(j,ii) = c(j,ii) + a(i,j)
end do
end do
do j = 1, n
do l = 1, k
c(j,l) = c(j,l) / dble ( nc(l) )
end do
do i = 1, m
ii = ic1(i)
da = a(i,j) - c(j,ii)
wss(ii) = wss(ii) + da * da
end do
end do
return
end
subroutine optra ( a, m, n, c, k, ic1, ic2, nc, an1, an2, ncp,
& d, itran, live, indx )
c*********************************************************************72
c
cc OPTRA carries out the optimal transfer stage.
c
c Discussion:
c
c This is the optimal transfer stage.
c
c Each point is re-allocated, if necessary, to the cluster that
c will induce a maximum reduction in the within-cluster sum of
c squares.
c
c Modified:
c
c 15 February 2008
c
c Author:
c
c Original FORTRAN77 version by John Hartigan, Manchek Wong.
c Modifications by John Burkardt.
c
c Reference:
c
c John Hartigan, Manchek Wong,
c Algorithm AS 136:
c A K-Means Clustering Algorithm,
c Applied Statistics,
c Volume 28, Number 1, 1979, pages 100-108.
c
c Parameters:
c
c Input, double precision A(M,N), the points.
c
c Input, integer M, the number of points.
c
c Input, integer N, the number of spatial dimensions.
c
c Input/output, double precision C(N,K), the cluster centers.
c
c Input, integer K, the number of clusters.
c
c Input/output, integer IC1(M), the cluster to which each point is assigned.
c
c Input/output, integer IC2(M), used to store the cluster which each point
c is most likely to be transferred to at each step.
c
c Input/output, integer NC(K), the number of points in each cluster.
c
c Input/output, double precision AN1(K).
c
c Input/output, double precision AN2(K).
c
c Input/output, integer NCP(K).
c
c Input/output, double precision D(M).
c
c Input/output, integer ITRAN(K).
c
c Input/output, integer LIVE(K).
c
c Input/output, integer INDX, the number of steps since a transfer took place.
c
implicit none
integer k
integer m
integer n
double precision a(m,n)
double precision al1
double precision al2
double precision alt
double precision alw
double precision an1(k)
double precision an2(k)
double precision c(n,k)
double precision d(m)
double precision da
double precision db
double precision dc
double precision dd
double precision de
double precision df
integer i
integer ic1(m)
integer ic2(m)
integer indx
integer itran(k)
integer j
integer l
integer l1
integer l2
integer live(k)
integer ll
integer nc(k)
integer ncp(k)
double precision r2
double precision r8_huge
double precision rr
c
c If cluster L is updated in the last quick-transfer stage, it
c belongs to the live set throughout this stage. Otherwise, at
c each step, it is not in the live set if it has not been updated
c in the last M optimal transfer steps.
c
do l = 1, k
if ( itran(l) .eq. 1) then
live(l) = m + 1
end if
end do
do i = 1, m
indx = indx + 1
l1 = ic1(i)
l2 = ic2(i)
ll = l2
c
c If point I is the only member of cluster L1, no transfer.
c
if ( 1 .lt. nc(l1) ) then
c
c If L1 has not yet been updated in this stage, no need to
c re-compute D(I).
c
if ( ncp(l1) .ne. 0 ) then
de = 0.0D+00
do j = 1, n
df = a(i,j) - c(j,l1)
de = de + df * df
end do
d(i) = de * an1(l1)
end if
c
c Find the cluster with minimum R2.
c
da = 0.0D+00
do j = 1, n
db = a(i,j) - c(j,l2)
da = da + db * db
end do
r2 = da * an2(l2)
do l = 1, k
c
c If LIVE(L1) <= I, then L1 is not in the live set. If this is
c true, we only need to consider clusters that are in the live set
c for possible transfer of point I. Otherwise, we need to consider
c all possible clusters.
c
if ( ( i .lt. live(l1) .or. i .lt. live(l2) ) .and.
& l .ne. l1 .and. l .ne. ll ) then
rr = r2 / an2(l)
dc = 0.0D+00
do j = 1, n
dd = a(i,j) - c(j,l)
dc = dc + dd * dd
end do
if ( dc .lt. rr ) then
r2 = dc * an2(l)
l2 = l
end if
end if
end do
c
c If no transfer is necessary, L2 is the new IC2(I).
c
if ( d(i) .le. r2 ) then
ic2(i) = l2
c
c Update cluster centers, LIVE, NCP, AN1 and AN2 for clusters L1 and
c L2, and update IC1(I) and IC2(I).
c
else
indx = 0
live(l1) = m + i
live(l2) = m + i
ncp(l1) = i
ncp(l2) = i
al1 = nc(l1)
alw = al1 - 1.0D+00
al2 = nc(l2)
alt = al2 + 1.0D+00
do j = 1, n
c(j,l1) = ( c(j,l1) * al1 - a(i,j) ) / alw
c(j,l2) = ( c(j,l2) * al2 + a(i,j) ) / alt
end do
nc(l1) = nc(l1) - 1
nc(l2) = nc(l2) + 1
an2(l1) = alw / al1
if ( 1.0D+00 .lt. alw ) then
an1(l1) = alw / ( alw - 1.0D+00 )
else
an1(l1) = r8_huge ( )
end if
an1(l2) = alt / al2
an2(l2) = alt / ( alt + 1.0D+00 )
ic1(i) = l2
ic2(i) = l1
end if
end if
if ( indx .eq. m ) then
return
end if
end do
c
c ITRAN(L) = 0 before entering QTRAN. Also, LIVE(L) has to be
c decreased by M before re-entering OPTRA.
c
do l = 1, k
itran(l) = 0
live(l) = live(l) - m
end do
return
end
subroutine qtran ( a, m, n, c, k, ic1, ic2, nc, an1, an2, ncp,
& d, itran, indx )
c*********************************************************************72
c
cc QTRAN carries out the quick transfer stage.
c
c Discussion:
c
c This is the quick transfer stage.
c
c IC1(I) is the cluster which point I belongs to.
c IC2(I) is the cluster which point I is most likely to be
c transferred to.
c
c For each point I, IC1(I) and IC2(I) are switched, if necessary, to
c reduce within-cluster sum of squares. The cluster centers are
c updated after each step.
c
c Modified:
c
c 15 February 2008
c
c Author:
c
c Original FORTRAN77 version by John Hartigan, Manchek Wong.
c Modifications by John Burkardt.
c
c Reference:
c
c John Hartigan, Manchek Wong,
c Algorithm AS 136:
c A K-Means Clustering Algorithm,
c Applied Statistics,
c Volume 28, Number 1, 1979, pages 100-108.
c
c Parameters:
c
c Input, double precision A(M,N), the points.
c
c Input, integer M, the number of points.
c
c Input, integer N, the number of spatial dimensions.
c
c Input/output, double precision C(N,K), the cluster centers.
c
c Input, integer K, the number of clusters.
c
c Input/output, integer IC1(M), the cluster to which each point is assigned.
c
c Input/output, integer IC2(M), used to store the cluster which each point
c is most likely to be transferred to at each step.
c
c Input/output, integer NC(K), the number of points in each cluster.
c
c Input/output, double precision AN1(K).
c
c Input/output, double precision AN2(K).
c
c Input/output, integer NCP(K).
c
c Input/output, double precision D(M).
c
c Input/output, integer ITRAN(K).
c
c Input/output, integer INDX, counts the number of steps since the
c last transfer.
c
implicit none
integer k
integer m
integer n
double precision a(m,n)
double precision al1
double precision al2
double precision alt
double precision alw
double precision an1(k)
double precision an2(k)
double precision c(n,k)
double precision d(m)
double precision da
double precision db
double precision dd
double precision de
integer i
integer ic1(m)
integer ic2(m)
integer icoun
integer indx
integer istep
integer itran(k)
integer j
integer l1
integer l2
integer nc(k)
integer ncp(k)
double precision r2
double precision r8_huge
c
c In the optimal transfer stage, NCP(L) indicates the step at which
c cluster L is last updated. In the quick transfer stage, NCP(L)
c is equal to the step at which cluster L is last updated plus M.
c
icoun = 0
istep = 0
10 continue
do i = 1, m
icoun = icoun + 1
istep = istep + 1
l1 = ic1(i)
l2 = ic2(i)
c
c If point I is the only member of cluster L1, no transfer.
c
if ( 1 .lt. nc(l1) ) then
c
c If NCP(L1) < ISTEP, no need to re-compute distance from point I to
c cluster L1. Note that if cluster L1 is last updated exactly M
c steps ago, we still need to compute the distance from point I to
c cluster L1.
c
if ( istep .le. ncp(l1) ) then
da = 0.0D+00
do j = 1, n
db = a(i,j) - c(j,l1)
da = da + db * db
end do
d(i) = da * an1(l1)
end if
c
c If NCP(L1) <= ISTEP and NCP(L2) <= ISTEP, there will be no transfer of
c point I at this step.
c
if ( istep .lt. ncp(l1) .or. istep .lt. ncp(l2) ) then
r2 = d(i) / an2(l2)
dd = 0.0D+00
do j = 1, n
de = a(i,j) - c(j,l2)
dd = dd + de * de
end do
c
c Update cluster centers, NCP, NC, ITRAN, AN1 and AN2 for clusters
c L1 and L2. Also update IC1(I) and IC2(I). Note that if any
c updating occurs in this stage, INDX is set back to 0.
c
if ( dd .lt. r2 ) then
icoun = 0
indx = 0
itran(l1) = 1
itran(l2) = 1
ncp(l1) = istep + m
ncp(l2) = istep + m
al1 = nc(l1)
alw = al1 - 1.0D+00
al2 = nc(l2)
alt = al2 + 1.0D+00
do j = 1, n
c(j,l1) = ( c(j,l1) * al1 - a(i,j) ) / alw
c(j,l2) = ( c(j,l2) * al2 + a(i,j) ) / alt
end do
nc(l1) = nc(l1) - 1
nc(l2) = nc(l2) + 1
an2(l1) = alw / al1
if ( 1.0D+00 .lt. alw ) then
an1(l1) = alw / ( alw - 1.0D+00 )
else
an1(l1) = r8_huge ( )
end if
an1(l2) = alt / al2
an2(l2) = alt / ( alt + 1.0D+00 )
ic1(i) = l2
ic2(i) = l1
end if
end if
end if
c
c If no re-allocation took place in the last M steps, return.
c
if ( icoun .eq. m ) then
return
end if
end do
go to 10
end
function r8_huge ( )
c*********************************************************************72
c
cc R8_HUGE returns a "huge" R8.
c
c Modified:
c
c 13 April 2004
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Output, double precision R8_HUGE, a huge number.
c
implicit none
double precision r8_huge
r8_huge = 1.0D+30
return
end
| ni/src/lib/nfpfort/kmeans_kmns_as136.f |
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------
MODULE m_types_hub1inp
USE m_juDFT
USE m_constants
USE m_types_fleurinput_base
IMPLICIT NONE
PRIVATE
TYPE, EXTENDS(t_fleurinput_base):: t_hub1inp
!Convergence criteria for the density matrix
INTEGER :: itmax = 5
REAL :: minoccDistance=1.0e-2
REAL :: minmatDistance=1.0e-3
LOGICAL :: l_dftspinpol=.FALSE. !Determines whether the DFT part is spin-polarized in a magnetic DFT+Hubbard 1 calculation
LOGICAL :: l_fullMatch=.TRUE. !Determines whether two chemical potentials are used to match (if possible)
LOGICAL :: l_nonsphDC=.TRUE. !Determines whether to remove the nonspherical contributions to the Hamiltonian (in the HIA orbital)
!Parameters for the solver
REAL :: beta = 100.0 !inverse temperature
INTEGER :: n_occpm = 2 !number of particle excitations considered in the solver
REAL, ALLOCATABLE :: init_occ(:) !initial occupation
REAL, ALLOCATABLE :: ccf(:) !crystal field factor
REAL, ALLOCATABLE :: xi_par(:) !Fixed SOC parameters
INTEGER, ALLOCATABLE :: n_exc(:)
INTEGER, ALLOCATABLE :: exc_l(:,:) !l quantum number from which the intraorbital exchange
REAL, ALLOCATABLE :: exc(:,:) !exchange splitting parameter
REAL, ALLOCATABLE :: init_mom(:,:) !initial magnetic moment
!Additional arguments to be passed on to hloc.cfg (at the moment only real)
INTEGER, ALLOCATABLE :: n_addArgs(:)
CHARACTER(len=100), ALLOCATABLE :: arg_keys(:,:)
REAL, ALLOCATABLE :: arg_vals(:,:)
!Switches for arguments that were explicitly given and should not be calculated from DFT
LOGICAL,ALLOCATABLE :: l_soc_given(:)
LOGICAL,ALLOCATABLE :: l_ccf_given(:)
CONTAINS
PROCEDURE :: read_xml => read_xml_hub1inp
PROCEDURE :: mpi_bc => mpi_bc_hub1inp
END TYPE t_hub1inp
PUBLIC t_hub1inp
CONTAINS
SUBROUTINE mpi_bc_hub1inp(this, mpi_comm, irank)
USE m_mpi_bc_tool
CLASS(t_hub1inp), INTENT(INOUT)::this
INTEGER, INTENT(IN):: mpi_comm
INTEGER, INTENT(IN), OPTIONAL::irank
INTEGER ::rank
IF (PRESENT(irank)) THEN
rank = irank
ELSE
rank = 0
END IF
CALL mpi_bc(this%itmax,rank,mpi_comm)
CALL mpi_bc(this%minoccDistance,rank,mpi_comm)
CALL mpi_bc(this%minmatDistance,rank,mpi_comm)
CALL mpi_bc(this%l_dftspinpol,rank,mpi_comm)
CALL mpi_bc(this%l_fullMatch,rank,mpi_comm)
CALL mpi_bc(this%l_nonsphDC,rank,mpi_comm)
CALL mpi_bc(this%beta,rank,mpi_comm)
CALL mpi_bc(this%n_occpm,rank,mpi_comm)
CALL mpi_bc(this%init_occ,rank,mpi_comm)
CALL mpi_bc(this%ccf,rank,mpi_comm)
CALL mpi_bc(this%xi_par,rank,mpi_comm)
CALL mpi_bc(this%n_exc,rank,mpi_comm)
CALL mpi_bc(this%exc_l,rank,mpi_comm)
CALL mpi_bc(this%exc,rank,mpi_comm)
CALL mpi_bc(this%init_mom,rank,mpi_comm)
CALL mpi_bc(this%n_addArgs,rank,mpi_comm)
CALL mpi_bc(this%arg_keys,rank,mpi_comm)
CALL mpi_bc(this%arg_vals,rank,mpi_comm)
CALL mpi_bc(this%l_soc_given,rank,mpi_comm)
CALL mpi_bc(this%l_ccf_given,rank,mpi_comm)
END SUBROUTINE mpi_bc_hub1inp
SUBROUTINE read_xml_hub1inp(this, xml)
USE m_types_xml
CLASS(t_hub1inp), INTENT(INOUT):: this
TYPE(t_xml),INTENT(INOUT) ::xml
INTEGER::numberNodes,ntype,n_maxaddArgs
INTEGER::i_hia,itype,i_exc,i_addArg,i,j,hub1_l
CHARACTER(len=100) :: xPathA,xPathB,xPathS,key,tmp_str
REAL::val
ntype = xml%GetNumberOfNodes('/fleurInput/atomGroups/atomGroup')
n_maxaddArgs = 5 !Maximum allowed number of additional arguments (excluding xiSOC and ccf)
ALLOCATE(this%init_occ(4*ntype),source=0.0)
ALLOCATE(this%ccf(4*ntype),source=-1.0)
ALLOCATE(this%xi_par(4*ntype),source=0.0)
ALLOCATE(this%n_exc(4*ntype),source=0)
ALLOCATE(this%exc_l(4*ntype,lmaxU_const),source=-1)
ALLOCATE(this%exc(4*ntype,lmaxU_const),source=0.0)
ALLOCATE(this%init_mom(4*ntype,lmaxU_const),source=0.0)
ALLOCATE(this%n_addArgs(4*ntype),source=0)
ALLOCATE(this%arg_keys(4*ntype,n_maxaddArgs))
this%arg_keys='' !For some reason source doesn't work here
ALLOCATE(this%arg_vals(4*ntype,n_maxaddArgs),source=0.0)
ALLOCATE(this%l_soc_given(4*ntype),source=.FALSE.)
ALLOCATE(this%l_ccf_given(4*ntype),source=.FALSE.)
!General parameters:
xPathA = '/fleurInput/calculationSetup/ldaHIA'
numberNodes = xml%GetNumberOfNodes(TRIM(ADJUSTL(xPathA)))
IF(numberNodes==1) THEN
this%itmax = evaluateFirstIntOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@itmax'))
this%minoccDistance = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@minoccDistance'))
this%minmatDistance = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@minmatDistance'))
this%beta = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@beta'))
this%n_occpm = evaluateFirstIntOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@n_occpm'))
this%l_dftspinpol = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@dftspinpol'))
this%l_fullMatch = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@fullMatch'))
this%l_nonsphDC = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_nonsphDC'))
ENDIF
!Read in the additional information given in the ldaHIA tags (exchange splitting and additional keywords)
i_hia=0
DO itype = 1, ntype
xPathS = xml%speciesPath(itype)
DO j = 1, xml%GetNumberOfNodes(TRIM(ADJUSTL(xPathS))//'/ldaHIA')
i_hia = i_hia + 1
WRITE(xPathA,*) TRIM(ADJUSTL(xPathS))//'/ldaHIA[',j,']'
!Read in the hubbard 1 orbital for a later check
hub1_l = evaluateFirstIntOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l'))
!Initial occupation
tmp_str = TRIM(ADJUSTL(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@init_occ')))
IF(TRIM(ADJUSTL(tmp_str))=="calc") THEN
this%init_occ(i_hia) = -9e99
ELSE
this%init_occ(i_hia) = evaluateFirstOnly(TRIM(ADJUSTL(tmp_str)))
ENDIF
!Additional exchange splitting
DO i_exc = 1, xml%GetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/exc')
WRITE(xPathB,*) TRIM(ADJUSTL(xPathA))//'/exc[',i_exc,']'
IF(i_exc>lmaxU_const) CALL juDFT_error("Too many additional exchange splittings provided. Maximum is 3.",&
calledby="read_xml_hub1inp")
this%n_exc(i_hia) = this%n_exc(i_hia) + 1
this%exc_l(i_hia,i_exc) = evaluateFirstIntOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathB))//'/@l'))
this%exc(i_hia,i_exc) = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathB))//'/@J'))
tmp_str = TRIM(ADJUSTL(xml%GetAttributeValue(TRIM(ADJUSTL(xPathB))//'/@init_mom')))
IF(TRIM(ADJUSTL(tmp_str))=="calc") THEN
this%init_mom(i_hia,i_exc) = -9e99
ELSE
this%init_mom(i_hia,i_exc) = evaluateFirstOnly(TRIM(ADJUSTL(tmp_str)))
ENDIF
!Check if the given l is valid (l<3 and not the same as the hubbard orbital)
IF(this%exc_l(i_hia,i_exc).EQ.hub1_l.OR.this%exc_l(i_hia,i_exc).GT.3) &
CALL juDFT_error("Additional exchange splitting: Not a valid l"&
,calledby="read_xml_hub1inp")
!Check if there already is a defined exchange splitting on this orbital
DO i = 1, this%n_exc(i_hia)-1
IF(this%exc_l(i_hia,i_exc)==this%exc_l(i_hia,i)) &
CALL juDFT_error("Two exchange splittings defined for equal l"&
,calledby="read_xml_hub1inp")
ENDDO
ENDDO
DO i_addArg = 1, xml%GetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/addArg')
WRITE(xPathB,*) TRIM(ADJUSTL(xPathA))//'/addArg[',i_addArg,']'
IF(i_addArg>n_maxaddArgs) CALL juDFT_error("Too many additional arguments provided. Maximum is 5.",&
calledby="read_xml_hub1inp")
key = xml%GetAttributeValue(TRIM(ADJUSTL(xPathB))//'/@key')
val = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathB))//'/@value'))
DO i = 1, this%n_addArgs(i_hia)
IF(TRIM(ADJUSTL(key)).EQ.TRIM(ADJUSTL(this%arg_keys(i_hia,i)))) THEN
CALL juDFT_error("Ambigous additional arguments: You specified two arguments with the same keyword"&
,calledby="read_xml_hub1inp")
ENDIF
ENDDO
SELECT CASE(TRIM(ADJUSTL(key)))
CASE('xiSOC')
!Do not get soc from DFT and use provided value
IF(this%l_soc_given(i_hia)) CALL juDFT_error("Two SOC parameters provided",calledby="read_xml_hub1inp")
this%l_soc_given(i_hia) = .TRUE.
this%xi_par(i_hia) = val
IF(ABS(this%xi_par(i_hia))< 0.001) this%xi_par(i_hia) = 0.001
CASE('ccf')
IF(this%l_ccf_given(i_hia)) CALL juDFT_error("Two crystal field factors provided",calledby="read_xml_hub1inp")
this%l_ccf_given(i_hia) = .TRUE.
this%ccf(i_hia) = val
CASE DEFAULT
!Additional argument -> simply pass on to solver
this%n_addArgs(i_hia) = this%n_addArgs(i_hia) + 1
this%arg_keys(i_hia,this%n_addArgs(i_hia)) = TRIM(ADJUSTL(key))
this%arg_vals(i_hia,this%n_addArgs(i_hia)) = val
END SELECT
ENDDO
ENDDO
ENDDO
END SUBROUTINE read_xml_hub1inp
END MODULE m_types_hub1inp
| fleurinput/types_hub1inp.f90 |
module qlibc_util_m
use iso_c_binding
implicit none
interface
! void qtreetbl_copy_data_c(void *val_data_from, void *val_data_to, size_t size_data, bool freemem)
subroutine qlibc_copy_data_c(val_data_from, val_data_to, size_data, freemem) bind(c)
import :: c_ptr, c_size_t, c_bool
type(c_ptr), value :: val_data_from
type(c_ptr), value :: val_data_to
integer(c_size_t), value :: size_data
logical(c_bool), value :: freemem
end subroutine
! void qlibc_free_c(void *obj)
subroutine qlibc_free_c(obj) bind(c)
import :: c_ptr
type(c_ptr), value :: obj
end subroutine
end interface
contains
pure function f_c_string(f_string) result (c_string)
use, intrinsic :: iso_c_binding, only: c_char, c_null_char
implicit none
character(len=*), intent(in) :: f_string
character(len=1,kind=c_char) :: c_string(len_trim(f_string)+1)
integer :: n, i
n = len_trim(f_string)
do i = 1, n
c_string(i) = f_string(i:i)
end do
c_string(n + 1) = c_null_char
end function
end module qlibc_util_m
| qcontainers_f/qlibc_util.f90 |
program collect_events
implicit none
character*512 string512,eventfile
character*19 basicfile,nextbasicfile
character*15 outputfile
integer istep,i,numoffiles,nbunches,nevents,ievents,junit(80)
double precision xtotal,absxsec,evwgt,xsecfrac
integer i_orig
common /c_i_orig/i_orig
integer ioutput
parameter(ioutput=99)
integer nevents_file(80),proc_id(80)
double precision xsecfrac_all(80)
common /to_xsecfrac/xsecfrac_all
common /to_nevents_file/nevents_file,proc_id
integer proc_id_tot(0:100)
double precision xsec(100),xsecABS,xerr(100)
logical get_xsec_from_res1
common/total_xsec/xsec,xerr,xsecABS,proc_id_tot,get_xsec_from_res1
write (*,*) "Overwrite the event weights?"
write (*,*) "give '0' to keep original weights;"
write (*,*) "give '1' to overwrite the weights"/
$ /" to sum to the Xsec;"
write (*,*) "give '2' to overwrite the weights"/
$ /" to average to the Xsec (=default)"
write (*,*) "give '3' to overwrite the weights"/
$ /" to either +/- 1."
read (*,*) i_orig
if (i_orig.ne.0 .and. i_orig.ne.1 .and. i_orig.ne.2 .and.
$ i_orig.ne.3) stop
write(*,*) i_orig
istep=0
1 continue
write (*,*) 'step #',istep
outputfile='allevents_X_000'
if(istep.eq.0) then
basicfile='nevents_unweighted'
outputfile='allevents_0_000'
else
basicfile='nevents_unweighted0'
if(istep.gt.8) then
write (*,*) 'Error, istep too large',istep
stop
endif
write(basicfile(19:19),'(i1)')istep
write(outputfile(11:11),'(i1)')istep
endif
nextbasicfile='nevents_unweighted0'
write(nextbasicfile(19:19),'(i1)')istep+1
open(unit=10,file=basicfile,status='old')
open(unit=98,file=nextbasicfile,status='unknown')
call get_orderstags_glob_infos()
c
c First get the cross section from the res_1 files
c
if (istep.eq.0) then
call get_xsec(10)
endif
numoffiles=0
nbunches=0
nevents=0
xtotal=0.d0
do while (.true.)
read(10,'(512a)',err=2,end=2) string512
eventfile=string512(2:index(string512,' '))
read(string512(index(string512,' '):512),*)
$ ievents,absxsec,xsecfrac
if (ievents.eq.0) cycle
nevents=nevents+ievents
numoffiles=numoffiles+1
xsecfrac_all(numoffiles) = xsecfrac
c store here the proc_id as computed from directory name ("@XX" in
c process generation)
if (eventfile(1:1).eq.'P') then
if (eventfile(3:3).eq.'_') then
read(eventfile(2:2),'(i1)') proc_id(numoffiles)
elseif(eventfile(4:4).eq.'_') then
read(eventfile(2:3),'(i2)') proc_id(numoffiles)
elseif(eventfile(5:5).eq.'_') then
read(eventfile(2:4),'(i3)') proc_id(numoffiles)
else
write (*,*) 'ERROR in collect_events: '/
$ /'cannot find process ID'
stop
endif
else
proc_id(numoffiles)=-1
endif
c store here the number of events per file
nevents_file(numoffiles) = ievents
xtotal=xtotal+absxsec
junit(numoffiles)=numoffiles+10
open(unit=junit(numoffiles),file=eventfile,status='old',
& err=999)
c Every time we find 80 files, collect the events
if (numoffiles.eq.80) then
nbunches=nbunches+1
if (i_orig.eq.1) then
if (.not.get_xsec_from_res1) then
evwgt=xtotal/dfloat(nevents)
else
evwgt=xsecABS/dfloat(nevents)
endif
elseif(i_orig.eq.2) then
if (.not.get_xsec_from_res1) then
evwgt=xtotal
else
evwgt=xsecABS
endif
elseif(i_orig.eq.3) then
evwgt=1d0
endif
write (*,*) 'found ',numoffiles,
& ' files, bunch number is',nbunches
if(nbunches.le.9) then
write(outputfile(15:15),'(i1)')nbunches
elseif(nbunches.le.99) then
write(outputfile(14:15),'(i2)')nbunches
elseif(nbunches.le.999) then
write(outputfile(13:15),'(i3)')nbunches
else
write (*,*) 'Error, too many bunches'
stop
endif
open (unit=ioutput,file=outputfile,status='unknown')
call collect_all_evfiles(ioutput,numoffiles,junit,
# nevents,evwgt)
do i=1,numoffiles
if (istep.eq.0) then
close (junit(i))
else
close (junit(i),status='delete')
endif
enddo
close (ioutput)
write(98,*) outputfile(1:15),' ',nevents,' ',xtotal,
# ' ', 1e0
numoffiles=0
nevents=0
xtotal=0.d0
endif
enddo
2 continue
close(10)
c Also collect events from the rest files
if(numoffiles.ne.0) then
nbunches=nbunches+1
if (i_orig.eq.1) then
if (.not.get_xsec_from_res1) then
evwgt=xtotal/dfloat(nevents)
else
evwgt=xsecABS/dfloat(nevents)
endif
elseif(i_orig.eq.2) then
if (.not.get_xsec_from_res1) then
evwgt=xtotal
else
evwgt=xsecABS
endif
elseif(i_orig.eq.3) then
evwgt=1d0
endif
write (*,*) 'found ',numoffiles,
& ' files, bunch number is',nbunches
if(nbunches.le.9) then
write(outputfile(15:15),'(i1)')nbunches
elseif(nbunches.le.99) then
write(outputfile(14:15),'(i2)')nbunches
elseif(nbunches.le.999) then
write(outputfile(13:15),'(i3)')nbunches
else
write (*,*) 'Error, too many bunches'
stop
endif
open (unit=ioutput,file=outputfile,status='unknown')
call collect_all_evfiles(ioutput,numoffiles,junit,
# nevents,evwgt)
do i=1,numoffiles
if (istep.eq.0) then
close (junit(i))
else
close (junit(i),status='delete')
endif
enddo
close(ioutput)
write(98,*) outputfile(1:15),' ',nevents,' ',xtotal,
# ' ', 1e0
endif
close(98)
c
if(nbunches.gt.1) then
istep=istep+1
write (*,*) 'More than 1 bunch, doing next step',istep
goto 1
else
write (*,*) 'Done. Final event file (with',nevents,
& ' events) is:'
write (*,*) outputfile(1:15)
endif
return
c
999 continue
write (*,*) 'Error, event file',eventfile,' not found'
stop
end
subroutine collect_all_evfiles(ioutput,numoffiles,junit,imaxevt
$ ,evwgt)
use extra_weights
implicit none
integer i_orig
common /c_i_orig/i_orig
integer ioutput,junit(80)
integer imaxevt,maxevt,ii,numoffiles,nevents,itot,iunit,
# mx_of_evt(80),i0,i,j,jj,kk,n,nn
double precision evwgt,evwgt_sign
integer ione
parameter (ione=1)
integer IDBMUP(2),PDFGUP(2),PDFSUP(2),IDWTUP,NPRUP,LPRUP
double precision EBMUP(2),XSECUP,XERRUP,XMAXUP
integer IDBMUP1(2),PDFGUP1(2),PDFSUP1(2),IDWTUP1,NPRUP1,LPRUP1
double precision EBMUP1(2),XSECUP1,XERRUP1,XMAXUP1
INTEGER MAXNUP
PARAMETER (MAXNUP=500)
INTEGER NUP,IDPRUP,IDUP(MAXNUP),ISTUP(MAXNUP),
# MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP)
DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,
# PUP(5,MAXNUP),VTIMUP(MAXNUP),SPINUP(MAXNUP)
character*140 buff
character*10 MonteCarlo,MonteCarlo1, MonteCarlo0
character*100 path
integer iseed
data iseed/1/
double precision rnd,fk88random
external fk88random
integer nevents_file(80),proc_id(80)
common /to_nevents_file/nevents_file,proc_id
double precision xsecfrac_all(80)
common /to_xsecfrac/xsecfrac_all
double precision XSECUP2(100),XERRUP2(100),XMAXUP2(100)
integer LPRUP2(100)
common /lhef_init/XSECUP2,XERRUP2,XMAXUP2,LPRUP2
double precision xsecup_l(100),xerrup_l(100)
integer lprup_l(100),nproc_l
logical found_proc
include 'run.inc'
integer proc_id_tot(0:100)
double precision xsec(100),xsecABS,xerr(100)
logical get_xsec_from_res1
common/total_xsec/xsec,xerr,xsecABS,proc_id_tot,get_xsec_from_res1
c Common blocks for the orders tags
integer n_orderstags,oo
integer orderstags_glob(maxorders)
common /c_orderstags_glob/n_orderstags, orderstags_glob
c
maxevt=0
if (.not. get_xsec_from_res1) then
do i=1,100
xsecup_l(i)=0.d0
xerrup_l(i)=0.d0
enddo
else
do i=1,100
if (i.le.proc_id_tot(0)) then
xsecup_l(i)=xsec(i)
xerrup_l(i)=xerr(i)
lprup_l(i) =proc_id_tot(i)
else
xsecup_l(i)=0.d0
xerrup_l(i)=0.d0
endif
enddo
endif
call read_lhef_header(junit(ione),maxevt,MonteCarlo)
if (MonteCarlo .ne. '') MonteCarlo0 = MonteCarlo
call read_lhef_init(junit(ione),
# IDBMUP,EBMUP,PDFGUP,PDFSUP,IDWTUP,NPRUP,
# XSECUP,XERRUP,XMAXUP,LPRUP)
c if the number of the events is in the header (as for evt files in the
c subchannel folders (P*/G*/), the number of events should be in the
c header. Check consistency in this case
if (maxevt .gt. 0) then
mx_of_evt(1)=maxevt
if (mx_of_evt(1) .ne. nevents_file(1)) then
write(*,*) 'Inconsistent event file 1, unit=', junit(1)
write(*,*) 'Expected # of events:', nevents_file(1)
write(*,*) 'Found # of events:', mx_of_evt(1)
stop
endif
else
mx_of_evt(1)=nevents_file(1)
endif
maxevt=mx_of_evt(1)
nproc_l=NPRUP
if (.not. get_xsec_from_res1) then
do i=1,nproc_l
xerrup_l(i)=xerrup2(i)**2 * xsecfrac_all(ione)
xsecup_l(i)=xsecup2(i) * xsecfrac_all(ione)
if (proc_id(ione).ne.-1) then
lprup_l(i)=proc_id(ione)
if (nproc_l.gt.1) then
write (*,*)
$ 'ERROR: inconsistent nproc in collect_event'
write (*,*) nproc_l,NPRUP
write (*,*) proc_id
stop
endif
else
lprup_l(i)=lprup2(i)
endif
enddo
endif
do ii=2,numoffiles
call read_lhef_header(junit(ii),nevents,MonteCarlo1)
if (nevents .gt. 0) then
mx_of_evt(ii)=nevents
if (mx_of_evt(ii) .ne. nevents_file(ii)) then
write(*,*) 'Inconsistent event file, unit=',junit(ii)
write(*,*) 'Expected # of events:', nevents_file(ii)
write(*,*) 'Found # of events:', mx_of_evt(ii)
stop
endif
else
mx_of_evt(ii)=nevents_file(ii)
endif
if(MonteCarlo.ne.MonteCarlo1)then
write(*,*)'Error in collect_all_evfiles'
write(*,*)'Files ',ione,' and ',ii,' are inconsistent'
write(*,*)'Monte Carlo types are not the same'
write(*,*)'1', MonteCarlo, '2', MonteCarlo1
stop
endif
maxevt=maxevt+mx_of_evt(ii)
call read_lhef_init(junit(ii),
# IDBMUP1,EBMUP1,PDFGUP1,PDFSUP1,IDWTUP1,NPRUP1,
# XSECUP1,XERRUP1,XMAXUP1,LPRUP1)
if (.not.get_xsec_from_res1) then
if(proc_id(ii).ne.-1) then
lprup2(1)=proc_id(ii)
endif
do i=1,NPRUP1
found_proc=.false.
do j=1,nproc_l
if (lprup_l(j).eq.lprup2(i)) then
xerrup_l(j)=xerrup_l(j)+xerrup2(i)**2 *xsecfrac_all(ii)
xsecup_l(j)=xsecup_l(j)+xsecup2(i) *xsecfrac_all(ii)
found_proc=.true.
exit
endif
enddo
if (.not.found_proc) then
nproc_l=nproc_l+1
xerrup_l(nproc_l)=xerrup2(i)**2 *xsecfrac_all(ii)
xsecup_l(nproc_l)=xsecup2(i) *xsecfrac_all(ii)
lprup_l(nproc_l)=lprup2(i)
endif
enddo
endif
if(
# IDBMUP(1).ne.IDBMUP1(1) .or.
# IDBMUP(2).ne.IDBMUP1(2) .or.
# EBMUP(1) .ne.EBMUP1(1) .or.
# EBMUP(2) .ne.EBMUP1(2) .or.
# PDFGUP(1).ne.PDFGUP1(1) .or.
# PDFGUP(2).ne.PDFGUP1(2) .or.
# PDFSUP(1).ne.PDFSUP1(1) .or.
# PDFSUP(2).ne.PDFSUP1(2))then
write(*,*)'Error in collect_all_evfiles'
write(*,*)'Files ',ione,' and ',ii,' are inconsistent'
write(*,*)'Run parameters are not the same'
stop
endif
enddo
if(maxevt.ne.imaxevt)then
write(*,*)'Error in collect_all_evfiles'
write(*,*)'Total number of events inconsistent with input'
write(*,*)maxevt,imaxevt
stop
endif
if (.not.get_xsec_from_res1) then
do i=1,nproc_l
xerrup_l(i)=sqrt(xerrup_l(i))
enddo
endif
XSECUP=xsecup_l(ione)
XERRUP=xerrup_l(ione)
LPRUP=lprup_l(ione)
if (.not.get_xsec_from_res1) then
NPRUP=nproc_l
else
NPRUP=proc_id_tot(0)
endif
do i=1,NPRUP
XSECUP2(i)=xsecup_l(i)
xerrup2(i)=xerrup_l(i)
lprup2(i)=lprup_l(i)
xmaxup2(i)=abs(evwgt)
enddo
path="../Cards/"
call write_lhef_header_banner(ioutput,maxevt,MonteCarlo0,path)
call write_lhef_init(ioutput,
# IDBMUP,EBMUP,PDFGUP,PDFSUP,IDWTUP,NPRUP,
# XSECUP,XERRUP,abs(evwgt),LPRUP)
itot=maxevt
do i=1,maxevt
rnd=fk88random(iseed)
call whichone(rnd,numoffiles,itot,mx_of_evt,junit,iunit,i0)
call read_lhef_event(iunit,
# NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,
# IDUP,ISTUP,MOTHUP,ICOLUP,PUP,VTIMUP,SPINUP,buff)
if (proc_id(i0).ne.-1) IDPRUP=proc_id(i0)
if (i_orig.eq.0) then
evwgt_sign=XWGTUP
else
c Overwrite the weights. Also overwrite the weights used for PDF & scale
c reweighting
evwgt_sign=dsign(evwgt,XWGTUP)
if (do_rwgt_scale) then
do oo=0,n_orderstags
do kk=1,dyn_scale(0)
if (lscalevar(kk)) then
do ii=1,nint(scalevarF(0))
do jj=1,nint(scalevarR(0))
wgtxsecmu(oo,jj,ii,kk)=wgtxsecmu(oo,jj,ii,kk)
$ *evwgt_sign/XWGTUP
enddo
enddo
else
wgtxsecmu(oo,1,1,kk)=wgtxsecmu(oo,1,1,kk)
$ *evwgt_sign/XWGTUP
endif
enddo
enddo
endif
if (do_rwgt_pdf) then
do nn=1,lhaPDFid(0)
if (lpdfvar(nn)) then
do n=0,nmemPDF(nn)
wgtxsecPDF(n,nn)=wgtxsecPDF(n,nn)*evwgt_sign/XWGTUP
enddo
else
wgtxsecPDF(0,nn)=wgtxsecPDF(0,nn)*evwgt_sign/XWGTUP
endif
enddo
endif
endif
call write_lhef_event(ioutput,
# NUP,IDPRUP,evwgt_sign,SCALUP,AQEDUP,AQCDUP,
# IDUP,ISTUP,MOTHUP,ICOLUP,PUP,VTIMUP,SPINUP,buff)
enddo
write(ioutput,'(a)')'</LesHouchesEvents>'
return
end
subroutine whichone(rnd,numoffiles,itot,mx_of_evt,junit,iunit,i0)
implicit none
double precision rnd,tiny,one,xp(80),xsum,prob
integer numoffiles,itot,mx_of_evt(80),junit(80),iunit,ifiles,i0
logical flag
parameter (tiny=1.d-4)
c
if(itot.le.0)then
write(6,*)'fatal error #1 in whichone'
stop
endif
one=0.d0
do ifiles=1,numoffiles
xp(ifiles)=dfloat(mx_of_evt(ifiles))/dfloat(itot)
one=one+xp(ifiles)
enddo
if(abs(one-1.d0).gt.tiny)then
write(6,*)'whichone: probability not normalized'
stop
endif
c
i0=0
flag=.true.
xsum=0.d0
do while(flag)
if(i0.gt.numoffiles)then
write(6,*)'fatal error #2 in whichone'
stop
endif
i0=i0+1
prob=xp(i0)
xsum=xsum+prob
if(rnd.lt.xsum)then
flag=.false.
itot=itot-1
mx_of_evt(i0)=mx_of_evt(i0)-1
iunit=junit(i0)
endif
enddo
return
end
FUNCTION FK88RANDOM(SEED)
* -----------------
* Ref.: K. Park and K.W. Miller, Comm. of the ACM 31 (1988) p.1192
* Use seed = 1 as first value.
*
IMPLICIT INTEGER(A-Z)
REAL*8 MINV,FK88RANDOM
SAVE
PARAMETER(M=2147483647,A=16807,Q=127773,R=2836)
PARAMETER(MINV=0.46566128752458d-09)
HI = SEED/Q
LO = MOD(SEED,Q)
SEED = A*LO - R*HI
IF(SEED.LE.0) SEED = SEED + M
FK88RANDOM = SEED*MINV
END
subroutine get_xsec(unit10)
implicit none
integer unit10
character*120 string120,eventfile,results_file,read_line
integer proc_id_l,add_xsec_to,i,ievents
double precision xsec_read,xerr_read,absxsec,xsecfrac,xsecABS_read
integer proc_id_tot(0:100)
double precision xsec(100),xsecABS,xerr(100)
logical get_xsec_from_res1
common/total_xsec/xsec,xerr,xsecABS,proc_id_tot,get_xsec_from_res1
proc_id_tot(0)=0
get_xsec_from_res1=.true.
xsecABS=0d0
do
read(unit10,'(120a)',end=22,err=22) string120
eventfile=string120(2:index(string120,' '))
read(string120(index(string120,' '):120),*)
$ ievents,absxsec,xsecfrac
if (eventfile(1:1).eq.'P') then
if (eventfile(3:3).eq.'_') then
read(eventfile(2:2),'(i1)') proc_id_l
elseif(eventfile(4:4).eq.'_') then
read(eventfile(2:3),'(i2)') proc_id_l
elseif(eventfile(5:5).eq.'_') then
read(eventfile(2:4),'(i3)') proc_id_l
else
write (*,*) 'ERROR in collect_events: '/
$ /'cannot find process ID'
stop
endif
else
proc_id_l=-1
get_xsec_from_res1=.false.
exit
endif
if (index(eventfile,'events.lhe').eq.0) then
get_xsec_from_res1=.false.
exit
endif
results_file=eventfile(1:index(eventfile,'events.lhe')-1)
$ //'res_1'
open (unit=11,file=results_file,status='old',err=998)
read (11,'(120a)',err=998) read_line
read(read_line(index(read_line,'Final result [ABS]:')+20:),*
$ ,err=998)xsecABS_read
read (11,'(120a)',err=998) read_line
close (11)
read(read_line(index(read_line,'Final result:')+14:),*,err=998)
$ xsec_read
read(read_line(index(read_line,'+/-')+4:),*,err=998) xerr_read
add_xsec_to=-1
if (proc_id_tot(0).ge.1) then
do i=1,proc_id_tot(0)
if (proc_id_l.eq.proc_id_tot(i)) then
add_xsec_to=i
exit
endif
enddo
endif
if (add_xsec_to.eq.-1) then
proc_id_tot(0)=proc_id_tot(0)+1
if (proc_id_tot(0).gt.100) then
write (*,*) 'ERROR, too many separate processes'
$ ,proc_id_tot(0)
stop
endif
proc_id_tot(proc_id_tot(0))=proc_id_l
xsec(proc_id_tot(0))=xsec_read*xsecfrac
xerr(proc_id_tot(0))=xerr_read**2*xsecfrac
else
xsec(add_xsec_to)=xsec(add_xsec_to)+xsec_read*xsecfrac
xerr(add_xsec_to)=xerr(add_xsec_to)+xerr_read**2*xsecfrac
endif
xsecABS=xsecABS + xsecABS_read*xsecfrac
enddo
22 continue
do i=1,proc_id_tot(0)
xerr(i)=sqrt(xerr(i))
enddo
rewind(unit10)
return
998 continue
write (*,*) 'Error, results file',results_file
$ ,' not found or not the correct format.'
stop
end
| Template/NLO/SubProcesses/collect_events.f |
subroutine corrpos(ctimestp,rc)
include 'globals.h'
character(len=*) :: rc
integer :: i,p,k,ctimestp(*)
real dt2,rcsign,acceff,dt
if(rc.NE.'sync'.AND.rc.NE.'desync') &
call terror('unknown sync option in corrpos')
if(rc.EQ.'sync') then
if(syncflag.EQ.0) return
syncflag=0
rcsign=-1.
if(verbosity.GT.0) print*,'<corrpos> sync'
endif
if(rc.EQ.'desync') then
if(syncflag.EQ.1) return
syncflag=1
rcsign=1.
if(verbosity.GT.0) print*,'<corrpos> desync'
endif
ppropcount=ppropcount+1
if(.not.periodic) then
do k=1,ndim
do i=1,npactive
p=pactive(i)
dt2=(dtime/2**(ctimestp(p)-1))**2
pos(p,k)=pos(p,k)+rcsign*acc(p,k)*dt2/8.
enddo
enddo
else
do k=1,ndim
do i=1,npactive
p=pactive(i)
dt2=(dtime/2**(ctimestp(p)-1))**2
pos(p,k)=pos(p,k)+rcsign*acc(p,k)*dt2/8.
if(pos(p,k).GE.hboxsize) pos(p,k)=pos(p,k)-pboxsize
if(pos(p,k).LT.-hboxsize) pos(p,k)=pos(p,k)+pboxsize
enddo
enddo
endif
end subroutine
subroutine steppos
include 'globals.h'
integer i,ib,p,k,nkeep
real acceff,distance,csdtime
ppropcount=ppropcount+1
if(.not.periodic) then
do k=1,ndim
do p=1,nbodies
pos(p,k)=pos(p,k)+vel(p,k)*tsteppos
enddo
enddo
else
do k=1,ndim
do p=1,nbodies
pos(p,k)=pos(p,k)+vel(p,k)*tsteppos
if(pos(p,k).GE.hboxsize) pos(p,k)=pos(p,k)-pboxsize
if(pos(p,k).LT.-hboxsize) pos(p,k)=pos(p,k)+pboxsize
enddo
enddo
endif
tpos=tpos+tsteppos
tnow=tpos
end subroutine
subroutine stepvel
include 'globals.h'
integer p,k,i
real acceff,vfac1now,vfac2now,dt,go,maxacc
! adhoc acc limiter
k=0
if(usesph) then
do i=1,nsphact
p=pactive(i)
acceff=sqrt(sum(acc(p,1:3)**2))
maxacc=tstepcrit**2*hsmooth(p)*(2**(itimestp(p)-1)/dtime)**2
if(acceff.GT.maxacc) then
k=k+1
acc(p,1:3)=acc(p,1:3)/acceff*maxacc
endif
enddo
endif
if(k.GT.0.AND.(verbosity.GT.0).OR.k.GT.0.001*nsph) &
print*,' > acc limiter',tnow,k
!
do k=1,ndim
do i=1,npactive
p=pactive(i)
vel(p,k)=vel(p,k)+acc(p,k)*dtime/2**(itimestp(p)-1)
enddo
enddo
do i=1,npactive
p=pactive(i)
tvel(p)=tvel(p)+dtime/2**(itimestp(p)-1)
if(ABS(tvel(p)-tnow).gt.dtime/2**(itimestp(p)-1)) then
print*,p,tvel(p),tnow,itimestp(p),npactive
call terror(' stepvel error: tvel mismatch')
endif
enddo
end subroutine
subroutine zeroacc
include 'globals.h'
acc(pactive(1:npactive),1:3)=0.
end subroutine
subroutine zeropot
include 'globals.h'
phi(pactive(1:npactive))=0.
phiext(pactive(1:npactive))=0.
if(npactive.EQ.nbodies) esofttot=0.0
end subroutine
subroutine vextrap
include 'globals.h'
integer p,k
do k=1,ndim
do p=1,nsph
veltpos(p,k)=vel(p,k)+acc(p,k)*(tnow-tvel(p))
enddo
enddo
end subroutine
subroutine allethdot
include 'globals.h'
if(.NOT.consph) then
call terror(' non conservative TBD')
! if(sph_visc.EQ.'sphv') call omp_ethdotcv(pc)
! if(sph_visc.EQ.'bulk') call omp_ethdotbv(pc)
! if(sph_visc.EQ.'sph ') call omp_ethdot(pc)
else
! if(sph_visc.EQ.'sph ') call omp_ethdotco(pc)
if(sph_visc.EQ.'bulk') call terror(' allethdot error')
if(sph_visc.EQ.'sphv') call terror(' allethdot error')
endif
end subroutine
subroutine allentdot
include 'globals.h'
if(sph_visc.EQ.'sph ') call omp_entdot
if(sph_visc.EQ.'bulk') call terror(' allentdot error')
if(sph_visc.EQ.'sphv') call terror(' allentdot error')
end subroutine
subroutine allaccsph
include 'globals.h'
if(.NOT.consph) then
call terror(' non conservative TBD')
! if(sph_visc.EQ.'sphv') call omp_accsphcv
! if(sph_visc.EQ.'bulk') call omp_accsphbv
! if(sph_visc.EQ.'sph ') call omp_accsph
else
if(sph_visc.EQ.'sph ') call omp_accsphco
if(sph_visc.EQ.'bulk') call terror(' allaccsph error')
if(sph_visc.EQ.'sphv') call terror(' allaccsph error')
endif
end subroutine
subroutine alldentacc
include 'globals.h'
if(.NOT.consph) then
call terror(' non conservative TBD')
! if(sph_visc.EQ.'sphv') call omp_accsphcv
! if(sph_visc.EQ.'bulk') call omp_accsphbv
! if(sph_visc.EQ.'sph ') call omp_accsph
else
if(sph_visc.EQ.'sph ') call omp_entdotaccsphco
if(sph_visc.EQ.'bulk') call terror(' allaccsph error')
if(sph_visc.EQ.'sphv') call terror(' allaccsph error')
endif
end subroutine
subroutine alldethacc
include 'globals.h'
if(.NOT.consph) then
call terror(' dethacc TBD ')
! if(sph_visc.EQ.'sphv') call omp_accsphcv
! if(sph_visc.EQ.'bulk') call omp_accsphbv
! if(sph_visc.EQ.'sph ') call omp_accsph
else
if(sph_visc.EQ.'sph ') call omp_ethdotaccsphco
if(sph_visc.EQ.'bulk') call terror(' allaccsph error')
if(sph_visc.EQ.'sphv') call terror(' allaccsph error')
endif
end subroutine
subroutine stepsph
include 'globals.h'
integer i,j,npnear,p
call makesphtree
if(hupdatemethod.NE.'mass') then
call terror('TBD: hupdate=mass')
! call omp_stepnear !change to hsmcal
! call omp_density !easychange
! call veldisp ! lesseasy
else
call densnhsmooth
endif
! call update_reduction !!!!!! not so urgent
! quick fix: (not parallelized)
call tree_reduction(root,incells,'sph ')
if(nbh.GT.0) call blackholes
if(nstar+nbh.GT.0) call mech_feedback
if(nsphact.EQ.0) return
if(.NOT.isotherm) then
if(.NOT.uentropy) then
call allethdot
call exstep2(1)
call alldethacc
call exstep2(2)
else
call allentdot ! entdot is 2x faster than accsph
call exstep2(1)
call alldentacc ! call allentdot
call exstep2(2)
endif
call exstep2(3)
else
call alldethacc
endif
end subroutine
subroutine step
include 'globals.h'
integer itime
itime=0
do while(itime.LT.2*max_tbin)
call setrnd()
if(starform.and.nsph.gt.0) then
if(verbosity.GT.0) print*,'<stepsys> starform...'
call newstar
endif
if(nbh.gt.0) then
if(verbosity.GT.0) print*,'<stepsys> bh mergers...'
call bhmergers
endif
if(verbosity.GT.0) print*,'<stepsys> partremoval1...'
call partremoval
if(verbosity.GT.0) print*,'<stepsys> timestep..'
call timestep(itime)
if(verbosity.GT.0) print*,'<stepsys> steppos..'
call steppos
! note that particles are not removed in clean, just set to zero mass
! - we have moved this from before partremoval. all routines should be
! 'zero-mass-safe'
if(verbosity.GT.0) print*,'<stepsys> clean...'
call clean
! if(verbosity.GT.0) print*,'<stepsys> cosmo...'
!TBD if(usesph.and.radiate) call cosmicray
if(usesph) then
if(verbosity.GT.0) print*,'<stepsys> extrapolate..'
call vextrap
call extrapethrho
endif
if(npactive.gt.0) then
if(verbosity.GT.0) print*,'<stepsys> gravity..'
call zeroacc
call gravity('acc ')
endif
if((starform.or.radiate)) then
if(verbosity.GT.0) print*,'<stepsys> starevolv..'
call starevolv
endif
if(usesph.and.nsphact.gt.0.and.radiate) then
if(verbosity.GT.0) print*,'<stepsys> fuvflux..'
call zerofuv
call fuvflux
endif
if(usesph.and.radiate) then
if(verbosity.GT.0) print*,'<stepsys> molecules...'
call molecules
endif
if(usesph) then
if(verbosity.GT.0) print*,'<stepsys> stepsph..'
call stepsph
endif
if(npactive.GT.0) then
if(verbosity.GT.0) print*,'<stepsys> stepvel..'
! if(sphfiltr.and.usesph.and.nsphact.gt.0) call vfilter tbd
call stepvel
endif
enddo
if(verbosity.GT.0) print*,'<stepsys> partremoval2...'
call partremoval
if(verbosity.GT.0) print*,'<stepsys> nbodies,nsph,nstar:',nbodies,nsph,nstar
if(sortpart) then
if(verbosity.GT.0) print*,'<stepsys> sorting...'
if(sortpart) call mortonsort
endif
end subroutine
subroutine stepsystem(n)
include 'globals.h'
integer n
! for AMUSE
! reset the record of the removed ids
nremovals = 0
! ---
call step
print*,'<stepsystem> step completed:',n
call outstate(n)
end subroutine
| src/amuse/community/fi/src/stepsystem.f90 |
! ###################################################################
! Copyright (c) 2019-2020, 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:xrd.f90
!--------------------------------------------------------------------------
!
! MODULE: xrd
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief Basic routines for XRD computations
!
!> @date 07/30/19 MDG 1.0 original version
!--------------------------------------------------------------------------
module xrdmod
use local
contains
!--------------------------------------------------------------------------
!
! SUBROUTINE: getXRDwavenumber
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief return the x-ray wave number for a given accelerating voltage
!
!> @param kV accelerating voltage of x-ray tube (in kV, obviously)
!
!> @date 07/30/19 MDG 1.0 original
!--------------------------------------------------------------------------
recursive function getXRDwavenumber(kV) result(wavenumber)
!DEC$ ATTRIBUTES DLLEXPORT :: getXRDwavenumber
IMPLICIT NONE
real(kind=sgl),INTENT(IN) :: kV
real(kind=sgl) :: wavenumber
wavenumber = kV / 1.23984193 ! in nm
end function getXRDwavenumber
end module xrdmod
| Source/EMsoftLib/xrd.f90 |
program main
use, intrinsic :: iso_fortran_env
use :: json_module
use :: stdlib_logger
use :: ex_io
implicit none
type(json_file) :: config_json
real(real64), allocatable :: d(:, :, :)
call config_json%initialize()
call load_configure_file(config_json, filename="config")
call construct(d, config_json)
call compute_distance_function(d, config_json)
call output_distance_function(d, "distance_function")
call finalize(d)
call config_json%destroy()
end program main
| app/main.f90 |
program t
integer :: i
do i = 1, 10
if (i == 5) exit
print *, i
end do
end program t
| test/output_tests/exit_out1.f90 |
Debats du Senat (hansard)
1ere Session, 36 e Legislature,
Volume 137, Numero 111
Le mardi 16 fevrier 1999
L'honorable Gildas L. Molgat, President
La reaction aux articles de presse
Le resultat des premieres elections
Projet de loi modificatif-Rapport du comite
Projet de loi modificatif-Motion d'adoption du message des Communes-Rapport du comite
Regie interne, budgets et administration
Presentation du trentieme rapport du comite
Presentation du trente et unieme rapport du comite
Le debat sur l'envoi de troupes a l'etranger-Avis d'interpellation
La reponse du gouvernement aux demandes et aux recommandations-Avis d'interpellation
Le programme d'echange de pages avec la Chambre des communes
La gestion du fonds-Le debut de l'envoi des bourses-La position du gouvernement
L'election du leader du gouvernement par ses pairs-La position du gouvernement
La Societe de developpement du Cap-Breton
Avis de motion condamnant l'article du magazine Hustler concernant la ministre du Patrimoine canadien
Projet de loi sur la reconnaissance des services de guerre de la marine marchande
Deuxieme lecture-Suite du debat
Etude du rapport du comite special-Ajournement du debat
L'etat du systeme financier
Etude du rapport provisoire du comite des banques et du commerce-Ajournement du debat
Examen en comite plenier-Report de l'article
La situation du systeme financier
Les travaux du Senat
Le mardi 16 fevrier 1999
La seance est ouverte a 14 heures, le President etant au fauteuil.
Son Honneur le President :
Au nom de tous les senateurs, je vous souhaite la bienvenue au Senat canadien.
La date du Nouvel An est fixee selon le calendrier lunaire chinois.
Nous entamons aujourd'hui l'annee du lapin.
Les enfants et amis celibataires recoivent des lai xi des personnes mariees.
Ces petites enveloppes rouges contiennent de l'argent, en guise de bonne fortune.
Les personnes qui les consomment verront leurs voeux se realiser.
| data/Hansard/Training/hansard.36.1.senate.debates.1999-02-16.111.f |
subroutine gg_hZZ_tb(p,msq)
implicit none
c--- Author: J. M. Campbell, September 2013
c--- Matrix element squared for gg -> H -> ZZ signal process
c--- The exact result for massive bottom and top quark loops is included
include 'constants.f'
include 'ewcouple.f'
include 'qcdcouple.f'
include 'qlfirst.f'
include 'interference.f'
integer h1,h2,h34,h56
double precision p(mxpart,4),msq(fn:nf,fn:nf),msqgg,fac,
& pswap(mxpart,4),oprat
double complex ggH_bquark(2,2,2,2),ggH_tquark(2,2,2,2),Ahiggs,
& ggH_bquark_swap(2,2,2,2),ggH_tquark_swap(2,2,2,2),Ahiggs_swap
double complex ggH2_bquark(2,2,2,2),ggH2_tquark(2,2,2,2),
& ggH2_bquark_swap(2,2,2,2),ggH2_tquark_swap(2,2,2,2)
if (qlfirst) then
qlfirst=.false.
call qlinit
endif
msq(:,:)=0d0
call getggHZZamps(p,ggH_bquark,ggH_tquark)
call getggH2ZZamps(p,ggH2_bquark,ggH2_tquark)
if (interference) then
c--- for interference, compute amplitudes after 4<->6 swap
pswap(1,:)=p(1,:)
pswap(2,:)=p(2,:)
pswap(3,:)=p(3,:)
pswap(4,:)=p(6,:)
pswap(5,:)=p(5,:)
pswap(6,:)=p(4,:)
call getggHZZamps(pswap,ggH_bquark_swap,ggH_tquark_swap)
call getggH2ZZamps(pswap,ggH2_bquark_swap,ggH2_tquark_swap)
endif
msqgg=0d0
do h1=1,2
h2=h1
do h34=1,2
do h56=1,2
c--- compute total Higgs amplitude
AHiggs=
& +ggH_bquark(h1,h2,h34,h56)
& +ggH_tquark(h1,h2,h34,h56)
& +ggH2_bquark(h1,h2,h34,h56)
& +ggH2_tquark(h1,h2,h34,h56)
if (interference .eqv. .false.) then
c--- normal case
msqgg=msqgg+cdabs(AHiggs)**2
else
c--- with interference
AHiggs_swap=
& +ggH_bquark_swap(h1,h2,h34,h56)
& +ggH_tquark_swap(h1,h2,h34,h56)
& +ggH2_bquark_swap(h1,h2,h34,h56)
& +ggH2_tquark_swap(h1,h2,h34,h56)
if (h34 .eq. h56) then
oprat=1d0-2d0*dble(dconjg(AHiggs)*AHiggs_swap)
& /(cdabs(AHiggs)**2+cdabs(AHiggs_swap)**2)
else
oprat=1d0
endif
msqgg=msqgg+cdabs(AHiggs)**2*oprat
& +cdabs(AHiggs_swap)**2*oprat
endif
enddo
enddo
enddo
c--- overall factor extracted (c.f. getggHZZamps.f)
fac=avegg*V*(4d0*esq*gsq/(16d0*pisq)*esq)**2
msq(0,0)=msqgg*fac*vsymfact
return
end
| MCFM-JHUGen/src/ZZ/gg_hzz_tb.f |
!=============================================================================!
subroutine resstat(res, dtl)
!
! This subroutine calculates the statistics of the residual.
!
! Note that the norm of the residual is divided by dtl
!
!=============================================================================!
use global
use material
implicit none
real :: res(ndof,nx,ny), dtl(nx,ny)
!$sgi distribute res(*,*,block), dtl(*,block)
real :: resnod
real :: totres = 0.0d0, resfrt = 0.0d0, resmax = 0.0d0
real :: resmx(ndof)
integer :: jtotrs, jresmx, numnp
integer :: i, j, ixrmax, iyrmax
real :: CPUl
#ifdef CRAY
real, save :: CPU
real, external :: second
#else
real*4, save :: CPU
real*4, external :: second
#endif
!=============================================================================!
ixrmax = 0
iyrmax = 0
numnp = nx * ny
! !$omp parallel do private(i,resnod,ixrmax,iyrmax) &
! !$omp& reduction(+: totres) reduction(max: resmax)
do j = 1, ny
do i = 1, nx
resnod = ( res(1,i,j)**2 + &
res(2,i,j)**2 + &
res(3,i,j)**2 + &
res(4,i,j)**2 + &
res(5,i,j)**2 ) / dtl(i,j)**2
totres = totres + resnod
! resmax = max(resnod,resmax)
if (resnod .gt. resmax) then
resmax = resnod
ixrmax = i
iyrmax = j
end if
end do
end do
if (ixrmax.ne.0 .and. iyrmax.ne.0) then
resmx(:) = res(:,ixrmax,iyrmax) / dtl(ixrmax,iyrmax)
else
resmx(:) = zero
end if
totres = sqrt(totres / real(numnp))
resmax = sqrt(resmax)
if (resfrt .eq. zero) resfrt = totres
if (totres .ne. zero) then
jtotrs = int ( 10.0 * log10 ( totres / resfrt ) )
jresmx = int ( 10.0 * log10 ( resmax / totres ) )
else
jtotrs = zero
jresmx = zero
end if
!.... calculate the CPU-time
if (istep.eq.0) then
CPUl = zero
else
CPUl = second() - CPU
end if
CPU = second()
!.... output the result
write(*,1000) lstep, time, Delt, cfl, totres, jtotrs, &
ixrmax, iyrmax, jresmx, CPU, CPUl
write(ihist,1000) lstep, time, Delt, cfl, totres, jtotrs, &
ixrmax, iyrmax, jresmx, CPU, CPUl
call flush(ihist)
!.... this outputs the value of the maximum residual
! write(60,1010) lstep, ixrmax, iyrmax, resmx(1), resmx(2), &
! resmx(3), resmx(4), resmx(5)
!.... reinitialize the variables
totres = zero
resmax = zero
return
1000 format(1p,i6,e10.3,e10.3,e10.3,e10.3,2x,'(',i4,')',&
2x,'<',' (',i3,',',i3,') ','|',i4,'>',e10.3,e10.3)
1010 format(3(i6,1x),5(1pe13.6,1x))
end
!=============================================================================!
subroutine vstat(vl, dtl)
!
! This subroutine calculates the statistics of the solution.
!
!=============================================================================!
use global
use material
implicit none
real :: vl(ndof,nx,ny), dtl(nx,ny)
!$sgi distribute vl(*,*,block), dtl(*,block)
real :: resnod
real :: totres = 0.0d0, resfrt = 0.0d0, resmax = 0.0d0
real :: resmx(ndof)
integer :: jtotrs, jresmx, numnp
integer :: i, j, ixrmax, iyrmax
real :: CPUl
#ifdef CRAY
real, save :: CPU
real, external :: second
#else
real*4, save :: CPU
real*4, external :: second
#endif
!=============================================================================!
ixrmax = 0
iyrmax = 0
numnp = nx * ny
! !$omp parallel do private(i,resnod,ixrmax,iyrmax) &
! !$omp& reduction(+: totres) reduction(max: resmax)
do j = 1, ny
do i = 1, nx
resnod = vl(1,i,j)**2 + vl(2,i,j)**2 + &
vl(3,i,j)**2 + vl(4,i,j)**2 + &
vl(5,i,j)**2
totres = totres + resnod
! resmax = max(resnod,resmax)
if (resnod .gt. resmax) then
resmax = resnod
ixrmax = i
iyrmax = j
end if
end do
end do
if (ixrmax.ne.0 .and. iyrmax.ne.0) then
resmx(:) = vl(:,ixrmax,iyrmax) / dtl(ixrmax,iyrmax)
else
resmx(:) = zero
end if
totres = sqrt(totres / real(numnp))
resmax = sqrt(resmax)
if (resfrt .eq. zero) resfrt = totres
if (totres .ne. zero) then
jtotrs = int ( 10.0 * log10 ( totres / resfrt ) )
jresmx = int ( 10.0 * log10 ( resmax / totres ) )
else
jtotrs = zero
jresmx = zero
end if
!.... calculate the CPU-time
if (istep.eq.0) then
CPUl = zero
else
CPUl = second() - CPU
end if
CPU = second()
!.... output the result
write(*,1000) lstep, time, Delt, cfl, totres, jtotrs, &
jresmx, CPU, CPUl
write(ihist,1000) lstep, time, Delt, cfl, totres, jtotrs, &
jresmx, CPU, CPUl
!!$ write(*,1000) lstep, time, Delt, cfl, totres, jtotrs, &
!!$ ixrmax, iyrmax, jresmx, CPU, CPUl
!!$
!!$ write(ihist,1000) lstep, time, Delt, cfl, totres, jtotrs, &
!!$ ixrmax, iyrmax, jresmx, CPU, CPUl
call flush(ihist)
!.... this outputs the value of the maximum residual
! write(60,1010) lstep, ixrmax, iyrmax, resmx(1), resmx(2), &
! resmx(3), resmx(4), resmx(5)
!.... reinitialize the variables
totres = zero
resmax = zero
return
1000 format(1p,i6,e10.3,e10.3,e10.3,e10.3,1x,'(',i4,') ',i4,e10.3,e10.3)
!!$1000 format(1p,i6,e10.3,e10.3,e10.3,e10.3,2x,'(',i4,')',&
!!$ 2x,'<',' (',i3,',',i3,') ','|',i4,'>',e10.3,e10.3)
1010 format(3(i6,1x),5(1pe13.6,1x))
end
| src/resstat.f90 |
subroutine gg_hWWgg_v(p,msq)
c--- Virtual matrix element squared averaged over initial colors and spins
c
c g(-p1)+g(-p2)-->H --> W^- (e^-(p5)+nubar(p6))
c + W^+ (nu(p3)+e^+(p4))+g(p_iglue1=7)+g(p_iglue2=8)
c
c Calculation is fully analytic
implicit none
include 'constants.f'
include 'masses.f'
include 'ewcouple.f'
include 'qcdcouple.f'
include 'sprods_com.f'
include 'zprods_com.f'
include 'scheme.f'
include 'nflav.f'
include 'deltar.f'
integer j,k,i5,i6
double precision p(mxpart,4),msq(fn:nf,fn:nf),s3456
double precision hdecay,Asq,fac
double precision qrqr,qarb,aqbr,abab,qbra,bqar
double precision qaqa,aqaq,qqqq,aaaa
double precision qagg,aqgg,qgqg,gqqg,agag,gaag,ggqa
double precision gggg
double precision Hqarbvsqanal
double precision Hqaqavsqanal
double precision HAQggvsqanal
double precision Hggggvsqanal
logical CheckEGZ
common/CheckEGZ/CheckEGZ
!$omp threadprivate(/CheckEGZ/)
parameter(i5=7,i6=8)
C***************************************************
scheme='dred'
C***************************************************
if (scheme .eq. 'dred') then
deltar=0d0
elseif (scheme .eq. 'tH-V') then
deltar=1d0
else
write(6,*) 'Invalid scheme in gg_hgg_v.f'
stop
endif
c--- Set this to true to check squared matrix elements against
c--- hep-ph/0506196 using the point specified in Eq. (51)
CheckEGZ=.false.
c--- Set up spinor products
call spinoru(i6,p,za,zb)
Asq=(as/(3d0*pi))**2/vevsq
C Deal with Higgs decay to WW
s3456=s(3,4)+s(3,5)+s(3,6)+s(4,5)+s(4,6)+s(5,6)
hdecay=gwsq**3*wmass**2*s(3,5)*s(6,4)
hdecay=hdecay/(((s3456-hmass**2)**2+(hmass*hwidth)**2)
. *((s(3,4)-wmass**2)**2+(wmass*wwidth)**2)
. *((s(5,6)-wmass**2)**2+(wmass*wwidth)**2))
Asq=(as/(3d0*pi))**2/vevsq
fac=ason2pi*Asq*gsq**2*hdecay
c--- for checking EGZ
if (CheckEGZ) then
call CheckEGZres
endif
c--- for checking scheme dependence of amplitudes
c call CheckScheme(1,2,i5,i6)
C--- Note that Hqarbvsqanal(1,2,i5,i6)=Hqarbvsqanal(i6,i5,2,1)
C--- and the basic process is q(-ki6)+r(-k2)-->q(-k5)+r(-k1)
c--- FOUR-QUARK PROCESSES WITH NON-IDENTICAL QUARKS
C---quark-quark
C q(1)+r(2)->q(i5)+r(i6)
qrqr=Hqarbvsqanal(i6,2,i5,1)
C----quark-antiquark annihilation (i6-->i5-->2-->i6) wrt q(1)+r(2)->q(i5)+r(i6)
c q(1)+a(2)->r(i5)+b(i6)
qarb=Hqarbvsqanal(i5,i6,2,1)
C----antiquark-quark annihilation (1<-->2, i5<-->6) wrt to the above
c a(1)+q(2)->b(i5)+r(i6)
c aqbr=Hqarbvsqanal(i6,i5,1,2)
aqbr=qarb
C----quark-antiquark scattering (i6<-->2) wrt q(1)+r(2)->q(i5)+r(i6)
c q(1)+b(2)->r(i5)+a(i6)
qbra=Hqarbvsqanal(2,i6,i5,1)
C----antiquark-quark scattering
c b(1)+q(2)->a(i5)+r(i6) (1<-->2, i5<-->i6) wrt to the above
c bqar=Hqarbvsqanal(1,i5,i6,2)
bqar=qbra
C---antiquark-antiquark scattering (1<-->i5,2<-->i6) wrt q(1)+r(2)->q(i5)+r(i6)
C a(1)+b(2)->a(i5)+b(i6)
abab=Hqarbvsqanal(2,i6,1,i5)
C--- FOUR-QUARK PROCESSES WITH IDENTICAL QUARKS
C q(1)+q(2)->q(i5)+q(i6)
qqqq=qrqr+Hqarbvsqanal(i5,2,i6,1)+Hqaqavsqanal(i6,2,i5,1)
C a(1)+a(2)->a(i5)+a(i6) (1<-->i5,2<-->i6) wrt q(1)+q(2)->q(i5)+q(i6)
aaaa=abab+Hqarbvsqanal(2,i5,1,i6)+Hqaqavsqanal(2,i6,1,i5)
C q(1)+a(2)->q(i5)+a(i6) (2<-->i6) wrt q(1)+q(2)->q(i5)+q(i6)
qaqa=qbra+qarb+Hqaqavsqanal(2,i6,i5,1)
C a(1)+q(2)->a(i5)+q(i6) (1<-->2, i5<-->i6) wrt the above
C aqqa=qbra+qarb+Hqaqavsqanal(1,i5,i6,2)
aqaq=qaqa
c--- TWO-QUARK, TWO GLUON PROCESSES
C a(1)+q(2)->g(3)+g(4)
aqgg=+HAQggvsqanal(2,1,i5,i6)
C q(1)+g(2)->q(i5)+g(i6)
qgqg=+HAQggvsqanal(1,i5,2,i6)
C g(1)+q(2)->q(i5)+g(i6)
gqqg=+HAQggvsqanal(2,i5,1,i6)
C a(1)+g(2)->a(i5)+g(i6)
c agag=+HAQggvsqanal(i5,1,2,i6)
agag=qgqg
C g(1)+a(2)->a(i5)+g(i6)
c gaag=+HAQggvsqanal(i5,2,1,i6)
gaag=gqqg
C g(1)+g(2)->q(i5)+a(i6)
ggqa=+HAQggvsqanal(i6,i5,1,2)
C q(1)+a(2)->g(i5)+g(i6)
c qagg=+HAQggvsqanal(1,2,i5,i6)
qagg=aqgg
c--- FOUR GLUON PROCESS
gggg=+Hggggvsqanal(1,2,i5,i6)
C--- DEBUGGING OUTPUT
C write(6,*) 'qrqr',qrqr
C write(6,*) 'qarb',qarb
C write(6,*) 'aqrb',aqrb
C write(6,*) 'abab',abab
C write(6,*) 'qbra',qbra
C write(6,*) 'bqra',bqra
C write(6,*) 'Identical'
C write(6,*) 'qaqa',qaqa
C write(6,*) 'aqqa',aqqa
C write(6,*) 'qqqq',qqqq
C write(6,*) 'aaaa',aaaa
do j=-nf,nf
do k=-nf,nf
msq(j,k)=0d0
if ((j.eq.0).and.(k.eq.0)) then
C---gg - all poles cancelled
msq(j,k)=fac*avegg*(half*gggg+dfloat(nflav)*ggqa)
elseif ((j.gt.0).and.(k.gt.0)) then
C---qq - all poles cancelled
if (j.eq.k) then
msq(j,k)=aveqq*fac*half*qqqq
else
msq(j,k)=aveqq*fac*qrqr
endif
elseif ((j.lt.0).and.(k.lt.0)) then
C---aa - all poles cancelled
if (j.eq.k) then
msq(j,k)=aveqq*fac*half*aaaa
else
msq(j,k)=aveqq*fac*abab
endif
elseif ((j.gt.0).and.(k.lt.0)) then
C----qa scattering - all poles cancelled
if (j.eq.-k) then
msq(j,k)=aveqq*fac*(dfloat(nflav-1)*qarb+qaqa+half*qagg)
else
msq(j,k)=aveqq*fac*qbra
endif
elseif ((j.lt.0).and.(k.gt.0)) then
C----aq scattering - all poles cancelled
if (j.eq.-k) then
msq(j,k)=aveqq*fac*(dfloat(nflav-1)*aqbr+aqaq+half*aqgg)
else
msq(j,k)=aveqq*fac*bqar
endif
elseif ((j.eq.0).and.(k.gt.0)) then
C----gq scattering - all poles cancelled
msq(j,k)=aveqg*fac*gqqg
elseif ((j.eq.0).and.(k.lt.0)) then
C----ga scattering - all poles cancelled
msq(j,k)=aveqg*fac*gaag
elseif ((j.gt.0).and.(k.eq.0)) then
C----qg scattering - all poles cancelled
msq(j,k)=aveqg*fac*qgqg
elseif ((j.lt.0).and.(k.eq.0)) then
C----ag scattering - all poles cancelled
msq(j,k)=aveqg*fac*agag
endif
enddo
enddo
return
end
| MCFM-JHUGen/src/ggHggvirt/gg_hWWgg_v.f |
Intro What is Jalapeño Water?
On October 9, 2010 during lunch at the Oxford Circle Dining Commons Cuarto Dining Commons, there was a great discovery: The Jalapeño Cilantro Infused Water (Jalapeño Water for short). It was the most amazing beverage ever. When you drink it, it feels and tastes just like water. But once it is swallowed, you get the awesome jalapeño burn and the best part is the only thing to wash the burn down with is more jalapeño water, unless you get some other drink (but what’s the fun in that). Basically what happens is jalapeños are sliced and allowed to sit in water. During this time, the capsaicin (the chemical that gives the burn) dissolves off the seeds of the jalapeños and into the water ready to burn any tissue it comes in contact with.
The Conspiracy
Since then the Jalapeño water has yet to return to the dining commons and only lives on in the stories told by its admirers. Many comment cards have been filled out at the Oxford Circle Dining Commons Cuarto Dining Commons saying things such as Jalapeño Water! Where did it go? and What happened to the Jalapeño Water? I love that stuff,” but still no sight of any return. The comment cards mentioning the Jalapeño water also all seem to disappear and never end up on the board with responses like all the other comment cards. It was sighted on April 12, 2011 someone taking a jalapeño water comment card to the table where they respond to them, but the card was never seen again. Where do they go? The only logical explanation is that it is all part of a conspiracy to keep the students that visit the dining commons from enjoying a good beverage and keeping the food as nonspicy as possible (has anyone ever found a dish at the dining commons with the slightest bit of heat?).
Current Actions
At late night on April 12, 2011, students informed the dining common staff that they aware of the conspiracy through a comment card (which also disappeared with no response) and will continue to write the comment cards inquiring about the Jalapeño Water until a response is received and it becomes a regular beverage available multiple times a week at the dining commons.
End of the Conspiracy
On April 13, 2011 (which just happened to be the day this page was created, coincidence?) the conspiracy ended at dinner when two of the Jalapeño Water comment cards were seen with responses on the comment board, one being the one where the dining common staff was informed students knew about the conspiracy. One response explained that they rotated the flavors of infused water and that since the Jalapeño one was not very popular (why not?), it wasnt rotated in often. How about never? The second one said to prepare our palates for a new infused water with chilies and citrus. So now students wait for the new chili and citrus water and hope it is as amazing as the legendary Jalapeño Water.
Update
On April 17, 2011, the Cuarto Dining Commons unveiled the Jalapino Citrus infused water for us Jalapeño Water lovers. It was the biggest disappointment ever! Correct me if Im wrong, but Im pretty sure there is no such thing as a Jalapino (even Google corrects it to Jalapeño and its not recognized by spell check). Maybe it was a typo, but the peppers were red (the color of an over ripe Jalapeño). Worst of all, the peppers (whatever they were) were not even cut open, so the burn causing chemicals didnt dissolve into the water. This water gave no burn whatsoever. Lastly, the dispenser was going extremely slowly, so you couldnt even really get much. Nice try Cuarto DC, but this is not what we were promised when we were told to prepare our pallets. Come on DC, whats going on?
Your community wants to know
Query: was this a contamination issue? Urban legend? Salsainwater? Condiment peppers in water? Back in the day, the Tercero DC commentboard used to get requests for more hotdogs on Sundays, guaranteed canned pineapples on the salad bar, rotten produce in prepacked sandwichesa mixture of goofy and serious issues. I cant tell what this is, but it seems like management would assume its simply an inside joke.
Response to the community
This is not an inside joke and all the events described above are true and actually occurred. The dining commons intentionally put this out one day as one of their infused waters. I have a picture on my phone of the label/sign that I am working to put on the site (yes I was so excited that I took a picture).
Response from the community
Dear college students who get the pleasure of the DC,
its not that hard to make infused water.. Cucumber water is delicious, so is Jalap/Hab/others fruits/veggies water. Slice, let sit, drink! Find out how long you like to let it sit, 24 hours is good, but it will have the taste by 12. 4872+ hour cucumber water gets so deliciously cucumbery. Experiment with it and have fun
| lab/davisWiki/Jalape%C3%B1o_Water_Conspiracy.f |