text
stringlengths
12
986k
repo_path
stringlengths
6
121
SUBROUTINE loop6_F90(N, x, a, b) INTEGER i, N REAL*8 x(N), a(N), b(N) x = a*b RETURN END SUBROUTINE loop6_F90Overhead(N, x, a, b) INTEGER i, N REAL*8 x(N), a(N), b(N) RETURN END
depspawn-blitz-0.10/benchmarks/loop6f90.f90
*> \brief \b DTPQRT2 computes a QR factorization of a real or complex "triangular-pentagonal" matrix, which is composed of a triangular block and a pentagonal block, using the compact WY representation for Q. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DTPQRT2 + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtpqrt2.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtpqrt2.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtpqrt2.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DTPQRT2( M, N, L, A, LDA, B, LDB, T, LDT, INFO ) * * .. Scalar Arguments .. * INTEGER INFO, LDA, LDB, LDT, N, M, L * .. * .. Array Arguments .. * DOUBLE PRECISION A( LDA, * ), B( LDB, * ), T( LDT, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DTPQRT2 computes a QR factorization of a real "triangular-pentagonal" *> matrix C, which is composed of a triangular block A and pentagonal block B, *> using the compact WY representation for Q. *> \endverbatim * * Arguments: * ========== * *> \param[in] M *> \verbatim *> M is INTEGER *> The total number of rows of the matrix B. *> M >= 0. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of columns of the matrix B, and the order of *> the triangular matrix A. *> N >= 0. *> \endverbatim *> *> \param[in] L *> \verbatim *> L is INTEGER *> The number of rows of the upper trapezoidal part of B. *> MIN(M,N) >= L >= 0. See Further Details. *> \endverbatim *> *> \param[in,out] A *> \verbatim *> A is DOUBLE PRECISION array, dimension (LDA,N) *> On entry, the upper triangular N-by-N matrix A. *> On exit, the elements on and above the diagonal of the array *> contain the upper triangular matrix R. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. LDA >= max(1,N). *> \endverbatim *> *> \param[in,out] B *> \verbatim *> B is DOUBLE PRECISION array, dimension (LDB,N) *> On entry, the pentagonal M-by-N matrix B. The first M-L rows *> are rectangular, and the last L rows are upper trapezoidal. *> On exit, B contains the pentagonal matrix V. See Further Details. *> \endverbatim *> *> \param[in] LDB *> \verbatim *> LDB is INTEGER *> The leading dimension of the array B. LDB >= max(1,M). *> \endverbatim *> *> \param[out] T *> \verbatim *> T is DOUBLE PRECISION array, dimension (LDT,N) *> The N-by-N upper triangular factor T of the block reflector. *> See Further Details. *> \endverbatim *> *> \param[in] LDT *> \verbatim *> LDT is INTEGER *> The leading dimension of the array T. LDT >= max(1,N) *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup doubleOTHERcomputational * *> \par Further Details: * ===================== *> *> \verbatim *> *> The input matrix C is a (N+M)-by-N matrix *> *> C = [ A ] *> [ B ] *> *> where A is an upper triangular N-by-N matrix, and B is M-by-N pentagonal *> matrix consisting of a (M-L)-by-N rectangular matrix B1 on top of a L-by-N *> upper trapezoidal matrix B2: *> *> B = [ B1 ] <- (M-L)-by-N rectangular *> [ B2 ] <- L-by-N upper trapezoidal. *> *> The upper trapezoidal matrix B2 consists of the first L rows of a *> N-by-N upper triangular matrix, where 0 <= L <= MIN(M,N). If L=0, *> B is rectangular M-by-N; if M=L=N, B is upper triangular. *> *> The matrix W stores the elementary reflectors H(i) in the i-th column *> below the diagonal (of A) in the (N+M)-by-N input matrix C *> *> C = [ A ] <- upper triangular N-by-N *> [ B ] <- M-by-N pentagonal *> *> so that W can be represented as *> *> W = [ I ] <- identity, N-by-N *> [ V ] <- M-by-N, same form as B. *> *> Thus, all of information needed for W is contained on exit in B, which *> we call V above. Note that V has the same form as B; that is, *> *> V = [ V1 ] <- (M-L)-by-N rectangular *> [ V2 ] <- L-by-N upper trapezoidal. *> *> The columns of V represent the vectors which define the H(i)'s. *> The (M+N)-by-(M+N) block reflector H is then given by *> *> H = I - W * T * W**T *> *> where W^H is the conjugate transpose of W and T is the upper triangular *> factor of the block reflector. *> \endverbatim *> * ===================================================================== SUBROUTINE DTPQRT2( M, N, L, A, LDA, B, LDB, T, LDT, INFO ) * * -- LAPACK computational routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. INTEGER INFO, LDA, LDB, LDT, N, M, L * .. * .. Array Arguments .. DOUBLE PRECISION A( LDA, * ), B( LDB, * ), T( LDT, * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ONE, ZERO PARAMETER( ONE = 1.0, ZERO = 0.0 ) * .. * .. Local Scalars .. INTEGER I, J, P, MP, NP DOUBLE PRECISION ALPHA * .. * .. External Subroutines .. EXTERNAL DLARFG, DGEMV, DGER, DTRMV, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. * .. Executable Statements .. * * Test the input arguments * INFO = 0 IF( M.LT.0 ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( L.LT.0 .OR. L.GT.MIN(M,N) ) THEN INFO = -3 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN INFO = -5 ELSE IF( LDB.LT.MAX( 1, M ) ) THEN INFO = -7 ELSE IF( LDT.LT.MAX( 1, N ) ) THEN INFO = -9 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'DTPQRT2', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 .OR. M.EQ.0 ) RETURN * DO I = 1, N * * Generate elementary reflector H(I) to annihilate B(:,I) * P = M-L+MIN( L, I ) CALL DLARFG( P+1, A( I, I ), B( 1, I ), 1, T( I, 1 ) ) IF( I.LT.N ) THEN * * W(1:N-I) := C(I:M,I+1:N)^H * C(I:M,I) [use W = T(:,N)] * DO J = 1, N-I T( J, N ) = (A( I, I+J )) END DO CALL DGEMV( 'T', P, N-I, ONE, B( 1, I+1 ), LDB, $ B( 1, I ), 1, ONE, T( 1, N ), 1 ) * * C(I:M,I+1:N) = C(I:m,I+1:N) + alpha*C(I:M,I)*W(1:N-1)^H * ALPHA = -(T( I, 1 )) DO J = 1, N-I A( I, I+J ) = A( I, I+J ) + ALPHA*(T( J, N )) END DO CALL DGER( P, N-I, ALPHA, B( 1, I ), 1, $ T( 1, N ), 1, B( 1, I+1 ), LDB ) END IF END DO * DO I = 2, N * * T(1:I-1,I) := C(I:M,1:I-1)^H * (alpha * C(I:M,I)) * ALPHA = -T( I, 1 ) DO J = 1, I-1 T( J, I ) = ZERO END DO P = MIN( I-1, L ) MP = MIN( M-L+1, M ) NP = MIN( P+1, N ) * * Triangular part of B2 * DO J = 1, P T( J, I ) = ALPHA*B( M-L+J, I ) END DO CALL DTRMV( 'U', 'T', 'N', P, B( MP, 1 ), LDB, $ T( 1, I ), 1 ) * * Rectangular part of B2 * CALL DGEMV( 'T', L, I-1-P, ALPHA, B( MP, NP ), LDB, $ B( MP, I ), 1, ZERO, T( NP, I ), 1 ) * * B1 * CALL DGEMV( 'T', M-L, I-1, ALPHA, B, LDB, B( 1, I ), 1, $ ONE, T( 1, I ), 1 ) * * T(1:I-1,I) := T(1:I-1,1:I-1) * T(1:I-1,I) * CALL DTRMV( 'U', 'N', 'N', I-1, T, LDT, T( 1, I ), 1 ) * * T(I,I) = tau(I) * T( I, I ) = T( I, 1 ) T( I, 1 ) = ZERO END DO * * End of DTPQRT2 * END
netlib/LAPACK/dtpqrt2.f
! ! -- MAGMA (version 1.6.1) -- ! Univ. of Tennessee, Knoxville ! Univ. of California, Berkeley ! Univ. of Colorado, Denver ! @date January 2015 ! ! @precisions normal z -> c d s ! #define PRECISION_z module magma_zfortran use magma_param, only: sizeof_complex_16 implicit none !---- Fortran interfaces to MAGMA subroutines ---- interface subroutine magmaf_zgetptr( m, n, A, lda, d, e,tauq, taup, work, lwork, info) integer :: m integer :: n complex*16 :: A(*) integer :: lda double precision:: d(*) double precision:: e(*) complex*16 :: tauq(*) complex*16 :: taup(*) complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zgetptr subroutine magmaf_zgebrd( m, n, A, lda, d, e,tauq, taup, work, lwork, info) integer :: m integer :: n complex*16 :: A(*) integer :: lda double precision:: d(*) double precision:: e(*) complex*16 :: tauq(*) complex*16 :: taup(*) complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zgebrd subroutine magmaf_zgehrd2(n, ilo, ihi,A, lda, tau, work, lwork, info) integer :: n integer :: ilo integer :: ihi complex*16 :: A(*) integer :: lda complex*16 :: tau(*) complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zgehrd2 subroutine magmaf_zgehrd(n, ilo, ihi,A, lda, tau, work, lwork, d_T, info) integer :: n integer :: ilo integer :: ihi complex*16 :: A(*) integer :: lda complex*16 :: tau(*) complex*16 :: work(*) integer :: lwork complex*16 :: d_T(*) integer :: info end subroutine magmaf_zgehrd subroutine magmaf_zgelqf( m, n, A, lda, tau, work, lwork, info) integer :: m integer :: n complex*16 :: A(*) integer :: lda complex*16 :: tau(*) complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zgelqf subroutine magmaf_zgeqlf( m, n, A, lda, tau, work, lwork, info) integer :: m integer :: n complex*16 :: A(*) integer :: lda complex*16 :: tau(*) complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zgeqlf subroutine magmaf_zgeqrf( m, n, A, lda, tau, work, lwork, info) integer :: m integer :: n complex*16 :: A(*) integer :: lda complex*16 :: tau(*) complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zgeqrf subroutine magmaf_zgesv( n, nrhs, A, lda, ipiv, B, ldb, info) integer :: n integer :: nrhs complex*16 :: A integer :: lda integer :: ipiv(*) complex*16 :: B integer :: ldb integer :: info end subroutine magmaf_zgesv subroutine magmaf_zgetrf( m, n, A, lda, ipiv, info) integer :: m integer :: n complex*16 :: A(*) integer :: lda integer :: ipiv(*) integer :: info end subroutine magmaf_zgetrf subroutine magmaf_zposv( uplo, n, nrhs, dA, ldda, dB, lddb, info) character :: uplo integer :: n integer :: nrhs magma_devptr_t:: dA integer :: ldda magma_devptr_t:: dB integer :: lddb integer :: info end subroutine magmaf_zposv subroutine magmaf_zpotrf( uplo, n, A, lda, info) character :: uplo integer :: n complex*16 :: A(*) integer :: lda integer :: info end subroutine magmaf_zpotrf subroutine magmaf_zhetrd( uplo, n, A, lda, d, e, tau, work, lwork, info) character :: uplo integer :: n complex*16 :: A(*) integer :: lda double precision:: d(*) double precision:: e(*) complex*16 :: tau(*) complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zhetrd subroutine magmaf_zunmqr( side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info) character :: side character :: trans integer :: m integer :: n integer :: k complex*16 :: a(*) integer :: lda complex*16 :: tau(*) complex*16 :: c(*) integer :: ldc complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zunmqr subroutine magmaf_zunmtr( side, uplo, trans, m, n, a, lda,tau,c, ldc,work, lwork,info) character :: side character :: uplo character :: trans integer :: m integer :: n complex*16 :: a(*) integer :: lda complex*16 :: tau(*) complex*16 :: c(*) integer :: ldc complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zunmtr #if defined(PRECISION_z) || defined(PRECISION_c) subroutine magmaf_zgeev( jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info) character :: jobvl character :: jobvr integer :: n complex*16 :: a(*) integer :: lda complex*16 :: w(*) complex*16 :: vl(*) integer :: ldvl complex*16 :: vr(*) integer :: ldvr complex*16 :: work(*) integer :: lwork double precision:: rwork(*) integer :: info end subroutine magmaf_zgeev subroutine magmaf_zgesvd( jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, rwork, info) character :: jobu character :: jobvt integer :: m integer :: n complex*16 :: a(*) integer :: lda double precision:: s(*) complex*16 :: u(*) integer :: ldu complex*16 :: vt(*) integer :: ldvt complex*16 :: work(*) integer :: lwork double precision:: rwork(*) integer :: info end subroutine magmaf_zgesvd subroutine magmaf_zheevd( jobz, uplo, n, a, lda, w, work, lwork, rwork, lrwork, iwork, liwork, info) character :: jobz character :: uplo integer :: n complex*16 :: a(*) integer :: lda double precision:: w(*) complex*16 :: work(*) integer :: lwork double precision:: rwork(*) integer :: lrwork integer :: iwork(*) integer :: liwork integer :: info end subroutine magmaf_zheevd subroutine magmaf_zhegvd( itype, jobz, uplo, n, a, lda, b, ldb, w, work, lwork, rwork, lrwork, iwork, liwork, info) integer :: itype character :: jobz character :: uplo integer :: n complex*16 :: a(*) integer :: lda complex*16 :: b(*) integer :: ldb double precision:: w(*) complex*16 :: work(*) integer :: lwork double precision:: rwork(*) integer :: lrwork integer :: iwork(*) integer :: liwork integer :: info end subroutine magmaf_zhegvd #else subroutine magmaf_zgeev( jobvl, jobvr, n, a, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info) character :: jobvl character :: jobvr integer :: n complex*16 :: a(*) integer :: lda complex*16 :: wr(*) complex*16 :: wi(*) complex*16 :: vl(*) integer :: ldvl complex*16 :: vr(*) integer :: ldvr complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zgeev subroutine magmaf_zgesvd( jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, info) character :: jobu character :: jobvt integer :: m integer :: n complex*16 :: a(*) integer :: lda double precision:: s(*) complex*16 :: u(*) integer :: ldu complex*16 :: vt(*) integer :: ldvt complex*16 :: work(*) integer :: lwork integer :: info end subroutine magmaf_zgesvd subroutine magmaf_zheevd( jobz, uplo, n, a, lda, w, work, lwork, iwork, liwork, info) character :: jobz character :: uplo integer :: n complex*16 :: a(*) integer :: lda double precision:: w(*) complex*16 :: work(*) integer :: lwork integer :: iwork(*) integer :: liwork integer :: info end subroutine magmaf_zheevd subroutine magmaf_zhegvd( itype, jobz, uplo, n, a, lda, b, ldb, w, work, lwork, iwork, liwork, info) integer :: itype character :: jobz character :: uplo integer :: n complex*16 :: a(*) integer :: lda complex*16 :: b(*) integer :: ldb double precision:: w(*) complex*16 :: work(*) integer :: lwork integer :: iwork(*) integer :: liwork integer :: info end subroutine magmaf_zhegvd #endif subroutine magmaf_zgels_gpu( trans, m, n, nrhs, dA, ldda, dB, lddb, hwork, lwork, info) character :: trans integer :: m integer :: n integer :: nrhs magma_devptr_t:: dA integer :: ldda magma_devptr_t:: dB integer :: lddb complex*16 :: hwork(*) integer :: lwork integer :: info end subroutine magmaf_zgels_gpu subroutine magmaf_zgeqrf_gpu( m, n, dA, ldda, tau, dT, info) integer :: m integer :: n magma_devptr_t:: dA integer :: ldda complex*16 :: tau(*) magma_devptr_t:: dT integer :: info end subroutine magmaf_zgeqrf_gpu subroutine magmaf_zgeqrf2_gpu(m, n, dA, ldda, tau, info) integer :: m integer :: n magma_devptr_t:: dA integer :: ldda complex*16 :: tau(*) integer :: info end subroutine magmaf_zgeqrf2_gpu subroutine magmaf_zgeqrf3_gpu(m, n, dA, ldda, tau, dT, info) integer :: m integer :: n magma_devptr_t:: dA integer :: ldda complex*16 :: tau(*) magma_devptr_t:: dT integer :: info end subroutine magmaf_zgeqrf3_gpu subroutine magmaf_zgeqrs_gpu( m, n, nrhs, dA, ldda, tau, dT, dB, lddb, hwork, lhwork, info) integer :: m integer :: n integer :: nrhs magma_devptr_t:: dA integer :: ldda complex*16 :: tau magma_devptr_t:: dT magma_devptr_t:: dB integer :: lddb complex*16 :: hwork(*) integer :: lhwork integer :: info end subroutine magmaf_zgeqrs_gpu subroutine magmaf_zgeqrs3_gpu( m, n, nrhs, dA, ldda, tau, dT, dB, lddb, hwork, lhwork, info) integer :: m integer :: n integer :: nrhs magma_devptr_t:: dA integer :: ldda complex*16 :: tau magma_devptr_t:: dT magma_devptr_t:: dB integer :: lddb complex*16 :: hwork(*) integer :: lhwork integer :: info end subroutine magmaf_zgeqrs3_gpu subroutine magmaf_zgessm_gpu( storev, m, n, k, ib, ipiv, dL1, lddl1, dL, lddl, dA, ldda, info) character :: storev integer :: m integer :: n integer :: k integer :: ib integer :: ipiv(*) magma_devptr_t:: dL1 integer :: lddl1 magma_devptr_t:: dL integer :: lddl magma_devptr_t:: dA integer :: ldda integer :: info end subroutine magmaf_zgessm_gpu subroutine magmaf_zgesv_gpu( n, nrhs, dA, ldda, ipiv, dB, lddb, info) integer :: n integer :: nrhs magma_devptr_t:: dA integer :: ldda integer :: ipiv(*) magma_devptr_t:: dB integer :: lddb integer :: info end subroutine magmaf_zgesv_gpu subroutine magmaf_zgetrf_gpu( m, n, dA, ldda, ipiv, info) integer :: m integer :: n magma_devptr_t:: dA integer :: ldda integer :: ipiv(*) integer :: info end subroutine magmaf_zgetrf_gpu subroutine magmaf_zgetrs_gpu( trans, n, nrhs, dA, ldda, ipiv, dB, lddb, info) character :: trans integer :: n integer :: nrhs magma_devptr_t:: dA integer :: ldda integer :: ipiv(*) magma_devptr_t:: dB integer :: lddb integer :: info end subroutine magmaf_zgetrs_gpu subroutine magmaf_zlabrd_gpu( m, n, nb, a, lda, da, ldda, d, e, tauq, taup, x, ldx, dx, lddx, y, ldy, dy, lddy) integer :: m integer :: n integer :: nb complex*16 :: a(*) integer :: lda magma_devptr_t:: da integer :: ldda double precision:: d(*) double precision:: e(*) complex*16 :: tauq(*) complex*16 :: taup(*) complex*16 :: x(*) integer :: ldx magma_devptr_t:: dx integer :: lddx complex*16 :: y(*) integer :: ldy magma_devptr_t:: dy integer :: lddy end subroutine magmaf_zlabrd_gpu subroutine magmaf_zlarfb_gpu( side, trans, direct, storev, m, n, k, dv, ldv, dt, ldt, dc, ldc, dowrk, ldwork) character :: side character :: trans character :: direct character :: storev integer :: m integer :: n integer :: k magma_devptr_t:: dv integer :: ldv magma_devptr_t:: dt integer :: ldt magma_devptr_t:: dc integer :: ldc magma_devptr_t:: dowrk integer :: ldwork end subroutine magmaf_zlarfb_gpu subroutine magmaf_zposv_gpu( uplo, n, nrhs, dA, ldda, dB, lddb, info) character :: uplo integer :: n integer :: nrhs magma_devptr_t:: dA integer :: ldda magma_devptr_t:: dB integer :: lddb integer :: info end subroutine magmaf_zposv_gpu subroutine magmaf_zpotrf_gpu( uplo, n, dA, ldda, info) character :: uplo integer :: n magma_devptr_t:: dA integer :: ldda integer :: info end subroutine magmaf_zpotrf_gpu subroutine magmaf_zpotrs_gpu( uplo, n, nrhs, dA, ldda, dB, lddb, info) character :: uplo integer :: n integer :: nrhs magma_devptr_t:: dA integer :: ldda magma_devptr_t:: dB integer :: lddb integer :: info end subroutine magmaf_zpotrs_gpu subroutine magmaf_zssssm_gpu( storev, m1, n1, m2, n2, k, ib, dA1, ldda1, dA2, ldda2, dL1, lddl1, dL2, lddl2, IPIV, info) character :: storev integer :: m1 integer :: n1 integer :: m2 integer :: n2 integer :: k integer :: ib magma_devptr_t:: dA1 integer :: ldda1 magma_devptr_t:: dA2 integer :: ldda2 magma_devptr_t:: dL1 integer :: lddl1 magma_devptr_t:: dL2 integer :: lddl2 integer :: IPIV(*) integer :: info end subroutine magmaf_zssssm_gpu subroutine magmaf_zungqr_gpu( m, n, k, da, ldda, tau, dwork, nb, info) integer :: m integer :: n integer :: k magma_devptr_t:: da integer :: ldda complex*16 :: tau(*) magma_devptr_t:: dwork integer :: nb integer :: info end subroutine magmaf_zungqr_gpu subroutine magmaf_zunmqr_gpu( side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, td, nb, info) character :: side character :: trans integer :: m integer :: n integer :: k magma_devptr_t:: a integer :: lda complex*16 :: tau(*) magma_devptr_t:: c integer :: ldc magma_devptr_t:: work integer :: lwork magma_devptr_t:: td integer :: nb integer :: info end subroutine magmaf_zunmqr_gpu end interface contains subroutine magmaf_zoff1d( ptrNew, ptrOld, inc, i) magma_devptr_t :: ptrNew magma_devptr_t :: ptrOld integer :: inc, i ptrNew = ptrOld + (i-1) * inc * sizeof_complex_16 end subroutine magmaf_zoff1d subroutine magmaf_zoff2d( ptrNew, ptrOld, lda, i, j) magma_devptr_t :: ptrNew magma_devptr_t :: ptrOld integer :: lda, i, j ptrNew = ptrOld + ((j-1) * lda + (i-1)) * sizeof_complex_16 end subroutine magmaf_zoff2d end module magma_zfortran
exp/control/magma_zfortran.f90
!======================================================================! SUBROUTINE CalBou() ! Extrapoloate variables on the boundaries where needed [OBSOLETE] ! ! completely substitutes with CalcDens END SUBROUTINE CalBou
Process/CalBou.f90
! ! -------------------------------------------------------------- ! R E C O U P L S 3 1 ! -------------------------------------------------------------- ! * ! Written by G. Gaigalas, * ! Vanderbilt University, Nashville February 1994 * ! SUBROUTINE RECOUPLS31(K, JA1, JA2, JA3, K1, K2, KA, IRE, IAT, REC) !----------------------------------------------- ! M o d u l e s !----------------------------------------------- USE vast_kind_param, ONLY: DOUBLE USE CONSTS_C USE MEDEFN_C !...Translated by Pacific-Sierra Research 77to90 4.3E 11:00:59 11/16/01 !...Switches: !----------------------------------------------- ! I n t e r f a c e B l o c k s !----------------------------------------------- USE dlsa3_I USE dlsa2_I USE dlsa4_I USE dlsa1_I IMPLICIT NONE !----------------------------------------------- ! D u m m y A r g u m e n t s !----------------------------------------------- INTEGER :: K INTEGER :: JA1 INTEGER :: JA2 INTEGER :: JA3 INTEGER :: K1 INTEGER :: K2 INTEGER :: KA INTEGER :: IRE INTEGER :: IAT REAL(DOUBLE) , INTENT(OUT) :: REC !----------------------------------------------- ! L o c a l V a r i a b l e s !----------------------------------------------- INTEGER :: IA3, IB3, ISKR REAL(DOUBLE) :: S1, S2, S3, RE !----------------------------------------------- S1 = DBLE(J1QN1(JA1,K)) S2 = DBLE(J1QN1(JA2,K)) S3 = DBLE(J1QN1(JA3,K)) REC = ONE/DSQRT(S1*S2*S3) IA3 = J1QN1(JA3,K) - 1 IB3 = J1QN2(JA3,K) - 1 REC = REC*DSQRT(DBLE(IA3 + 1))/DSQRT(DBLE((KA + 1)*(IB3 + 1))) ! IAT = 0 ISKR = JA3 - JA2 IF (ISKR > 1) THEN CALL DLSA3 (K, JA2, JA3, KA, IRE, IAT, RE) IF (IAT == 0) RETURN REC = RE*REC ENDIF IAT = 0 CALL DLSA2 (K, JA1, JA3, KA, IRE, IAT, RE) IF (IAT == 0) RETURN REC = RE*REC IAT = 0 CALL DLSA4 (K, JA1, JA2, K1, K2, KA, IRE, IAT, RE) IF (IAT == 0) RETURN REC = RE*REC IF (JA1==1 .AND. JA2==2) RETURN IAT = 0 CALL DLSA1 (K, JA1, K1, IRE, IAT, RE) IF (IAT == 0) RETURN REC = RE*REC ISKR = JA2 - JA1 IF (JA1 == 1) ISKR = JA2 - 1 - JA1 IF (ISKR <= 1) RETURN IAT = 0 CALL DLSA3 (K, JA1, JA2, K1, IRE, IAT, RE) REC = RE*REC RETURN END SUBROUTINE RECOUPLS31
src90/lib/libang90/recoupls31.f90
program jsonff_test use jsonff use iso_fortran_env, only: int64,real64 implicit none type(fallible_json_value_t) :: parsed_json integer(int64) :: start, finish, count_rate call system_clock(start, count_rate) parsed_json = parse_json_from_file('canada.json') call system_clock(finish) write(*,'(A30,1X,F7.4,1X,A)') 'jsonff : ', (finish-start)/real(count_rate,real64), ' seconds' if (parsed_json%failed()) error stop 'error parsing JSON file' end program jsonff_test
app/jsonff_test.f90
C Copyright(C) 2009-2017 National Technology & Engineering Solutions of C 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 Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C======================================================================= SUBROUTINE MSFLAG (ANYDEF, ANYUND, & DOIXF, DON2B, DOELED, DOELEU, DODEAD, DONPS, DOESS, DOSCAL, & MINMSH, MAXMSH, MAXHID) C======================================================================= C --*** MSFLAG *** (MESH) Set mesh plot flags C -- Written by Amy Gilkey - revised 05/31/88 C -- C --MSFLAG sets the flags needed to plot a mesh. C -- C --Parameters: C -- ANYDEF - OUT - true iff any deformed mesh is to be plotted C -- ANYUND - OUT - true iff any undeformed mesh is to be plotted C -- DOIXF - OUT - true iff the IXFAC array is needed C -- DON2B - OUT - true iff the IN2ELB array is needed C -- DOELED - OUT - true iff the deformed element quarilateral centers C -- are needed C -- DOELEU - OUT - true iff the undeformed element quarilateral centers C -- are needed C -- DODEAD - OUT - true iff dead nodes are needed C -- DONPS - OUT - true iff node set information is needed C -- DOESS - OUT - true iff side set information is needed C -- DOSCAL - OUT - true iff the zoom window limits need to be calculated C -- MINMSH, MAXMSH - OUT - the minimum and maximum mesh line types C -- to be displayed C -- MAXHID - OUT - the maximum hidden line option C -- C --Common Variables: C -- Uses IS3DIM of /D3NUMS/ C -- Uses DFAC of /DEFORM/ C -- Uses MSHDEF, MSHNUM, MSHLIN, IHIDOP, NALVAR, DEADNP of /MSHOPT/ C -- Uses MSCTYP of /MSHLIM/ PARAMETER (MSHNON=0, MSHBOR=1, MSHDIV=2, MSHSEL=3, MSHALL=4) PARAMETER (KLFT=1, KRGT=2, KBOT=3, KTOP=4, KNEA=5, KFAR=6) include 'dbnums.blk' COMMON /D3NUMS/ IS3DIM, NNPSUR, NUMNPF, LLNSET LOGICAL IS3DIM COMMON /DEFORM/ DEFPRO, DEFOK, DEFFAC, DDFAC, DFAC, & IXDEF, IYDEF, IZDEF LOGICAL DEFPRO, DEFOK include 'mshopt.blk' COMMON /MSHLIM/ UNMESH(KFAR), ALMESH(KFAR), & ZMMESH(KTOP), RDMESH(KTOP), TICMSH, SQMESH LOGICAL SQMESH COMMON /MSHLIC/ MSCTYP CHARACTER*8 MSCTYP LOGICAL ANYDEF, ANYUND LOGICAL DOIXF, DON2B, DOELED, DOELEU, DODEAD, DONPS, DOESS, DOSCAL INTEGER NUMMOD, NDEFVW, IXVW C --Set up calculation flags ANYDEF = (NUMMOD (MSHDEF, ' ', 'DEFORM', ' ') .GE. 1) ANYUND = (NUMMOD (MSHDEF, ' ', 'UNDEFORM', ' ') .GE. 1) IF (DFAC .EQ. 0.0) THEN ANYUND = .TRUE. ANYDEF = .FALSE. END IF DOIXF = .FALSE. DON2B = (NUMMOD (MSHDEF, MSHNUM, 'DEFORM', 'NODE') .GE. 1) & .OR. (NUMMOD (MSHDEF, MSHNUM, 'DEFORM', 'ALL') .GE. 1) & .OR. (NUMMOD (MSHDEF, MSHNUM, 'UNDEFORM', 'NODE') .GE. 1) & .OR. (NUMMOD (MSHDEF, MSHNUM, 'UNDEFORM', 'ALL') .GE. 1) DOELED = (NUMMOD (MSHDEF, MSHNUM, 'DEFORM', 'ELEMENT') .GE. 1) & .OR. (NUMMOD (MSHDEF, MSHNUM, 'DEFORM', 'ALL') .GE. 1) DOELEU = (NUMMOD (MSHDEF, MSHNUM, 'UNDEFORM', 'ELEMENT') .GE. 1) & .OR. (NUMMOD (MSHDEF, MSHNUM, 'UNDEFORM', 'ALL') .GE. 1) IF (.NOT. ANYDEF) THEN IF (DOELED) DOELEU = .TRUE. DOELED = .FALSE. END IF DODEAD = (NALVAR .GT. 0) .AND. DEADNP DONPS = .FALSE. DOESS = .FALSE. DO 100 IVW = 1, NDEFVW (.FALSE.) IVIEW = IXVW (.FALSE., IVW) DONPS = DONPS .OR. (NNPSET(IVIEW) .GT. 0) DOESS = DOESS .OR. (NESSET(IVIEW) .GT. 0) 100 CONTINUE DOSCAL = (MSCTYP .EQ. 'EACH') IF (IS3DIM) THEN MAXHID = IHIDOP MINMSH = 999 MAXMSH = 0 DO 110 IVW = 1, NDEFVW (.FALSE.) IVIEW = IXVW (.FALSE., IVW) MINMSH = MIN (MINMSH, MSHLIN(IVIEW)) MAXMSH = MAX (MAXMSH, MSHLIN(IVIEW)) 110 CONTINUE END IF RETURN END
packages/seacas/applications/blot/msflag.f
program test_moment use stdlib_experimental_error, only: check use stdlib_experimental_kinds, only: sp, dp, int32, int64 use stdlib_experimental_stats, only: moment use,intrinsic :: ieee_arithmetic, only : ieee_is_nan implicit none real(sp), parameter :: sptol = 1000 * epsilon(1._sp) real(dp), parameter :: dptol = 1000 * epsilon(1._dp) real(dp) :: d1(5) = [1.0_dp, 2.0_dp, 3.0_dp, 4.0_dp, 5.0_dp] real(dp) :: d(4, 3) = reshape([1._dp, 3._dp, 5._dp, 7._dp,& 2._dp, 4._dp, 6._dp, 8._dp,& 9._dp, 10._dp, 11._dp, 12._dp], [4, 3]) complex(sp) :: cs1(5) = [ cmplx(0.57706_sp, 0.00000_sp),& cmplx(0.00000_sp, 1.44065_sp),& cmplx(1.26401_sp, 0.00000_sp),& cmplx(0.00000_sp, 0.88833_sp),& cmplx(1.14352_sp, 0.00000_sp)] complex(sp) :: cs(5,3) call test_sp(real(d1,sp), real(d,sp)) call test_dp(d1, d) call test_int32(int(d1, int32), int(d, int32)) call test_int64(int(d1, int64), int(d, int64)) cs(:,1) = cs1 cs(:,2) = cs1*3_sp cs(:,3) = cs1*1.5_sp call test_csp(cs1, cs) contains subroutine test_sp(x1, x2) real(sp), intent(in) :: x1(:), x2(:, :) integer :: order real(sp), allocatable :: x3(:, :, :) order = 1 !1dim print*,' test_sp_1dim', order call check( abs(moment(x1, order)) < sptol) call check( abs(moment(x1, order, dim=1)) < sptol) print*,' test_sp_1dim_mask', order call check( ieee_is_nan(moment(x1, order, mask = .false.))) call check( ieee_is_nan(moment(x1, order, 1, mask = .false.))) print*,' test_sp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (x1 < 5))) < sptol) call check( abs(moment(x1, order, 1, mask = (x1 < 5))) < sptol) !2dim print*,' test_sp_2dim', order call check( abs(moment(x2, order)) < sptol) call check( all( abs( moment(x2, order, 1)) < sptol)) call check( all( abs( moment(x2, order, 2)) < sptol)) print*,' test_sp_2dim_mask', order call check( ieee_is_nan(moment(x2, order, mask = .false.))) call check( any(ieee_is_nan(moment(x2, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x2, order, 2, mask = .false.)))) print*,' test_sp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (x2 < 11))) < sptol) call check( all( abs( moment(x2, order, 1, mask = (x2 < 11))) < sptol)) call check( all( abs( moment(x2, order, 2, mask = (x2 < 11))) < sptol)) !3dim allocate(x3(size(x2,1),size(x2,2),3)) x3(:,:,1)=x2; x3(:,:,2)=x2*2; x3(:,:,3)=x2*4; print*,' test_sp_3dim', order call check( abs(moment(x3, order)) < sptol) call check( all( abs( moment(x3, order, 1)) < sptol)) call check( all( abs( moment(x3, order, 2)) < sptol)) call check( all( abs( moment(x3, order, 3)) < sptol)) print*,' test_sp_3dim_mask', order call check( ieee_is_nan(moment(x3, order, mask = .false.))) call check( any(ieee_is_nan(moment(x3, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 2, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 3, mask = .false.)))) print*,' test_sp_3dim_mask_array', order call check( abs(moment(x3, order, mask = (x3 < 11)) ) < sptol) call check( all( abs( moment(x3, order, 1, mask = (x3 < 45))) < sptol )) call check( all( abs( moment(x3, order, 2, mask = (x3 < 45))) < sptol )) call check( all( abs( moment(x3, order, 3, mask = (x3 < 45))) < sptol )) order = 2 !1dim print*,' test_sp_1dim', order call check( abs(moment(x1, order) - 2._sp) < sptol) call check( abs(moment(x1, order, dim=1) - 2._sp) < sptol) print*,' test_sp_1dim_mask', order call check( ieee_is_nan(moment(x1, order, mask = .false.))) call check( ieee_is_nan(moment(x1, order, 1, mask = .false.))) print*,' test_sp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (x1 < 5)) - 1.25_sp) < sptol) call check( abs(moment(x1, order, 1, mask = (x1 < 5)) - 1.25_sp) < sptol) !2dim print*,' test_sp_2dim', order call check( abs(moment(x2, order) - 107.25_sp/9.) < sptol) call check( all( abs( moment(x2, order, 1) - [5._sp, 5._sp, 1.25_sp]) < sptol)) call check( all( abs( moment(x2, order, 2) -& [19.0, 43. / 3., 31. / 3. , 7.0]*2./3.) < sptol)) print*,' test_sp_2dim_mask', order call check( ieee_is_nan(moment(x2, order, mask = .false.))) call check( any(ieee_is_nan(moment(x2, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x2, order, 2, mask = .false.)))) print*,' test_sp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (x2 < 11))- 2.75_sp*3.) < sptol) call check( all( abs( moment(x2, order, 1, mask = (x2 < 11)) -& [5._sp, 5._sp, 0.25_sp]) < sptol)) call check( all( abs( moment(x2, order, 2, mask = (x2 < 11)) -& [19._sp*2./3., 43._sp/9.*2., 0.25_sp , 0.25_sp]) < sptol)) !3dim print*,' test_sp_3dim', order call check( abs(moment(x3, order) - 153.4_sp*35./36.) < sptol) call check( all( abs( moment(x3, order, 1) -& reshape([20._sp / 3., 20._sp / 3., 5._sp / 3.,& 4* 20._sp / 3., 4* 20._sp / 3., 4* 5._sp / 3.,& 16* 20._sp / 3., 16* 20._sp / 3., 16* 5._sp / 3.],& [size(x3,2), size(x3,3)])*3._sp/4.)& < sptol)) call check( all( abs( moment(x3, order, 2) -& reshape([19._sp, 43._sp / 3., 31._sp / 3. , 7.0_sp,& 4* 19.0_sp, 4* 43._sp / 3., 4* 31._sp / 3. , 4* 7.0_sp,& 16* 19.0_sp, 16* 43._sp / 3., 16* 31._sp / 3. , 16* 7.0_sp],& [size(x3,1), size(x3,3)] )*2._sp/3.)& < sptol)) call check( all( abs( moment(x3, order, 3) -& reshape([ 7._sp/3., 21._sp, 175._sp/3.,& 343._sp/3., 28._sp/3., 112._sp/3.,& 84._sp, 448._sp/3., 189._sp,& 700._sp/3., 847._sp/3., 336._sp],& [size(x3,1), size(x3,2)] )*2./3.)& < sptol)) print*,' test_sp_3dim_mask', order call check( ieee_is_nan(moment(x3, order, mask = .false.))) call check( any(ieee_is_nan(moment(x3, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 2, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 3, mask = .false.)))) print*,' test_sp_3dim_mask_array', order call check( abs(moment(x3, order, mask = (x3 < 11)) -& 7.7370242214532876_dp ) < sptol) call check( all( abs( moment(x3, order, 1, mask = (x3 < 45)) -& reshape([5._sp, 5._sp, 1.25_sp, 20._sp, 20._sp, 5._sp,& 80._sp, 80._sp, 32._sp/3.],& [size(x3, 2), size(x3, 3)])) < sptol )) call check( all( abs( moment(x3, order, 2, mask = (x3 < 45)) -& reshape([ 38._sp/3., 86._sp/9., 62._sp/9., 14._sp/3., 152._sp/3.,& 344._sp/9., 248._sp/9., 168._sp/9., 1824._sp/9.,& 1376._sp/9., 992._sp/9., 4._sp& ],& [size(x3, 1), size(x3, 3)])) < sptol )) call check( all( abs( moment(x3, order, 3, mask = (x3 < 45)) -& reshape([14._sp/9., 14._sp, 350._sp/9., 686._sp/9., 56._sp/9.,& 224._sp/9., 56._sp, 896._sp/9., 126._sp, 1400._sp/9.,& 1694._sp/9., 36._sp& ], [size(x3,1), size(x3,2)] ))& < sptol )) end subroutine subroutine test_dp(x1, x2) real(dp), intent(in) :: x1(:), x2(:, :) integer :: order real(dp), allocatable :: x3(:, :, :) order = 1 !1dim print*,' test_dp_1dim', order call check( abs(moment(x1, order)) < dptol) call check( abs(moment(x1, order, dim=1)) < dptol) print*,' test_dp_1dim_mask', order call check( ieee_is_nan(moment(x1, order, mask = .false.))) call check( ieee_is_nan(moment(x1, order, 1, mask = .false.))) print*,' test_dp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (x1 < 5))) < dptol) call check( abs(moment(x1, order, 1, mask = (x1 < 5))) < dptol) !2dim print*,' test_dp_2dim', order call check( abs(moment(x2, order)) < dptol) call check( all( abs( moment(x2, order, 1)) < dptol)) call check( all( abs( moment(x2, order, 2)) < dptol)) print*,' test_dp_2dim_mask', order call check( ieee_is_nan(moment(x2, order, mask = .false.))) call check( any(ieee_is_nan(moment(x2, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x2, order, 2, mask = .false.)))) print*,' test_dp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (x2 < 11))) < dptol) call check( all( abs( moment(x2, order, 1, mask = (x2 < 11))) < dptol)) call check( all( abs( moment(x2, order, 2, mask = (x2 < 11))) < dptol)) !3dim allocate(x3(size(x2,1),size(x2,2),3)) x3(:,:,1)=x2; x3(:,:,2)=x2*2; x3(:,:,3)=x2*4; print*,' test_dp_3dim', order call check( abs(moment(x3, order)) < dptol) call check( all( abs( moment(x3, order, 1)) < dptol)) call check( all( abs( moment(x3, order, 2)) < dptol)) call check( all( abs( moment(x3, order, 3)) < dptol)) print*,' test_dp_3dim_mask', order call check( ieee_is_nan(moment(x3, order, mask = .false.))) call check( any(ieee_is_nan(moment(x3, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 2, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 3, mask = .false.)))) print*,' test_dp_3dim_mask_array', order call check( abs(moment(x3, order, mask = (x3 < 11)) ) < dptol) call check( all( abs( moment(x3, order, 1, mask = (x3 < 45))) < dptol )) call check( all( abs( moment(x3, order, 2, mask = (x3 < 45))) < dptol )) call check( all( abs( moment(x3, order, 3, mask = (x3 < 45))) < dptol )) order = 2 !1dim print*,' test_dp_1dim', order call check( abs(moment(x1, order) - 2._dp) < dptol) call check( abs(moment(x1, order, dim=1) - 2._dp) < dptol) print*,' test_dp_1dim_mask', order call check( ieee_is_nan(moment(x1, order, mask = .false.))) call check( ieee_is_nan(moment(x1, order, 1, mask = .false.))) print*,' test_dp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (x1 < 5)) - 1.25_dp) < dptol) call check( abs(moment(x1, order, 1, mask = (x1 < 5)) - 1.25_dp) < dptol) !2dim print*,' test_dp_2dim', order call check( abs(moment(x2, order) - 107.25_dp/9.) < dptol) call check( all( abs( moment(x2, order, 1) - [5._dp, 5._dp, 1.25_dp]) < dptol)) call check( all( abs( moment(x2, order, 2) -& [19._dp, 43._dp / 3., 31._dp / 3. , 7._dp]*2._dp/3.) < dptol)) print*,' test_dp_2dim_mask', order call check( ieee_is_nan(moment(x2, order, mask = .false.))) call check( any(ieee_is_nan(moment(x2, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x2, order, 2, mask = .false.)))) print*,' test_dp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (x2 < 11))- 2.75_dp*3.) < dptol) call check( all( abs( moment(x2, order, 1, mask = (x2 < 11)) -& [5._dp, 5._dp, 0.25_dp]) < dptol)) call check( all( abs( moment(x2, order, 2, mask = (x2 < 11)) -& [19._dp*2./3., 43._dp/9.*2., 0.25_dp , 0.25_dp]) < dptol)) !3dim print*,' test_dp_3dim', order call check( abs(moment(x3, order) - 153.4_dp*35./36.) < dptol) call check( all( abs( moment(x3, order, 1) -& reshape([20._dp / 3., 20._dp / 3., 5._dp / 3.,& 4* 20._dp / 3., 4* 20._dp / 3., 4* 5._dp / 3.,& 16* 20._dp / 3., 16* 20._dp / 3., 16* 5._dp / 3.],& [size(x3,2), size(x3,3)])*3._dp/4.)& < dptol)) call check( all( abs( moment(x3, order, 2) -& reshape([19._dp, 43._dp / 3., 31._dp / 3. , 7.0_dp,& 4* 19.0_dp, 4* 43._dp / 3., 4* 31._dp / 3. , 4* 7.0_dp,& 16* 19.0_dp, 16* 43._dp / 3., 16* 31._dp / 3. , 16* 7.0_dp],& [size(x3,1), size(x3,3)] )*2._dp/3.)& < dptol)) call check( all( abs( moment(x3, order, 3) -& reshape([ 7._dp/3., 21._dp, 175._dp/3.,& 343._dp/3., 28._dp/3., 112._dp/3.,& 84._dp, 448._dp/3., 189._dp,& 700._dp/3., 847._dp/3., 336._dp],& [size(x3,1), size(x3,2)] )*2./3.)& < dptol)) print*,' test_dp_3dim_mask', order call check( ieee_is_nan(moment(x3, order, mask = .false.))) call check( any(ieee_is_nan(moment(x3, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 2, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 3, mask = .false.)))) print*,' test_dp_3dim_mask_array', order call check( abs(moment(x3, order, mask = (x3 < 11)) -& 7.7370242214532876_dp ) < dptol) call check( all( abs( moment(x3, order, 1, mask = (x3 < 45)) -& reshape([5._dp, 5._dp, 1.25_dp, 20._dp, 20._dp, 5._dp,& 80._dp, 80._dp, 32._dp/3.],& [size(x3, 2), size(x3, 3)])) < dptol )) call check( all( abs( moment(x3, order, 2, mask = (x3 < 45)) -& reshape([ 38._dp/3., 86._dp/9., 62._dp/9., 14._dp/3., 152._dp/3.,& 344._dp/9., 248._dp/9., 168._dp/9., 1824._dp/9.,& 1376._dp/9., 992._dp/9., 4._dp& ],& [size(x3, 1), size(x3, 3)])) < dptol )) call check( all( abs( moment(x3, order, 3, mask = (x3 < 45)) -& reshape([14._dp/9., 14._dp, 350._dp/9., 686._dp/9., 56._dp/9.,& 224._dp/9., 56._dp, 896._dp/9., 126._dp, 1400._dp/9.,& 1694._dp/9., 36._dp& ], [size(x3,1), size(x3,2)] ))& < dptol )) end subroutine subroutine test_int32(x1, x2) integer(int32), intent(in) :: x1(:), x2(:, :) integer :: order integer(int32), allocatable :: x3(:, :, :) order = 1 !1dim print*,' test_dp_1dim', order call check( abs(moment(x1, order)) < dptol) call check( abs(moment(x1, order, dim=1)) < dptol) print*,' test_dp_1dim_mask', order call check( ieee_is_nan(moment(x1, order, mask = .false.))) call check( ieee_is_nan(moment(x1, order, 1, mask = .false.))) print*,' test_dp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (x1 < 5))) < dptol) call check( abs(moment(x1, order, 1, mask = (x1 < 5))) < dptol) !2dim print*,' test_dp_2dim', order call check( abs(moment(x2, order)) < dptol) call check( all( abs( moment(x2, order, 1)) < dptol)) call check( all( abs( moment(x2, order, 2)) < dptol)) print*,' test_dp_2dim_mask', order call check( ieee_is_nan(moment(x2, order, mask = .false.))) call check( any(ieee_is_nan(moment(x2, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x2, order, 2, mask = .false.)))) print*,' test_dp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (x2 < 11))) < dptol) call check( all( abs( moment(x2, order, 1, mask = (x2 < 11))) < dptol)) call check( all( abs( moment(x2, order, 2, mask = (x2 < 11))) < dptol)) !3dim allocate(x3(size(x2,1),size(x2,2),3)) x3(:,:,1)=x2; x3(:,:,2)=x2*2; x3(:,:,3)=x2*4; print*,' test_dp_3dim', order call check( abs(moment(x3, order)) < dptol) call check( all( abs( moment(x3, order, 1)) < dptol)) call check( all( abs( moment(x3, order, 2)) < dptol)) call check( all( abs( moment(x3, order, 3)) < dptol)) print*,' test_dp_3dim_mask', order call check( ieee_is_nan(moment(x3, order, mask = .false.))) call check( any(ieee_is_nan(moment(x3, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 2, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 3, mask = .false.)))) print*,' test_dp_3dim_mask_array', order call check( abs(moment(x3, order, mask = (x3 < 11)) ) < dptol) call check( all( abs( moment(x3, order, 1, mask = (x3 < 45))) < dptol )) call check( all( abs( moment(x3, order, 2, mask = (x3 < 45))) < dptol )) call check( all( abs( moment(x3, order, 3, mask = (x3 < 45))) < dptol )) order = 2 !1dim print*,' test_dp_1dim', order call check( abs(moment(x1, order) - 2._dp) < dptol) call check( abs(moment(x1, order, dim=1) - 2._dp) < dptol) print*,' test_dp_1dim_mask', order call check( ieee_is_nan(moment(x1, order, mask = .false.))) call check( ieee_is_nan(moment(x1, order, 1, mask = .false.))) print*,' test_dp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (x1 < 5)) - 1.25_dp) < dptol) call check( abs(moment(x1, order, 1, mask = (x1 < 5)) - 1.25_dp) < dptol) !2dim print*,' test_dp_2dim', order call check( abs(moment(x2, order) - 107.25_dp/9.) < dptol) call check( all( abs( moment(x2, order, 1) - [5._dp, 5._dp, 1.25_dp]) < dptol)) call check( all( abs( moment(x2, order, 2) -& [19._dp, 43._dp / 3., 31._dp / 3. , 7._dp]*2._dp/3.) < dptol)) print*,' test_dp_2dim_mask', order call check( ieee_is_nan(moment(x2, order, mask = .false.))) call check( any(ieee_is_nan(moment(x2, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x2, order, 2, mask = .false.)))) print*,' test_dp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (x2 < 11))- 2.75_dp*3.) < dptol) call check( all( abs( moment(x2, order, 1, mask = (x2 < 11)) -& [5._dp, 5._dp, 0.25_dp]) < dptol)) call check( all( abs( moment(x2, order, 2, mask = (x2 < 11)) -& [19._dp*2./3., 43._dp/9.*2., 0.25_dp , 0.25_dp]) < dptol)) !3dim print*,' test_dp_3dim', order call check( abs(moment(x3, order) - 153.4_dp*35./36.) < dptol) call check( all( abs( moment(x3, order, 1) -& reshape([20._dp / 3., 20._dp / 3., 5._dp / 3.,& 4* 20._dp / 3., 4* 20._dp / 3., 4* 5._dp / 3.,& 16* 20._dp / 3., 16* 20._dp / 3., 16* 5._dp / 3.],& [size(x3,2), size(x3,3)])*3._dp/4.)& < dptol)) call check( all( abs( moment(x3, order, 2) -& reshape([19._dp, 43._dp / 3., 31._dp / 3. , 7.0_dp,& 4* 19.0_dp, 4* 43._dp / 3., 4* 31._dp / 3. , 4* 7.0_dp,& 16* 19.0_dp, 16* 43._dp / 3., 16* 31._dp / 3. , 16* 7.0_dp],& [size(x3,1), size(x3,3)] )*2._dp/3.)& < dptol)) call check( all( abs( moment(x3, order, 3) -& reshape([ 7._dp/3., 21._dp, 175._dp/3.,& 343._dp/3., 28._dp/3., 112._dp/3.,& 84._dp, 448._dp/3., 189._dp,& 700._dp/3., 847._dp/3., 336._dp],& [size(x3,1), size(x3,2)] )*2./3.)& < dptol)) print*,' test_dp_3dim_mask', order call check( ieee_is_nan(moment(x3, order, mask = .false.))) call check( any(ieee_is_nan(moment(x3, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 2, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 3, mask = .false.)))) print*,' test_dp_3dim_mask_array', order call check( abs(moment(x3, order, mask = (x3 < 11)) -& 7.7370242214532876_dp ) < dptol) call check( all( abs( moment(x3, order, 1, mask = (x3 < 45)) -& reshape([5._dp, 5._dp, 1.25_dp, 20._dp, 20._dp, 5._dp,& 80._dp, 80._dp, 32._dp/3.],& [size(x3, 2), size(x3, 3)])) < dptol )) call check( all( abs( moment(x3, order, 2, mask = (x3 < 45)) -& reshape([ 38._dp/3., 86._dp/9., 62._dp/9., 14._dp/3., 152._dp/3.,& 344._dp/9., 248._dp/9., 168._dp/9., 1824._dp/9.,& 1376._dp/9., 992._dp/9., 4._dp& ],& [size(x3, 1), size(x3, 3)])) < dptol )) call check( all( abs( moment(x3, order, 3, mask = (x3 < 45)) -& reshape([14._dp/9., 14._dp, 350._dp/9., 686._dp/9., 56._dp/9.,& 224._dp/9., 56._dp, 896._dp/9., 126._dp, 1400._dp/9.,& 1694._dp/9., 36._dp& ], [size(x3,1), size(x3,2)] ))& < dptol )) end subroutine subroutine test_int64(x1, x2) integer(int64), intent(in) :: x1(:), x2(:, :) integer :: order integer(int64), allocatable :: x3(:, :, :) order = 1 !1dim print*,' test_dp_1dim', order call check( abs(moment(x1, order)) < dptol) call check( abs(moment(x1, order, dim=1)) < dptol) print*,' test_dp_1dim_mask', order call check( ieee_is_nan(moment(x1, order, mask = .false.))) call check( ieee_is_nan(moment(x1, order, 1, mask = .false.))) print*,' test_dp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (x1 < 5))) < dptol) call check( abs(moment(x1, order, 1, mask = (x1 < 5))) < dptol) !2dim print*,' test_dp_2dim', order call check( abs(moment(x2, order)) < dptol) call check( all( abs( moment(x2, order, 1)) < dptol)) call check( all( abs( moment(x2, order, 2)) < dptol)) print*,' test_dp_2dim_mask', order call check( ieee_is_nan(moment(x2, order, mask = .false.))) call check( any(ieee_is_nan(moment(x2, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x2, order, 2, mask = .false.)))) print*,' test_dp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (x2 < 11))) < dptol) call check( all( abs( moment(x2, order, 1, mask = (x2 < 11))) < dptol)) call check( all( abs( moment(x2, order, 2, mask = (x2 < 11))) < dptol)) !3dim allocate(x3(size(x2,1),size(x2,2),3)) x3(:,:,1)=x2; x3(:,:,2)=x2*2; x3(:,:,3)=x2*4; print*,' test_dp_3dim', order call check( abs(moment(x3, order)) < dptol) call check( all( abs( moment(x3, order, 1)) < dptol)) call check( all( abs( moment(x3, order, 2)) < dptol)) call check( all( abs( moment(x3, order, 3)) < dptol)) print*,' test_dp_3dim_mask', order call check( ieee_is_nan(moment(x3, order, mask = .false.))) call check( any(ieee_is_nan(moment(x3, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 2, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 3, mask = .false.)))) print*,' test_dp_3dim_mask_array', order call check( abs(moment(x3, order, mask = (x3 < 11)) ) < dptol) call check( all( abs( moment(x3, order, 1, mask = (x3 < 45))) < dptol )) call check( all( abs( moment(x3, order, 2, mask = (x3 < 45))) < dptol )) call check( all( abs( moment(x3, order, 3, mask = (x3 < 45))) < dptol )) order = 2 !1dim print*,' test_dp_1dim', order call check( abs(moment(x1, order) - 2._dp) < dptol) call check( abs(moment(x1, order, dim=1) - 2._dp) < dptol) print*,' test_dp_1dim_mask', order call check( ieee_is_nan(moment(x1, order, mask = .false.))) call check( ieee_is_nan(moment(x1, order, 1, mask = .false.))) print*,' test_dp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (x1 < 5)) - 1.25_dp) < dptol) call check( abs(moment(x1, order, 1, mask = (x1 < 5)) - 1.25_dp) < dptol) !2dim print*,' test_dp_2dim', order call check( abs(moment(x2, order) - 107.25_dp/9.) < dptol) call check( all( abs( moment(x2, order, 1) - [5._dp, 5._dp, 1.25_dp]) < dptol)) call check( all( abs( moment(x2, order, 2) -& [19._dp, 43._dp / 3., 31._dp / 3. , 7._dp]*2._dp/3.) < dptol)) print*,' test_dp_2dim_mask', order call check( ieee_is_nan(moment(x2, order, mask = .false.))) call check( any(ieee_is_nan(moment(x2, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x2, order, 2, mask = .false.)))) print*,' test_dp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (x2 < 11))- 2.75_dp*3.) < dptol) call check( all( abs( moment(x2, order, 1, mask = (x2 < 11)) -& [5._dp, 5._dp, 0.25_dp]) < dptol)) call check( all( abs( moment(x2, order, 2, mask = (x2 < 11)) -& [19._dp*2./3., 43._dp/9.*2., 0.25_dp , 0.25_dp]) < dptol)) !3dim print*,' test_dp_3dim', order call check( abs(moment(x3, order) - 153.4_dp*35./36.) < dptol) call check( all( abs( moment(x3, order, 1) -& reshape([20._dp / 3., 20._dp / 3., 5._dp / 3.,& 4* 20._dp / 3., 4* 20._dp / 3., 4* 5._dp / 3.,& 16* 20._dp / 3., 16* 20._dp / 3., 16* 5._dp / 3.],& [size(x3,2), size(x3,3)])*3._dp/4.)& < dptol)) call check( all( abs( moment(x3, order, 2) -& reshape([19._dp, 43._dp / 3., 31._dp / 3. , 7.0_dp,& 4* 19.0_dp, 4* 43._dp / 3., 4* 31._dp / 3. , 4* 7.0_dp,& 16* 19.0_dp, 16* 43._dp / 3., 16* 31._dp / 3. , 16* 7.0_dp],& [size(x3,1), size(x3,3)] )*2._dp/3.)& < dptol)) call check( all( abs( moment(x3, order, 3) -& reshape([ 7._dp/3., 21._dp, 175._dp/3.,& 343._dp/3., 28._dp/3., 112._dp/3.,& 84._dp, 448._dp/3., 189._dp,& 700._dp/3., 847._dp/3., 336._dp],& [size(x3,1), size(x3,2)] )*2./3.)& < dptol)) print*,' test_dp_3dim_mask', order call check( ieee_is_nan(moment(x3, order, mask = .false.))) call check( any(ieee_is_nan(moment(x3, order, 1, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 2, mask = .false.)))) call check( any(ieee_is_nan(moment(x3, order, 3, mask = .false.)))) print*,' test_dp_3dim_mask_array', order call check( abs(moment(x3, order, mask = (x3 < 11)) -& 7.7370242214532876_dp ) < dptol) call check( all( abs( moment(x3, order, 1, mask = (x3 < 45)) -& reshape([5._dp, 5._dp, 1.25_dp, 20._dp, 20._dp, 5._dp,& 80._dp, 80._dp, 32._dp/3.],& [size(x3, 2), size(x3, 3)])) < dptol )) call check( all( abs( moment(x3, order, 2, mask = (x3 < 45)) -& reshape([ 38._dp/3., 86._dp/9., 62._dp/9., 14._dp/3., 152._dp/3.,& 344._dp/9., 248._dp/9., 168._dp/9., 1824._dp/9.,& 1376._dp/9., 992._dp/9., 4._dp& ],& [size(x3, 1), size(x3, 3)])) < dptol )) call check( all( abs( moment(x3, order, 3, mask = (x3 < 45)) -& reshape([14._dp/9., 14._dp, 350._dp/9., 686._dp/9., 56._dp/9.,& 224._dp/9., 56._dp, 896._dp/9., 126._dp, 1400._dp/9.,& 1694._dp/9., 36._dp& ], [size(x3,1), size(x3,2)] ))& < dptol )) end subroutine subroutine test_csp(x1, x2) complex(sp), intent(in) :: x1(:), x2(:, :) integer :: order order = 1 !1dim print*,' test_sp_1dim', order call check( abs(moment(x1, order)) < sptol) call check( abs(moment(x1, order, dim=1)) < sptol) print*,' test_sp_1dim_mask', order call check( ieee_is_nan(abs(moment(x1, order, mask = .false.)))) call check( ieee_is_nan(abs(moment(x1, order, 1, mask = .false.)))) print*,' test_sp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (aimag(x1) == 0))) < sptol) call check( abs(moment(x1, order, 1, mask = (aimag(x1) == 0))) < sptol) !2dim print*,' test_sp_2dim', order call check( abs(moment(x2, order)) < sptol) call check( all( abs( moment(x2, order, 1)) < sptol)) call check( all( abs( moment(x2, order, 2)) < sptol)) print*,' test_sp_2dim_mask', order call check( ieee_is_nan(abs(moment(x2, order, mask = .false.)))) call check( any(ieee_is_nan(abs(moment(x2, order, 1, mask = .false.))))) call check( any(ieee_is_nan(abs(moment(x2, order, 2, mask = .false.))))) print*,' test_sp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (aimag(x2) == 0))) < sptol) call check( all( abs( moment(x2, order, 1, mask = (aimag(x2) == 0))) < sptol)) call check( any(ieee_is_nan( abs( moment(x2, order, 2,& mask = (aimag(x2) == 0)))))) order = 2 !1dim print*,' test_sp_1dim', order call check( abs(moment(x1, order) - (-6.459422410E-02,-0.556084037)) < sptol) call check( abs(moment(x1, order, dim=1) -& (-6.459422410E-02,-0.556084037)) < sptol) print*,' test_sp_1dim_mask', order call check( ieee_is_nan(abs(moment(x1, order, mask = .false.)))) call check( ieee_is_nan(abs(moment(x1, order, 1, mask = .false.)))) print*,' test_sp_1dim_mask_array', order call check( abs(moment(x1, order, mask = (aimag(x1) == 0)) -& (8.969944715E-02,0.00000000)) < sptol) call check( abs(moment(x1, order, 1, mask = (aimag(x1) == 0)) -& (8.969944715E-02,0.00000000)) < sptol) !2dim print*,' test_sp_2dim', order call check( abs(moment(x2, order) - (-0.163121477,-1.86906016)) < sptol) call check( all( abs( moment(x2, order, 1) -& [(-6.459422410E-02,-0.556084037),& (-0.581347823,-5.00475645),& (-0.145336956,-1.25118911)]& ) < sptol)) call check( all( abs( moment(x2, order, 2) -& [(0.240498722,0.00000000),& (-1.49895227,0.00000000),& (1.15390968,0.00000000),& (-0.569927275,0.00000000),& (0.944405317,0.00000000)]& ) < sptol)) print*,' test_sp_2dim_mask', order call check( ieee_is_nan(abs(moment(x2, order, mask = .false.)))) call check( any(ieee_is_nan(abs(moment(x2, order, 1, mask = .false.))))) call check( any(ieee_is_nan(abs(moment(x2, order, 2, mask = .false.))))) print*,' test_sp_2dim_mask_array', order call check( abs(moment(x2, order, mask = (aimag(x2) == 0))-& (1.08109438,0.00000000)) < sptol) call check( all( abs( moment(x2, order, 1, mask = (aimag(x2)==0)) -& [(8.969944715E-02,0.00000000),& (0.807295084,0.00000000),& (0.201823771,0.00000000)]& ) < sptol)) end subroutine end program
src/tests/stats/test_moment.f90
array A = [3] U32 enum E: A { X = 1 }
compiler/tools/fpp-check/test/enum/bad_rep_type.fpp
program ch1002 ! Reading Real Data implicit none integer, parameter :: n = 10 real, dimension(1:n) :: h, w, bmi integer :: i open(100,file='ch1001.out',status='old') do i = 1, n read(100,'(1x,f5.2,2x,f4.1)') h(i), w(i) end do close(100) bmi = w/(h*h) do i = 1, n write(*,'(1x, f4.1)') bmi(i) end do end program
ch10/ch1002.f90
subroutine r1(x, y, n, f1) integer n real*8 x(n), y(n) external f1 call f1(x, y, n) return end subroutine r2(x, y, n, f2) integer n real*8 x(n), y(n) external f2 call r1(x, y, n, f2) return end
sandbox/src1/TCSE3-3rd-examples/src/misc/f2py_callback/somefile.f
subroutine open_ascii_files(ID) use utils, only: add_path, read_comment implicit none integer, intent(in):: ID include 'combine_foam.inc' character(len=1000):: line integer:: ierr !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! INPUT AND INITIALIZATION FILES !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !GEOCLIM_VAR_INIT_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (2 ,status='old',file=filename) !SPECIES_INIT_FILE: call read_comment(ID) if (coupling_ecogeo) then print *, 'ECOGEO module not available' stop else read(ID,*) end if !BIODIV_VAR_INIT_FILE: call read_comment(ID) if (coupling_ecogeo) then print *, 'ECOGEO module not available' stop else read(ID,*) end if !--------! !CONTINENTAL_INPUT_MODE call read_comment(ID) read(unit=ID, fmt=*) dummychar, land_input_mode if (land_input_mode=='ascii') then !GRID_AREA_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (301,status='old',file=filename) !CONTINENTAL_AREA_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (7 ,status='old',file=filename) !ccccccc +++++++++++++++++++++++++++++++++ ! Climate under several CO2 levels !TEMPERATURE_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (30 ,status='old',file=filename) !RUNOFF_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (31 ,status='old',file=filename) call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename !call add_path(filename) !open (302 ,status='old',file=filename) call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename !call add_path(filename) !open (303 ,status='old',file=filename) !GCM_INPUT_CONDITIONS_FILE (ignore) call read_comment(ID) read(unit=ID, fmt=*) elseif (land_input_mode == 'GCM') then ! Skip 6 ascii-mode entries do k = 1,6 call read_comment(ID) read(unit=ID, fmt=*) end do !GCM_INPUT_CONDITIONS_FILE call read_comment(ID) read(unit=ID, fmt=*) dummychar, filename call add_path(filename) open (333, status='old', file=filename) else print *, 'ERROR: continental input mode (defined config/IO_CONDITIONS) must be "ascii" or "GCM"' stop end if !LITHOLOGICAL FRACTION (NETCDF FILE): call read_comment(ID) ! => store info in scratch file (that will be read by 'load_lithology' subroutine) read(unit=ID,fmt='(A1000)') line open (304 ,status='scratch') write(304, fmt='(A1000)') line !VEGETATION_FILE: call read_comment(ID) if (coupling_veget==1) then read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (48 ,status='old',file=filename) else read(ID,*) end if !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! COMBINE INPUT FILES !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !OCEANIC_TEMPERATURE_FILE call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename ! Check if got "parametric" instead of file name if (filename=='parametric') then ! if so, store that info in a scratch file open(unit=32, status='scratch', action='readwrite') write(unit=32, fmt=*) 'parametric' rewind(unit=32) else ! if not, open expected input ascii file call add_path(filename) open (32 ,status='old',file=filename) end if ! **OBSOLETE** (former HYPSO_FILE): call read_comment(ID) read(unit=ID,fmt=*)! dummychar, filename !call add_path(filename) !open (4 ,status='old',file=filename) !ccccccc +++++++++++++++++++++++++++++++++ ! Earth physical dimensions !OCEANIC_BOX_VOLUME_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (33 ,status='old',file=filename) !OCEAN_SURFACE_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (34 ,status='old',file=filename) !SURF_SEDIM_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (37 ,status='old',file=filename) !ccccccc+++++++++++++++++++++++++++++++++ ! definition of boxes !DEEP_BOX_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (35 ,status='old',file=filename) !SEDIM_BOX_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (36 ,status='old',file=filename) !BOX_TEMPERATURE_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (38 ,status='old',file=filename) !APP_CONT_BOX_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (39 ,status='old',file=filename) !THERMOCLINE_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (40 ,status='old',file=filename) !SURFACE_BOX_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (41 ,status='old',file=filename) !EXCHANGE_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (42 ,status='old',file=filename) ! ! unit=43: obsolete file: INPUT/indice_part.dat ! !FSINK_INORG_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (44 ,status='old',file=filename) !FSINK_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (45 ,status='old',file=filename) !EPICONT_BOX_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (46 ,status='old',file=filename) !POLAR_BOX_FILE: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename call add_path(filename) open (47 ,status='old',file=filename) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! RESTART AND OFFLINE FILES !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !ccccccc+++++++++++++++++++++++++++++++++ ! geoclim restart files: call read_comment(ID) read(unit=ID,fmt=*) dummychar, filename open (10 ,status='REPLACE',file=trim(output_path)//trim(filename)//run_name) if (coupling_ecogeo) then print *, 'ECOGEO module not available' stop else do i = 1,12 call read_comment(ID) read(ID,*) end do end if end subroutine
source/open_ascii_files.f
submodule(chamber_gas_t_interface) chamber_gas_t_implementation !! Defined the chamber_gas_t user-defined structure constructors and type-bound procedures implicit none contains module procedure new_chamber_gas_t new_chamber_gas_t%MW_ = MW new_chamber_gas_t%c_p_ = c_p new_chamber_gas_t%mcham_ = p*V/(new_chamber_gas_t%R_gas()*T) new_chamber_gas_t%echam_ = new_chamber_gas_t%mcham_*new_chamber_gas_t%c_v()*T end procedure module procedure incremented_chamber_gas_t incremented_chamber_gas_t%MW_ = old_chamber_gas_t%MW_ incremented_chamber_gas_t%c_p_ = old_chamber_gas_t%c_p_ incremented_chamber_gas_t%mcham_ = old_chamber_gas_t%mcham_ + mass_increment incremented_chamber_gas_t%echam_ = old_chamber_gas_t%echam_ + energy_increment end procedure module procedure R_gas real(dp), parameter :: R_universal=8314._dp R_gas = R_universal/this%MW_ end procedure module procedure c_p c_p = this%c_p_ end procedure module procedure c_v c_v = this%c_p() - this%R_gas() end procedure module procedure T T = this%echam_/(this%mcham_*this%c_v()) end procedure module procedure calcp calcp = this%mcham_*this%R_gas()*this%T()/V end procedure module procedure g g = this%c_p_/this%c_v() end procedure end submodule chamber_gas_t_implementation
src/refurbished/chamber_gas_t_implementation.f90
integer maxdata parameter (maxdata=3500) real*8 eqtime,eqlon real*8 data(maxdata,2),time(maxdata),dlon(maxdata),dlat(maxdata) integer*4 cycle,pass,select(1),ndata,verbose character*256 mission,metafile real*4 rlat,rlon,rssh,rtime integer*4 cycstart,cycend,passstart,passend character*256 comment nmission=10 do nm=1,nmission read(5,*)comment if(comment.eq.'END')stop read(5,'(A)')mission ! write(18,*)mission read(5,*)cycstart,cycend read(5,*)passstart,passend verbose = 2 select(1) = 0 call getraw_init(mission,verbose) ! call getraw_options(16,14) ! old mss_dtu10 being replaced call getraw_options(16,18) ! new mss_dtu15 jason-2,SARAL, Cryosat2 call getraw_options(10,02) call getraw_options(47,01) call getraw_limits(47,-.5d0,.5d0) do cycle=cycstart,cycend write(18,*)'cycle',cycle do pass = passstart,passend write(18,*)'pass',pass call getraw (cycle,pass,1,maxdata,select,time,dlat,dlon,data,ndata,eqtime,eqlon,metafile) write(18,*)'KING',ndata write(18,*)eqtime,eqlon write(18,*)metafile if(ndata.gt.1)then metafile=metafile(43:53) write(18,*)metafile open(16,file=metafile,status='unknown',form='unformatted',access='direct',recl=4*4) j=0 do i = 1,ndata if(data(i,1).le.10)then rlat=dlat(i) rlon=dlon(i) rssh=data(i,1) rtime=time(i)/(60*60*24) j=j+1 write(16,rec=j) rlat,rlon,rssh,rtime endif enddo !ndata endif enddo ! pass enddo ! cycle call getraw_stat(0) enddo ! nmission end
sla/RADS/setup_v4.f90
! DART software - Copyright UCAR. This open source software is provided ! by UCAR, "as is", without charge, subject to all terms of use at ! http://www.image.ucar.edu/DAReS/DART/DART_download ! ! $Id$ program advance_cymdh implicit none ! version controlled file description for error handling, do not edit character(len=256), parameter :: source = & "$URL$" character(len=32 ), parameter :: revision = "$Revision$" character(len=128), parameter :: revdate = "$Date$" interface integer function iargc() end function iargc end interface integer :: ccyy, mm, dd, hh, dh integer :: nargum, i, n, sign character(len=80), dimension(2) :: argum character(len=10) :: ccyymmddhh nargum=iargc() if(nargum /= 2) then write(unit=*, fmt='(a)') & 'Usage: advance_cymdh ccyymmddhh dh' stop 'try again.' endif do i=1,nargum do n=1,80 argum(i)(n:n)=' ' enddo call getarg(i,argum(i)) enddo ccyymmddhh = trim(argum(1)) read(ccyymmddhh(1:10), fmt='(i4, 3i2)') ccyy, mm, dd, hh sign = 1 dh = 0 do n=1,len_trim(argum(2)) if(argum(2)(n:n) == '-') then sign = -1 cycle else read(argum(2)(n:n), fmt='(i1)') i dh=10*dh + i end if enddo dh = sign * dh hh = hh + dh do while (hh < 0) hh = hh + 24 call change_date ( ccyy, mm, dd, -1 ) end do do while (hh > 23) hh = hh - 24 call change_date ( ccyy, mm, dd, 1 ) end do write(ccyymmddhh(1:10), fmt='(i4, 3i2.2)') ccyy, mm, dd, hh write(unit=*, fmt='(a)') ccyymmddhh contains subroutine change_date( ccyy, mm, dd, delta ) implicit none integer, intent(inout) :: ccyy, mm, dd integer, intent(in) :: delta integer, dimension(12) :: mmday mmday = (/31,28,31,30,31,30,31,31,30,31,30,31/) if (mod(ccyy,4) == 0) then mmday(2) = 29 if ( mod(ccyy,100) == 0) then mmday(2) = 28 endif if(mod(ccyy,400) == 0) then mmday(2) = 29 end if endif dd = dd + delta if(dd == 0) then mm = mm - 1 if(mm == 0) then mm = 12 ccyy = ccyy - 1 endif dd = mmday(mm) elseif ( dd .gt. mmday(mm) ) then dd = 1 mm = mm + 1 if(mm > 12 ) then mm = 1 ccyy = ccyy + 1 end if end if end subroutine change_date end program advance_cymdh ! <next few lines under version control, do not edit> ! $URL$ ! $Id$ ! $Revision$ ! $Date$
models/wrf/WRF_DART_utilities/advance_cymdh.f90
! ! Apodisation_Utility ! ! Module containing apodisation function routines. ! ! ! CREATION HISTORY: ! Written by: Paul van Delst, 31-Oct-2006 ! [email protected] ! MODULE Apodisation_Utility ! ----------------- ! Environment setup ! ----------------- ! Module usage USE Type_Kinds , ONLY: fp USE Fundamental_Constants, ONLY: PI USE SPC_IFG_Utility , ONLY: ComputeNSPC, & ComputeMeanDelta ! Disable implicit typing IMPLICIT NONE ! ---------- ! Visibility ! ---------- ! Everything is default private PRIVATE ! Parameters PUBLIC :: BARTLETT PUBLIC :: WELCH PUBLIC :: CONNES PUBLIC :: COSINE PUBLIC :: HAMMING PUBLIC :: HANNING PUBLIC :: NORTONBEER_WEAK PUBLIC :: NORTONBEER_MEDIUM PUBLIC :: NORTONBEER_STRONG PUBLIC :: BLACKMANHARRIS_3 PUBLIC :: BLACKMANHARRIS_4 PUBLIC :: BLACKMANHARRIS_4M PUBLIC :: BEER PUBLIC :: STRONGBEER PUBLIC :: HAPPGENZEL ! Procedures PUBLIC :: Apodisation_Function PUBLIC :: Apodisation_Utility_Version ! ---------- ! Parameters ! ---------- CHARACTER(*), PARAMETER :: MODULE_VERSION_ID = & ! Message string length INTEGER, PARAMETER :: ML = 256 ! Literal constants REAL(fp), PARAMETER :: ZERO = 0.0_fp REAL(fp), PARAMETER :: POINT5 = 0.5_fp REAL(fp), PARAMETER :: ONE = 1.0_fp REAL(fp), PARAMETER :: ONEPOINT5 = 1.5_fp REAL(fp), PARAMETER :: TWO = 2.0_fp REAL(fp), PARAMETER :: TEN = 10.0_fp ! Apodisation function coefficients !...Hamming apodfn coefficients REAL(fp), PARAMETER :: POINT46 = 0.46_fp REAL(fp), PARAMETER :: POINT54 = 0.54_fp !...Norton-Beer apodfn coefficients REAL(fp), PARAMETER :: NBC_WEAK(0:2) = (/ 0.384093_fp, -0.087577_fp, 0.703484_fp /) REAL(fp), PARAMETER :: NBC_MEDIUM(0:2) = (/ 0.152442_fp, -0.136176_fp, 0.983734_fp /) REAL(fp), PARAMETER :: NBC_STRONG(0:3) = (/ 0.045335_fp, ZERO , 0.554883_fp, 0.399782_fp /) !...Blackman-Harris apodfn coefficients REAL(fp), PARAMETER :: BHC_3(0:2) = (/ 0.42323_fp, 0.49755_fp, 0.07922_fp /) REAL(fp), PARAMETER :: BHC_4(0:3) = (/ 0.35875_fp, 0.48829_fp, 0.14128_fp, 0.01168_fp /) REAL(fp), PARAMETER :: BHC_4M(0:3) = (/ 0.355766_fp, 0.487395_fp, 0.144234_fp, 0.012605_fp /) ! Apodisation function type values INTEGER, PARAMETER :: BARTLETT = 1 INTEGER, PARAMETER :: WELCH = 2 INTEGER, PARAMETER :: CONNES = 3 INTEGER, PARAMETER :: COSINE = 4 INTEGER, PARAMETER :: HAMMING = 5 INTEGER, PARAMETER :: HANNING = 6 INTEGER, PARAMETER :: NORTONBEER_WEAK = 7 INTEGER, PARAMETER :: NORTONBEER_MEDIUM = 8 INTEGER, PARAMETER :: NORTONBEER_STRONG = 9 INTEGER, PARAMETER :: BLACKMANHARRIS_3 = 10 INTEGER, PARAMETER :: BLACKMANHARRIS_4 = 11 INTEGER, PARAMETER :: BLACKMANHARRIS_4M = 12 INTEGER, PARAMETER :: BEER = WELCH INTEGER, PARAMETER :: STRONGBEER = CONNES INTEGER, PARAMETER :: HAPPGENZEL = HAMMING CONTAINS !################################################################################## !################################################################################## !## ## !## ## PUBLIC MODULE ROUTINES ## ## !## ## !################################################################################## !################################################################################## !-------------------------------------------------------------------------------- !:sdoc+: ! ! NAME: ! Apodisation_Function ! ! PURPOSE: ! Pure function to compute various apodisation functions. ! ! CALLING SEQUENCE: ! y = Apodisation_Function(x, aType=aType, xMax=xMax) ! ! INPUTS: ! x: The regularly-spaced optical delay values for which the ! apodisation function is to be computed. ! UNITS: centimetres. ! TYPE: REAL(fp) ! DIMENSION: Rank-1 ! ATTRIBUTES: INTENT(IN) ! ! OPTIONAL INPUTS: ! aType: Set this argument to the defined parameter values to ! select the type of apodisation function. ! If == BARTLETT for Bartlett apodisation ! == WELCH for Welch apodisation ! == CONNES for Connes apodisation (DEFAULT) ! == COSINE for Cosine apodisation ! == HAMMING for Hamming apodisation ! == HANNING for Hanning apodisation ! == NORTONBEER_WEAK for weak Norton-Beer apodisation ! == NORTONBEER_MEDIUM for medium Norton-Beer apodisation ! == NORTONBEER_STRONG for strong Norton-Beer apodisation ! == BLACKMANHARRIS_3 for Blackman-Harris 3-term ! == BLACKMANHARRIS_4 for Blackman-Harris 4-term ! == BLACKMANHARRIS_4M for Blackman-Harris modified 4-term ! == BEER alias for WELCH ! == STRONGBEER alias for CONNES ! == HAPPGENZEL alias for HAMMING ! UNITS: N/A ! TYPE: INTEGER ! DIMENSION: Scalar ! ATTRIBUTES: INTENT(IN), OPTIONAL ! ! xMax: The maximum optical delay to use in calculating the ! apodisation function. ! - For x > xMax, the apodisation function is set to zero. ! - If not specified MAXVAL(ABS(x)) is used. ! UNITS: centimetres ! TYPE: REAL(fp) ! DIMENSION: Scalar ! ATTRIBUTES: INTENT(IN), OPTIONAL ! ! FUNCTION RESULT: ! y: Apodisation function. ! UNITS: N/A ! TYPE: REAL(fp) ! DIMENSION: Same as input x. ! ! COMMENTS: ! The formulae for the above apodisation functions are taken from: ! ! Weisstein, Eric W. "Apodization Function." ! From MathWorld--A Wolfram Web Resource. ! http://mathworld.wolfram.com/ApodizationFunction.html ! ! and ! ! Naylor,D.A. and M.K. Tahic, "Apodizing functions for Fourier ! transform spectroscopy, J.Opt.Soc.Am.A 24(11):3644-3648, 2007 ! !:sdoc-: !-------------------------------------------------------------------------------- PURE FUNCTION Apodisation_Function( & x , & aType, & xMax ) & RESULT(y) ! Arguments REAL(fp), INTENT(IN) :: x(:) INTEGER, OPTIONAL, INTENT(IN) :: aType REAL(fp), OPTIONAL, INTENT(IN) :: xMax ! Function result REAL(fp) :: y(SIZE(x)) ! Local variables INTEGER :: local_aType REAL(fp) :: local_xMax REAL(fp) :: tolerance REAL(fp) :: xnorm(SIZE(x)) INTEGER :: i, n REAL(fp) :: nbc(0:3), bhc(0:3) ! Set the apodisation function type local_aType = -1 ! Force default IF ( PRESENT(aType) ) local_aType = aType ! Set the maximum optical path delay IF ( PRESENT(xMax) ) THEN local_xMax = ABS(xMax) ELSE local_xMax = MAXVAL(ABS(x)) END IF ! Compute the normalised optical path delay xNorm = ABS(x)/local_xMax ! Compute apodisation function for +ve delays. The default ! apodisation function is CONNES SELECT CASE(local_aType) !...Some standard functions CASE(BARTLETT); y = ONE - xNorm CASE(WELCH) ; y = ONE - xNorm**2 CASE(COSINE) ; y = COS(POINT5*PI*xNorm) CASE(HAMMING) ; y = POINT54 + (POINT46*COS(PI*xNorm)) CASE(HANNING) ; y = POINT5*(ONE + COS(PI*xNorm)) !...Norton-Beer series CASE(NORTONBEER_WEAK, NORTONBEER_MEDIUM, NORTONBEER_STRONG) SELECT CASE(local_aType) CASE(NORTONBEER_WEAK) ; n = 2; nbc(0:n) = NBC_WEAK(0:n) CASE(NORTONBEER_MEDIUM); n = 2; nbc(0:n) = NBC_MEDIUM(0:n) CASE(NORTONBEER_STRONG); n = 3; nbc(0:n) = NBC_STRONG(0:n) END SELECT y = nbc(0) DO i = 1, n y = y + nbc(i)*(ONE - xNorm**2)**i END DO !...Blackman-Harris series CASE(BLACKMANHARRIS_3, BLACKMANHARRIS_4, BLACKMANHARRIS_4M) SELECT CASE(local_aType) CASE(BLACKMANHARRIS_3) ; n = 2; bhc(0:n) = BHC_3(0:n) CASE(BLACKMANHARRIS_4) ; n = 3; bhc(0:n) = BHC_4(0:n) CASE(BLACKMANHARRIS_4M); n = 3; bhc(0:n) = BHC_4M(0:n) END SELECT y = bhc(0) DO i = 1, n y = y + bhc(i)*COS(REAL(i,fp)*PI*xNorm) END DO !...Default is CONNES CASE DEFAULT ; y = (ONE - xNorm**2)**2 END SELECT ! Set out-of-bounds apodisation to zero tolerance = ComputeMeanDelta(x)/TEN WHERE ( ABS(x) > local_xMax+tolerance ) y = ZERO END FUNCTION Apodisation_Function !-------------------------------------------------------------------------------- !:sdoc+: ! ! NAME: ! Apodisation_Utility_Version ! ! PURPOSE: ! Subroutine to return the module version information. ! ! CALLING SEQUENCE: ! CALL Apodisation_Utility_Version( Id ) ! ! OUTPUTS: ! Id: Character string containing the version Id information ! for the module. ! UNITS: N/A ! TYPE: CHARACTER(*) ! DIMENSION: Scalar ! ATTRIBUTES: INTENT(OUT) ! !:sdoc-: !-------------------------------------------------------------------------------- SUBROUTINE Apodisation_Utility_Version( Id ) CHARACTER(*), INTENT(OUT) :: Id Id = MODULE_VERSION_ID END SUBROUTINE Apodisation_Utility_Version END MODULE Apodisation_Utility
src/Utility/FFT_Utility/Apodisation_Utility.f90
Describe Users/KTFreeman here. 20090623 23:21:25 nbsp Welcome to the Wiki! Users/robinlaughlin
lab/davisWiki/KTFreeman.f
! Contains the command handlers that encapsule ann FEAT commands. module featcommandhandler use fsystem use genoutput use storage use collection use io use basicgeometry use boundary use triangulation use meshhierarchy use element use cubature use fespacehierarchybase use fespacehierarchy use spatialdiscretisation use multilevelprojection use linearsystemscalar use linearsystemblock use multilevelprojection use derivatives use scalarpde use domainintegration use bilinearformevaluation use stdoperators use feevaluation use analyticprojection use spdiscprojection use vectorio use ucd use typedsymbol use commandparserbase use stdinoutparser implicit none private ! Execution mode: Standard execution integer, parameter, public :: FCMD_EXECSTD = 0 ! Execution mode: Print short help message integer, parameter, public :: FCMD_EXECSHORTHELP = 1 ! Execution mode: Print long help message integer, parameter, public :: FCMD_EXECLONGHELP = 2 public :: fcmd_evalCommand ! Specification for a variable for the automatic variable check. type t_varspec ! Tag for the variable. May be ="", then the variable is an untagged, mandatory ! variable. character(len=SYS_NAMELEN) :: svartag ! Mandatory type for the argument. An STYPE_xxxx constant integer :: ctype = STYPE_INVALID ! Mandatory type for the variable in the collection. If not set to COLLCT_UNDEFINED, ! the variable must be part of a collection and have this type. integer :: ccollectionType = COLLCT_UNDEFINED end type contains ! *************************************************************************** !<subroutine> subroutine fcmd_evalCommand (sstring,rcmdStatus,inestlevel,rvalue,bunknown,Rvalues) !<description> ! Evaluates a FEAT command. !</description> !<input> ! Name of the function character(len=*), intent(in) :: sstring ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! OPTIONAL: list of values or NULL if the list is empty. type(t_symbolValue), dimension(:), optional :: Rvalues !</input> !<output> ! Returns TRUE if the command is unknown. logical, intent(out) :: bunknown ! Return value of the function. type(t_symbolValue), intent(out) :: rvalue !</output> !</subroutine> bunknown = .false. rvalue%ctype = STYPE_INVALID if (sstring .eq. "help") then ! Call the FEAT command handler call fcmd_help (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "halt") then ! Stop the program. call fcmd_halt (rcmdStatus,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "meminfo") then ! Memory information call fcmd_meminfo (rcmdStatus,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "delete") then ! Delte a variabnle call fcmd_delete (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "destroy") then ! Destroy a variable call fcmd_destroy (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "show") then ! Information about a variable. call fcmd_show (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "info") then ! Information about a variable. call fcmd_info (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "printf") then ! Print text. call fcmd_printf (rcmdStatus,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "sprintf") then ! Put text to string. call fcmd_sprintf (rcmdStatus,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "read2dprm") then ! Call the FEAT command handler call fcmd_read2dprm (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "read2dtri") then ! Call the FEAT command handler call fcmd_read2dtri (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "meshrefine") then ! Call the FEAT command handler call fcmd_meshrefine (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "meshhierarchy") then ! Call the FEAT command handler call fcmd_meshhierarchy (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "fespace") then ! Call the FEAT command handler call fcmd_fespace (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "fehierarchy") then ! Call the FEAT command handler call fcmd_fehierarchy (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "mlevelprjhierarchy") then ! Call the FEAT command handler call fcmd_mlevelprjhierarchy (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "createblockvector") then ! Call the FEAT command handler call fcmd_createblockvector (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "readblockvector") then ! Call the FEAT command handler call fcmd_readblockvector (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "writeblockvector") then ! Call the FEAT command handler call fcmd_writeblockvector (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "copyvector") then ! Call the FEAT command handler call fcmd_copyvector (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "interpolatevector") then ! Call the FEAT command handler call fcmd_interpolatevector (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "extractfespacefromhier") then ! Call the FEAT command handler call fcmd_extractfespacefromhier (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "extractmeshfromhier") then ! Call the FEAT command handler call fcmd_extractmeshfromhier (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "extractsubvector") then ! Call the FEAT command handler call fcmd_extractsubvector (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "l2projection") then ! Call the FEAT command handler call fcmd_l2projection (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "writeucd") then ! Call the FEAT command handler call fcmd_writeucd (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "daxpyvector") then ! Call the FEAT command handler call fcmd_daxpyvector (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "clearvector") then ! Call the FEAT command handler call fcmd_clearvector (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else if (sstring .eq. "scalevector") then ! Call the FEAT command handler call fcmd_scalevector (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,Rvalues) else ! Mathematical function with 1 parameter? call fcmd_mathfunction (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,& sstring,bunknown,Rvalues) if (bunknown) then ! Mathematical function with 2 parameter? call fcmd_math2function (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,& sstring,bunknown,Rvalues) end if if (bunknown) then ! Simple function with 1 parameter call fcmd_simplefunction (rcmdStatus,inestlevel,rvalue,FCMD_EXECSTD,& sstring,bunknown,Rvalues) end if end if end subroutine ! *************************************************************************** !<subroutine> recursive subroutine fcmd_help (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: HELP. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! local variables character(len=COLLCT_MLNAME) :: scommand logical :: bunknown select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" help - This help page.") return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("help - Shows help to a command.") call output_lbrk () call output_line ("Usage:") call output_line (" help (""[command]"")") call output_lbrk () call output_line ("Shows help for the command ""[command]"".") return end select if (.not. present(Rvalues)) then ! Short help call output_line ("FEAT2 command parser.") call output_line ("---------------------") call output_line ("The following commands are available. For a specific help") call output_line ("type 'help (""[command]"")'.") call output_lbrk () ! Show the short help for all commands. call fcmd_help (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_internal_run (rcmdStatus,rreturn,FCMD_EXECSHORTHELP) call fcmd_halt (rcmdStatus,rreturn,FCMD_EXECSHORTHELP) call fcmd_meminfo (rcmdStatus,rreturn,FCMD_EXECSHORTHELP) call fcmd_delete (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_destroy (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_show (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_info (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_printf (rcmdStatus,rreturn,FCMD_EXECSHORTHELP) call fcmd_sprintf (rcmdStatus,rreturn,FCMD_EXECSHORTHELP) call fcmd_read2dprm (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_read2dtri (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_meshrefine (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_meshhierarchy (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_fespace (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_fehierarchy (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_mlevelprjhierarchy (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_createblockvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_readblockvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_writeblockvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_copyvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_extractfespacefromhier (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_extractmeshfromhier (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_extractsubvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_l2projection (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_writeucd (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_daxpyvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_clearvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_scalevector (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP) call fcmd_mathfunction (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP,"",bunknown) call fcmd_math2function (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP,"",bunknown) call fcmd_simplefunction (rcmdStatus,inestlevel,rreturn,FCMD_EXECSHORTHELP,"",bunknown) else ! Get the command. call cmdprs_dequoteStd(Rvalues(1)%svalue,scommand) if (scommand .eq. "help") then call fcmd_help (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "run") then call fcmd_internal_run (rcmdStatus,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "exit") then call fcmd_halt (rcmdStatus,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "meminfo") then call fcmd_meminfo (rcmdStatus,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "delete") then call fcmd_delete (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "destroy") then call fcmd_destroy (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "show") then call fcmd_show (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "info") then call fcmd_info (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "halt") then call fcmd_halt (rcmdStatus,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "printf") then call fcmd_printf (rcmdStatus,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "sprintf") then call fcmd_sprintf (rcmdStatus,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "read2dprm") then call fcmd_read2dprm (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "read2dtri") then call fcmd_read2dtri (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "meshrefine") then call fcmd_meshrefine (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "meshhierarchy") then call fcmd_meshhierarchy (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "fespace") then call fcmd_fespace (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "fehierarchy") then call fcmd_fehierarchy (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "mlevelprjhierarchy") then call fcmd_mlevelprjhierarchy (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "createblockvector") then call fcmd_createblockvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "readblockvector") then call fcmd_readblockvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "writeblockvector") then call fcmd_writeblockvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "copyvector") then call fcmd_copyvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "interpolatevector") then call fcmd_interpolatevector (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "extractfespacefromhier") then call fcmd_extractfespacefromhier (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "extractmeshfromhier") then call fcmd_extractmeshfromhier (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "extractsubvector") then call fcmd_extractsubvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "l2projection") then call fcmd_l2projection (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "writeucd") then call fcmd_writeucd (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "daxpyvector") then call fcmd_daxpyvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "clearvector") then call fcmd_clearvector (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else if (scommand .eq. "scalevector") then call fcmd_scalevector (rcmdStatus,inestlevel,rreturn,FCMD_EXECLONGHELP) else call output_line ("help: Unknown command.") end if end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** ! Auzxiliary routines ! *************************************************************************** !<subroutine> subroutine fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,rcollection,& inestlevel,Rvalues) !<description> ! Checks parameters and finds indices of optional parameters. !</description> !<input> ! Variable specification. Contains name and mandatory types vor the ! parameters in Rvalues. Parameters without a tag are mandatory ! and their number has to match the non-anynomous variables in Rvalues. ! Tagged variables are optional and searched for in Rvalues. ! For every variable in Snames, Itypes must specify a mandatory type, ! Iindex will receive the index of the named (optional) variables ! in Rvalues. type(t_varspec), dimension(:), intent(in) :: Rvarspec ! Collection object that contains all variables of the program. type(t_collection), intent(in) :: rcollection ! Level of nesting integer, intent(in) :: inestlevel ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! For each named variable in Snames, this array receives an index ! where this variable can be found in Rvalues. The index is =0 ! if the variable does not appear in Rvalues. ! The unnamed variables receive indices 1,2,3,... integer, dimension(:), intent(out) :: Iindex ! Returns TRUE if the parameters match in number and type the definitions ! in Snames/Itypes. if FALSE, serrormsg gets an error message. logical, intent(out) :: bsuccess character(len=*), intent(out) :: serrormsg !</output> !</subroutine> ! local variables integer :: i,j,nuntagged integer :: ctype character(len=SYS_NAMELEN) :: ssection logical :: bexists bsuccess = .false. Iindex(:) = 0 serrormsg = "" ! Figure out the number of untagged variables do nuntagged = 1,size(Rvarspec) if (Rvarspec(nuntagged)%svartag .ne. "") exit end do nuntagged = nuntagged-1 ! This must match the number of arguments. if (nuntagged .gt. 0) then if (.not. present (Rvalues)) return if (ubound(Rvalues,1) .lt. nuntagged) then serrormsg = "Not enough arguments." return end if do i=1,nuntagged if (Rvalues(i)%svartag .ne. "") then serrormsg = "Not enough arguments." return end if end do else ! If there are no arguments and all are optional, that's ok. if (.not. present (Rvalues)) then bsuccess = .true. return end if end if ! Fill the indices of the unnamed variables. Stop if a type does not match. do i=1,nuntagged if (Rvarspec(i)%ctype .ne. STYPE_UNDEFINED) then if (Rvalues(i)%ctype .ne. Rvarspec(i)%ctype) then serrormsg = "Invalid arguments." return end if end if Iindex(i) = i end do ! Now find the optional parameters. do i=nuntagged+1,size(Rvarspec) do j=nuntagged+1,size(Rvalues) if (Rvarspec(i)%svartag .eq. Rvalues(j)%svartag) then if (Rvarspec(i)%ctype .ne. STYPE_UNDEFINED) then ! Cancel if the type is wrong. if (Rvarspec(i)%ctype .ne. Rvalues(j)%ctype) then serrormsg = "Invalid arguments." return end if end if ! Remember the index, parameter done. Iindex(i) = j exit end if end do end do ! Check the parameters which have to fulfil the type in the collection ! to be correct. do i=1,size(Rvarspec) if (Rvarspec(i)%ccollectiontype .ne. COLLCT_UNDEFINED) then ! Check if we have this parameter if (Iindex(i) .ne. 0) then ! Is this a parameter from the collection? if (Rvalues(Iindex(i))%svarname .eq. "") then serrormsg = "Unknown variable" return end if call cmdprs_getSymbolSection (rcollection,Rvalues(Iindex(i))%svarname,& inestlevel,ssection,bexists) if (.not. bexists) then serrormsg = "Unknown variable: "//trim(Rvalues(Iindex(i))%svarname) return end if ! Is this parameter present in the collection? ctype = collct_gettype (rcollection, Rvalues(Iindex(i))%svarname, ssectionName=ssection) if (ctype .ne. Rvarspec(i)%ccollectionType) then serrormsg = "Invalid type: "//trim(Rvalues(Iindex(i))%svarname) return end if end if end if end do bsuccess = .true. end subroutine ! *************************************************************************** ! internal subroutines, only help messages ! *************************************************************************** !<subroutine> subroutine fcmd_internal_run (rcmdStatus,rreturn,cexecmode,Rvalues) !<description> ! Command: RUN. ! Internal command, this routine only provides help text. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! local variables select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" run - Execute script.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("run() - Execute a script on hard disc.") call output_lbrk () call output_line ("Usage on the command line:") call output_line (" run ""[filename/path]""") call output_lbrk () call output_line ("Usage in a script:") call output_line (" run (""[filename/path]"")") ! Ok. rreturn%ctype = STYPE_INTEGER return end select rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_internal_print (rcmdStatus,rreturn,cexecmode,Rvalues) !<description> ! Command: RUN. ! Internal command, this routine only provides help text. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! local variables select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" print - Print some text.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("print - prints some text to the terminal.") call output_lbrk () call output_line ("Usage on command line:") call output_line (" PRINT ""[some text]""") ! Ok. rreturn%ctype = STYPE_INTEGER return end select rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** ! General FEAT commands and expressions ! *************************************************************************** !<subroutine> subroutine fcmd_halt (rcmdStatus,rreturn,cexecmode,Rvalues) !<description> ! Command: HALT. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! local variables select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" exit - Exits the command line/a running loop.") call output_line (" halt() - Exits the command line/Stop the program.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("halt - Stops a running program or close interactive command line.") call output_lbrk () call output_line ("Usage:") call output_line (" halt()") call output_lbrk () call output_lbrk () call output_line ("exit - Exit a loop in a program.") call output_lbrk () call output_line ("Usage in a script:") call output_line (" exit") call output_lbrk () call output_lbrk () call output_line ("exit - Close interactive command line, return to terminal.") call output_lbrk () call output_line ("Usage on command line:") call output_line (" exit") ! Ok. rreturn%ctype = STYPE_INTEGER return end select rcmdStatus%bterminate = .true. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_meminfo (rcmdStatus,rreturn,cexecmode,Rvalues) !<description> ! Command: HALT. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! local variables select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" meminfo() - Information about memory management.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("meminfo - Information about memory management.") call output_lbrk () call output_line ("Usage:") call output_line (" meminfo()") ! Ok. rreturn%ctype = STYPE_INTEGER return end select call storage_info (.true.) rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_show (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: INFO. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(1), parameter :: Rvarspec = & (/ t_varspec("", STYPE_UNDEFINED, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=SYS_NAMELEN) :: svalname,ssection character(len=SYS_STRLEN) :: svalue integer :: ctype logical :: bexists select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" show() - Show environment variable (if possible).") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("show - Show content about an environment vairbale.") call output_lbrk () call output_line ("Usage:") call output_line (" show ()") call output_line (" show ([name])") call output_lbrk () call output_line ("If possible, this routine prints information about an") call output_line ("environment variable to the terminal. For standard types") call output_line ("(int, double, string,...), the value is returned.") call output_line ("For extended types (e.g. meshes), status information") call output_line ("is returned.") call output_line ("If no variable is specified, the environment information") call output_line ("for all variables is shown.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select if (.not. present(Rvalues)) then ! Environment statistics. call output_lbrk () call output_line ("Environment statistics:") call output_lbrk () ! Print the current status of the collection. call collct_printStatistics (rcmdStatus%rcollection) else ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers svalname = Rvalues(1)%svarname if (svalname .eq. "") then call output_line ("Unknown environment variable!") return end if ! That's an awful task. Figure out the type at first. ! Then get the value and/or print information. call cmdprs_getSymbolSection (rcmdStatus%rcollection,svalname,inestlevel,ssection) ctype = collct_gettype (rcmdStatus%rcollection, svalname, bexists=bexists, & ssectionName=ssection) if (.not. bexists) then call output_line ("Unknown environment variable!") else select case (ctype) case (COLLCT_INTEGER) call output_line (trim(sys_siL(& collct_getvalue_int (rcmdStatus%rcollection, svalname) ,10))) case (COLLCT_REAL) call output_line (trim(sys_sdEL(& collct_getvalue_real (rcmdStatus%rcollection, svalname) ,10))) case (COLLCT_STRING) call collct_getvalue_string (rcmdStatus%rcollection, svalname, svalue) call output_line (svalue) case default call output_line ("No information available.") end select end if end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_info (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: INFO. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(1), parameter :: Rvarspec = & (/ t_varspec("", STYPE_UNDEFINED, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_NAMELEN) :: svalname character(len=SYS_STRLEN) :: svalue integer :: ctype logical :: bexists type(t_triangulation), pointer :: p_rtriangulation type(t_meshhierarchy), pointer :: p_rmeshhierarchy type(t_fespaceLevel), pointer :: p_rfespace type(t_feHierarchy), pointer :: p_rfeHierarchy type(t_vectorBlock), pointer :: p_rvectorBlock type(t_vectorScalar), pointer :: p_rvectorScalar select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" info() - Detailed information about an environment variable.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("info - Detailed information about environment variables.") call output_lbrk () call output_line ("Usage:") call output_line (" info [name]") call output_lbrk () call output_line ("Shows detailed information about an environment variable.") call output_line ("This includes type, value,...") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers svalname = Rvalues(1)%svarname if (svalname .eq. "") then call output_line ("Unknown environment variable!") return end if ! That's an awful task. Figure out the type at first. ! Then get the value and/or print information. call cmdprs_getSymbolSection (rcmdStatus%rcollection,svalname,inestlevel,ssection) ctype = collct_gettype (rcmdStatus%rcollection, svalname, bexists=bexists, & ssectionName=ssection) if (.not. bexists) then call output_line ("Unknown environment variable!") else call output_line ("Variable: "//svalname) select case (ctype) case (COLLCT_INTEGER) call output_line ("Type : Integer") call output_line ("Content : ",bnolinebreak=.true., bnotrim=.true.) call output_line (trim(sys_siL(& collct_getvalue_int (rcmdStatus%rcollection, svalname, ssectionName=ssection) ,10))) case (COLLCT_REAL) call output_line ("Type : Double precision") call output_line ("Content : ",bnolinebreak=.true., bnotrim=.true.) call output_line (trim(sys_sdEL(& collct_getvalue_real (rcmdStatus%rcollection, svalname, ssectionName=ssection) ,10))) case (COLLCT_STRING) call output_line ("Type : string") call output_line ("Content : ",bnolinebreak=.true., bnotrim=.true.) call collct_getvalue_string (rcmdStatus%rcollection, svalname, svalue, ssectionName=ssection) call output_line (svalue) case (COLLCT_BOUNDARY) call output_line ("Type : Boundary object (2D)") case (COLLCT_TRIA) call output_line ("Type : Triangulation object") call output_lbrk () p_rtriangulation => collct_getvalue_tria (rcmdStatus%rcollection, svalname, ssectionName=ssection) call tria_infoStatistics (p_rtriangulation,.true.) case (COLLCT_MSHHIERARCHY) call output_line ("Type : Mesh hierarchy") call output_lbrk () p_rmeshhierarchy => collct_getvalue_mshh (rcmdStatus%rcollection, svalname, ssectionName=ssection) call mshh_printHierStatistics (p_rmeshhierarchy) case (COLLCT_FESPACE) call output_line ("Type : FE space") call output_lbrk () p_rfeSpace => collct_getvalue_fesp (rcmdStatus%rcollection, svalname, ssectionName=ssection) call fesph_infoStatistics (p_rfeSpace,.true.) call spdiscr_infoBlockDiscr (p_rfeSpace%p_rdiscretisation) case (COLLCT_FEHIERARCHY) call output_line ("Type : Mesh hierarchy") call output_lbrk () p_rfeHierarchy => collct_getvalue_feh (rcmdStatus%rcollection, svalname, ssectionName=ssection) call fesph_printHierStatistics (p_rfeHierarchy) case (COLLCT_MLPRJHIERARCHY) call output_line ("Type : Multilevel projection hierarchy") call output_lbrk () case (COLLCT_BLKVECTOR) call output_line ("Type : Block vector") call output_lbrk () p_rvectorBlock => collct_getvalue_vec (rcmdStatus%rcollection, svalname, ssectionName=ssection) call lsysbl_infoVector (p_rvectorBlock) case (COLLCT_SCAVECTOR) call output_line ("Type : Scalar vector") call output_lbrk () p_rvectorScalar => collct_getvalue_vecsca (rcmdStatus%rcollection, svalname, ssectionName=ssection) call lsyssc_infoVector (p_rvectorScalar) case default call output_line ("Type : "//sys_siL(ctype,10)) end select end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_destroy (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: destroy. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(1), parameter :: Rvarspec = & (/ t_varspec("", STYPE_UNDEFINED, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_NAMELEN) :: svalname logical :: bexists select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" destroy() - Destroys a variable and releases memory.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("destroy - Destroys a variable. Releases any associated memory..") call output_lbrk () call output_line ("Usage:") call output_line (" destroy([name])") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers svalname = Rvalues(1)%svarname ! Destroy the variable call cmdprs_getSymbolSection (rcmdStatus%rcollection,svalname,inestlevel,ssection,bexists) if (bexists) then call do_destroy (rcmdStatus,svalname,ssection,.true.) end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_delete (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: delete. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(1), parameter :: Rvarspec = & (/ t_varspec("", STYPE_UNDEFINED, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_NAMELEN) :: svalname logical :: bexists select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" delete() - Delete variable from environment.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("delete - Delete a variable from the environment.") call output_lbrk () call output_line ("Usage:") call output_line (" delete ([name])") call output_lbrk () call output_line ("WARNING: This does not release probably associated memory!") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers svalname = Rvalues(1)%svarname ! Destroy the variable call cmdprs_getSymbolSection (rcmdStatus%rcollection,svalname,inestlevel,ssection,bexists) if (bexists) then call collct_deletevalue (rcmdStatus%rcollection, svalname,ssectionName=ssection) end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_printf (rcmdStatus,rreturn,cexecmode,Rvalues) !<description> ! Command: PRINTF. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! local variables character (len=SYS_STRLEN) :: stemp,stemp2 select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" printf() - Print text to the terminal.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("printf - Print text to the termininal.") call output_lbrk () call output_line ("Usage:") call output_line (" printf(""[format string]"",...)") ! Ok. rreturn%ctype = STYPE_INTEGER return end select rreturn%ctype = STYPE_INTEGER if (present(Rvalues)) then if (Rvalues(1)%ctype .eq. STYPE_STRING) then ! Evaluate the arguments. stemp = Rvalues(1)%svalue call sioprs_qualifyString (stemp,Rvalues(2:)) ! Print to terminal call cmdprs_dequoteStd(stemp,stemp2) call output_line (stemp2) ! Worked. return end if end if ! If we come to here, there is something wrong. call output_line ("Invalid arguments!") end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_sprintf (rcmdStatus,rreturn,cexecmode,Rvalues) !<description> ! Command: SPRINTF. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(inout), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! local variables character (len=SYS_STRLEN) :: stemp select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" sprintf() - Print text to a string.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("sprintf - Print text to a string.") call output_lbrk () call output_line ("Usage:") call output_line (" sprintf([destination string],""[format string]"",...)") ! Ok. rreturn%ctype = STYPE_INTEGER return end select rreturn%ctype = STYPE_INTEGER if (present(Rvalues)) then if (size(Rvalues) .ge. 2) then if ((Rvalues(1)%ctype .eq. STYPE_STRING) .and.& (Rvalues(2)%ctype .eq. STYPE_STRING)) then ! Evaluate the arguments. stemp = Rvalues(2)%svalue if (size(Rvalues) .ge. 3) then call sioprs_qualifyString (stemp,Rvalues(3:)) else call sioprs_qualifyString (stemp) end if ! Print to string Rvalues(1)%svalue = trim(stemp) Rvalues(1)%ilength = len_trim(stemp) call tpsym_saveSymbol (Rvalues(1)) ! Worked. return end if end if end if ! If we come to here, there is something wrong. call output_line ("Invalid arguments!") end subroutine ! *************************************************************************** subroutine do_destroy (rcmdStatus,svalname,svalsection,bverbose) !<description> ! Command handler: DESTROY. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus !</inputoutput> !<input> ! Name of the variable to destroy character(len=*), intent(in) :: svalname ! Name of the section containing the variable character(len=*), intent(in) :: svalsection ! Print vebose messages logical, intent(in) :: bverbose !</input> ! local variables integer :: ctype,itag logical :: bexists,bdelete type(t_boundary), pointer :: p_rboundary type(t_triangulation), pointer :: p_rtriangulation type(t_meshhierarchy), pointer :: p_rmeshhierarchy type(t_feSpaceLevel), pointer :: p_rfeSpace type(t_feHierarchy), pointer :: p_rfeHierarchy type(t_interlevelProjectionHier), pointer :: p_rinterlevelProjectionHier type(t_vectorBlock), pointer :: p_rvectorBlock type(t_vectorScalar), pointer :: p_rvectorScalar ! That's an awful task. Figure out the type at first. ! Then get the value and/or print information. ctype = collct_gettype (rcmdStatus%rcollection, svalname, bexists=bexists, ssectionName=svalsection) if (.not. bexists) then if (bverbose) then call output_line ("Unknown environment variable!") end if else ! Get the user defined tag. If the tag is set to 1, do not destroy the variable ! but only delete it -- it is associated to another structure! itag = collct_gettag(rcmdStatus%rcollection, svalname, ssectionName=svalsection) bdelete = .true. if (itag .eq. 0) then select case (ctype) case (COLLCT_INTEGER,COLLCT_REAL,COLLCT_STRING) ! Primitive type case (COLLCT_BOUNDARY) ! Boundary object p_rboundary => collct_getvalue_bdry (rcmdStatus%rcollection, svalname,ssectionName=svalsection) call boundary_release(p_rboundary) deallocate(p_rboundary) case (COLLCT_TRIA) ! Boundary object p_rtriangulation => collct_getvalue_tria (rcmdStatus%rcollection, svalname,ssectionName=svalsection) call tria_done(p_rtriangulation) deallocate(p_rtriangulation) case (COLLCT_MSHHIERARCHY) ! Boundary object p_rmeshhierarchy => collct_getvalue_mshh (rcmdStatus%rcollection, svalname,ssectionName=svalsection) call mshh_releaseHierarchy(p_rmeshhierarchy) deallocate(p_rmeshhierarchy) case (COLLCT_FESPACE) ! Boundary object p_rfeSpace => collct_getvalue_fesp (rcmdStatus%rcollection, svalname,ssectionName=svalsection) call fesph_releaseFEspace(p_rfeSpace) deallocate(p_rfeSpace) case (COLLCT_FEHIERARCHY) ! Boundary object p_rfeHierarchy => collct_getvalue_feh (rcmdStatus%rcollection, svalname,ssectionName=svalsection) call fesph_releaseHierarchy(p_rfeHierarchy) deallocate(p_rfeHierarchy) case (COLLCT_MLPRJHIERARCHY) ! Multilevel projection hierarchy p_rinterlevelProjectionHier => collct_getvalue_mlprjh (rcmdStatus%rcollection, svalname,& ssectionName=svalsection) call mlprj_releasePrjHierarchy(p_rinterlevelProjectionHier) deallocate(p_rinterlevelProjectionHier) case (COLLCT_BLKVECTOR) ! Multilevel projection hierarchy p_rvectorBlock => collct_getvalue_vec (rcmdStatus%rcollection, svalname,& ssectionName=svalsection) call lsysbl_releaseVector(p_rvectorBlock) deallocate(p_rvectorBlock) case (COLLCT_SCAVECTOR) ! Multilevel projection hierarchy p_rvectorScalar => collct_getvalue_vecsca (rcmdStatus%rcollection, svalname,& ssectionName=svalsection) call lsyssc_releaseVector(p_rvectorScalar) deallocate(p_rvectorScalar) case default call output_line ("Unknown type, variable cannot be destroyed!") bdelete = .false. end select end if if (bdelete) then call collct_deletevalue (rcmdStatus%rcollection, svalname, ssectionName=svalsection) end if end if end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_read2dprm (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: READ2DPRM. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(2), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & ! Variable name t_varspec("", STYPE_STRING, COLLCT_UNDEFINED) & ! File name /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables logical :: bexists character(len=SYS_STRLEN) :: sfilename character(len=COLLCT_MLNAME) :: sname, ssection type(t_boundary), pointer :: p_rboundary select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" read2dprm() - Read 2D .prm file.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("read2dprm - Read 2D .PRM file.") call output_lbrk () call output_line ("Usage:") call output_line (" read2dprm ([varname],[filename])") call output_lbrk () call output_line ("Read in a .prm file and store it using the name [variable].") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifier and file name sname = Rvalues(1)%svarname call cmdprs_dequoteStd(Rvalues(2)%svalue,sfilename) if ((sname .eq. "") .or. (sfilename .eq. "")) then call output_line ("Invalid arguments.") return end if ! Open the file and read. inquire(file=trim(sfilename), exist=bexists) if (.not. bexists) then call output_line ("File not found!") return else call output_line ("Reading file: "//trim(sfilename)) ! Read allocate (p_rboundary) call boundary_read_prm(p_rboundary, sfilename) ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_bdry (rcmdStatus%rcollection, sname, p_rboundary, .true., & ssectionName=ssection) end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_read2dtri (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: READ2DTRI. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(3), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("boundary", STYPE_VAR, COLLCT_BOUNDARY) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables logical :: bexists character(len=SYS_STRLEN) :: sfilename, stoken character(len=COLLCT_MLNAME) :: sname,ssection type(t_boundary), pointer :: p_rboundary type(t_triangulation), pointer :: p_rtriangulation select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" read2dtri() - Read 2D .tri file.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("read2dtri - Read 2D .TRI file.") call output_lbrk () call output_line ("Usage:") call output_line (" read2dtri ([varname],[filename] [,boundary=[varbd]]") call output_lbrk () call output_line ("Read in a .tri file and store it using the name [variable].") call output_line ("If BOUNDARY is specified, the triangulation is connected") call output_line ("to a boundary object varbd.") call output_lbrk () call output_line ("Example:") call output_line (" read2dprm (myprm,""myprmfile.prm"";"); call output_line (" read2dtri (mytri,""mytrifile.tri"",boundary=myprm);") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check the parameters if (.not. present(Rvalues)) then call output_line ("Not enough arguments.") return end if if (size(Rvalues) .lt. 2) then call output_line ("Not enough arguments.") return end if ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifier and file name sname = Rvalues(1)%svarname call cmdprs_dequoteStd(Rvalues(2)%svalue,sfilename) nullify(p_rboundary) if (Iindex(3) .ne. 0) then ! Get the bondary object. stoken = Rvalues(Iindex(3))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rboundary => collct_getvalue_bdry(rcmdStatus%rcollection,stoken,bexists=bexists,& ssectionName=ssection) end if ! Open the file and read. inquire(file=trim(sfilename), exist=bexists) if (.not. bexists) then call output_line ("File not found!") else call output_line ("Reading file: "//trim(sfilename)) ! Read allocate (p_rtriangulation) if (associated(p_rboundary)) then call tria_readTriFile2D(p_rtriangulation, sfilename, p_rboundary) ! Create a standard mesh. call tria_initStandardMeshFromRaw (p_rtriangulation, p_rboundary) else call output_line("Warning. No boundary specified!") call tria_readTriFile2D(p_rtriangulation, sfilename) ! Create a standard mesh. call tria_initStandardMeshFromRaw (p_rtriangulation) end if ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_tria (rcmdStatus%rcollection, sname, p_rtriangulation, .true.,& ssectionName=ssection) end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_meshrefine (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: MESHREFINE. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(4), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_TRIA), & t_varspec("levels", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("boundary", STYPE_VAR, COLLCT_BOUNDARY), & t_varspec("method", STYPE_STRING, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=SYS_STRLEN) :: stoken integer :: cmethod, ilevels integer :: i type(t_boundary), pointer :: p_rboundary type(t_triangulation), pointer :: p_rtriangulation character(len=COLLCT_MLNAME) :: ssection logical :: bexists select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" meshrefine() - Refine a mesh.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("meshrefine - Refine a mesh.") call output_lbrk () call output_line ("Usage:") call output_line (" meshrefine ([varmesh] [, ...options...]);") call output_lbrk () call output_line ("Refine a mesh with a given method one or multiple times.") call output_line ("[varmesh] identifies the mesh to refine.") call output_line ("The following options are possible in [...options...]:") call output_lbrk () call output_line (" ... levels=[varname] ...") call output_line (" Refine the mesh [varname] times. Default is ""levels=1"".") call output_lbrk () call output_line (" ... boundary=[varname] ...") call output_line (" Use the specified boundary object [varname] fdor boundary refinement.") call output_line (" If not specified, no boundary object is used.") call output_lbrk () call output_line (" ... method=[varname] ...") call output_line (" Use a specific method. Default is ""method ""2levelordered"""". Possible choices:") call output_line (" ""2levelordered"" - Use 2-level-ordering refinement.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifier and file name nullify(p_rboundary) nullify(p_rtriangulation) ilevels = 1 cmethod = 0 ! 2-level ordering if (Iindex(2) .ne. 0) then ! Refinement levels ilevels = Rvalues(Iindex(2))%ivalue end if if (Iindex(3) .ne. 0) then ! Get the bondary object. stoken = Rvalues(Iindex(3))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rboundary => collct_getvalue_bdry(rcmdStatus%rcollection,stoken,bexists=bexists,& ssectionName=ssection) end if if (Iindex(4) .ne. 0) then ! Method if (Rvalues(Iindex(4))%svalue .eq. "2levelordered") then cmethod = 0 else call output_line ("Warning: Unknown refinement method! Using default.") cmethod = 0 end if end if ! Get the triangulation object. stoken = Rvalues(Iindex(1))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rtriangulation => collct_getvalue_tria(rcmdStatus%rcollection,stoken,ssectionName=ssection) call output_line ("Refining mesh... [",bnolinebreak=.true.) ! Refine the mesh select case (cmethod) case (0) ! 2-level ordered do i = 1,ilevels call output_line (" "//trim(sys_siL(i,10)),bnolinebreak=.true.) ! Boundary present? if (associated(p_rboundary)) then call tria_quickRefine2LevelOrdering(1,p_rtriangulation) else call tria_quickRefine2LevelOrdering(1,p_rtriangulation,p_rboundary) end if end do ! Create a standard mesh. if (associated(p_rboundary)) then call tria_initStandardMeshFromRaw (p_rtriangulation) else call tria_initStandardMeshFromRaw (p_rtriangulation,p_rboundary) end if call output_line ("]") end select ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_meshhierarchy (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: MESHIHIERARCHY. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(5), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("mesh", STYPE_VAR, COLLCT_TRIA), & t_varspec("boundary", STYPE_VAR, COLLCT_BOUNDARY), & t_varspec("levels", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("method", STYPE_INTEGER, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=SYS_STRLEN) :: stoken integer :: cmethod, ilevels type(t_boundary), pointer :: p_rboundary type(t_triangulation), pointer :: p_rtriangulation character(len=COLLCT_MLNAME) :: sname,ssection type(t_meshHierarchy), pointer :: p_rmeshHierarchy logical :: bexists select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" meshhierarchy() - Create a mesh hierarchy.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("meshhierarchy - Create a mesh hierarchy.") call output_lbrk () call output_line ("Usage:") call output_line (" meshhierarchy ([varname] [, ...options...])") call output_lbrk () call output_line ("Refine a mesh with a given method one or multiple times.") call output_line ("[varname] identifies the variable to create.") call output_line ("The following options are possible in [...options...]:") call output_lbrk () call output_line (" ... mesh=[varname] ...") call output_line (" Use mesh [varname] as coarse mesh of teh hierarchy.") call output_line (" Mandatory argument") call output_lbrk () call output_line (" ... boundary=[varname] ...") call output_line (" Use the specified boundary object [varname] for boundary refinement.") call output_line (" If not specified, no boundary object is used.") call output_lbrk () call output_line (" ... levels=[varname] ...") call output_line (" Creates a hierarchy of [varname] levels. Default is ""levels=1"".") call output_lbrk () call output_line (" ... method=""[varname]"" ...") call output_line (" Use a specific method. Default is ""method ""2levelordered"""". Possible choices:") call output_line (" 2levelordered - Use 2-level-ordering refinement.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifier and file name nullify(p_rboundary) nullify(p_rtriangulation) sname = Rvalues(1)%svarname ilevels = 1 cmethod = 0 ! 2-level ordering if (Iindex(2) .ne. 0) then ! Get the triangulation object. stoken = Rvalues(Iindex(2))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rtriangulation => collct_getvalue_tria(rcmdStatus%rcollection,stoken,ssectionName=ssection) end if if (Iindex(3) .ne. 0) then ! Get the bondary object. stoken = Rvalues(Iindex(3))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rboundary => collct_getvalue_bdry(rcmdStatus%rcollection,stoken,bexists=bexists,& ssectionName=ssection) end if if (Iindex(4) .ne. 0) then ! Refinement levels ilevels = Rvalues(Iindex(4))%ivalue end if if (Iindex(5) .ne. 0) then ! Method if (Rvalues(Iindex(5))%svalue .eq. "2levelordered") then cmethod = 0 else call output_line ("Warning: Unknown refinement method! Using default.") cmethod = 0 end if end if if (.not. associated (p_rtriangulation)) then call output_line ("Invalid triangulation!") return end if ! Create the hierarchy. allocate(p_rmeshHierarchy) ! Create the hierarchy select case (cmethod) case (0) ! 2-level ordered ! Boundary present? if (associated(p_rboundary)) then call output_line ("Creating mesh hierarchy... [1",bnolinebreak=.true.) call mshh_initHierarchy (p_rmeshHierarchy,p_rtriangulation,0,ilevels,& rboundary=p_rboundary) call mshh_refineHierarchy2lv (p_rmeshHierarchy,ilevels,& rboundary=p_rboundary,bprint=.true.) else call output_line ("Warning: No boundary present!") call output_line ("Creating mesh hierarchy... [1",bnolinebreak=.true.) call mshh_initHierarchy (p_rmeshHierarchy,p_rtriangulation,0,ilevels) call mshh_refineHierarchy2lv (p_rmeshHierarchy,ilevels,bprint=.true.) end if call output_line ("]") end select ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_mshh (rcmdStatus%rcollection, sname, p_rmeshHierarchy, .true.,& ssectionName=ssection) ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** subroutine fgetDiscr(rtriangulation,rdiscr,rboundary,rcollection) !<description> ! Callback routine to set up a block discretisation. !</description> !<input> ! Triangulation structure type(t_triangulation), intent(in) :: rtriangulation ! Definition of the boundary type(t_boundary), intent(in), optional :: rboundary ! Collection structure with information about the discretisation type(t_collection), intent(inout), optional :: rcollection !</input> !<output> ! Block discretisation structure type(t_blockDiscretisation), intent(out) :: rdiscr !</output> ! local variables integer :: i,nspaces logical :: bexists integer :: celtri,celquad,ccubtri,ccubquad integer, dimension(:), allocatable :: p_IelementIdsTri integer, dimension(:), allocatable :: p_IelementIdsQuad integer, dimension(:), allocatable :: p_IcubIdsTri integer, dimension(:), allocatable :: p_IcubIdsQuad nspaces = rcollection%IquickAccess(1) allocate(p_IelementIdsTri(nspaces)) allocate(p_IelementIdsQuad(nspaces)) allocate(p_IcubIdsTri(nspaces)) allocate(p_IcubIdsQuad(nspaces)) call collct_getvalue_intarr (rcollection, "IelementIdsTri", p_IelementIdsTri, bexists=bexists) call collct_getvalue_intarr (rcollection, "IelementIdsQuad", p_IelementIdsQuad, bexists=bexists) call collct_getvalue_intarr (rcollection, "IcubIdsTri", p_IcubIdsTri, bexists=bexists) call collct_getvalue_intarr (rcollection, "IcubIdsQuad", p_IcubIdsQuad, bexists=bexists) select case (rtriangulation%ndim) case (NDIM2D) ! Create a block discretisation of the specific size. call spdiscr_initBlockDiscr (rdiscr,nspaces,rtriangulation,rboundary) ! Create the sub-discretisation structures. celtri = 0 celquad = 0 ccubtri = 0 ccubquad = 0 do i=1,nspaces celtri = p_IelementIdsTri(i) celquad = p_IelementIdsQuad(i) ccubtri = p_IcubIdsTri(i) ccubquad = p_IcubIdsQuad(i) if (celquad .eq. 0) then ! Pure tri space call spdiscr_initDiscr_simple (rdiscr%RspatialDiscr(i), & INT(celtri,I32),INT(ccubtri,I32),rtriangulation, & rboundary) else if (celtri .eq. 0) then ! Pure quad space call spdiscr_initDiscr_simple (rdiscr%RspatialDiscr(i), & INT(celquad,I32),INT(ccubquad,I32),rtriangulation, & rboundary) else ! Combined space call spdiscr_initDiscr_triquad (rdiscr%RspatialDiscr(i), & int(celtri,I32), INT(celquad,I32),& int(ccubtri,I32), INT(ccubquad,I32),rtriangulation, & rboundary) end if end do case default call output_line("Error. Dimension not supported!") call sys_halt() end select end subroutine ! *************************************************************************** subroutine prepare_fgetDiscr(rcollection,rcmdStatus,nspaces,& p_IelementIdsTri,p_IelementIdsQuad,p_IcubIdsTri,p_IcubIdsQuad) !<description> ! Prepares setting up a discretisation. ! Must be called in advance to fgetDiscr. !</description> !<input> ! Number of components integer, intent(in) :: nspaces ! List of element id's for tri/tetra elements integer, dimension(:), pointer :: p_IelementIdsTri ! List of element id's for quad/hexa elements integer, dimension(:), pointer :: p_IelementIdsQuad ! List of cubature id's for tri/tetra elements integer, dimension(:), pointer :: p_IcubIdsTri ! List of cubature id's for quad/hexa elements integer, dimension(:), pointer :: p_IcubIdsQuad !</input> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout), target :: rcmdStatus ! Collection structure with information about the discretisation type(t_collection), intent(inout), optional :: rcollection !</inputoutput> rcollection%p_rnextCollection => rcmdStatus%rcollection rcollection%IquickAccess(1) = nspaces if (associated(p_IelementIdsTri)) then call collct_setvalue_intarr (rcollection, "IelementIdsTri", p_IelementIdsTri, .true.) end if if (associated(p_IelementIdsQuad)) then call collct_setvalue_intarr (rcollection, "IelementIdsQuad", p_IelementIdsQuad, .true.) end if if (associated(p_IcubIdsTri)) then call collct_setvalue_intarr (rcollection, "IcubIdsTri", p_IcubIdsTri, .true.) end if if (associated(p_IcubIdsQuad)) then call collct_setvalue_intarr (rcollection, "IcubIdsQuad", p_IcubIdsQuad, .true.) end if end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_fespace (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: FESPACE. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(9), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("mesh", STYPE_VAR, COLLCT_TRIA), & t_varspec("boundary", STYPE_VAR, COLLCT_BOUNDARY), & t_varspec("components", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("trielements", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("quadelements", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("tricub", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("quadcub", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("concat", STYPE_STRING, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables logical :: bexists,berror character(len=SYS_STRLEN) :: stoken integer :: ncomponents integer :: i,j,istart,iend,ilength type(t_boundary), pointer :: p_rboundary type(t_triangulation), pointer :: p_rtriangulation character(len=COLLCT_MLNAME) :: sname,ssection character(len=SYS_STRLEN) :: strielements,squadelements,stricub,squadcub,sconcat type(t_feSpaceLevel), pointer :: p_rfeSpace type(t_feSpaceLevel), pointer :: p_rfeSpace1,p_rfeSpace2 type (t_collection) :: rcollection integer, dimension(:), pointer :: p_IelementIdsTri,p_IelementIdsQuad integer, dimension(:), pointer :: p_IcubIdsTri,p_IcubIdsQuad select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" fespace() - Create a FE space.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("fespace - Create an FE space.") call output_lbrk () call output_line ("Usage:") call output_line (" fespace ([varname] [, ...options...])") call output_lbrk () call output_line ("Creates an FE space that can be used to set up matrices/vectors.") call output_line ("[varname] identifies the variable to create.") call output_line ("The following options are possible in [...options...]:") call output_lbrk () call output_line (" ... mesh=[varname] ...") call output_line (" Use mesh [varname] as coarse mesh of the hierarchy.") call output_line (" Mandatory argument") call output_lbrk () call output_line (" ... boundary=[varname] ...") call output_line (" Use boundary definition [varname] for refinements.") call output_lbrk () call output_line (" ... components=[num] ...") call output_line (" Creates a FE space with [num] components. Mandatory argument.") call output_line (" Must be defined in advance to all element/cubature specifications.") call output_lbrk () call output_line (" ... trielements=""EL_xxx EL_xxx EL_xxx"" ...") call output_line (" Specifies a list of TRI/TETRA elemnent types to be used for") call output_line (" triangular/tetrahedral elements. There must be one ID per component.") call output_lbrk () call output_line (" ... quadelements=""EL_xxx EL_xxx EL_xxx"" ...") call output_line (" Specifies a list of QUAD/HEXA elemnent types to be used for") call output_line (" quadrilateral/hexahedral elements. There must be one ID per component.") call output_lbrk () call output_line (" ... tricub=""CUB_xxx CUB_xxx CUB_xxx"" ...") call output_line (" Specifies a list of TRI/TETRA cubature formulas to be used for") call output_line (" triangular/tetrahedral elements. There must be one ID per component.") call output_line (" If not defined, the default cubature formula is used.") call output_lbrk () call output_line (" ... quadcub=""CUB_xxx CUB_xxx CUB_xxx"" ...") call output_line (" Specifies a list of QUAD/HEXA cubature formulas to be used for") call output_line (" quadrilateral/hexahedral elements. There must be one ID per component.") call output_line (" If not defined, the default cubature formula is used.") call output_lbrk () call output_line ("Alternative usage:") call output_line (" fespace ([varname] , concat=""[var1] [var2] ..."")") call output_lbrk () call output_line ("Forms a FE-space by concatenation of other FE-spaces..") call output_line ("""[var1] [var2] ..."" must be a list of FE spaces to be concatenated.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers sname = Rvalues(1)%svarname sconcat = "" ncomponents = 0 nullify(p_rboundary) nullify(p_rtriangulation) nullify(p_rfeSpace) nullify(p_rfeSpace1) nullify(p_rfeSpace2) strielements = "" squadelements = "" stricub = "" squadcub = "" if (Iindex(2) .ne. 0) then ! Get the triangulation object. stoken = Rvalues(Iindex(2))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rtriangulation => collct_getvalue_tria(rcmdStatus%rcollection,stoken,ssectionName=ssection) end if if (Iindex(3) .ne. 0) then ! Get the bondary object. stoken = Rvalues(Iindex(3))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rboundary => collct_getvalue_bdry(rcmdStatus%rcollection,stoken,bexists=bexists,& ssectionName=ssection) end if if (Iindex(4) .ne. 0) then ! Number of components ncomponents = Rvalues(Iindex(4))%ivalue end if if (Iindex(5) .ne. 0) then ! tri-elements call cmdprs_dequoteStd(Rvalues(Iindex(5))%svalue,strielements) end if if (Iindex(6) .ne. 0) then ! Quad-elements call cmdprs_dequoteStd(Rvalues(Iindex(6))%svalue,squadelements) end if if (Iindex(7) .ne. 0) then ! Tri-cubature call cmdprs_dequoteStd(Rvalues(Iindex(7))%svalue,stricub) end if if (Iindex(8) .ne. 0) then ! Quad-Cubature call cmdprs_dequoteStd(Rvalues(Iindex(8))%svalue,squadcub) end if if (Iindex(9) .ne. 0) then ! Concatenation sconcat = Rvalues(Iindex(9))%svalue end if if (sconcat .ne. "") then ! Concatenation of FE-spaces. if (cmdprs_counttokens(sconcat," ") .lt. 2) then call output_line("Error. Not enough source spaces specified!") berror = .true. else ! Concatenate the first two. istart = 0 iend = 0 call cmdprs_nexttoken (sconcat,istart,iend,ilength,cseparator=" ") sname = sconcat(istart:iend) p_rfeSpace1 => collct_getvalue_fesp(rcmdStatus%rcollection,sname,bexists=bexists) if (.not. bexists) then call output_line("Error. 1st source FE space does not exist.") berror = .true. end if if (.not. berror) then call cmdprs_nexttoken (sconcat,istart,iend,ilength,cseparator=" ") sname = sconcat(istart:iend) p_rfeSpace2 => collct_getvalue_fesp(rcmdStatus%rcollection,sname,bexists=bexists) if (.not. bexists) then call output_line("Error. 1st source FE space does not exist.") berror = .true. end if end if if (.not. berror) then ! Concat. call fesph_concatFeSpaces (p_rfeSpace1,p_rfeSpace2,p_rfeSpace,p_rtriangulation) ! Now the case that there are even more spaces. do i=3,cmdprs_counttokens(sconcat," ") ! Shift the spaces. p_rfeSpace1 => p_rfeSpace ! Get the next one. call cmdprs_nexttoken (sconcat,istart,iend,ilength,cseparator=" ") sname = sconcat(istart:iend) p_rfeSpace2 => collct_getvalue_fesp(rcmdStatus%rcollection,sname,bexists=bexists) if (.not. bexists) then call output_line("Warning. Invalid source space """//trim(sname)//""". Ignored.") ! Ignore the error. else ! Concatenate and remove the old one. call fesph_concatFeSpaces (p_rfeSpace1,p_rfeSpace2,p_rfeSpace,p_rtriangulation) call fesph_releaseFEspace (p_rfeSpace1) end if end do end if end if else if (.not. associated (p_rtriangulation)) then call output_line ("Invalid triangulation!") return end if if (ncomponents .le. 0) then call output_line("Error. Number of components undefined!") return end if berror = .false. nullify(p_IcubIdsTri) nullify(p_IcubIdsQuad) nullify(p_IelementIdsTri) nullify(p_IelementIdsQuad) if ((strielements .ne. "") .and. (cmdprs_counttokens(strielements," ") .eq. ncomponents)) then allocate (p_IelementIdsTri(ncomponents)) istart = 0 iend = 0 ilength = len_trim(strielements) do i=1,ncomponents ! Parse the Id. call cmdprs_nexttoken (strielements,istart,iend,ilength,cseparator=" ") p_IelementIdsTri(j) = elem_igetID(strielements(istart:iend),.true.) if (p_IelementIdsTri(j) .eq. 0) then call output_line("Error. Invalid element ID: "//trim(stoken)) berror = .true. exit end if if (elem_igetDimension(p_IelementIdsTri(j)) .ne. NDIM2D) then call output_line("Error. Not a 2D element: "//trim(stoken)) berror = .true. exit end if if (elem_igetNVE(p_IelementIdsTri(j)) .ne. 3) then call output_line("Error. Not a tri element: "//trim(stoken)) berror = .true. exit end if end do end if if ((.not. berror) .and. (squadelements .ne. "")) then if (cmdprs_counttokens(squadelements," ") .eq. ncomponents) then allocate (p_IelementIdsQuad(ncomponents)) istart = 0 iend = 0 ilength = len_trim(squadelements) do i=1,ncomponents ! Parse the Id. call cmdprs_nexttoken (squadelements,istart,iend,ilength,cseparator=" ") p_IelementIdsQuad(i) = elem_igetID(squadelements(istart:iend),.true.) if (p_IelementIdsQuad(i) .eq. 0) then call output_line("Error. Invalid element ID: "//trim(stoken)) berror = .true. exit end if if (elem_igetDimension(p_IelementIdsquad(i)) .ne. NDIM2D) then call output_line("Error. Not a 2D element: "//trim(stoken)) berror = .true. exit end if if (elem_igetNVE(p_IelementIdsquad(i)) .ne. 4) then call output_line("Error. Not a quad element: "//trim(stoken)) berror = .true. exit end if end do else call output_line("Error. Invalid parameters!") berror = .true. end if end if if ((.not. berror) .and. (stricub .ne. "")) then if (cmdprs_counttokens(stricub," ") .eq. ncomponents) then allocate (p_IcubIdsTri(ncomponents)) istart = 0 iend = 0 ilength = len_trim(stricub) do i=1,ncomponents ! Parse the Id. call cmdprs_nexttoken (stricub,istart,iend,ilength,cseparator=" ") p_IcubIdsTri(i) = cub_igetID(stricub(istart:iend)) if (p_IcubIdsTri(i) .eq. 0) then call output_line("Error. Invalid cubature ID: "//trim(stoken)) berror = .true. exit end if end do else call output_line("Error. Invalid parameters!") berror = .true. end if end if if ((.not. berror) .and. (squadcub .ne. "")) then if (cmdprs_counttokens(squadcub," ") .eq. ncomponents) then allocate (p_IcubIdsquad(ncomponents)) istart = 0 iend = 0 ilength = len_trim(squadcub) do i=1,ncomponents ! Parse the Id. call cmdprs_nexttoken (squadcub,istart,iend,ilength,cseparator=" ") p_IcubIdsQuad(i) = cub_igetID(squadcub(istart:iend)) if (p_IcubIdsQuad(i) .eq. 0) then call output_line("Error. Invalid cubature ID: "//trim(stoken)) berror = .true. exit end if end do else call output_line("Error. Invalid parameters!") berror = .true. end if end if ! Create the FE space usinf fgetDiscr. if (.not. berror) then call collct_init (rcollection) call prepare_fgetDiscr(rcollection,rcmdStatus,ncomponents,& p_IelementIdsTri,p_IelementIdsQuad,p_IcubIdsTri,p_IcubIdsQuad) allocate(p_rfeSpace) if (associated(p_rboundary)) then call fesph_createFEspace (p_rfeSpace,1,& p_rtriangulation,1,fgetDiscr,rcollection,rboundary=p_rboundary) else call output_line ("Warning: No boundary present!") call fesph_createFEspace (p_rfeSpace,1,& p_rtriangulation,1,fgetDiscr,rcollection) end if call collct_done (rcollection) end if end if if (.not. berror) then ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_fesp (rcmdStatus%rcollection, sname, p_rfeSpace, .true.,& ssectionName=ssection) end if ! Release allocated memory if (associated(p_IelementIdsTri)) deallocate(p_IelementIdsTri) if (associated(p_IelementIdsQuad)) deallocate(p_IelementIdsQuad) if (associated(p_IcubIdsTri)) deallocate(p_IcubIdsTri) if (associated(p_IcubIdsQuad)) deallocate(p_IcubIdsQuad) if (berror) then return end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_fehierarchy (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: FEHIERARCHY. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(9), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("meshhierarchy", STYPE_VAR, COLLCT_MSHHIERARCHY), & t_varspec("boundary", STYPE_VAR, COLLCT_BOUNDARY), & t_varspec("components", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("trielements", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("quadelements", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("tricub", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("quadcub", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("concat", STYPE_STRING, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables logical :: bexists,berror character(len=SYS_STRLEN) :: stoken integer :: ncomponents integer :: i,istart,iend,ilength type(t_boundary), pointer :: p_rboundary type(t_meshhierarchy), pointer :: p_rmeshhierarchy character(len=COLLCT_MLNAME) :: sname,ssection character(len=SYS_STRLEN) :: strielements,squadelements,stricub,squadcub,sconcat type(t_feHierarchy), pointer :: p_rfeSpHier type(t_feHierarchy), pointer :: p_rfeSpHier1,p_rfeSpHier2 type (t_collection) :: rcollection integer, dimension(:), pointer :: p_IelementIdsTri,p_IelementIdsQuad integer, dimension(:), pointer :: p_IcubIdsTri,p_IcubIdsQuad select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" fehierarchy() - Create a FE hierarchy.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("fehierarchy - Create a FE hierarchy.") call output_lbrk () call output_line ("Usage:") call output_line (" fehierarchy ([varname] [, ...options...])") call output_lbrk () call output_line ("Creates an FE hierarchy that can be used to set up matrices/vectors.") call output_line ("[varname] identifies the variable to create.") call output_line ("The following options are possible in [...options...]:") call output_lbrk () call output_line (" ... meshhierarchy=[varname] ...") call output_line (" Use mesh hierarchy [varname] as basis mesh of the hierarchy.") call output_line (" Mandatory argument.") call output_lbrk () call output_line (" ... boundary=[varname] ...") call output_line (" Use boundary definition [varname] for refinements.") call output_lbrk () call output_line (" ... components=[num] ...") call output_line (" Creates a FE space with [num] components. Mandatory argument.") call output_line (" Must be defined in advance to all element/cubature specifications.") call output_lbrk () call output_line (" ... trielements=""EL_xxx EL_xxx EL_xxx"" ...") call output_line (" Specifies a list of TRI/TETRA elemnent types to be used for") call output_line (" triangular/tetrahedral elements. There must be one ID per component.") call output_lbrk () call output_line (" ... quadelements=""EL_xxx EL_xxx EL_xxx"" ...") call output_line (" Specifies a list of QUAD/HEXA elemnent types to be used for") call output_line (" quadrilateral/hexahedral elements. There must be one ID per component.") call output_lbrk () call output_line (" ... tricub=""CUB_xxx CUB_xxx CUB_xxx"" ...") call output_line (" Specifies a list of TRI/TETRA cubature formulas to be used for") call output_line (" triangular/tetrahedral elements. There must be one ID per component.") call output_line (" If not defined, the default cubature formula is used.") call output_lbrk () call output_line (" ... quadcub=""CUB_xxx CUB_xxx CUB_xxx"" ...") call output_line (" Specifies a list of QUAD/HEXA cubature formulas to be used for") call output_line (" quadrilateral/hexahedral elements. There must be one ID per component.") call output_line (" If not defined, the default cubature formula is used.") call output_lbrk () call output_line ("Alternative usage:") call output_line (" fespace ([varname] , concat=""[var1] [var2] ..."")") call output_lbrk () call output_line ("Forms a FE-space hierarchy by concatenation of other FE-space hierarchies.") call output_line ("""[var1] [var2] ..."" must be a list of FE spaces to be concatenated.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Get the identifiers sname = Rvalues(1)%svarname sconcat = "" stricub = "" squadcub = "" strielements = "" squadelements = "" ncomponents = 0 nullify(p_rboundary) nullify(p_rmeshHierarchy) ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if if (Iindex(2) .ne. 0) then ! Get the triangulation object. stoken = Rvalues(Iindex(2))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rmeshhierarchy => collct_getvalue_mshh(rcmdStatus%rcollection,stoken,ssectionName=ssection) end if if (Iindex(3) .ne. 0) then ! Get the bondary object. stoken = Rvalues(Iindex(3))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rboundary => collct_getvalue_bdry(rcmdStatus%rcollection,stoken,bexists=bexists,& ssectionName=ssection) end if if (Iindex(4) .ne. 0) then ! Number of components ncomponents = Rvalues(Iindex(4))%ivalue end if if (Iindex(5) .ne. 0) then ! tri-elements call cmdprs_dequoteStd(Rvalues(Iindex(5))%svalue,strielements) end if if (Iindex(6) .ne. 0) then ! Quad-elements call cmdprs_dequoteStd(Rvalues(Iindex(6))%svalue,squadelements) end if if (Iindex(7) .ne. 0) then ! Tri-cubature call cmdprs_dequoteStd(Rvalues(Iindex(7))%svalue,stricub) end if if (Iindex(8) .ne. 0) then ! Quad-Cubature call cmdprs_dequoteStd(Rvalues(Iindex(8))%svalue,squadcub) end if if (Iindex(9) .ne. 0) then ! Concatenation call cmdprs_dequoteStd(Rvalues(Iindex(9))%svalue,sconcat) end if if (sconcat .ne. "") then ! Concatenation of FE-spaces. if (cmdprs_counttokens(sconcat," ") .lt. 2) then call output_line("Error. Not enough source spaces specified!") berror = .true. else ! Concatenate the first two. istart = 0 iend = 0 call cmdprs_nexttoken (sconcat,istart,iend,ilength,cseparator=" ") sname = sconcat(istart:iend) p_rfeSpHier1 => collct_getvalue_feh(rcmdStatus%rcollection,sname,bexists=bexists) if (.not. bexists) then call output_line("Error. 1st source FE space does not exist.") berror = .true. end if if (.not. berror) then call cmdprs_nexttoken (sconcat,istart,iend,ilength,cseparator=" ") sname = sconcat(istart:iend) p_rfeSpHier2 => collct_getvalue_feh(rcmdStatus%rcollection,sname,bexists=bexists) if (.not. bexists) then call output_line("Error. 1st source FE space does not exist.") berror = .true. end if end if if (.not. berror) then ! Concat. call fesph_concatFeHierarchies (p_rfeSpHier1,p_rfeSpHier2,p_rfeSpHier) ! Now the case that there are even more spaces. do i=3,cmdprs_counttokens(sconcat," ") ! Shift the spaces. p_rfeSpHier1 => p_rfeSpHier ! Get the next one. call cmdprs_nexttoken (sconcat,istart,iend,ilength,cseparator=" ") sname = sconcat(istart:iend) p_rfeSpHier2 => collct_getvalue_feh(rcmdStatus%rcollection,sname,bexists=bexists) if (.not. bexists) then call output_line("Warning. Invalid source space """//trim(sname)//""". Ignored.") ! Ignore the error. else ! Concatenate and remove the old one. call fesph_concatFeHierarchies (p_rfeSpHier1,p_rfeSpHier2,p_rfeSpHier) call fesph_releaseHierarchy (p_rfeSpHier1) end if end do end if end if else if (ncomponents .le. 0) then call output_line("Error. Number of components undefined!") return end if berror = .false. if ((strielements .ne. "") .and. (cmdprs_counttokens(strielements," ") .eq. ncomponents)) then allocate (p_IelementIdsTri(ncomponents)) istart = 0 iend = 0 ilength = len_trim(strielements) do i=1,ncomponents ! Parse the Id. call cmdprs_nexttoken (strielements,istart,iend,ilength,cseparator=" ") p_IelementIdsTri(i) = elem_igetID(strielements(istart:iend),.true.) if (p_IelementIdsTri(i) .eq. 0) then call output_line("Error. Invalid element ID: "//trim(strielements(istart:iend))) berror = .true. exit end if if (elem_igetDimension(p_IelementIdsTri(i)) .ne. NDIM2D) then call output_line("Error. Not a 2D element: "//trim(strielements(istart:iend))) berror = .true. exit end if if (elem_igetNVE(p_IelementIdsTri(i)) .ne. 3) then call output_line("Error. Not a tri element: "//trim(strielements(istart:iend))) berror = .true. exit end if end do end if if ((.not. berror) .and. (squadelements .ne. "")) then if (cmdprs_counttokens(squadelements," ") .eq. ncomponents) then allocate (p_IelementIdsQuad(ncomponents)) istart = 0 iend = 0 ilength = len_trim(squadelements) do i=1,ncomponents ! Parse the Id. call cmdprs_nexttoken (squadelements,istart,iend,ilength,cseparator=" ") p_IelementIdsQuad(i) = elem_igetID(squadelements(istart:iend),.true.) if (p_IelementIdsQuad(i) .eq. 0) then call output_line("Error. Invalid element ID: "//trim(squadelements(istart:iend))) berror = .true. exit end if if (elem_igetDimension(p_IelementIdsQuad(i)) .ne. NDIM2D) then call output_line("Error. Not a 2D element: "//trim(squadelements(istart:iend))) berror = .true. exit end if if (elem_igetNVE(p_IelementIdsQuad(i)) .ne. 4) then call output_line("Error. Not a quad element: "//trim(squadelements(istart:iend))) berror = .true. exit end if end do else call output_line("Error. Invalid parameters!") berror = .true. end if end if if ((.not. berror) .and. (stricub .ne. "")) then if (cmdprs_counttokens(stricub," ") .eq. ncomponents) then allocate (p_IcubIdsTri(ncomponents)) istart = 0 iend = 0 ilength = len_trim(stricub) do i=1,ncomponents ! Parse the Id. call cmdprs_nexttoken (stricub,istart,iend,ilength,cseparator=" ") p_IcubIdsTri(i) = cub_igetID(stricub(istart:iend)) if (p_IcubIdsTri(i) .eq. 0) then call output_line("Error. Invalid cubature ID: "//trim(stricub(istart:iend))) berror = .true. exit end if end do else call output_line("Error. Invalid parameters!") berror = .true. end if end if if ((.not. berror) .and. (squadcub .ne. "")) then if (cmdprs_counttokens(squadcub," ") .eq. ncomponents) then allocate (p_IcubIdsquad(ncomponents)) istart = 0 iend = 0 ilength = len_trim(squadcub) do i=1,ncomponents ! Parse the Id. call cmdprs_nexttoken (squadcub,istart,iend,ilength,cseparator=" ") p_IcubIdsquad(i) = cub_igetID(squadcub(istart:iend)) if (p_IcubIdsquad(i) .eq. 0) then call output_line("Error. Invalid cubature ID: "//trim(squadcub(istart:iend))) berror = .true. exit end if end do else call output_line("Error. Invalid parameters!") berror = .true. end if end if if (.not. berror) then ! Create the FE space using fgetDiscr. call collct_init (rcollection) call prepare_fgetDiscr(rcollection,rcmdStatus,ncomponents,& p_IelementIdsTri,p_IelementIdsQuad,p_IcubIdsTri,p_IcubIdsQuad) allocate(p_rfeSpHier) if (associated(p_rboundary)) then call fesph_createHierarchy (p_rfeSpHier,p_rmeshHierarchy%nlevels,& p_rmeshHierarchy,fgetDiscr,rcollection,rboundary=p_rboundary) else call output_line ("Warning: No boundary present!") call fesph_createHierarchy (p_rfeSpHier,p_rmeshHierarchy%nlevels,& p_rmeshHierarchy,fgetDiscr,rcollection) end if call collct_done (rcollection) end if end if if (.not. berror) then ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_feh (rcmdStatus%rcollection, sname, p_rfeSpHier, .true.,& ssectionName=ssection) end if ! Release allocated memory if (associated(p_IelementIdsTri)) deallocate(p_IelementIdsTri) if (associated(p_IelementIdsQuad)) deallocate(p_IelementIdsQuad) if (associated(p_IcubIdsTri)) deallocate(p_IcubIdsTri) if (associated(p_IcubIdsQuad)) deallocate(p_IcubIdsQuad) if (berror) then return end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_extractfespacefromhier (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: EXTRACTFESPACEFROMHIER. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(3), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_FEHIERARCHY) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg integer :: ilevel ! local variables character(len=COLLCT_MLNAME) :: sname,ssection type(t_fehierarchy), pointer :: p_rfeHierarchy type(t_feSpaceLevel), pointer :: p_rfeSpace select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" extractfespacefromhier() - Extract an FE space from a hierarchy.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("extractfespacefromhier - Extract an FE space from a hierarchy.") call output_lbrk () call output_line ("Usage:") call output_line (" extractfespacefromhier ([varname], [varhier], [level])") call output_lbrk () call output_line ("Extracts the FE-space of level [level] from the hierarchy [varhier]") call output_line ("and stores it to the variable [varname].") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers sname = Rvalues(1)%svarname ilevel = Rvalues(2)%ivalue nullify(p_rfeHierarchy) p_rfeHierarchy => collct_getvalue_feh (rcmdStatus%rcollection, Rvalues(3)%svarname) ! Get the FE space if ((ilevel .lt. 1) .or. (ilevel .gt. p_rfeHierarchy%nlevels)) then call output_line ("Invalid level.") return end if p_rfeSpace => p_rfeHierarchy%p_rfeSpaces(ilevel) ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_fesp (rcmdStatus%rcollection, sname, p_rfeSpace, .true.,& ssectionName=ssection) ! Set the user defined tag to 1 to mark this as "shared copy" so that ! no memory is released upon a destroy. call collct_settag(rcmdStatus%rcollection, sname, 1, ssectionName=ssection) ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_extractmeshfromhier (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: EXTRACTMESHFROMHIER. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(3), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_MSHHIERARCHY) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg integer :: ilevel ! local variables character(len=COLLCT_MLNAME) :: sname,ssection type(t_meshhierarchy), pointer :: p_rmeshHierarchy type(t_triangulation), pointer :: p_rtriangulation select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" extractmeshfromhier() - Extract an FE space from a hierarchy.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("extractmeshfromhier - Extract a mesh from a hierarchy.") call output_lbrk () call output_line ("Usage:") call output_line (" extractmeshfromhier ([varname], [varhier], [level])") call output_lbrk () call output_line ("Extracts the mesh of level [level] from the mesh hierarchy [varhier]") call output_line ("and stores it to the variable [varname].") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers sname = Rvalues(1)%svarname ilevel = Rvalues(2)%ivalue nullify(p_rmeshHierarchy) p_rmeshHierarchy => collct_getvalue_mshh (rcmdStatus%rcollection, Rvalues(3)%svarname) ! Get the FE space if ((ilevel .lt. 1) .or. (ilevel .gt. p_rmeshHierarchy%nlevels)) then call output_line ("Invalid level.") return end if p_rtriangulation => p_rmeshHierarchy%p_Rtriangulations(ilevel) ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_tria (rcmdStatus%rcollection, sname, p_rtriangulation, .true.,& ssectionName=ssection) ! Set the user defined tag to 1 to mark this as "shared copy" so that ! no memory is released upon a destroy. call collct_settag(rcmdStatus%rcollection, sname, 1, ssectionName=ssection) ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_extractsubvector (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: extractsubvector. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(3), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_BLKVECTOR) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg integer :: icomponent ! local variables character(len=COLLCT_MLNAME) :: sname,ssection type(t_vectorBlock), pointer :: p_rvectorBlock type(t_vectorScalar), pointer :: p_rvectorScalar select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" extractsubvector() - Extract a subvector from a block vector.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("extractsubvector - Extract a subvector from a block vector.") call output_lbrk () call output_line ("Usage:") call output_line (" extractsubvector ([varname], [vecidx], [varblock])") call output_lbrk () call output_line ("Extracts subvector [vecidx] from the block vector [varblock]") call output_line ("and stores it to the variable [varname].") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers sname = Rvalues(1)%svarname icomponent = Rvalues(2)%ivalue nullify(p_rvectorBlock) p_rvectorBlock => collct_getvalue_vec (rcmdStatus%rcollection, Rvalues(3)%svarname) ! Get the FE space if ((icomponent .lt. 1) .or. (icomponent .gt. p_rvectorBlock%nblocks)) then call output_line ("Invalid component.") return end if p_rvectorScalar => p_rvectorBlock%RvectorBlock(icomponent) ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_vecsca (rcmdStatus%rcollection, sname, p_rvectorScalar, .true.,& ssectionName=ssection) ! Set the user defined tag to 1 to mark this as "shared copy" so that ! no memory is released upon a destroy. call collct_settag(rcmdStatus%rcollection, sname, 1, ssectionName=ssection) ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_mlevelprjhierarchy (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: MLEVELPRJHIERARCHY. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(2), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("fehierarchy", STYPE_VAR, COLLCT_FEHIERARCHY) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables logical :: bexists integer :: i character(len=COLLCT_MLNAME) :: sname,ssection character(len=SYS_STRLEN) :: stoken type(t_feHierarchy), pointer :: p_rfeHierarchy type(t_interlevelProjectionHier), pointer :: p_rprjHier select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" mlevelprjhierarchy() - Create a multilevel projection hierarchy.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("mlevelprjhierarchy - Create an multilevel projection hierarchy.") call output_lbrk () call output_line ("Usage:") call output_line (" mlevelprjhierarchy ([varname] [, ...options...])") call output_lbrk () call output_line ("Creates a multilevel projection hierarchy that can be used to transfer") call output_line ("soltion/rhs vectors from one level to another.") call output_line ("[varname] identifies the variable to create.") call output_line ("The following options are possible in [...options...]:") call output_lbrk () call output_line (" ... fehierarchy=[varname] ...") call output_line (" Create a multilevel projection hierarchy based on the") call output_line (" FE space hierarchy [varname]. Mandatory argument") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers sname = Rvalues(1)%svarname if (Iindex(2) .ne. 0) then ! Get the triangulation object. stoken = Rvalues(Iindex(2))%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rfeHierarchy => collct_getvalue_feh(rcmdStatus%rcollection,stoken,bexists=bexists,ssectionName=ssection) end if if (.not. associated (p_rfeHierarchy)) then call output_line ("Invalid FE hierarchy!") return end if ! Create the fe space. allocate(p_rprjHier) call output_line ("Creating multilevel projection hierarchy.") ! Create the FE space usinf fgetDiscr. call mlprj_initPrjHierarchy(p_rprjHier,1,p_rfeHierarchy%nlevels) do i = 1,p_rfeHierarchy%nlevels call mlprj_initPrjHierarchyLevel(p_rprjHier,i,& p_rfeHierarchy%p_rfeSpaces(i)%p_rdiscretisation) end do call mlprj_commitPrjHierarchy (p_rprjHier) ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_mlprjh (rcmdStatus%rcollection, sname, p_rprjHier, .true.,& ssectionName=ssection) ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_createblockvector (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: CREATEBLOCKVECTOR. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(2), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_FESPACE) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables logical :: bexists character(len=COLLCT_MLNAME) :: sname,ssection character(len=SYS_STRLEN) :: stoken type(t_feSpaceLevel), pointer :: p_rfeSpace type(t_vectorBlock), pointer :: p_rvectorBlock select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" createblockvector() - Create an empty block vector.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("createblockvector - Create an empty block vector.") call output_lbrk () call output_line ("Usage:") call output_line (" createblockvector ([varname],[varfespace])") call output_lbrk () call output_line ("Creates an empty block vector..") call output_line ("[varname] identifies the variable to create.") call output_line ("[varfespace] defines the FE space, the vector is based on.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers sname = Rvalues(1)%svarname stoken = Rvalues(2)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rfeSpace => collct_getvalue_fesp(rcmdStatus%rcollection,stoken,bexists=bexists,ssectionName=ssection) ! Create the vector. allocate(p_rvectorBlock) call lsysbl_createVectorBlock (p_rfeSpace%p_rdiscretisation,p_rvectorBlock,.true.) ! Remove old value from collection if present call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) call do_destroy(rcmdStatus,sname,ssection,.false.) ! Add to the collection call collct_setvalue_vec (rcmdStatus%rcollection, sname, p_rvectorBlock, .true., & ssectionName=ssection) ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_readblockvector (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: READBLOCKVECTOR. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(3), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_BLKVECTOR), & t_varspec("", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("format", STYPE_STRING, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=SYS_STRLEN) :: sfilename character(len=COLLCT_MLNAME) :: sname,ssection character(len=SYS_STRLEN) :: stoken type(t_vectorBlock), pointer :: p_rvectorBlock logical :: bformatted select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" readblockvector() - Read a block vector from a file.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("readblockvector - Read block vector from file.") call output_lbrk () call output_line ("Usage:") call output_line (" readblockvector ([varname],[filename] [,...options...]") call output_lbrk () call output_line ("Read a block vector from a file.") call output_line ("[varname] identifies the variable where to read data to.") call output_line ("[filename] identifies the filename.") call output_line ("The following options are possible in [...options...]:") call output_lbrk () call output_line (" ... format=""unformatted"" ...") call output_line (" Read a binary file. Default is formatted, human readable file.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers sname = Rvalues(1)%svarname call cmdprs_dequoteStd(Rvalues(2)%svalue,sfilename) bformatted = .true. if (Iindex(3) .ne. 0) then call cmdprs_dequoteStd(Rvalues(Iindex(3))%svalue,stoken) bformatted = sys_upcase(stoken) .ne. "UNFORMATTED" end if call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) p_rvectorBlock => collct_getvalue_vec (rcmdStatus%rcollection, sname, ssectionName=ssection) call output_line ("Reading vector: "//trim(sfilename)) call vecio_readBlockVectorHR (p_rvectorBlock, stoken, .true.,& 0, sfilename, bformatted) ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_writeblockvector (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: WRITEBLOCKVECTOR. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(3), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("format", STYPE_STRING, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=SYS_STRLEN) :: sfilename,sformat character(len=COLLCT_MLNAME) :: sname,ssection character(len=SYS_STRLEN) :: stoken type(t_vectorBlock), pointer :: p_rvectorBlock logical :: bformatted select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" writeblockvector() - Write a block vector to a file.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("writeblockvector - Write block vector from file.") call output_lbrk () call output_line ("Usage:") call output_line (" writeblockvector ([varname],[filename] [,...options...]") call output_lbrk () call output_line ("Writes a block vector to a file.") call output_line ("[varname] identifies the variable where to read data to.") call output_line ("[filename] identifies the filename.") call output_line ("The following options are possible in [...options...]:") call output_lbrk () call output_line (" ... format=""unformatted"" ...") call output_line (" Write a binary file. Default is formatted, human readable file.") call output_lbrk () call output_line (" ... format=""(E20.10)"" ...") call output_line (" Write a human readable file with the specified number format.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the identifiers sname = Rvalues(1)%svarname call cmdprs_dequoteStd(Rvalues(2)%svalue,sfilename) bformatted = .true. sformat = "(E20.10)" if (Iindex(3) .ne. 0) then call cmdprs_dequoteStd(Rvalues(Iindex(3))%svalue,stoken) bformatted = sys_upcase(stoken) .ne. "UNFORMATTED" if (bformatted) sformat = stoken end if stoken = Rvalues(2)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,sname,inestlevel,ssection) p_rvectorBlock => collct_getvalue_vec (rcmdStatus%rcollection, sname, ssectionName=ssection) call output_line ("Writing vector: "//trim(sfilename)) if (bformatted) then call vecio_writeBlockVectorHR (p_rvectorBlock, "vector", .true.,& 0, sfilename, sformat) else call vecio_writeBlockVectorHR (p_rvectorBlock, "vector", .true.,& 0, sfilename) end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_copyvector (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: copyvector. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(2), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_STRLEN) :: stoken integer :: ctype1,ctype2 type(t_vectorBlock), pointer :: p_rvectorBlock1,p_rvectorBlock2 type(t_vectorScalar), pointer :: p_rvectorScalar1,p_rvectorScalar2 select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" copyvector() - Copy a vector to another.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("copyvector - Copy a scalar or block vector.") call output_lbrk () call output_line ("Usage:") call output_line (" copyvector ([varsource],[vardest])") call output_lbrk () call output_line ("Copies vector [varsource] to vector [vardest].") call output_line ("The vector may be a full block vector or a single.") call output_line ("subvector.") call output_lbrk () call output_line ("Example:") call output_line (" copyvector (source,dest)") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if stoken = Rvalues(1)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype1 = collct_gettype (rcmdStatus%rcollection, Rvalues(1)%svarname, ssectionName=ssection) if (ctype1 .eq. COLLCT_BLKVECTOR) then p_rvectorBlock1 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) stoken = Rvalues(2)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype2 = collct_gettype (rcmdStatus%rcollection, Rvalues(2)%svarname, ssectionName=ssection) if (ctype2 .ne. COLLCT_BLKVECTOR) then call output_line ("Source and destination not compatible.") return end if p_rvectorBlock2 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) ! Copy! call lsysbl_copyVector (p_rvectorBlock1,p_rvectorBlock2) else if (ctype1 .eq. COLLCT_SCAVECTOR) then p_rvectorScalar1 => collct_getvalue_vecsca (rcmdStatus%rcollection, stoken,& ssectionName=ssection) stoken = Rvalues(2)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype2 = collct_gettype (rcmdStatus%rcollection, Rvalues(2)%svarname, ssectionName=ssection) if (ctype2 .ne. COLLCT_SCAVECTOR) then call output_line ("Source and destination not compatible.") return end if p_rvectorScalar2 => collct_getvalue_vecsca (rcmdStatus%rcollection, stoken,& ssectionName=ssection) ! Copy! call lsyssc_copyVector (p_rvectorScalar1,p_rvectorScalar2) else call output_line ("Invalid source vector.") return end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_interpolatevector (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: interpolate. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(6), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_FEHIERARCHY), & t_varspec("", STYPE_VAR, COLLCT_MLPRJHIERARCHY) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_STRLEN) :: stoken type(t_vectorBlock), pointer :: p_rvectorBlock1,p_rvectorBlock2 type(t_feHierarchy), pointer :: p_rfeHierarchy type(t_interlevelProjectionHier), pointer :: p_rprjHier type(t_vectorBlock), pointer :: p_rtemp1,p_rtemp2 integer :: i,isource,idest select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" interpolatevector() - Interpolate a vector to another level.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("interpolatevector - Interpolate a vector to another level.") call output_lbrk () call output_line ("Usage:") call output_line (" interpolatevector ([varsource],[lvlsource],[vardest],[lvldest],[varhier],[mlprj])") call output_lbrk () call output_line ("Interpolates vector [varsource] from level [lvlsource] to") call output_line ("level [lvldest] and writes the result to [vardest].") call output_line ("[varhier] specifies the FE hierarchy, the level refer to.") call output_line ("[mlprj] specifies the projection hierarchy to be used.") call output_line ("The method uses prolongation/interpolation for the level change.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the variables. stoken = Rvalues(1)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rvectorBlock1 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) isource = Rvalues(2)%ivalue stoken = Rvalues(3)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rvectorBlock2 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) idest = Rvalues(4)%ivalue stoken = Rvalues(5)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rfeHierarchy => collct_getvalue_feh (rcmdStatus%rcollection, stoken,& ssectionName=ssection) stoken = Rvalues(6)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rprjHier => collct_getvalue_mlprjh (rcmdStatus%rcollection, stoken,& ssectionName=ssection) ! Go either up or down - or copy. if (isource .eq. idest) then call lsysbl_copyVector (p_rvectorBlock1,p_rvectorBlock2) else if (isource .lt. idest) then if (isource .eq. idest-1) then ! One prolongation p_rtemp1 => p_rvectorBlock1 else if (.not. associated (p_rfeHierarchy)) then call output_line ("Invalid FE hierarchy!") return end if ! Multiple prolongations allocate (p_rtemp1) call lsysbl_createVectorBlock (p_rvectorBlock1,p_rtemp1,.false.) call lsysbl_copyVector (p_rvectorBlock1,p_rtemp1) ! Create the temp vectors using the FE hierarchy. do i=isource+1,idest-1 allocate (p_rtemp2) call lsysbl_createVectorBlock (p_rfeHierarchy%p_rfeSpaces(i)%p_rdiscretisation,& p_rtemp2,.false.) call mlprj_performProlongationHier (p_rprjHier,& i,p_rtemp1,p_rtemp2) call lsysbl_releaseVector (p_rtemp1) deallocate (p_rtemp1) p_rtemp1 => p_rtemp2 end do end if ! Final prolongation call mlprj_performProlongationHier (p_rprjHier,& idest,p_rtemp1,p_rvectorBlock2) if (isource .eq. idest-1) then ! Cleanup call lsysbl_releaseVector (p_rtemp1) deallocate(p_rtemp1) end if else ! Interpolation. NOT RESTRICTION!!! if (isource-1 .eq. idest) then ! One prolongation p_rtemp1 => p_rvectorBlock1 else if (.not. associated (p_rfeHierarchy)) then call output_line ("Invalid FE hierarchy!") return end if ! Multiple interpolations allocate (p_rtemp1) call lsysbl_createVectorBlock (p_rvectorBlock1,p_rtemp1,.false.) call lsysbl_copyVector (p_rvectorBlock1,p_rtemp1) ! Create the temp vectors using the FE hierarchy. do i=idest-1,isource+1,-1 allocate (p_rtemp2) call lsysbl_createVectorBlock (p_rfeHierarchy%p_rfeSpaces(i)%p_rdiscretisation,& p_rtemp2,.false.) call mlprj_performInterpolationHier (p_rprjHier,& i+1,p_rtemp2,p_rtemp1) call lsysbl_releaseVector (p_rtemp1) deallocate (p_rtemp1) p_rtemp1 => p_rtemp2 end do end if ! Final interpolation call mlprj_performInterpolationHier (p_rprjHier,& idest+1,p_rvectorBlock2,p_rtemp1) if (isource-1 .eq. idest) then ! Cleanup call lsysbl_releaseVector (p_rtemp1) deallocate(p_rtemp1) end if end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** subroutine fcoeff_analytPrj (rdiscretisation, rform, & nelements, npointsPerElement, Dpoints, & IdofsTest, rdomainIntSubset, & Dcoefficients, rcollection) ! Returns values of an FE function in cubature points. type(t_spatialDiscretisation), intent(in) :: rdiscretisation type(t_linearForm), intent(in) :: rform integer, intent(in) :: nelements integer, intent(in) :: npointsPerElement real(DP), dimension(:,:,:), intent(in) :: Dpoints integer, dimension(:,:), intent(in) :: IdofsTest type(t_domainIntSubset), intent(in) :: rdomainIntSubset type(t_collection), intent(inout), optional :: rcollection real(DP), dimension(:,:,:), intent(out) :: Dcoefficients ! local variables integer :: icomponent type(t_vectorBlock), pointer :: p_rvectorBlock ! Get the component and the FE function p_rvectorBlock => rcollection%p_rvectorQuickAccess1 icomponent = rcollection%IquickAccess(1) ! Evaluate the FE function call fevl_evaluate_sim (p_rvectorBlock%RvectorBlock(icomponent), & rdomainIntSubset, DER_FUNC, Dcoefficients, 1) end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_l2projection (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: L2PROJECTION. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(4), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("verbose", STYPE_INTEGER, COLLCT_UNDEFINED), & t_varspec("relerror", STYPE_DOUBLE, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_STRLEN) :: stoken type(t_matrixScalar) :: rmatrixMass integer :: i,ctype logical :: bverbose type(t_collection) :: rcollection type(t_configL2ProjectionByMass) :: rL2ProjectionConfig type(t_vectorBlock), pointer :: p_rvectorBlock1,p_rvectorBlock2 type(t_vectorScalar), pointer :: p_rvectorScalar1,p_rvectorScalar2 select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" l2projection() - Appies an L2 projection to a vector.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("l2projection - Appies an L2 projection to a vector.") call output_lbrk () call output_line ("Usage:") call output_line (" l2projection ([varsource],[vardest] [,...options...])") call output_lbrk () call output_line ("Interpolates vector [varsource] to [vardest] using an") call output_line ("L2-projection.") call output_lbrk () call output_line ("Example:") call output_line (" l2projection (source,dest)") call output_lbrk () call output_line ("The following options are possible in [...options...]:") call output_lbrk () call output_line (" ... verbose==1 ...") call output_line (" Activate/Deactivate verbose output.") call output_lbrk () call output_line (" ... relerror=[error] ...") call output_line (" Defines the relative accuracy of the projection.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the parameters nullify(p_rvectorBlock1) nullify(p_rvectorBlock2) nullify(p_rvectorScalar1) nullify(p_rvectorScalar2) bverbose = .true. if (Iindex(3) .ne. 0) then bverbose = Rvalues(Iindex(3))%ivalue .ne. 0 end if if (Iindex(4) .ne. 0) then rL2ProjectionConfig%depsrel = Rvalues(Iindex(4))%dvalue end if ! Vectors may be block or scalar stoken = Rvalues(1)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype = collct_gettype (rcollection, stoken, ssectionName=ssection) if (ctype .eq. COLLCT_SCAVECTOR) then p_rvectorScalar1 => collct_getvalue_vecsca (rcmdStatus%rcollection, stoken,& ssectionName=ssection) else if (ctype .eq. COLLCT_BLKVECTOR) then p_rvectorBlock1 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) else call output_line ("Invalid source vector") return end if stoken = Rvalues(2)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype = collct_gettype (rcollection, stoken, ssectionName=ssection) if (ctype .eq. COLLCT_SCAVECTOR) then p_rvectorScalar2 => collct_getvalue_vecsca (rcmdStatus%rcollection, stoken,& ssectionName=ssection) else if (ctype .eq. COLLCT_BLKVECTOR) then p_rvectorBlock2 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) else call output_line ("Invalid destination vector") return end if if ((associated(p_rvectorScalar1) .and. .not. associated(p_rvectorScalar2)) .or. & (associated(p_rvectorBlock1) .and. .not. associated(p_rvectorBlock2)) .or. & (associated(p_rvectorScalar2) .and. .not. associated(p_rvectorScalar1)) .or. & (associated(p_rvectorBlock2) .and. .not. associated(p_rvectorBlock1))) then call output_line ("Source and destination vector not compatible.") return end if if (associated(p_rvectorScalar1)) then ! Scalar projection call lsyssc_clearVector (p_rvectorScalar2) if (bverbose) then call output_line ("Creating mass matrix - structure...") end if ! Create a mass matrix in that space call bilf_createMatrixStructure (p_rvectorScalar2%p_rspatialDiscr,& LSYSSC_MATRIX9,rmatrixMass) if (bverbose) then call output_line ("Creating mass matrix - content...") end if call stdop_assembleSimpleMatrix (rmatrixMass,DER_FUNC,DER_FUNC,1.0_DP,.true.) if (bverbose) then call output_line ("Projecting...") end if ! Do the L2 projection. Put the vector in a temporary block vector. allocate (rcollection%p_rvectorQuickAccess1) call lsysbl_createVecFromScalar (p_rvectorScalar1,rcollection%p_rvectorQuickAccess1) rcollection%IquickAccess(1) = 1 call anprj_analytL2projectionByMass (p_rvectorScalar2, rmatrixMass,& fcoeff_analytPrj, rcollection, rL2ProjectionConfig) call lsysbl_releaseVector (rcollection%p_rvectorQuickAccess1) deallocate (rcollection%p_rvectorQuickAccess1) if (bverbose) then call output_line ("Rel. error: "//trim(sys_sdEL(rL2ProjectionConfig%drelError,10))) call output_line ("Abs. error: "//trim(sys_sdEL(rL2ProjectionConfig%dabsError,10))) call output_line ("Iteraions : "//trim(sys_siL(rL2ProjectionConfig%iiterations,10))) end if ! Release the mass matrix call lsyssc_releaseMatrix (rmatrixMass) else ! Block projection. All blocks separately. ! Clear the destination call lsysbl_clearVector (p_rvectorBlock2) ! Loop through the components do i=1,min(p_rvectorBlock1%nblocks,p_rvectorBlock2%nblocks) if (bverbose) then call output_lbrk () call output_line ("Component : "//trim(sys_siL(i,10))) call output_line ("Creating mass matrix - structure...") end if ! Create a mass matrix in that space call bilf_createMatrixStructure (p_rvectorBlock2%p_rblockDiscr%RspatialDiscr(i),& LSYSSC_MATRIX9,rmatrixMass) if (bverbose) then call output_line ("Creating mass matrix - content...") end if call stdop_assembleSimpleMatrix (rmatrixMass,DER_FUNC,DER_FUNC,1.0_DP,.true.) if (bverbose) then call output_line ("Projecting...") end if ! Do the L2 projection rcollection%p_rvectorQuickAccess1 => p_rvectorBlock1 rcollection%IquickAccess(1) = i call anprj_analytL2projectionByMass (p_rvectorBlock2%RvectorBlock(i), rmatrixMass,& fcoeff_analytPrj, rcollection, rL2ProjectionConfig) if (bverbose) then call output_line ("Rel. error: "//trim(sys_sdEL(rL2ProjectionConfig%drelError,10))) call output_line ("Abs. error: "//trim(sys_sdEL(rL2ProjectionConfig%dabsError,10))) call output_line ("Iteraions : "//trim(sys_siL(rL2ProjectionConfig%iiterations,10))) end if ! Release the mass matrix call lsyssc_releaseMatrix (rmatrixMass) end do end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_writeucd (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: writeucd. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(3), parameter :: Rvarspec = & (/ t_varspec("", STYPE_STRING, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_TRIA), & t_varspec("", STYPE_STRING, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_STRLEN) :: sfilename,stype,svecname,sname,stoken type(t_triangulation), pointer :: p_rtriangulation type(t_vectorScalar), pointer :: p_rvectorScalar real(DP), dimension(:), pointer :: p_Ddata1,p_Ddata2,p_Ddata3 type(t_ucdExport) :: rexport integer :: istart,iend,ilength,iparam,ncomponents logical :: bexists integer :: ctype select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" writeucd() - Writes a postprocessing file.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("writeucd - Write a postprocessing file.") call output_lbrk () call output_line ("Usage:") call output_line (" writeucd ([filename],[mesh],[type] [,...options...])") call output_lbrk () call output_line ("Writes a postproceessing file [filename] based on the") call output_line ("mesh [mesh]. [type] specifies the type of the output.") call output_lbrk () call output_line ("Example:") call output_line (" writeucd (""mypostproc.vtk"",mymesh,""vtk"")") call output_lbrk () call output_line ("The following postprocessing output is possible:") call output_lbrk () call output_line (" [type] = ""vtk"": VTK-output") call output_line (" ""gmv"": GMV output") call output_lbrk () call output_line ("The following parameters are available in [...options...]:") call output_lbrk () call output_line (" pointdatascalar=""[name] [vector]""") call output_line (" Writes out subvector of vector [vector]") call output_line (" as scalar array with the name [name]. May be specified") call output_line (" more than once. The data is interpreted in the corner") call output_line (" points of the elements. Example:") call output_line (" pointdatascalar=""vel_y myvec""") call output_lbrk () call output_line (" pointdatavec=""[name] [vector1] [vector2] ...""") call output_line (" Writes out a set of subvectors [vector1] [vector2]...") call output_line (" as a vector field with name [name]. May be specified more than once.") call output_line (" Example:") call output_line (" pointdatavec=""velocity myvec""") call output_lbrk () call output_line (" celldatascalar=""[name] [vector]""") call output_line (" Writes out vector [vector] as scalar array with the name ") call output_line (" [name]. May be specified more than once.") call output_line (" The data is interpreted in the elements.") call output_line (" Example:") call output_line (" celldatascalar=""pressure myvec""") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if call cmdprs_dequoteStd(Rvalues(1)%svalue,sfilename) stoken = Rvalues(2)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) p_rtriangulation => collct_getvalue_tria (rcmdStatus%rcollection, stoken,& ssectionName=ssection) ! Start the output file call cmdprs_dequoteStd(sys_upcase(Rvalues(3)%svalue),stype) if (stype .eq. "VTK") then call ucd_startVTK (rexport,UCD_FLAG_STANDARD,p_rtriangulation,sfilename) else if (stype .eq. "GMV") then call ucd_startGMV (rexport,UCD_FLAG_STANDARD,p_rtriangulation,sfilename) else call output_line ("Unknown output format!") return end if ! Loop through the other arguments do iparam = 4,size(Rvalues) if (Rvalues(iparam)%svartag .eq. "pointdatascalar") then ! Get the data. Ignore if wrong. if (Rvalues(iparam)%ctype .ne. STYPE_STRING) then call output_line ("Ignoring invalid parameter.") cycle end if call cmdprs_dequoteStd(Rvalues(iparam)%svalue,stoken) ! Must have two entries if (cmdprs_counttokens (stoken," ") .ne. 2) then call output_line ("Ignoring invalid parameter.") cycle end if istart = 0 iend = 0 ilength = len_trim(stoken) call cmdprs_nexttoken (stoken,istart,iend,ilength,cseparator=" ") sname = stoken(istart:iend) call cmdprs_nexttoken (stoken,istart,iend,ilength,cseparator=" ") svecname = stoken(istart:iend) ! Check the type call cmdprs_getSymbolSection (rcmdStatus%rcollection,svecname,inestlevel,ssection,bexists) if (.not. bexists) then call output_line ("Ignoring unknown vector: "//trim(svecname)) cycle end if ctype = collct_gettype (rcmdStatus%rcollection, svecname, ssectionName=ssection) if (ctype .ne. COLLCT_SCAVECTOR) then call output_line ("Ignoring unknown type: "//trim(svecname)) cycle end if p_rvectorScalar => collct_getvalue_vecsca (rcmdStatus%rcollection, svecname, & ssectionName=ssection) ! Write the block call spdp_projectToVertices (p_rvectorScalar,p_Ddata1) call ucd_addVariableVertexBased (rexport,trim(sname),UCD_VAR_STANDARD,p_Ddata1) deallocate(p_Ddata1) else if (Rvalues(iparam)%svartag .eq. "pointdatavec") then ! Get the data. Ignore if wrong. if (Rvalues(iparam)%ctype .ne. STYPE_STRING) then call output_line ("Ignoring invalid parameter.") cycle end if call cmdprs_dequoteStd(Rvalues(iparam)%svalue,stoken) ! Must have at most 4 entries if (cmdprs_counttokens (stoken," ") .gt. 4) then call output_line ("Ignoring invalid parameter.") cycle end if ! Must have at most 4 entries if (cmdprs_counttokens (stoken," ") .lt. 2) then call output_line ("Ignoring invalid parameter.") cycle end if ! Up to three components nullify(p_Ddata1) nullify(p_Ddata2) nullify(p_Ddata3) ncomponents = 0 ! Get the name and the components istart = 0 iend = 0 ilength = len_trim(stoken) call cmdprs_nexttoken (stoken,istart,iend,ilength,cseparator=" ") sname = stoken(istart:iend) ! 1st component call cmdprs_nexttoken (stoken,istart,iend,ilength,cseparator=" ") svecname = stoken(istart:iend) ! Check the type call cmdprs_getSymbolSection (rcmdStatus%rcollection,svecname,inestlevel,ssection,bexists) if (.not. bexists) then call output_line ("Ignoring unknown vector: "//trim(svecname)) cycle end if ctype = collct_gettype (rcmdStatus%rcollection, svecname, ssectionName=ssection) if (ctype .ne. COLLCT_SCAVECTOR) then call output_line ("Ignoring unknown type: "//trim(svecname)) cycle end if p_rvectorScalar => collct_getvalue_vecsca (rcmdStatus%rcollection, svecname, & ssectionName=ssection) ! Write the block call spdp_projectToVertices (p_rvectorScalar,p_Ddata1) ncomponents = ncomponents + 1 call cmdprs_nexttoken (stoken,istart,iend,ilength,cseparator=" ") if (istart .ne. 0) then ! 2nd component svecname = stoken(istart:iend) ! Check the type call cmdprs_getSymbolSection (rcmdStatus%rcollection,svecname,inestlevel,ssection,bexists) if (.not. bexists) then call output_line ("Ignoring unknown vector: "//trim(svecname)) cycle end if ctype = collct_gettype (rcmdStatus%rcollection, svecname, ssectionName=ssection) if (ctype .ne. COLLCT_SCAVECTOR) then call output_line ("Ignoring unknown type: "//trim(svecname)) cycle end if p_rvectorScalar => collct_getvalue_vecsca (rcmdStatus%rcollection, svecname, & ssectionName=ssection) ! Write the block call spdp_projectToVertices (p_rvectorScalar,p_Ddata2) ncomponents = ncomponents + 1 call cmdprs_nexttoken (stoken,istart,iend,ilength,cseparator=" ") end if if (istart .ne. 0) then ! 3rd component svecname = stoken(istart:iend) ! Check the type call cmdprs_getSymbolSection (rcmdStatus%rcollection,svecname,inestlevel,ssection,bexists) if (.not. bexists) then call output_line ("Ignoring unknown vector: "//trim(svecname)) cycle end if ctype = collct_gettype (rcmdStatus%rcollection, svecname, ssectionName=ssection) if (ctype .ne. COLLCT_SCAVECTOR) then call output_line ("Ignoring unknown type: "//trim(svecname)) cycle end if p_rvectorScalar => collct_getvalue_vecsca (rcmdStatus%rcollection, svecname, & ssectionName=ssection) ! Write the block call spdp_projectToVertices (p_rvectorScalar,p_Ddata3) ncomponents = ncomponents + 1 call cmdprs_nexttoken (stoken,istart,iend,ilength,cseparator=" ") end if ! Write the block select case (ncomponents) case (1) call ucd_addVarVertBasedVec (rexport,trim(sname),p_Ddata1) deallocate(p_Ddata1) case (2) call ucd_addVarVertBasedVec (rexport,trim(sname),p_Ddata1,p_Ddata2) deallocate(p_Ddata2) deallocate(p_Ddata1) case (3:) call ucd_addVarVertBasedVec (rexport,trim(sname),p_Ddata1,p_Ddata2,p_Ddata3) deallocate(p_Ddata3) deallocate(p_Ddata2) deallocate(p_Ddata1) end select else if (Rvalues(iparam)%svartag .eq. "celldatascalar") then ! Get the data. Ignore if wrong. if (Rvalues(iparam)%ctype .ne. STYPE_STRING) then call output_line ("Ignoring invalid parameter.") cycle end if call cmdprs_dequoteStd(Rvalues(iparam)%svalue,stoken) ! Must have two entries if (cmdprs_counttokens (stoken," ") .ne. 2) then call output_line ("Ignoring invalid parameter.") cycle end if istart = 0 iend = 0 ilength = len_trim(stoken) call cmdprs_nexttoken (stoken,istart,iend,ilength,cseparator=" ") sname = stoken(istart:iend) call cmdprs_nexttoken (stoken,istart,iend,ilength,cseparator=" ") svecname = stoken(istart:iend) ! Check the type call cmdprs_getSymbolSection (rcmdStatus%rcollection,svecname,inestlevel,ssection,bexists) if (.not. bexists) then call output_line ("Ignoring unknown vector: "//trim(svecname)) cycle end if ctype = collct_gettype (rcmdStatus%rcollection, svecname, ssectionName=ssection) if (ctype .ne. COLLCT_SCAVECTOR) then call output_line ("Ignoring unknown type: "//trim(svecname)) cycle end if p_rvectorScalar => collct_getvalue_vecsca (rcmdStatus%rcollection, svecname, & ssectionName=ssection) ! Write the block call spdp_projectToCells (p_rvectorScalar,p_Ddata1) call ucd_addVariableElementBased (rexport,trim(sname),UCD_VAR_STANDARD,p_Ddata1) deallocate(p_Ddata1) end if end do ! Write the file, done. call ucd_write(rexport) call ucd_release(rexport) ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_daxpyvector (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: daxpyvector. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(4), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_DOUBLE, COLLCT_UNDEFINED), & t_varspec("", STYPE_DOUBLE, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_STRLEN) :: stoken integer :: ctype1,ctype2 type(t_vectorBlock), pointer :: p_rvectorBlock1,p_rvectorBlock2 type(t_vectorScalar), pointer :: p_rvectorScalar1,p_rvectorScalar2 real(DP) :: da,dp select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" daxpyvector() - Linear combination of two vectors") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("daxpyvector - Do a linear combination of two vectors.") call output_lbrk () call output_line ("Usage:") call output_line (" daxpyvector ([varsource],[vardest],[da],[dp])") call output_lbrk () call output_line ("Does a DAXPY operation in the following form:") call output_line (" [vardest] = [da]*[varsource] + [dp]*[vardest]") call output_line ("The vectors may be scalar or block.") call output_lbrk () call output_line ("Example:") call output_line (" daxpyvector (source,dest,-1.0,1.0)") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the parameters da = Rvalues(3)%dvalue dp = Rvalues(4)%dvalue stoken = Rvalues(1)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype1 = collct_gettype (rcmdStatus%rcollection, Rvalues(1)%svarname, ssectionName=ssection) if (ctype1 .eq. COLLCT_BLKVECTOR) then p_rvectorBlock1 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) stoken = Rvalues(2)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype2 = collct_gettype (rcmdStatus%rcollection, Rvalues(2)%svarname, ssectionName=ssection) if (ctype2 .ne. COLLCT_BLKVECTOR) then call output_line ("Source and destination not compatible.") return end if p_rvectorBlock2 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) ! Copy! call lsysbl_vectorLinearComb (p_rvectorBlock1,p_rvectorBlock2,da,dp) else if (ctype1 .eq. COLLCT_SCAVECTOR) then p_rvectorScalar1 => collct_getvalue_vecsca (rcmdStatus%rcollection, stoken,& ssectionName=ssection) stoken = Rvalues(2)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype2 = collct_gettype (rcmdStatus%rcollection, Rvalues(2)%svarname, ssectionName=ssection) if (ctype2 .ne. COLLCT_SCAVECTOR) then call output_line ("Source and destination not compatible.") return end if p_rvectorScalar2 => collct_getvalue_vecsca (rcmdStatus%rcollection, stoken,& ssectionName=ssection) ! Copy! call lsyssc_vectorLinearComb (p_rvectorScalar1,p_rvectorScalar2,da,dp) else call output_line ("Invalid source vector.") return end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_clearvector (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: clearvector. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(2), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("value", STYPE_DOUBLE, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_STRLEN) :: stoken integer :: ctype1 type(t_vectorBlock), pointer :: p_rvectorBlock1 type(t_vectorScalar), pointer :: p_rvectorScalar1 real(DP) :: da select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" clearvector() - Clears a vector or overwrites with a value.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("clearvector - Clears a vector or overwrites with a numbert.") call output_lbrk () call output_line ("Usage:") call output_line (" clearvector ([vector])") call output_line (" clearvector ([vector],value=[val])") call output_lbrk () call output_line ("Overwrites [vector] with zero. If [val] is specified,") call output_line ("overwrites the vector with [val].") call output_line ("The vectors may be scalar or block.") call output_lbrk () call output_line ("Example:") call output_line (" clearvector (source)") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the parameters da = 0.0_DP if (Iindex(2) .ne. 0) da = Rvalues(Iindex(2))%dvalue stoken = Rvalues(1)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype1 = collct_gettype (rcmdStatus%rcollection, Rvalues(1)%svarname, ssectionName=ssection) if (ctype1 .eq. COLLCT_BLKVECTOR) then p_rvectorBlock1 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) if (da .eq. 0.0_DP) then call lsysbl_clearVector (p_rvectorBlock1) else call lsysbl_clearVector (p_rvectorBlock1,da) end if else if (ctype1 .eq. COLLCT_SCAVECTOR) then p_rvectorScalar1 => collct_getvalue_vecsca (rcmdStatus%rcollection, stoken,& ssectionName=ssection) if (da .eq. 0.0_DP) then call lsyssc_clearVector (p_rvectorScalar1) else call lsyssc_clearVector (p_rvectorScalar1,da) end if else call output_line ("Invalid vector.") return end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_scalevector (rcmdStatus,inestlevel,rreturn,cexecmode,Rvalues) !<description> ! Command: clearvector. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(2), parameter :: Rvarspec = & (/ t_varspec("", STYPE_VAR, COLLCT_UNDEFINED), & t_varspec("", STYPE_DOUBLE, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables character(len=COLLCT_MLNAME) :: ssection character(len=SYS_STRLEN) :: stoken integer :: ctype1 type(t_vectorBlock), pointer :: p_rvectorBlock1 type(t_vectorScalar), pointer :: p_rvectorScalar1 real(DP) :: da select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return call output_line (" scalevector() - Scales a vector by a value.") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return call output_line ("scalevector - Scales a vector by a value.") call output_lbrk () call output_line ("Usage:") call output_line (" scalevector ([vector],[val])") call output_lbrk () call output_line ("Scales the vector [vector] by the value [val].") call output_line ("The vectors may be scalar or block.") call output_lbrk () call output_line ("Example:") call output_line (" scalevector (source,-1.0)") ! Ok. rreturn%ctype = STYPE_INTEGER return end select ! Check parameters call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then call output_line (serrormsg) return end if ! Get the parameters da = Rvalues(2)%dvalue stoken = Rvalues(1)%svarname call cmdprs_getSymbolSection (rcmdStatus%rcollection,stoken,inestlevel,ssection) ctype1 = collct_gettype (rcmdStatus%rcollection, Rvalues(1)%svarname, ssectionName=ssection) if (ctype1 .eq. COLLCT_BLKVECTOR) then p_rvectorBlock1 => collct_getvalue_vec (rcmdStatus%rcollection, stoken,& ssectionName=ssection) call lsysbl_scaleVector (p_rvectorBlock1,da) else if (ctype1 .eq. COLLCT_SCAVECTOR) then p_rvectorScalar1 => collct_getvalue_vecsca (rcmdStatus%rcollection, stoken,& ssectionName=ssection) call lsyssc_scaleVector (p_rvectorScalar1,da) else call output_line ("Invalid vector.") return end if ! Ok. rreturn%ctype = STYPE_INTEGER end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_mathfunction (rcmdStatus,inestlevel,rreturn,cexecmode,& sfunction,bunknown,Rvalues) !<description> ! Command: simple math function. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode ! String identifying a function. Must be lower case. character(len=*), intent(in) :: sfunction !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn ! Set to TRUE if the command is unknown. logical, intent(out) :: bunknown !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(1), parameter :: Rvarspec1 = & (/ t_varspec("", STYPE_DOUBLE, COLLCT_UNDEFINED) & /) type(t_varspec), dimension(1), parameter :: Rvarspec2 = & (/ t_varspec("", STYPE_INTEGER, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec1)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables real(DP) :: dvalue select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return !call output_line (" scalevector() - Scales a vector by a value.") call output_line (" sin() - ") call output_line (" cos() - ") call output_line (" asin() - ") call output_line (" acos() - ") call output_line (" sinh() - ") call output_line (" cosh() - ") call output_line (" exp() - ") call output_line (" floor() - ") call output_line (" ceil() - ") call output_line (" log() - ") call output_line (" log10() - ") call output_line (" sqrt() - ") call output_line (" abs() - ") call output_line (" tan() - ") call output_line (" tanh() - ") call output_line (" cot() - ") call output_line (" aint() - ") call output_line (" round() - ") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return !call output_line ("scalevector - Scales a vector by a value.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select bunknown = .false. ! Check parameters. 1st try: double value call fcmd_getparameters (Rvarspec1,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (bsuccess) then ! Get the value dvalue = Rvalues(1)%dvalue else ! 2nd try: integer. Type conversion. call fcmd_getparameters (Rvarspec2,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (bsuccess) then ! Get the value dvalue = real(Rvalues(1)%ivalue,dp) else ! Invalid value. bunknown = .true. return end if end if if (sfunction .eq. "sin") then rreturn%dvalue = sin(dvalue) else if (sfunction .eq. "cos") then rreturn%dvalue = cos(dvalue) else if (sfunction .eq. "asin") then rreturn%dvalue = asin(dvalue) else if (sfunction .eq. "acos") then rreturn%dvalue = acos(dvalue) else if (sfunction .eq. "sinh") then rreturn%dvalue = sinh(dvalue) else if (sfunction .eq. "cosh") then rreturn%dvalue = cosh(dvalue) else if (sfunction .eq. "exp") then rreturn%dvalue = exp(dvalue) else if (sfunction .eq. "floor") then rreturn%dvalue = floor(dvalue) else if (sfunction .eq. "ceil") then rreturn%dvalue = ceiling(dvalue) else if (sfunction .eq. "log") then rreturn%dvalue = log(dvalue) else if (sfunction .eq. "log10") then rreturn%dvalue = log10(dvalue) else if (sfunction .eq. "sqrt") then rreturn%dvalue = sqrt(dvalue) else if (sfunction .eq. "abs") then rreturn%dvalue = abs(dvalue) else if (sfunction .eq. "tan") then rreturn%dvalue = tan(dvalue) else if (sfunction .eq. "tanh") then rreturn%dvalue = tanh(dvalue) else if (sfunction .eq. "aint") then rreturn%dvalue = aint(dvalue) else if (sfunction .eq. "round") then rreturn%dvalue = aint(dvalue+0.5_DP) else ! Unknown command bunknown = .true. return end if ! Ok. bunknown = .false. rreturn%ctype = STYPE_DOUBLE end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_simplefunction (rcmdStatus,inestlevel,rreturn,cexecmode,& sfunction,bunknown,Rvalues) !<description> ! Command: simple math function. !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode ! String identifying a function. Must be lower case. character(len=*), intent(in) :: sfunction !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn ! Set to TRUE if the command is unknown. logical, intent(out) :: bunknown !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(1), parameter :: Rvarspec1 = & (/ t_varspec("", STYPE_DOUBLE, COLLCT_UNDEFINED) & /) type(t_varspec), dimension(1), parameter :: Rvarspec2 = & (/ t_varspec("", STYPE_INTEGER, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec1)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables real(DP) :: dvalue select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return !call output_line (" scalevector() - Scales a vector by a value.") call output_line (" double() - ") call output_line (" int() - ") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return !call output_line ("scalevector - Scales a vector by a value.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select bunknown = .false. ! Check parameters. 1st try: double value call fcmd_getparameters (Rvarspec1,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (bsuccess) then ! Get the value dvalue = Rvalues(1)%dvalue else ! 2nd try: integer. Type conversion. call fcmd_getparameters (Rvarspec2,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (bsuccess) then ! Get the value dvalue = real(Rvalues(1)%ivalue,dp) else ! Invalid value. bunknown = .true. return end if end if if (sfunction .eq. "double") then rreturn%dvalue = dvalue rreturn%ctype = STYPE_DOUBLE else if (sfunction .eq. "int") then rreturn%ivalue = int(dvalue) rreturn%ctype = STYPE_INTEGER else ! Unknown command bunknown = .true. return end if end subroutine ! *************************************************************************** !<subroutine> subroutine fcmd_math2function (rcmdStatus,inestlevel,rreturn,cexecmode,& sfunction,bunknown,Rvalues) !<description> ! Command: math function with two arguments !</description> !<inputoutput> ! Current status block. type(t_commandstatus), intent(inout) :: rcmdStatus ! Level of nesting integer, intent(in) :: inestlevel ! Type of execution mode. One of the FCMD_EXECxxxx constants. integer, intent(in) :: cexecmode ! String identifying a function. Must be lower case. character(len=*), intent(in) :: sfunction !</inputoutput> !<input> ! OPTIONAL: Command line arguments. type(t_symbolValue), dimension(:), intent(in), optional :: Rvalues !</input> !<output> ! Return value type(t_symbolValue), intent(inout) :: rreturn ! Set to TRUE if the command is unknown. logical, intent(out) :: bunknown !</output> !</subroutine> ! Command arguments type(t_varspec), dimension(2), parameter :: Rvarspec = & (/ t_varspec("", STYPE_UNDEFINED, COLLCT_UNDEFINED), & t_varspec("", STYPE_UNDEFINED, COLLCT_UNDEFINED) & /) integer, dimension(size(Rvarspec)) :: Iindex logical :: bsuccess character(len=SYS_STRLEN) :: serrormsg ! local variables real(DP) :: dvalue1,dvalue2 select case (cexecmode) case (FCMD_EXECSHORTHELP) ! Print a short help message and return !call output_line (" scalevector() - Scales a vector by a value.") call output_line (" min() - ") call output_line (" max() - ") ! Ok. rreturn%ctype = STYPE_INTEGER return case (FCMD_EXECLONGHELP) ! Print a long help message and return !call output_line ("scalevector - Scales a vector by a value.") ! Ok. rreturn%ctype = STYPE_INTEGER return end select bunknown = .false. ! Check parameters. call fcmd_getparameters (Rvarspec,Iindex,bsuccess,serrormsg,& rcmdStatus%rcollection,inestlevel,Rvalues) if (.not. bsuccess) then ! No error message bunknown = .true. return end if select case (Rvalues(1)%ctype) case (STYPE_INTEGER) dvalue1 = real(Rvalues(1)%ivalue,dp) case (STYPE_DOUBLE) dvalue1 = Rvalues(1)%dvalue case default call output_line ("Invalid type!") return end select select case (Rvalues(2)%ctype) case (STYPE_INTEGER) dvalue2 = real(Rvalues(2)%ivalue,dp) case (STYPE_DOUBLE) dvalue2 = Rvalues(2)%dvalue case default call output_line ("Invalid type!") return end select if (sfunction .eq. "min") then rreturn%dvalue = min(dvalue1,dvalue2) else if (sfunction .eq. "max") then rreturn%dvalue = max(dvalue1,dvalue2) else ! Unknown command bunknown = .true. return end if ! Ok. bunknown = .false. rreturn%ctype = STYPE_DOUBLE end subroutine end module
area51/featcmdline/src/featcommandhandler.f90
!############################################################################## !# **************************************************************************** !# <name> newtoniteration </name> !# **************************************************************************** !# !# <purpose> !# This module realises a (semismooth) Newton iteration in the control !# space of the optimal control problem. !# </purpose> !############################################################################## module newtoniteration use fsystem use genoutput use paramlist use statistics use iterationcontrol use spatialdiscretisation use timediscretisation use linearsystemscalar use linearsystemblock use scalarpde use linearformevaluation use bilinearformevaluation use feevaluation2 use blockmatassemblybase use blockmatassembly use collection use spacetimevectors use analyticsolution use structuresdiscretisation use structuresoptcontrol use structuresgeneral use structuresoptflow use structuresoperatorasm use structuresnewton use assemblytemplates use spacematvecassembly use spacelinearsolver use spacesolver use spacetimehierarchy use spacetimeinterlevelprj use kktsystemspaces use kktsystem use kktsystemhierarchy use postprocessing use newtoniterationlinear implicit none private !<types> !<typeblock> ! Linear solver statistics type t_newtonitSolverStat ! Number of iterations necessary for the solver integer :: niterations = 0 ! Total time necessary for the solver type(t_timer) :: rtotalTime ! Time necessary for solving the nonlinear forward problem type(t_timer) :: rtimeForward ! Time necessary for solving the backward problem type(t_timer) :: rtimeBackward ! Time necessary for the creation of nonlinear defects type(t_timer) :: rtimeDefect ! Time necessary for the prolongation of the solution to all levels type(t_timer) :: rtimeProlRest ! Time necessary for postprocessing type(t_timer) :: rtimePostprocessing ! Statistics of the subsolver in space used for calculating the residual. type(t_spaceslSolverStat) :: rspaceslSolverStat ! Statistics of the linear subsolver type(t_newtonlinSolverStat) :: rnewtonlinSolverStat end type !</typeblock> public :: t_newtonitSolverStat !<typeblock> ! Parameters for the space-time Newton algorithm. type t_spacetimeNewton ! <!-- --------------------------------------- --> ! <!-- GENRERAL PARAMETERS AND SOLVER SETTINGS --> ! <!-- --------------------------------------- --> ! General newton parameters type(t_newtonParameters) :: rnewtonParams ! Iteration control parameters type(t_iterationControl) :: riter ! Parameters of the OptFlow solver type(t_settings_optflow), pointer :: p_rsettingsSolver => null() ! <!-- ----------------------------- --> ! <!-- SUBSOLVERS AND OTHER SETTINGS --> ! <!-- ----------------------------- --> ! Defines a policy how to generate the initial condition of a timestep. ! =0: Always take zero ! =1: Propagate the solution of the previous/next timestep to the ! current one. (Default) ! =2: Take the solution of the last space-time iteration integer :: cspatialInitCondPolicy = SPINITCOND_PREVTIMESTEP ! Whether to postprocess intermediate solutions. ! =1: Calculate functional values, errors,... ! =2: Write postprocessing files with unique filename. ! =3: Calculate functional values, errors,... and ! write postprocessing files with unique filename. integer :: cpostprocessIterates = 1 ! Parameters for the linear space-time subsolver. type(t_linsolParameters) :: rlinsolParam ! KKT subsolver hierarchy which encapsules all subsolvers used ! by the KKT system solvers. type(t_kktSubsolverSet) :: rkktSubsolvers ! <!-- -------------- --> ! <!-- TEMPORARY DATA --> ! <!-- -------------- --> ! Underlying KKT system hierarchy that defines the shape of the solutions. type(t_kktsystemHierarchy), pointer :: p_rkktsystemHierarchy => null() ! Hierarchy of solutions (nonlinearities) for the nonlinear iteration type(t_kktsystemHierarchy), pointer :: p_rsolutionHierarchy => null() ! Hierarchy of directional derivatives. Calculated during the Newton iteration. type(t_kktsystemDirDerivHierarchy), pointer :: p_rdirDerivHierarchy => null() ! Descent direction type(t_controlSpace), pointer :: p_rdescentDir => null() end type !</typeblock> public :: t_spacetimeNewton !</types> ! Basic initialisation of the Newton solver public :: newtonit_init ! Structural initialisation public :: newtonit_initStructure ! Apply a Newton iteration in the control space public :: newtonit_solve ! Cleanup of structures public :: newtonit_doneStructure ! Final cleanup public :: newtonit_done contains ! *************************************************************************** !<subroutine> subroutine newtonit_init (rsolver,rsettingsSolver,ssection,rparamList) !<description> ! Initialises the solver parameters according to a parameter list. !</description> !<input> ! Parameters of the OptFlow solver type(t_settings_optflow), intent(in), target :: rsettingsSolver ! Parameter list with the parameters configuring the nonlinear solver type(t_parlist), intent(in) :: rparamList ! Name of the section in the parameter list containing the parameters ! of the nonlinear solver. character(LEN=*), intent(in) :: ssection !</input> !<output> ! Solver structure receiving the parameters type(t_spacetimeNewton), intent(inout) :: rsolver !</output> !</subroutine> ! local variables character(LEN=SYS_STRLEN) :: ssolverLin ! Remember the solver settings for later use rsolver%p_rsettingsSolver => rsettingsSolver ! Initialise basic parameters call newtonit_initBasicParams (rsolver%rnewtonParams,rsolver%riter,ssection,rparamList) ! Get the sections with the parameters for the nonlinear / linear ! solver in space call parlst_getvalue_int (rparamList, ssection, "cspatialInitCondPolicy", & rsolver%cspatialInitCondPolicy, rsolver%cspatialInitCondPolicy) call parlst_getvalue_int (rparamList, ssection, "cpostprocessIterates", & rsolver%cpostprocessIterates, rsolver%cpostprocessIterates) call parlst_getvalue_string (rparamList, ssection, & "ssectionLinSolverSpaceTime", ssolverLin, "SPACETIME-LINSOLVER",bdequote=.true.) ! Initialise the KKT system subsolvers. ! ! The definition of the lineraised forward/backward equation depends upon ! whether we use the full Newton approach or not. select case (rsolver%rnewtonParams%ctypeIteration) ! -------------- ! Partial Newton ! -------------- case (1) call kkt_initSubsolvers (rsolver%rkktSubsolvers,& rsettingsSolver,ssection,rparamList,0) ! ---------------------------- ! Full Newton, adaptive Newton ! ---------------------------- case (2,3) call kkt_initSubsolvers (rsolver%rkktSubsolvers,& rsettingsSolver,ssection,rparamList,1) case default call output_line ("Invalid nonlinear iteration",& OU_CLASS_ERROR,OU_MODE_STD,"newtonit_init") call sys_halt() end select ! Initialise the linear subsolver call newtonlin_init (rsolver%rlinsolParam,rsettingsSolver,& rsolver%rkktSubsolvers,rparamList,ssolverLin) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_getResidual (rsolver,rkktsystem,rresidual,dres,iresnorm,rstatistics) !<description> ! Calculates the basic (unprecondiotioned) search direction of the ! Newton algorithm. !</description> !<input> ! Type of norm. A LINALG_NORMxxxx constant. integer, intent(in) :: iresnorm !</input> !<inputoutput> ! Parameters for the Newton iteration. type(t_spacetimeNewton), intent(inout) :: rsolver ! Structure defining the KKT system. The control in this structure ! defines the current "state" of the Newton algorithm. ! On output, the primal and dual solution are updated. type(t_kktsystem), intent(inout) :: rkktsystem ! On output, this structure receives a representation of the search ! direction / residual in the Newton iteration. type(t_controlSpace), intent(inout) :: rresidual !</inputoutput> !<output> ! Statistic structure. type(t_newtonitSolverStat), intent(out) :: rstatistics ! L2-Norm of the residual real(DP), intent(out) :: dres !</output> !</subroutine> ! local variables type(t_vectorBlock), pointer :: p_rvector real(DP), dimension(:), pointer :: p_Ddata type(t_spaceslSolverStat) :: rlocalStat call stat_startTimer (rstatistics%rtotalTime) call sptivec_getVectorFromPool(rkktsystem%p_rcontrol%p_rvectorAccess,1,p_rvector) call lsysbl_getbase_double (p_rvector,p_Ddata) ! ------------------------------------------------------------- ! Step 1: Solve the primal system ! ------------------------------------------------------------- if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_line ("Nonlin. space-time Residual: Solving the primal equation") end if ! Solve the primal equation, update the primal solution. output_iautoOutputIndent = output_iautoOutputIndent + 2 call kkt_solvePrimal (rkktsystem,& rsolver%cspatialInitCondPolicy,rsolver%rkktSubsolvers,rlocalStat) output_iautoOutputIndent = output_iautoOutputIndent - 2 call spacesl_sumStatistics(rlocalStat,rstatistics%rspaceslSolverStat) if (rsolver%rnewtonParams%ioutputLevel .ge. 3) then call output_line ("Nonlin. space-time Residual: Time for solving : "//& trim(sys_sdL(rlocalStat%rtotalTime%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for space-defects: "//& trim(sys_sdL(rlocalStat%rtimeDefect%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for space-RHS : "//& trim(sys_sdL(rlocalStat%rtimeRHS%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for mat. assembly: "//& trim(sys_sdL(rlocalStat%rtimeMatrixAssembly%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for factorisation: "//& trim(sys_sdL(rlocalStat%rlssSolverStat%rtimeSymbolicFactorisation%delapsedReal+& rlocalStat%rlssSolverStat%rtimeNumericFactorisation%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for space-solver : "//& trim(sys_sdL(rlocalStat%rlssSolverStat%rtotalTime%delapsedReal,10))) end if ! Add time to the time of the forward equation call stat_addTimers (rlocalStat%rtotalTime,rstatistics%rtimeForward) ! ------------------------------------------------------------- ! Step 2: Solve the dual system ! ------------------------------------------------------------- if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_line ("Nonlin. space-time Residual: Solving the dual equation") end if ! Solve the dual equation, update the dual solution. output_iautoOutputIndent = output_iautoOutputIndent + 2 call kkt_solveDual (rkktsystem,& rsolver%cspatialInitCondPolicy,rsolver%rkktSubsolvers,rlocalStat) output_iautoOutputIndent = output_iautoOutputIndent - 2 call spacesl_sumStatistics(rlocalStat,rstatistics%rspaceslSolverStat) ! Add time to the time of the backward equation call stat_addTimers (rlocalStat%rtotalTime,rstatistics%rtimeBackward) if (rsolver%rnewtonParams%ioutputLevel .ge. 3) then call output_line ("Nonlin. space-time Residual: Time for solving : "//& trim(sys_sdL(rlocalStat%rtotalTime%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for space-defects: "//& trim(sys_sdL(rlocalStat%rtimeDefect%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for space-RHS : "//& trim(sys_sdL(rlocalStat%rtimeRHS%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for mat. assembly: "//& trim(sys_sdL(rlocalStat%rtimeMatrixAssembly%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for factorisation: "//& trim(sys_sdL(rlocalStat%rlssSolverStat%rtimeSymbolicFactorisation%delapsedReal+& rlocalStat%rlssSolverStat%rtimeNumericFactorisation%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for space-solver : "//& trim(sys_sdL(rlocalStat%rlssSolverStat%rtotalTime%delapsedReal,10))) end if ! ------------------------------------------------------------- ! Step 3: Calculate the intermediate control and the search direction ! ------------------------------------------------------------- ! The search direction is just the residual in the control equation. call kkt_calcControlRes (rkktsystem,rresidual,dres,iresnorm,& rsolver%rkktSubsolvers,rlocalStat) call spacesl_sumStatistics(rlocalStat,rstatistics%rspaceslSolverStat) call stat_stopTimer (rstatistics%rtotalTime) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_updateControl (rsolver,rkktsystem,rcorrection) !<description> ! Calculates the basic (unprecondiotioned) search direction of the ! Newton algorithm. !</description> !<input> ! Parameters for the Newton iteration. ! The output parameters are changed according to the iteration. type(t_spacetimeNewton), intent(in) :: rsolver ! The preconditioned search direction type(t_controlSpace), intent(inout) :: rcorrection !</input> !<inputoutput> ! Structure defining the KKT system. The control in this structure ! is updated according to the search direction. type(t_kktsystem), intent(inout) :: rkktsystem !</inputoutput> !</subroutine> ! Impose active set conditions to the correction. ! As a result, we get a correction which, when being added to the solution, ! gives the bounds on the active set. ! Gives currently worse results for sigma=1. The nonlinear residual always jumps ! up before going down. Probably, this has an error or has to be after ! the linear combination below? I do not know. call kkt_imposeActiveSetConditions (rkktsystem,rsolution=rkktsystem%p_rcontrol,& rcorrection=rcorrection) ! Type of step length control select case (rsolver%rnewtonParams%radaptiveNewton%cstepLengthStrategy) case (0) ! No step length control ! ! u_n+1 = u_n + omega g_n ! ! with omega from the solver structure. call kktsp_controlLinearComb (& rcorrection,rsolver%rnewtonParams%domega,rkktsystem%p_rcontrol,1.0_DP) case (1) ! The first nstepLengthSteps iterations, take the alternative step length. ! Then, switch to full Newton. if (rsolver%riter%niterations .lt. rsolver%rnewtonParams%radaptiveNewton%nstepLengthSteps) then call output_line ("Step length strategy 1: Using step length domega = "//& trim(sys_sdEL(rsolver%rnewtonParams%radaptiveNewton%dstepLengthOmega,10))) call kktsp_controlLinearComb (& rcorrection,rsolver%rnewtonParams%radaptiveNewton%dstepLengthOmega,& rkktsystem%p_rcontrol,1.0_DP) else call output_line ("Step length strategy 1: Using step length domega = "//& trim(sys_sdEL(rsolver%rnewtonParams%domega,10))) call kktsp_controlLinearComb (& rcorrection,rsolver%rnewtonParams%domega,rkktsystem%p_rcontrol,1.0_DP) end if end select end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_smoothIterate (rsolver,rkktsystem,rstatistics) !<description> ! Applies smoothing to the current control !</description> !<inputoutput> ! Parameters for the Newton iteration. type(t_spacetimeNewton), intent(inout) :: rsolver ! Structure defining the KKT system. The control in this structure ! defines the current "state" of the Newton algorithm. ! On output, the primal and dual solution are updated. type(t_kktsystem), intent(inout) :: rkktsystem !</inputoutput> !<output> ! Statistic structure. type(t_newtonitSolverStat), intent(out) :: rstatistics !</output> !</subroutine> ! local variables type(t_vectorBlock), pointer :: p_rvector real(DP), dimension(:), pointer :: p_Ddata type(t_spaceslSolverStat) :: rlocalStat call stat_startTimer (rstatistics%rtotalTime) call sptivec_getVectorFromPool(rkktsystem%p_rcontrol%p_rvectorAccess,1,p_rvector) call lsysbl_getbase_double (p_rvector,p_Ddata) ! ------------------------------------------------------------- ! Step 1: Solve the primal system ! ------------------------------------------------------------- if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_line ("Nonlinear Smoothing: Solving the primal equation") end if ! Solve the primal equation, update the primal solution. output_iautoOutputIndent = output_iautoOutputIndent + 2 call kkt_solvePrimal (rkktsystem,& rsolver%cspatialInitCondPolicy,rsolver%rkktSubsolvers,rlocalStat) output_iautoOutputIndent = output_iautoOutputIndent - 2 call spacesl_sumStatistics(rlocalStat,rstatistics%rspaceslSolverStat) if (rsolver%rnewtonParams%ioutputLevel .ge. 3) then call output_line ("Nonlin. space-time Residual: Time for solving : "//& trim(sys_sdL(rlocalStat%rtotalTime%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for space-defects: "//& trim(sys_sdL(rlocalStat%rtimeDefect%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for space-RHS : "//& trim(sys_sdL(rlocalStat%rtimeRHS%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for mat. assembly: "//& trim(sys_sdL(rlocalStat%rtimeMatrixAssembly%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for factorisation: "//& trim(sys_sdL(rlocalStat%rlssSolverStat%rtimeSymbolicFactorisation%delapsedReal+& rlocalStat%rlssSolverStat%rtimeNumericFactorisation%delapsedReal,10))) call output_line ("Nonlin. space-time Residual: Time for space-solver : "//& trim(sys_sdL(rlocalStat%rlssSolverStat%rtotalTime%delapsedReal,10))) end if ! Add time to the time of the forward equation call stat_addTimers (rlocalStat%rtotalTime,rstatistics%rtimeForward) ! ------------------------------------------------------------- ! Step 2: Solve the dual system ! ------------------------------------------------------------- if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_line ("Nonlinear Smoothing: Solving the dual equation") end if ! Solve the dual equation, update the dual solution. output_iautoOutputIndent = output_iautoOutputIndent + 2 call kkt_solveDual (rkktsystem,& rsolver%cspatialInitCondPolicy,rsolver%rkktSubsolvers,rlocalStat) output_iautoOutputIndent = output_iautoOutputIndent - 2 call spacesl_sumStatistics(rlocalStat,rstatistics%rspaceslSolverStat) ! Add time to the time of the backward equation call stat_addTimers (rlocalStat%rtotalTime,rstatistics%rtimeBackward) if (rsolver%rnewtonParams%ioutputLevel .ge. 3) then call output_line ("Nonlinear Smoothing: Time for solving : "//& trim(sys_sdL(rlocalStat%rtotalTime%delapsedReal,10))) call output_line ("Nonlinear Smoothing: Time for space-defects: "//& trim(sys_sdL(rlocalStat%rtimeDefect%delapsedReal,10))) call output_line ("Nonlinear Smoothing: Time for space-RHS : "//& trim(sys_sdL(rlocalStat%rtimeRHS%delapsedReal,10))) call output_line ("Nonlinear Smoothing: Time for mat. assembly: "//& trim(sys_sdL(rlocalStat%rtimeMatrixAssembly%delapsedReal,10))) call output_line ("Nonlinear Smoothing: Time for factorisation: "//& trim(sys_sdL(rlocalStat%rlssSolverStat%rtimeSymbolicFactorisation%delapsedReal+& rlocalStat%rlssSolverStat%rtimeNumericFactorisation%delapsedReal,10))) call output_line ("Nonlinear Smoothing: Time for space-solver : "//& trim(sys_sdL(rlocalStat%rlssSolverStat%rtotalTime%delapsedReal,10))) end if ! ------------------------------------------------------------- ! Step 3: Calculate the control ! ------------------------------------------------------------- call kkt_dualToControl (rkktsystem,rkktsystem%p_rcontrol,rsolver%rkktSubsolvers,rlocalStat) call spacesl_sumStatistics(rlocalStat,rstatistics%rspaceslSolverStat) call stat_stopTimer (rstatistics%rtotalTime) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_adNewton_setEps (rsolver,radNewtonParams,dresInit,dresLastIte) !<description> ! Realises the adaptive Newton algorithm. Sets the stopping criterions of ! all solvers to appropriate values. ! ! WARNING!!! THIS ROUTINE HAS A SIDE EFFECT! ! IT SETS THE STOPPING CRITERION OF ALL SOLVERS IN SPACE TO AN APPROPRIATE ! VALUE! IF THE SPACE SOVLERS AE USED SOMEWHERE ELSE, THE STOPPING CRITERION ! IS LOST AND THUS, THEY MAY BEHAVE NOT AS EXPECTED!!! !</description> !<input> ! Parameters of the adaptive Newton algotithm. type(t_ccDynamicNewtonControl), intent(in) :: radNewtonParams ! Initial residual. ! May be set to 0.0 if there is no initial residual. real(DP), intent(in) :: dresInit ! Residual obtained in the last nonlinear iteration. ! In the first call, this should be set to dresInit. real(DP), intent(in) :: dresLastIte !</input> !<inputoutput> ! Parameters for the Newton iteration. ! The output parameters are changed according to the iteration. type(t_spacetimeNewton), intent(inout) :: rsolver !</inputoutput> !</subroutine> real(DP) :: depsAbs,depsRel,ddigitsGained, ddigitsToGain if ((dresInit .eq. 0.0_DP) .and. (dresLastIte .eq. 0.0_DP)) then ! Gain two digits for the initial residual, that is enough depsAbs = 0.0_DP depsRel = 1.0E-2_DP if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_line ("Adaptive Newton: New stopping criterion. ||res_rel|| < "//& trim(sys_sdEL(depsRel,10))) end if else ! We have to determine a new dresAbs for all solver components: ! - At least, gain as many digits as configured in the adaptive-Newton ! structure has to be gained ! - The number of digits to gain in the next iteration has to be an ! appropriate multiple of the digits already gained. ! So... ddigitsGained = dresLastIte/dresInit ddigitsToGain = min(radNewtonParams%dinexactNewtonTolRel*ddigitsGained,& ddigitsGained ** radNewtonParams%dinexactNewtonExponent) depsRel = 0.0_DP depsAbs = max(dresInit * ddigitsToGain,radNewtonParams%dinexactNewtonTolAbs) ! Do not gain too much. depsAbs = max(depsAbs,& max(dresInit * rsolver%riter%dtolrel * radNewtonParams%dinexactNewtonTolRel,& rsolver%riter%dtolabs * radNewtonParams%dinexactNewtonTolRel)) if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_line ("Adaptive Newton: New stopping criterion. ||res|| < "//& trim(sys_sdEL(depsAbs,10))) end if end if ! Initialise the linear subsolver(s). call newtonlin_adNewton_setEps (rsolver%rlinsolParam,depsAbs,depsRel) ! Initialise the nonlinear and linear solver in space which are used ! for the calvulation of the current residual. !call spaceslh_setEps (rsolver%p_rsolverHierPrimal,depsAbs,depsRel) !call spaceslh_setEps (rsolver%p_rsolverHierDual,depsAbs,depsRel) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_solve (rsolver,rsolution,rstatistics) !<description> ! Applies a Newton iteration to solve the space-time system. !</description> !<inputoutput> ! Parameters for the Newton iteration. ! The output parameters are changed according to the iteration. type(t_spacetimeNewton), intent(inout) :: rsolver ! Structure defining the solutions of the KKT system. type(t_kktsystem), intent(inout), target :: rsolution !</inputoutput> !<output> ! Statistic structure which receives the statistics of the iteration. type(t_newtonitSolverStat), intent(out) :: rstatistics !</output> !</subroutine> ! local variables type(t_controlSpace), pointer :: p_rdescentDir type(t_kktsystem), pointer :: p_rsolution type(t_kktsystemDirDeriv), pointer :: p_rsolutionDirDeriv type(t_timer) :: rtotalTime type(t_newtonlinSolverStat) :: rstatisticsLinSol real(DP) :: delapsedReal, dres type(t_newtonitSolverStat) :: rlocalStat integer :: ismooth ! Measure the total computational time call stat_startTimer(rtotalTime) ! Initialise data for the nonlinear iteration call newtonit_initData (rsolver,rsolution) ! Get a pointer to the solution and directional derivative on the maximum level call kkth_getKKTsystem (rsolver%p_rsolutionHierarchy,0,p_rsolution) call kkth_getKKTsystemDirDeriv (rsolver%p_rdirDerivHierarchy,0,p_rsolutionDirDeriv) ! Temporary vector(s) p_rdescentDir => rsolver%p_rdescentDir ! Prepare a structure that encapsules the directional derivative. ! Apply the Newton iteration call itc_initIteration(rsolver%riter) !rsolver%p_rsettingsSolver%rsettingsOptControl%rconstraints%rconstraintsDistCtrl%cconstraints = 0 do while (.true.) ! The Newton iteration reads ! ! u_n+1 = u_n - [J''(u_n)]^-1 J'(u_n) ! ! or in other words, ! ! u_n+1 = u_n + [J''(u_n)]^-1 d_n ! ! with the residual d_n = -J'(u_n) specifying a "search direction". ! ------------------------------------------------------------- ! Get the current residual / search direction ! ------------------------------------------------------------- if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_line ("Space-time Newton: Calculating the residual") end if ! Compute the basic (unpreconditioned) search direction d_n. output_iautoOutputIndent = output_iautoOutputIndent + 2 call newtonit_getResidual (rsolver,p_rsolution,p_rdescentDir,& dres,rsolver%rnewtonParams%iresnorm,rlocalStat) output_iautoOutputIndent = output_iautoOutputIndent - 2 call newtonit_sumStatistics(rlocalStat,rstatistics,.false.) call stat_addTimers (rlocalStat%rtotalTime,rstatistics%rtimeDefect) if (rsolver%riter%cstatus .eq. ITC_STATUS_UNDEFINED) then ! Remember the initial residual call itc_initResidual(rsolver%riter,dres) else ! Push the residual, increase the iteration counter call itc_pushResidual(rsolver%riter,dres) end if if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_line ("Space-time Newton: Iteration "// & trim(sys_siL(rsolver%riter%niterations,10))// & ", ||res(u)|| = "// & trim(sys_sdEL(dres,10))) end if ! ------------------------------------------------------------- ! Check for convergence ! ------------------------------------------------------------- if (rsolver%riter%cstatus .ne. ITC_STATUS_CONTINUE) exit ! ------------------------------------------------------------- ! Postprocessing. ! It has to be after newtonit_getResidual as newtonit_getResidual ! computes the corresponding y/lambda to the control u. ! We do it after the residual checks, so the final solution ! is not postprocessed. ! ------------------------------------------------------------- if (rsolver%cpostprocessIterates .ge. 0) then call output_separator (OU_SEP_MINUS) call stat_startTimer (rstatistics%rtimePostprocessing) call optcpp_postprocessSubstep (rsolver%p_rsettingsSolver%rpostproc,& rsolver%p_rsettingsSolver%rspaceTimeHierPrimal%p_rfeHierarchy%nlevels,& rsolver%p_rsettingsSolver%rspaceTimeHierPrimal%p_rtimeHierarchy%nlevels,& p_rsolution,rsolver%rkktSubsolvers,rsolver%p_rsettingsSolver,& rsolver%cpostprocessIterates,rsolver%riter%niterations) call stat_stopTimer (rstatistics%rtimePostprocessing) call output_separator (OU_SEP_MINUS) end if ! ------------------------------------------------------------- ! Adaptive Newton for the next iteration? ! ------------------------------------------------------------- if (rsolver%rnewtonParams%ctypeIteration .eq. 3) then call newtonit_adNewton_setEps (& rsolver,rsolver%rnewtonParams%radaptiveNewton,& rsolver%riter%dresInitial,rsolver%riter%dresFinal) end if ! ------------------------------------------------------------- ! Partial Newton for the next iteration? ! ------------------------------------------------------------- ! By default use partial Newton. if (rsolver%rnewtonParams%ctypeIteration .eq. 1) then rsolver%rlinsolParam%ceqnflags = SPACESLH_EQNF_NONEWTON else select case (rsolver%rnewtonParams%radaptiveNewton%cpartialNewton) case (NEWTN_PN_FULLNEWTON) rsolver%rlinsolParam%ceqnflags = SPACESLH_EQNF_DEFAULT if (rsolver%riter%niterations .le. 1) then call output_line (& "Partial Newton not used. Better use partial Newton (dual) in the first step!",& OU_CLASS_WARNING,OU_MODE_STD,"newtonit_solve") end if case (NEWTN_PN_PARTIALNEWTON) rsolver%rlinsolParam%ceqnflags = SPACESLH_EQNF_NONEWTON case (NEWTN_PN_PARTIALNEWTONDUAL) rsolver%rlinsolParam%ceqnflags = SPACESLH_EQNF_NONEWTONDUAL end select ! Should we switch to full Newton? if (rsolver%rnewtonParams%radaptiveNewton%cpartialNewton .ne. NEWTN_PN_FULLNEWTON) then if (rsolver%riter%niterations .gt. & rsolver%rnewtonParams%radaptiveNewton%nmaxPartialNewtonIterations) then ! Full Newton rsolver%rlinsolParam%ceqnflags = SPACESLH_EQNF_DEFAULT else if (rsolver%riter%niterations .ge. & rsolver%rnewtonParams%radaptiveNewton%nminPartialNewtonIterations) then ! We are allowed to switch to the full Newton if some conditions ! are met. if (rsolver%rnewtonParams%radaptiveNewton%dtolAbsPartialNewton .gt. 0.0_DP) then ! Check the absolute residual if (dres .le. rsolver%rnewtonParams%radaptiveNewton%dtolAbsPartialNewton) then rsolver%rlinsolParam%ceqnflags = SPACESLH_EQNF_DEFAULT end if end if if (rsolver%rnewtonParams%radaptiveNewton%dtolRelPartialNewton .gt. 0.0_DP) then ! Check the relative residual if (dres .le. rsolver%rnewtonParams%radaptiveNewton%dtolRelPartialNewton* & rsolver%riter%dresInitial) then rsolver%rlinsolParam%ceqnflags = SPACESLH_EQNF_DEFAULT end if end if end if end if end if ! Print out the choice if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then select case (rsolver%rlinsolParam%ceqnflags) case (SPACESLH_EQNF_DEFAULT) call output_line ("Space-time Newton: Full Newton selected.") case (SPACESLH_EQNF_NONEWTON) call output_line ("Space-time Newton: Partial Newton for primal and dual equation selected.") case (SPACESLH_EQNF_NONEWTONDUAL) call output_line ("Space-time Newton: Partial Newton for dual equation selected.") end select end if ! ------------------------------------------------------------- ! Preconditioning with the Newton matrix ! ------------------------------------------------------------- if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_line ("Space-time Newton: Preconditioning") end if ! Initialise data arrays in the linear subsolver. call stat_startTimer(rstatistics%rtimeProlRest) call newtonlin_initNonlinearData (rsolver%rlinsolParam,rsolver%p_rsolutionHierarchy) call stat_stopTimer(rstatistics%rtimeProlRest) call newtonlin_initData (rsolver%rlinsolParam,rsolver%p_rsolutionHierarchy) ! Actual Newton iteration. Apply the Newton preconditioner ! to get the Newton search direction: ! ! J''(u_n) g_n = d_n ! ! The control on the maximum level of p_rdirDerivHierarchy ! (identified by p_rsolutionDirDeriv%p_rcontrolLin) receives the result. output_iautoOutputIndent = output_iautoOutputIndent + 2 call newtonlin_precond (rsolver%rlinsolParam,& rsolver%p_rdirDerivHierarchy,p_rdescentDir,rstatisticsLinSol) output_iautoOutputIndent = output_iautoOutputIndent - 2 ! Statistics call newtonlin_sumStatistics (& rstatisticsLinSol,rstatistics%rnewtonlinSolverStat,NLIN_STYPE_LINSOL) ! Clean up data in the linear subsolver call newtonlin_doneData (rsolver%rlinsolParam) ! ------------------------------------------------------------- ! Update of the solution ! ------------------------------------------------------------- ! Update the control according to the search direction: ! ! u_n+1 = u_n + g_n ! ! or to any configured step-length control rule. call newtonit_updateControl (& rsolver,p_rsolution,p_rsolutionDirDeriv%p_rcontrolLin) ! Perform a couple of smoothing steps if desired. do ismooth = 1,rsolver%rnewtonParams%radaptiveNewton%nsmoothingSteps ! This is just: Calculate primal, calculate dual, calculate control from the dual. call newtonit_smoothIterate (rsolver,p_rsolution,rstatistics) end do ! ! DEBUG!!! ! call kktsp_dualLinearComb (& ! p_rsolutionDirDeriv%p_rdualSolLin,p_rsolution%p_rdualSol,1.0_DP,1.0_DP) ! call kkt_calcControlRes (p_rsolution,p_rdescentDir,& ! rsolver%rnewtonParams%dresFinal,rsolver%rnewtonParams%iresnorm) ! !-> dres = u+du + 1/alpha (lambda+dlambda) =0 -> is ok! ! ------------------------------------------------------------- ! Proceed with the next iteration ! ------------------------------------------------------------- if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_separator (OU_SEP_MINUS) call output_line ("Space-time Newton: Time for the linear solver = "//& sys_sdL(rstatisticsLinSol%rtotalTime%delapsedReal,10)) call stat_sampleTimer(rtotalTime,delapsedReal) call output_line ("Space-time Newton: Computation time = "//& sys_sdL(delapsedReal,10)) end if call output_separator (OU_SEP_MINUS) !rsolver%p_rsettingsSolver%rsettingsOptControl%rconstraints%rconstraintsDistCtrl%cconstraints = 1 end do ! Release data call newtonit_doneData (rsolver) call stat_stopTimer(rtotalTime) call stat_addTimers(rtotalTime,rstatistics%rtotalTime) rstatistics%niterations = rstatistics%niterations + rsolver%riter%niterations ! Statistics if (rsolver%rnewtonParams%ioutputLevel .ge. 2) then call output_lbrk() call output_line ("Space-time Newton: Statistics.") call output_lbrk() call itc_printStatistics(rsolver%riter) end if end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_initStructure (rsolver,rkktsystemHierarchy,& rprjHierSpaceTimePrimal,rprjHierSpaceTimeDual,rprjHierSpaceTimeControl) !<description> ! Structural initialisation of the Newton solver. !</description> !<input> ! Defines the basic hierarchy of the solutions of the KKT system. ! This can be a "template" structure, i.e., memory for the solutions ! in rkktsystemHierarchy does not have to be allocated. type(t_kktsystemHierarchy), intent(in), target :: rkktsystemHierarchy ! Projection hierarchy for the interlevel projection in space/time, primal space. type(t_sptiProjHierarchyBlock), intent(in), target :: rprjHierSpaceTimePrimal ! Projection hierarchy for the interlevel projection in space/time, dual space. type(t_sptiProjHierarchyBlock), intent(in), target :: rprjHierSpaceTimeDual ! Projection hierarchy for the interlevel projection in space/time, control space. type(t_sptiProjHierarchyBlock), intent(in), target :: rprjHierSpaceTimeControl !</input> !<inputoutput> ! Structure to be initialised. type(t_spacetimeNewton), intent(inout) :: rsolver !</inputoutput> !</subroutine> ! Remember the structure of the solutions. rsolver%p_rkktsystemHierarchy => rkktsystemHierarchy ! Initialise the structures of the linear subsolver. call newtonlin_initStructure (rsolver%rlinsolParam,rkktsystemHierarchy,& rprjHierSpaceTimePrimal,rprjHierSpaceTimeDual,rprjHierSpaceTimeControl) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_initData (rsolver,rsolution) !<description> ! Final preparation of the Newton solver. !</description> !<input> ! Structure defining the solutions of the KKT system. type(t_kktsystem), intent(in), target :: rsolution !</input> !<inputoutput> ! Structure to be initialised. type(t_spacetimeNewton), intent(inout) :: rsolver !</inputoutput> !</subroutine> ! Allocate memory for the descent direction vector allocate(rsolver%p_rdescentDir) ! Create a vector holding the descent direction (highest level) call kkth_initControl (rsolver%p_rdescentDir,rsolver%p_rkktsystemHierarchy,0) ! Create temporary memory for the nonlinearity and the search direction. allocate(rsolver%p_rsolutionHierarchy) call kkth_initHierarchy (rsolver%p_rsolutionHierarchy,& rsolver%p_rkktsystemHierarchy%p_roperatorAsmHier,& rsolver%p_rkktsystemHierarchy%p_rspaceTimeHierPrimal,& rsolver%p_rkktsystemHierarchy%p_rspaceTimeHierDual,& rsolver%p_rkktsystemHierarchy%p_rspaceTimeHierControl,.true.,& rsolver%p_rsettingsSolver%roptcBDC,rsolution) ! create tempoprary memory for the search direction connected with ! the above solution hierarchy. allocate(rsolver%p_rdirDerivHierarchy) call kkth_initHierarchyDirDeriv (& rsolver%p_rdirDerivHierarchy,rsolver%p_rsolutionHierarchy) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_doneData (rsolver) !<description> ! Cleanup of the data initalised in newtonit_initData. !</description> !<inputoutput> ! Structure to be cleaned up. type(t_spacetimeNewton), intent(inout) :: rsolver !</inputoutput> !</subroutine> ! Release the descent direction, memory for the directional derivative,... call kktsp_doneControlVector (rsolver%p_rdescentDir) deallocate(rsolver%p_rdescentDir) call kkth_doneHierarchyDirDeriv (rsolver%p_rdirDerivHierarchy) deallocate(rsolver%p_rdirDerivHierarchy) call kkth_doneHierarchy (rsolver%p_rsolutionHierarchy) deallocate(rsolver%p_rsolutionHierarchy) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_doneStructure (rsolver) !<description> ! Cleanup of the data initalised in newtonit_initStructure. !</description> !<inputoutput> ! Structure to be cleaned up. type(t_spacetimeNewton), intent(inout) :: rsolver !</inputoutput> !</subroutine> ! Release structures in the subsolver call newtonlin_doneStructure (rsolver%rlinsolParam) ! Detach the solution structure nullify(rsolver%p_rkktsystemHierarchy) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_done (rsolver) !<description> ! Clean up the Newton iteration. !</description> !<inputoutput> ! Structure to be cleaned up. type(t_spacetimeNewton), intent(inout) :: rsolver !</inputoutput> !</subroutine> ! Release the linear subsolver. call newtonlin_done (rsolver%rlinsolParam) ! Release the KKT subsolvers. call kkt_doneSubsolvers (rsolver%rkktSubsolvers) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_clearStatistics(rstatistics) !<description> ! Resets a statistic structure. !</description> !<inputoutput> ! Structure to be reset. type(t_newtonitSolverStat), intent(inout) :: rstatistics !</inputoutput> !</subroutine> rstatistics%niterations = 0 call stat_clearTimer(rstatistics%rtotalTime) call stat_clearTimer(rstatistics%rtimeForward) call stat_clearTimer(rstatistics%rtimeBackward) call stat_clearTimer(rstatistics%rtimeDefect) call stat_clearTimer(rstatistics%rtimePostprocessing) call spacesl_clearStatistics (rstatistics%rspaceslSolverStat) call newtonlin_clearStatistics (rstatistics%rnewtonlinSolverStat) end subroutine ! *************************************************************************** !<subroutine> subroutine newtonit_sumStatistics(rstatistics1,rstatistics2,btotalTime) !<description> ! Sums up the data of rstatistics1 to the data in rstatistics2. !</description> !<input> ! Source structure type(t_newtonitSolverStat), intent(in) :: rstatistics1 ! OPTIONAL: Whether or not to sum up the total time. ! If not present, TRUE is assumed. logical, intent(in), optional :: btotalTime !</input> !<inputoutput> ! Destination structure. type(t_newtonitSolverStat), intent(inout) :: rstatistics2 !</inputoutput> !</subroutine> rstatistics2%niterations = rstatistics2%niterations + rstatistics1%niterations if (.not. present(btotalTime)) then call stat_addTimers(rstatistics1%rtotalTime, rstatistics2%rtotalTime) else if (btotalTime) then call stat_addTimers(rstatistics1%rtotalTime, rstatistics2%rtotalTime) end if call stat_addTimers(rstatistics1%rtimeForward, rstatistics2%rtimeForward) call stat_addTimers(rstatistics1%rtimeBackward, rstatistics2%rtimeBackward) call stat_addTimers(rstatistics1%rtimeDefect, rstatistics2%rtimeDefect) call stat_addTimers(rstatistics1%rtimeProlRest, rstatistics2%rtimeProlRest) call stat_addTimers(rstatistics1%rtimePostprocessing,rstatistics2%rtimePostprocessing) call spacesl_sumStatistics (& rstatistics1%rspaceslSolverStat,rstatistics2%rspaceslSolverStat) call newtonlin_sumStatistics (& rstatistics1%rnewtonlinSolverStat,rstatistics2%rnewtonlinSolverStat,NLIN_STYPE_LINSOL) end subroutine end module
area51/cc2doptcontrol3/src/newtoniteration.f90
!>\file module_nst_water_prop.f90 !! This file contains GFS NSST water property subroutines. !>\defgroup waterprop GFS NSST Water Property !!This module contains GFS NSST water property subroutines. !!\ingroup gfs_nst_main module module_nst_water_prop use machine, only : kind_phys use module_nst_parameters, only : t0k ! private public :: rhocoef,density,sw_rad,sw_rad_aw,sw_rad_sum,sw_rad_upper,sw_rad_upper_aw,sw_rad_skin,grv,solar_time_from_julian,compjd, & sw_ps_9b,sw_ps_9b_aw,get_dtzm_point,get_dtzm_2d ! interface sw_ps_9b module procedure sw_ps_9b end interface interface sw_ps_9b_aw module procedure sw_ps_9b_aw end interface ! interface sw_rad module procedure sw_fairall_6exp_v1 ! sw_wick_v1 end interface interface sw_rad_aw module procedure sw_fairall_6exp_v1_aw end interface interface sw_rad_sum module procedure sw_fairall_6exp_v1_sum end interface interface sw_rad_upper module procedure sw_soloviev_3exp_v2 end interface interface sw_rad_upper_aw module procedure sw_soloviev_3exp_v2_aw end interface interface sw_rad_skin module procedure sw_ohlmann_v1 end interface contains ! ------------------------------------------------------ !>\ingroup waterprop !! This subroutine computes thermal expansion coefficient (alpha) !! and saline contraction coefficient (beta). subroutine rhocoef(t, s, rhoref, alpha, beta) ! ------------------------------------------------------ ! compute thermal expansion coefficient (alpha) ! and saline contraction coefficient (beta) using ! the international equation of state of sea water ! (1980). ref: pond and pickard, introduction to ! dynamical oceanography, pp310. ! note: compression effects are not included implicit none real(kind=kind_phys), intent(in) :: t, s, rhoref real(kind=kind_phys), intent(out) :: alpha, beta real(kind=kind_phys) :: tc tc = t - t0k alpha = & 6.793952e-2 & - 2.0 * 9.095290e-3 * tc + 3.0 * 1.001685e-4 * tc**2 & - 4.0 * 1.120083e-6 * tc**3 + 5.0 * 6.536332e-9 * tc**4 & - 4.0899e-3 * s & + 2.0 * 7.6438e-5 * tc * s - 3.0 * 8.2467e-7 * tc**2 * s & + 4.0 * 5.3875e-9 * tc**3 * s & + 1.0227e-4 * s**1.5 - 2.0 * 1.6546e-6 * tc * s**1.5 ! note: rhoref - specify ! alpha = -alpha/rhoref beta = & 8.24493e-1 - 4.0899e-3 * tc & + 7.6438e-5 * tc**2 - 8.2467e-7 * tc**3 & + 5.3875e-9 * tc**4 - 1.5 * 5.72466e-3 * s**.5 & + 1.5 * 1.0227e-4 * tc * s**.5 & - 1.5 * 1.6546e-6 * tc**2 * s**.5 & + 2.0 * 4.8314e-4 * s beta = beta / rhoref end subroutine rhocoef ! ---------------------------------------- !>\ingroup waterprop !! This subroutine computes sea water density. subroutine density(t, s, rho) ! ---------------------------------------- implicit none ! input real(kind=kind_phys), intent(in) :: t !unit, k real(kind=kind_phys), intent(in) :: s !unit, 1/1000 ! output real(kind=kind_phys), intent(out) :: rho !unit, kg/m^3 ! local real(kind=kind_phys) :: tc ! compute density using the international equation ! of state of sea water 1980, (pond and pickard, ! introduction to dynamical oceanography, pp310). ! compression effects are not included rho = 0.0 tc = t - t0k ! effect of temperature on density (lines 1-3) ! effect of temperature and salinity on density (lines 4-8) rho = & 999.842594 + 6.793952e-2 * tc & - 9.095290e-3 * tc**2 + 1.001685e-4 * tc**3 & - 1.120083e-6 * tc**4 + 6.536332e-9 * tc**5 & + 8.24493e-1 * s - 4.0899e-3 * tc * s & + 7.6438e-5 * tc**2 * s - 8.2467e-7 * tc**3 * s & + 5.3875e-9 * tc**4 * s - 5.72466e-3 * s**1.5 & + 1.0227e-4 * tc * s**1.5 - 1.6546e-6 * tc**2 * s**1.5 & + 4.8314e-4 * s**2 end subroutine density ! !====================== ! !>\ingroup waterprop !! This subroutine computes the fraction of the solar radiation absorbed !! by the depth z following Paulson and Simpson (1981) \cite paulson_and_simpson_1981 . elemental subroutine sw_ps_9b(z,fxp) ! ! fraction of the solar radiation absorbed by the ocean at the depth z ! following paulson and simpson, 1981 ! ! input: ! z: depth (m) ! ! output: ! fxp: fraction of the solar radiation absorbed by the ocean at depth z (w/m^2) ! implicit none real,intent(in):: z real,intent(out):: fxp real, dimension(9), parameter :: f=(/0.237,0.36,0.179,0.087,0.08,0.0246,0.025,0.007,0.0004/) & ,gamma=(/34.8,2.27,3.15e-2,5.48e-3,8.32e-4,1.26e-4,3.13e-4,7.82e-5,1.44e-5/) ! if(z>0) then fxp=1.0-(f(1)*exp(-z/gamma(1))+f(2)*exp(-z/gamma(2))+f(3)*exp(-z/gamma(3))+ & f(4)*exp(-z/gamma(4))+f(5)*exp(-z/gamma(5))+f(6)*exp(-z/gamma(6))+ & f(7)*exp(-z/gamma(7))+f(8)*exp(-z/gamma(8))+f(9)*exp(-z/gamma(9))) else fxp=0. endif ! end subroutine sw_ps_9b ! !====================== ! ! !====================== ! !>\ingroup waterprop !! This subroutine elemental subroutine sw_ps_9b_aw(z,aw) ! ! d(fw)/d(z) for 9-band ! ! input: ! z: depth (m) ! ! output: ! fxp: fraction of the solar radiation absorbed by the ocean at depth z (w/m^2) ! implicit none real,intent(in):: z real,intent(out):: aw real, dimension(9), parameter :: f=(/0.237,0.36,0.179,0.087,0.08,0.0246,0.025,0.007,0.0004/) & ,gamma=(/34.8,2.27,3.15e-2,5.48e-3,8.32e-4,1.26e-4,3.13e-4,7.82e-5,1.44e-5/) ! if(z>0) then aw=(f(1)/gamma(1))*exp(-z/gamma(1))+(f(2)/gamma(2))*exp(-z/gamma(2))+(f(3)/gamma(3))*exp(-z/gamma(3))+ & (f(1)/gamma(4))*exp(-z/gamma(4))+(f(2)/gamma(5))*exp(-z/gamma(5))+(f(6)/gamma(6))*exp(-z/gamma(6))+ & (f(1)/gamma(7))*exp(-z/gamma(7))+(f(2)/gamma(8))*exp(-z/gamma(8))+(f(9)/gamma(9))*exp(-z/gamma(9)) else aw=0. endif ! end subroutine sw_ps_9b_aw ! !====================== !>\ingroup waterprop !! This subroutine computes fraction of the solar radiation absorbed by the ocean at the depth !! z (Fairall et al. (1996) \cite fairall_et_al_1996, p. 1298) following Paulson and Simpson !! (1981) \cite paulson_and_simpson_1981 . elemental subroutine sw_fairall_6exp_v1(z,fxp) ! ! fraction of the solar radiation absorbed by the ocean at the depth z (fairall et all, 1996, p. 1298) ! following paulson and simpson, 1981 ! ! input: ! z: depth (m) ! ! output: ! fxp: fraction of the solar radiation absorbed by the ocean at depth z (w/m^2) ! implicit none real(kind=kind_phys),intent(in):: z real(kind=kind_phys),intent(out):: fxp real(kind=kind_phys), dimension(9), parameter :: f=(/0.237,0.36,0.179,0.087,0.08,0.0246,0.025,0.007,0.0004/) & ,gamma=(/34.8,2.27,3.15e-2,5.48e-3,8.32e-4,1.26e-4,3.13e-4,7.82e-5,1.44e-5/) real(kind=kind_phys),dimension(9) :: zgamma real(kind=kind_phys),dimension(9) :: f_c ! if(z>0) then zgamma=z/gamma f_c=f*(1.-1./zgamma*(1-exp(-zgamma))) fxp=sum(f_c) else fxp=0. endif ! end subroutine sw_fairall_6exp_v1 ! !====================== ! ! !>\ingroup waterprop !! This subroutine calculates fraction of the solar radiation absorbed by the !! ocean at the depth z (fairall et al.(1996) \cite fairall_et_al_1996; p.1298) !! following Paulson and Simpson (1981) \cite paulson_and_simpson_1981. elemental subroutine sw_fairall_6exp_v1_aw(z,aw) ! ! fraction of the solar radiation absorbed by the ocean at the depth z (fairall et all, 1996, p. 1298) ! following paulson and simpson, 1981 ! ! input: ! z: depth (m) ! ! output: ! aw: d(fxp)/d(z) ! ! fxp: fraction of the solar radiation absorbed by the ocean at depth z (w/m^2) ! implicit none real(kind=kind_phys),intent(in):: z real(kind=kind_phys),intent(out):: aw real(kind=kind_phys) :: fxp real(kind=kind_phys), dimension(9), parameter :: f=(/0.237,0.36,0.179,0.087,0.08,0.0246,0.025,0.007,0.0004/) & ,gamma=(/34.8,2.27,3.15e-2,5.48e-3,8.32e-4,1.26e-4,3.13e-4,7.82e-5,1.44e-5/) real(kind=kind_phys),dimension(9) :: zgamma real(kind=kind_phys),dimension(9) :: f_aw ! if(z>0) then zgamma=z/gamma f_aw=(f/z)*((gamma/z)*(1-exp(-zgamma))-exp(-zgamma)) aw=sum(f_aw) ! write(*,'(a,f6.2,f12.6,9f10.4)') 'z,aw in sw_rad_aw : ',z,aw,f_aw else aw=0. endif ! end subroutine sw_fairall_6exp_v1_aw ! !>\ingroup waterprop !! This subroutine computes fraction of the solar radiation absorbed by the ocean at the !! depth z (Fairall et al.(1996) \cite fairall_et_al_1996 , p.1298) following Paulson and !! Simpson (1981) \cite paulson_and_simpson_1981 . !>\param[in] z depth (m) !>\param[out] sum for convection depth calculation elemental subroutine sw_fairall_6exp_v1_sum(z,sum) ! ! fraction of the solar radiation absorbed by the ocean at the depth z (fairall et all, 1996, p. 1298) ! following paulson and simpson, 1981 ! ! input: ! z: depth (m) ! ! output: ! sum: for convection depth calculation ! ! implicit none real(kind=kind_phys),intent(in):: z real(kind=kind_phys),intent(out):: sum real(kind=kind_phys), dimension(9), parameter :: gamma=(/34.8,2.27,3.15e-2,5.48e-3,8.32e-4,1.26e-4,3.13e-4,7.82e-5,1.44e-5/) real(kind=kind_phys),dimension(9) :: zgamma real(kind=kind_phys),dimension(9) :: f_sum ! ! zgamma=z/gamma ! f_sum=(zgamma/z)*exp(-zgamma) ! sum=sum(f_sum) sum=(1.0/gamma(1))*exp(-z/gamma(1))+(1.0/gamma(2))*exp(-z/gamma(2))+(1.0/gamma(3))*exp(-z/gamma(3))+ & (1.0/gamma(4))*exp(-z/gamma(4))+(1.0/gamma(5))*exp(-z/gamma(5))+(1.0/gamma(6))*exp(-z/gamma(6))+ & (1.0/gamma(7))*exp(-z/gamma(7))+(1.0/gamma(8))*exp(-z/gamma(8))+(1.0/gamma(9))*exp(-z/gamma(9)) ! end subroutine sw_fairall_6exp_v1_sum ! !====================== !>\ingroup waterprop !! Solar radiation absorbed by the ocean at the depth z (Fairall et al. (1996) !! \cite fairall_et_al_1996, p.1298) !!\param[in] f_sol_0 solar radiation at the ocean surface (\f$W m^{-2}\f$) !!\param[in] z depth (m) !!\param[out] df_sol_z solar radiation absorbed by the ocean at depth z (\f$W m^{-2}\f$) elemental subroutine sw_fairall_simple_v1(f_sol_0,z,df_sol_z) ! ! solar radiation absorbed by the ocean at the depth z (fairall et all, 1996, p. 1298) ! ! input: ! f_sol_0: solar radiation at the ocean surface (w/m^2) ! z: depth (m) ! ! output: ! df_sol_z: solar radiation absorbed by the ocean at depth z (w/m^2) ! implicit none real(kind=kind_phys),intent(in):: z,f_sol_0 real(kind=kind_phys),intent(out):: df_sol_z ! if(z>0) then df_sol_z=f_sol_0*(0.137+11.0*z-6.6e-6/z*(1.-exp(-z/8.e-4))) else df_sol_z=0. endif ! end subroutine sw_fairall_simple_v1 ! !====================== ! !>\ingroup waterprop !! solar radiation absorbed by the ocean at the depth z (Zeng and Beljaars (2005) !! \cite zeng_and_beljaars_2005 , p.5). !>\param[in] f_sol_0 solar radiation at the ocean surface (\f$W m^{-2}\f$) !>\param[in] z depth (m) !>\param[out] df_sol_z solar radiation absorbed by the ocean at depth z (\f$W m^{-2}\f$) elemental subroutine sw_wick_v1(f_sol_0,z,df_sol_z) ! ! solar radiation absorbed by the ocean at the depth z (zeng and beljaars, 2005, p.5) ! ! input: ! f_sol_0: solar radiation at the ocean surface (w/m^2) ! z: depth (m) ! ! output: ! df_sol_z: solar radiation absorbed by the ocean at depth z (w/m^2) ! implicit none real(kind=kind_phys),intent(in):: z,f_sol_0 real(kind=kind_phys),intent(out):: df_sol_z ! if(z>0) then df_sol_z=f_sol_0*(0.065+11.0*z-6.6e-5/z*(1.-exp(-z/8.e-4))) else df_sol_z=0. endif ! end subroutine sw_wick_v1 ! !====================== ! !>\ingroup waterprop !! This subroutine computes solar radiation absorbed by the ocean at the depth z !! (Fairall et al.(1996) \cite fairall_et_al_1996 , p.1301) following !! Soloviev and Vershinsky (1982) \cite soloviev_and_vershinsky_1982. !>\param[in] f_sol_0 solar radiation at the ocean surface (\f$W m^{-2}\f$) !>\param[in] z depth (m) !>\param[out] df_sol_z solar radiation absorbed by the ocean at depth z (\f$W m^{-2}\f$) elemental subroutine sw_soloviev_3exp_v1(f_sol_0,z,df_sol_z) ! ! solar radiation absorbed by the ocean at the depth z (fairall et all, 1996, p. 1301) ! following soloviev, 1982 ! ! input: ! f_sol_0: solar radiation at the ocean surface (w/m^2) ! z: depth (m) ! ! output: ! df_sol_z: solar radiation absorbed by the ocean at depth z (w/m^2) ! implicit none real(kind=kind_phys),intent(in):: z,f_sol_0 real(kind=kind_phys),intent(out):: df_sol_z real(kind=kind_phys),dimension(3) :: f_c real(kind=kind_phys), dimension(3), parameter :: f=(/0.45,0.27,0.28/) & ,gamma=(/12.8,0.357,0.014/) ! if(z>0) then f_c = f*gamma(int(1-exp(-z/gamma))) df_sol_z = f_sol_0*(1.0-sum(f_c)/z) else df_sol_z = 0. endif ! end subroutine sw_soloviev_3exp_v1 ! !====================== ! !>\ingroup waterprop elemental subroutine sw_soloviev_3exp_v2(f_sol_0,z,df_sol_z) ! ! solar radiation absorbed by the ocean at the depth z (fairall et all, 1996, p. 1301) ! following soloviev, 1982 ! ! input: ! f_sol_0: solar radiation at the ocean surface (w/m^2) ! z: depth (m) ! ! output: ! df_sol_z: solar radiation absorbed by the ocean at depth z (w/m^2) ! implicit none real(kind=kind_phys),intent(in):: z,f_sol_0 real(kind=kind_phys),intent(out):: df_sol_z ! if(z>0) then df_sol_z=f_sol_0*(1.0 & -(0.28*0.014*(1.-exp(-z/0.014)) & +0.27*0.357*(1.-exp(-z/0.357)) & +.45*12.82*(1.-exp(-z/12.82)))/z & ) else df_sol_z=0. endif ! end subroutine sw_soloviev_3exp_v2 !>\ingroup waterprop elemental subroutine sw_soloviev_3exp_v2_aw(z,aw) ! ! aw = d(fxp)/d(z) ! following soloviev, 1982 ! ! input: ! z: depth (m) ! ! output: ! aw: d(fxp)/d(z) ! implicit none real(kind=kind_phys),intent(in):: z real(kind=kind_phys),intent(out):: aw real(kind=kind_phys):: fxp ! if(z>0) then fxp=(1.0 & -(0.28*0.014*(1.-exp(-z/0.014)) & + 0.27*0.357*(1.-exp(-z/0.357)) & + 0.45*12.82*(1.-exp(-z/12.82)))/z & ) aw=1.0-fxp-(0.28*exp(-z/0.014)+0.27*exp(-z/0.357)+0.45*exp(-z/12.82)) else aw=0. endif end subroutine sw_soloviev_3exp_v2_aw ! ! !====================== ! !>\ingroup waterprop elemental subroutine sw_ohlmann_v1(z,fxp) ! ! fraction of the solar radiation absorbed by the ocean at the depth z ! ! input: ! z: depth (m) ! ! output: ! fxp: fraction of the solar radiation absorbed by the ocean at depth z (w/m^2) ! implicit none real(kind=kind_phys),intent(in):: z real(kind=kind_phys),intent(out):: fxp ! if(z>0) then fxp=.065+11.*z-6.6e-5/z*(1.-exp(-z/8.0e-4)) else fxp=0. endif ! end subroutine sw_ohlmann_v1 ! !>\ingroup waterprop function grv(lat) real(kind=kind_phys) :: lat real(kind=kind_phys) :: gamma,c1,c2,c3,c4,pi,phi,x gamma=9.7803267715 c1=0.0052790414 c2=0.0000232718 c3=0.0000001262 c4=0.0000000007 pi=3.141593 phi=lat*pi/180 x=sin(phi) grv=gamma*(1+(c1*x**2)+(c2*x**4)+(c3*x**6)+(c4*x**8)) !print *,'grav=',grv,lat end function grv !>\ingroup waterprop !>This subroutine computes solar time from the julian date. subroutine solar_time_from_julian(jday,xlon,soltim) ! ! calculate solar time from the julian date ! implicit none real(kind=kind_phys), intent(in) :: jday real(kind=kind_phys), intent(in) :: xlon real(kind=kind_phys), intent(out) :: soltim real(kind=kind_phys) :: fjd,xhr,xmin,xsec,intime integer :: nn ! fjd=jday-floor(jday) fjd=jday xhr=floor(fjd*24.0)-sign(12.0,fjd-0.5) xmin=nint(fjd*1440.0)-(xhr+sign(12.0,fjd-0.5))*60 xsec=0 intime=xhr+xmin/60.0+xsec/3600.0+24.0 soltim=mod(xlon/15.0+intime,24.0)*3600.0 end subroutine solar_time_from_julian ! !*********************************************************************** ! !>\ingroup waterprop !> This subroutine computes julian day and fraction from year, !! month, day and time UTC. subroutine compjd(jyr,jmnth,jday,jhr,jmn,jd,fjd) !fpp$ noconcur r !$$$ subprogram documentation block ! . . . . ! subprogram: compjd computes julian day and fraction ! prgmmr: kenneth campana org: w/nmc23 date: 89-07-07 ! ! abstract: computes julian day and fraction ! from year, month, day and time utc. ! ! program history log: ! 77-05-06 ray orzol,gfdl ! 98-05-15 iredell y2k compliance ! ! usage: call compjd(jyr,jmnth,jday,jhr,jmn,jd,fjd) ! input argument list: ! jyr - year (4 digits) ! jmnth - month ! jday - day ! jhr - hour ! jmn - minutes ! output argument list: ! jd - julian day. ! fjd - fraction of the julian day. ! ! subprograms called: ! iw3jdn compute julian day number ! ! attributes: ! language: fortran. ! !$$$ use machine , only :kind_phys implicit none ! integer jyr,jmnth,jday,jhr,jmn,jd integer iw3jdn real (kind=kind_phys) fjd jd=iw3jdn(jyr,jmnth,jday) if(jhr.lt.12) then jd=jd-1 fjd=0.5+jhr/24.+jmn/1440. else fjd=(jhr-12)/24.+jmn/1440. endif end subroutine compjd !>\ingroup waterprop !>This subroutine computes dtm (the mean of \f$dT(z)\f$). subroutine get_dtzm_point(xt,xz,dt_cool,zc,z1,z2,dtm) ! ===================================================================== ! ! ! ! description: get dtm = mean of dT(z) (z1 - z2) with NSST dT(z) ! ! dT(z) = (1-z/xz)*dt_warm - (1-z/zc)*dt_cool ! ! ! ! usage: ! ! ! ! call get_dtm12 ! ! ! ! inputs: ! ! (xt,xz,dt_cool,zc,z1,z2, ! ! outputs: ! ! dtm) ! ! ! ! program history log: ! ! ! ! 2015 -- xu li createad original code ! ! inputs: ! ! xt - real, heat content in dtl 1 ! ! xz - real, dtl thickness 1 ! ! dt_cool - real, sub-layer cooling amount 1 ! ! zc - sub-layer cooling thickness 1 ! ! z1 - lower bound of depth of sea temperature 1 ! ! z2 - upper bound of depth of sea temperature 1 ! ! outputs: ! ! dtm - mean of dT(z) (z1 to z2) 1 ! ! use machine , only : kind_phys implicit none real (kind=kind_phys), intent(in) :: xt,xz,dt_cool,zc,z1,z2 real (kind=kind_phys), intent(out) :: dtm ! Local variables real (kind=kind_phys) :: dt_warm,dtw,dtc ! ! get the mean warming in the range of z=z1 to z=z2 ! dtw = 0.0 if ( xt > 0.0 ) then dt_warm = (xt+xt)/xz ! Tw(0) if ( z1 < z2) then if ( z2 < xz ) then dtw = dt_warm*(1.0-(z1+z2)/(xz+xz)) elseif ( z1 < xz .and. z2 >= xz ) then dtw = 0.5*(1.0-z1/xz)*dt_warm*(xz-z1)/(z2-z1) endif elseif ( z1 == z2 ) then if ( z1 < xz ) then dtw = dt_warm*(1.0-z1/xz) endif endif endif ! ! get the mean cooling in the range of z=z1 to z=z2 ! dtc = 0.0 if ( zc > 0.0 ) then if ( z1 < z2) then if ( z2 < zc ) then dtc = dt_cool*(1.0-(z1+z2)/(zc+zc)) elseif ( z1 < zc .and. z2 >= zc ) then dtc = 0.5*(1.0-z1/zc)*dt_cool*(zc-z1)/(z2-z1) endif elseif ( z1 == z2 ) then if ( z1 < zc ) then dtc = dt_cool*(1.0-z1/zc) endif endif endif ! ! get the mean T departure from Tf in the range of z=z1 to z=z2 ! dtm = dtw - dtc end subroutine get_dtzm_point !>\ingroup waterprop subroutine get_dtzm_2d(xt,xz,dt_cool,zc,wet,z1,z2,nx,ny,dtm) !subroutine get_dtzm_2d(xt,xz,dt_cool,zc,wet,icy,z1,z2,nx,ny,dtm) ! ===================================================================== ! ! ! ! description: get dtm = mean of dT(z) (z1 - z2) with NSST dT(z) ! ! dT(z) = (1-z/xz)*dt_warm - (1-z/zc)*dt_cool ! ! ! ! usage: ! ! ! ! call get_dtzm_2d ! ! ! ! inputs: ! ! (xt,xz,dt_cool,zc,z1,z2, ! ! outputs: ! ! dtm) ! ! ! ! program history log: ! ! ! ! 2015 -- xu li createad original code ! ! inputs: ! ! xt - real, heat content in dtl 1 ! ! xz - real, dtl thickness 1 ! ! dt_cool - real, sub-layer cooling amount 1 ! ! zc - sub-layer cooling thickness 1 ! ! wet - logical, flag for wet point (ocean or lake) 1 ! ! icy - logical, flag for ice point (ocean or lake) 1 ! ! nx - integer, dimension in x-direction (zonal) 1 ! ! ny - integer, dimension in y-direction (meridional) 1 ! ! z1 - lower bound of depth of sea temperature 1 ! ! z2 - upper bound of depth of sea temperature 1 ! ! outputs: ! ! dtm - mean of dT(z) (z1 to z2) 1 ! ! use machine , only : kind_phys implicit none integer, intent(in) :: nx,ny real (kind=kind_phys), dimension(nx,ny), intent(in) :: xt,xz,dt_cool,zc logical, dimension(nx,ny), intent(in) :: wet ! logical, dimension(nx,ny), intent(in) :: wet,icy real (kind=kind_phys), intent(in) :: z1,z2 real (kind=kind_phys), dimension(nx,ny), intent(out) :: dtm ! Local variables integer :: i,j real (kind=kind_phys), dimension(nx,ny) :: dtw,dtc real (kind=kind_phys) :: dt_warm !$omp parallel do private(j,i) do j = 1, ny do i= 1, nx ! ! initialize dtw & dtc as zeros ! dtw(i,j) = 0.0 dtc(i,j) = 0.0 ! if ( wet(i,j) .and. .not.icy(i,j) ) then if ( wet(i,j) ) then ! ! get the mean warming in the range of z=z1 to z=z2 ! if ( xt(i,j) > 0.0 ) then dt_warm = (xt(i,j)+xt(i,j))/xz(i,j) ! Tw(0) if ( z1 < z2) then if ( z2 < xz(i,j) ) then dtw(i,j) = dt_warm*(1.0-(z1+z2)/(xz(i,j)+xz(i,j))) elseif ( z1 < xz(i,j) .and. z2 >= xz(i,j) ) then dtw(i,j) = 0.5*(1.0-z1/xz(i,j))*dt_warm*(xz(i,j)-z1)/(z2-z1) endif elseif ( z1 == z2 ) then if ( z1 < xz(i,j) ) then dtw(i,j) = dt_warm*(1.0-z1/xz(i,j)) endif endif endif ! ! get the mean cooling in the range of z=0 to z=zsea ! if ( zc(i,j) > 0.0 ) then if ( z1 < z2) then if ( z2 < zc(i,j) ) then dtc(i,j) = dt_cool(i,j)*(1.0-(z1+z2)/(zc(i,j)+zc(i,j))) elseif ( z1 < zc(i,j) .and. z2 >= zc(i,j) ) then dtc(i,j) = 0.5*(1.0-z1/zc(i,j))*dt_cool(i,j)*(zc(i,j)-z1)/(z2-z1) endif elseif ( z1 == z2 ) then if ( z1 < zc(i,j) ) then dtc(i,j) = dt_cool(i,j)*(1.0-z1/zc(i,j)) endif endif endif endif ! if ( wet(i,j) .and. .not.icy(i,j) ) then enddo enddo ! ! get the mean T departure from Tf in the range of z=z1 to z=z2 ! DH* NEED NTHREADS HERE! TODO !$omp parallel do private(j,i) do j = 1, ny do i= 1, nx ! if ( wet(i,j) .and. .not.icy(i,j)) then if ( wet(i,j) ) then dtm(i,j) = dtw(i,j) - dtc(i,j) endif enddo enddo end subroutine get_dtzm_2d end module module_nst_water_prop
physics/module_nst_water_prop.f90
! { dg-do compile } ! ! PR 40822: [4.5 Regression] Internal compiler error when Fortran intrinsic LEN referenced before explicit declaration ! ! Contributed by Mat Cross <[email protected]> SUBROUTINE SEARCH(ITEMVAL) CHARACTER (*) :: ITEMVAL CHARACTER (LEN(ITEMVAL)) :: ITEM INTRINSIC LEN END
validation_tests/llvm/f18/gfortran.dg/char_length_16.f90
MODULE ReferenceElementModuleE USE KindModule, ONLY: & DP USE QuadratureModule, ONLY: & GetQuadrature USE ProgramHeaderModule, ONLY: & nNodesE IMPLICIT NONE PRIVATE REAL(DP), DIMENSION(:), ALLOCATABLE, PUBLIC :: NodesE, WeightsE REAL(DP), DIMENSION(:), ALLOCATABLE, PUBLIC :: NodesE_L, WeightsE_L PUBLIC :: InitializeReferenceElementE PUBLIC :: FinalizeReferenceElementE CONTAINS SUBROUTINE InitializeReferenceElementE ! --- Gaussian Quadrature Points and Weights --- ALLOCATE( NodesE(nNodesE), WeightsE(nNodesE) ) CALL GetQuadrature( nNodesE, NodesE, WeightsE ) ! --- Lobatto Quadrature Points and Weights --- ALLOCATE( NodesE_L(nNodesE), WeightsE_L(nNodesE) ) CALL GetQuadrature( nNodesE, NodesE_L, WeightsE_L, 'Lobatto' ) END SUBROUTINE InitializeReferenceElementE SUBROUTINE FinalizeReferenceElementE DEALLOCATE( NodesE, WeightsE ) DEALLOCATE( NodesE_L, WeightsE_L ) END SUBROUTINE FinalizeReferenceElementE END MODULE ReferenceElementModuleE
SandBox/dgExperiments_M1/ReferenceElementModuleE.f90
PROGRAM SFVGSF C************************************************************************ C* PROGRAM SFVGSF * C* * C* This program takes the data in a Vector Graphics file and adds * C* it to a surface file. * C** * C* Log: * C* S. Jacobs/NCEP 2/99 Created * C************************************************************************ INCLUDE 'GEMPRM.PRM' C* CHARACTER vgfile*(LLMXLN), sfoutf*(LLMXLN), + sfparm*(LLMXLN), dattim*(LLMXLN), + colors*(LLMXLN) C* LOGICAL respnd, done, proces, stndrd CHARACTER prmdst (MMPARM)*4, parms (MMPARM)*4, filnam*72, + plist*(LLMXLN), clist*(LLMXLN) INTEGER iploc (MMPARM), icolr (MMPARM) C------------------------------------------------------------------------ C* Initilaize user interface. C CALL IP_INIT ( respnd, iperr ) IF ( iperr .ne. 0 ) THEN CALL ER_WMSG ( 'SFVGSF', iperr, ' ', ier ) CALL SS_EXIT END IF CALL IP_IDNT ( 'SFVGSF', ier ) C C* Main loop. C isffln = 0 done = .false. DO WHILE ( .not. done ) C C* Get user input and exit if there is an error. C CALL SFVINP ( vgfile, sfoutf, dattim, sfparm, colors, + iperr ) IF ( iperr .ne. 0 ) THEN CALL ER_WMSG ( 'SFVGSF', iperr, ' ', ier ) CALL SS_EXIT END IF proces = .true. C C* Open the surface file. C CALL FL_MFIL ( sfoutf, ' ', filnam, iret ) IF ( iret .ne. 0 ) CALL ER_WMSG ( 'FL', iret, ' ', ier ) CALL SF_OPNF ( filnam, .true., isffln, isr, npmdst, + prmdst, iret ) IF ( iret .ne. 0 ) THEN CALL ER_WMSG ( 'SF', iret, ' ', ier ) proces = .false. END IF C C* Get the parameters and colors from the parameter table. C IF ( proces ) THEN CALL TB_PARM ( sfparm, plist, clist, iret ) IF ( iret .lt. 0 ) THEN CALL ER_WMSG ( 'TB', iret, ' ', ier ) proces = .false. ELSE IF ( iret .eq. 2 ) THEN plist = sfparm clist = colors ELSE IF ( colors .ne. ' ' ) clist = colors END IF END IF C C* Check for a standard or non-standard file. C IF ( proces ) THEN CALL SF_FTYP ( isffln, stndrd, iret ) IF ( iret .ne. 0 ) THEN CALL ER_WMSG ( 'SF', iret, ' ', ier ) proces = .false. END IF END IF C C* Cannot process a non-standard file. C IF ( .not. stndrd ) THEN CALL ER_WMSG ( 'SFVGSF', -4, ' ', ier ) proces = .false. END IF C C* Open the edit file and get parameter names. C IF ( proces ) THEN CALL SFVPRM ( plist, clist, prmdst, npmdst, + parms, iploc, icolr, nparm, iret ) IF ( iret .ne. 0 ) THEN CALL ER_WMSG ( 'SFVGSF', iret, ' ', ier ) proces = .false. END IF END IF C C* Give user a chance to exit. C IF ( proces ) THEN CALL SFVOPT ( vgfile, filnam, dattim, parms, icolr, + nparm, iret ) IF ( iret .ne. 0 ) THEN proces = .false. CALL SF_CLOS ( isffln, ier ) END IF END IF C C* Get the data and write to the file. C IF ( proces ) THEN CALL SFVDTA ( vgfile, isffln, dattim, nparm, iploc, + icolr, iret ) CALL SF_CLOS ( isffln, ier ) END IF C C* Call the dynamic tutor. C CALL IP_DYNM ( done, ier ) END DO C C* Exit. C CALL IP_EXIT ( iret ) END
gempak/source/programs/sf/sfvgsf/sfvgsf.f
C Copyright(C) 2009-2017 National Technology & Engineering Solutions of C 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 Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C $Log: scal3d.f,v $ C Revision 1.2 2009/03/25 12:36:47 gdsjaar C Add copyright and license notice to all files. C Permission to assert copyright has been granted; blot is now open source, BSD C C Revision 1.1 1994/04/07 20:10:50 gdsjaar C Initial checkin of ACCESS/graphics/blotII2 C c Revision 1.2 1990/12/14 08:56:57 gdsjaar c Added RCS Id and Log to all files c C======================================================================= SUBROUTINE SCAL3D (MSCTYP, ROTMAT, ROTCEN, ALMESH, D2MESH) C======================================================================= C --*** SCAL3D *** (MESH) Find the 2D limits of a 3D mesh C -- Written by Amy Gilkey - revised 06/30/86 C -- C --SCAL3D takes the mesh limits and scales them in one of two ways: C -- 1) it finds the 2D limits enclosing the smallest sphere enclosing C -- a cube from the maximum 3D limits C -- 2) it finds the 2D limits of the rotated mesh C --The mesh limits are expanded a little. C -- C --Parameters: C -- MSCTYP - IN - mesh scaling flag (as in /MSHLIM/) C -- ROTMAT - IN - the rotation matrix C -- ROTCEN - IN - the mesh center for the rotation C -- ALMESH - IN - the mesh limits C -- D2MESH - OUT - the 2D rotated mesh limits PARAMETER (KLFT=1, KRGT=2, KBOT=3, KTOP=4, KNEA=5, KFAR=6) CHARACTER*(*) MSCTYP REAL ROTMAT(3,3), ROTCEN(3) REAL ALMESH(KFAR), D2MESH(KTOP) IF (MSCTYP .EQ. 'ALL') THEN RMAX = MAX (ALMESH(KRGT)-ROTCEN(1), ROTCEN(1)-ALMESH(KLFT) & , ALMESH(KTOP)-ROTCEN(2), ROTCEN(2)-ALMESH(KBOT) & , ALMESH(KFAR)-ROTCEN(3), ROTCEN(3)-ALMESH(KNEA)) RAD = SQRT(3.0) * RMAX D2MESH(KLFT) = - RAD D2MESH(KRGT) = + RAD D2MESH(KBOT) = - RAD D2MESH(KTOP) = + RAD ELSE CALL BL_ROTATE (1, 1, ROTMAT, ROTCEN, & ALMESH(KLFT), ALMESH(KBOT), ALMESH(KNEA), X1, Y1, RDUM) CALL BL_ROTATE (1, 1, ROTMAT, ROTCEN, & ALMESH(KRGT), ALMESH(KTOP), ALMESH(KFAR), X2, Y2, RDUM) D2MESH(KLFT) = MIN (X1, X2) D2MESH(KRGT) = MAX (X1, X2) D2MESH(KBOT) = MIN (Y1, Y2) D2MESH(KTOP) = MAX (Y1, Y2) END IF CALL EXPLIM (2, D2MESH, D2MESH) RETURN END
packages/seacas/applications/blot/scal3d.f
module extended_zgrid implicit none public :: nsegments public :: neigen public :: ikxmod public :: iz_low, iz_mid, iz_up public :: periodic public :: nzed_segment public :: fill_zed_ghost_zones public :: init_extended_zgrid, finish_extended_zgrid public :: map_to_extended_zgrid public :: map_from_extended_zgrid !> these arrays needed to keep track of connections between different !> 2pi segments integer :: nzed_segment integer, dimension(:), allocatable :: neigen integer, dimension(:), allocatable :: iz_low, iz_mid, iz_up integer, dimension(:, :), allocatable :: nsegments integer, dimension(:, :, :), allocatable :: ikxmod !> arrays indicate which flux tube index to connect to !> on the left and on the right !> as a function of current flux tube index !> pre-compute to avoid conditionals in loops integer, dimension(:), allocatable :: it_left, it_right complex, dimension(:), allocatable :: phase_shift logical, dimension(:), allocatable :: periodic logical :: extended_zgrid_initialized = .false. contains subroutine init_extended_zgrid use zgrid, only: boundary_option_switch use zgrid, only: boundary_option_self_periodic use zgrid, only: boundary_option_linked use zgrid, only: twist_shift_option_switch use zgrid, only: twist_shift_option_periodic use zgrid, only: twist_shift_option_std use zgrid, only: twist_shift_option_stellarator use zgrid, only: nperiod, nzgrid, nzed, ntubes use kt_grids, only: nakx, naky use kt_grids, only: jtwist, ikx_twist_shift, phase_shift_fac use kt_grids, only: aky, ikx_max use constants, only: zi implicit none integer :: iseg, iky, ie, ikx, it integer :: nseg_max, neigen_max integer, dimension(:), allocatable :: ikx_shift_end integer, dimension(:, :), allocatable :: ikx_shift if (extended_zgrid_initialized) return extended_zgrid_initialized = .true. if (.not. allocated(neigen)) allocate (neigen(naky)) if (.not. allocated(periodic)) allocate (periodic(naky)); periodic = .false. if (.not. allocated(phase_shift)) allocate (phase_shift(naky)); phase_shift = 1. if (boundary_option_switch == boundary_option_self_periodic) then periodic = .true. else where (abs(aky) < epsilon(0.0)) periodic = .true. end if if (twist_shift_option_switch == twist_shift_option_periodic) then periodic = .true. end if select case (boundary_option_switch) case (boundary_option_linked) !> all periodic modes (e.g., the zonal mode) have no connections do iky = 1, naky if (periodic(iky)) then neigen(iky) = nakx else neigen(iky) = min((iky - 1) * jtwist, nakx) end if end do neigen_max = maxval(neigen) if (.not. allocated(ikx_shift_end)) then allocate (ikx_shift_end(neigen_max)); ikx_shift_end = 0 allocate (ikx_shift(nakx, naky)); ikx_shift = 0 end if !> phi(kx-kx_shift,-nzgrid) = phi(kx,nzgrid) from twist-and-shift BC !> for positive (negative) magnetic shear, kx_shift is positive (negative), !> so start at most positive (negative) kx and !> progress to smaller (larger) kx values as connections occur !> figure out how much to shift ikx by to get to the end of the kx chain !> for positive (negative) magnetic shear, this is the left-most (right-most) theta-theta0 !> in each set of connected 2pi segments !> note that theta0 goes from 0 to theta0_max and then from theta0_min back !> to -dtheta0 do ikx = 1, neigen_max !> first ikx_max=nakx/2+1 theta0s are 0 and all positive theta0 values !> remainder are negative theta0s !> theta_0 = kx / ky / shat !> if ky > 0, then most positive theta_0 corresponds to most positive kx !> first consider case where shift in kx is negative (corresponds to positive magnetic shear) if (ikx_twist_shift < 0) then if (ikx <= ikx_max) then ikx_shift_end(ikx) = ikx_max - 2 * ikx + 1 else ikx_shift_end(ikx) = 3 * ikx_max - 2 * ikx end if !> then consider case where shift in kx is positive else if (ikx_twist_shift > 0) then if (ikx < ikx_max) then if (ikx + ikx_max <= nakx) then ikx_shift_end(ikx) = ikx_max else ikx_shift_end(ikx) = ikx - nakx end if else ikx_shift_end(ikx) = 1 - ikx_max end if end if !> note that zero shift case is taken care of by initialization of ikx_shift_end end do do iky = 1, naky !> ikx_shift is how much to shift each ikx by to connect !> to the next theta0 (from most positive to most negative for positive magnetic shear !> and vice versa for negative magnetic shear) !> first consider shift in index for case where shift is negative !> (corresponds to positive magnetic shear) if (ikx_twist_shift < 0) then !> if ky > 0, then going to more negative theta0 !> corresponds to going to more negative kx do ikx = 1, ikx_max !> if theta0 is sufficiently positive, shifting to more !> negative theta0 corresponds to decreasing ikx if (ikx - neigen(iky) > 0) then ikx_shift(ikx, iky) = -neigen(iky) !> if a positive theta0 connects to a negative theta0 !> must do more complicated mapping of ikx else if (ikx - neigen(iky) + nakx >= ikx_max + 1) then ikx_shift(ikx, iky) = nakx - neigen(iky) end if end do !> if theta0 is negative, then shifting to more negative !> theta0 corresponds to decreasing ikx do ikx = ikx_max + 1, nakx !> if theta0 is sufficiently negative, it has no !> more negative theta0 with which it can connect if (ikx - neigen(iky) > ikx_max) then ikx_shift(ikx, iky) = -neigen(iky) end if !> theta0 is positive end do else if (ikx_twist_shift > 0) then !> if ky > 0, then going to more positive theta0 !> corresponds to going to more positive kx do ikx = 1, ikx_max !> if shift in kx, kx_shift, is less than kx-kx_max, !> then shift by the appropriate amount if (ikx + neigen(iky) <= ikx_max) then ikx_shift(ikx, iky) = neigen(iky) end if !> otherwise, no kx on grid to connect with end do do ikx = ikx_max + 1, nakx !> if kx+kx_shift < 0, then simple shift by neigen if (ikx + neigen(iky) <= nakx) then ikx_shift(ikx, iky) = neigen(iky) !> if 0 < kx+kx_shift <= kx_max, then more complicated shift !> to positive set of kx values else if (ikx - ikx_max + neigen(iky) <= nakx) then ikx_shift(ikx, iky) = neigen(iky) - nakx end if !> otherwise, no kx on grid with which to connect end do end if end do if (.not. allocated(nsegments)) allocate (nsegments(neigen_max, naky)) do iky = 1, naky if (neigen(iky) == 0) then nsegments(:, iky) = 1 else nsegments(:, iky) = (nakx - 1) / neigen(iky) do ie = 1, mod(nakx - 1, neigen(iky)) + 1 nsegments(ie, iky) = nsegments(ie, iky) + 1 end do end if end do nseg_max = maxval(nsegments) if (.not. allocated(iz_low)) then allocate (iz_low(nseg_max)); iz_low = -nzgrid allocate (iz_mid(nseg_max)); iz_mid = 0 allocate (iz_up(nseg_max)); iz_up = nzgrid end if phase_shift = exp(zi * aky * phase_shift_fac) case default neigen = nakx; neigen_max = nakx if (.not. allocated(ikx_shift_end)) then allocate (ikx_shift_end(neigen_max)) allocate (ikx_shift(nakx, naky)) end if ikx_shift = 0; ikx_shift_end = 0 if (.not. allocated(nsegments)) then allocate (nsegments(neigen_max, naky)) end if !> this is the number of 2pi poloidal segments in the extended theta domain, !> which is needed in initializing the reponse matrix and doing the implicit sweep nsegments = 2 * (nperiod - 1) + 1 nseg_max = maxval(nsegments) if (.not. allocated(iz_low)) then allocate (iz_low(nseg_max)) allocate (iz_mid(nseg_max)) allocate (iz_up(nseg_max)) end if !> iz_low(j) is the ig index corresponding to the inboard midplane from below (theta=-pi) within the jth segment !> iz_mid(j) is the ig index corresponding to the outboard midplane (theta=0) within the jth segment do iseg = 1, nseg_max iz_low(iseg) = -nzgrid + (iseg - 1) * nzed iz_mid(iseg) = iz_low(iseg) + nzed / 2 iz_up(iseg) = iz_low(iseg) + nzed end do end select if (.not. allocated(ikxmod)) then allocate (ikxmod(nseg_max, neigen_max, naky)) !> initialize ikxmod to nakx !> should not be necessary but just in case one tries to access !> a value beyond nsegments(ie,iky) ikxmod = nakx end if do iky = 1, naky !> only do the following once for each independent set of theta0s !> the assumption here is that all kx are on processor and sequential do ie = 1, neigen(iky) !> remap to start at theta0 = theta0_max (theta0_min) for negative (positive) kx shift !> for this set of connected theta0s iseg = 1 ikxmod(iseg, ie, iky) = ie + ikx_shift_end(ie) if (nsegments(ie, iky) > 1) then do iseg = 2, nsegments(ie, iky) ikxmod(iseg, ie, iky) = ikxmod(iseg - 1, ie, iky) + ikx_shift(ikxmod(iseg - 1, ie, iky), iky) end do end if end do end do if (allocated(ikx_shift_end)) deallocate (ikx_shift_end) if (allocated(ikx_shift)) deallocate (ikx_shift) if (.not. allocated(it_left)) allocate (it_left(ntubes)) if (.not. allocated(it_right)) allocate (it_right(ntubes)) it_right(ntubes) = 1 if (ntubes > 1) then do it = 1, ntubes - 1 it_right(it) = it + 1 end do end if it_left(1) = ntubes if (ntubes > 1) then do it = 2, ntubes it_left(it) = it - 1 end do end if !> this is the number of unique zed values in all segments but the first !> the first has one extra unique zed value (all others have one grid common !> with the previous segment due to periodicity) nzed_segment = iz_up(1) - iz_low(1) end subroutine init_extended_zgrid subroutine fill_zed_ghost_zones(it, iseg, ie, iky, g, gleft, gright) use zgrid, only: nzgrid implicit none integer, intent(in) :: it, iseg, ie, iky complex, dimension(:, :, -nzgrid:, :), intent(in) :: g complex, dimension(:), intent(out) :: gleft, gright integer :: nseg ! stream_sign > 0 --> stream speed < 0 nseg = nsegments(ie, iky) if (iseg == 1) then if (periodic(iky)) then gleft = phase_shift(iky) * g(iky, ikxmod(iseg, ie, iky), iz_up(nseg) - 2:iz_up(nseg) - 1, it) else gleft = 0.0 end if else gleft = phase_shift(iky) * g(iky, ikxmod(iseg - 1, ie, iky), iz_up(iseg - 1) - 2:iz_up(iseg - 1) - 1, it_left(it)) end if if (nseg > iseg) then ! connect to segment with larger theta-theta0 (on right) gright = g(iky, ikxmod(iseg + 1, ie, iky), iz_low(iseg + 1) + 1:iz_low(iseg + 1) + 2, it_right(it)) / phase_shift(iky) else ! apply periodic BC where necessary and zero BC otherwise if (periodic(iky)) then gright = g(iky, ikxmod(iseg, ie, iky), iz_low(1) + 1:iz_low(1) + 2, it) / phase_shift(iky) else gright = 0.0 end if end if end subroutine fill_zed_ghost_zones subroutine map_to_extended_zgrid(it, ie, iky, g, gext, ulim) use zgrid, only: nzgrid implicit none integer, intent(in) :: it, ie, iky complex, dimension(:, -nzgrid:, :), intent(in) :: g complex, dimension(:), intent(out) :: gext integer, intent(out) :: ulim integer :: iseg, ikx, itmod integer :: llim complex :: curr_shift ! avoid double-counting at boundaries between 2pi segments iseg = 1 curr_shift = 1. ikx = ikxmod(iseg, ie, iky) llim = 1; ulim = nzed_segment + 1 gext(llim:ulim) = g(ikx, iz_low(iseg):iz_up(iseg), it) * curr_shift if (nsegments(ie, iky) > 1) then itmod = it do iseg = 2, nsegments(ie, iky) curr_shift = curr_shift / phase_shift(iky) ikx = ikxmod(iseg, ie, iky) itmod = it_right(itmod) llim = ulim + 1 ulim = llim + nzed_segment - 1 gext(llim:ulim) = g(ikx, iz_low(iseg) + 1:iz_up(iseg), itmod) * curr_shift end do end if end subroutine map_to_extended_zgrid subroutine map_from_extended_zgrid(it, ie, iky, gext, g) use zgrid, only: nzgrid implicit none integer, intent(in) :: it, ie, iky complex, dimension(:), intent(in) :: gext complex, dimension(:, -nzgrid:, :), intent(in out) :: g integer :: iseg, ikx, itmod integer :: llim, ulim complex :: curr_shift iseg = 1 curr_shift = 1. ikx = ikxmod(iseg, ie, iky) llim = 1; ulim = nzed_segment + 1 g(ikx, iz_low(iseg):iz_up(iseg), it) = gext(llim:ulim) if (nsegments(ie, iky) > 1) then itmod = it do iseg = 2, nsegments(ie, iky) curr_shift = curr_shift * phase_shift(iky) llim = ulim + 1 ulim = llim + nzed_segment - 1 ikx = ikxmod(iseg, ie, iky) itmod = it_right(itmod) g(ikx, iz_low(iseg), itmod) = gext(llim - 1) * curr_shift g(ikx, iz_low(iseg) + 1:iz_up(iseg), itmod) = gext(llim:ulim) * curr_shift end do end if end subroutine map_from_extended_zgrid subroutine finish_extended_zgrid implicit none if (allocated(neigen)) deallocate (neigen) if (allocated(periodic)) deallocate (periodic) if (allocated(nsegments)) deallocate (nsegments) if (allocated(iz_low)) deallocate (iz_low, iz_mid, iz_up) if (allocated(ikxmod)) deallocate (ikxmod) if (allocated(it_right)) deallocate (it_right) if (allocated(it_left)) deallocate (it_left) if (allocated(phase_shift)) deallocate (phase_shift) extended_zgrid_initialized = .false. end subroutine finish_extended_zgrid end module extended_zgrid
extended_zgrid.f90
!Autor: Claudio Iván Esparza Castañeda !Título: Evaluar polinomios y su derivada !Descripción: Se encarga de evaluar polinomios mediante la anidación de los términos, así como la evaluación de la derivada !Fecha: 19/01/2020 program eval !Inicio del programa implicit none !Sin variables implícitas REAL, allocatable, dimension(:)::a !Vector tipo REAL con dimensión dinámica REAL::p, d, x !Varibles tipo REAL INTEGER::i, n !Variables enteras d=0.0 !Inicializar valor de derivada p=0.0 !Inicializar valor de polinomio WRITE(*, *) "Grado del polinomio" !Preguntar por el grado del polinomio READ(*, *) n allocate(a(0:n)) !Asignar valor a variable dinámica WRITE(*, *) "Coeficientes del polinomio a0+a1x+a2x²+...anx^n" !Pregunta coeficientes del polinomio do i=0, n READ(*, *) a(i) end do WRITE(*, *) "Valor para evaluar polinomio" !Preguntar valor para evaluar polinomio READ(*, *) x do i=n, 0, -1 !Recorrer el arreglo al revés d=d*x+p !Derivada=Derivada*valor+Polinomio p=p*x+a(i) !Polinomio=Polinomio*valor+elemento del vector end do deallocate(a) WRITE(*, 1) "F(x)=", p, "F'(x)=", d !Imprimir resultado con formato 1 1 format(' ', a5, f10.3, 5x, a6, f10.3) ! end program eval
13.- EvaluarPoli/Evaluar.f90
program hello print "(a)", "Hello, World!" end program hello
0_RootFS/Rootfs/bundled/testsuite/fortran/hello_world/hello_world.f
Name: Who you talking about? Margot Abrasive Parfitt Office: Where is their office? Just listen for her yelling as she goes through Death star Deathstar. Personality: Whats this person like? Still need to ask? 20051215 22:46:26 nbsp Abrasive is my middle name, my mother foresaw the need very early on. Users/MargotParfitt 20051216 00:06:55 nbsp i love the death star. i will linger and listen for you Users/MichelleAccurso 20080114 23:04:20 nbsp whats up? how did math and econ work out for ya? Users/JessicaRockwell
lab/davisWiki/MargotParfitt.f
!> A test program to run a linear cyclone itg benchmark !! at low resolution and check the growth rate module checks_mod use functional_tests public checks contains function checks() use gs2_time, only: code_dt_cfl use unit_tests, only: agrees_with implicit none logical :: checks !Check if the cfl condition matches expected value with 3% !Checking against a predefined "correct" value, this may not !be a fatal error if agreement not found. checks = agrees_with(code_dt_cfl,0.11400483899841848,0.03) end function checks end module checks_mod program cyclone_itg_low_res use functional_tests, only: test_gs2 use checks_mod, only: checks use fields_local, only: fields_local_functional use mp, only: init_mp, proc0, finish_mp use gs2_time, only: code_dt_cfl implicit none character(len=8) :: field_type integer :: length, ierr ! If you want to see the minimal linear test look at slab_itg_low_res call init_mp call test_gs2('Linear CBC ITG in single mode with field algorithm '//trim(field_type), checks) if(proc0) print*,code_dt_cfl," ",0.11400483899841848 call finish_mp end program cyclone_itg_low_res
tests/nonlinear_tests/cyclone_itg/cyclone_itg_low_res.f90
module SolverLib use constpara use graphlib implicit none type,public::methods character(len = 10)::name type(graphclass)::nwk real*8,allocatable::x(:,:) ! percentage, approach proportion real*8,allocatable::fx(:,:) !mapping function real*8,allocatable::xfa(:,:) ! link flow for each dest real*8,allocatable::logitprob(:,:) ! logit probability real*8,allocatable::lf(:),lt(:) real*8,allocatable::nf(:,:) ! node flow for each dest real*8,ALLOCATABLE::node_exp_sum(:,:) real*8,ALLOCATABLE::dial_link_like(:,:) real*8,ALLOCATABLE::dial_rlabel(:,:),dial_slabel(:,:) integer,ALLOCATABLE::rorder(:,:),sorder(:,:) ! ascend order real*8,ALLOCATABLE::dial_Wsd(:,:) real*8::ncperr,cputime,max_dist_gap logical::isNCPconverge integer::solc integer::gapfileno contains !procedure,pass::minsp=>method_init_arc_flow procedure,pass::initial_x=>initial_x procedure,pass::forward_update_flow=>forward_update_flow procedure,pass::backward_update_fx=>backward_update_fx procedure,pass::update_bush=>update_bush procedure,pass::getncperr=>getncperr procedure,pass::outputx=>outputx procedure,pass::outputod=>outputod procedure,pass::init_arc_flow=>init_arc_flow procedure,pass::node_flow=>node_flow procedure,pass::cal_fx=>cal_fx procedure,pass::geninisol=>geninisol procedure,nopass::get_bcmval=>get_bcmval procedure,PASS::inimethod=>inimethod procedure,pass::delmethod=>delmethod procedure,pass::dial_load_main =>dial_load_main procedure,pass::dial_sub_graph=>dial_sub_graph procedure,pass::dial_get_link_like=>dial_get_link_like procedure,pass::dial_foward=>dial_forward procedure,pass::dial_backward=>dial_backward end type methods contains subroutine inimethod(this) implicit none CLASS(methods)::this call this%nwk%inigraph if(.not.allocated(this%x)) then allocate(this%x(nl,ndest)) allocate(this%fx(nl,ndest)) allocate(this%xfa(nl,ndest)) allocate(this%logitprob(nl,ndest)) allocate(this%lf(nl)) allocate(this%lt(nl)) allocate(this%nf(nn,ndest)) allocate(this%node_exp_sum(nn,ndest)) allocate(this%dial_link_like(nl,ndest)) allocate(this%dial_rlabel(nn,ndest),this%dial_slabel(nn,ndest)) allocate(this%rorder(nn,ndest),this%sorder(nn,ndest)) allocate(this%dial_wsd(nl,ndest)) end if this%x=0 this%fx=0 this%xfa=0 this%logitprob = 0 this%lf=0 this%lt=0 this%nf=0 this%node_exp_sum=0 this%dial_link_like = 0 this%dial_Wsd = 0 this%rorder = 0 this%sorder = 0 end subroutine subroutine delmethod(this) implicit none class(methods)::this deallocate(this%x,this%fx,this%xfa,this%logitprob,this%lf,this%lt) deallocate(this%nf,this%node_exp_sum) deallocate(this%dial_wsd,this%dial_link_like,this%dial_rlabel,this%dial_slabel) DEALLOCATE(this%sorder,this%rorder) call this%nwk%delgraph end subroutine !TODO: check this function get_bcmval(baseval) result(res) reaL*8::res,baseval if (isConstBcm) then res = const_bcm_value else res = baseval*bcmratio endif return end function subroutine update_bush(this) implicit none class(methods)::this call this%nwk%minspantree(this%lt) call this%nwk%bfs_torder call this%nwk%getorder call this%nwk%countconect if (islogit) then call this%nwk%getsuebush end if end subroutine subroutine geninisol(this,set_nwk) implicit none CLASS(methods)::this integer::l CLASS(graphclass),optional::set_nwk real*8::max_dist_err_2 ! read network -> create topological order -> check connectivity ! compute inital x and intial y call this%nwk%readnwt(set_nwk) this%lt = this%nwk%scost !call this%nwk%readnwt(set_nwk,numlink=nl,numnode=nn,numline=nline,& !maxcomsec=maxcom,maxseclineval=maxsecline,maxlinestopval=maxlinestops) if (load_index.eq.1) then this%lt = this%nwk%scost call this%dial_sub_graph this%nwk%torder = this%sorder else call this%update_bush endif call this%init_arc_flow call this%initial_x call this%forward_update_flow(this%x,d1=nl,d2=ndest) call this%nwk%link_time(this%lf,this%lt) call this%backward_update_fx(this%fx,this%logitprob,d1=nl,d2=ndest) this%ncperr = this%getncperr(this%x,this%xfa,this%fx,this%logitprob) this%max_dist_gap = max_dist_err_2(this%x,this%logitprob,this%xfa,ncp_flow_eps,nl,ndest) if (iswriteconverge) then if (isdebug) then write(*,'(i4,a,f16.8,a,f16.8)') this%solc,',',this%ncperr,',',this%max_dist_gap end if write(this%gapfileno,'(i4,a,f16.8,a,f16.8)') this%solc,",",this%ncperr,",",this%max_dist_gap end if return end subroutine subroutine iniassignflow(this) implicit none class(methods)::this call this%nwk%minspantree(this%nwk%scost) call this%init_arc_flow return end subroutine subroutine node_flow(this) ! given arf flow get node flow use constpara implicit none class(methods)::this integer::l,nr this%nf=0.0 do nr=1,ndest do l =1,nl this%nf(this%nwk%anode(l),nr) = this%nf(this%nwk%anode(l),nr)+this%xfa(l,nr) end do end do return end subroutine !Solution class subroutine initial_x(this) use constpara implicit none class(methods)::this integer::i,l,node,nr integer::lcount this%x=0.0 if (islogit) then goto 10 end if call this%node_flow ! intial node flow do i = 1, ndest do l = 1, nl node = this%nwk%anode(l) if (this%nf(node,i).ne.0.0) then this%x(l,i) = this%xfa(l,i)/this%nf(node,i) end if end do end do do i = 1, ndest do node =1, nn if (this%nwk%subnode(node,i)) then if (this%nf(node,i).eq.0.0) then lcount = 0 do l = this%nwk%firstout(node),this%nwk%lastout(node) if(this%nwk%sublink(l,i)) then this%x(l,i) = 1.0 exit end if end do endif end if end do end do 10 if (islogit) then do nr = 1, ndest do node =1, nn if (this%nwk%subnode(node,nr)) then lcount = 0 do l = this%nwk%firstout(node),this%nwk%lastout(node) if (this%nwk%sublink(l,nr)) then lcount=lcount + 1 !if (lcount.ge.2) then ! write(*,*) " wft:2 links" !end if end if end do do l = this%nwk%firstout(node),this%nwk%lastout(node) if(this%nwk%sublink(l,nr)) then this%x(l,nr)=1.0/lcount end if end do end if end do end do end if return end subroutine subroutine backward_update_fx(this,fx1,logitprob,d1,d2) use constpara implicit none ! tail(a)--------->head(b) class(methods)::this ! real*8,intent(out)::fx1(nl,ndest) integer::d1,d2 real*8,intent(out),DIMENSION(d1,d2)::fx1 real*8,optional,DIMENSION(d1,d2)::logitprob integer::i,j,node,nr,link,ll,l real*8::link_dest_flow !update the label on the subnetwork logitprob = 0 if (.not.islogit) then fx1=large this%nwk%ndist = large do nr = 1,ndest this%nwk%ndist(this%nwk%roots(nr),nr) = 0.0 do i = nn,1,-1 node = this%nwk%torder(i,nr) if ((i.eq.nn).and.(node.ne.this%nwk%roots(nr))) then write(*,*) "Solverlib: backward update fx: check torder" pause end if if ((node.ne.0).and.this%nwk%subnode(node,nr)) then do j=this%nwk%firstin(node),this%nwk%lastin(node) link = this%nwk%backtoforward(j) if (this%nwk%sublink(link,nr)) then if (this%nwk%ndist(this%nwk%bnode(link),nr) + this%lt(link).lt. & this%nwk%ndist(this%nwk%anode(link),nr)) then this%nwk%ndist(this%nwk%anode(link),nr) & = this%nwk%ndist(this%nwk%bnode(link),nr)+this%lt(link) end if fx1(link,nr) = this%nwk%ndist(this%nwk%bnode(link),nr)+this%lt(link) end if end do end if end do end do else ! else if logit model fx1 = large this%nwk%ndist = 0 this%node_exp_sum = 0 !TODO "solver bwd check ndist label large or zero" do nr = 1, ndest this%nwk%ndist(this%nwk%roots(nr),nr) = 0.0 do i = nn,1,-1 !do i = 1,nn node = this%nwk%torder(i,nr) if ((node.eq.0)) then cycle end if if (this%nwk%toder_level(node,nr).lt.0) then this%nwk%ndist(node,nr) = large !cycle end if if (this%nwk%subnode(node,nr)) then if (node.eq.this%nwk%roots(nr)) then this%nwk%ndist(node,nr) = 0 else this%nwk%ndist(node,nr) = & !(-1/theta)*log(this%node_exp_sum(this%nwk%anode(link),nr)) (-1/theta)*log(max(this%node_exp_sum(node,nr),zero)) end if do j = this%nwk%firstin(node),this%nwk%lastin(node) link = this%nwk%backtoforward(j) !if (link.eq.66) then ! write(*,*) "wtf" !end if if (this%nwk%sublink(link,nr)) then ! if((this%x(link,nr).gt.0).and.(this%lf(link).gt.0)) then !if((this%x(link,nr).gt.0).and.(this%nf(this%nwk%anode(link),nr).gt.0.0)) then this%node_exp_sum(this%nwk%anode(link),nr) = this%node_exp_sum(this%nwk%anode(link),nr) & + exp((-theta)*(this%lt(link) + this%nwk%ndist(this%nwk%bnode(link),nr))) !end if if (this%node_exp_sum(this%nwk%anode(link),nr).lT.0.0) then write(*,*) "node = ",this%nwk%anode(link)," link = ", link write(*,*) "expvalue = ",exp((-theta)*(this%lt(link)+this%nwk%ndist(this%nwk%bnode(link),nr))) write(*,*) "backward: expum is less than 0" endif ! if ((this%nwk%anode(link).eq.18).and.(nr.eq.1)) then ! write (*,*) "debug" ! write (*,*) this%node_exp_sum(this%nwk%anode(link),nr) ! write (*,*) log(this%node_exp_sum(this%nwk%anode(link),nr)) ! end if ! this%nwk%ndist(this%nwk%anode(link),nr) = & !(-1/theta)*log(this%node_exp_sum(this%nwk%anode(link),nr)) ! (-1/theta)*log(max(this%node_exp_sum(this%nwk%anode(link),nr),zero)) link_dest_flow = this%nf(this%nwk%anode(link),nr) * this%x(link,nr) ! if (this%lf(link).eq.0) then if (link_dest_flow.eq.0) then fx1(link,nr) = this%nwk%ndist(this%nwk%bnode(link),nr) & + this%lt(link) + 1/theta ! if ( fx1(link,nr) .gt.10000) then ! write (*,*) " wtf" !end if else fx1(link,nr) = this%nwk%ndist(this%nwk%bnode(link),nr) & ! + this%lt(link)+(1+log(this%lf(link)))/theta + this%lt(link)+(1+log(link_dest_flow))/theta !if ( fx1(link,nr) .gt.10000) then ! write (*,*) " wtf" !endif end if endif end do end if end do ! do torder nodes end do ! do ndest endif if (islogit) then if(load_index.eq.0) then do nr = 1, ndest do l = 1, nl if (this%nwk%sublink(l,nr)) then if((this%x(l,nr).gt.0).and.(this%nf(this%nwk%anode(l),nr).gt.0)) then logitprob(l,nr) = & exp((-theta)*(this%lt(l)+this%nwk%ndist(this%nwk%bnode(l),nr))) & /this%node_exp_sum(this%nwk%anode(l),nr) end if if (logitprob(l,nr).gt.1+zero) then write(*,*) "get prob larger than 1" endif if (isnan(logitprob(l,nr))) then write(*,*) "wtf" end if end if end do end do else call this%dial_load_main(logitprob) endif end if return end subroutine ! this subroutine is used to update the flow for each node ! input is the flow proportion ! out put is the link flow and node flow ! Algorithm subroutine forward_update_flow(this,x0,d1,d2) use constpara implicit none class(methods)::this ! real*8,intent(in)::x0(nl,ndest) integer::d1,d2 real*8,intent(in),dimension(d1,d2)::x0 integer i,j,nr,node,link,o,d this%xfa = 0.0 this%nf = 0.0 do i=1,nod o = this%nwk%origin(i) d = this%nwk%dest(i) do j=1,ndest if (this%nwk%roots(j)==d) then nr =j exit end if enddo this%nf(o,nr) = this%nf(o,nr) + this%nwk%demand(i) end do do nr = 1,ndest do i = 1,nn node = this%nwk%torder(i,nr) if (node.ne.0) then do j = this%nwk%firstout(node),this%nwk%lastout(node) link = j if(this%nwk%sublink(link,nr).and.this%nwk%subnode(this%nwk%bnode(link),nr)) then this%xfa(link,nr) = this%nf(this%nwk%anode(link),nr)*x0(link,nr) this%nf(this%nwk%bnode(link),nr) & = this%nf(this%nwk%bnode(link),nr) + this%xfa(link,nr) end if end do end if enddo enddo forall (i=1:nl) this%lf(i)=sum(this%xfa(i,:)) end forall end subroutine !this contains two subroutine to measure the error !use constpara function getncperr(this,x,xfa,fx,logitprob) result (madf) use constpara implicit none class(methods)::this ! real*8::x(nl,ndest),xfa(nl,ndest),fx(nl,ndest) real*8,dimension(nl,ndest)::x,xfa,fx real*8,optional,dimension(nl,ndest)::logitprob real*8::madf integer::i,nr,node,j, link, tail, head real*8,dimension(nl)::lf logical,dimension(nn,ndest)::isupdated real*8,dimension(nn,ndest)::nodefx real*8::lamda, mincost,minfx,bcm,thismdf integer::bcmcount logical::isbcm(5) open(1,file='c:\gitcodes\BTNDP\results\fortran_checkmadf.txt',position="append") madf = 0.0d0 if (islogit) then nodefx = large isupdated = .false. do nr =1, ndest do i = 1,nl if (this%nwk%sublink(i,nr).and.this%nwk%subnode(this%nwk%anode(i),nr).and.this%nwk%subnode(this%nwk%bnode(i),nr)) then if (this%nwk%anode(i)/=this%nwk%roots(nr)) then node = this%nwk%anode(i) if (isupdated(node,nr)) then cycle endif do j = this%nwk%firstout(node), this%nwk%lastout(node) !if(xfa(j,nr).gt.ncp_flow_eps) then nodefx(node,nr) = min(fx(j,nr),nodefx(node,nr)) !end if enddo isupdated(node,nr) = .true. end if end if end do enddo end if do nr =1, ndest do i = 1,nl if (this%nwk%sublink(i,nr).and.this%nwk%subnode(this%nwk%anode(i),nr).and.this%nwk%subnode(this%nwk%bnode(i),nr)) then if (this%nwk%anode(i)/=this%nwk%roots(nr)) then if (islogit) then if (this%nf(this%nwk%anode(i),nr)*this%x(i,nr).gt.ncp_flow_eps) then !if (abs(this%x(i,nr)-this%logitprob(i,nr)).gt.0.001) then madf = max(madf,fx(i,nr)-nodefx(this%nwk%anode(i),nr)) !endif endif !endif !end if else if (xfa(i,nr).gt.0.1.and.(fx(i,nr)-this%nwk%ndist(this%nwk%anode(i),nr))>madf) then madf = fx(i,nr) - this%nwk%ndist(this%nwk%anode(i),nr) !write(1,'(i5,a,i5,a,i5,a,i5,a,f6.2,a,f6.2,a,f6.2,a,f6.2)') & ! caseindex,',',i,',',this%nwk%anode(i),',',nr,',',xfa(i,nr),',',fx(i,nr),',', & ! this%nwk%ndist(this%nwk%anode(i),nr),',',madf end if endif ! if to check whether it is logit endif endif end do end do if (madf.lt.ncp_eps) then this%isNCPconverge = .true. else this%isNCPconverge = .false. end if close(1) end function ! TODO: add to change to logit model ! subroutine error_euclidean_distance(f1,f0,n1,n2,error) ! implicit none ! ! integer,intent(in)::n1,n2 ! real*8,dimension(n1,n2),intent(in)::f0,f1 ! real*8::error ! integer i,j ! real*8::sum ! sum = 0.0 ! error=0.0 ! do i=1,n1 ! do j=1,n2 ! error=error+abs(f1(i,j)-f0(i,j)) ! sum=sum+f0(i,j) ! end do ! enddo ! error=error/sum !! write(*,*) "err = ", error ! return ! end subroutine ! out link flow subroutine outputx(this) use constpara implicit none class(methods)::this integer::i,j,nr,n logical::isused real*8:: largecost real*8:: printfx largecost = 1000.0 ! open(1,file='c:\gitcodes\LogitAssign\results\fortran_output_link.txt',status='old',position='append') open(1,file='c:\gitcodes\BTNDP\results\fortran_output_link.txt',status='old',position='append') ! write(1,*) "method,case,dest,link,flow,fx,lt,xprob,logitprob,tail,head" do i=1,ndest do j=1,nl ! if (this%xfa(j,i)/=0.0) then write(1,"(a5,a,i5,a,i2,a,i3,a,f10.2,a,f7.2,a,f6.2,a,f6.4,a,f6.4,a,i3,a,i3)") & this%name,',',caseindex,',', i,',',j,',',this%xfa(j,i),',',dmin1(largecost,this%fx(j,i)), ',', & this%lt(j),',',this%x(j,i),',', this%logitprob(j,i),',',this%nwk%anode(j),',',this%nwk%bnode(j) ! endif enddo end do close(1) ! open(1,file='c:\GitCodes\LogitAssign\results\fortran_output_node.txt',position='append') open(1,file='c:\GitCodes\BTNDP\results\fortran_output_node.txt',position='append') ! write(1,*) "method,case,dest,node,fout,lout,label" do nr = 1, ndest do n = 1, nn isused = .false. do j = this%nwk%firstout(n), this%nwk%lastout(n) if (this%xfa(j,nr).gt.ncp_flow_eps) then isused = .true. end if end do if (isused) then write(1,"(a5,a,i5,a,i2,a,i3,a,i3,a,i3,a,f6.2)") & this%name,',',caseindex,',',nr,',',n,',',this%nwk%firstout(n),',',this%nwk%lastout(n),',',this%nwk%ndist(n,nr) end if enddo end do close(1) end subroutine subroutine outputod(this,flow,y,d1,d2) use constpara implicit none class(methods)::this integer i,j ! real*8::flow(nl,ndest),y(nl,ndest) integer::d1,d2 real*8,DIMENSION(d1,d2)::flow,y integer q,w ! open(1,file='c:\gitcodes\logitassign\results\fortran_output_od.txt',position='append') open(1,file='c:\gitcodes\BTNDP\results\fortran_output_od.txt',position='append') do q = 1, nod do w=1,ndest if (this%nwk%roots(w).eq.this%nwk%dest(q)) then do j = 1, nl if (this%nwk%anode(j).eq.this%nwk%origin(q)) then !write(39,"(i2,1x,i3,1x,1x,f7.2)") origin(q),dest(q),y(j,w) if (flow(j,w)>0.0001) then !write(39,"(i2,1x,i3,1x,f6.2,1x,f7.2)") origin(q),dest(q),demand(q),y(j,w) !write(39,"(i2,a,i3,a,f6.2,a,f7.2)") origin(q),',',dest(q),',', demand(q),',',y(j,w) write(1,"(i5,a,i2,a,i3,a,f8.4,a,f8.4,a,f8.4)") & caseindex,',',this%nwk%origin(q),',',this%nwk%dest(q),',',this%nwk%demand(q),',',y(j,w),',',flow(j,w) exit endif endif enddo endif enddo enddo close(1) end subroutine ! subroutine method_outputpath(this,linktime, xfa) ! use constpara ! implicit none ! class(methods)::this ! integer i,j ! real*8::linktime(nl) ! real*8,intent(in)::xfa(nl,ndest) ! open(1,file='c:\gitcodes\logitassign\results\fortran_linkcost.txt' ) ! open(2,file='c:\gitcodes\logitassign\results\fortran_pathcost.txt' ) ! write(1,*) "case,linkid,linktime" ! do i = 1, nl ! write(1,'(i2,a,i3,a,f8.4)') caseindex,',',i,',',linktime(i) ! enddo ! close(1) ! write(2,*) "case,x,approchtime" ! ! the second demmension of the xfa is the destination index ! ! the first three paths blong to od pair 1-4 ! write(2,'(i3,a,f8.4,a,f8.4)') caseindex,',',xfa(3,1),',',linktime(3) ! write(2,'(i3,a,f8.4,a,f8.4)') caseindex,',',xfa(2,1),',',linktime(2)+linktime(6) ! write(2,'(i3,a,f8.4,a,f8.4)') caseindex,',',xfa(1,1),',',linktime(1)+linktime(4)+linktime(6) ! ! the following two belongs to od pair 2-4 ! write(2,'(i3,a,f8.4,a,f8.4)') caseindex,',',xfa(4,1),',',linktime(4)+linktime(6) ! write(2,'(i3,a,f8.4,a,f8.4)') caseindex,',',xfa(5,1),',',linktime(5) ! ! the last belong to od pair 3-4 ! write(2,'(i3,a,f8.4,a,f8.4)') caseindex,',',xfa(6,1),',',linktime(6) ! close(2) ! end subroutine subroutine cal_fx(this,x,fx) ! x => fx use constpara implicit none class(methods)::this real*8,intent(out)::fx(nl,ndest) real*8,intent(in)::x(nl,ndest) real*8::st,et,max_dist_err_2 call cpu_time(st) this%solc = this%solc + 1 call this%forward_update_flow(x,d1=nl,d2=ndest) ! call this%nwk%link_time(this%lf,this%stt) call this%nwk%link_time(this%lf,this%lt) call this%backward_update_fx(fx,this%logitprob,d1=nl,d2=ndest) !this%ncperr = this%getncperr(x,this%xfa,fx,this%logitprob,nl,ndest,nn) this%ncperr = this%getncperr(x,this%xfa,fx,this%logitprob) this%max_dist_gap = max_dist_err_2(x,this%logitprob,this%xfa,ncp_flow_eps,nl,ndest) call cpu_time(et) if (iswriteconverge) then if(isdebug) then write(*,'(i4,a,f16.8,a,f16.8)') this%solc,',',this%ncperr,',',this%max_dist_gap end if write(this%gapfileno,'(i4,a,f16.8,a,f16.8)') this%solc,",",this%ncperr,",",this%max_dist_gap end if return end subroutine subroutine init_arc_flow(this) implicit none class(methods)::this integer::i,o,root,nr,node,arc,j if (islogit) then return ! this%nwk%subnode = .false. ! this%nwk%sublink = .false. this%xfa=0.0 do nr =1, ndest root = this%nwk%roots(nr) ! first set the subnode and sublink do i = 1, nn if (this%nwk%pa(i,nr).ne.0) then arc = this%nwk%pa(i,nr) arc = this%nwk%backtoforward(arc) ! this%nwk%sublink(arc,nr)=.true. ! this%nwk%subnode(this%nwk%anode(arc),nr)=.true. ! this%nwk%subnode(this%nwk%bnode(arc),nr)=.true. end if end do do i = 1,nod o = this%nwk%origin(i) node = o do while (node.ne.root) arc = this%nwk%pa(node,nr) node = this%nwk%backanode(arc) arc = this%nwk%backtoforward(arc) ! this%nwk%sublink(arc,nr)=.true. ! this%xfa(arc,nr) = this%xfa(arc,nr) + this%nwk%demand(i) end do enddo end do else this%nwk%subnode = .false. this%nwk%sublink = .false. this%xfa=0.0 ! Minimum spanning tree do nr =1,ndest root = this%nwk%roots(nr) do i = 1, nn if (this%nwk%pa(i,nr).ne.0) then arc = this%nwk%pa(i,nr) arc = this%nwk%backtoforward(arc) this%nwk%sublink(arc,nr)=.true. this%nwk%subnode(this%nwk%anode(arc),nr)=.true. this%nwk%subnode(this%nwk%bnode(arc),nr)=.true. end if end do do i=1,nod o=this%nwk%origin(i) node=o do while (node.ne.root) arc = this%nwk%pa(node,nr) this%nwk%sublink(arc,nr)=.true. node = this%nwk%backanode(arc) arc = this%nwk%backtoforward(arc) this%xfa(arc,nr) = this%xfa(arc,nr) + this%nwk%demand(i) end do enddo end do end if end subroutine ! dial algorithm solver subroutine dial_load_main(this,prob) implicit none CLASS(methods)::this real*8,intent(inout)::prob(nl,ndest) ! this%lt= this%nwk%scost call this%dial_sub_graph this%nwk%torder = this%sorder call this%dial_get_link_like call this%dial_backward call this%dial_foward(prob) end subroutine subroutine dial_sub_graph(this) use constpara implicit none integer::r,s,w,i,nr,l,j class(methods)::this this%nwk%sublink =.false. this%nwk%subnode =.false. do w = 1,nod r = this%nwk%origin(w) s = this%nwk%dest(w) do i = 1, ndest if (s.eq.this%nwk%roots(i)) then nr = i exit end if enddo ! from r to all nodes call sp(r,this%lt,this%nwk%firstout,this%nwk%lastout,this%nwk%pa(:,nr),this%nwk%bnode) this%dial_rlabel(:,nr) = dist(:) call sort(-1*this%dial_rlabel(:,nr),this%rorder(:,nr),nn) ! from s to all nodes call rsp(s,this%nwk%scost,this%nwk%firstin,this%nwk%lastin,this%nwk%pa(:,nr),this%nwk%backbnode,this%nwk%backtoforward) this%dial_slabel(:,nr) = dist(:) call sort(-1*this%dial_slabel(:,nr),this%sorder(:,nr),nn) do l = 1,nl i = this%nwk%anode(l) j = this%nwk%bnode(l) if ((this%dial_rlabel(i,nr).lt.this%dial_rlabel(j,nr)).and.(this%dial_slabel(i,nr).gt.this%dial_slabel(j,nr))) then this%nwk%sublink(l,nr) = .true. this%nwk%subnode(i,nr) = .true. this%nwk%subnode(j,nr) = .true. end if end do enddo end subroutine ! compute the link likelyhood subroutine dial_get_link_like(this) implicit none integer::l,nr,i,j CLASS(methods)::this do nr = 1, ndest do l = 1, nl i = this%nwk%anode(l) j = this%nwk%bnode(l) if (this%nwk%sublink(l,nr)) then this%dial_link_like(l,nr) = exp(theta*(this%dial_rlabel(j,nr)-this%dial_rlabel(i,nr)-this%lt(l))) ! write(*,*) "i = ",i," j = ",j," val = ",this%dial_rlabel(j,nr)-this%dial_rlabel(i,nr)-this%lt(l),& ! " L = ", this%dial_link_like(l,nr) else this%dial_link_like(l,nr) = 0 endif end do end do end subroutine subroutine dial_backward(this) implicit none integer::nr,i,now,l,ol,link class(methods)::this real*8::sumwsd do nr = 1, ndest this%dial_Wsd(:,nr) = 0 ! call sort(-1*this%dial_slabel(:,nr),this%sorder(:,nr),nn) do i = 1, nn now = this%sorder(i,nr) do link = this%nwk%firstin(now),this%nwk%lastin(now) l=this%nwk%backtoforward(link) if (now.eq.this%nwk%roots(nr)) then !this%dial_Wsd(l,nr) = 1 this%dial_Wsd(l,nr) = this%dial_link_like(l,nr) else sumwsd = 0 do ol = this%nwk%firstout(now), this%nwk%lastout(now) sumwsd = sumwsd + this%dial_Wsd(ol,nr) enddo this%dial_Wsd(l,nr) = this%dial_link_like(l,nr)*sumwsd endif ! write(*,*) "i = ",this%nwk%anode(l), " j =",this%nwk%bnode(l), " val=",& ! this%dial_Wsd(l,nr) enddo enddo end do end subroutine subroutine dial_forward(this,prob) implicit none class(methods)::this integer::nr,i,now,l,a,b real*8::sumwsd real*8::prob(nl,ndest) do nr = 1, ndest ! call sort(-1*this%dial_rlabel(:,nr),this%rorder(:,nr),nn) do i = 1, nn now = this%rorder(i,nr) sumwsd = 0 do l = this%nwk%firstout(now), this%nwk%lastout(now) sumwsd = this%dial_Wsd(l,nr) + sumwsd enddo do l = this%nwk%firstout(now), this%nwk%lastout(now) if (sumwsd .eq.0) then prob(l,nr) = 0 else prob(l,nr) = this%dial_Wsd(l,nr)/sumwsd end if enddo enddo do l = 1, nl a = this%nwk%anode(l) b = this%nwk%bnode(l) enddo end do end subroutine end module
RTND/RTND/solverlib.f90
!*==cuncsd2by1.f90 processed by SPAG 7.51RB at 20:08 on 3 Mar 2022 !> \brief \b CUNCSD2BY1 ! ! =========== DOCUMENTATION =========== ! ! Online html documentation available at ! http://www.netlib.org/lapack/explore-html/ ! !> \htmlonly !> Download CUNCSD2BY1 + dependencies !> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cuncsd2by1.f"> !> [TGZ]</a> !> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cuncsd2by1.f"> !> [ZIP]</a> !> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cuncsd2by1.f"> !> [TXT]</a> !> \endhtmlonly ! ! Definition: ! =========== ! ! SUBROUTINE CUNCSD2BY1( JOBU1, JOBU2, JOBV1T, M, P, Q, X11, LDX11, ! X21, LDX21, THETA, U1, LDU1, U2, LDU2, V1T, ! LDV1T, WORK, LWORK, RWORK, LRWORK, IWORK, ! INFO ) ! ! .. Scalar Arguments .. ! CHARACTER JOBU1, JOBU2, JOBV1T ! INTEGER INFO, LDU1, LDU2, LDV1T, LWORK, LDX11, LDX21, ! $ M, P, Q ! INTEGER LRWORK, LRWORKMIN, LRWORKOPT ! .. ! .. Array Arguments .. ! REAL RWORK(*) ! REAL THETA(*) ! COMPLEX U1(LDU1,*), U2(LDU2,*), V1T(LDV1T,*), WORK(*), ! $ X11(LDX11,*), X21(LDX21,*) ! INTEGER IWORK(*) ! .. ! ! !> \par Purpose: ! ============= !> !>\verbatim !> !> CUNCSD2BY1 computes the CS decomposition of an M-by-Q matrix X with !> orthonormal columns that has been partitioned into a 2-by-1 block !> structure: !> !> [ I1 0 0 ] !> [ 0 C 0 ] !> [ X11 ] [ U1 | ] [ 0 0 0 ] !> X = [-----] = [---------] [----------] V1**T . !> [ X21 ] [ | U2 ] [ 0 0 0 ] !> [ 0 S 0 ] !> [ 0 0 I2] !> !> X11 is P-by-Q. The unitary matrices U1, U2, and V1 are P-by-P, !> (M-P)-by-(M-P), and Q-by-Q, respectively. C and S are R-by-R !> nonnegative diagonal matrices satisfying C^2 + S^2 = I, in which !> R = MIN(P,M-P,Q,M-Q). I1 is a K1-by-K1 identity matrix and I2 is a !> K2-by-K2 identity matrix, where K1 = MAX(Q+P-M,0), K2 = MAX(Q-P,0). !> !> \endverbatim ! ! Arguments: ! ========== ! !> \param[in] JOBU1 !> \verbatim !> JOBU1 is CHARACTER !> = 'Y': U1 is computed; !> otherwise: U1 is not computed. !> \endverbatim !> !> \param[in] JOBU2 !> \verbatim !> JOBU2 is CHARACTER !> = 'Y': U2 is computed; !> otherwise: U2 is not computed. !> \endverbatim !> !> \param[in] JOBV1T !> \verbatim !> JOBV1T is CHARACTER !> = 'Y': V1T is computed; !> otherwise: V1T is not computed. !> \endverbatim !> !> \param[in] M !> \verbatim !> M is INTEGER !> The number of rows in X. !> \endverbatim !> !> \param[in] P !> \verbatim !> P is INTEGER !> The number of rows in X11. 0 <= P <= M. !> \endverbatim !> !> \param[in] Q !> \verbatim !> Q is INTEGER !> The number of columns in X11 and X21. 0 <= Q <= M. !> \endverbatim !> !> \param[in,out] X11 !> \verbatim !> X11 is COMPLEX array, dimension (LDX11,Q) !> On entry, part of the unitary matrix whose CSD is desired. !> \endverbatim !> !> \param[in] LDX11 !> \verbatim !> LDX11 is INTEGER !> The leading dimension of X11. LDX11 >= MAX(1,P). !> \endverbatim !> !> \param[in,out] X21 !> \verbatim !> X21 is COMPLEX array, dimension (LDX21,Q) !> On entry, part of the unitary matrix whose CSD is desired. !> \endverbatim !> !> \param[in] LDX21 !> \verbatim !> LDX21 is INTEGER !> The leading dimension of X21. LDX21 >= MAX(1,M-P). !> \endverbatim !> !> \param[out] THETA !> \verbatim !> THETA is REAL array, dimension (R), in which R = !> MIN(P,M-P,Q,M-Q). !> C = DIAG( COS(THETA(1)), ... , COS(THETA(R)) ) and !> S = DIAG( SIN(THETA(1)), ... , SIN(THETA(R)) ). !> \endverbatim !> !> \param[out] U1 !> \verbatim !> U1 is COMPLEX array, dimension (P) !> If JOBU1 = 'Y', U1 contains the P-by-P unitary matrix U1. !> \endverbatim !> !> \param[in] LDU1 !> \verbatim !> LDU1 is INTEGER !> The leading dimension of U1. If JOBU1 = 'Y', LDU1 >= !> MAX(1,P). !> \endverbatim !> !> \param[out] U2 !> \verbatim !> U2 is COMPLEX array, dimension (M-P) !> If JOBU2 = 'Y', U2 contains the (M-P)-by-(M-P) unitary !> matrix U2. !> \endverbatim !> !> \param[in] LDU2 !> \verbatim !> LDU2 is INTEGER !> The leading dimension of U2. If JOBU2 = 'Y', LDU2 >= !> MAX(1,M-P). !> \endverbatim !> !> \param[out] V1T !> \verbatim !> V1T is COMPLEX array, dimension (Q) !> If JOBV1T = 'Y', V1T contains the Q-by-Q matrix unitary !> matrix V1**T. !> \endverbatim !> !> \param[in] LDV1T !> \verbatim !> LDV1T is INTEGER !> The leading dimension of V1T. If JOBV1T = 'Y', LDV1T >= !> MAX(1,Q). !> \endverbatim !> !> \param[out] WORK !> \verbatim !> WORK is COMPLEX array, dimension (MAX(1,LWORK)) !> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. !> \endverbatim !> !> \param[in] LWORK !> \verbatim !> LWORK is INTEGER !> The dimension of the array WORK. !> !> If LWORK = -1, then a workspace query is assumed; the routine !> only calculates the optimal size of the WORK and RWORK !> arrays, returns this value as the first entry of the WORK !> and RWORK array, respectively, and no error message related !> to LWORK or LRWORK is issued by XERBLA. !> \endverbatim !> !> \param[out] RWORK !> \verbatim !> RWORK is REAL array, dimension (MAX(1,LRWORK)) !> On exit, if INFO = 0, RWORK(1) returns the optimal LRWORK. !> If INFO > 0 on exit, RWORK(2:R) contains the values PHI(1), !> ..., PHI(R-1) that, together with THETA(1), ..., THETA(R), !> define the matrix in intermediate bidiagonal-block form !> remaining after nonconvergence. INFO specifies the number !> of nonzero PHI's. !> \endverbatim !> !> \param[in] LRWORK !> \verbatim !> LRWORK is INTEGER !> The dimension of the array RWORK. !> !> If LRWORK=-1, then a workspace query is assumed; the routine !> only calculates the optimal size of the WORK and RWORK !> arrays, returns this value as the first entry of the WORK !> and RWORK array, respectively, and no error message related !> to LWORK or LRWORK is issued by XERBLA. !> \endverbatim ! !> \param[out] IWORK !> \verbatim !> IWORK is INTEGER array, dimension (M-MIN(P,M-P,Q,M-Q)) !> \endverbatim !> !> \param[out] INFO !> \verbatim !> INFO is INTEGER !> = 0: successful exit. !> < 0: if INFO = -i, the i-th argument had an illegal value. !> > 0: CBBCSD did not converge. See the description of WORK !> above for details. !> \endverbatim ! !> \par References: ! ================ !> !> [1] Brian D. Sutton. Computing the complete CS decomposition. Numer. !> Algorithms, 50(1):33-65, 2009. ! ! Authors: ! ======== ! !> \author Univ. of Tennessee !> \author Univ. of California Berkeley !> \author Univ. of Colorado Denver !> \author NAG Ltd. ! !> \date June 2016 ! !> \ingroup complexOTHERcomputational ! ! ===================================================================== SUBROUTINE CUNCSD2BY1(Jobu1,Jobu2,Jobv1t,M,P,Q,X11,Ldx11,X21, & & Ldx21,Theta,U1,Ldu1,U2,Ldu2,V1t,Ldv1t,Work, & & Lwork,Rwork,Lrwork,Iwork,Info) IMPLICIT NONE !*--CUNCSD2BY1261 ! ! -- LAPACK computational routine (version 3.7.1) -- ! -- LAPACK is a software package provided by Univ. of Tennessee, -- ! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- ! June 2016 ! ! .. Scalar Arguments .. CHARACTER Jobu1 , Jobu2 , Jobv1t INTEGER Info , Ldu1 , Ldu2 , Ldv1t , Lwork , Ldx11 , Ldx21 , M , & & P , Q INTEGER Lrwork , lrworkmin , lrworkopt ! .. ! .. Array Arguments .. REAL Rwork(*) REAL Theta(*) COMPLEX U1(Ldu1,*) , U2(Ldu2,*) , V1t(Ldv1t,*) , Work(*) , & & X11(Ldx11,*) , X21(Ldx21,*) INTEGER Iwork(*) ! .. ! ! ===================================================================== ! ! .. Parameters .. COMPLEX ONE , ZERO PARAMETER (ONE=(1.0E0,0.0E0),ZERO=(0.0E0,0.0E0)) ! .. ! .. Local Scalars .. INTEGER childinfo , i , ib11d , ib11e , ib12d , ib12e , ib21d , & & ib21e , ib22d , ib22e , ibbcsd , iorbdb , iorglq , & & iorgqr , iphi , itaup1 , itaup2 , itauq1 , j , lbbcsd , & & lorbdb , lorglq , lorglqmin , lorglqopt , lorgqr , & & lorgqrmin , lorgqropt , lworkmin , lworkopt , r LOGICAL lquery , wantu1 , wantu2 , wantv1t ! .. ! .. Local Arrays .. REAL dum(1) COMPLEX cdum(1,1) ! .. ! .. External Subroutines .. EXTERNAL CBBCSD , CCOPY , CLACPY , CLAPMR , CLAPMT , CUNBDB1 , & & CUNBDB2 , CUNBDB3 , CUNBDB4 , CUNGLQ , CUNGQR , XERBLA ! .. ! .. External Functions .. LOGICAL LSAME EXTERNAL LSAME ! .. ! .. Intrinsic Function .. INTRINSIC INT , MAX , MIN ! .. ! .. Executable Statements .. ! ! Test input arguments ! Info = 0 wantu1 = LSAME(Jobu1,'Y') wantu2 = LSAME(Jobu2,'Y') wantv1t = LSAME(Jobv1t,'Y') lquery = (Lwork==-1) .OR. (Lrwork==-1) ! IF ( M<0 ) THEN Info = -4 ELSEIF ( P<0 .OR. P>M ) THEN Info = -5 ELSEIF ( Q<0 .OR. Q>M ) THEN Info = -6 ELSEIF ( Ldx11<MAX(1,P) ) THEN Info = -8 ELSEIF ( Ldx21<MAX(1,M-P) ) THEN Info = -10 ELSEIF ( wantu1 .AND. Ldu1<MAX(1,P) ) THEN Info = -13 ELSEIF ( wantu2 .AND. Ldu2<MAX(1,M-P) ) THEN Info = -15 ELSEIF ( wantv1t .AND. Ldv1t<MAX(1,Q) ) THEN Info = -17 ENDIF ! r = MIN(P,M-P,Q,M-Q) ! ! Compute workspace ! ! WORK layout: ! |-----------------------------------------| ! | LWORKOPT (1) | ! |-----------------------------------------| ! | TAUP1 (MAX(1,P)) | ! | TAUP2 (MAX(1,M-P)) | ! | TAUQ1 (MAX(1,Q)) | ! |-----------------------------------------| ! | CUNBDB WORK | CUNGQR WORK | CUNGLQ WORK | ! | | | | ! | | | | ! | | | | ! | | | | ! |-----------------------------------------| ! RWORK layout: ! |------------------| ! | LRWORKOPT (1) | ! |------------------| ! | PHI (MAX(1,R-1)) | ! |------------------| ! | B11D (R) | ! | B11E (R-1) | ! | B12D (R) | ! | B12E (R-1) | ! | B21D (R) | ! | B21E (R-1) | ! | B22D (R) | ! | B22E (R-1) | ! | CBBCSD RWORK | ! |------------------| ! IF ( Info==0 ) THEN iphi = 2 ib11d = iphi + MAX(1,r-1) ib11e = ib11d + MAX(1,r) ib12d = ib11e + MAX(1,r-1) ib12e = ib12d + MAX(1,r) ib21d = ib12e + MAX(1,r-1) ib21e = ib21d + MAX(1,r) ib22d = ib21e + MAX(1,r-1) ib22e = ib22d + MAX(1,r) ibbcsd = ib22e + MAX(1,r-1) itaup1 = 2 itaup2 = itaup1 + MAX(1,P) itauq1 = itaup2 + MAX(1,M-P) iorbdb = itauq1 + MAX(1,Q) iorgqr = itauq1 + MAX(1,Q) iorglq = itauq1 + MAX(1,Q) lorgqrmin = 1 lorgqropt = 1 lorglqmin = 1 lorglqopt = 1 IF ( r==Q ) THEN CALL CUNBDB1(M,P,Q,X11,Ldx11,X21,Ldx21,Theta,dum,cdum,cdum, & & cdum,Work,-1,childinfo) lorbdb = INT(Work(1)) IF ( wantu1 .AND. P>0 ) THEN CALL CUNGQR(P,P,Q,U1,Ldu1,cdum,Work(1),-1,childinfo) lorgqrmin = MAX(lorgqrmin,P) lorgqropt = MAX(lorgqropt,INT(Work(1))) ENDIF IF ( wantu2 .AND. M>P ) THEN CALL CUNGQR(M-P,M-P,Q,U2,Ldu2,cdum,Work(1),-1,childinfo) lorgqrmin = MAX(lorgqrmin,M-P) lorgqropt = MAX(lorgqropt,INT(Work(1))) ENDIF IF ( wantv1t .AND. Q>0 ) THEN CALL CUNGLQ(Q-1,Q-1,Q-1,V1t,Ldv1t,cdum,Work(1),-1, & & childinfo) lorglqmin = MAX(lorglqmin,Q-1) lorglqopt = MAX(lorglqopt,INT(Work(1))) ENDIF CALL CBBCSD(Jobu1,Jobu2,Jobv1t,'N','N',M,P,Q,Theta,dum(1), & & U1,Ldu1,U2,Ldu2,V1t,Ldv1t,cdum,1,dum,dum,dum, & & dum,dum,dum,dum,dum,Rwork(1),-1,childinfo) lbbcsd = INT(Rwork(1)) ELSEIF ( r==P ) THEN CALL CUNBDB2(M,P,Q,X11,Ldx11,X21,Ldx21,Theta,dum,cdum,cdum, & & cdum,Work(1),-1,childinfo) lorbdb = INT(Work(1)) IF ( wantu1 .AND. P>0 ) THEN CALL CUNGQR(P-1,P-1,P-1,U1(2,2),Ldu1,cdum,Work(1),-1, & & childinfo) lorgqrmin = MAX(lorgqrmin,P-1) lorgqropt = MAX(lorgqropt,INT(Work(1))) ENDIF IF ( wantu2 .AND. M>P ) THEN CALL CUNGQR(M-P,M-P,Q,U2,Ldu2,cdum,Work(1),-1,childinfo) lorgqrmin = MAX(lorgqrmin,M-P) lorgqropt = MAX(lorgqropt,INT(Work(1))) ENDIF IF ( wantv1t .AND. Q>0 ) THEN CALL CUNGLQ(Q,Q,r,V1t,Ldv1t,cdum,Work(1),-1,childinfo) lorglqmin = MAX(lorglqmin,Q) lorglqopt = MAX(lorglqopt,INT(Work(1))) ENDIF CALL CBBCSD(Jobv1t,'N',Jobu1,Jobu2,'T',M,Q,P,Theta,dum,V1t, & & Ldv1t,cdum,1,U1,Ldu1,U2,Ldu2,dum,dum,dum,dum, & & dum,dum,dum,dum,Rwork(1),-1,childinfo) lbbcsd = INT(Rwork(1)) ELSEIF ( r==M-P ) THEN CALL CUNBDB3(M,P,Q,X11,Ldx11,X21,Ldx21,Theta,dum,cdum,cdum, & & cdum,Work(1),-1,childinfo) lorbdb = INT(Work(1)) IF ( wantu1 .AND. P>0 ) THEN CALL CUNGQR(P,P,Q,U1,Ldu1,cdum,Work(1),-1,childinfo) lorgqrmin = MAX(lorgqrmin,P) lorgqropt = MAX(lorgqropt,INT(Work(1))) ENDIF IF ( wantu2 .AND. M>P ) THEN CALL CUNGQR(M-P-1,M-P-1,M-P-1,U2(2,2),Ldu2,cdum,Work(1), & & -1,childinfo) lorgqrmin = MAX(lorgqrmin,M-P-1) lorgqropt = MAX(lorgqropt,INT(Work(1))) ENDIF IF ( wantv1t .AND. Q>0 ) THEN CALL CUNGLQ(Q,Q,r,V1t,Ldv1t,cdum,Work(1),-1,childinfo) lorglqmin = MAX(lorglqmin,Q) lorglqopt = MAX(lorglqopt,INT(Work(1))) ENDIF CALL CBBCSD('N',Jobv1t,Jobu2,Jobu1,'T',M,M-Q,M-P,Theta,dum, & & cdum,1,V1t,Ldv1t,U2,Ldu2,U1,Ldu1,dum,dum,dum, & & dum,dum,dum,dum,dum,Rwork(1),-1,childinfo) lbbcsd = INT(Rwork(1)) ELSE CALL CUNBDB4(M,P,Q,X11,Ldx11,X21,Ldx21,Theta,dum,cdum,cdum, & & cdum,cdum,Work(1),-1,childinfo) lorbdb = M + INT(Work(1)) IF ( wantu1 .AND. P>0 ) THEN CALL CUNGQR(P,P,M-Q,U1,Ldu1,cdum,Work(1),-1,childinfo) lorgqrmin = MAX(lorgqrmin,P) lorgqropt = MAX(lorgqropt,INT(Work(1))) ENDIF IF ( wantu2 .AND. M>P ) THEN CALL CUNGQR(M-P,M-P,M-Q,U2,Ldu2,cdum,Work(1),-1, & & childinfo) lorgqrmin = MAX(lorgqrmin,M-P) lorgqropt = MAX(lorgqropt,INT(Work(1))) ENDIF IF ( wantv1t .AND. Q>0 ) THEN CALL CUNGLQ(Q,Q,Q,V1t,Ldv1t,cdum,Work(1),-1,childinfo) lorglqmin = MAX(lorglqmin,Q) lorglqopt = MAX(lorglqopt,INT(Work(1))) ENDIF CALL CBBCSD(Jobu2,Jobu1,'N',Jobv1t,'N',M,M-P,M-Q,Theta,dum, & & U2,Ldu2,U1,Ldu1,cdum,1,V1t,Ldv1t,dum,dum,dum, & & dum,dum,dum,dum,dum,Rwork(1),-1,childinfo) lbbcsd = INT(Rwork(1)) ENDIF lrworkmin = ibbcsd + lbbcsd - 1 lrworkopt = lrworkmin Rwork(1) = lrworkopt lworkmin = MAX(iorbdb+lorbdb-1,iorgqr+lorgqrmin-1, & & iorglq+lorglqmin-1) lworkopt = MAX(iorbdb+lorbdb-1,iorgqr+lorgqropt-1, & & iorglq+lorglqopt-1) Work(1) = lworkopt IF ( Lwork<lworkmin .AND. .NOT.lquery ) Info = -19 IF ( Lrwork<lrworkmin .AND. .NOT.lquery ) Info = -21 ENDIF IF ( Info/=0 ) THEN CALL XERBLA('CUNCSD2BY1',-Info) RETURN ELSEIF ( lquery ) THEN RETURN ENDIF lorgqr = Lwork - iorgqr + 1 lorglq = Lwork - iorglq + 1 ! ! Handle four cases separately: R = Q, R = P, R = M-P, and R = M-Q, ! in which R = MIN(P,M-P,Q,M-Q) ! IF ( r==Q ) THEN ! ! Case 1: R = Q ! ! Simultaneously bidiagonalize X11 and X21 ! CALL CUNBDB1(M,P,Q,X11,Ldx11,X21,Ldx21,Theta,Rwork(iphi), & & Work(itaup1),Work(itaup2),Work(itauq1), & & Work(iorbdb),lorbdb,childinfo) ! ! Accumulate Householder reflectors ! IF ( wantu1 .AND. P>0 ) THEN CALL CLACPY('L',P,Q,X11,Ldx11,U1,Ldu1) CALL CUNGQR(P,P,Q,U1,Ldu1,Work(itaup1),Work(iorgqr),lorgqr, & & childinfo) ENDIF IF ( wantu2 .AND. M>P ) THEN CALL CLACPY('L',M-P,Q,X21,Ldx21,U2,Ldu2) CALL CUNGQR(M-P,M-P,Q,U2,Ldu2,Work(itaup2),Work(iorgqr), & & lorgqr,childinfo) ENDIF IF ( wantv1t .AND. Q>0 ) THEN V1t(1,1) = ONE DO j = 2 , Q V1t(1,j) = ZERO V1t(j,1) = ZERO ENDDO CALL CLACPY('U',Q-1,Q-1,X21(1,2),Ldx21,V1t(2,2),Ldv1t) CALL CUNGLQ(Q-1,Q-1,Q-1,V1t(2,2),Ldv1t,Work(itauq1), & & Work(iorglq),lorglq,childinfo) ENDIF ! ! Simultaneously diagonalize X11 and X21. ! CALL CBBCSD(Jobu1,Jobu2,Jobv1t,'N','N',M,P,Q,Theta,Rwork(iphi),& & U1,Ldu1,U2,Ldu2,V1t,Ldv1t,cdum,1,Rwork(ib11d), & & Rwork(ib11e),Rwork(ib12d),Rwork(ib12e),Rwork(ib21d)& & ,Rwork(ib21e),Rwork(ib22d),Rwork(ib22e), & & Rwork(ibbcsd),Lrwork-ibbcsd+1,childinfo) ! ! Permute rows and columns to place zero submatrices in ! preferred positions ! IF ( Q>0 .AND. wantu2 ) THEN DO i = 1 , Q Iwork(i) = M - P - Q + i ENDDO DO i = Q + 1 , M - P Iwork(i) = i - Q ENDDO CALL CLAPMT(.FALSE.,M-P,M-P,U2,Ldu2,Iwork) ENDIF ELSEIF ( r==P ) THEN ! ! Case 2: R = P ! ! Simultaneously bidiagonalize X11 and X21 ! CALL CUNBDB2(M,P,Q,X11,Ldx11,X21,Ldx21,Theta,Rwork(iphi), & & Work(itaup1),Work(itaup2),Work(itauq1), & & Work(iorbdb),lorbdb,childinfo) ! ! Accumulate Householder reflectors ! IF ( wantu1 .AND. P>0 ) THEN U1(1,1) = ONE DO j = 2 , P U1(1,j) = ZERO U1(j,1) = ZERO ENDDO CALL CLACPY('L',P-1,P-1,X11(2,1),Ldx11,U1(2,2),Ldu1) CALL CUNGQR(P-1,P-1,P-1,U1(2,2),Ldu1,Work(itaup1), & & Work(iorgqr),lorgqr,childinfo) ENDIF IF ( wantu2 .AND. M>P ) THEN CALL CLACPY('L',M-P,Q,X21,Ldx21,U2,Ldu2) CALL CUNGQR(M-P,M-P,Q,U2,Ldu2,Work(itaup2),Work(iorgqr), & & lorgqr,childinfo) ENDIF IF ( wantv1t .AND. Q>0 ) THEN CALL CLACPY('U',P,Q,X11,Ldx11,V1t,Ldv1t) CALL CUNGLQ(Q,Q,r,V1t,Ldv1t,Work(itauq1),Work(iorglq), & & lorglq,childinfo) ENDIF ! ! Simultaneously diagonalize X11 and X21. ! CALL CBBCSD(Jobv1t,'N',Jobu1,Jobu2,'T',M,Q,P,Theta,Rwork(iphi),& & V1t,Ldv1t,cdum,1,U1,Ldu1,U2,Ldu2,Rwork(ib11d), & & Rwork(ib11e),Rwork(ib12d),Rwork(ib12e),Rwork(ib21d)& & ,Rwork(ib21e),Rwork(ib22d),Rwork(ib22e), & & Rwork(ibbcsd),lbbcsd,childinfo) ! ! Permute rows and columns to place identity submatrices in ! preferred positions ! IF ( Q>0 .AND. wantu2 ) THEN DO i = 1 , Q Iwork(i) = M - P - Q + i ENDDO DO i = Q + 1 , M - P Iwork(i) = i - Q ENDDO CALL CLAPMT(.FALSE.,M-P,M-P,U2,Ldu2,Iwork) ENDIF ELSEIF ( r==M-P ) THEN ! ! Case 3: R = M-P ! ! Simultaneously bidiagonalize X11 and X21 ! CALL CUNBDB3(M,P,Q,X11,Ldx11,X21,Ldx21,Theta,Rwork(iphi), & & Work(itaup1),Work(itaup2),Work(itauq1), & & Work(iorbdb),lorbdb,childinfo) ! ! Accumulate Householder reflectors ! IF ( wantu1 .AND. P>0 ) THEN CALL CLACPY('L',P,Q,X11,Ldx11,U1,Ldu1) CALL CUNGQR(P,P,Q,U1,Ldu1,Work(itaup1),Work(iorgqr),lorgqr, & & childinfo) ENDIF IF ( wantu2 .AND. M>P ) THEN U2(1,1) = ONE DO j = 2 , M - P U2(1,j) = ZERO U2(j,1) = ZERO ENDDO CALL CLACPY('L',M-P-1,M-P-1,X21(2,1),Ldx21,U2(2,2),Ldu2) CALL CUNGQR(M-P-1,M-P-1,M-P-1,U2(2,2),Ldu2,Work(itaup2), & & Work(iorgqr),lorgqr,childinfo) ENDIF IF ( wantv1t .AND. Q>0 ) THEN CALL CLACPY('U',M-P,Q,X21,Ldx21,V1t,Ldv1t) CALL CUNGLQ(Q,Q,r,V1t,Ldv1t,Work(itauq1),Work(iorglq), & & lorglq,childinfo) ENDIF ! ! Simultaneously diagonalize X11 and X21. ! CALL CBBCSD('N',Jobv1t,Jobu2,Jobu1,'T',M,M-Q,M-P,Theta, & & Rwork(iphi),cdum,1,V1t,Ldv1t,U2,Ldu2,U1,Ldu1, & & Rwork(ib11d),Rwork(ib11e),Rwork(ib12d),Rwork(ib12e)& & ,Rwork(ib21d),Rwork(ib21e),Rwork(ib22d), & & Rwork(ib22e),Rwork(ibbcsd),lbbcsd,childinfo) ! ! Permute rows and columns to place identity submatrices in ! preferred positions ! IF ( Q>r ) THEN DO i = 1 , r Iwork(i) = Q - r + i ENDDO DO i = r + 1 , Q Iwork(i) = i - r ENDDO IF ( wantu1 ) CALL CLAPMT(.FALSE.,P,Q,U1,Ldu1,Iwork) IF ( wantv1t ) CALL CLAPMR(.FALSE.,Q,Q,V1t,Ldv1t,Iwork) ENDIF ELSE ! ! Case 4: R = M-Q ! ! Simultaneously bidiagonalize X11 and X21 ! CALL CUNBDB4(M,P,Q,X11,Ldx11,X21,Ldx21,Theta,Rwork(iphi), & & Work(itaup1),Work(itaup2),Work(itauq1), & & Work(iorbdb),Work(iorbdb+M),lorbdb-M,childinfo) ! ! Accumulate Householder reflectors ! IF ( wantu2 .AND. M>P ) CALL CCOPY(M-P,Work(iorbdb+P),1,U2,1) IF ( wantu1 .AND. P>0 ) THEN CALL CCOPY(P,Work(iorbdb),1,U1,1) DO j = 2 , P U1(1,j) = ZERO ENDDO CALL CLACPY('L',P-1,M-Q-1,X11(2,1),Ldx11,U1(2,2),Ldu1) CALL CUNGQR(P,P,M-Q,U1,Ldu1,Work(itaup1),Work(iorgqr), & & lorgqr,childinfo) ENDIF IF ( wantu2 .AND. M>P ) THEN DO j = 2 , M - P U2(1,j) = ZERO ENDDO CALL CLACPY('L',M-P-1,M-Q-1,X21(2,1),Ldx21,U2(2,2),Ldu2) CALL CUNGQR(M-P,M-P,M-Q,U2,Ldu2,Work(itaup2),Work(iorgqr), & & lorgqr,childinfo) ENDIF IF ( wantv1t .AND. Q>0 ) THEN CALL CLACPY('U',M-Q,Q,X21,Ldx21,V1t,Ldv1t) CALL CLACPY('U',P-(M-Q),Q-(M-Q),X11(M-Q+1,M-Q+1),Ldx11, & & V1t(M-Q+1,M-Q+1),Ldv1t) CALL CLACPY('U',-P+Q,Q-P,X21(M-Q+1,P+1),Ldx21,V1t(P+1,P+1), & & Ldv1t) CALL CUNGLQ(Q,Q,Q,V1t,Ldv1t,Work(itauq1),Work(iorglq), & & lorglq,childinfo) ENDIF ! ! Simultaneously diagonalize X11 and X21. ! CALL CBBCSD(Jobu2,Jobu1,'N',Jobv1t,'N',M,M-P,M-Q,Theta, & & Rwork(iphi),U2,Ldu2,U1,Ldu1,cdum,1,V1t,Ldv1t, & & Rwork(ib11d),Rwork(ib11e),Rwork(ib12d),Rwork(ib12e)& & ,Rwork(ib21d),Rwork(ib21e),Rwork(ib22d), & & Rwork(ib22e),Rwork(ibbcsd),lbbcsd,childinfo) ! ! Permute rows and columns to place identity submatrices in ! preferred positions ! IF ( P>r ) THEN DO i = 1 , r Iwork(i) = P - r + i ENDDO DO i = r + 1 , P Iwork(i) = i - r ENDDO IF ( wantu1 ) CALL CLAPMT(.FALSE.,P,P,U1,Ldu1,Iwork) IF ( wantv1t ) CALL CLAPMR(.FALSE.,P,Q,V1t,Ldv1t,Iwork) ENDIF ENDIF ! ! ! End of CUNCSD2BY1 ! END SUBROUTINE CUNCSD2BY1
src/complex/cuncsd2by1.f90
program supflow integer a, c, d read *, a call supflowfoo(a, a, c, d) print *, a, c, d end subroutine supflowfoo(a, b, c, d) integer a, b, c, d a = 2 c = b * a d = a + c end
packages/PIPS/validation/Ricedg/Old.sub/pro_constant.f
For The Luv Of Pets Professional pet sitting & dog walking service. We love what we do and it shows! Licensed & Insured.
lab/davisWiki/NickyKim.f
c ============================================ subroutine setaux(maxmx,maxmy,mbc,mx,my,xlower,ylower,dxc,dyc, & maux,aux) c ============================================ c c c # aux(i,j,1) = ax c # aux(i,j,2) = ay where (ax,ay) is unit normal to left face c # aux(i,j,3) = ratio of length of left face to dyc c c # aux(i,j,4) = bx c # aux(i,j,5) = by where (bx,by) is unit normal to bottom face c # aux(i,j,6) = ratio of length of bottom face to dxc c c # aux(i,j,7) = ratio of cell area to dxc*dyc c # (approximately Jacobian of mapping function) c c # aux(i,j,8) = impedance Z in cell (i,j) c # aux(i,j,9) = sound speed c in cell (i,j) c c implicit double precision (a-h,o-z) dimension aux(1-mbc:maxmx+mbc,1-mbc:maxmy+mbc, 9) dimension xccorn(5),yccorn(5),xpcorn(5),ypcorn(5) common /cparam/ rho,bulk,cc,zz c dx2 = dxc/2.d0 dy2 = dyc/2.d0 c do 20 j=1-mbc,my+mbc do 20 i=1-mbc,mx+mbc c c # computational points (xc,yc) are mapped to physical c # coordinates (xp,yp) by mapc2p: c c # lower left corner: xccorn(1) = xlower + (i-1)*dxc yccorn(1) = ylower + (j-1)*dyc call mapc2p(xccorn(1),yccorn(1),xpcorn(1),ypcorn(1)) c # upper left corner: xccorn(2) = xccorn(1) yccorn(2) = yccorn(1) + dyc call mapc2p(xccorn(2),yccorn(2),xpcorn(2),ypcorn(2)) c c # upper right corner: xccorn(3) = xccorn(1) + dxc yccorn(3) = yccorn(1) + dyc call mapc2p(xccorn(3),yccorn(3),xpcorn(3),ypcorn(3)) c c # lower right corner: xccorn(4) = xccorn(1) + dxc yccorn(4) = yccorn(1) call mapc2p(xccorn(4),yccorn(4),xpcorn(4),ypcorn(4)) c c # compute normals to left and bottom side: c ax = (ypcorn(2) - ypcorn(1)) ay = -(xpcorn(2) - xpcorn(1)) anorm = dsqrt(ax*ax + ay*ay) aux(i,j,1) = ax/anorm aux(i,j,2) = ay/anorm aux(i,j,3) = anorm/dyc c bx = -(ypcorn(4) - ypcorn(1)) by = (xpcorn(4) - xpcorn(1)) bnorm = dsqrt(bx*bx + by*by) aux(i,j,4) = bx/bnorm aux(i,j,5) = by/bnorm aux(i,j,6) = bnorm/dxc c c # compute area of physical cell from four corners: xpcorn(5) = xpcorn(1) ypcorn(5) = ypcorn(1) area = 0.d0 do ic=1,4 area = area + 0.5d0 * (ypcorn(ic)+ypcorn(ic+1)) * & (xpcorn(ic+1)-xpcorn(ic)) enddo aux(i,j,7) = area / (dxc*dyc) c aux(i,j,8) = zz aux(i,j,9) = cc 20 continue c return end
book/chap23/acoustics/setaux.f
! cornelius2 version 1.3: Copyright 2012, Pasi Huovinen ! ! This subroutine is aimed to be used as a part of the fluid dynamical ! models of the heavy-ion physics community. Permission to use it for ! any purpose except for any commercial purpose is granted, provided ! that any publication cites the paper describing the algorithm: ! P. Huovinen and H. Petersen, arXiv:1206.3371 ! ! Permission to distribute this subroutine is granted, provided that no ! fee is charged, and that this copyright and permission notice appear ! in all the copies. Permission to modify this subroutine is granted ! provided that the modified subroutine is made publicly available ! latest when any results obtained using the modified subroutine are ! published, the modified subroutine is distributed under terms similar ! to this notice, and the modified code carries both the original ! copyright notice and notices stating that you modified it, and a ! relevant date/year. ! ! This program is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of FITNESS FOR ! A PARTICULAR PURPOSE. SUBROUTINE Cornelius2(E0,Cube,dSigma,Nsurf,Vmid,dt,dx,dy,Nambi,Ndisc) ! ! version 1.3 zeta ! ! This routine search for a 2-dimensional isosurface of constant X in ! a volume-element (cube) of 3-dimensional space when the values of X ! are known at the vertices (=corners) of the cube and X is interpolated ! linearly between the vertices. I.e. the usual problem of finding the ! freeze-out surface. ! The routine devides this surface into triangles, evaluates their ! sizes and normal vectors, and provides an approximation (dSigma) of ! the normal vector of the surface as a sum of the normal vectors of ! the triangles. The length of the normal vector gives the size (area) ! of the surface. ! ! Variables: E0: the value of X on the surface (INPUT) ! Cube: 3D cube (2x2x2) to store the values of X (INPUT) ! dSigma: 3-vector table to store the normal vector(s) of ! the surface element(s), |dSigma| is the area ! of the surface element (OUTPUT) ! Nsurf: Number of separate surface elements within the cube ! (OUTPUT) ! Vmid: coordinates of the approximate centroid(s) of the ! element(s) if the origin is at (0,0,0) corner of ! the cube (OUTPUT) ! dt, dx, dy: the lengths of the edges of the cube (INPUT) ! Nambi: number of ambiguous faces on surfaces (INOUT) ! (do not set this to zero between successive calls) ! Ndisc: number of disconnected surface-elements so far (INOUT) ! (do not set this to zero between successive calls) ! ! -- P. Huovinen, Jyvaskyla-Frankfurt, March 2005-March 2011 -- ! ! Changes in version 1.2: ! - improves the handling of a case where a corner or the center of the face ! is exactly at the freeze-out temperature and the face is ambiguous. In ! previous version the behaviour dependend on which corner was at the FO ! temperature, now the treatment is consistent depending only on the value ! in the center of the face ! -- PH, Heraklion, Sept 2011 -- ! ! Changes in version 1.3: ! - added the license statement and a check that the cube really contains ! a surface element ! -- PH, Frankfurt, July 2012 -- ! ! The ordering of values in Cube(t,i,j): ! first index time, second x, third y ! Cube(0,0,0) <-> t=0,x=0,y=0 ! Cube(0,0,1) <-> t=0,x=0,y=1 ! Cube(0,1,0) <-> t=0,x=1,y=0 ! Cube(0,1,1) <-> t=0,x=1,y=1 ! Cube(1,0,0) <-> t=1,x=0,y=0 ! Cube(1,0,1) <-> t=1,x=0,y=1 ! Cube(1,1,0) <-> t=1,x=1,y=0 ! Cube(1,1,1) <-> t=1,x=1,y=1 ! IMPLICIT NONE REAL(KIND(0D0)),INTENT(IN) :: E0 REAL(KIND(0D0)),DIMENSION(0:1,0:1,0:1),INTENT(IN) :: Cube REAL(KIND(0D0)),DIMENSION(0:2,4),INTENT(OUT) :: dSigma INTEGER,INTENT(OUT) :: Nsurf REAL(KIND(0D0)),DIMENSION(0:2,4),INTENT(OUT) :: Vmid REAL(KIND(0D0)),INTENT(IN) :: dt, dx, dy INTEGER,INTENT(INOUT) :: Nambi, Ndisc REAL(KIND(0D0)),DIMENSION(0:2,2,12) :: Edge ! Table for ends of edges ! i.e. corners of the polygons INTEGER :: Nedge, Ncorners LOGICAL :: Ambiguous REAL(KIND(0D0)),DIMENSION(0:2,12) :: Ut ! Outside direction LOGICAL :: Pathological INTEGER,DIMENSION(5) :: EdgeSet ! which edges belong to different surfaces INTEGER :: j Ncorners = COUNT(Cube .ge. E0) dSigma = 0D0 ! Check that the cube really contains a surface element IF ((Ncorners .gt. 0).and.(Ncorners .lt. 8)) THEN Nedge = 0 Ut = 0D0 Ambiguous = .false. Pathological = .false. ! Find surface corners and edges: CALL Edges(E0,Cube,Edge,Ut,dt,dx,dy,Nedge,Ambiguous,Pathological) IF (Pathological) CALL DeadEnd(Cube,E0) ! Check disconnectedness: IF ((.not.(Ambiguous)).and.(Nedge .eq. 6)) & Ambiguous = (((Cube(0,0,0)-E0)*(Cube(1,1,1)-E0).gt.0D0).and. & ((Cube(1,0,0)-E0)*(Cube(0,1,1)-E0).gt.0D0).and. & ((Cube(1,1,0)-E0)*(Cube(0,0,1)-E0).gt.0D0).and. & ((Cube(0,1,0)-E0)*(Cube(1,0,1)-E0).gt.0D0)) IF (Ambiguous) THEN Nambi = Nambi + 1 CALL Disconnected2D(Nedge,Edge,Ut,Nsurf,EdgeSet) ELSE Nsurf = 1 EdgeSet(1) = 1 EdgeSet(2) = Nedge+1 END IF IF (Nsurf .gt. 1) Ndisc = Ndisc+1 ! Evaluate the center and normal for each surface: DO j = 1,Nsurf Nedge = EdgeSet(j+1)-EdgeSet(j) CALL NormalVector(j,EdgeSet(j),EdgeSet(j+1)-1,Nedge,Edge,Ut, & dSigma,Vmid) END DO ELSE Nsurf = 0 Vmid = 0D0 END IF END SUBROUTINE Cornelius2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE NormalVector(j,First,Last,Nedge,Edge,Ut,dSigma,Vmids) IMPLICIT NONE INTEGER :: i, j, First, Last, Nedge REAL(KIND(0D0)),DIMENSION(0:2,2,12) :: Edge REAL(KIND(0D0)),DIMENSION(0:2,12) :: Surfs, Ut REAL(KIND(0D0)),DIMENSION(0:2,4) :: dSigma, Vmids REAL(KIND(0D0)),DIMENSION(0:2) :: Vmid, Wmid, V, A, B, SuL, Vout REAL(KIND(0D0)) :: Area, AreaI, Vsum ! Calculate the mean vector of intersection points V = 0D0 DO i = First,Last V = V + Edge(:,1,i) + Edge(:,2,i) END DO Vmid = V/(2*Nedge) ! Calculate the centroid, i.e., the center of gravity of the surface element ! (if Nedge=3, the surface element is a triangle and centroid is the mean of ! corner coordinates) IF (Nedge .eq. 3) THEN Wmid = Vmid ELSE Area = 0D0 V = 0D0 DO i = First,Last A = Edge(:,1,i) - Vmid B = Edge(:,2,i) - Vmid AreaI = Sqrt((A(2)*B(1) - A(1)*B(2))**2 & +(A(0)*B(2) - A(2)*B(0))**2 & +(A(1)*B(0) - A(0)*B(1))**2)/2 Area = Area + AreaI V = V + (Edge(:,1,i) + Edge(:,2,i) + Vmid)*AreaI/3 END DO Wmid = V/Area END IF ! Start calculating the surface vector DO i = First,Last A = Edge(:,1,i) - Wmid B = Edge(:,2,i) - Wmid SuL(0) = 0.5*(A(2)*B(1) - A(1)*B(2)) ! Covariant components SuL(1) = 0.5*(A(0)*B(2) - A(2)*B(0)) ! of the surface SuL(2) = 0.5*(A(1)*B(0) - A(0)*B(1)) ! normal vector ! Choose the direction towards lower energy Vout = Ut(:,i) - Wmid Vsum = Vout(0)*SuL(0) + Vout(1)*SuL(1) + Vout(2)*SuL(2) Surfs(:,i) = SIGN(1D0,Vsum)*SuL END DO dSigma(:,j) = SUM(Surfs(:,First:Last),DIM=2) ! Surface normal Vmids(:,j) = Wmid END SUBROUTINE NormalVector !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE DeadEnd(Cube,E0) IMPLICIT NONE REAL(KIND(0D0)) :: E0 REAL(KIND(0D0)),DIMENSION(0:1,0:1,0:1) :: Cube WRITE(*,*) 'Error in CubeCut. Impossible surface.' WRITE(*,*) 'Freeze-out value:',E0 WRITE(*,*) 'Values at Cube corners:' WRITE(*,*) 'E(1,0,1) =',Cube(1,0,1),'E(1,1,1) =',Cube(1,1,1) WRITE(*,*) 'E(1,0,0) =',Cube(1,0,0),'E(1,1,0) =',Cube(1,1,0) WRITE(*,*) WRITE(*,*) 'E(0,0,1) =',Cube(0,0,1),'E(0,1,1) =',Cube(0,1,1) WRITE(*,*) 'E(0,0,0) =',Cube(0,0,0),'E(0,1,0) =',Cube(0,1,0) STOP END SUBROUTINE DeadEnd !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!! Subroutines below this line are identical to subroutines in ! !!!! 3+1D cornelius, except for the size of the Edge array ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE Edges(E0,Cube,Edge,Ut,dt,dx,dy,Nedge,Outo,Patho) IMPLICIT NONE REAL(KIND(0D0)) :: E0,dx,dy,dt REAL(KIND(0D0)),DIMENSION(0:1,0:1,0:1) :: Cube REAL(KIND(0D0)),DIMENSION(0:1,0:1) :: Square REAL(KIND(0D0)),DIMENSION(0:2,2,12) :: Edge REAL(KIND(0D0)),DIMENSION(0:2,12) :: Ut REAL(KIND(0D0)),DIMENSION(2,4) :: Cut REAL(KIND(0D0)),DIMENSION(2,2) :: Out INTEGER :: Ncuts,Nedge, i LOGICAL :: Outo, Patho DO i = 0,1 ! t = 0 or 1 Square = Cube(i,:,:) CALL FindEdge(E0,Square,Cut,Out,dx,dy,Ncuts,Patho) IF (Patho) RETURN CALL StoreEdge(Ncuts,Cut,Out,i*dt,0,(/1,2/),Nedge,Edge,Ut,Outo) END DO DO i = 0,1 ! x = 0 or 1 Square = Cube(:,i,:) CALL FindEdge(E0,Square,Cut,Out,dt,dy,Ncuts,Patho) IF (Patho) RETURN CALL StoreEdge(Ncuts,Cut,Out,i*dx,1,(/0,2/),Nedge,Edge,Ut,Outo) END DO DO i = 0,1 ! y = 0 or 1 Square = Cube(:,:,i) CALL FindEdge(E0,Square,Cut,Out,dt,dx,Ncuts,Patho) IF (Patho) RETURN CALL StoreEdge(Ncuts,Cut,Out,i*dy,2,(/0,1/),Nedge,Edge,Ut,Outo) END DO END SUBROUTINE Edges SUBROUTINE FindEdge(E0,Square,Cut,Out,dx,dy,Ncuts,Patho) IMPLICIT NONE REAL(KIND(0D0)) :: E0,dx,dy REAL(KIND(0D0)),DIMENSION(0:1,0:1) :: Square REAL(KIND(0D0)),DIMENSION(2,4) :: Cut REAL(KIND(0D0)),DIMENSION(2,2) :: Out INTEGER :: Ncuts LOGICAL :: Patho CALL EndsOfEdge(E0,Square,Cut,dx,dy,Ncuts) IF (Ncuts .gt. 0) CALL FindOutside(Ncuts,E0,Square,Cut,Out,dx,dy) IF ((Ncuts .eq. 3).or.(Ncuts .eq. 1)) THEN WRITE(*,*) 'Error in FindEdge,',Ncuts,' cuts.' WRITE(*,*) 'Noncontinuous surface. E0 =',E0 WRITE(*,*) 'Eps(0,0) =',Square(0,0),' Eps(1,0) =',Square(1,0) WRITE(*,*) 'Eps(0,1) =',Square(0,1),' Eps(1,1) =',Square(1,1) WRITE(*,*) Patho = .true. END IF END SUBROUTINE FindEdge SUBROUTINE EndsOfEdge(E0,Square,Cut,dx,dy,Ncuts) IMPLICIT NONE REAL(KIND(0D0)) :: E0,dx,dy REAL(KIND(0D0)),DIMENSION(0:1,0:1) :: Square REAL(KIND(0D0)),DIMENSION(2,4) :: Cut INTEGER :: Ncuts Ncuts = 0 IF (((Square(0,0)-E0)*(Square(1,0)-E0)) .lt. 0D0) THEN Ncuts = Ncuts+1 Cut(1,Ncuts) = (Square(0,0)-E0)/(Square(0,0)-Square(1,0))*dx Cut(2,Ncuts) = 0D0 ELSE IF ((Square(0,0).eq.E0) .or. (Square(1,0).eq.E0)) & CALL EndsAtCorner(Square(0,0),Square(1,0),E0,Ncuts, & Cut(1,Ncuts+1),Cut(2,Ncuts+1),dx,0D0) END IF IF (((Square(0,0)-E0)*(Square(0,1)-E0)) .lt. 0D0) THEN Ncuts = Ncuts + 1 Cut(1,Ncuts) = 0D0 Cut(2,Ncuts) = (Square(0,0)-E0)/(Square(0,0)-Square(0,1))*dy ELSE IF ((Square(0,0).eq.E0) .or. (Square(0,1).eq.E0)) & CALL EndsAtCorner(Square(0,0),Square(0,1),E0,Ncuts, & Cut(2,Ncuts+1),Cut(1,Ncuts+1),dy,0D0) END IF IF (((Square(1,0)-E0)*(Square(1,1)-E0)) .lt. 0D0) THEN Ncuts = Ncuts+1 Cut(1,Ncuts) = dx Cut(2,Ncuts) = (Square(1,0)-E0)/(Square(1,0)-Square(1,1))*dy ELSE IF ((Square(1,0).eq.E0) .or. (Square(1,1).eq.E0)) & CALL EndsAtCorner(Square(1,0),Square(1,1),E0,Ncuts, & Cut(2,Ncuts+1),Cut(1,Ncuts+1),dy,dx) END IF IF (((Square(0,1)-E0)*(Square(1,1)-E0)) .lt. 0D0) THEN Ncuts = Ncuts+1 Cut(1,Ncuts) = (Square(0,1)-E0)/(Square(0,1)-Square(1,1))*dx Cut(2,Ncuts) = dy ELSE IF ((Square(0,1).eq.E0) .or. (Square(1,1).eq.E0)) & CALL EndsAtCorner(Square(0,1),Square(1,1),E0,Ncuts, & Cut(1,Ncuts+1),Cut(2,Ncuts+1),dx,dy) END IF END SUBROUTINE EndsOfEdge SUBROUTINE EndsAtCorner(A,B,E0,Ncuts,C1,C2,d1,d2) IMPLICIT NONE REAL(KIND(0D0)) :: A,B,E0,C1,C2,d1,d2 INTEGER :: Ncuts IF ((A .eq. E0).and.(B .lt. E0)) THEN Ncuts = Ncuts+1 C1 = 1D-9*d1 C2 = d2 END IF IF ((A .lt. E0).and.(B .eq. E0)) THEN Ncuts = Ncuts+1 C1 = (1D0-1D-9)*d1 C2 = d2 END IF END SUBROUTINE EndsAtCorner !!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE FindOutside(Ncuts,E0,Square,Cut,Out,dx,dy) ! Finds a point outside the freeze-out surface and sorts ambiguous surfaces ! with two edges on one face of the cube. The rule is to interpolate the value ! at the center of the face, see if it is below or above freeze-out criterion ! and set the surface accordingly. IMPLICIT NONE INTEGER :: Ncuts REAL(KIND(0D0)) :: E0,dx,dy REAL(KIND(0D0)),DIMENSION(0:1,0:1) :: Square REAL(KIND(0D0)),DIMENSION(2,4) :: Cut REAL(KIND(0D0)),DIMENSION(2,2) :: Out INTEGER :: i, j, Nout REAL(KIND(0D0)) :: Eave IF (Ncuts .eq. 4) THEN ! Ambiguous surface check, interpolate the center Eave = 2.5D-1*SUM(Square) IF ( ((Square(0,0).lt.E0).and.(Eave.lt.E0)) & .or.((Square(0,0).ge.E0).and.(Eave.ge.E0))) THEN Out(:,1) = Cut(:,2) Cut(:,2) = Cut(:,3) Cut(:,3) = Out(:,1) END IF IF ((Eave-E0) .lt. 0D0) THEN ! Outward direction at the center Out(1,:) = 5D-1*dx Out(2,:) = 5D-1*dy ELSE IF ((Square(0,0)-E0) .lt. 0D0) THEN Out(:,1) = 0D0 Out(1,2) = dx Out(2,2) = dy ELSE Out(1,1) = dx Out(2,1) = 0D0 Out(1,2) = 0D0 Out(2,2) = dy END IF END IF ELSE ! Normal case, only one edge cutting the face of the cube Out = 0D0 ! Find the direction outwards (to lower value) Nout = 0 DO i = 0,1 DO j = 0,1 IF (Square(i,j) .lt. E0) THEN Out(1,1) = Out(1,1) + i*dx Out(2,1) = Out(2,1) + j*dy Nout = Nout + 1 END IF END DO END DO IF (Nout .gt. 0) Out = Out/Nout END IF END SUBROUTINE FindOutside !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE StoreEdge(Ncuts,Cut,Out,dKnown,Trivial,nonTrivial, & Nedge,Edge,Ut,Outo) IMPLICIT NONE LOGICAL :: Outo INTEGER :: Ncuts, Nedge, Trivial INTEGER,DIMENSION(2) :: nonTrivial REAL(KIND(0D0)),DIMENSION(2,4) :: Cut REAL(KIND(0D0)),DIMENSION(2,2) :: Out REAL(KIND(0D0)) :: dKnown REAL(KIND(0D0)),DIMENSION(0:2,2,12) :: Edge REAL(KIND(0D0)),DIMENSION(0:2,12) :: Ut IF ((Ncuts .eq. 2).or.(Ncuts .eq. 4)) THEN Nedge = Nedge + 1 Edge(Trivial,:,Nedge) = dKnown Edge(nonTrivial,:,Nedge) = Cut(:,1:2) Ut(Trivial,Nedge) = dKnown Ut(nonTrivial,Nedge) = Out(:,1) END IF IF (Ncuts .eq. 4) THEN Nedge = Nedge + 1 Edge(Trivial,:,Nedge) = dKnown Edge(nonTrivial,:,Nedge) = Cut(:,3:4) Ut(Trivial,Nedge) = dKnown Ut(nonTrivial,Nedge) = Out(:,2) Outo = .true. END IF END SUBROUTINE StoreEdge !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE Disconnected2D(N,Edge,Ut,Nsurfs,EdgeSet) ! Subroutine to check whether the surface cuts the cube once or several times IMPLICIT NONE INTEGER :: N, Nsurfs INTEGER,DIMENSION(5) :: EdgeSet REAL(KIND(0D0)),DIMENSION(0:2,2,12) :: Edge REAL(KIND(0D0)),DIMENSION(0:2,2,12) :: Side REAL(KIND(0D0)),DIMENSION(0:2,12) :: Ut, Ut2 INTEGER :: i, Nside, Nedge Nsurfs = 1 EdgeSet(1) = 1 Side(:,:,1) = Edge(:,:,N) Ut2(:,1) = Ut(:,N) Nside = 1 Nedge = N-1 DO WHILE (Nedge .gt. 0) i = 1 DO WHILE (ANY(Side(:,1,Nside).ne.Edge(:,1,i)).and. & ANY(Side(:,1,Nside).ne.Edge(:,2,i)).and.(i.le.Nedge)) i = i+1 END DO IF (i.le.Nedge) THEN IF (ALL(Side(:,1,Nside).eq.Edge(:,1,i))) THEN Side(:,2,Nside+1) = Edge(:,1,i) Side(:,1,Nside+1) = Edge(:,2,i) ELSE Side(:,:,Nside+1) = Edge(:,:,i) END IF Ut2(:,Nside+1) = Ut(:,i) Edge(:,:,i) = Edge(:,:,Nedge) Ut(:,i) = Ut(:,Nedge) EdgeSet(Nsurfs+1) = Nside+2 ELSE Nsurfs = Nsurfs+1 Side(:,:,Nside+1) = Edge(:,1:2,Nedge) Ut2(:,Nside+1) = Ut(:,Nedge) END IF Nside = Nside+1 Nedge = Nedge-1 END DO Edge(:,:,1:N) = Side(:,:,1:N) Ut(:,1:N) = Ut2(:,1:N) END SUBROUTINE Disconnected2D
models/osu-hydro/src/cornelius2.f90
! { dg-do compile } ! { dg-options "-std=f2008" } ! ! PR fortran/48820 ! ! Test TYPE(*) subroutine one(a) type(*) :: a ! { dg-error "TS 29113/TS 18508: Assumed type" } end subroutine one
validation_tests/llvm/f18/gfortran.dg/assumed_type_4.f90
SUBROUTINE W3FT209(ALOLA,ALAMB,INTERP) C$$$ SUBROUTINE DOCUMENTATION BLOCK *** C C SUBROUTINE: W3FT209 CONVERT (361,91) GRID TO (101,81) LAMBERT GRID C AUTHOR: JONES,R.E. ORG: W342 DATE: 94-05-18 C C ABSTRACT: CONVERT A NORTHERN HEMISPHERE 1.0 DEGREE LAT.,LON. 361 BY C 91 GRID TO A LAMBERT CONFORMAL 101 BY 81 AWIPS GRIB 209. C C PROGRAM HISTORY LOG: C 94-05-18 R.E.JONES C C USAGE: CALL W3FT209(ALOLA,ALAMB,INTERP) C C INPUT ARGUMENTS: ALOLA - 361*91 GRID 1.0 DEG. LAT,LON GRID N. HEMI. C 32851 POINT GRID. 360 * 181 ONE DEGREE C GRIB GRID 3 WAS FLIPPED, GREENWISH ADDED C TO RIGHT SIDE AND CUT TO 361 * 91. C INTERP - 1 LINEAR INTERPOLATION , NE.1 BIQUADRATIC C C INPUT FILES: NONE C C OUTPUT ARGUMENTS: ALAMB - 101*81 REGIONAL - CENTRAL US MARD C DOUBLE RES. C (LAMBERT CONFORMAL). 8181 POINT GRID C IS AWIPS GRID TYPE 209 C C OUTPUT FILES: ERROR MESSAGE TO FORTRAN OUTPUT FILE C C WARNINGS: C C 1. W1 AND W2 ARE USED TO STORE SETS OF CONSTANTS WHICH ARE C REUSABLE FOR REPEATED CALLS TO THE SUBROUTINE. 11 OTHER ARRAY C ARE SAVED AND REUSED ON THE NEXT CALL. C C 2. WIND COMPONENTS ARE NOT ROTATED TO THE 101*81 GRID ORIENTATION C AFTER INTERPOLATION. YOU MAY USE W3FC08 TO DO THIS. C C RETURN CONDITIONS: NORMAL SUBROUTINE EXIT C C SUBPROGRAMS CALLED: C UNIQUE : NONE C C LIBRARY: W3FB12 C C ATTRIBUTES: C LANGUAGE: CRAY CFT77 FORTRAN C MACHINE: CRAY C916-128, CRAY Y-MP8/864, CRAY Y-MP EL92/256 C C$$$ C C PARAMETER (NPTS=8181,II=101,JJ=81) PARAMETER (ALATAN=25.000) PARAMETER (PI=3.1416) PARAMETER (DX=40635.250) PARAMETER (ALAT1=22.289) PARAMETER (ELON1=242.00962) PARAMETER (ELONV=265.000) PARAMETER (III=361,JJJ=91) C REAL ALOLA(III,JJJ) REAL ALAMB(NPTS) REAL W1(NPTS), W2(NPTS), ERAS(NPTS,4) REAL XDELI(NPTS), XDELJ(NPTS) REAL XI2TM(NPTS), XJ2TM(NPTS) C INTEGER IV(NPTS), JV(NPTS), JY(NPTS,4) INTEGER IM1(NPTS), IP1(NPTS), IP2(NPTS) C LOGICAL LIN C SAVE C DATA ISWT /0/ DATA INTRPO/99/ C LIN = .FALSE. IF (INTERP.EQ.1) LIN = .TRUE. C IF (ISWT.EQ.1) GO TO 900 c print *,'iswt = ',iswt N = 0 DO J = 1,JJ DO I = 1,II XJ = J XI = I CALL W3FB12(XI,XJ,ALAT1,ELON1,DX,ELONV,ALATAN,ALAT, & ELON,IERR) N = N + 1 W1(N) = ELON + 1.0 W2(N) = ALAT + 1.0 END DO END DO C ISWT = 1 INTRPO = INTERP GO TO 1000 C C AFTER THE 1ST CALL TO W3FT209 TEST INTERP, IF IT HAS C CHANGED RECOMPUTE SOME CONSTANTS C 900 CONTINUE IF (INTERP.EQ.INTRPO) GO TO 2100 INTRPO = INTERP C 1000 CONTINUE DO 1100 K = 1,NPTS IV(K) = W1(K) JV(K) = W2(K) XDELI(K) = W1(K) - IV(K) XDELJ(K) = W2(K) - JV(K) IP1(K) = IV(K) + 1 JY(K,3) = JV(K) + 1 JY(K,2) = JV(K) 1100 CONTINUE C IF (LIN) GO TO 2100 C DO 1200 K = 1,NPTS IP2(K) = IV(K) + 2 IM1(K) = IV(K) - 1 JY(K,1) = JV(K) - 1 JY(K,4) = JV(K) + 2 XI2TM(K) = XDELI(K) * (XDELI(K) - 1.0) * .25 XJ2TM(K) = XDELJ(K) * (XDELJ(K) - 1.0) * .25 1200 CONTINUE C 2100 CONTINUE IF (LIN) THEN C C LINEAR INTERPOLATION C DO 2200 KK = 1,NPTS ERAS(KK,2) = (ALOLA(IP1(KK),JY(KK,2))-ALOLA(IV(KK),JY(KK,2))) & * XDELI(KK) + ALOLA(IV(KK),JY(KK,2)) ERAS(KK,3) = (ALOLA(IP1(KK),JY(KK,3))-ALOLA(IV(KK),JY(KK,3))) & * XDELI(KK) + ALOLA(IV(KK),JY(KK,3)) 2200 CONTINUE C DO 2300 KK = 1,NPTS ALAMB(KK) = ERAS(KK,2) + (ERAS(KK,3) - ERAS(KK,2)) & * XDELJ(KK) 2300 CONTINUE C ELSE C C QUADRATIC INTERPOLATION C DO 2400 KK = 1,NPTS ERAS(KK,1)=(ALOLA(IP1(KK),JY(KK,1))-ALOLA(IV(KK),JY(KK,1))) & * XDELI(KK) + ALOLA(IV(KK),JY(KK,1)) + & ( ALOLA(IM1(KK),JY(KK,1)) - ALOLA(IV(KK),JY(KK,1)) & - ALOLA(IP1(KK),JY(KK,1))+ALOLA(IP2(KK),JY(KK,1))) & * XI2TM(KK) ERAS(KK,2)=(ALOLA(IP1(KK),JY(KK,2))-ALOLA(IV(KK),JY(KK,2))) & * XDELI(KK) + ALOLA(IV(KK),JY(KK,2)) + & ( ALOLA(IM1(KK),JY(KK,2)) - ALOLA(IV(KK),JY(KK,2)) & - ALOLA(IP1(KK),JY(KK,2))+ALOLA(IP2(KK),JY(KK,2))) & * XI2TM(KK) ERAS(KK,3)=(ALOLA(IP1(KK),JY(KK,3))-ALOLA(IV(KK),JY(KK,3))) & * XDELI(KK) + ALOLA(IV(KK),JY(KK,3)) + & ( ALOLA(IM1(KK),JY(KK,3)) - ALOLA(IV(KK),JY(KK,3)) & - ALOLA(IP1(KK),JY(KK,3))+ALOLA(IP2(KK),JY(KK,3))) & * XI2TM(KK) ERAS(KK,4)=(ALOLA(IP1(KK),JY(KK,4))-ALOLA(IV(KK),JY(KK,4))) & * XDELI(KK) + ALOLA(IV(KK),JY(KK,4)) + & ( ALOLA(IM1(KK),JY(KK,4)) - ALOLA(IV(KK),JY(KK,4)) & - ALOLA(IP1(KK),JY(KK,4))+ALOLA(IP2(KK),JY(KK,4))) & * XI2TM(KK) 2400 CONTINUE C DO 2500 KK = 1,NPTS ALAMB(KK) = ERAS(KK,2) + (ERAS(KK,3) - ERAS(KK,2)) & * XDELJ(KK) + (ERAS(KK,1) - ERAS(KK,2) & - ERAS(KK,3) + ERAS(KK,4)) * XJ2TM(KK) 2500 CONTINUE C ENDIF C RETURN END
buildscripts/libs/NCEPlibs/src/w3emc/v2.2.0/src/w3ft209.f
C Copyright(C) 1999-2020 National Technology & Engineering Solutions C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C See packages/seacas/LICENSE for details C======================================================================= SUBROUTINE GETALV (A, NALVAR, ALIVAL, ISTEP, LENE, ISEVOK, * ALIVE, VAR) C======================================================================= C --*** GETALV *** (MESH) Read birth/death variable C -- Written by Amy Gilkey - revised 10/28/87 C -- C --GETALV reads the values for the requested birth/death variable and C --returns the element state. C -- C --The element is alive iff the input variable is 0.0. C -- C --Parameters: C -- A - IN - the dynamic memory base array C -- NALVAR - IN - the variable sequence number C -- ALIVAL - IN - the value to indicate element is fully alive C -- ISTEP - IN - the time step number C -- LENE - IN - the cumulative element counts by element block C -- ISEVOK - IN - the element block variable truth table; C -- variable i of block j exists iff ISEVOK(j,i) C -- ALIVE - OUT - true iff the element i is alive C -- VAR - SCRATCH - the birth/death variable array; may be ALIVE C -- C --Common Variables: C -- Uses NUMEL, NELBLK of /DBNUMS/ include 'dbnums.blk' DIMENSION A(*) INTEGER LENE(0:*) LOGICAL ISEVOK(NELBLK,NVAREL) LOGICAL ALIVE(NUMEL) REAL VAR(NUMEL) CHARACTER CDUM CALL GETVAR (A, NALVAR, -1, ISTEP, NUMEL, VAR) CALL DBVTYP_BL (NALVAR, CDUM, IDALV) DO 120 IELB = 1, NELBLK IF (ISEVOK(IELB,IDALV)) THEN DO 100 IEL = LENE(IELB-1)+1, LENE(IELB) ALIVE(IEL) = (VAR(IEL) .EQ. ALIVAL) 100 CONTINUE ELSE DO 110 IEL = LENE(IELB-1)+1, LENE(IELB) ALIVE(IEL) = .TRUE. 110 CONTINUE END IF 120 CONTINUE RETURN END
packages/seacas/applications/blot/getalv.f
SUBROUTINE getdiam(amat_i, amat_p, data_array, kcdiam) USE vmec_main USE vmec_params, ONLY: signgs USE realspace USE vforces, ONLY : r12=>armn_o, ru12=>azmn_e USE vsvd USE vspline IMPLICIT NONE C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- INTEGER kcdiam REAL(rprec), DIMENSION(isnodes,*) :: amat_i REAL(rprec), DIMENSION(ipnodes,*) :: amat_p REAL(rprec), DIMENSION(*) :: data_array C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- INTEGER, PARAMETER :: ilimit = 2 C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- INTEGER :: js, lk, l REAL(rprec), DIMENSION(ns) :: gp, gi, gip REAL(rprec), DIMENSION(isnodes) :: amat2_i REAL(rprec) :: wdiam, z12, tv, ti, t2, sum1 C----------------------------------------------- kcdiam = 0 IF (iphidiam.eq.0 .or. iresidue.lt.ilimit) RETURN ! ! COMPUTE FIT TO DIAMAGNETIC SIGNAL, USING EQUILIBRIUM RELATION ! (modified 7/96 by SPH) ! ! PHI-DIAMAG = 2*pi*INT[ Gp dp/ds + Gi d(<Bu>)/ds ] ! ! WHERE ! ! Gp = Ru * Z * <SQRT(g)> /(R * phip) ! Gi = Ru * Z * iota / R ! kcdiam = kcdiam + 1 c-7/96 dNewPhiedge = signgs*twopi*hs*Ssum_1(ns1,phip(2),1) c-7/96 VacPhiedge = signgs*bsubvvac*hs*Ssum_1(ns1,vrm2(2),1) c-7/96 delphid0 = VacPhiedge - dNewPhiedge wdiam = one/sigma_delphid gp(1) = zero gi(1) = zero DO js = 2, ns gp(js) = zero DO lk = 1, nznt l = js + ns*(lk - 1) z12 = .5_dp*(z1(l,0)+z1(l-1,0)+shalf(l)*(z1(l,1)+z1(l-1,1))) gp(js) = gp(js) + ru12(l)*z12/r12(l)*wint(l) END DO END DO ! ! NOTE: gip terms comes from linearizing the iota*d/ds[current*iota] ! terms ! DO js = 2, ns tv = twopi*vp(js)/phip(js) ti = -gp(js)*signgs*wdiam gi(js) = ti*iotas(js) gp(js) = -gp(js)*tv*wdiam gip(js) = ti*(current(js)*iotaf(js)-current(js-1)*iotaf(js-1)) END DO CALL splinint (gi, current, amat_i(1,kcdiam), hstark, u_ib, u1_ib 1 , w_ib, w1_ib, nk_ib, isnodes, intder, ns) CALL splinint (gip(2), current(2), amat2_i, hstark, u_ia, u1_ia, 1 w_ia, w1_ia, nk_ia, isnodes, intfun, ns1) CALL splinint (gp, presint, amat_p(1,kcdiam), hthom, u_pb, u1_pb, 1 w_pb, w1_pb, nk_pb, ipnodes, intder, ns) amat_i(:isnodes,kcdiam) = amat_i(:isnodes,kcdiam) + amat2_i(: 1 isnodes) t2 = mu0*pthommax !!*pfac moved to getthom amat_p(:ipnodes,kcdiam) = t2*amat_p(:ipnodes,kcdiam) sum1 = SUM(iotas(2:ns)*gip(2:ns)) data_array(kcdiam) = wdiam*phidiam + sum1 IF (iequi .eq. 0) THEN ! ! Eliminate p variation until well-converged ! !@ DO i = 1,ipnodes !@ data_array(kcdiam) = data_array(kcdiam) - !@ > amat_p(i,kcdiam)*ythom(i) !@ amat_p(i,kcdiam) = 0. !@ END DO ! ! FINAL OUTPUT (ALSO USE FOR DEBUGGING) ! ELSE ! ! Integrate by parts ! delphid = gp(ns)*presf(ns) + gi(ns)*iotaf(ns)*current(ns) - 1 gp(2)*presf(1) - gi(2)*current(1)*iotaf(1) DO js = 2, ns1 delphid = delphid - presf(js)*(gp(js+1)-gp(js)) - iotaf(js)* 1 current(js)*(gi(js+1)-gi(js)) END DO delphid = delphid/wdiam ENDIF !@ DO js = 2,ns !@ END DO !@ !@ sumi = SUM(amat_i(:isnodes,kcdiam)*ystark(:isnodes)) !@ > - SUM(amat2_i(isnodes)*ystark(:isnodes)) !@ sump = bla_dot(ipnodes,amat_p(1,kcdiam),1,ythom,1) !@ !@ WRITE(*,1212)delphid,(sumi+sump)/wdiam,delphid0 !@ 1212 FORMAT(' DelPhid = ',1pe10.3,' PhiD = ',1pe10.3, !@ > ' DelPhid0 = ',1pe10.3) END SUBROUTINE getdiam
VMEC2000/Sources/Reconstruction/getdiam.f
C @(#)ptcommnt.f 20.3 2/13/96 C**************************************************************** C C File: ptcommnt.f C C Purpose: Subroutine to write new headers and comments. C C Author: Walt Powell Date: 1 May 1993 C Called by: p_ptdata.f C C**************************************************************** C subroutine ptcommnt (in_buffer, out_buffer) character in_buffer * (*), out_buffer * (*) c c This subroutine returns WSCC-formated input data records. c Output parameter: c c in_buffer - a character string specifying desired data c out_buffer - a character string for storing data c error - warning switch (0 means ignore errors, c 1 means observe errors) c include 'ipfinc/parametr.inc' include 'ipfinc/blank.inc' include 'ipfinc/lfiles.inc' include 'ipfinc/basval.inc' include 'ipfinc/header.inc' include 'ipfinc/coment.inc' character * 10 capital character text * 140, null * 1, linefeed * 1, word(10) * 60 integer o2, apdoutbuf save null = char(0) linefeed = char(10) last = index (in_buffer, null) out_buffer(1:1) = null o2 = 1 c c Process case records c i1 = 1 numhdr = 0 ncom = 0 do while ( i1 .lt. last ) next_i1 = nxt_term(in_buffer(i1+1:)) + i1 text = in_buffer(i1:next_i1-1) if ( capital( text(1:7) ) .eq. 'CASE_ID' .or. & capital( text(1:6) ) .eq. 'CASEID' ) then call uscan( text, word, nwrd, '=', ' ,' ) basval(4) = word(3) chase1(1) = word(3) else if ( capital( text(1:7) ) .eq. 'CASE_DS' .or. & capital( text(1:6) ) .eq. 'CASEDS' ) then call uscan( text, word, nwrd, '=', ' ,' ) basval(7) = word(3) chase1(34) = word(3)(1:10) chase1(35) = word(3)(11:20) else if ( text(1:1) .eq. 'H' .and. numhdr .lt. 2 ) then numhdr = numhdr + 1 coment(numhdr) = text(2:) else if ( text(1:1) .eq. 'C' .and. ncom .lt. MAXCMT ) then ncom = ncom + 1 com(ncom) = text(2:) endif i1 = next_i1 if (in_buffer(i1:i1) .eq. linefeed) i1 = i1 + 1 enddo return end
ipf/ptcommnt.f
************************************************************************ * General collection of routines which might help somewhere... ************************************************************************ ************************************************************************ * Linear rescale * * Scales a coordinate x linearly from the interval [a,b] to the * interval [c,d]. * * In: * x - coordinate to be rescaled * [a,b] - source interval * [c,d] - destination interval * * Out: * y - Rescaled coordinate ************************************************************************ SUBROUTINE LRSCLE (X,A,B,C,D,Y) IMPLICIT NONE DOUBLE PRECISION X,A,B,C,D,Y DOUBLE PRECISION D1,D2,D3 C Calculate the coefficients of the transformation C D1*A+D2 = C, D1*B+D2 = D. C Use them to calculate Y=D1*X+D2. IF (A.EQ.B) THEN Y = C RETURN END IF D3 = 1D0/(A-B) D1 = (C-D)*D3 D2 = (-B*C+A*D)*D3 Y = D1*X+D2 END
area51/cc2d_movbc_structured_2/src/misc/generalutil.f
C LAST UPDATE 27/02/96 C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C REAL FUNCTION GAMMQ(A,X) IMPLICIT NONE C C Purpose: Calculates the incomplete gamma function Q(a,x) = 1 - P(a,x) C C Calls 2: GSER , GCF C Called by: C C-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- C Arguments: C REAL A,X C C Local variables: C REAL GAMSER,GAMMCF,GLN C C----------------------------------------------------------------------- GAMMQ = 0.0 IF(X.LT.0.0.OR.A.LE.0.0)THEN WRITE(6,1000) RETURN ENDIF IF(X.LT.A+1.0)THEN CALL GSER(GAMSER,A,X,GLN) GAMMQ = 1.0 - GAMSER ELSE CALL GCF(GAMMCF,A,X,GLN) GAMMQ = GAMMCF ENDIF RETURN C 1000 FORMAT(1X,'Error - invalid argument to gamma function') END
software/libs/mlib/gammq.f
! Copyright (C) 2012 The SPEED FOUNDATION ! Author: Ilario Mazzieri ! ! This file is part of SPEED. ! ! SPEED is free software; you can redistribute it and/or modify it ! under the terms of the GNU Affero General Public License as ! published by the Free Software Foundation, either version 3 of the ! License, or (at your option) any later version. ! ! SPEED 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 ! Affero General Public License for more details. ! ! You should have received a copy of the GNU Affero General Public License ! along with SPEED. If not, see <http://www.gnu.org/licenses/>. !> @brief Writes output results for Restart. !! @author Ilario Mazzieri !> @date September, 2013 !> @version 1.0 !> @param[in,out] file_name directory where saving files !> @param[in] count index for snapshot !> @param[in] proc mpi process id !> @param[in] nv number of values to print !> @param[in] vec values to print subroutine WRITE_FILEOUT(file_name,count,proc,nv,vec) character*70 :: file_name integer*4 :: count,proc,nv real*8, dimension(nv) :: vec character*70 :: out_file integer*4 :: i,lname lname = len_trim(file_name) out_file = file_name(1:lname) // '000000_0000.out' if (proc .lt. 10) then write(out_file(lname+6:lname+6),'(i1)') proc else if (proc .lt. 100) then write(out_file(lname+5:lname+6),'(i2)') proc else if (proc .lt. 1000) then write(out_file(lname+4:lname+6),'(i3)') proc else if (proc .lt. 10000) then write(out_file(lname+3:lname+6),'(i4)') proc else if (proc .lt. 100000) then write(out_file(lname+2:lname+6),'(i5)') proc else write(out_file(lname+1:lname+6),'(i6)') proc endif if (count .lt. 10) then write(out_file(lname+11:lname+11),'(i1)') count else if (proc .lt. 100) then write(out_file(lname+10:lname+11),'(i2)') count else if (proc .lt. 1000) then write(out_file(lname+9:lname+11),'(i3)') count else write(out_file(lname+8:lname+11),'(i4)') count endif open(20+proc, file=out_file) do i = 1,nv write(20+proc,*) vec(i) enddo close(20+proc) return end subroutine WRITE_FILEOUT
SRC/SPEED-MDOF190510/WRITE_FILEOUT.f90
subroutine blend_gauge_data( i4time,ni,nj,maxsta ! I 1 ,r_missing_data ! I 1 ,lat,lon ! I 1 ,pcp_bkg_m ! I 1 ,ilaps_cycle_time ! I 1 ,closest_radar ! I 1 ,precip_accum_m) ! I/O ! Blend the radar derived and background first guess to provide a ! spatially continuous precip estimate. This estimate is then corrected ! using rain gauges. If the radar/background field has any missing values ! a gauge only analysis is done instead. use mem_namelist, only: l_accum_fg, l_accum_radar, l_accum_gauge include 'read_sfc.inc' include 'constants.inc' real precip_accum_m(ni,nj)! input radar / output precip analysis (M) real pcp_2d_in(ni,nj) ! gauge corrected analysis (IN) real pcp_bkg_m(ni,nj) ! background field for gauge analysis (M) real pcp_cmb_m(ni,nj) ! background + radar field combined (M) real pcp_cmb_in(ni,nj) ! background + radar field combined (IN) real wt_bkg_a(ni,nj) ! background weight for gauge analysis real one(ni,nj) ! unity array for bias analysis real zero(ni,nj) ! zero array for gauge only analysis real bias_anal(ni,nj) ! bias analysis real closest_radar(ni,nj) ! M real lat(ni,nj) real lon(ni,nj) real pcp_gauge(maxsta) ! relevant time of accumulation is selected real pcp_laps_in_a(maxsta)! radar/first guess precip of paired obs real gauge_pairs_a(maxsta)! rain gauge reading of paired observations character*5 c_field integer ilaps(maxsta),jlaps(maxsta) logical l_accum_bias_ratio ! Apply bias correction as a constant ratio ! (given we are analyzing radar/fg & gauges) logical l_regression ! Apply regression of radar/fg & gauges logical l_gauge_only ! Gauge only analysis logical l_qc ! QC of radar gauge pairs l_gauge_only = (.not. l_accum_fg) .AND. (.not. l_accum_radar) 1 .AND. l_accum_gauge l_accum_bias_ratio = .false. l_regression = .true. ! Combine background and radar field given radar gap areas n_radar = 0 n_bkg = 0 n_msg_rdr_bkg = 0 do i = 1,ni do j = 1,nj if(precip_accum_m(i,j) .ne. r_missing_data)then n_radar = n_radar + 1 ! ! we have radar input pcp_cmb_m(i,j) = precip_accum_m(i,j) elseif(pcp_bkg_m(i,j) .ne. r_missing_data)then n_bkg = n_bkg + 1 pcp_cmb_m(i,j) = pcp_bkg_m(i,j) else pcp_cmb_m(i,j) = r_missing_data n_msg_rdr_bkg = n_msg_rdr_bkg + 1 endif enddo ! j enddo ! i write(6,*) write(6,*)' Subroutine blend_gauge_data (1hr pcp inches)...' write(6,*)' Number of radar points = ',n_radar write(6,*)' Number of background points = ',n_bkg write(6,*)' Number of missing points = ',n_msg_rdr_bkg write(6,*) write(6,*)' # Name Gauge Analyzed Range' call read_sfc_precip(i4time,btime,n_obs_g,n_obs_b, & stations,provider,lat_s,lon_s,elev_s, & pcp1,pcp3,pcp6,pcp24, & snow,maxsta,jstatus) call get_sfc_badflag(badflag,istatus) n_gauge_noradar = 0 n_pairs = 0 ! Loop through obs and write out precip values (when gauge reports precip) do iob = 1,n_obs_b ! Fill gauge array according to cycle time if(ilaps_cycle_time .eq. 3600)then pcp_gauge(iob) = pcp1(iob) c_field = 'pcp1' elseif(ilaps_cycle_time .eq. 10800)then pcp_gauge(iob) = pcp3(iob) c_field = 'pcp3' elseif(ilaps_cycle_time .eq. 21600)then pcp_gauge(iob) = pcp6(iob) c_field = 'pcp6' elseif(ilaps_cycle_time .eq. 86400)then pcp_gauge(iob) = pcp24(iob) c_field = 'pcp24' else pcp_gauge(iob) = badflag c_field = 'none' endif ! Obtain LAPS i,j at ob location call latlon_to_rlapsgrid(lat_s(iob),lon_s(iob),lat,lon 1 ,ni,nj,ri,rj 1 ,istatus) if(istatus.ne.1)goto20 ilaps(iob) = nint(ri) jlaps(iob) = nint(rj) if(ilaps(iob) .ge. 1 .and. ilaps(iob) .le. ni .and. 1 jlaps(iob) .ge. 1 .and. jlaps(iob) .le. nj )then ! Convert from meters to inches if(pcp_cmb_m(ilaps(iob),jlaps(iob)) .ne. r_missing_data 1 )then pcp_laps_in = pcp_cmb_m(ilaps(iob),jlaps(iob)) 1 * in_per_m else pcp_laps_in = r_missing_data endif if(closest_radar(ilaps(iob),jlaps(iob)) 1 .ne. r_missing_data ) then closest_radar_km = 1 closest_radar(ilaps(iob),jlaps(iob)) / 1000. else closest_radar_km = -999. endif if(pcp_gauge(iob) .ge. 0.)then if(pcp_laps_in .ne. r_missing_data)then if(pcp_laps_in .gt. 0. .and. 1 pcp_gauge(iob) .gt. 0. )then l_qc = .true. if(pcp_gauge(iob) .gt. .20 .and. 1 pcp_laps_in / pcp_gauge(iob) .lt. 0.1)then l_qc = .false. endif if(l_qc)then n_pairs = n_pairs + 1 pcp_laps_in_a(n_pairs) = pcp_laps_in gauge_pairs_a(n_pairs) = pcp_gauge(iob) write(6,12)iob,stations(iob)(1:10) 1 ,pcp_gauge(iob),pcp_laps_in 1 ,closest_radar_km,provider(iob) 12 format(i6,1x,a,2f7.3,f10.1,1x,a11 1 ,' RADAR/FG VALID PAIR') else write(6,13)iob,stations(iob)(1:10) 1 ,pcp_gauge(iob),pcp_laps_in 1 ,closest_radar_km,provider(iob) 13 format(i6,1x,a,2f7.3,f10.1,1x,a11 1 ,' RADAR/FG QC FAILED') endif else write(6,14)iob,stations(iob)(1:10) 1 ,pcp_gauge(iob),pcp_laps_in 1 ,closest_radar_km,provider(iob) 14 format(i6,1x,a,2f7.3,f10.1,1x,a11,' RADAR/FG') endif else write(6,15)iob,stations(iob)(1:10) 1 ,pcp_gauge(iob),lat_s(iob),lon_s(iob) 1 ,closest_radar_km,provider(iob) 15 format(i6,1x,a,f7.3,2f8.2,f10.1,1x,a11 1 ,' NORADAR/FG') n_gauge_noradar = n_gauge_noradar + 1 endif endif ! Other QC can be done here if needed by setting to badflag if(l_accum_bias_ratio .and. n_msg_rdr_bkg .eq. 0 1 .and. (.not. l_regression) )then if(pcp_gauge(iob) .gt. 0. .AND. 1 pcp_laps_in .ne. r_missing_data .AND. 1 pcp_laps_in .gt. 0.)then bias_ratio = pcp_gauge(iob) / pcp_laps_in if(bias_ratio .ge. 0.5 .AND. 1 bias_ratio .le. 2.0 )then pcp_gauge(iob) = bias_ratio else pcp_gauge(iob) = badflag endif else pcp_gauge(iob) = badflag endif endif endif 20 continue enddo ! iob wt_bkg_a = 5e28 if(n_msg_rdr_bkg .gt. 0 .or. l_gauge_only)then ! do gauge only analysis if(n_msg_rdr_bkg .gt. 0)then write(6,*)' Background/radar field has missing points' endif write(6,*)' Performing gauge only analysis' call precip_barnes_jacket( c_field ! I 1 ,ilaps,jlaps ! I 1 ,pcp_gauge ! I 1 ,maxsta ! I 1 ,zero ! I 1 ,badflag,ni,nj ! I 1 ,topo,ldf ! I 1 ,wt_bkg_a ! I 1 ,pcp_2d_in,istatus) ! O precip_accum_m = pcp_2d_in * meters_per_inch precip_accum_m = max(precip_accum_m,0.) elseif( (.not. l_accum_bias_ratio) .and. l_accum_gauge 1 .and. (.not. l_regression) )then ! Analyze gauge values via increments write(6,*)' Performing gauge increment analysis' pcp_cmb_in = pcp_cmb_m * in_per_m call precip_barnes_jacket( c_field ! I 1 ,ilaps,jlaps ! I 1 ,pcp_gauge ! I 1 ,maxsta ! I 1 ,pcp_cmb_in ! I 1 ,badflag,ni,nj ! I 1 ,topo,ldf ! I 1 ,wt_bkg_a ! I 1 ,pcp_2d_in,istatus) ! O ! precip_accum_m = pcp_2d_in * meters_per_inch precip_accum_m = max(precip_accum_m,0.) elseif(l_regression .and. l_accum_gauge)then ! Perform gauge bias analysis write(6,*)' Performing gauge bias analysis' if(.false.)then one = 1.0 call precip_barnes_jacket( c_field ! I 1 ,ilaps,jlaps ! I 1 ,pcp_gauge ! I 1 ,maxsta ! I 1 ,one ! I 1 ,badflag,ni,nj ! I 1 ,topo,ldf ! I 1 ,wt_bkg_a ! I 1 ,bias_anal,istatus) ! O write(6,*)' Max Bias Anal: ', MAXVAL(bias_anal) write(6,*)' Min Bias Anal: ', MINVAL(bias_anal) precip_accum_m = pcp_cmb_m * bias_anal else ! do regression of radar/gauge pairs (pcp_gauge,pcp_laps_in_a) if(n_pairs .gt. 0)then write(6,*)' Do regression of radar/gauge pairs ' 1 ,n_pairs call regress_precip(n_pairs,pcp_laps_in_a 1 ,gauge_pairs_a 1 ,a_t,b_t,rbar,gbar,istatus) if(istatus .eq. 1)then write(6,*)' Apply regression to radar/fg' precip_accum_m = (pcp_cmb_m * a_t) 1 + (b_t * meters_per_inch) precip_accum_m = max(precip_accum_m,0.) where(pcp_cmb_m .eq. 0.)precip_accum_m = 0. else write(6,*)' regression not applied' endif else write(6,*)' no gauge/radar pairs for regression' endif endif else ! return blended radar/background (no gauges) write(6,*)' Returning radar/background blend (no gauges)' precip_accum_m = pcp_cmb_m endif return end
src/accum/blend_gauge_data.f
*----------------------------------------------------------------------* * * * SUBROUTINE PARAMETER_ADJUSTMENT * * ******************************* * * * * This routine is invoked by the existance of the word 'ARGUMENT' in * * the input file after the soil parameter line. * * * * The routine is used to read in parameters values from a file. * * The filename is given by the command line argument, two additional * * parameters are supplied in the command line which select the first * * and last records to be run. * * All parameters in 'param.inc', can be adjusted. * * * *----------------------------------------------------------------------* SUBROUTINE PARAMETER_ADJUSTMENT(param_file,n_param) *----------------------------------------------------------------------* IMPLICIT NONE CHARACTER param_file*1000 INTEGER n_param,blank,i,kode REAL ans(17) INCLUDE 'param.inc' OPEN(98,FILE=param_file(1:blank(param_file)),STATUS='OLD', &iostat=kode) IF (kode.NE.0) THEN WRITE(*,'('' PROGRAM TERMINATED'')') WRITE(*,*) 'Parameter adjustment file does not exist.' WRITE(*,'('' "'',A,''"'')') param_file(1:blank(param_file)) STOP ENDIF IF (n_param.GT.1) THEN DO i=1,n_param-1 READ(98,*) ENDDO ENDIF READ(98,*) ans CLOSE(98) p_sand = ans(1) p_silt = (100.0-p_sand)*ans(2)/100.0 p_bulk = ans(3) p_orgc = ans(4) p_awl(1) = ans(5) p_awl(2) = ans(6) p_awl(3) = ans(7) p_awl(4) = ans(8) p_bc_res = ans(9) p_kx = ans(10) p_kd = ans(11) p_bs = ans(12) p_et = ans(13) p_roff = ans(14) p_roff2 = ans(15) p_dep = ans(16) p_topsl = ans(17) RETURN END
source/f90/parameter_adjustment.f
!> This module contains the subroutines which set the initial value of the !! fields and the distribution function. module init_g implicit none public :: ginit public :: init_init_g, finish_init_g public :: width0 public :: scale_to_phiinit, phiinit public :: tstart public :: reset_init private ! knobs integer :: ginitopt_switch integer, parameter :: ginitopt_default = 1, & ginitopt_noise = 2, ginitopt_restart_many = 3, & ginitopt_kpar = 4, ginitopt_nltest = 5, & ginitopt_kxtest = 6, ginitopt_rh = 7, & ginitopt_remap = 8 real :: width0, phiinit, imfac, refac, zf_init real :: den0, upar0, tpar0, tperp0 real :: den1, upar1, tpar1, tperp1 real :: den2, upar2, tpar2, tperp2 real :: tstart, scale, kxmax, kxmin logical :: chop_side, left, even, scale_to_phiinit character(300), public :: restart_file character(len=150) :: restart_dir logical :: initialized = .false. logical :: exist contains subroutine init_init_g use stella_save, only: init_save, read_many use stella_layouts, only: init_stella_layouts use system_fortran, only: systemf use mp, only: proc0, broadcast implicit none integer :: ind_slash if (initialized) return initialized = .true. call init_stella_layouts if (proc0) call read_parameters ! prepend restart_dir to restart_file ! append trailing slash if not exists if (restart_dir(len_trim(restart_dir):) /= "/") & restart_dir = trim(restart_dir)//"/" if (proc0) call systemf('mkdir -p '//trim(restart_dir)) !Determine if restart file contains "/" if so split on this point to give DIR//FILE !so restart files are created in DIR//restart_dir//FILE ind_slash = index(restart_file, "/", .true.) if (ind_slash == 0) then !No slash present restart_file = trim(restart_dir)//trim(restart_file) else !Slash present restart_file = trim(restart_file(1:ind_slash))//trim(restart_dir)//trim(restart_file(ind_slash + 1:)) end if call broadcast(ginitopt_switch) call broadcast(width0) call broadcast(refac) call broadcast(imfac) call broadcast(den0) call broadcast(upar0) call broadcast(tpar0) call broadcast(tperp0) call broadcast(den1) call broadcast(upar1) call broadcast(tpar1) call broadcast(tperp1) call broadcast(den2) call broadcast(upar2) call broadcast(tpar2) call broadcast(tperp2) call broadcast(phiinit) call broadcast(zf_init) call broadcast(kxmax) call broadcast(kxmin) call broadcast(tstart) call broadcast(chop_side) call broadcast(even) call broadcast(left) call broadcast(restart_file) call broadcast(read_many) call broadcast(scale_to_phiinit) call broadcast(scale) call init_save(restart_file) end subroutine init_init_g subroutine ginit(restarted, istep0) use stella_save, only: init_tstart use physics_flags, only: full_flux_surface logical, intent(out) :: restarted integer, intent(out) :: istep0 integer :: istatus restarted = .false. istep0 = 0 select case (ginitopt_switch) case (ginitopt_default) call ginit_default case (ginitopt_noise) call ginit_noise case (ginitopt_kpar) call ginit_kpar case (ginitopt_rh) call ginit_rh case (ginitopt_remap) call ginit_remap case (ginitopt_restart_many) call ginit_restart_many call init_tstart(tstart, istep0, istatus) restarted = .true. scale = 1. ! case (ginitopt_nltest) ! call ginit_nltest ! case (ginitopt_kxtest) ! call ginit_kxtest end select !> if simulating a full flux surface, g is normalized by F0 (which is not the case otherwise) !> unless reading in g from a restart file, normalise g by F0 for a full flux surface simulation if (full_flux_surface .and. ginitopt_switch /= ginitopt_restart_many) then call normalize_by_maxwellian end if end subroutine ginit subroutine read_parameters use file_utils, only: input_unit, error_unit, run_name, input_unit_exist use text_options, only: text_option, get_option_value use stella_save, only: read_many implicit none type(text_option), dimension(8), parameter :: ginitopts = & (/text_option('default', ginitopt_default), & text_option('noise', ginitopt_noise), & text_option('many', ginitopt_restart_many), & text_option('nltest', ginitopt_nltest), & text_option('kxtest', ginitopt_kxtest), & text_option('kpar', ginitopt_kpar), & text_option('rh', ginitopt_rh), & text_option('remap', ginitopt_remap) & /) character(20) :: ginit_option namelist /init_g_knobs/ ginit_option, width0, phiinit, chop_side, & restart_file, restart_dir, read_many, left, scale, tstart, zf_init, & den0, upar0, tpar0, tperp0, imfac, refac, even, & den1, upar1, tpar1, tperp1, & den2, upar2, tpar2, tperp2, & kxmax, kxmin, scale_to_phiinit integer :: ierr, in_file tstart = 0. scale = 1.0 ginit_option = "default" width0 = -3.5 refac = 1. imfac = 0. den0 = 1. upar0 = 0. tpar0 = 0. tperp0 = 0. den1 = 0. upar1 = 0. tpar1 = 0. tperp1 = 0. den2 = 0. upar2 = 0. tpar2 = 0. tperp2 = 0. phiinit = 1.0 zf_init = 1.0 kxmax = 1.e100 kxmin = 0. chop_side = .false. scale_to_phiinit = .false. left = .true. even = .true. restart_file = trim(run_name)//".nc" restart_dir = "./" in_file = input_unit_exist("init_g_knobs", exist) ! if (exist) read (unit=input_unit("init_g_knobs"), nml=init_g_knobs) if (exist) read (unit=in_file, nml=init_g_knobs) ierr = error_unit() call get_option_value & (ginit_option, ginitopts, ginitopt_switch, & ierr, "ginit_option in ginit_knobs", stop_on_error=.true.) end subroutine read_parameters subroutine ginit_default use constants, only: zi use species, only: spec use zgrid, only: nzgrid, zed use kt_grids, only: naky, nakx use kt_grids, only: theta0 use kt_grids, only: reality, zonal_mode use vpamu_grids, only: nvpa, nmu use vpamu_grids, only: vpa use vpamu_grids, only: maxwell_vpa, maxwell_mu, maxwell_fac use dist_fn_arrays, only: gvmu use stella_layouts, only: kxkyz_lo, iz_idx, ikx_idx, iky_idx, is_idx use ran, only: ranf implicit none complex, dimension(naky, nakx, -nzgrid:nzgrid) :: phi logical :: right integer :: ikxkyz integer :: iz, iky, ikx, is, ia right = .not. left do iz = -nzgrid, nzgrid phi(:, :, iz) = exp(-((zed(iz) - theta0) / width0)**2) * cmplx(1.0, 1.0) end do ! this is a messy way of doing things ! could tidy it up a bit if (sum(cabs(phi)) < epsilon(0.)) then do iz = -nzgrid, nzgrid phi(:, :, iz) = exp(-(zed(iz) / width0)**2) * cmplx(1.0, 1.0) end do end if if (chop_side) then if (left) phi(:, :, :-1) = 0.0 if (right) phi(:, :, 1:) = 0.0 end if if (reality .and. zonal_mode(1)) phi(1, :, :) = 0.0 ia = 1 gvmu = 0. do ikxkyz = kxkyz_lo%llim_proc, kxkyz_lo%ulim_proc iz = iz_idx(kxkyz_lo, ikxkyz) ikx = ikx_idx(kxkyz_lo, ikxkyz) iky = iky_idx(kxkyz_lo, ikxkyz) is = is_idx(kxkyz_lo, ikxkyz) gvmu(:, :, ikxkyz) = phiinit * phi(iky, ikx, iz) / abs(spec(is)%z) & * (den0 + 2.0 * zi * spread(vpa, 2, nmu) * upar0) & * spread(maxwell_mu(ia, iz, :, is), 1, nvpa) * spread(maxwell_vpa(:, is), 2, nmu) * maxwell_fac(is) end do end subroutine ginit_default ! initialize two kys and kx=0 ! subroutine ginit_nltest ! use mp, only: proc0 ! use species, only: spec ! use zgrid, only: nzgrid, bmag ! use kt_grids, only: naky, ntheta0 ! use vpamu_grids, only: nvgrid, vpa, mu ! use dist_fn_arrays, only: gnew, gold ! use stella_layouts, only: gxyz_lo, iv_idx, is_idx, imu_idx ! implicit none ! complex, dimension (-nzgrid:nzgrid,ntheta0,naky) :: phi ! logical :: right ! integer :: iglo ! integer :: ig, ik, it, is, iv, imu ! right = .not. left ! if (naky < 4 .or. ntheta0 < 2) then ! if (proc0) write (*,*) 'must have at least 2 kxs and 4 kys to use nltest init option. aborting.' ! stop ! end if ! phi = 0.0 ! do ig = -nzgrid, nzgrid ! phi(ig,2,2) = 1.0!exp(-((theta(ig)-theta0(2,2))/width0)**2)*cmplx(1.0,1.0) ! end do ! gnew = 0.0 ! do iglo = gxyz_lo%llim_proc, gxyz_lo%ulim_proc ! iv = iv_idx(gxyz_lo,iglo) ! is = is_idx(gxyz_lo,iglo) ! imu = imu_idx(gxyz_lo,iglo) ! it = 1 ! do ik = 2, 3 ! gnew(:,it,ik,iglo) = exp(-2.0*mu(imu)*bmag)*phi(:,it,ik) & ! *spec(is)%z*phiinit*exp(-vpa(iv)**2) ! end do ! end do ! gold = gnew ! end subroutine ginit_nltest ! subroutine ginit_kxtest ! use constants, only: zi ! use species, only: spec ! use zgrid, only: itor_over_b ! use kt_grids, only: ntheta0, akx, naky ! use vpamu_grids, only: nvgrid, energy, vpa ! use dist_fn_arrays, only: gnew, gold ! use stella_layouts, only: gxyz_lo, iv_idx, is_idx, imu_idx ! implicit none ! integer :: iglo ! integer :: ik, it, is, imu, iv ! do iglo = gxyz_lo%llim_proc, gxyz_lo%ulim_proc ! iv = iv_idx(gxyz_lo,iglo) ! is = is_idx(gxyz_lo,iglo) ! imu = imu_idx(gxyz_lo,iglo) ! do it = 1, ntheta0 ! do ik = 1, naky ! gnew(:,it,ik,iglo) = exp(-zi*akx(it)*itor_over_B*vpa(iv)/spec(is)%zstm) & ! *exp(-energy(:,iv,imu))*spec(is)%z*phiinit ! end do ! end do ! end do ! gold = gnew ! end subroutine ginit_kxtest ! !> Initialise with only the kparallel = 0 mode. ! subroutine single_initial_kx(phi) ! use zgrid, only: nzgrid ! use kt_grids, only: naky, ntheta0 ! use mp, only: mp_abort ! implicit none ! complex, dimension (-nzgrid:nzgrid,ntheta0,naky), intent(inout) :: phi ! real :: a, b ! integer :: ig, ik, it ! if (ikx_init < 2 .or. ikx_init > (ntheta0+1)/2) then ! call mp_abort("The subroutine single_initial_kx should only be called when 1 < ikx_init < (ntheta0+1)/2") ! end if ! do it = 1, ntheta0 ! if (it .ne. ikx_init) then ! do ik = 1, naky ! do ig = -nzgrid, nzgrid ! a = 0.0 ! b = 0.0 ! phi(ig,it,ik) = cmplx(a,b) ! end do ! end do ! end if ! end do ! end subroutine single_initial_kx !> Initialise the distribution function with random noise. This is the default !! initialisation option. Each different mode is given a random amplitude !! between zero and one. subroutine ginit_noise use mp, only: proc0, broadcast use dist_fn_arrays, only: kperp2 use species, only: spec use zgrid, only: nzgrid, ntubes use extended_zgrid, only: ikxmod, nsegments, neigen use extended_zgrid, only: it_right use extended_zgrid, only: periodic use kt_grids, only: naky, nakx, reality, zonal_mode use vpamu_grids, only: nvpa, nmu use vpamu_grids, only: maxwell_vpa, maxwell_mu, maxwell_fac use dist_fn_arrays, only: gvmu use stella_layouts, only: kxkyz_lo use stella_layouts, only: iky_idx, ikx_idx, iz_idx, it_idx, is_idx use mp, only: proc0, broadcast, max_allreduce use mp, only: scope, crossdomprocs, subprocs use file_utils, only: runtype_option_switch, runtype_multibox use ran implicit none complex, dimension(naky, nakx, -nzgrid:nzgrid, ntubes) :: phi real :: a, b, kmin integer :: ikxkyz, iz, it, iky, ikx, is, ie, iseg, ia integer :: itmod if (naky == 1 .and. nakx == 1) then if (proc0) then write (*, *) 'noise initialization option is not suited for single mode simulations.' write (*, *) 'using default initialization option' end if call ginit_default return else ! zero out ky=kx=0 mode phi(1, 1, :, :) = 0.0 end if ia = 1 if (proc0) then phi(1, 1, :, :) = 0.0 kmin = 1.e6 if (naky > 1) kmin = minval(kperp2(2, 1, ia, :)) if (nakx > 1) kmin = min(kmin, minval(kperp2(1, 2, ia, :))) if (runtype_option_switch == runtype_multibox) then call scope(crossdomprocs) call max_allreduce(kmin) call scope(subprocs) end if ! keep old (ikx, iky) loop order to get old results exactly: !Fill phi with random (complex) numbers between -0.5 and 0.5 do ikx = 1, nakx do iky = 1, naky do it = 1, ntubes do iz = -nzgrid, nzgrid a = ranf() - 0.5 b = ranf() - 0.5 ! do not populate high k modes with large amplitudes if ((ikx > 1 .or. iky > 1) .and. (kperp2(iky, ikx, ia, iz) >= kmin)) then !the following as an extra factor of kmin to offset the Gamma-1 in quasineutrality phi(iky, ikx, iz, it) = cmplx(a, b) * kmin * kmin / kperp2(iky, ikx, ia, iz) else phi(iky, ikx, iz, it) = 0.0 end if end do if (chop_side) then if (left) then phi(iky, ikx, :-1, it) = 0.0 else phi(iky, ikx, 1:, it) = 0.0 end if end if end do end do end do ! enforce periodicity where required do iky = 1, naky if (periodic(iky)) then phi(1, :, nzgrid, :) = phi(1, :, -nzgrid, :) end if end do ! zero out the kx=ky=0 mode and apply optional ! scaliing factor to all zonal modes if (zonal_mode(1)) then !Apply scaling factor phi(1, :, :, :) = phi(1, :, :, :) * zf_init !Set ky=kx=0.0 mode to zero in amplitude phi(1, 1, :, :) = 0.0 end if !Apply reality condition (i.e. -kx mode is conjugate of +kx mode) if (reality) then do ikx = nakx / 2 + 2, nakx phi(1, ikx, :, :) = conjg(phi(1, nakx - ikx + 2, :, :)) end do end if end if do iky = 1, naky do ie = 1, neigen(iky) ! enforce zero BC at ends of domain, unless periodic if (.not. periodic(iky)) then phi(iky, ikxmod(1, ie, iky), -nzgrid, :) = 0.0 phi(iky, ikxmod(nsegments(ie, iky), ie, iky), nzgrid, :) = 0.0 end if ! enforce equality of g values at duplicate zed points if (nsegments(ie, iky) > 1) then do it = 1, ntubes itmod = it do iseg = 2, nsegments(ie, iky) phi(iky, ikxmod(iseg, ie, iky), -nzgrid, it_right(itmod)) = phi(iky, ikxmod(iseg - 1, ie, iky), nzgrid, itmod) itmod = it_right(itmod) end do end do end if end do end do call broadcast(phi) !Now set g using data in phi do ikxkyz = kxkyz_lo%llim_proc, kxkyz_lo%ulim_proc iz = iz_idx(kxkyz_lo, ikxkyz) it = it_idx(kxkyz_lo, ikxkyz) ikx = ikx_idx(kxkyz_lo, ikxkyz) iky = iky_idx(kxkyz_lo, ikxkyz) is = is_idx(kxkyz_lo, ikxkyz) gvmu(:, :, ikxkyz) = spec(is)%z * phiinit * phi(iky, ikx, iz, it) & * spread(maxwell_vpa(:, is), 2, nmu) * spread(maxwell_mu(ia, iz, :, is), 1, nvpa) * maxwell_fac(is) end do end subroutine ginit_noise subroutine ginit_kpar ! use species, only: spec, has_electron_species use zgrid, only: nzgrid, zed use kt_grids, only: naky, nakx, theta0 use vpamu_grids, only: nvpa, nmu use vpamu_grids, only: vpa, vperp2 use vpamu_grids, only: maxwell_vpa, maxwell_mu, maxwell_fac use dist_fn_arrays, only: gvmu use stella_layouts, only: kxkyz_lo, iky_idx, ikx_idx, iz_idx, is_idx use constants, only: zi implicit none complex, dimension(naky, nakx, -nzgrid:nzgrid) :: phi, odd real, dimension(-nzgrid:nzgrid) :: dfac, ufac, tparfac, tperpfac integer :: ikxkyz integer :: iz, iky, ikx, imu, iv, ia, is phi = 0. odd = 0. if (width0 > 0.) then do iz = -nzgrid, nzgrid phi(:, :, iz) = exp(-((zed(iz) - theta0) / width0)**2) * cmplx(refac, imfac) end do else do iz = -nzgrid, nzgrid phi(:, :, iz) = cmplx(refac, imfac) end do end if if (chop_side) then if (left) then phi(:, :, :-1) = 0.0 else phi(:, :, 1:) = 0.0 end if end if odd = zi * phi dfac = den0 + den1 * cos(zed) + den2 * cos(2.*zed) ufac = upar0 + upar1 * sin(zed) + upar2 * sin(2.*zed) tparfac = tpar0 + tpar1 * cos(zed) + tpar2 * cos(2.*zed) tperpfac = tperp0 + tperp1 * cos(zed) + tperp2 * cos(2.*zed) ia = 1 ! charge dependence keeps initial Phi from being too small do ikxkyz = kxkyz_lo%llim_proc, kxkyz_lo%ulim_proc iky = iky_idx(kxkyz_lo, ikxkyz) ikx = ikx_idx(kxkyz_lo, ikxkyz) iz = iz_idx(kxkyz_lo, ikxkyz) is = is_idx(kxkyz_lo, ikxkyz) do imu = 1, nmu do iv = 1, nvpa gvmu(iv, imu, ikxkyz) = phiinit & * (dfac(iz) * phi(iky, ikx, iz) & + 2.0 * vpa(iv) * ufac(iz) * odd(iky, ikx, iz) & + (vpa(iv)**2 - 0.5) * tparfac(iz) * phi(iky, ikx, iz) & + tperpfac(iz) * (vperp2(ia, iz, imu) - 1.) * phi(iky, ikx, iz)) end do end do gvmu(:, :, ikxkyz) = gvmu(:, :, ikxkyz) & * spread(maxwell_vpa(:, is), 2, nmu) * spread(maxwell_mu(ia, iz, :, is), 1, nvpa) * maxwell_fac(is) end do ! FLAG -- should be uncommented, which means I need to fix flae ! if (has_electron_species(spec)) then ! call flae (gold, gnew) ! gold = gold - gnew ! end if ! gnew = gold end subroutine ginit_kpar subroutine ginit_rh use species, only: spec use dist_fn_arrays, only: gvmu, kperp2 use stella_layouts, only: kxkyz_lo use stella_layouts, only: iky_idx, ikx_idx, iz_idx, is_idx use vpamu_grids, only: maxwell_vpa, maxwell_mu, maxwell_fac use vpamu_grids, only: nvpa, nmu use kt_grids, only: akx implicit none integer :: ikxkyz, iky, ikx, iz, is, ia ! initialize g to be a Maxwellian with a constant density perturbation gvmu = 0. ia = 1 do ikxkyz = kxkyz_lo%llim_proc, kxkyz_lo%ulim_proc iky = iky_idx(kxkyz_lo, ikxkyz); if (iky /= 1) cycle ikx = ikx_idx(kxkyz_lo, ikxkyz) iz = iz_idx(kxkyz_lo, ikxkyz) is = is_idx(kxkyz_lo, ikxkyz) if (abs(akx(ikx)) < kxmax .and. abs(akx(ikx)) > kxmin) then gvmu(:, :, ikxkyz) = spec(is)%z * 0.5 * phiinit * kperp2(iky, ikx, ia, iz) & * spread(maxwell_vpa(:, is), 2, nmu) * spread(maxwell_mu(ia, iz, :, is), 1, nvpa) * maxwell_fac(is) end if end do end subroutine ginit_rh subroutine ginit_remap use species, only: spec use dist_fn_arrays, only: gvmu use stella_layouts, only: kxkyz_lo use stella_layouts, only: iky_idx, ikx_idx, iz_idx, is_idx use vpamu_grids, only: maxwell_vpa, maxwell_mu, maxwell_fac use vpamu_grids, only: nvpa, nmu implicit none integer :: ikxkyz, iky, ikx, iz, is, ia ! initialize g to be a Maxwellian with a constant density perturbation gvmu = 0. ia = 1 do ikxkyz = kxkyz_lo%llim_proc, kxkyz_lo%ulim_proc iky = iky_idx(kxkyz_lo, ikxkyz) ikx = ikx_idx(kxkyz_lo, ikxkyz) iz = iz_idx(kxkyz_lo, ikxkyz) is = is_idx(kxkyz_lo, ikxkyz) !if((ikx.eq.15.and.iky.eq.5).or.((ikx-nakx).eq.-12.and.iky.eq.3)) then if ((ikx == 1 .and. iky == 2)) then gvmu(:, :, ikxkyz) = spec(is)%z * phiinit & * spread(maxwell_vpa(:, is), 2, nmu) * spread(maxwell_mu(ia, iz, :, is), 1, nvpa) * maxwell_fac(is) end if end do end subroutine ginit_remap subroutine ginit_restart_many use dist_fn_arrays, only: gvmu use stella_save, only: stella_restore use mp, only: proc0 use file_utils, only: error_unit implicit none integer :: istatus, ierr ! should really check if profile_variation=T here but need ! to move profile_variation to module that is accessible here call stella_restore(gvmu, scale, istatus) if (istatus /= 0) then ierr = error_unit() if (proc0) write (ierr, *) "Error reading file: ", trim(restart_file) gvmu = 0. end if end subroutine ginit_restart_many subroutine normalize_by_maxwellian use stella_layouts, only: kxkyz_lo, is_idx, iz_idx use dist_fn_arrays, only: gvmu use vpamu_grids, only: nmu use vpamu_grids, only: maxwell_mu, maxwell_vpa, maxwell_fac implicit none integer :: ia, imu integer :: ikxkyz, iz, is !> gvmu is initialised with a Maxwellian weighting for flux tube simulations, !> with the Maxwellian evaluated at ia = 1 !> we are undoing that weighting here, so also need to use ia = 1 ia = 1 do ikxkyz = kxkyz_lo%llim_proc, kxkyz_lo%ulim_proc iz = iz_idx(kxkyz_lo, ikxkyz) is = is_idx(kxkyz_lo, ikxkyz) do imu = 1, nmu gvmu(:, imu, ikxkyz) = gvmu(:, imu, ikxkyz) / (maxwell_mu(ia, iz, imu, is) * maxwell_vpa(:, is) * maxwell_fac(is)) end do end do end subroutine normalize_by_maxwellian subroutine reset_init ginitopt_switch = ginitopt_restart_many end subroutine reset_init ! subroutine flae (g, gavg) ! use species, only: spec, electron_species ! use zgrid, only: nzgrid, delthet, jacob ! use kt_grids, only: aky, ntheta0 ! use vpamu_grids, only: nvgrid ! use stella_layouts, only: gxyz_lo, is_idx ! complex, dimension (-nzgrid:,:,:,gxyz_lo%llim_proc:), intent (in) :: g ! complex, dimension (-nzgrid:,:,:,gxyz_lo%llim_proc:), intent (out) :: gavg ! real :: wgt ! integer :: iglo, it, ik ! gavg = 0. ! wgt = 1./sum(delthet*jacob) ! do iglo = gxyz_lo%llim_proc, gxyz_lo%ulim_proc ! if (spec(is_idx(gxyz_lo, iglo))%type /= electron_species) cycle ! ik = 1 ! if (aky(ik) > epsilon(0.)) cycle ! do it = 1, ntheta0 ! gavg(:,it,ik,iglo) = sum(g(:,it,ik,iglo)*delthet*jacob)*wgt ! end do ! end do ! end subroutine flae subroutine finish_init_g use stella_save, only: finish_save implicit none initialized = .false. call finish_save end subroutine finish_init_g end module init_g
init_g.f90
module m_intgrf implicit none TYPE :: intgrf_out REAL :: value ! value of the integration INTEGER :: ierror ! error code END TYPE intgrf_out ! error and warning codes for intgrf function INTEGER, PARAMETER :: NO_ERROR = 0 INTEGER, PARAMETER :: NEGATIVE_EXPONENT_WARNING = 1 INTEGER, PARAMETER :: NEGATIVE_EXPONENT_ERROR = 2 CONTAINS !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Integrates function f numerically (Lagrange and Simpson integration) ! on grid(itype) and is much faster than intgr. ! (Only normal outward integration.) ! Before first use of this function it has to be initialized with ! intgrf_init. FUNCTION intgrf(f, atoms, itype, gridf) use m_juDFT use m_types_setup USE m_constants IMPLICIT NONE REAL :: intgrf type(t_atoms) :: atoms INTEGER, INTENT(IN) :: itype REAL, INTENT(IN) :: gridf(atoms%jmtd, atoms%ntype) REAL, INTENT(IN) :: f(:) ! - local - TYPE(intgrf_out) :: fct_res fct_res = pure_intgrf(f, atoms%jri, atoms%jmtd, atoms%rmsh, atoms%dx, & atoms%ntype, itype, gridf) IF (fct_res%ierror == NEGATIVE_EXPONENT_WARNING) THEN write (oUnit, *) 'intgrf: Warning!'// & 'Negative exponent x in extrapolation a+c*r**x' ELSEIF (fct_res%ierror == NEGATIVE_EXPONENT_ERROR) THEN write (oUnit, *) & 'intgrf: Negative exponent x in extrapolation a+c*r**x' CALL juDFT_error( & 'intgrf: Negative exponent x in extrapolation a+c*r**x') END IF intgrf = fct_res%value END FUNCTION intgrf ! pure wrapper for intgrf with same functionality ! can be used within forall loops PURE FUNCTION pure_intgrf(f, jri, jmtd, rmsh, dx, ntype, itype, gridf) IMPLICIT NONE TYPE(intgrf_out) :: pure_intgrf INTEGER, INTENT(IN) :: itype, ntype, jmtd INTEGER, INTENT(IN) :: jri(ntype) REAL, INTENT(IN) :: dx(ntype), rmsh(jmtd, ntype) REAL, INTENT(IN) :: gridf(jmtd, ntype) REAL, INTENT(IN) :: f(:) ! - local - INTEGER :: n REAL :: r1, h, a, x n = jri(itype) r1 = rmsh(1, itype) h = dx(itype) pure_intgrf%ierror = NO_ERROR ! integral from 0 to r1 approximated by leading term in power series expansion IF (f(1)*f(2) > 1e-10 .AND. h > 0) THEN IF (f(2) == f(1)) THEN pure_intgrf%value = r1*f(1) ELSE x = (f(3) - f(2))/(f(2) - f(1)) a = (f(2) - x*f(1))/(1 - x) x = log(x)/h IF (x < 0) THEN IF (x > -1) THEN pure_intgrf%ierror = NEGATIVE_EXPONENT_WARNING ELSE IF (x <= -1) THEN pure_intgrf%ierror = NEGATIVE_EXPONENT_ERROR RETURN END IF END IF pure_intgrf%value = r1*(f(1) + x*a)/(x + 1) ! x = f(2) / f(1) ! x = log(x)/h ! IF(x.lt.0) THEN ! IF(x.gt.-1) write(oUnit,'(A,ES9.1)') 'intgrf: Warning!& ! & Negative exponent x in& ! & extrapolation c*r**x:',x ! IF(x.le.-1) write(oUnit,'(A,ES9.1)') 'intgrf: Negative exponent& ! & x in extrapolation& ! & c*r**x:',x ! IF(x.le.-1) call juDFT_error('intgrf: Negative exponent& ! & x in extrapolation & ! & c*r**x') ! END IF ! intgrf = (r1*f(1))/(x+1) END IF ELSE pure_intgrf%value = 0 END IF ! integrate from r(1) to r(n) by multiplying with gridf pure_intgrf%value = pure_intgrf%value & + dot_product(gridf(:n, itype), f(:n)) END FUNCTION pure_intgrf ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Initializes fast numerical integration intgrf (see below). SUBROUTINE intgrf_init(ntype, jmtd, jri, dx, rmsh, gridf) IMPLICIT NONE INTEGER, INTENT(IN) :: ntype, jmtd INTEGER, INTENT(IN) :: jri(ntype) REAL, INTENT(IN) :: dx(ntype), rmsh(jmtd, ntype) REAL, INTENT(OUT), ALLOCATABLE :: gridf(:, :) ! - local - INTEGER :: i, j, itype INTEGER :: n, nstep, n0 = 6 INTEGER, PARAMETER :: simpson(7) = (/41, 216, 27, 272, 27, 216, 41/) REAL :: r1, h, dr REAL :: r(7) REAL, PARAMETER :: lagrange(7, 6) = reshape( & (/19087., 65112., -46461., 37504., -20211., 6312., -863., & -863., 25128., 46989., -16256., 7299., -2088., 271., & & 271., -2760., 30819., 37504., -6771., 1608., -191., & -191., 1608., -6771., 37504., 30819., -2760., 271., & & 271., -2088., 7299., -16256., 46989., 25128., -863., & -863., 6312., -20211., 37504., -46461., 65112., 19087./), & ! The last row is actually never used. (/7, 6/)) n = jmtd ALLOCATE (gridf(n, ntype)) gridf = 0 DO itype = 1, ntype n = jri(itype) r1 = rmsh(1, itype) h = dx(itype) nstep = (n - 1)/6 n0 = n - 6*nstep dr = exp(h) ! Calculate Lagrange-integration coefficients from r(1) to r(n0) r(1) = r1 IF (n0 > 1) THEN DO i = 2, 7 r(i) = r(i - 1)*dr END DO DO i = 1, 7 gridf(i, itype) = h/60480*r(i)*sum(lagrange(i, 1:n0 - 1)) END DO r(1) = r(n0) END IF ! Calculate Simpson-integration coefficients from r(n0) to r(n) DO i = 1, nstep DO j = 2, 7 r(j) = r(j - 1)*dr END DO DO j = n0, n0 + 6 gridf(j, itype) = gridf(j, itype) + h/140*r(j - n0 + 1)* & simpson(j - n0 + 1) END DO n0 = n0 + 6 r(1) = r(7) END DO END DO END SUBROUTINE intgrf_init end module m_intgrf
hybrid/util/intgrf.f90
c compute the mean spectrum c nspec is the # of spectra, nspmax is physical dimension of array subroutine compmean(specarray,nspec,nspmax,nwave,specmean,specrms) real specarray(nspmax,nwave) real specmean(nwave),specrms(nwave) include 'pcredshift.h' do j=1,nwave sum = 0.0 sumsq = 0.0 np = 0 do i=1,nspec if (specarray(i,j) .gt. bad) then sum = sum + specarray(i,j) sumsq = sumsq + specarray(i,j)*specarray(i,j) np = np + 1 end if end do if (np .eq. 0) then specmean(j) = badset specrms(j) = badset else if (np .eq. 1) then specmean(j) = sum/np specrms(j) = badset else specmean(j) = sum/np specrms(j) = sqrt(sumsq/np - specmean(j)*specmean(j)) end if end do return end
compmean.f
Subroutine flow(nt) Parameter (pi=3.1415926, apion=0.13957, aka=0.498) Parameter (maxstr=150001, maxr=1, amu=0.9383, etam=0.5475) Dimension ypion(-80:80), ypr(-80:80), ykaon(-80:80) Dimension pxpion(-80:80), pxpro(-80:80), pxkaon(-80:80) Common /aa/r(3, maxstr) Common /bb/p(3, maxstr) Common /cc/e(maxstr) Common /ee/id(maxstr), lb(maxstr) Common /rr/massr(0:maxr) Common /run/num Common /input1/masspr, massta, iseed, iavoid, dt Save ycut1 = -2.6 ycut2 = 2.6 dy = 0.2 ly = nint((ycut2-ycut1)/dy) Do kk = -80, 80 pxpion(kk) = 0 pxpro(kk) = 0 pxkaon(kk) = 0 End Do Do j = -ly, ly ypion(j) = 0 ykaon(j) = 0 ypr(j) = 0 End Do nkaon = 0 npr = 0 npion = 0 is = 0 Do nrun = 1, num is = is + massr(nrun-1) Do j = 1, massr(nrun) i = j + is e00 = sqrt(p(1,i)**2+p(2,i)**2+p(3,i)**2+e(i)**2) y00 = 0.5*alog((e00+p(3,i))/(e00-p(3,i))) If (abs(y00)>=ycut2) Goto 20 iy = nint(y00/dy) If (abs(iy)>=80) Goto 20 If (e(i)==0) Goto 20 If (lb(i)>=25) Goto 20 If ((lb(i)<=5) .And. (lb(i)>=3)) Goto 50 If (lb(i)==1 .Or. lb(i)==2) Goto 200 If (lb(i)>=6 .And. lb(i)<=17) Goto 200 If (lb(i)==23) Goto 400 Goto 20 50 npion = npion + 1 ypion(iy) = ypion(iy) + 1 pxpion(iy) = pxpion(iy) + p(1, i)/e(i) Goto 20 200 npr = npr + 1 pxpro(iy) = pxpro(iy) + p(1, i)/e(i) ypr(iy) = ypr(iy) + 1. Goto 20 400 nkaon = nkaon + 1 ykaon(iy) = ykaon(iy) + 1. pxkaon(iy) = pxkaon(iy) + p(1, i)/e(i) 20 End Do End Do Do npt = -10, 10 If (ypr(npt)==0) Goto 101 pxpro(npt) = -pxpro(npt)/ypr(npt) dnuc = pxpro(npt)/sqrt(ypr(npt)) 101 If (ypion(npt)==0) Goto 102 pxpion(npt) = -pxpion(npt)/ypion(npt) dnucp = pxpion(npt)/sqrt(ypion(npt)) 102 If (ykaon(npt)==0) Goto 3 pxkaon(npt) = -pxkaon(npt)/ykaon(npt) dnuck = pxkaon(npt)/sqrt(ykaon(npt)) 3 End Do Do m = -ly, ly dypr = 0 If (ypr(m)/=0) dypr = sqrt(ypr(m))/float(nrun)/dy ypr(m) = ypr(m)/float(nrun)/dy dypion = 0 If (ypion(m)/=0) dypion = sqrt(ypion(m))/float(nrun)/dy ypion(m) = ypion(m)/float(nrun)/dy dykaon = 0 If (ykaon(m)/=0) dykaon = sqrt(ykaon(m))/float(nrun)/dy ykaon(m) = ykaon(m)/float(nrun)/dy End Do Return End Subroutine flow
src/flow.f90
!> Benchmark program program fhash_demo use fhash, only: fhash_tbl_t, key=>fhash_key implicit none type(fhash_tbl_t) :: tbl integer :: i, stat integer :: num_buckets, num_items, num_collisions, max_depth integer, parameter :: n = 1e7 real(kind(0.d0)) :: t0, t1 print *, '# fhash demo program: benchmark' !> Manually specify number of table buckets call tbl%allocate(2*n) print *, 'Setting keys... ' call cpu_time(t0) do i=1,n call tbl%set(key([1,2,3,4,5,6,7,8,9,10,11,12,13,i]),0.0d0) end do call cpu_time(t1) print *, 'Time: ', (t1-t0) print *, 'Items per second: ', n/(t1-t0) print * !> Query information about the hash table print *, 'Querying table info...' call tbl%stats(num_buckets,num_items,num_collisions,max_depth) write(*,'(A,T40,I0)') ' Number of buckets allocated: ',num_buckets write(*,'(A,T40,I0)') ' Number of key-value pairs stored: ',num_items write(*,'(A,T40,I0)') ' Total number of hash-collisions: ',num_collisions write(*,'(A,T40,I0)') ' The worst case bucket depth is ',max_depth print * end program fhash_demo
app/bench/main.f90
! ########################################################### ! # # ! # THE LIDORT FAMILY # ! # # ! # (LInearized Discrete Ordinate Radiative Transfer) # ! # -- - - - - # ! # # ! ########################################################### ! ########################################################### ! # # ! # Author : Robert. J. D. Spurr # ! # # ! # Address : RT Solutions, Inc. # ! # 9 Channing Street # ! # Cambridge, MA 02138, USA # ! # # ! # Tel: (617) 492 1183 # ! # Email : [email protected] # ! # # ! # This Version : 3.7 F90 # ! # Release Date : June 2014 # ! # # ! # NEW: THERMAL SUPPLEMENT INCLUDED (3.2) # ! # NEW: OUTGOING SPHERICITY CORRECTION (3.2) # ! # NEW: TOTAL COLUMN JACOBIANS (3.3) # ! # VLIDORT COMPATIBILITY (3.4) # ! # THREADED/OPTIMIZED F90 code (3.5) # ! # EXTERNAL SS / NEW I/O STRUCTURES (3.6) # ! # # ! # Surface-leaving, BRDF Albedo-scaling (3.7) # ! # Taylor series, BBF Jacobians, ThreadSafe (3.7) # ! # # ! ########################################################### ! ##################################################### ! # # ! # This Version of LIDORT comes with a GNU-style # ! # license. Please read the license carefully. # ! # # ! ##################################################### MODULE BRDF_Sup_Mod ! BRDF standard i/o type definitions USE BRDF_Sup_Inputs_def USE BRDF_Sup_Outputs_def ! BRDF main standard file USE BRDF_Sup_Masters_M END MODULE BRDF_Sup_Mod
src/Components/rtms/RTSI/LIDORT3p7/sup/brdf/brdf_sup_mod.f90
MODULE cbmz_mosaic_4bin_vbs9_Parameters USE cbmz_mosaic_4bin_vbs9_Precision PUBLIC SAVE INTEGER, PARAMETER :: NSPEC = 138 INTEGER, PARAMETER :: NVAR = 136 INTEGER, PARAMETER :: NVARACT = 124 INTEGER, PARAMETER :: NFIX = 2 INTEGER, PARAMETER :: NREACT = 210 INTEGER, PARAMETER :: NVARST = 1 INTEGER, PARAMETER :: NFIXST = 137 INTEGER, PARAMETER :: NONZERO = 957 INTEGER, PARAMETER :: LU_NONZERO = 1029 INTEGER, PARAMETER :: CNVAR = 137 INTEGER, PARAMETER :: NLOOKAT = 0 INTEGER, PARAMETER :: NMONITOR = 0 INTEGER, PARAMETER :: NMASS = 1 REAL(kind=dp), PARAMETER :: PI = 3.14159265358979 INTEGER, PARAMETER :: ind_H2SO4 = 1 INTEGER, PARAMETER :: ind_HCl = 2 INTEGER, PARAMETER :: ind_NH3 = 3 INTEGER, PARAMETER :: ind_PCG1_B_C = 4 INTEGER, PARAMETER :: ind_PCG1_B_O = 5 INTEGER, PARAMETER :: ind_PCG1_F_C = 6 INTEGER, PARAMETER :: ind_PCG1_F_O = 7 INTEGER, PARAMETER :: ind_HCOOH = 8 INTEGER, PARAMETER :: ind_RCOOH = 9 INTEGER, PARAMETER :: ind_ARO1 = 10 INTEGER, PARAMETER :: ind_ARO2 = 11 INTEGER, PARAMETER :: ind_ALK1 = 12 INTEGER, PARAMETER :: ind_OLE1 = 13 INTEGER, PARAMETER :: ind_API1 = 14 INTEGER, PARAMETER :: ind_API2 = 15 INTEGER, PARAMETER :: ind_LIM1 = 16 INTEGER, PARAMETER :: ind_LIM2 = 17 INTEGER, PARAMETER :: ind_PSD1 = 18 INTEGER, PARAMETER :: ind_PSD2 = 19 INTEGER, PARAMETER :: ind_PCG2_B_O = 20 INTEGER, PARAMETER :: ind_PCG3_B_O = 21 INTEGER, PARAMETER :: ind_PCG4_B_O = 22 INTEGER, PARAMETER :: ind_PCG5_B_O = 23 INTEGER, PARAMETER :: ind_PCG6_B_O = 24 INTEGER, PARAMETER :: ind_PCG7_B_O = 25 INTEGER, PARAMETER :: ind_PCG8_B_O = 26 INTEGER, PARAMETER :: ind_PCG9_B_O = 27 INTEGER, PARAMETER :: ind_PCG2_F_O = 28 INTEGER, PARAMETER :: ind_PCG3_F_O = 29 INTEGER, PARAMETER :: ind_PCG4_F_O = 30 INTEGER, PARAMETER :: ind_PCG5_F_O = 31 INTEGER, PARAMETER :: ind_PCG6_F_O = 32 INTEGER, PARAMETER :: ind_PCG7_F_O = 33 INTEGER, PARAMETER :: ind_PCG8_F_O = 34 INTEGER, PARAMETER :: ind_PCG9_F_O = 35 INTEGER, PARAMETER :: ind_O1D = 36 INTEGER, PARAMETER :: ind_SO2 = 37 INTEGER, PARAMETER :: ind_PCG2_B_C = 38 INTEGER, PARAMETER :: ind_OPCG1_B_C = 39 INTEGER, PARAMETER :: ind_PCG3_B_C = 40 INTEGER, PARAMETER :: ind_PCG4_B_C = 41 INTEGER, PARAMETER :: ind_PCG5_B_C = 42 INTEGER, PARAMETER :: ind_PCG6_B_C = 43 INTEGER, PARAMETER :: ind_PCG7_B_C = 44 INTEGER, PARAMETER :: ind_PCG8_B_C = 45 INTEGER, PARAMETER :: ind_PCG9_B_C = 46 INTEGER, PARAMETER :: ind_OPCG8_B_O = 47 INTEGER, PARAMETER :: ind_ANOL = 48 INTEGER, PARAMETER :: ind_OPCG8_B_C = 49 INTEGER, PARAMETER :: ind_OPCG7_B_O = 50 INTEGER, PARAMETER :: ind_OPCG7_B_C = 51 INTEGER, PARAMETER :: ind_OPCG6_B_O = 52 INTEGER, PARAMETER :: ind_OPCG6_B_C = 53 INTEGER, PARAMETER :: ind_OPCG5_B_O = 54 INTEGER, PARAMETER :: ind_OPCG5_B_C = 55 INTEGER, PARAMETER :: ind_OPCG4_B_O = 56 INTEGER, PARAMETER :: ind_OPCG4_B_C = 57 INTEGER, PARAMETER :: ind_OPCG3_B_O = 58 INTEGER, PARAMETER :: ind_OPCG3_B_C = 59 INTEGER, PARAMETER :: ind_OPCG2_B_C = 60 INTEGER, PARAMETER :: ind_OPCG1_B_O = 61 INTEGER, PARAMETER :: ind_OPCG2_B_O = 62 INTEGER, PARAMETER :: ind_PCG2_F_C = 63 INTEGER, PARAMETER :: ind_OPCG1_F_C = 64 INTEGER, PARAMETER :: ind_PCG3_F_C = 65 INTEGER, PARAMETER :: ind_PCG4_F_C = 66 INTEGER, PARAMETER :: ind_PCG5_F_C = 67 INTEGER, PARAMETER :: ind_PCG6_F_C = 68 INTEGER, PARAMETER :: ind_PCG7_F_C = 69 INTEGER, PARAMETER :: ind_PCG8_F_C = 70 INTEGER, PARAMETER :: ind_PCG9_F_C = 71 INTEGER, PARAMETER :: ind_OPCG8_F_O = 72 INTEGER, PARAMETER :: ind_OPCG8_F_C = 73 INTEGER, PARAMETER :: ind_OPCG7_F_O = 74 INTEGER, PARAMETER :: ind_OPCG7_F_C = 75 INTEGER, PARAMETER :: ind_OPCG6_F_O = 76 INTEGER, PARAMETER :: ind_OPCG6_F_C = 77 INTEGER, PARAMETER :: ind_OPCG5_F_O = 78 INTEGER, PARAMETER :: ind_OPCG5_F_C = 79 INTEGER, PARAMETER :: ind_OPCG4_F_O = 80 INTEGER, PARAMETER :: ind_OPCG4_F_C = 81 INTEGER, PARAMETER :: ind_OPCG3_F_O = 82 INTEGER, PARAMETER :: ind_OPCG3_F_C = 83 INTEGER, PARAMETER :: ind_OPCG2_F_C = 84 INTEGER, PARAMETER :: ind_OPCG1_F_O = 85 INTEGER, PARAMETER :: ind_OPCG2_F_O = 86 INTEGER, PARAMETER :: ind_PAN = 87 INTEGER, PARAMETER :: ind_H2O2 = 88 INTEGER, PARAMETER :: ind_TOL = 89 INTEGER, PARAMETER :: ind_N2O5 = 90 INTEGER, PARAMETER :: ind_XYL = 91 INTEGER, PARAMETER :: ind_CRO = 92 INTEGER, PARAMETER :: ind_CH4 = 93 INTEGER, PARAMETER :: ind_API = 94 INTEGER, PARAMETER :: ind_LIM = 95 INTEGER, PARAMETER :: ind_HNO4 = 96 INTEGER, PARAMETER :: ind_TO2 = 97 INTEGER, PARAMETER :: ind_C2H6 = 98 INTEGER, PARAMETER :: ind_XPAR = 99 INTEGER, PARAMETER :: ind_CH3OOH = 100 INTEGER, PARAMETER :: ind_ETHOOH = 101 INTEGER, PARAMETER :: ind_HONO = 102 INTEGER, PARAMETER :: ind_ETH = 103 INTEGER, PARAMETER :: ind_CH3OH = 104 INTEGER, PARAMETER :: ind_CRES = 105 INTEGER, PARAMETER :: ind_O3P = 106 INTEGER, PARAMETER :: ind_HNO3 = 107 INTEGER, PARAMETER :: ind_CO = 108 INTEGER, PARAMETER :: ind_PAR = 109 INTEGER, PARAMETER :: ind_OPEN = 110 INTEGER, PARAMETER :: ind_ISOPN = 111 INTEGER, PARAMETER :: ind_ISOPO2 = 112 INTEGER, PARAMETER :: ind_ISOPP = 113 INTEGER, PARAMETER :: ind_OLET = 114 INTEGER, PARAMETER :: ind_ISOP = 115 INTEGER, PARAMETER :: ind_HCHO = 116 INTEGER, PARAMETER :: ind_XO2 = 117 INTEGER, PARAMETER :: ind_AONE = 118 INTEGER, PARAMETER :: ind_OLEI = 119 INTEGER, PARAMETER :: ind_NAP = 120 INTEGER, PARAMETER :: ind_MGLY = 121 INTEGER, PARAMETER :: ind_ETHP = 122 INTEGER, PARAMETER :: ind_ALD2 = 123 INTEGER, PARAMETER :: ind_CH3O2 = 124 INTEGER, PARAMETER :: ind_ISOPRD = 125 INTEGER, PARAMETER :: ind_ONIT = 126 INTEGER, PARAMETER :: ind_O3 = 127 INTEGER, PARAMETER :: ind_RO2 = 128 INTEGER, PARAMETER :: ind_NO2 = 129 INTEGER, PARAMETER :: ind_C2O3 = 130 INTEGER, PARAMETER :: ind_OH = 131 INTEGER, PARAMETER :: ind_HO2 = 132 INTEGER, PARAMETER :: ind_NO = 133 INTEGER, PARAMETER :: ind_ANO2 = 134 INTEGER, PARAMETER :: ind_ROOH = 135 INTEGER, PARAMETER :: ind_NO3 = 136 INTEGER, PARAMETER :: ind_H2O = 137 INTEGER, PARAMETER :: ind_M = 138 INTEGER, PARAMETER :: indf_H2O = 1 INTEGER, PARAMETER :: indf_M = 2 END MODULE cbmz_mosaic_4bin_vbs9_Parameters
WRF-CHEM/chem/module_kpp_cbmz_mosaic_4bin_vbs9_Parameters.f90
SUBROUTINE PBZTRST1( ICONTXT, XDIST, N, NB, NZ, X, INCX, BETA, Y, $ INCY, LCMP, LCMQ, NINT ) * * -- PB-BLAS routine (version 2.1) -- * University of Tennessee, Knoxville, Oak Ridge National Laboratory. * April 28, 1996 * * .. Scalar Arguments .. CHARACTER*1 XDIST INTEGER ICONTXT, INCX, INCY, LCMP, LCMQ, N, NB, NINT, $ NZ COMPLEX*16 BETA * .. * .. Array Arguments .. COMPLEX*16 X( * ), Y( * ) * .. * * Purpose * ======= * * PBZTRST1 forms y <== x + beta * y, where y is a sorted * condensed row (or column) vector from a column (or row) vector of x. * * ===================================================================== * * .. Parameters .. COMPLEX*16 ONE PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) ) * .. * .. Local Variables .. INTEGER ITER, IX, IY, K, KK, KZ, NJUMP * .. * .. External Subroutines .. EXTERNAL PBZVECADD * .. * .. External Functions .. LOGICAL LSAME INTEGER ICEIL EXTERNAL ICEIL, LSAME * .. * .. Intrinsic Functions .. INTRINSIC MIN, MAX, MOD * .. * .. Executable Statements .. * ITER = ICEIL( NINT, NB ) KZ = NZ * IF( LSAME( XDIST, 'R' ) ) THEN NJUMP = NB * LCMQ * DO 20 KK = 0, LCMQ-1 IX = NINT * MOD( KK*LCMP, LCMQ ) IY = MAX( 0, NB*KK-NZ ) IF( N.LT.IY ) GO TO 50 * IF( ITER.GT.1 ) THEN CALL PBZVECADD( ICONTXT, 'G', NB-KZ, ONE, X(IX*INCX+1), $ INCX, BETA, Y(IY*INCY+1), INCY ) IX = IX + NB - KZ IY = IY + NJUMP - KZ KZ = 0 * DO 10 K = 2, ITER-1 CALL PBZVECADD( ICONTXT, 'G', NB, ONE, X(IX*INCX+1), $ INCX, BETA, Y(IY*INCY+1), INCY ) IX = IX + NB IY = IY + NJUMP 10 CONTINUE END IF * CALL PBZVECADD( ICONTXT, 'G', MIN(NB-KZ,N-IY), ONE, $ X(IX*INCX+1), INCX, BETA, Y(IY*INCY+1), $ INCY ) KZ = 0 20 CONTINUE * * if( LSAME( XDIST, 'C' ) ) then * ELSE NJUMP = NB * LCMP * DO 40 KK = 0, LCMP-1 IX = NINT * MOD( KK*LCMQ, LCMP ) IY = MAX( 0, NB*KK-NZ ) IF( N.LT.IY ) GO TO 50 * IF( ITER.GT.1 ) THEN CALL PBZVECADD( ICONTXT, 'G', NB-KZ, ONE, X(IX*INCX+1), $ INCX, BETA, Y(IY*INCY+1), INCY ) IX = IX + NB - KZ IY = IY + NJUMP - KZ KZ = 0 * DO 30 K = 2, ITER-1 CALL PBZVECADD( ICONTXT, 'G', NB, ONE, X(IX*INCX+1), $ INCX, BETA, Y(IY*INCY+1), INCY ) IX = IX + NB IY = IY + NJUMP 30 CONTINUE END IF * CALL PBZVECADD( ICONTXT, 'G', MIN(NB-KZ,N-IY), ONE, $ X(IX*INCX+1), INCX, BETA, Y(IY*INCY+1), $ INCY ) KZ = 0 40 CONTINUE END IF * 50 CONTINUE * RETURN * * End of PBZTRST1 * END
PBLAS/SRC/PBBLAS/pbztrst1.f
! ! CSvar_Define ! ! Module defining the CRTM CloudScatter module internal ! variable object. ! ! ! CREATION HISTORY: ! Written by: Paul van Delst, 14-Feb-2012 ! [email protected] ! MODULE CSvar_Define ! ----------------- ! Environment setup ! ----------------- ! Module use USE Type_Kinds , ONLY: fp USE Message_Handler , ONLY: SUCCESS, FAILURE, INFORMATION, Display_Message USE Compare_Float_Numbers, ONLY: OPERATOR(.EqualTo.) USE File_Utility , ONLY: File_Open, File_Exists USE Binary_File_Utility , ONLY: Open_Binary_File , & WriteGAtts_Binary_File, & ReadGAtts_Binary_File USE CRTM_Interpolation , ONLY: NPTS , & LPoly_type ! Disable implicit typing IMPLICIT NONE ! ------------ ! Visibilities ! ------------ ! Everything private by default PRIVATE ! Datatypes PUBLIC :: CSvar_type PUBLIC :: CSinterp_type ! Operators PUBLIC :: OPERATOR(==) ! Procedures PUBLIC :: CSvar_Associated PUBLIC :: CSvar_Destroy PUBLIC :: CSvar_Create PUBLIC :: CSvar_Inspect PUBLIC :: CSvar_ValidRelease PUBLIC :: CSvar_Info PUBLIC :: CSvar_DefineVersion PUBLIC :: CSvar_InquireFile PUBLIC :: CSvar_ReadFile PUBLIC :: CSvar_WriteFile ! --------------------- ! Procedure overloading ! --------------------- INTERFACE OPERATOR(==) MODULE PROCEDURE CSvar_Equal END INTERFACE OPERATOR(==) ! ----------------- ! Module parameters ! ----------------- CHARACTER(*), PARAMETER :: MODULE_VERSION_ID = & '$Id: CSvar_Define.f90,v 1.1 2013/04/07 22:56:27 jguo Exp $' ! Release and version INTEGER, PARAMETER :: CSVAR_RELEASE = 1 ! This determines structure and file formats. INTEGER, PARAMETER :: CSVAR_VERSION = 1 ! This is just the default data version. ! Close status for write errors CHARACTER(*), PARAMETER :: WRITE_ERROR_STATUS = 'DELETE' ! Literal constants REAL(fp), PARAMETER :: ZERO = 0.0_fp REAL(fp), PARAMETER :: ONE = 1.0_fp ! String lengths INTEGER, PARAMETER :: ML = 256 ! Message length INTEGER, PARAMETER :: SL = 80 ! String length ! --------------------- ! Structure definitions ! --------------------- ! The interpolation routine structure TYPE :: CSinterp_type ! The interpolating polynomials TYPE(LPoly_type) :: wlp ! Frequency TYPE(LPoly_type) :: xlp ! Effective radius TYPE(LPoly_type) :: ylp ! Temperature ! The LUT interpolation indices INTEGER :: i1, i2 ! Frequency INTEGER :: j1, j2 ! Effective radius INTEGER :: k1, k2 ! Temperature ! The LUT interpolation boundary check LOGICAL :: f_outbound ! Frequency LOGICAL :: r_outbound ! Effective radius LOGICAL :: t_outbound ! Temperature ! The interpolation input REAL(fp) :: f_int ! Frequency REAL(fp) :: r_int ! Effective radius REAL(fp) :: t_int ! Temperature ! The data to be interpolated REAL(fp) :: f(NPTS) ! Frequency REAL(fp) :: r(NPTS) ! Effective radius REAL(fp) :: t(NPTS) ! Temperature END TYPE CSinterp_type ! The internal variable definition to hold information ! between FWD, TL, AD, and K-matrix calls TYPE :: CSvar_type ! Allocation indicator LOGICAL :: Is_Allocated = .FALSE. ! Release and version information INTEGER :: Release = CSVAR_RELEASE INTEGER :: Version = CSVAR_VERSION ! Dimensions INTEGER :: n_Legendre_Terms = 0 ! I1 INTEGER :: n_Phase_Elements = 0 ! I2 INTEGER :: n_Layers = 0 ! I3 INTEGER :: n_Clouds = 0 ! I4 ! The interpolating data TYPE(CSinterp_type), ALLOCATABLE :: csi(:,:) ! I3 x I4 ! The interpolation results REAL(fp), ALLOCATABLE :: ke(:,:) ! I3 x I4 Mass extinction coefficient REAL(fp), ALLOCATABLE :: w(:,:) ! I3 x I4 Single Scatter Albedo REAL(fp), ALLOCATABLE :: g(:,:) ! I3 x I4 Asymmetry factor REAL(fp), ALLOCATABLE :: pcoeff(:,:,:,:) ! 0:I1 x I2 x I3 x I4 Phase coefficients ! The accumulated scattering coefficient REAL(fp), ALLOCATABLE :: total_bs(:) ! I3 Volume scattering coefficient END TYPE CSvar_type CONTAINS !################################################################################ !################################################################################ !## ## !## ## PUBLIC PROCEDURES ## ## !## ## !################################################################################ !################################################################################ ELEMENTAL FUNCTION CSvar_Associated( self ) RESULT( Status ) TYPE(CSvar_type), INTENT(IN) :: self LOGICAL :: Status Status = self%Is_Allocated END FUNCTION CSvar_Associated ELEMENTAL SUBROUTINE CSvar_Destroy( self ) TYPE(CSvar_type), INTENT(OUT) :: self self%Is_Allocated = .FALSE. self%n_Legendre_Terms = 0 self%n_Phase_Elements = 0 self%n_Layers = 0 self%n_Clouds = 0 END SUBROUTINE CSvar_Destroy ELEMENTAL SUBROUTINE CSvar_Create( & self , & ! Output n_Legendre_Terms, & ! Input n_Phase_Elements, & ! Input n_Layers , & ! Input n_Clouds ) ! Input ! Arguments TYPE(CSvar_type), INTENT(OUT) :: self INTEGER , INTENT(IN) :: n_Legendre_Terms INTEGER , INTENT(IN) :: n_Phase_Elements INTEGER , INTENT(IN) :: n_Layers INTEGER , INTENT(IN) :: n_Clouds ! Local variables INTEGER :: alloc_stat ! Check input IF ( n_Legendre_Terms < 1 .OR. & n_Phase_Elements < 1 .OR. & n_Layers < 1 .OR. & n_Clouds < 1 ) RETURN ! Perform the allocation ALLOCATE( self%csi(n_Layers, n_Clouds), & self%ke(n_Layers, n_Clouds), & self%w(n_Layers, n_Clouds), & self%g(n_Layers, n_Clouds), & self%pcoeff(0:n_Legendre_Terms,n_Phase_Elements,n_Layers, n_Clouds), & self%total_bs(n_Layers), & STAT = alloc_stat ) IF ( alloc_stat /= 0 ) RETURN ! Initialise dimensions only! self%n_Legendre_Terms = n_Legendre_Terms self%n_Phase_Elements = n_Phase_Elements self%n_Layers = n_Layers self%n_Clouds = n_Clouds ! Set allocation indicator self%Is_Allocated = .TRUE. END SUBROUTINE CSvar_Create SUBROUTINE CSvar_Inspect( self) TYPE(CSvar_type), INTENT(IN) :: self INTEGER :: i2, i3, i4 WRITE(*,'(1x,"CSvar OBJECT")') ! Release/version info WRITE(*,'(3x,"Release.Version :",1x,i0,".",i0)') self%Release, self%Version ! Dimensions WRITE(*,'(3x,"n_Legendre_Terms :",1x,i0)') self%n_Legendre_Terms WRITE(*,'(3x,"n_Phase_Elements :",1x,i0)') self%n_Phase_Elements WRITE(*,'(3x,"n_Layers :",1x,i0)') self%n_Layers WRITE(*,'(3x,"n_Clouds :",1x,i0)') self%n_Clouds IF ( .NOT. CSvar_Associated(self) ) RETURN ! Data WRITE(*,'(3x,"Mass extinction coefficient (ke) :")') DO i4 = 1, self%n_Clouds WRITE(*,'(5x,"ke Cloud index #",i0)') i4 WRITE(*,'(5(1x,es13.6,:))') self%ke(:,i4) END DO WRITE(*,'(3x,"Single scatter albedo (w) :")') DO i4 = 1, self%n_Clouds WRITE(*,'(5x,"w Cloud index #",i0)') i4 WRITE(*,'(5(1x,es13.6,:))') self%w(:,i4) END DO WRITE(*,'(3x,"Asymmetry factor (g) :")') DO i4 = 1, self%n_Clouds WRITE(*,'(5x,"g Cloud index #",i0)') i4 WRITE(*,'(5(1x,es13.6,:))') self%g(:,i4) END DO WRITE(*,'(3x,"Phase coefficients (pcoeff) :")') DO i4 = 1, self%n_Clouds WRITE(*,'(5x,"pcoeff Cloud index #",i0)') i4 DO i3 = 1, self%n_Layers WRITE(*,'(7x,"pcoeff Layer index #",i0)') i3 DO i2 = 1, self%n_Phase_Elements WRITE(*,'(9x,"pcoeff Phase element index #",i0)') i2 WRITE(*,'(5(1x,es13.6,:))') self%pcoeff(0:,i2,i3,i4) END DO END DO END DO WRITE(*,'(3x,"Volume scattering coefficient (total_bs) :")') WRITE(*,'(5(1x,es13.6,:))') self%total_bs END SUBROUTINE CSvar_Inspect FUNCTION CSvar_ValidRelease( self ) RESULT( IsValid ) ! Arguments TYPE(CSvar_type), INTENT(IN) :: self ! Function result LOGICAL :: IsValid ! Local parameters CHARACTER(*), PARAMETER :: ROUTINE_NAME = 'CSvar_ValidRelease' ! Local variables CHARACTER(ML) :: msg ! Set up IsValid = .TRUE. ! Check release is not too old IF ( self%Release < CSVAR_RELEASE ) THEN IsValid = .FALSE. WRITE( msg,'("An CSvar data update is needed. ", & &"CSvar release is ",i0,". Valid release is ",i0,"." )' ) & self%Release, CSVAR_RELEASE CALL Display_Message( ROUTINE_NAME, msg, INFORMATION ); RETURN END IF ! Check release is not too new IF ( self%Release > CSVAR_RELEASE ) THEN IsValid = .FALSE. WRITE( msg,'("An CSvar software update is needed. ", & &"CSvar release is ",i0,". Valid release is ",i0,"." )' ) & self%Release, CSVAR_RELEASE CALL Display_Message( ROUTINE_NAME, msg, INFORMATION ); RETURN END IF END FUNCTION CSvar_ValidRelease SUBROUTINE CSvar_Info( self, Info ) ! Arguments TYPE(CSvar_type), INTENT(IN) :: self CHARACTER(*), INTENT(OUT) :: Info ! Parameters INTEGER, PARAMETER :: CARRIAGE_RETURN = 13 INTEGER, PARAMETER :: LINEFEED = 10 ! Local variables CHARACTER(2000) :: Long_String ! Write the required data to the local string WRITE( Long_String, & '(a,1x,"CSvar RELEASE.VERSION: ",i2,".",i2.2,a,3x, & &"N_LEGENDRE_TERMS=",i0,2x,& &"N_PHASE_ELEMENTS=",i0,2x,& &"N_LAYERS=",i0,2x,& &"N_CLOUDS=",i0 )' ) & ACHAR(CARRIAGE_RETURN)//ACHAR(LINEFEED), & self%Release, self%Version, & ACHAR(CARRIAGE_RETURN)//ACHAR(LINEFEED), & self%n_Legendre_Terms, & self%n_Phase_Elements, & self%n_Layers , & self%n_Clouds ! Trim the output based on the ! dummy argument string length Info = Long_String(1:MIN(LEN(Info), LEN_TRIM(Long_String))) END SUBROUTINE CSvar_Info SUBROUTINE CSvar_DefineVersion( Id ) CHARACTER(*), INTENT(OUT) :: Id Id = MODULE_VERSION_ID END SUBROUTINE CSvar_DefineVersion FUNCTION CSvar_InquireFile( & Filename , & ! Input n_Legendre_Terms, & ! Optional output n_Phase_Elements, & ! Optional output n_Layers , & ! Optional output n_Clouds , & ! Optional output Release , & ! Optional output Version , & ! Optional output Title , & ! Optional output History , & ! Optional output Comment ) & ! Optional output RESULT( err_stat ) ! Arguments CHARACTER(*), INTENT(IN) :: Filename INTEGER , OPTIONAL, INTENT(OUT) :: n_Legendre_Terms INTEGER , OPTIONAL, INTENT(OUT) :: n_Phase_Elements INTEGER , OPTIONAL, INTENT(OUT) :: n_Layers INTEGER , OPTIONAL, INTENT(OUT) :: n_Clouds INTEGER , OPTIONAL, INTENT(OUT) :: Release INTEGER , OPTIONAL, INTENT(OUT) :: Version CHARACTER(*), OPTIONAL, INTENT(OUT) :: Title CHARACTER(*), OPTIONAL, INTENT(OUT) :: History CHARACTER(*), OPTIONAL, INTENT(OUT) :: Comment ! Function result INTEGER :: err_stat ! Function parameters CHARACTER(*), PARAMETER :: ROUTINE_NAME = 'CSvar_InquireFile' ! Function variables CHARACTER(ML) :: msg CHARACTER(ML) :: io_msg INTEGER :: io_stat INTEGER :: fid TYPE(CSvar_type) :: CSvar ! Setup err_stat = SUCCESS ! ...Check that the file exists IF ( .NOT. File_Exists( Filename ) ) THEN msg = 'File '//TRIM(Filename)//' not found.' CALL Inquire_Cleanup(); RETURN END IF ! Open the file err_stat = Open_Binary_File( Filename, fid ) IF ( err_stat /= SUCCESS ) THEN msg = 'Error opening '//TRIM(Filename) CALL Inquire_Cleanup(); RETURN END IF ! Read the release and version READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%Release, & CSvar%Version IF ( io_stat /= 0 ) THEN msg = 'Error reading Release/Version - '//TRIM(io_msg) CALL Inquire_Cleanup(); RETURN END IF IF ( .NOT. CSvar_ValidRelease( CSvar ) ) THEN msg = 'CSvar Release check failed.' CALL Inquire_Cleanup(); RETURN END IF ! Read the dimensions READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%n_Legendre_Terms, & CSvar%n_Phase_Elements, & CSvar%n_Layers , & CSvar%n_Clouds IF ( io_stat /= 0 ) THEN msg = 'Error reading dimension values from '//TRIM(Filename)//' - '//TRIM(io_msg) CALL Inquire_Cleanup(); RETURN END IF ! Read the global attributes err_stat = ReadGAtts_Binary_File( & fid, & Title = Title , & History = History, & Comment = Comment ) IF ( err_stat /= SUCCESS ) THEN msg = 'Error reading global attributes' CALL Inquire_Cleanup(); RETURN END IF ! Close the file CLOSE( fid, IOSTAT=io_stat, IOMSG=io_msg ) IF ( io_stat /= 0 ) THEN msg = 'Error closing '//TRIM(Filename)//' - '//TRIM(io_msg) CALL Inquire_Cleanup(); RETURN END IF ! Assign the return arguments IF ( PRESENT(n_Legendre_Terms) ) n_Legendre_Terms = CSvar%n_Legendre_Terms IF ( PRESENT(n_Phase_Elements) ) n_Phase_Elements = CSvar%n_Phase_Elements IF ( PRESENT(n_Layers ) ) n_Layers = CSvar%n_Layers IF ( PRESENT(n_Clouds ) ) n_Clouds = CSvar%n_Clouds IF ( PRESENT(Release ) ) Release = CSvar%Release IF ( PRESENT(Version ) ) Version = CSvar%Version CONTAINS SUBROUTINE Inquire_CleanUp() ! Close file if necessary IF ( File_Open(fid) ) THEN CLOSE( fid, IOSTAT=io_stat, IOMSG=io_msg ) IF ( io_stat /= 0 ) & msg = TRIM(msg)//'; Error closing input file during error cleanup - '//TRIM(io_msg) END IF ! Set error status and print error message err_stat = FAILURE CALL Display_Message( ROUTINE_NAME, msg, err_stat ) END SUBROUTINE Inquire_CleanUp END FUNCTION CSvar_InquireFile FUNCTION CSvar_ReadFile( & CSvar , & ! Output Filename , & ! Input No_Close , & ! Optional input Quiet , & ! Optional input Title , & ! Optional output History , & ! Optional output Comment , & ! Optional output Debug ) & ! Optional input (Debug output control) RESULT( err_stat ) ! Arguments TYPE(CSvar_type), INTENT(OUT) :: CSvar CHARACTER(*), INTENT(IN) :: Filename LOGICAL, OPTIONAL, INTENT(IN) :: No_Close LOGICAL, OPTIONAL, INTENT(IN) :: Quiet CHARACTER(*), OPTIONAL, INTENT(OUT) :: Title CHARACTER(*), OPTIONAL, INTENT(OUT) :: History CHARACTER(*), OPTIONAL, INTENT(OUT) :: Comment LOGICAL, OPTIONAL, INTENT(IN) :: Debug ! Function result INTEGER :: err_stat ! Function parameters CHARACTER(*), PARAMETER :: ROUTINE_NAME = 'CSvar_ReadFile' ! Function variables CHARACTER(ML) :: msg CHARACTER(ML) :: io_msg LOGICAL :: close_file LOGICAL :: noisy INTEGER :: io_stat INTEGER :: fid TYPE(CSvar_type) :: dummy ! Setup err_stat = SUCCESS ! ...Check No_Close argument close_file = .TRUE. IF ( PRESENT(No_Close) ) close_file = .NOT. No_Close ! ...Check Quiet argument noisy = .TRUE. IF ( PRESENT(Quiet) ) noisy = .NOT. Quiet ! ...Override Quiet settings if debug set. IF ( PRESENT(Debug) ) THEN IF ( Debug ) noisy = .TRUE. END IF ! Check if the file is open. IF ( File_Open( Filename ) ) THEN ! ...Inquire for the logical unit number INQUIRE( FILE=Filename, NUMBER=fid ) ! ...Ensure it's valid IF ( fid < 0 ) THEN msg = 'Error inquiring '//TRIM(Filename)//' for its FileID' CALL Read_CleanUp(); RETURN END IF ELSE ! ...Open the file if it exists IF ( File_Exists( Filename ) ) THEN err_stat = Open_Binary_File( Filename, fid ) IF ( err_Stat /= SUCCESS ) THEN msg = 'Error opening '//TRIM(Filename) CALL Read_CleanUp(); RETURN END IF ELSE msg = 'File '//TRIM(Filename)//' not found.' CALL Read_CleanUp(); RETURN END IF END IF ! Read and check the release and version READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) & dummy%Release, & dummy%Version IF ( io_stat /= 0 ) THEN msg = 'Error reading Release/Version - '//TRIM(io_msg) CALL Read_Cleanup(); RETURN END IF IF ( .NOT. CSvar_ValidRelease( dummy ) ) THEN msg = 'CSvar Release check failed.' CALL Read_Cleanup(); RETURN END IF ! Read the dimensions READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) & dummy%n_Legendre_Terms, & dummy%n_Phase_Elements, & dummy%n_Layers , & dummy%n_Clouds IF ( io_stat /= 0 ) THEN msg = 'Error reading data dimensions - '//TRIM(io_msg) CALL Read_Cleanup(); RETURN END IF ! ...Allocate the object CALL CSvar_Create( & CSvar , & dummy%n_Legendre_Terms, & dummy%n_Phase_Elements, & dummy%n_Layers , & dummy%n_Clouds ) IF ( .NOT. CSvar_Associated( CSvar ) ) THEN msg = 'CSvar object allocation failed.' CALL Read_Cleanup(); RETURN END IF ! ...Explicitly assign the version number CSvar%Version = dummy%Version ! Read the global attributes err_stat = ReadGAtts_Binary_File( & fid, & Title = Title , & History = History, & Comment = Comment ) IF ( err_stat /= SUCCESS ) THEN msg = 'Error reading global attributes' CALL Read_Cleanup(); RETURN END IF ! Read the data ! ...Mass extinction coefficient READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%ke IF ( io_stat /= 0 ) THEN msg = 'Error reading mass extinction coefficient - '//TRIM(io_msg) CALL Read_Cleanup(); RETURN END IF ! ...Single scatter albedo READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%w IF ( io_stat /= 0 ) THEN msg = 'Error reading single scatter albedo - '//TRIM(io_msg) CALL Read_Cleanup(); RETURN END IF ! ...Asymmetry factor READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%g IF ( io_stat /= 0 ) THEN msg = 'Error reading asymmetry factor - '//TRIM(io_msg) CALL Read_Cleanup(); RETURN END IF ! ...Phase coefficients READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%pcoeff IF ( io_stat /= 0 ) THEN msg = 'Error reading phase coefficients - '//TRIM(io_msg) CALL Read_Cleanup(); RETURN END IF ! ...Total volume scattering coefficient READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%total_bs IF ( io_stat /= 0 ) THEN msg = 'Error reading total volume scattering coefficient - '//TRIM(io_msg) CALL Read_Cleanup(); RETURN END IF ! Close the file IF ( close_file ) THEN CLOSE( fid, IOSTAT=io_stat, IOMSG=io_msg ) IF ( io_stat /= 0 ) THEN msg = 'Error closing '//TRIM(Filename)//' - '//TRIM(io_msg) CALL Read_Cleanup(); RETURN END IF END IF ! Output an info message IF ( noisy ) THEN CALL CSvar_Info( CSvar, msg ) CALL Display_Message( ROUTINE_NAME, 'FILE: '//TRIM(Filename)//'; '//TRIM(msg), INFORMATION ) END IF CONTAINS SUBROUTINE Read_CleanUp() IF ( File_Open(Filename) ) THEN CLOSE( fid, IOSTAT=io_stat, IOMSG=io_msg ) IF ( io_stat /= 0 ) & msg = TRIM(msg)//'; Error closing input file during error cleanup - '//TRIM(io_msg) END IF CALL CSvar_Destroy( CSvar ) err_stat = FAILURE CALL Display_Message( ROUTINE_NAME, msg, err_stat ) END SUBROUTINE Read_CleanUp END FUNCTION CSvar_ReadFile FUNCTION CSvar_WriteFile( & CSvar , & ! Input Filename , & ! Input No_Close , & ! Optional input Quiet , & ! Optional input Title , & ! Optional input History , & ! Optional input Comment , & ! Optional input Debug ) & ! Optional input (Debug output control) RESULT( err_stat ) ! Arguments TYPE(CSvar_type), INTENT(IN) :: CSvar CHARACTER(*), INTENT(IN) :: Filename LOGICAL, OPTIONAL, INTENT(IN) :: No_Close LOGICAL, OPTIONAL, INTENT(IN) :: Quiet CHARACTER(*), OPTIONAL, INTENT(IN) :: Title CHARACTER(*), OPTIONAL, INTENT(IN) :: History CHARACTER(*), OPTIONAL, INTENT(IN) :: Comment LOGICAL, OPTIONAL, INTENT(IN) :: Debug ! Function result INTEGER :: err_stat ! Function parameters CHARACTER(*), PARAMETER :: ROUTINE_NAME = 'CSvar_WriteFile' ! Function variables CHARACTER(ML) :: msg CHARACTER(ML) :: io_msg LOGICAL :: close_file LOGICAL :: noisy INTEGER :: io_stat INTEGER :: fid ! Setup err_stat = SUCCESS ! ...Check No_Close argument close_file = .TRUE. IF ( PRESENT(No_Close) ) close_file = .NOT. No_Close ! ...Check Quiet argument noisy = .TRUE. IF ( PRESENT(Quiet) ) noisy = .NOT. Quiet ! ...Override Quiet settings if debug set. IF ( PRESENT(Debug) ) THEN IF ( Debug ) noisy = .TRUE. END IF ! ...Check there is data to write IF ( .NOT. CSvar_Associated( CSvar ) ) THEN msg = 'CSvar object is empty.' CALL Write_Cleanup(); RETURN END IF ! Check if the file is open. IF ( File_Open( FileName ) ) THEN ! ...Inquire for the logical unit number INQUIRE( FILE=Filename, NUMBER=fid ) ! ...Ensure it's valid IF ( fid < 0 ) THEN msg = 'Error inquiring '//TRIM(Filename)//' for its FileID' CALL Write_CleanUp(); RETURN END IF ELSE ! ...Open the file for output err_stat = Open_Binary_File( Filename, fid, For_Output=.TRUE. ) IF ( err_Stat /= SUCCESS ) THEN msg = 'Error opening '//TRIM(Filename) CALL Write_CleanUp(); RETURN END IF END IF ! Write the release and version WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%Release, & CSvar%Version IF ( io_stat /= 0 ) THEN msg = 'Error writing Release/Version - '//TRIM(io_msg) CALL Write_Cleanup(); RETURN END IF ! Write the dimensions WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%n_Legendre_Terms, & CSvar%n_Phase_Elements, & CSvar%n_Layers , & CSvar%n_Clouds IF ( io_stat /= 0 ) THEN msg = 'Error writing data dimensions - '//TRIM(io_msg) CALL Write_Cleanup(); RETURN END IF ! Write the global attributes err_stat = WriteGAtts_Binary_File( & fid, & Write_Module = MODULE_VERSION_ID, & Title = Title , & History = History, & Comment = Comment ) IF ( err_stat /= SUCCESS ) THEN msg = 'Error writing global attributes' CALL Write_Cleanup(); RETURN END IF ! Write the data ! ...Mass extinction coefficient WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%ke IF ( io_stat /= 0 ) THEN msg = 'Error writing mass extinction coefficient - '//TRIM(io_msg) CALL Write_Cleanup(); RETURN END IF ! ...Single scatter albedo WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%w IF ( io_stat /= 0 ) THEN msg = 'Error writing single scatter albedo - '//TRIM(io_msg) CALL Write_Cleanup(); RETURN END IF ! ...Asymmetry factor WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%g IF ( io_stat /= 0 ) THEN msg = 'Error writing asymmetry factor - '//TRIM(io_msg) CALL Write_Cleanup(); RETURN END IF ! ...Phase coefficients WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%pcoeff IF ( io_stat /= 0 ) THEN msg = 'Error writing phase coefficients - '//TRIM(io_msg) CALL Write_Cleanup(); RETURN END IF ! ...Total volume scattering coefficient WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) & CSvar%total_bs IF ( io_stat /= 0 ) THEN msg = 'Error writing total volume scattering coefficient - '//TRIM(io_msg) CALL Write_Cleanup(); RETURN END IF ! Close the file IF ( close_file ) THEN CLOSE( fid, IOSTAT=io_stat, IOMSG=io_msg ) IF ( io_stat /= 0 ) THEN msg = 'Error closing '//TRIM(Filename)//' - '//TRIM(io_msg) CALL Write_Cleanup(); RETURN END IF END IF ! Output an info message IF ( noisy ) THEN CALL CSvar_Info( CSvar, msg ) CALL Display_Message( ROUTINE_NAME, 'FILE: '//TRIM(Filename)//'; '//TRIM(msg), INFORMATION ) END IF CONTAINS SUBROUTINE Write_Cleanup() IF ( File_Open(Filename) ) THEN CLOSE( fid, IOSTAT=io_stat, IOMSG=io_msg ) IF ( io_stat /= 0 ) & msg = TRIM(msg)//'; Error closing output file during error cleanup - '//TRIM(io_msg) END IF err_stat = FAILURE CALL Display_Message( ROUTINE_NAME, msg, err_stat ) END SUBROUTINE Write_Cleanup END FUNCTION CSvar_WriteFile !################################################################################ !################################################################################ !## ## !## ## PRIVATE PROCEDURES ## ## !## ## !################################################################################ !################################################################################ ELEMENTAL FUNCTION CSvar_Equal( x, y ) RESULT( is_equal ) TYPE(CSvar_type), INTENT(IN) :: x, y LOGICAL :: is_equal ! Set up is_equal = .FALSE. ! Check the object association status IF ( (.NOT. CSvar_Associated(x)) .OR. & (.NOT. CSvar_Associated(y)) ) RETURN ! Check contents ! ...Release/version info IF ( (x%Release /= y%Release) .OR. & (x%Version /= y%Version) ) RETURN ! ...Dimensions IF ( (x%n_Legendre_Terms /= y%n_Legendre_Terms ) .OR. & (x%n_Phase_Elements /= y%n_Phase_Elements ) .OR. & (x%n_Layers /= y%n_Layers ) .OR. & (x%n_Clouds /= y%n_Clouds ) ) RETURN ! ...Arrays IF ( ALL(x%ke .EqualTo. y%ke ) .AND. & ALL(x%w .EqualTo. y%w ) .AND. & ALL(x%g .EqualTo. y%g ) .AND. & ALL(x%pcoeff .EqualTo. y%pcoeff ) .AND. & ALL(x%total_bs .EqualTo. y%total_bs ) ) & is_equal = .TRUE. END FUNCTION CSvar_Equal END MODULE CSvar_Define
src/Components/rtms/crtm/CSvar_Define.f90
!======================================================================! subroutine UserProbe1D_pipe(grid) !----------------------------------------------------------------------! ! Reads the "pipe_rad.1D" file created by yourself and averages the ! ! results in the homogeneous azimutal direction and axial direction. ! ! The values of Umean, Vmean, Wmean, uu, vv, ww, uv, uw and vw are ! ! writen into file "pipe_mean.dat" and "pipe_mean_plus.dat". ! !----------------------------------------------------------------------! use all_mod use allp_mod use les_mod use pro_mod use par_mod use rans_mod !----------------------------------------------------------------------! implicit none !-----------------------------[Arguments]------------------------------! real :: y(-NbC:NC) real :: Rad_2, Ufric !------------------------------[Calling]-------------------------------! interface logical function Approx(A,B,tol) real :: A,B real, optional :: tol end function Approx end interface !-------------------------------[Locals]-------------------------------! integer :: Nprob, pl, c, i, count character :: namCoo*80, namPro*80, answer*80 real,allocatable :: z_p(:), Ump(:), Vmp(:), Wmp(:), & uup(:), vvp(:), wwp(:), & uvp(:), uwp(:), vwp(:), & Tmp(:), TTp(:), & uTp(:), vTp(:), wTp(:), & Ksgsp(:), & var_1(:), var_2(:), var_3(:), Rad_1(:), Rad_mp(:) integer,allocatable :: Np(:), Ncount(:) real :: R, Urad_mean, Utan_mean, dummy !======================================================================! namPro = name !>>>>>>>>>>>>>>>>>>>>>>! ! read 1D file ! !>>>>>>>>>>>>>>>>>>>>>>! namCoo = name namCoo(len_trim(name)+1:len_trim(name)+3) = '.1D' write(6, *) '# Now reading the file:', namCoo open(9, file=namCoo) !---- write the number of probes read(9,*) Nprob allocate(z_p(Nprob*2)) !---- write the probe coordinates out do pl=1,Nprob read(9,*) dummy, z_p(pl) end do close(9) call CalcShear(U % n, V % n, W % n, Shear) allocate(Np(Nprob)); Np=0 allocate(Ump(Nprob)); Ump=0.0 allocate(Vmp(Nprob)); Vmp=0.0 allocate(Wmp(Nprob)); Wmp=0.0 allocate(uup(Nprob)); uup=0.0 allocate(vvp(Nprob)); vvp=0.0 allocate(wwp(Nprob)); wwp=0.0 allocate(uvp(Nprob)); uvp=0.0 allocate(uwp(Nprob)); uwp=0.0 allocate(vwp(Nprob)); vwp=0.0 allocate(Ksgsp(Nprob)); Ksgsp=0.0 allocate(Rad_mp(Nprob)); Rad_mp=0.0 allocate(var_1(Nprob)); var_1=0.0 allocate(Rad_1(Nprob)); Rad_1=0.0 allocate(Ncount(Nprob)); Ncount=0 count = 0 if(HOT==YES) then allocate(Tmp(Nprob)); Tmp=0.0 allocate(TTp(Nprob)); TTp=0.0 allocate(uTp(Nprob)); uTp=0.0 allocate(vTp(Nprob)); vTp=0.0 allocate(wTp(Nprob)); wTp=0.0 end if !+++++++++++++++++++++++++++++! ! average the results ! !+++++++++++++++++++++++++++++! do i = 1, Nprob Rad_1(i) = 1.0 - abs(z_p(i)) end do do i = 2, Nprob do c=1, NC Rad_2 = WallDs(c) if(Rad_2 < Rad_1(i-1) .and. Rad_2 > Rad_1(i)) then R = (xc(c)*xc(c) + yc(c)*yc(c))**0.5 Urad_mean = (U % n(c) * xc(c) / R + V % n(c) * yc(c) / R) Utan_mean = (-U % n(c) * yc(c) / R + V % n(c) * xc(c) / R) Ump(i) = Ump(i) + U % n(c) Vmp(i) = Vmp(i) + V % n(c) Wmp(i) = Wmp(i) + W % n(c) if(SIMULA==K_EPS_VV) then uup(i) = uup(i) + Kin % n(c) vvp(i) = vvp(i) + Eps % n(c) wwp(i) = wwp(i) + v_2 % n(c) uvp(i) = uvp(i) + f22 % n(c) uwp(i) = uwp(i) + 0.0 else if(SIMULA==ZETA) then uup(i) = uup(i) + Kin % n(c) vvp(i) = vvp(i) + Eps % n(c) wwp(i) = wwp(i) + v_2 % n(c) uvp(i) = uvp(i) + f22 % n(c) uwp(i) = uwp(i) + 0.0 else if(SIMULA==K_EPS) then uup(i) = uup(i) + Kin % n(c) vvp(i) = vvp(i) + Eps % n(c) wwp(i) = wwp(i) + 0.0 uvp(i) = uvp(i) + 0.0 uwp(i) = uwp(i) + 0.0 else if(SIMULA==LES.or.SIMULA==DES_SPA) then uup(i) = uup(i) + (uu % mean(c)- Urad_mean * Urad_mean) vvp(i) = vvp(i) + (vv % mean(c)- Utan_mean * Utan_mean) wwp(i) = wwp(i) + (ww % mean(c)- W % mean(c) * W % mean(c)) uvp(i) = uvp(i) + (uv % mean(c)- Urad_mean * Utan_mean ) uwp(i) = uwp(i) + (uw % mean(c)- Urad_mean * W % mean(c)) vwp(i) = uwp(i) + (vw % mean(c)- Utan_mean * W % mean(c)) end if if(HOT==YES) then Tmp(i) = Tmp(i) + T % mean(c) if(SIMULA == LES.or.SIMULA == DES_SPA) then TTp(i) = TTp(i) + (TT % mean(c) - T % mean(c) * T % mean(c)) uTp(i) = uTp(i) + (uT % mean(c) - u % mean(c) * T % mean(c)) vTp(i) = vTp(i) + (vT % mean(c) - v % mean(c) * T % mean(c)) wTp(i) = wTp(i) + (wT % mean(c) - w % mean(c) * T % mean(c)) end if end if Rad_mp(i) = Rad_mp(i) + WallDs(c) !(xc(c)*xc(c) + yc(c)*yc(c))**0.5 Ncount(i) = Ncount(i) + 1 end if end do end do !---- average over all processors do pl=2, Nprob call IGlSum(Ncount(pl)) call GloSum(Ump(pl)) call GloSum(Vmp(pl)) call GloSum(Wmp(pl)) call GloSum(Rad_mp(pl)) call GloSum(uup(pl)) call GloSum(vvp(pl)) call GloSum(wwp(pl)) call GloSum(uvp(pl)) call GloSum(uwp(pl)) call GloSum(vwp(pl)) call GloSum(var_1(pl)) count = count + Ncount(pl) if(HOT==YES) then call GloSum(Tmp(pl)) call GloSum(TTp(pl)) call GloSum(uTp(pl)) call GloSum(vTp(pl)) call GloSum(wTp(pl)) end if end do open(3,file='pipe_mean.dat') do i = 2, Nprob if(Ncount(i) /= 0) then Ump(i) = Ump(i)/Ncount(i) Vmp(i) = Vmp(i)/Ncount(i) Wmp(i) = Wmp(i)/Ncount(i) Ump(i) = Ump(i)/Ncount(i) Vmp(i) = Vmp(i)/Ncount(i) uup(i) = uup(i)/Ncount(i) vvp(i) = vvp(i)/Ncount(i) wwp(i) = wwp(i)/Ncount(i) uvp(i) = uvp(i)/Ncount(i) uwp(i) = uwp(i)/Ncount(i) var_1(i) = var_1(i)/Ncount(i) Rad_mp(i) = Rad_mp(i)/Ncount(i) end if end do Ufric = (VISc*abs(Wmp(Nprob))/(Rad_mp(Nprob)))**0.5 10 continue open(3,file='pipe_mean.dat') write(3,'(A1,2(A10, F13.5))') '#', 'Utau = ', Ufric, 'Re_tau = ', Ufric/VISc if(SIMULA == LES.or.SIMULA == DES_SPA) then write(3,'(A1,2X,A80)') '#', '1:Xrad, 2:U, 3:V, 4:W, 5:uu, 6:vv, 7:ww, 8:uv, 9:uw, 10:vw, 11:Kin' do i = Nprob, 2, -1 if(Ncount(i) /= 0) then write(3,'(11E15.7)') Rad_mp(i), abs(Ump(i)), abs(Vmp(i)), abs(Wmp(i)), & uup(i), vvp(i), wwp(i), uvp(i), uwp(i), & vwp(i), (uup(i) + vvp(i) + wwp(i)) end if end do else if(SIMULA == ZETA) then write(3,'(A1,1X,A60)') '#', '1:Xrad, 2:U, 3:V, 4:W, 5:Kin, 6:Eps, 7:zeta, 8:f' do i = Nprob, 2, -1 if(Ncount(i) /= 0) then write(3,'(9E15.7)') Rad_mp(i), abs(Ump(i)), abs(Vmp(i)), abs(Wmp(i)), & uup(i), vvp(i), wwp(i), uvp(i), uwp(i) end if end do end if close(3) open(3,file='pipe_mean_plus.dat') write(3,'(A1,2(A10, F13.5))') '#', 'Utau = ', Ufric, 'Re_tau = ', Ufric/VISc if(SIMULA == LES.or.SIMULA == DES_SPA) then write(3,'(A1,2X,A80)') '#', '1:Xrad+, 2:U+, 3:V+, 4:W+, 5:uu+, 6:vv+, 7:ww+, 8:uv+, 9:uw+, 10:vw+, 11:Kin+' do i = Nprob, 2, -1 if(Ncount(i) /= 0) then write(3,'(11E15.7)') Rad_mp(i)*Ufric/VISc, abs(Ump(i))/Ufric, abs(Vmp(i))/Ufric, abs(Wmp(i))/Ufric, & uup(i)/Ufric**2.0, vvp(i)/Ufric**2.0, wwp(i)/Ufric**2.0, uvp(i)/Ufric**2.0, uwp(i)/Ufric**2.0, & vwp(i)/Ufric**2.0, (uup(i) + vvp(i) + wwp(i))/Ufric**2.0 end if end do else if(SIMULA == ZETA) then write(3,'(A1,1X,A60)') '#', '1:Xrad+, 2:U+, 3:V+, 4:W+, 5:Kin+, 6:Eps+, 7:zeta+, 8:f+' do i = Nprob, 2, -1 if(Ncount(i) /= 0) then write(3,'(9E15.7)') (Rad_mp(i))*Ufric/VISc, abs(Ump(i))/Ufric, abs(Vmp(i))/Ufric, abs(Wmp(i))/Ufric, & uup(i)/Ufric**2.0, vvp(i)*VISc/Ufric**4.0, wwp(i), uvp(i)*VISc/Ufric**2.0, uwp(i)/Ufric**2.0 end if end do end if close(3) deallocate(Np) deallocate(z_p) deallocate(Ump) deallocate(Vmp) deallocate(Wmp) deallocate(uup) deallocate(vvp) deallocate(wwp) deallocate(uvp) deallocate(uwp) deallocate(vwp) deallocate(var_1) deallocate(Ksgsp) if(HOT==YES) then deallocate(Tmp) deallocate(TTp) deallocate(uTp) deallocate(vTp) deallocate(wTp) end if end subroutine UserProbe1D_pipe
Sources/Process/User/Unused/UserProbe1D_pipe.f90
c { dg-do run } program cabs_1 complex z0 real r0 complex(kind=8) z1 real(kind=8) r1 z0 = cmplx(3.,4.) r0 = cabs(z0) if (r0 .ne. 5.) STOP 1 z1 = dcmplx(3.d0,4.d0) r1 = zabs(z1) if (r1 .ne. 5.d0) STOP 2 end
validation_tests/llvm/f18/gfortran.dg/g77/cabs.f
Lamar Heystek was a member of the Davis City Council, a former columnist for The California Aggie, and a former employee of Safeway. A graduate of UC Daviss Linguistics program, his political life has centered on voicing student concerns and preserving Daviss Essence of Davis unique qualities. He is often seen as an ally to Sue Greenwald on council, but that is mainly because of his cows slowgrowth stance. Lamar is Dutch and proud of it, has a twin brother (who is on the board of education in his own respective location), a sister in the veterans military, and a father who is at least as funny as he is. Lamar is also a monthly contributor to The Peoples Vanguard of Davis. Is this still true? See also Heysteks Pothole Project. Davis City Council Campaigns Petition to Urge Lamar to Run for ReElection in 2010 In October 2010, Lamar announced that he would not be running for reelection to the 2010 City Council Election City Council in 2010. Some of his many fans started a petition to urge him to reconsider. The letter stated that Lamar has demonstrated leadership, honesty and integrity on the key issues that face the city of Davis, that he has been a voice of civility, maturity, reason, and passion in the face of great obstacles, and that the city cannot afford to now lose Lamars experience. The petition is available http://www.draftlamar.com here. However, on March 12, 2010 at 4:30 PM 30 minutes before the filing deadline Lamar announced that his October decision would stand and that he would not run for reelection. 2004 and 2006 Campaigns Lamar first pursued a seat on the Davis City Council as a student in 2004. He finished seventh among eight candidates, earning 4,539 votes, or about http://www.yoloelections.org/sites/elections/archives/20040302/davis_council.html 10 percent of the vote. On Wednesday, January 25, 2006, Lamar announced that he would once again run for city council. The California Aggie ran an http://www.californiaaggie.com/media/paper981/news/2006/01/26/CityNews/UcdAlumnus.Launches.City.Council.Bid1505861.shtml article on it the next day. His platform was based on: growth management neighborhood preservation fiscal restraint environmental protection policecommunity trust His campaign slogan was Its a Brand New Day! Image(lamarswear.jpg, left, Lamar being sworn into his new position. http://media.collegepublisher.com/media/paper981/stills/9m33r8g6.jpg Source.)On June 6th, 2006, Lamar Heystek was elected to the Davis City Council, with June 2006 Primary Election/Results 24.1% of the vote, in a major victory for the student vote, as he presented himself as a councilmember that would pay attention to the needs of the students, who are a significant slice of the Davis population. Although detailed statistics are not available to determine what proportion of Heysteks supporters were students, the behavior of the election returns supports this assertion. Students typically do not vote by absentee, whereas establish residents of Davis often do. Early election returns showed Lamar clearly behind several other candidates due to the absentee votes which were already counted. As the night progressed and more votes were counted, Lamar gained on all his competitors. He garnered more ElectionDay inperson votes than all of the other candidates, finishing with the second highest number of total votes, winning him the seat (He almost passed the incumbent Ruth Asmundson). This suggests that he gained a greater proportion of the student vote than the other candidates. Safeway Career A head clerk at Safeway with a career spanning approximately eight years, Lamar decided to give up his job so he could continue to pursue local politics in 2006. However, Lamar did not make the decision recklessly, nor did he make it independently. The market had offered $20,000 to all of their longtime employees (including Lamar) to quit to make way for newer, lesspaid ones. Because of the strange nature of the $20,000 offer, and because few knew that the offer was made to all longtime employees, some people thought that Safeway was trying to silence his columns making fun of working at the market. The job had provided Lamar with four years worth of fodder for his weekly column in The California Aggie, so by quitting he would be dispensing of this humor source, not to mention ridding himself of an income. In a simultaneously prudent and clever move, Lamar asked his column readers to weigh in and decide for him: quit or not quit. (http://www.californiaaggie.com/media/paper981/news/2006/02/21/Opinion/Should.I.Quit.Safeway1621661.shtml?norewrite&sourcedomainwww.californiaaggie.com Should I quit Safeway?) A week later, Lamar announced that he would be leaving Safeway. (http://www.californiaaggie.com/media/paper981/news/2006/02/28/Opinion/ThePeople.Have.Spoken1640745.shtml?norewrite&sourcedomainwww.californiaaggie.com the people have spoken) At his retirement party held at Woodstocks, Elise Kane and Rob Roy, in a joint effort, presented Lamar with a death certificate for his career (see image at left), a bouquet of tampons in a toiletpaper roll vase, and a Safeway womens restroom sign meant to be worn as a medallion. Needless to say, Lamar was thrilled. Career with the California Aggie The Born Loser Column Image(lamar.jpg, Lamars famed California Aggie column mug, right, 300, noborder, thumbnail)The Born Loser was the name of Lamars weekly humor column in The California Aggie, from Fall 2002Spring 2006, spanning four years. Shortly after he started the column, column titles were stripped from most of the papers columns, so it ran without the tagline. Nevertheless, during funny antics about sleeping in safeway bathrooms, speaking dutch, and http://media.www.californiaaggie.com/media/storage/paper981/news/2004/11/09/Features/A.Stream.Of.Unconsciousness1318696.shtml peeing on an electric fence, Lamar managed to fit his tagline into the body of the column from time to time. The column ran on Tuesdays. The Born Loser character always seemed to find the universe, both animate and inanimate, getting the better of himself. No matter what he could do, incalculably unlikely calamities befell him, including getting stuck between shelves while looking for dairy products for a cute girl. He also has had the unlikely misfortune to have died several times, you can read about one of them http://www.californiaaggie.com/media/paper981/news/2005/06/07/Features/TheBorn.Loser.Dies1320825.shtml here. Death notwithstanding, Lamars column returned the following year. Image(lamar sleeping.jpg, Lamar taking a snooze on a couch at The California Aggie office., left, 300, thumbnail) Lamar always kept his column personality distinct from his public persona, especially as he got into Davis politics, but if you walk up to him and quote one of your favorite lines of his, he is likely to bowl over laughing. There is a Facebook group called http://ucdavis.facebook.com/group.php?gid2200419888 People Who Laugh Out Loud to Lamar Heystek Articles. Lamargate He has the unique distinction of having a major controversy named after him Lamargate (although he was not actually involved in the scandal). As an Aggie columnist, he wasnt allowed to have an opinion about ASUCD politics, to the point that they wouldnt actually allow him to use the word Lamargate in his column. Once elections were over, in a http://www.californiaaggie.com/media/paper981/news/2005/03/01/Features/WinOne.For.The.Loser1319754.shtml later column he did get to use the word. Lamars Stats This section needs some more work Lamar was a linguistics grad student at UC Davis and, as aforementioned, a columnist for the California Aggie. He ran for a position on the Davis City Council in 2004. Lamar remains active in Davis Politics city politics. He is currently (or was recently): Commissionerdesignate, City of Davis Finance and Budget Commission, 2006 Commissioner, City of Davis Open Space Commission Commissioner, City of Davis Recreation and Park Commission, 20042006 Alternative Recreation programs subcommittee, 20052006 Walnut and Manor pools subcommittee, 2004 Member, International House Board of Directors, 20042006 Mimi Sen Memorial Committee, 20052006 Lecturer, UC Davis Department of Linguistics, 20052006 Shop Steward, UFCW Local 588, Safeway #120515, 20012006 Member, UFCW Active Ballot Club (ABC) Member, AFLCIO Committee on Political Education (COPE) Senator, Associated Students of University of California, Davis (ASUCD), 19989 Member, steering committee for “No on Measure X” Member, KDRT working group. Member, Davis Citizens for Representation a proChoice Voting organization. Councilor, 2006 City Council Election City Council, 2006 20050721 12:40:34 nbsp I vaguely remember an old Born Loser column containing a paragraphbeginning my readership is so low I could insert a graphic sex scene in my column and nobody would notice or something like thatthat was taken directly, and without citation, from an old Dave Barry column. Of course, I dont want to make any libelous accusations based solely on my own memory of an event several years in the past, but does anyone else remember a Born Loser column fitting this description? Users/BarnabasTruman 20060126 18:47:49 nbsp Who else goes Lamarspotting? Users/CindySperry 20060126 23:19:43 nbsp I talked to Lamar at Safeway and I didnt even know he had a scandal named after him or anything. His nametag said that he spoke Dutch and I thought that was cool. Users/KarenaAslanian 20060222 17:13:23 nbsp So... will he quit Safeway? Users/CindySperry 20060306 00:27:56 nbsp I wish Cost Plus had offered me $20,000 to quit. That wouldve been great. Users/BarnabasTruman 20060310 15:34:48 nbsp I think it is inappropriate and unethical for a candidate for the City Council who is also a UC Davis employee to have a column in the California Aggie. Lamar I challenge you to quit your column in the Aggie, or else all the candidates should have columns in the Aggie. Users/RobinSouza Good point. Ive been wondering why Editor didnt bring this up when Lamar announced his candidacy. Users/ArlenAbraham I think its fine. Its not like Lamars column is in any way, shape, or form political. His columns are more like verbal diarrhea (not to take away from the funniness of the column) with no real point. As long as he isnt campaigning in his column or mentions anything about his running for office, theres nothing wrong with it. Users/VivianPham Yeah, thats right! And Rob Roy works at Ben & Jerrys... I challenge him to quit working there because it is unethical and inappropriate for a candidate to be giving away free scoops of ice cream during a campaign. Users/BrentLaabs Provided he doesnt campaign for himself in his column (and from my experience he makes fun of himself a lot in his column and doesnt campaign at all), I think its a bit unfair to ask him to quit his remaining job over this. Being the sitting mayor is surely more of an advantage should Ruth Asmundson resign her position? Lamar is not a candidate who happens to have a column, hes a columnist who happens to be running for city council. It doesnt give him an advantage over the status quo: it IS the status quo. Users/KrisFricke It doesnt matter that Lamar isnt (directly) using the column for political gain, its not good journalistic practice to have a candidate with a column in the paper. Its basically free advertising because his name and photo are on the top of every column. Everyone knows that you have to work hard at writing press releases if you want Aggie coverage. Im sure the other candidates would love to have a column in the aggie I know Rob has appiled in the past. The Ben & Jerrys comment is totally irrelevant because its not Ben & Jerrys job to provide unbiased election coverage to the City of Davis. I know that Aggie columnists in the past have resigned so that they could run for ASUCD Senate. Its a conflict of interest. Im not saying that lamar should resign, im just trying to support robins argument and was wondering why it hasnt been discussed before.Users/ArlenAbraham 20060310 19:27:36 nbsp I wrote a letter to the editor this Tuesday that didnt get published after reading Anna Ritters latest column. Here it is: Sir, It has come to my attention that, as of late, the Tuesday Aggie has quickly migrated from the hillarious raunchy sex column issue to the Anna Ritter bitching hour. If I wanted to bore myself with inane topical whining about the woes of frustrated college life, Id read that column by the guy constantly talking about his job at Safeway. How am I supposed to flirt with girls doing the crossword at the MU when my old line So, did you see the sex column today? becomes So, did you read the latest from that Safeway bozo? Users/ScottRitchie You could change the line to So, does this rant make me look like a bozo? Users/KarlMogel KJM 20060311 01:43:34 nbsp I would like to point out that if the Aggie chose to endorse anyone in the city council election, it would probably be a violation of the ASUCD Constitution. If this is true, it would mean that the last bill that I wrote was unconstituional oh well. Someone should propose that as an official question to that court. Users/BrentLaabs Editorials in the Aggie are the collective opinions of the editorial board. As such they are covered under free speech. So the Aggie endorsing someone doesnt constitute a violation of the IRS code that the ASUCD Constitution forbids. Users/MichaelNguyen Let me paraphrase you: Senate Resolutions are the collective opinion of the ASUCD Senate. As such they are covered under free speech. The Constitutional Amendment didnt just say you cant break this law, it enumerated specific things in addition that ASUCD was prohibited from. The distributing statements clause is particularly troublesome. Users/BrentLaabs {{{ Article I, Section 6 (2) In accordance with Internal Revenue Service regulations, ASUCD is prohibited from directly or indirectly participating or intervening in any political campaign on behalf of, or in opposition to, any candidate for public office. This includes endorsing a candidate, making donations to a candidate’s campaign, engaging in fundraising for a candidate, distributing statements for or against a particular candidate or becoming involved in any other activity that may be beneficial or detrimental to any candidate. }}} A senate resolution is not the collective opinions of the senators it is a representative statement from the ASUCD itself, as an organization. The Aggie opinion section is a forum for the opinions of individuals/groups of individuals, including those in the editorial board, not the ASUCD. The editorial board in no way reflects the opinions of the ASUCD. You are drawing a false parallel. It would be different for the Senators to get together and say We, being senators, all support candidate X then to say We support candidate X in the name of the ASUCD. The opinions are the former rather than the latter. Users/MichaelNguyen Im afraid I disagree with your logic here. When the Editorial Board collectively decides to endorse a candidate, is that not a representative statement from the California Aggie in the same way that a Senate resolution is a representative statement of ASUCD? The legal problem is that THE CALIFORNIA AGGIE IS, LEGALLY, A PART OF ASUCD. The fact that the California Aggie has large circulation in Davis (in fact, its said to have the largest circulation in Yolo County) and the fact that the California Aggies bank accounts are, in fact, ASUCD accounts mean that ASUCD is, naturally, leary of any legal trouble an Aggie endorsement of a political candidate may bring. I suppose the best I can do at this point is consult our legal counsel and our business manager. PH From the Aggie Editorials represent the collecticve opinions of The California Aggie editorial board. From that statement it looks like its the opinion of the Board not the organization. Its the collective opinions of the Board, not of the Aggie itself. When the Senate issues a resolution it is the not the opinion of the senate but a statement from the ASUCD itself. These are completely different situations. From the http://www.californiaaggie.com/about/ website Views or opinions expressed in The Aggie by editors or columnists regarding legislation or candidates for politicial office or other matters are those of the editors or columnist alone. They are not those of the University of California or any department of UC. Advertisements appearing in the Aggie reflect the views of advertisers only; they are not an expression of editorial opinion by The Aggie. So its like a bunch of editors coauthoring one opinion, not a bunch of editors deciding where the Aggie stands. 20060311 18:45:09 nbsp Lamars dad knocked on my door this afternoon and asked me to vote for his son. I was impressed. I will. Users/GrumpyoldGeek 20060319 14:15:04 nbsp I think theres a quite a difference between a school newspaper with an independent editorial board and the body of government itself. Because ASUCD is the governing body, it makes sense that this mini Congress be prohibited from endorsing a candidate. A campus Slate, however, could probably endorse a candidate without running afoul of this IRS rule. I think its official (quasi)governmental endorsements that theyre afraid of. So I dont think the parallel is tight enough to cause a problem. Users/JaimeRaba 20060328 16:52:19 nbsp Well, looking at the media board guidelines, it looks like the Aggie can endorse. Im going to stop worrying about this argument, because I really believe that the Aggie should be able to endorse anyone they want to. Its just a fact of the situation that ASUCD and the Aggie are in an abusive marriage, and neither seems to think about the other in its decisions. Users/BrentLaabs 20060608 00:23:52 nbsp Does anyone else find it funny that Lamar and Stan Forbes teamed up for this election? Consider their slogans: Preserve our quality of life. (Forbes) and Its a Brand New Day (Heystek). Users/BrentLaabs 20061102 17:12:15 nbsp I voted for him, and he cusses in public in reference to Liston bringing his shotty onto DHS property Users/StevenDaubert 20070128 18:35:17 nbsp You should check out the Albertsons page and then look at the picture of the luckys bag, then you should look at the upper right hand corner very close. Users/StevenDaubert 20070803 10:39:02 nbsp Lamar!!! Ik ben nu op de Wiki!!!! :) Users/WeMo 20070807 14:22:59 nbsp Lamar what years were you an ASUCD Senator? And how many times do you lose before you won? And what was the name of the slate? Users/JamesSchwab I was an ASUCD Senator from Fall 1998 to Fall 1999. I was honored as ASUCD Senator of the Year in 1999. I had run as an independent candidate in the Winter 1998 election as one of 16 candidates and placed 16th (I told you I was the Born Loser! These roots run deep, really deep!). In the following election, I ran as one of six candidates on the Student Action Ticket (not Student Action as is reported on the Wiki; maybe someone can make this minor change). There were eight candidates in this election and I placed third from last (or sixth!), hanging on to the last seat by a measly 12 votes over my (now)friend Ken Loo, an independent candidate who ran on a twoply platform. I enjoyed this campaign very much, but my Senate win paled in comparison to becoming Senior Class President in high school (no offense!). I was the only ASUCD senator to vote against the proposed budget in June because it included an undeserved $7aweek pay raise for senators (bringing it to $35/week). One senator said he needed the increase to cover his electric bills, to which I said, Why dont push carts with me at Safeway? I actually donated each of my Senate paychecks to a different cause (one of them went to cover the expenses of attendees of the Students of Color conference, one of whom I would eventually run against in another ASUCD election). I ran for ASUCD Vice President on the Student Action Ticket with my slatemate and fellow Senate alum Jenna Ramesh. We ran against Matt Huerta and Erica Alfaro, who led the firstever LEAD slate. There were five tickets running and we worked hard to make it to a runoff with Matt and Erica. It was a tough campaign that we eventually lost. I congratulate Matt and Erica to this day they had a much better field team and their support was broad and deep. Ironically, I was told that I would have been broadly supported by those who had backed the eventual winners had I run for president instead! I have not affiliated myself with the Student Action Ticket since, well, I was a student (its a lot like citing which crowd you hung out with at lunch time in high school for your ASUCD campaign, and besides, the world perspective that had informed my undergraduate politics has since changed). By the way, Jenna ran for president again on the Student Action Ticket (or another incarnation thereof Ill have to ask her; I was studying in The Netherlands at the time). This was the first ASUCD election held via the Internet, to my knowledge. Previous elections had been held using fillinthe bubble Scantron ballots (which reminds me of how we used to register for classes by phone!). Jenna was briefly presidentelect due to the temporary disqualification of the eventual winners (which reminds me of the similar situation involving Senator Rob Roy). This was probably more than youd ever wanted to read! I can tell you even more about it over a beer or two. Users/LamarHeystek Lamar Heystek 20080220 20:20:28 nbsp I just started working at safeway. I would greatly appreciate it if you could give me some pros and cons of working there and of joining the union. Thank you! Users/JackkiCox 20120609 12:22:38 nbsp Whats Lamar up to these days? Users/KenjiYamada
lab/davisWiki/Lamar_Heystek.f
c QSATS version 1.0 (3 March 2011) c file name: odd.f c ---------------------------------------------------------------------- c this subroutine distributes odd-numbered replicas to the child c processes, waits for them to be processed, and then returns c control to the main parent subroutine. c errchk is a subroutine called after every MPI subroutine that c checks the MPI error code and reports any errors. c ---------------------------------------------------------------------- subroutine oddrep(loop, nsent, nrcvd, MPI_R) implicit double precision (a-h, o-z) include 'sizes.h' include 'qsats.h' include 'mpif.h' dimension istat(MPI_STATUS_SIZE) dimension imsg(3) dimension isent(NREPS), ikeep(NATOMS), replic(NATOM7) dimension rstate(8) c --- loop over all odd replicas. do nrep=1, NREPS-1, 2 if (idebug.eq.4) + write (9, *) 'finding child who can receive nrep = ', nrep c ------ wait for data request from a child. call MPI_PROBE(MPI_ANY_SOURCE, + 1201, + MPI_COMM_WORLD, + istat, + ierr) call errchk(0, ierr, 111201) nchild=istat(MPI_SOURCE) call MPI_RECV(imsg, + 3, + MPI_INTEGER, + nchild, + 1201, + MPI_COMM_WORLD, + istat, + ierr) call errchk(0, ierr, 151201) if (idebug.eq.4) + write (9, *) 'sending nrep = ', nrep, ' to ', nchild c ------ check whether the child is returning results. if so, then c receive the results. if (imsg(1).gt.0) then idrep=imsg(1) if (idebug.eq.4) + write (9, *) 'child ', nchild, ' returning replica ', + idrep c --------- keep track of acceptances and rejections. ztacc=ztacc+imsg(2) ztrej=ztrej+imsg(3) call MPI_RECV(replic, + NATOM3, + MPI_R, + nchild, + 1202, + MPI_COMM_WORLD, + istat, + ierr) call errchk(0, ierr, 111202) call MPI_RECV(rstate, + 8, + MPI_DOUBLE_PRECISION, + nchild, + 1203, + MPI_COMM_WORLD, + istat, + ierr) call errchk(0, ierr, 111203) c --------- update the random number generator state vector for this c replica. do i=1, 8 rstatv(i, idrep)=rstate(i) end do c --------- update the atom positions in this replica. do i=1, NATOM3 path(i, idrep)=replic(i) end do c --------- update the number of received replicas. nrcvd=nrcvd+1 c --------- indicate that this replica has been processed and returned. isent(idrep)=-nchild end if c ------ send a new replica to child. first tell the child which replica c it is going to receive. imsg(1)=nrep call MPI_SEND(imsg, + 1, + MPI_INTEGER, + nchild, + 0204, + MPI_COMM_WORLD, + ierr) call errchk(0, ierr, 110204) c ------ send the replica. if (idebug.eq.4) + write (9, *) 'calling rpsend for child ', nchild call rpsend(loop, nrep, nchild, MPI_R) if (idebug.eq.4) + write (9, *) 'replica ', nrep, ' sent to child ', nchild c ------ update how many replicas have been sent. nsent=nsent+1 c ------ leave the trail of crumbs! isent(nrep)=nchild c ------ update how much work has been sent to this child. iwork(nchild)=iwork(nchild)+1 end do c --- at this point we don't have any more odd replicas to send to the c children, but we need to retrieve any processed replicas that the c children are still holding to send back to the parent. this c flushes out all of those replicas. do i=1, NREPS-1, 2 if (isent(i).gt.0) then nchild=isent(i) call MPI_RECV(imsg, + 3, + MPI_INTEGER, + nchild, + 1201, + MPI_COMM_WORLD, + istat, + ierr) call errchk(0, ierr, 121201) c --------- check whether the child is returning results. if so, get c the results and update the atomic positions. if (imsg(1).gt.0) then idrep=imsg(1) if (idebug.eq.4) + write (9, *) 'child ', nchild, + ' returning replica ', idrep c ------------ keep track of acceptances and rejections. ztacc=ztacc+imsg(2) ztrej=ztrej+imsg(3) call MPI_RECV(replic, + NATOM3, + MPI_R, + nchild, + 1202, + MPI_COMM_WORLD, + istat, + ierr) call errchk(0, ierr, 121202) call MPI_RECV(rstate, + 8, + MPI_DOUBLE_PRECISION, + nchild, + 1203, + MPI_COMM_WORLD, + istat, + ierr) call errchk(0, ierr, 121203) c ------------ update the random number generator state vector for this c replica. do k=1, 8 rstatv(k, idrep)=rstate(k) end do c ------------ update the atom positions in this replica. do n=1, NATOM3 path(n, idrep)=replic(n) end do c ------------ update the number of received replicas. nrcvd=nrcvd+1 c ------------ indicate that this replica has been processed and returned. isent(idrep)=-nchild end if c --------- now tell the child to wait until all of the children are done c and more work is available. imsg(1)=-1 call MPI_SEND(imsg, + 1, + MPI_INTEGER, + nchild, + 0204, + MPI_COMM_WORLD, + ierr) call errchk(0, ierr, 121204) end if end do return end
QTM/MixQC/1.0.7/odd.f
x <= a % b;
tests/f/ungrammatical/ung03.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 OUT_data use salmon_parallel, only: nproc_id_global, nproc_size_global, nproc_group_global, nproc_group_h use salmon_communication, only: comm_is_root, comm_summation, comm_bcast use scf_data use new_world_sub use read_pslfile_sub use allocate_psl_sub use allocate_mat_sub implicit none integer :: is,iob,jj,ik integer :: ix,iy,iz real(8),allocatable :: matbox(:,:,:),matbox2(:,:,:) complex(8),allocatable :: cmatbox(:,:,:),cmatbox2(:,:,:) character(100) :: file_OUT_data character(100) :: file_OUT_data_ini integer :: ibox integer :: ii,j1,j2,j3 integer :: myrank_datafiles integer :: ista_Mxin_datafile(3) integer :: iend_Mxin_datafile(3) integer :: inum_Mxin_datafile(3) integer :: nproc_xyz_datafile(3) character(8) :: fileNumber_data integer :: iob_myob integer :: icorr_p if(comm_is_root(nproc_id_global))then open(97,file=file_OUT,form='unformatted') !version number version_num(1)=40 version_num(2)=1 write(97) version_num(1),version_num(2) write(97) Nd write(97) ilsda write(97) iflag_ps write(97) iend_Mx_ori(:3) write(97) lg_end(:3) if(ilsda == 0)then write(97) MST(1) write(97) ifMST(1) else if(ilsda == 1)then write(97) (MST(is),is=1,2) write(97) (ifMST(is),is=1,2) end if if(iflag_ps.eq.1)then write(97) MI,MKI,maxMps,Mlmps end if write(97) (Hgs(jj),jj=1,3) write(97) (rLsize(jj,ntmg),jj=1,3) write(97) Miter write(97) MEO if(iflag_ps.eq.1)then write(97) Jxyz_all(1:3,1:maxMps,1:MI),Mps_all(1:MI) end if if(iflag_ps.eq.1)then write(97) Kion(:MI) write(97) Rion(:,:MI) write(97) iZatom(:MKI) write(97) pseudo_file(:MKI) !ipsfileform(:MKI) write(97) Zps(:MKI),Rps(:MKI) write(97) AtomName(:MI) write(97) iAtomicNumber(:MI) end if end if if(comm_is_root(nproc_id_global))then if(iflag_ps.eq.1)then write(97) uV_all(:maxMps,:Mlmps,:MI),uVu(:Mlmps,:MI) write(97) Mlps(:MKI),Lref(:MKI) end if end if allocate(matbox(lg_sta(1):lg_end(1),lg_sta(2):lg_end(2),lg_sta(3):lg_end(3))) allocate(matbox2(lg_sta(1):lg_end(1),lg_sta(2):lg_end(2),lg_sta(3):lg_end(3))) allocate(cmatbox(lg_sta(1):lg_end(1),lg_sta(2):lg_end(2),lg_sta(3):lg_end(3))) allocate(cmatbox2(lg_sta(1):lg_end(1),lg_sta(2):lg_end(2),lg_sta(3):lg_end(3))) if(OC<=2)then if(num_datafiles_OUT==1.or.num_datafiles_OUT>nproc_size_global)then file_OUT_data_ini = file_OUT_ini else if(nproc_id_global<num_datafiles_OUT)then myrank_datafiles=nproc_id_global ibox=1 nproc_xyz_datafile=1 do ii=1,19 do jj=3,1,-1 if(ibox<num_datafiles_OUT)then nproc_xyz_datafile(jj)=nproc_xyz_datafile(jj)*2 ibox=ibox*2 end if end do end do do j3=0,nproc_xyz_datafile(3)-1 do j2=0,nproc_xyz_datafile(2)-1 do j1=0,nproc_xyz_datafile(1)-1 ibox = j1 + nproc_xyz_datafile(1)*j2 + nproc_xyz_datafile(1)*nproc_xyz_datafile(2)*j3 if(ibox==myrank_datafiles)then ista_Mxin_datafile(1)=j1*lg_num(1)/nproc_xyz_datafile(1)+lg_sta(1) iend_Mxin_datafile(1)=(j1+1)*lg_num(1)/nproc_xyz_datafile(1)+lg_sta(1)-1 ista_Mxin_datafile(2)=j2*lg_num(2)/nproc_xyz_datafile(2)+lg_sta(2) iend_Mxin_datafile(2)=(j2+1)*lg_num(2)/nproc_xyz_datafile(2)+lg_sta(2)-1 ista_Mxin_datafile(3)=j3*lg_num(3)/nproc_xyz_datafile(3)+lg_sta(3) iend_Mxin_datafile(3)=(j3+1)*lg_num(3)/nproc_xyz_datafile(3)+lg_sta(3)-1 if(OC==2)then mg_sta_ini(1)=j1*lg_num_ini(1)/nproc_xyz_datafile(1)+lg_sta_ini(1) mg_end_ini(1)=(j1+1)*lg_num_ini(1)/nproc_xyz_datafile(1)+lg_sta_ini(1)-1 mg_sta_ini(2)=j2*lg_num_ini(2)/nproc_xyz_datafile(2)+lg_sta_ini(2) mg_end_ini(2)=(j2+1)*lg_num_ini(2)/nproc_xyz_datafile(2)+lg_sta_ini(2)-1 mg_sta_ini(3)=j3*lg_num_ini(3)/nproc_xyz_datafile(3)+lg_sta_ini(3) mg_end_ini(3)=(j3+1)*lg_num_ini(3)/nproc_xyz_datafile(3)+lg_sta_ini(3)-1 end if end if end do end do end do inum_Mxin_datafile(:)=iend_Mxin_datafile(:)-ista_Mxin_datafile(:)+1 write(fileNumber_data, '(i6.6)') myrank_datafiles file_OUT_data = trim(adjustl(sysname))//"_gs_"//trim(adjustl(fileNumber_data))//".bin" open(87,file=file_OUT_data,form='unformatted') end if end if end if select case(iperiodic) case(0) if(OC<=2)then do ik=1,num_kpoints_rd do iob=1,itotMST call calc_myob(iob,iob_myob) call check_corrkob(iob,ik,icorr_p) matbox_l=0.d0 if(icorr_p==1)then matbox_l(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3)) & = psi(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3),iob_myob,ik) end if call comm_summation(matbox_l,matbox_l2,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_global) if(num_datafiles_OUT==1.or.num_datafiles_OUT>nproc_size_global)then if(comm_is_root(nproc_id_global))then write(97) ((( matbox_l2(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if else if(nproc_id_global<num_datafiles_OUT)then write(87) ((( matbox_l2(ix,iy,iz),ix=ista_Mxin_datafile(1),iend_Mxin_datafile(1)), & iy=ista_Mxin_datafile(2),iend_Mxin_datafile(2)), & iz=ista_Mxin_datafile(3),iend_Mxin_datafile(3)) end if end if end do end do else if(OC==3)then do iob=1,iobnum write(87,rec=iob) ((( psi(ix,iy,iz,iob,1),ix=mg_sta(1),mg_end(1)), & iy=mg_sta(2),mg_end(2)), & iz=mg_sta(3),mg_end(3)) end do end if case(3) if(OC<=2)then do ik=1,num_kpoints_rd do iob=1,itotMST call calc_myob(iob,iob_myob) call check_corrkob(iob,ik,icorr_p) cmatbox_l=0.d0 if(icorr_p==1)then cmatbox_l(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3)) & = zpsi(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3),iob_myob,ik) end if call comm_summation(cmatbox_l,cmatbox_l2,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_global) if(num_datafiles_OUT==1.or.num_datafiles_OUT>nproc_size_global)then if(comm_is_root(nproc_id_global))then write(97) ((( cmatbox_l2(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if else if(nproc_id_global<num_datafiles_OUT)then write(87) ((( cmatbox_l2(ix,iy,iz),ix=ista_Mxin_datafile(1),iend_Mxin_datafile(1)), & iy=ista_Mxin_datafile(2),iend_Mxin_datafile(2)), & iz=ista_Mxin_datafile(3),iend_Mxin_datafile(3)) end if end if end do end do else if(OC==3)then do ik=k_sta,k_end do iob=1,iobnum write(87,rec=iob) ((( zpsi(ix,iy,iz,iob,ik),ix=mg_sta(1),mg_end(1)), & iy=mg_sta(2),mg_end(2)), & iz=mg_sta(3),mg_end(3)) end do end do end if end select if(OC<=2)then if(num_datafiles_OUT==1.or.num_datafiles_OUT>nproc_size_global)then if(comm_is_root(nproc_id_global).and.OC==2) close(67) else if(nproc_id_global<num_datafiles_OUT)then close(87) if(OC==2) close(67) end if end if else if(OC==3)then close(87) end if matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = rho(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if do ii=1,num_rho_stock+1 matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = rho_in(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3),ii) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if end do do ii=1,num_rho_stock matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = rho_out(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3),ii) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if end do if(ilsda == 1)then do is=1,2 matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = rho_s(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3),is) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if do ii=1,num_rho_stock+1 matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = rho_s_in(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3),ii,is) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if end do do ii=1,num_rho_stock matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = rho_s_out(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3),ii,is) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if end do end do end if if(comm_is_root(nproc_id_global))then write(97) esp(:itotMST,:num_kpoints_rd),rocc(:itotMST,:num_kpoints_rd) end if matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = Vh(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if if(ilsda == 0)then matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = Vxc(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if else if(ilsda == 1) then do is=1,2 matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = Vxc_s(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3),is) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if end do end if matbox2=0.d0 matbox2(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) & = Vpsl(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3)) call comm_summation(matbox2,matbox,lg_num(1)*lg_num(2)*lg_num(3),nproc_group_h) if(comm_is_root(nproc_id_global))then write(97) ((( matbox(ix,iy,iz),ix=lg_sta(1),lg_end(1)),iy=lg_sta(2),lg_end(2)),iz=lg_sta(3),lg_end(3)) end if if(comm_is_root(nproc_id_global))then close(97) end if deallocate(matbox,matbox2) deallocate(cmatbox,cmatbox2) END SUBROUTINE OUT_data !======================================================================= SUBROUTINE IN_data use salmon_parallel, only: nproc_id_global, nproc_size_global, nproc_group_global, nproc_id_spin use salmon_parallel, only: nproc_id_orbitalgrid, nproc_id_kgrid use salmon_communication, only: comm_is_root, comm_summation, comm_bcast use scf_data use new_world_sub use allocate_mat_sub implicit none integer :: NI0,Ndv0,Nps0,Nd0 integer :: ii,is,iob,jj,ibox,j1,j2,j3,ik integer :: ix,iy,iz real(8),allocatable :: matbox(:,:,:) real(8),allocatable :: matbox2(:,:,:) real(8),allocatable :: matbox3(:,:,:) real(8),allocatable :: esp0(:,:),rocc0(:,:) complex(8),allocatable :: cmatbox(:,:,:) complex(8),allocatable :: cmatbox2(:,:,:) character(100) :: file_IN_data character(8) :: cha_version_num(2) integer :: version_num_box(2) integer :: myrank_datafiles integer :: ista_Mxin_datafile(3) integer :: iend_Mxin_datafile(3) integer :: inum_Mxin_datafile(3) integer :: nproc_xyz_datafile(3) character(8) :: fileNumber_data integer :: maxMdvbox integer :: iob_myob integer :: icheck_corrkob integer :: pstart(2),pend(2) integer :: is_sta,is_end integer :: p0 integer :: iobnum0 integer :: icount complex(8),parameter :: zi=(0.d0,1.d0) integer :: ig_sta(3),ig_end(3),ig_num(3) real(8),allocatable :: matbox_read(:,:,:) real(8),allocatable :: matbox_read2(:,:,:) complex(8),allocatable :: cmatbox_read(:,:,:) complex(8),allocatable :: cmatbox_read2(:,:,:) real(8),allocatable :: matbox_read3(:,:,:) complex(8),allocatable :: cmatbox_read3(:,:,:) integer :: icheck_read integer :: ifilenum_data integer :: icomm integer :: ifMST0(2) integer :: imesh_oddeven0 integer :: itmg if(comm_is_root(nproc_id_global))then write(*,*) file_IN open(96,file=file_IN,form='unformatted') read(96) version_num_box(1),version_num_box(2) end if call comm_bcast(version_num_box,nproc_group_global) if(version_num_box(1)>=40)then continue else if((version_num_box(1)==17.and.version_num_box(2)>=13).or.version_num_box(1)>=18) then if(comm_is_root(nproc_id_global))then read(96) imesh_oddeven0 end if call comm_bcast(imesh_oddeven0,nproc_group_global) else continue end if if(comm_is_root(nproc_id_global)) then read(96) Nd0 read(96) ilsda if(version_num_box(1)<=36)then read(96) iflag_ps,ibox else read(96) iflag_ps end if if(version_num_box(1)==17.and.version_num_box(2)<=10)then read(96) NI0,Ndv0,Nps0,Nd0 end if write(cha_version_num(1), '(i8)') version_num_box(1) write(cha_version_num(2), '(i8)') version_num_box(2) if((version_num_box(1)==17.and.version_num_box(2)==22).or. & (version_num_box(1)==18.and.version_num_box(2)==17).or. & (version_num_box(1)==23.and.version_num_box(2)==62).or. & (version_num_box(1)==25.and.version_num_box(2)==17).or. & (version_num_box(1)==26.and.version_num_box(2)==3).or. & (version_num_box(1)==27.and.version_num_box(2)==9).or. & (version_num_box(1)==28.and.version_num_box(2)==1).or. & (version_num_box(1)==29.and.version_num_box(2)==1))then write(*,'(a,a)') "A version of input data file is ", & "1."//trim(adjustl(cha_version_num(1))) else if(version_num_box(1)==30.and.version_num_box(2)>=18)then write(*,'(a,a)') "A version of input data file is ", & trim(adjustl(cha_version_num(2))) else write(*,'(a,a)') "A version of input data file is ", & "1."//trim(adjustl(cha_version_num(1)))//"."//trim(adjustl(cha_version_num(2))) end if end if call comm_bcast(ilsda,nproc_group_global) call comm_bcast(iflag_ps,nproc_group_global) if(comm_is_root(nproc_id_global))then read(96) iend_Mx_ori(:3) read(96) lg_end(:3) if(ilsda == 0) then read(96) MST0(1) ! read(96) ifMST(1) if(iSCFRT==2)then read(96) ifMST(1) else read(96) ifMST0(1) endif else if(ilsda == 1)then read(96) (MST0(is),is=1,2) ! read(96) (ifMST(is),is=1,2) if(iSCFRT==2)then read(96) (ifMST(is),is=1,2) else read(96) (ifMST0(is),is=1,2) endif end if if(version_num_box(1)<=31)then if(iflag_ps.eq.1)then read(96) MI_read,MKI,maxMdvbox,maxMps,Mlmps end if else if(iflag_ps.eq.1)then read(96) MI_read,MKI,maxMps,Mlmps end if end if if(version_num_box(1)>=35)then read(96) (Hgs(jj),jj=1,3) else read(96) Hgs(1) Hgs(2)=Hgs(1) Hgs(3)=Hgs(1) end if Hvol=Hgs(1)*Hgs(2)*Hgs(3) read(96) (rLsize(jj,1),jj=1,3) read(96) Miter read(96) ibox end if call comm_bcast(iend_Mx_ori,nproc_group_global) call comm_bcast(lg_end,nproc_group_global) call comm_bcast(MST0,nproc_group_global) call comm_bcast(ifMST,nproc_group_global) call comm_bcast(Hgs,nproc_group_global) call comm_bcast(Hvol,nproc_group_global) call comm_bcast(rLsize,nproc_group_global) call comm_bcast(Miter,nproc_group_global) itmg=1 call set_imesh_oddeven(itmg) if(version_num_box(1)>=40)then continue else if((version_num_box(1)==17.and.version_num_box(2)>=13).or.version_num_box(1)>=18) then if(imesh_oddeven0==1.and.imesh_oddeven(1)==1.and.imesh_oddeven(2)==1.and.imesh_oddeven(3)==1)then continue else if(imesh_oddeven0==2.and.imesh_oddeven(1)==2.and.imesh_oddeven(2)==2.and.imesh_oddeven(3)==2)then continue else stop "You cannot use data files of this version because imesh_oddeven and values of Lsize/Hgs are a mixture of odd and even." end if else if(imesh_oddeven(1)==2.and.imesh_oddeven(2)==2.and.imesh_oddeven(3)==2)then continue else stop "You cannot use data files of this version because imesh_oddeven is not 2." end if end if if(iSCFRT==2) then if(ilsda == 0) then MST(1)=ifMST(1) else if(ilsda == 1) then MST(1:2)=ifMST(1:2) end if end if select case(iperiodic) case(0) do jj=1,3 select case(imesh_oddeven(jj)) case(1) ista_Mx_ori(jj)=-iend_Mx_ori(jj) lg_sta(jj)=-lg_end(jj) case(2) ista_Mx_ori(jj)=-iend_Mx_ori(jj)+1 lg_sta(jj)=-lg_end(jj)+1 end select end do case(3) ista_Mx_ori(:)=1-Nd lg_sta(:)=1 end select inum_Mx_ori(:)=iend_Mx_ori(:)-ista_Mx_ori(:)+1 lg_num(:)=lg_end(:)-lg_sta(:)+1 call check_fourier call set_gridcoo allocate(ista_Mxin(3,0:nproc_size_global-1),iend_Mxin(3,0:nproc_size_global-1)) allocate(inum_Mxin(3,0:nproc_size_global-1)) call setmg(mg_sta,mg_end,mg_num,ista_Mxin,iend_Mxin,inum_Mxin, & lg_sta,lg_num,nproc_size_global,nproc_id_global,nproc_Mxin,nproc_k,nproc_ob,isequential) if(ilsda == 0) then itotMST0=MST0(1) itotMST=MST(1) itotfMST=ifMST(1) else if(ilsda == 1) then itotMST0=MST0(1)+MST0(2) itotMST=MST(1)+MST(2) itotfMST=ifMST(1)+ifMST(2) end if call init_mesh_s call check_ng if(iflag_ps.eq.1)then call comm_bcast(MI_read,nproc_group_global) call comm_bcast(MKI,nproc_group_global) call comm_bcast(maxMps,nproc_group_global) call comm_bcast(Mlmps,nproc_group_global) MI=MI_read end if if(iflag_ps.eq.1)then if(comm_is_root(nproc_id_global))then if(version_num_box(1)<=31)then read(96) read(96) else read(96) end if end if if(iSCFRT==2) then ! allocate( Kion(MI),Rion(3,MI) ) end if if(iSCFRT==2) allocate( AtomName(MI), iAtomicNumber(MI) ) if(comm_is_root(nproc_id_global))then read(96) Kion(:MI_read) read(96) Rion(:,:MI_read) read(96) iZatom(:MKI) if(version_num_box(1)>=34)then read(96) pseudo_file(:MKI) !ipsfileform(:MKI) else stop "This version is already invalid." end if read(96) read(96) AtomName(:MI_read) read(96) iAtomicNumber(:MI_read) end if call comm_bcast(Kion,nproc_group_global) call comm_bcast(Rion,nproc_group_global) call comm_bcast(iZatom,nproc_group_global) call comm_bcast(pseudo_file,nproc_group_global) call comm_bcast(AtomName,nproc_group_global) call comm_bcast(iAtomicNumber,nproc_group_global) end if if(ilsda==1)then nproc_ob_spin(1)=(nproc_ob+1)/2 nproc_ob_spin(2)=nproc_ob/2 end if if(iSCFRT==2) call make_new_world call setk(k_sta, k_end, k_num, num_kpoints_rd, nproc_k, nproc_id_orbitalgrid) if(ilsda==0)then call calc_iobnum(itotMST,nproc_ob,nproc_id_kgrid,iobnum,nproc_ob,iparaway_ob) else if(ilsda==1)then if(nproc_ob==1)then iobnum=itotMST else if(nproc_id_spin<nproc_ob_spin(1))then call calc_iobnum(MST(1),nproc_ob_spin(1),nproc_id_kgrid,iobnum,nproc_ob_spin(1),iparaway_ob) else call calc_iobnum(MST(2),nproc_ob_spin(2),nproc_id_kgrid,iobnum,nproc_ob_spin(2),iparaway_ob) end if end if end if if(iSCFRT==2)then call allocate_mat call set_icoo1d end if allocate(k_rd0(3,num_kpoints_rd),ksquare0(num_kpoints_rd)) if(iperiodic==3)then call init_k_rd(k_rd0,ksquare0,3) end if allocate( matbox(lg_sta(1):lg_end(1),lg_sta(2):lg_end(2),lg_sta(3):lg_end(3)) ) allocate( cmatbox(lg_sta(1):lg_end(1),lg_sta(2):lg_end(2),lg_sta(3):lg_end(3)) ) allocate( matbox3(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3)) ) if(iSCFRT==1)then select case(iperiodic) case(0) if(iobnum.ge.1)then allocate( psi(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3), & & 1:iobnum,k_sta:k_end) ) end if if(iswitch_orbital_mesh==1.or.iflag_subspace_diag==1)then allocate( psi_mesh(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3), & 1:itotMST,num_kpoints_rd) ) end if case(3) allocate( ttpsi(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3))) if(iobnum.ge.1)then allocate( zpsi(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3), & & 1:iobnum,k_sta:k_end) ) end if if(iswitch_orbital_mesh==1.or.iflag_subspace_diag==1)then allocate( zpsi_mesh(ng_sta(1):ng_end(1), & ng_sta(2):ng_end(2), & ng_sta(3):ng_end(3), & 1:itotMST,num_kpoints_rd) ) end if end select else if(iSCFRT==2)then if(iobnum.ge.1)then allocate( zpsi_in(mg_sta(1)-Nd:mg_end(1)+Nd+1,mg_sta(2)-Nd:mg_end(2)+Nd,mg_sta(3)-Nd:mg_end(3)+Nd, & & 1:iobnum,k_sta:k_end) ) allocate( zpsi_out(mg_sta(1)-Nd:mg_end(1)+Nd+1,mg_sta(2)-Nd:mg_end(2)+Nd,mg_sta(3)-Nd:mg_end(3)+Nd, & & 1:iobnum,k_sta:k_end) ) zpsi_in(mg_sta(1)-Nd:mg_end(1)+Nd+1,mg_sta(2)-Nd:mg_end(2)+Nd,mg_sta(3)-Nd:mg_end(3)+Nd, & & 1:iobnum,k_sta:k_end) = 0.d0 zpsi_out(mg_sta(1)-Nd:mg_end(1)+Nd+1,mg_sta(2)-Nd:mg_end(2)+Nd,mg_sta(3)-Nd:mg_end(3)+Nd, & & 1:iobnum,k_sta:k_end) = 0.d0 end if if(iwrite_projection==1)then if(ilsda==0)then call calc_iobnum(itotMST0,nproc_ob,nproc_id_kgrid,iobnum0,nproc_ob,iparaway_ob) else if(ilsda==1)then if(nproc_ob==1)then iobnum0=itotMST0 else if(nproc_id_spin<nproc_ob_spin(1))then call calc_iobnum(MST0(1),nproc_ob_spin(1),nproc_id_kgrid,iobnum0,nproc_ob_spin(1),iparaway_ob) else call calc_iobnum(MST0(2),nproc_ob_spin(2),nproc_id_kgrid,iobnum0,nproc_ob_spin(2),iparaway_ob) end if end if end if if(iobnum0.ge.1)then allocate( zpsi_t0(mg_sta(1)-Nd:mg_end(1)+Nd+1,mg_sta(2)-Nd:mg_end(2)+Nd,mg_sta(3)-Nd:mg_end(3)+Nd, & & 1:iobnum0,k_sta:k_end) ) zpsi_t0(mg_sta(1)-Nd:mg_end(1)+Nd+1,mg_sta(2)-Nd:mg_end(2)+Nd,mg_sta(3)-Nd:mg_end(3)+Nd, & & 1:iobnum0,k_sta:k_end) = 0.d0 end if end if end if allocate( rho(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3))) allocate( rho0(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3))) allocate( rho_diff(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3))) if(iSCFRT==1)then allocate( rho_in(ng_sta(1):ng_end(1),ng_sta(2):ng_end(2),ng_sta(3):ng_end(3),1:num_rho_stock+1)) allocate( rho_out(ng_sta(1):ng_end(1),ng_sta(2):ng_end(2),ng_sta(3):ng_end(3),1:num_rho_stock+1)) rho_in=0.d0 rho_out=0.d0 end if if(ilsda == 0) then continue else if(ilsda == 1) then allocate( rho_s(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3),2)) allocate( rho_s_in(ng_sta(1):ng_end(1),ng_sta(2):ng_end(2),ng_sta(3):ng_end(3),1:num_rho_stock+1,2)) allocate( rho_s_out(ng_sta(1):ng_end(1),ng_sta(2):ng_end(2),ng_sta(3):ng_end(3),1:num_rho_stock+1,2)) rho_s_in=0.d0 rho_s_out=0.d0 end if if(iSCFRT==1)then allocate( esp0(itotMST0,num_kpoints_rd)) allocate( esp(itotMST,num_kpoints_rd)) allocate( rocc0(itotMST0,num_kpoints_rd)) else if(iSCFRT==2)then allocate( esp(itotMST,num_kpoints_rd),rocc(itotMST,num_kpoints_rd)) allocate( esp0(itotMST0,num_kpoints_rd),rocc0(itotMST0,num_kpoints_rd)) allocate( esp2(itotMST,num_kpoints_rd)) esp2=0.d0 end if allocate( Vh(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3)) ) if(ilsda == 0) then allocate( Vxc(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3)) ) else if(ilsda == 1) then allocate( Vxc_s(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3),2) ) end if if(ilsda==0)then allocate( Vlocal(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3),1) ) allocate( Vlocal2(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3),1) ) else allocate( Vlocal(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3),2) ) allocate( Vlocal2(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3),2) ) end if allocate( Vpsl(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3)) ) if(icalcforce==1) allocate( Vpsl_atom(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3),MI) ) if(comm_is_root(nproc_id_global))then if(version_num_box(1)>=32)then if(iflag_ps.eq.1)then read(96) read(96) Mlps(:MKI),Lref(:MKI) end if end if end if if(version_num_box(1)>=32)then if(iflag_ps.eq.1)then call comm_bcast(Mlps,nproc_group_global) call comm_bcast(Lref,nproc_group_global) end if end if allocate( cmatbox2(lg_sta(1):lg_end(1),lg_sta(2):lg_end(2),lg_sta(3):lg_end(3)) ) if(num_datafiles_IN==1)then ifilenum_data=96 else ifilenum_data=86 end if !set ista_Mxin_datafile etc. if(IC<=2)then if(num_datafiles_IN<=nproc_size_global)then if(nproc_id_global<num_datafiles_IN)then myrank_datafiles=nproc_id_global ibox=1 nproc_xyz_datafile=1 do ii=1,19 do jj=3,1,-1 if(ibox<num_datafiles_IN)then nproc_xyz_datafile(jj)=nproc_xyz_datafile(jj)*2 ibox=ibox*2 end if end do end do do j3=0,nproc_xyz_datafile(3)-1 do j2=0,nproc_xyz_datafile(2)-1 do j1=0,nproc_xyz_datafile(1)-1 ibox = j1 + nproc_xyz_datafile(1)*j2 + nproc_xyz_datafile(1)*nproc_xyz_datafile(2)*j3 if(ibox==myrank_datafiles)then ista_Mxin_datafile(1)=j1*lg_num(1)/nproc_xyz_datafile(1)+lg_sta(1) iend_Mxin_datafile(1)=(j1+1)*lg_num(1)/nproc_xyz_datafile(1)+lg_sta(1)-1 ista_Mxin_datafile(2)=j2*lg_num(2)/nproc_xyz_datafile(2)+lg_sta(2) iend_Mxin_datafile(2)=(j2+1)*lg_num(2)/nproc_xyz_datafile(2)+lg_sta(2)-1 ista_Mxin_datafile(3)=j3*lg_num(3)/nproc_xyz_datafile(3)+lg_sta(3) iend_Mxin_datafile(3)=(j3+1)*lg_num(3)/nproc_xyz_datafile(3)+lg_sta(3)-1 end if end do end do end do inum_Mxin_datafile(:)=iend_Mxin_datafile(:)-ista_Mxin_datafile(:)+1 if(num_datafiles_IN>=2.and.nproc_id_global<num_datafiles_IN)then write(fileNumber_data, '(i6.6)') myrank_datafiles file_IN_data = trim(adjustl(sysname))//"_gs_"//trim(adjustl(fileNumber_data))//".bin" open(86,file=file_IN_data,form='unformatted') end if end if end if end if if(ilsda == 0)then is_sta=1 is_end=1 pstart(1)=1 pend(1)=itotMST0 else if(ilsda == 1)then is_sta=1 is_end=2 pstart(1)=1 pend(1)=MST0(1) pstart(2)=MST0(1)+1 pend(2)=itotMST0 end if allocate( matbox2(lg_sta(1):lg_end(1),lg_sta(2):lg_end(2),lg_sta(3):lg_end(3)) ) ig_sta(:)=lg_sta(:) ig_end(:)=lg_end(:) ig_num(:)=lg_num(:) allocate( matbox_read(ig_sta(1):ig_end(1),ig_sta(2):ig_end(2),ig_sta(3):ig_end(3)) ) allocate( matbox_read2(ig_sta(1):ig_end(1),ig_sta(2):ig_end(2),ig_sta(3):ig_end(3)) ) allocate( cmatbox_read(ig_sta(1):ig_end(1),ig_sta(2):ig_end(2),ig_sta(3):ig_end(3)) ) allocate( cmatbox_read2(ig_sta(1):ig_end(1),ig_sta(2):ig_end(2),ig_sta(3):ig_end(3)) ) allocate( matbox_read3(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3)) ) allocate( cmatbox_read3(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3)) ) !$OMP parallel do private(iz,iy,ix) do iz=ig_sta(3),ig_end(3) do iy=ig_sta(2),ig_end(2) do ix=ig_sta(1),ig_end(1) matbox_read2(ix,iy,iz)=0.d0 cmatbox_read2(ix,iy,iz)=0.d0 end do end do end do icount=0 do ik=1,num_kpoints_rd do is=is_sta,is_end do p0=pstart(is),pend(is) ! read file call conv_p0(p0,iob) call calc_myob(iob,iob_myob) call check_corrkob(iob,ik,icheck_corrkob) if(IC<=2)then if(nproc_id_global<num_datafiles_IN)then icheck_read=1 else icheck_read=0 end if else if(IC==3.or.IC==4)then if(icheck_corrkob==1)then icheck_read=1 else icheck_read=0 end if end if if(icheck_read==1)then icount=icount+1 if(IC<=2)then select case(iperiodic) case(0) read(ifilenum_data) ((( matbox_read2(ix,iy,iz),ix=ista_Mxin_datafile(1),iend_Mxin_datafile(1)), & iy=ista_Mxin_datafile(2),iend_Mxin_datafile(2)), & iz=ista_Mxin_datafile(3),iend_Mxin_datafile(3)) case(3) read(ifilenum_data) ((( cmatbox_read2(ix,iy,iz),ix=ista_Mxin_datafile(1),iend_Mxin_datafile(1)), & iy=ista_Mxin_datafile(2),iend_Mxin_datafile(2)), & iz=ista_Mxin_datafile(3),iend_Mxin_datafile(3)) end select else if(IC==3.or.IC==4)then select case(iperiodic) case(0) read(ifilenum_data,rec=icount) ((( matbox_read2(ix,iy,iz),ix=ista_Mxin_datafile(1),iend_Mxin_datafile(1)), & iy=ista_Mxin_datafile(2),iend_Mxin_datafile(2)), & iz=ista_Mxin_datafile(3),iend_Mxin_datafile(3)) case(3) read(ifilenum_data,rec=icount) ((( cmatbox_read2(ix,iy,iz),ix=ista_Mxin_datafile(1),iend_Mxin_datafile(1)), & iy=ista_Mxin_datafile(2),iend_Mxin_datafile(2)), & iz=ista_Mxin_datafile(3),iend_Mxin_datafile(3)) end select end if end if icomm=nproc_group_global select case(iperiodic) case(0) call comm_summation(matbox_read2,matbox_read,ig_num(1)*ig_num(2)*ig_num(3),icomm) case(3) call comm_summation(cmatbox_read2,cmatbox_read,ig_num(1)*ig_num(2)*ig_num(3),icomm) end select if(icheck_corrkob==1)then if(iSCFRT==1)then select case(iperiodic) case(0) psi(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3),iob_myob,ik)= & matbox_read(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3)) case(3) zpsi(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3),iob_myob,ik)= & cmatbox_read(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3)) end select else if(iSCFRT==2)then select case(iperiodic) case(0) if(iwrite_projection==1)then zpsi_t0(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3),iob_myob,ik)= & matbox_read(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3)) else if((ilsda==0.and.p0<=MST(1)).or. & (ilsda==1.and.(p0<=MST0(1).and.p0<=MST(1)).or.(p0>MST0(1).and.p0<=MST0(1)+MST(2))))then zpsi_in(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3),iob_myob,ik)= & matbox_read(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3)) end if end if case(3) if(iwrite_projection==1)then zpsi_t0(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3),iob_myob,ik)= & cmatbox_read(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3)) else if((ilsda==0.and.p0<=MST(1)).or. & (ilsda==1.and.(p0<=MST0(1).and.p0<=MST(1)).or.(p0>MST0(1).and.p0<=MST0(1)+MST(2))))then zpsi_in(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3),iob_myob,ik)= & cmatbox_read(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3)) end if end if end select if(iwrite_projection==1)then if((ilsda==0.and.p0<=MST(1)).or. & (ilsda==1.and.(p0<=MST0(1).and.p0<=MST(1)).or.(p0>MST0(1).and.p0<=MST0(1)+MST(2))))then zpsi_in(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3),iob_myob,ik)= & zpsi_t0(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2), & mg_sta(3):mg_end(3),iob_myob,ik) end if end if end if end if end do end do end do if(iSCFRT==1.and.itotMST>itotMST0) call init_wf_ns(2) if(IC<=2)then call read_copy_pot(rho,matbox_read,ig_sta,ig_end) if(version_num_box(1)<=29.or.(version_num_box(1)==30.and.version_num_box(2)<=18))then if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if if(iSCFRT==1)then call comm_bcast(matbox_read,nproc_group_global) do iz=ng_sta(3),ng_end(3) do iy=ng_sta(2),ng_end(2) do ix=ng_sta(1),ng_end(1) rho_in(ix,iy,iz,num_rho_stock+1)=matbox_read(ix,iy,iz) end do end do end do end if if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if if(iSCFRT==1)then call comm_bcast(matbox_read,nproc_group_global) do iz=ng_sta(3),ng_end(3) do iy=ng_sta(2),ng_end(2) do ix=ng_sta(1),ng_end(1) rho_out(ix,iy,iz,num_rho_stock)=matbox_read(ix,iy,iz) end do end do end do end if if(ilsda == 1)then do is=1,2 if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if call comm_bcast(matbox_read,nproc_group_global) do iz=mg_sta(3),mg_end(3) do iy=mg_sta(2),mg_end(2) do ix=mg_sta(1),mg_end(1) rho_s(ix,iy,iz,is)=matbox_read(ix,iy,iz) end do end do end do if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if call comm_bcast(matbox_read,nproc_group_global) do iz=ng_sta(3),ng_end(3) do iy=ng_sta(2),ng_end(2) do ix=ng_sta(1),ng_end(1) rho_s_in(ix,iy,iz,num_rho_stock,is)=matbox_read(ix,iy,iz) end do end do end do if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if call comm_bcast(matbox_read,nproc_group_global) do iz=ng_sta(3),ng_end(3) do iy=ng_sta(2),ng_end(2) do ix=ng_sta(1),ng_end(1) rho_s_out(ix,iy,iz,num_rho_stock,is)=matbox_read(ix,iy,iz) end do end do end do end do end if else do ii=1,num_rho_stock+1 if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if if(iSCFRT==1)then call comm_bcast(matbox_read,nproc_group_global) do iz=ng_sta(3),ng_end(3) do iy=ng_sta(2),ng_end(2) do ix=ng_sta(1),ng_end(1) rho_in(ix,iy,iz,ii)=matbox_read(ix,iy,iz) end do end do end do end if end do do ii=1,num_rho_stock if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if if(iSCFRT==1)then call comm_bcast(matbox_read,nproc_group_global) do iz=ng_sta(3),ng_end(3) do iy=ng_sta(2),ng_end(2) do ix=ng_sta(1),ng_end(1) rho_out(ix,iy,iz,ii)=matbox_read(ix,iy,iz) end do end do end do end if end do if(ilsda == 1)then do is=1,2 if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if call comm_bcast(matbox_read,nproc_group_global) do iz=mg_sta(3),mg_end(3) do iy=mg_sta(2),mg_end(2) do ix=mg_sta(1),mg_end(1) rho_s(ix,iy,iz,is)=matbox_read(ix,iy,iz) end do end do end do do ii=1,num_rho_stock+1 if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if if(iSCFRT==1)then call comm_bcast(matbox_read,nproc_group_global) do iz=ng_sta(3),ng_end(3) do iy=ng_sta(2),ng_end(2) do ix=ng_sta(1),ng_end(1) rho_s_in(ix,iy,iz,ii,is)=matbox_read(ix,iy,iz) end do end do end do end if end do do ii=1,num_rho_stock if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if if(iSCFRT==1)then call comm_bcast(matbox_read,nproc_group_global) do iz=ng_sta(3),ng_end(3) do iy=ng_sta(2),ng_end(2) do ix=ng_sta(1),ng_end(1) rho_s_out(ix,iy,iz,ii,is)=matbox_read(ix,iy,iz) end do end do end do end if end do end do end if end if end if if(comm_is_root(nproc_id_global))then read(96) esp0(:itotMST0,:num_kpoints_rd),rocc0(:itotMST0,:num_kpoints_rd) if(itotMST0>=itotMST)then if(ilsda == 0)then is_sta=1 is_end=1 pstart(1)=1 pend(1)=itotMST else if(ilsda == 1)then is_sta=1 is_end=2 pstart(1)=1 pend(1)=MST(1) pstart(2)=MST(1)+1 pend(2)=itotMST end if do ik=1,num_kpoints_rd do is=is_sta,is_end do iob=pstart(is),pend(is) call conv_p(iob,p0) esp(iob,ik)=esp0(p0,ik) rocc(iob,ik)=rocc0(p0,ik) end do end do end do else if(ilsda == 0)then is_sta=1 is_end=1 pstart(1)=1 pend(1)=itotMST0 else if(ilsda == 1)then is_sta=1 is_end=2 pstart(1)=1 pend(1)=MST0(1) pstart(2)=MST0(1)+1 pend(2)=itotMST0 end if esp(:,:)=0.d0 rocc(:,:)=0.d0 do ik=1,num_kpoints_rd do is=is_sta,is_end do iob=pstart(is),pend(is) call conv_p0(p0,iob) esp(p0,ik)=esp0(iob,ik) rocc(p0,ik)=rocc0(iob,ik) end do end do end do end if end if if(IC<=2)then call read_copy_pot(Vh,matbox_read,ig_sta,ig_end) if(ilsda == 0)then call read_copy_pot(Vxc,matbox_read,ig_sta,ig_end) else if(ilsda == 1)then do is=1,2 if(comm_is_root(nproc_id_global))then read(96) ((( matbox_read(ix,iy,iz),ix=ig_sta(1),ig_end(1)),iy=ig_sta(2),ig_end(2)),iz=ig_sta(3),ig_end(3)) end if call comm_bcast(matbox_read,nproc_group_global) do iz=mg_sta(3),mg_end(3) do iy=mg_sta(2),mg_end(2) do ix=mg_sta(1),mg_end(1) Vxc_s(ix,iy,iz,is)=matbox_read(ix,iy,iz) end do end do end do end do end if call read_copy_pot(Vpsl,matbox_read,ig_sta,ig_end) end if if(comm_is_root(nproc_id_global))then if(version_num_box(1)<=31)then if(iflag_ps.eq.1)then read(96) read(96) Mlps(:MKI),Lref(:MKI) end if end if close(96) end if call comm_bcast(rocc,nproc_group_global) call comm_bcast(esp,nproc_group_global) if(version_num_box(1)<=31)then if(iflag_ps.eq.1)then call comm_bcast(Mlps,nproc_group_global) call comm_bcast(Lref,nproc_group_global) end if end if if(iSCFRT==2)then allocate(Vh_stock1(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3))) allocate(Vh_stock2(mg_sta(1):mg_end(1),mg_sta(2):mg_end(2),mg_sta(3):mg_end(3))) !$OMP parallel do private(iz,iy,ix) do iz=mg_sta(3),mg_end(3) do iy=mg_sta(2),mg_end(2) do ix=mg_sta(1),mg_end(1) Vh_stock1(ix,iy,iz) = Vh(ix,iy,iz) Vh_stock2(ix,iy,iz) = Vh(ix,iy,iz) end do end do end do end if call allgatherv_vlocal deallocate( esp0,rocc0 ) deallocate(matbox,matbox2,matbox3) deallocate(cmatbox,cmatbox2) END SUBROUTINE IN_data
src/GCEED/common/OUT_IN_data.f90
C---------------------------------------------------------------------- SUBROUTINE HWURSC(NP,PP) C RESCALES A SET OF NP (<21) 3-MOMENTA PP(1-3,*) IN C THEIR CMF TO PUT PP ON MASS-SHELL AT MASSES PP(5,*) C---------------------------------------------------------------------- IMPLICIT NONE INTEGER NP,IP,IT,NT DOUBLE PRECISION PP(5,*),P(5,20),P2(20),M2(20),SP(5), & TINY,FAC,ECM,DCM,EP,STEP,FRT,HWUSQR DATA TINY,NT/1D-9,20/ IF (NP.GT.20) CALL HWWARN('HWURSC',300+NP) C--COMPUTE CM MOMENTUM CALL HWVZRO(4,SP) DO IP=1,NP CALL HWVSUM(4,PP(1,IP),SP,SP) ENDDO CALL HWUMAS(SP) C--BOOST TO CMF DO IP=1,NP CALL HWULOF(SP,PP(1,IP),P(1,IP)) P2(IP)=P(1,IP)**2+P(2,IP)**2+P(3,IP)**2 M2(IP)=P(5,IP)**2 ENDDO C--ITERATE RESCALING OF 3-MOMENTA FAC=1D0 DO IT=1,NT ECM=0D0 DCM=0D0 DO IP=1,NP EP=HWUSQR(M2(IP)+FAC*P2(IP)) IF (EP.GT.0D0) THEN ECM=ECM+EP DCM=DCM+P2(IP)/EP ENDIF ENDDO IF (DCM.EQ.0D0) CALL HWWARN('HWURSC',390) STEP=2D0*(ECM-SP(5))/DCM FAC=FAC-STEP IF (ABS(STEP).LT.TINY) GOTO 100 ENDDO C--FAILED TO CONVERGE CALL HWWARN('HWURSC',1) C--CONVERGED: RESCALE 3-MOMENTA AND BOOST BACK 100 IF (FAC.LT.0D0) CALL HWWARN('HWURSC',391) FRT=SQRT(FAC) DO IP=1,NP CALL HWVSCA(3,FRT,P(1,IP),P(1,IP)) P(4,IP)=SQRT(M2(IP)+FAC*P2(IP)) CALL HWULOB(SP,P(1,IP),PP(1,IP)) ENDDO END
GeneratorInterface/MCatNLOInterface/plugins/mcatnlo_hwursc.f
module ThermalModelM use UtilitiesM use SparseKit use MeshM use ModelM use HeatFluxM implicit none private public :: ThermalModelDT, thermalModel type, extends(modelDT) :: ThermalModelDT type(Sparse) :: lhs real(rkind), dimension(:) , allocatable :: rhs real(rkind), dimension(:) , allocatable :: dof type(HeatFluxDT) :: heatFlux contains procedure, public :: init procedure, public :: freeSystem end type ThermalModelDT interface thermalModel procedure :: constructor end interface thermalModel contains type(ThermalModelDT) function constructor(nDof, nnz, id, nNode, nElement, nCondition) implicit none integer(ikind), intent(in) :: nDof integer(ikind), intent(in) :: nnz integer(ikind), intent(in) :: id integer(ikind), intent(in) :: nNode integer(ikind), intent(in) :: nElement integer(ikind), intent(in) :: nCondition call constructor%init(nDof, nnz, id, nNode, nElement, nCondition) end function constructor subroutine init(this, nDof, nnz, id, nNode, nElement, nCondition) implicit none class(ThermalModelDT), intent(inout) :: this integer(ikind) , intent(in) :: nDof integer(ikind) , intent(in) :: nnz integer(ikind) , intent(in) :: id integer(ikind) , intent(in) :: nNode integer(ikind) , intent(in) :: nElement integer(ikind) , intent(in) :: nCondition this%lhs = sparse(nnz, nDof) allocate(this%rhs(nDof)) allocate(this%dof(nDof)) call this%initModel(1) !una sola malla en el modelo this%mesh(1) = mesh(id, nNode, nElement, nCondition) end subroutine init subroutine freeSystem(this) implicit none class(ThermalModelDT), intent(inout) :: this call this%lhs%free() if(allocated(this%rhs)) deallocate(this%rhs) end subroutine freeSystem end module ThermalModelM
applications/Thermal3D/src/Model/ThermalModel.f90
! { dg-do compile } ! ! PR 60231: [4.8/4.9 Regression] ICE on undefined generic ! ! Contributed by Antony Lewis <[email protected]> module Objects Type TObjectList contains procedure :: Add1 ! { dg-error "must be a module procedure" } procedure :: Add2 ! { dg-error "must be a module procedure" } generic :: Add => Add1, Add2 ! { dg-error "are ambiguous" } end Type end module
validation_tests/llvm/f18/gfortran.dg/typebound_generic_15.f90
C Copyright (C) 2002, Carnegie Mellon University and others. C All Rights Reserved. C This code is published under the Common Public License. C******************************************************************************* C subroutine INIT_MEM(NORIG, XORIG, N, NIND, M, NLB, NUB, NZORIG, 1 KCONSTR, LRS_END, LIS_END, LRW, RW, LIW, IW, IERR) C C******************************************************************************* C C $Id: init_mem.f,v 1.4 2002/11/24 21:42:10 andreasw Exp $ C C------------------------------------------------------------------------------- C Title C------------------------------------------------------------------------------- C CT Main (outer) loop of algorithm C C------------------------------------------------------------------------------- C Programm description C------------------------------------------------------------------------------- C CB C C------------------------------------------------------------------------------- C Author, date C------------------------------------------------------------------------------- C CA Andreas Waechter 05/01/02 Release as version IPOPT 2.0 C C------------------------------------------------------------------------------- C Documentation C------------------------------------------------------------------------------- C CD C C------------------------------------------------------------------------------- C Parameter list C------------------------------------------------------------------------------- C C Name I/O Type Meaning CP NORIG I INT total number of variables (incl. fixed vars) CP XORIG I DP initial values of variables (incl. fixed vars) CP N I INT number of variables (without fixed) CP NIND I INT number of independent variables CP M I INT number of constraints CP NLB I INT number of lower bounds (excluding fixed vars) CP NUB I INT number of upper bounds (excluding fixed vars) CP NZORIG I INT number of nonzeros in Jacobian of constraints CP (including rows to fixed variables!) CP KCONSTR I INT KCONSTR(1): LRS for CONSTR CP LRS_END I/O INT last used reserved entry in RS CP LRS_END I/O INT last used reserved entry in IS CP LRW I INT length of RW CP RW I/O DP can be used as DP work space but content will be CP changed between calls CP LIW I INT length of IW CP IW I/O INT can be used as INT work space but content will be CP changed between calls CP IERR O INT =0: everything OK CP >0: Error occured; abort optimization CP <0: Warning; message to user C C------------------------------------------------------------------------------- C local variables C------------------------------------------------------------------------------- C CL C C------------------------------------------------------------------------------- C used subroutines C------------------------------------------------------------------------------- C CS CONSTR CS MAINLOOP CS LINESEARCH CS EXTRAPOL C C******************************************************************************* C C Declarations C C******************************************************************************* C IMPLICIT NONE C C******************************************************************************* C C Include files C C******************************************************************************* C include 'IPOPT.INC' include 'TIMER.INC' C C------------------------------------------------------------------------------- C Parameter list C------------------------------------------------------------------------------- C integer NORIG double precision XORIG(NORIG) integer N integer NIND integer M integer NLB integer NUB integer NZORIG integer KCONSTR(6) integer LRS_END integer LIS_END integer LRW double precision RW(LRW) integer LIW integer IW(LIW) integer IERR C C------------------------------------------------------------------------------- C Local variables C------------------------------------------------------------------------------- C integer lrs_constr, lis_constr, lrw_constr, liw_constr integer idummy double precision dummy logical ldummy character*1 cdummy character*80 line C C******************************************************************************* C C Executable Statements C C******************************************************************************* C C C Initialize CPU times C TIME_BB = 0.d0 TIME_CG = 0.d0 TIME_YPY = 0.d0 TIME_EXACTW = 0.d0 TIME_ZWZY_BACKS = 0.d0 TIME_ZWZY_EVALA = 0.d0 TIME_PZ_CHOL = 0.d0 TIME_HV = 0.d0 COUNT_CG = 0 COUNT_RESTO_ITER = 0 COUNT_NEG_CURV = 0 COUNT_RESTO_CALL = 0 COUNT_TRON_CG = 0 COUNT_HV = 0 COUNT_DEPCON = 0 C C call subroutines to initialize their pointers for the storage space C C C CONSTR C if( M.ne.0 ) then lrw_constr = LRW liw_constr = LIW call CONSTR(0, idummy, N, NIND, M, idummy, idummy, idummy, 1 NORIG, XORIG, dummy, dummy, dummy, NZORIG, 2 idummy, lrs_constr, dummy, lis_constr, idummy, 3 lrw_constr, RW, liw_constr, IW, IERR) if( IERR.ne.0 ) then write(line,*) 'init_mem: CONSTR returns IERR = ', IERR call C_OUT(2,0,1,line) goto 9999 endif KCONSTR(1) = lrs_constr KCONSTR(3) = lis_constr KCONSTR(5) = lrw_constr KCONSTR(6) = liw_constr KCONSTR(2) = LRS_END LRS_END = KCONSTR(2) + lrs_constr KCONSTR(4) = LIS_END LIS_END = KCONSTR(4) + lis_constr else NZORIG = 0 endif write(line,1000) NZORIG 1000 format('Number of nonzeros in Jacobian: ',i8) call C_OUT(2,0,1,line) C C MAINLOOP C call MAINLOOP(-1, N, NIND, M, NORIG, dummy, 1 idummy, dummy, idummy, idummy, NLB, idummy, NUB, 2 idummy, dummy, dummy, NZORIG, dummy, 1 dummy, dummy, dummy, idummy, idummy, 3 LRS_END, dummy, idummy, LIS_END, idummy, 4 idummy, dummy, idummy, idummy, IERR) C C LINESEARCH C if( abs(QMERIT).eq.1 .or. abs(QMERIT).eq.2 .or. 1 (QMERIT.eq.3.and.QAUGITER.gt.0) ) then call LINESEARCH(-1, N, NIND, M, dummy, idummy, NLB, idummy, 1 NUB, idummy, ldummy, dummy, dummy, dummy, dummy, dummy, 2 dummy, dummy, dummy, dummy, dummy, dummy, NORIG, 3 dummy, dummy, dummy, dummy, dummy, dummy, dummy, 4 dummy, dummy, dummy, dummy, dummy, dummy, dummy, 2 dummy, dummy, dummy, ldummy, dummy, dummy, idummy, 5 cdummy, dummy, ldummy, idummy, idummy, 5 idummy, LRS_END, dummy, idummy, LIS_END, 6 idummy, idummy, dummy, idummy, idummy, IERR) endif if( abs(QMERIT).ge.4 ) then call FILTER(-1, N, NIND, M, dummy, idummy, idummy, idummy, 1 NLB, idummy, 1 NUB, idummy, ldummy, dummy, dummy, dummy, dummy, 2 dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, 3 NORIG, dummy, dummy, dummy, dummy, dummy, dummy, dummy, 4 dummy, dummy, dummy, dummy, dummy, dummy, ldummy, idummy, 5 dummy, cdummy, cdummy, idummy, ldummy, idummy, 5 LRS_END, dummy, LIS_END, 6 idummy, idummy, dummy, idummy, idummy, IERR) endif if( abs(QMERIT).ge.4 ) then if( QRESTO.eq.2 .or. abs(QRESTO).eq.3 ) then call RESTO_TRON(-1, N, NIND, M, NORIG, XORIG, 1 dummy, idummy, idummy, idummy, NLB, idummy, NUB, 1 idummy, dummy, dummy, dummy, dummy, dummy, NZORIG, 1 dummy, dummy, dummy, ldummy, dummy, dummy, 1 dummy, dummy, dummy, dummy, dummy, dummy, dummy, 1 dummy, dummy, dummy, 1 idummy, LRS_END, dummy, LIS_END, idummy, 1 idummy, dummy, idummy, idummy, IERR) endif endif C C GET_STEP_FULL C if( QFULL.ne.0 ) then call GET_STEP_FULL(-1, NORIG, N, NIND, M, NZORIG, dummy, 1 XORIG, dummy, dummy, NLB, idummy, NUB, idummy, idummy, 1 idummy, idummy, dummy, dummy, 1 dummy, dummy, dummy, dummy, dummy, dummy, ldummy, 1 dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, 1 dummy, dummy, 1 dummy, dummy, cdummy, ldummy, idummy, dummy, dummy, dummy, 1 dummy, dummy, dummy, idummy, dummy, dummy, ldummy, idummy, 1 idummy, ldummy, idummy, idummy, LRS_END, dummy, idummy, 1 LIS_END, idummy, idummy, dummy, idummy, idummy, IERR) endif C C ERROR (just for initialization of LASTITER) C call ERROR(N, NIND, M, dummy, dummy, dummy, dummy, dummy, dummy, 1 NLB, idummy, NUB, idummy, dummy, dummy, dummy, dummy, 1 dummy, dummy, dummy, dummy, dummy, dummy, ldummy, 2 dummy, cdummy, dummy, dummy, dummy, dummy, -1, idummy, 1 idummy, idummy, NORIG, dummy, 1 dummy, KCONSTR, idummy, dummy, idummy, idummy, 1 idummy, dummy, idummy, idummy, IERR) C C GET_HV C call GET_HV(-1, N, NIND, idummy, idummy, dummy, idummy, NORIG, 1 XORIG, NLB, idummy, NUB, idummy, dummy, dummy, 2 dummy, M, dummy, dummy, dummy, 2 KCONSTR, idummy, dummy, idummy, idummy, idummy, dummy, 3 idummy, idummy, IERR) C C GET_YPY (for orthogonal decomposition) C call GET_YPY(NZORIG, idummy, idummy, -1, idummy, idummy, idummy, 1 NORIG, dummy, dummy, idummy, idummy, idummy, idummy, 2 dummy, dummy, dummy, ldummy, idummy, 3 dummy, dummy, dummy, ldummy, dummy, 4 KCONSTR, idummy, dummy, idummy, idummy, 5 idummy, dummy, idummy, idummy, IERR) C 9999 continue return end
gsa/wit/COIN/Ipopt/SOURCES/IPOPT/ipopt/init_mem.f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!! !!!! MIT License !!!! !!!! ParaMonte: plain powerful parallel Monte Carlo library. !!!! !!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!! !!!! This file is part of the ParaMonte library. !!!! !!!! Permission is hereby granted, free of charge, to any person obtaining a !!!! copy of this software and associated documentation files (the "Software"), !!!! to deal in the Software without restriction, including without limitation !!!! the rights to use, copy, modify, merge, publish, distribute, sublicense, !!!! and/or sell copies of the Software, and to permit persons to whom the !!!! Software is furnished to do so, subject to the following conditions: !!!! !!!! The above copyright notice and this permission notice shall be !!!! included in all copies or substantial portions of the Software. !!!! !!!! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, !!!! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF !!!! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. !!!! IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, !!!! DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR !!!! OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE !!!! OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. !!!! !!!! ACKNOWLEDGMENT !!!! !!!! ParaMonte is an honor-ware and its currency is acknowledgment and citations. !!!! As per the ParaMonte library license agreement terms, if you use any parts of !!!! this library for any purposes, kindly acknowledge the use of ParaMonte in your !!!! work (education/research/industry/development/...) by citing the ParaMonte !!!! library as described on this page: !!!! !!!! https://github.com/cdslaborg/paramonte/blob/master/ACKNOWLEDGMENT.md !!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! use Constants_mod, only: IK, RK use Err_mod, only: Err_type implicit none #if defined PARADRAM character(*), parameter :: MODULE_NAME = "@ParaDRAMProposal_mod" #elif defined PARADISE character(*), parameter :: MODULE_NAME = "@ParaDISEProposal_mod" #endif type(Err_type), save :: ProposalErr !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% type, abstract :: ProposalAbstract_type contains procedure(getNew_proc) , nopass , deferred :: getNew procedure(getLogProb_proc) , nopass , deferred :: getLogProb procedure(doAdaptation_proc) , nopass , deferred :: doAdaptation !procedure(readRestartFileAscii_proc) , nopass , deferred :: readRestartFileAscii !procedure(writeRestartFileAscii_proc) , nopass , deferred :: writeRestartFileAscii #if defined CAF_ENABLED || defined MPI_ENABLED procedure(bcastAdaptation_proc) , nopass , deferred :: bcastAdaptation #endif end type ProposalAbstract_type !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #if defined CAF_ENABLED || defined MPI_ENABLED abstract interface subroutine bcastAdaptation_proc() end subroutine bcastAdaptation_proc end interface #endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% abstract interface function getNew_proc( nd & , counterDRS & , StateOld & ) result (StateNew) use Constants_mod, only: IK, RK import :: ProposalAbstract_type !class(ProposalAbstract_type), intent(inout) :: Proposal integer(IK), intent(in) :: nd integer(IK), intent(in) :: counterDRS real(RK) , intent(in) :: StateOld(nd) real(RK) :: StateNew(nd) end function getNew_proc end interface !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% abstract interface function getLogProb_proc( nd & , counterDRS & , StateOld & , StateNew & ) result (logProb) use Constants_mod, only: IK, RK import :: ProposalAbstract_type integer(IK), intent(in) :: nd integer(IK), intent(in) :: counterDRS real(RK) , intent(in) :: StateOld(nd) real(RK) , intent(in) :: StateNew(nd) real(RK) :: logProb end function getLogProb_proc end interface !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% abstract interface subroutine doAdaptation_proc( nd & , chainSize & , Chain & , ChainWeight & , isFreshRun & , samplerUpdateIsGreedy & , meanAccRateSinceStart & , samplerUpdateSucceeded & , adaptationMeasure & ) use Constants_mod, only: IK, RK import :: ProposalAbstract_type !class(ProposalAbstract_type), intent(inout) :: Proposal integer(IK), intent(in) :: nd integer(IK), intent(in) :: chainSize real(RK) , intent(in) :: Chain(nd,chainSize) integer(IK), intent(in) :: ChainWeight(chainSize) logical , intent(in) :: isFreshRun logical , intent(in) :: samplerUpdateIsGreedy real(RK) , intent(inout) :: meanAccRateSinceStart logical , intent(out) :: samplerUpdateSucceeded real(RK) , intent(out) :: adaptationMeasure end subroutine doAdaptation_proc end interface !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !abstract interface !subroutine readRestartFileAscii_proc() !end subroutine readRestartFileAscii_proc !end interface !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !abstract interface !subroutine writeRestartFileAscii_proc() !end subroutine writeRestartFileAscii_proc !end interface !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
src/ParaMonte/ParaDRAMProposalAbstract_mod.inc.f90
module msise00_data private public :: parm7g, ptm, pdm, pavgm, imr C MSISE-00 01-FEB-02 COMMON/PARM7g/PT1(50),PT2(50),PT3(50),PA1(50),PA2(50),PA3(50), $ PB1(50),PB2(50),PB3(50),PC1(50),PC2(50),PC3(50), $ PD1(50),PD2(50),PD3(50),PE1(50),PE2(50),PE3(50), $ PF1(50),PF2(50),PF3(50),PG1(50),PG2(50),PG3(50), $ PH1(50),PH2(50),PH3(50),PI1(50),PI2(50),PI3(50), $ PJ1(50),PJ2(50),PJ3(50),PK1(50),PL1(50),PL2(50), $ PM1(50),PM2(50),PN1(50),PN2(50),PO1(50),PO2(50), $ PP1(50),PP2(50),PQ1(50),PQ2(50),PR1(50),PR2(50), $ PS1(50),PS2(50),PU1(50),PU2(50),PV1(50),PV2(50), $ PW1(50),PW2(50),PX1(50),PX2(50),PY1(50),PY2(50), $ PZ1(50),PZ2(50),PAA1(50),PAA2(50) real :: PTM(10),PDM(10,8) real :: PAVGM(10) integer :: IMR = 0 C TEMPERATURE DATA PT1/ * 9.86573E-01, 1.62228E-02, 1.55270E-02,-1.04323E-01,-3.75801E-03, * -1.18538E-03,-1.24043E-01, 4.56820E-03, 8.76018E-03,-1.36235E-01, * -3.52427E-02, 8.84181E-03,-5.92127E-03,-8.61650E+00, 0.00000E+00, * 1.28492E-02, 0.00000E+00, 1.30096E+02, 1.04567E-02, 1.65686E-03, * -5.53887E-06, 2.97810E-03, 0.00000E+00, 5.13122E-03, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00,-7.27026E-06, * 0.00000E+00, 6.74494E+00, 4.93933E-03, 2.21656E-03, 2.50802E-03, * 0.00000E+00, 0.00000E+00,-2.08841E-02,-1.79873E+00, 1.45103E-03, * 2.81769E-04,-1.44703E-03,-5.16394E-05, 8.47001E-02, 1.70147E-01, * 5.72562E-03, 5.07493E-05, 4.36148E-03, 1.17863E-04, 4.74364E-03/ DATA PT2/ * 6.61278E-03, 4.34292E-05, 1.44373E-03, 2.41470E-05, 2.84426E-03, * 8.56560E-04, 2.04028E-03, 0.00000E+00,-3.15994E+03,-2.46423E-03, * 1.13843E-03, 4.20512E-04, 0.00000E+00,-9.77214E+01, 6.77794E-03, * 5.27499E-03, 1.14936E-03, 0.00000E+00,-6.61311E-03,-1.84255E-02, * -1.96259E-02, 2.98618E+04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 6.44574E+02, 8.84668E-04, 5.05066E-04, 0.00000E+00, 4.02881E+03, * -1.89503E-03, 0.00000E+00, 0.00000E+00, 8.21407E-04, 2.06780E-03, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * -1.20410E-02,-3.63963E-03, 9.92070E-05,-1.15284E-04,-6.33059E-05, * -6.05545E-01, 8.34218E-03,-9.13036E+01, 3.71042E-04, 0.00000E+00/ DATA PT3/ * 4.19000E-04, 2.70928E-03, 3.31507E-03,-4.44508E-03,-4.96334E-03, * -1.60449E-03, 3.95119E-03, 2.48924E-03, 5.09815E-04, 4.05302E-03, * 2.24076E-03, 0.00000E+00, 6.84256E-03, 4.66354E-04, 0.00000E+00, * -3.68328E-04, 0.00000E+00, 0.00000E+00,-1.46870E+02, 0.00000E+00, * 0.00000E+00, 1.09501E-03, 4.65156E-04, 5.62583E-04, 3.21596E+00, * 6.43168E-04, 3.14860E-03, 3.40738E-03, 1.78481E-03, 9.62532E-04, * 5.58171E-04, 3.43731E+00,-2.33195E-01, 5.10289E-04, 0.00000E+00, * 0.00000E+00,-9.25347E+04, 0.00000E+00,-1.99639E-03, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C HE DENSITY DATA PA1/ * 1.09979E+00,-4.88060E-02,-1.97501E-01,-9.10280E-02,-6.96558E-03, * 2.42136E-02, 3.91333E-01,-7.20068E-03,-3.22718E-02, 1.41508E+00, * 1.68194E-01, 1.85282E-02, 1.09384E-01,-7.24282E+00, 0.00000E+00, * 2.96377E-01,-4.97210E-02, 1.04114E+02,-8.61108E-02,-7.29177E-04, * 1.48998E-06, 1.08629E-03, 0.00000E+00, 0.00000E+00, 8.31090E-02, * 1.12818E-01,-5.75005E-02,-1.29919E-02,-1.78849E-02,-2.86343E-06, * 0.00000E+00,-1.51187E+02,-6.65902E-03, 0.00000E+00,-2.02069E-03, * 0.00000E+00, 0.00000E+00, 4.32264E-02,-2.80444E+01,-3.26789E-03, * 2.47461E-03, 0.00000E+00, 0.00000E+00, 9.82100E-02, 1.22714E-01, * -3.96450E-02, 0.00000E+00,-2.76489E-03, 0.00000E+00, 1.87723E-03/ DATA PA2/ * -8.09813E-03, 4.34428E-05,-7.70932E-03, 0.00000E+00,-2.28894E-03, * -5.69070E-03,-5.22193E-03, 6.00692E-03,-7.80434E+03,-3.48336E-03, * -6.38362E-03,-1.82190E-03, 0.00000E+00,-7.58976E+01,-2.17875E-02, * -1.72524E-02,-9.06287E-03, 0.00000E+00, 2.44725E-02, 8.66040E-02, * 1.05712E-01, 3.02543E+04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * -6.01364E+03,-5.64668E-03,-2.54157E-03, 0.00000E+00, 3.15611E+02, * -5.69158E-03, 0.00000E+00, 0.00000E+00,-4.47216E-03,-4.49523E-03, * 4.64428E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 4.51236E-02, 2.46520E-02, 6.17794E-03, 0.00000E+00, 0.00000E+00, * -3.62944E-01,-4.80022E-02,-7.57230E+01,-1.99656E-03, 0.00000E+00/ DATA PA3/ * -5.18780E-03,-1.73990E-02,-9.03485E-03, 7.48465E-03, 1.53267E-02, * 1.06296E-02, 1.18655E-02, 2.55569E-03, 1.69020E-03, 3.51936E-02, * -1.81242E-02, 0.00000E+00,-1.00529E-01,-5.10574E-03, 0.00000E+00, * 2.10228E-03, 0.00000E+00, 0.00000E+00,-1.73255E+02, 5.07833E-01, * -2.41408E-01, 8.75414E-03, 2.77527E-03,-8.90353E-05,-5.25148E+00, * -5.83899E-03,-2.09122E-02,-9.63530E-03, 9.77164E-03, 4.07051E-03, * 2.53555E-04,-5.52875E+00,-3.55993E-01,-2.49231E-03, 0.00000E+00, * 0.00000E+00, 2.86026E+01, 0.00000E+00, 3.42722E-04, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C O DENSITY DATA PB1/ * 1.02315E+00,-1.59710E-01,-1.06630E-01,-1.77074E-02,-4.42726E-03, * 3.44803E-02, 4.45613E-02,-3.33751E-02,-5.73598E-02, 3.50360E-01, * 6.33053E-02, 2.16221E-02, 5.42577E-02,-5.74193E+00, 0.00000E+00, * 1.90891E-01,-1.39194E-02, 1.01102E+02, 8.16363E-02, 1.33717E-04, * 6.54403E-06, 3.10295E-03, 0.00000E+00, 0.00000E+00, 5.38205E-02, * 1.23910E-01,-1.39831E-02, 0.00000E+00, 0.00000E+00,-3.95915E-06, * 0.00000E+00,-7.14651E-01,-5.01027E-03, 0.00000E+00,-3.24756E-03, * 0.00000E+00, 0.00000E+00, 4.42173E-02,-1.31598E+01,-3.15626E-03, * 1.24574E-03,-1.47626E-03,-1.55461E-03, 6.40682E-02, 1.34898E-01, * -2.42415E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, 6.13666E-04/ DATA PB2/ * -5.40373E-03, 2.61635E-05,-3.33012E-03, 0.00000E+00,-3.08101E-03, * -2.42679E-03,-3.36086E-03, 0.00000E+00,-1.18979E+03,-5.04738E-02, * -2.61547E-03,-1.03132E-03, 1.91583E-04,-8.38132E+01,-1.40517E-02, * -1.14167E-02,-4.08012E-03, 1.73522E-04,-1.39644E-02,-6.64128E-02, * -6.85152E-02,-1.34414E+04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 6.07916E+02,-4.12220E-03,-2.20996E-03, 0.00000E+00, 1.70277E+03, * -4.63015E-03, 0.00000E+00, 0.00000E+00,-2.25360E-03,-2.96204E-03, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 3.92786E-02, 1.31186E-02,-1.78086E-03, 0.00000E+00, 0.00000E+00, * -3.90083E-01,-2.84741E-02,-7.78400E+01,-1.02601E-03, 0.00000E+00/ DATA PB3/ * -7.26485E-04,-5.42181E-03,-5.59305E-03, 1.22825E-02, 1.23868E-02, * 6.68835E-03,-1.03303E-02,-9.51903E-03, 2.70021E-04,-2.57084E-02, * -1.32430E-02, 0.00000E+00,-3.81000E-02,-3.16810E-03, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-9.05762E-04,-2.14590E-03,-1.17824E-03, 3.66732E+00, * -3.79729E-04,-6.13966E-03,-5.09082E-03,-1.96332E-03,-3.08280E-03, * -9.75222E-04, 4.03315E+00,-2.52710E-01, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C N2 DENSITY DATA PC1/ * 1.16112E+00, 0.00000E+00, 0.00000E+00, 3.33725E-02, 0.00000E+00, * 3.48637E-02,-5.44368E-03, 0.00000E+00,-6.73940E-02, 1.74754E-01, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.74712E+02, 0.00000E+00, * 1.26733E-01, 0.00000E+00, 1.03154E+02, 5.52075E-02, 0.00000E+00, * 0.00000E+00, 8.13525E-04, 0.00000E+00, 0.00000E+00, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-2.50482E+01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-2.48894E-03, * 6.16053E-04,-5.79716E-04, 2.95482E-03, 8.47001E-02, 1.70147E-01, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PC2/ * 0.00000E+00, 2.47425E-05, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PC3/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C TLB DATA PD1/ * 9.44846E-01, 0.00000E+00, 0.00000E+00,-3.08617E-02, 0.00000E+00, * -2.44019E-02, 6.48607E-03, 0.00000E+00, 3.08181E-02, 4.59392E-02, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.74712E+02, 0.00000E+00, * 2.13260E-02, 0.00000E+00,-3.56958E+02, 0.00000E+00, 1.82278E-04, * 0.00000E+00, 3.07472E-04, 0.00000E+00, 0.00000E+00, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 3.83054E-03, 0.00000E+00, 0.00000E+00, * -1.93065E-03,-1.45090E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-1.23493E-03, 1.36736E-03, 8.47001E-02, 1.70147E-01, * 3.71469E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PD2/ * 5.10250E-03, 2.47425E-05, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 3.68756E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PD3/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C O2 DENSITY DATA PE1/ * 1.35580E+00, 1.44816E-01, 0.00000E+00, 6.07767E-02, 0.00000E+00, * 2.94777E-02, 7.46900E-02, 0.00000E+00,-9.23822E-02, 8.57342E-02, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.38636E+01, 0.00000E+00, * 7.71653E-02, 0.00000E+00, 8.18751E+01, 1.87736E-02, 0.00000E+00, * 0.00000E+00, 1.49667E-02, 0.00000E+00, 0.00000E+00, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-3.67874E+02, 5.48158E-03, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 8.47001E-02, 1.70147E-01, * 1.22631E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PE2/ * 8.17187E-03, 3.71617E-05, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-2.10826E-03, * -3.13640E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * -7.35742E-02,-5.00266E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 1.94965E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PE3/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C AR DENSITY DATA PF1/ * 1.04761E+00, 2.00165E-01, 2.37697E-01, 3.68552E-02, 0.00000E+00, * 3.57202E-02,-2.14075E-01, 0.00000E+00,-1.08018E-01,-3.73981E-01, * 0.00000E+00, 3.10022E-02,-1.16305E-03,-2.07596E+01, 0.00000E+00, * 8.64502E-02, 0.00000E+00, 9.74908E+01, 5.16707E-02, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 3.46193E+02, 1.34297E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-3.48509E-03, * -1.54689E-04, 0.00000E+00, 0.00000E+00, 8.47001E-02, 1.70147E-01, * 1.47753E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PF2/ * 1.89320E-02, 3.68181E-05, 1.32570E-02, 0.00000E+00, 0.00000E+00, * 3.59719E-03, 7.44328E-03,-1.00023E-03,-6.50528E+03, 0.00000E+00, * 1.03485E-02,-1.00983E-03,-4.06916E-03,-6.60864E+01,-1.71533E-02, * 1.10605E-02, 1.20300E-02,-5.20034E-03, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * -2.62769E+03, 7.13755E-03, 4.17999E-03, 0.00000E+00, 1.25910E+04, * 0.00000E+00, 0.00000E+00, 0.00000E+00,-2.23595E-03, 4.60217E-03, * 5.71794E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * -3.18353E-02,-2.35526E-02,-1.36189E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 2.03522E-02,-6.67837E+01,-1.09724E-03, 0.00000E+00/ DATA PF3/ * -1.38821E-02, 1.60468E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.51574E-02, * -5.44470E-04, 0.00000E+00, 7.28224E-02, 6.59413E-02, 0.00000E+00, * -5.15692E-03, 0.00000E+00, 0.00000E+00,-3.70367E+03, 0.00000E+00, * 0.00000E+00, 1.36131E-02, 5.38153E-03, 0.00000E+00, 4.76285E+00, * -1.75677E-02, 2.26301E-02, 0.00000E+00, 1.76631E-02, 4.77162E-03, * 0.00000E+00, 5.39354E+00, 0.00000E+00,-7.51710E-03, 0.00000E+00, * 0.00000E+00,-8.82736E+01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C H DENSITY DATA PG1/ * 1.26376E+00,-2.14304E-01,-1.49984E-01, 2.30404E-01, 2.98237E-02, * 2.68673E-02, 2.96228E-01, 2.21900E-02,-2.07655E-02, 4.52506E-01, * 1.20105E-01, 3.24420E-02, 4.24816E-02,-9.14313E+00, 0.00000E+00, * 2.47178E-02,-2.88229E-02, 8.12805E+01, 5.10380E-02,-5.80611E-03, * 2.51236E-05,-1.24083E-02, 0.00000E+00, 0.00000E+00, 8.66784E-02, * 1.58727E-01,-3.48190E-02, 0.00000E+00, 0.00000E+00, 2.89885E-05, * 0.00000E+00, 1.53595E+02,-1.68604E-02, 0.00000E+00, 1.01015E-02, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.84552E-04, * -1.22181E-03, 0.00000E+00, 0.00000E+00, 8.47001E-02, 1.70147E-01, * -1.04927E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00,-5.91313E-03/ DATA PG2/ * -2.30501E-02, 3.14758E-05, 0.00000E+00, 0.00000E+00, 1.26956E-02, * 8.35489E-03, 3.10513E-04, 0.00000E+00, 3.42119E+03,-2.45017E-03, * -4.27154E-04, 5.45152E-04, 1.89896E-03, 2.89121E+01,-6.49973E-03, * -1.93855E-02,-1.48492E-02, 0.00000E+00,-5.10576E-02, 7.87306E-02, * 9.51981E-02,-1.49422E+04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 2.65503E+02, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 6.37110E-03, 3.24789E-04, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 6.14274E-02, 1.00376E-02,-8.41083E-04, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-1.27099E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PG3/ * -3.94077E-03,-1.28601E-02,-7.97616E-03, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-6.71465E-03,-1.69799E-03, 1.93772E-03, 3.81140E+00, * -7.79290E-03,-1.82589E-02,-1.25860E-02,-1.04311E-02,-3.02465E-03, * 2.43063E-03, 3.63237E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C N DENSITY DATA PH1/ * 7.09557E+01,-3.26740E-01, 0.00000E+00,-5.16829E-01,-1.71664E-03, * 9.09310E-02,-6.71500E-01,-1.47771E-01,-9.27471E-02,-2.30862E-01, * -1.56410E-01, 1.34455E-02,-1.19717E-01, 2.52151E+00, 0.00000E+00, * -2.41582E-01, 5.92939E-02, 4.39756E+00, 9.15280E-02, 4.41292E-03, * 0.00000E+00, 8.66807E-03, 0.00000E+00, 0.00000E+00, 8.66784E-02, * 1.58727E-01, 9.74701E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 6.70217E+01,-1.31660E-03, 0.00000E+00,-1.65317E-02, * 0.00000E+00, 0.00000E+00, 8.50247E-02, 2.77428E+01, 4.98658E-03, * 6.15115E-03, 9.50156E-03,-2.12723E-02, 8.47001E-02, 1.70147E-01, * -2.38645E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.37380E-03/ DATA PH2/ * -8.41918E-03, 2.80145E-05, 7.12383E-03, 0.00000E+00,-1.66209E-02, * 1.03533E-04,-1.68898E-02, 0.00000E+00, 3.64526E+03, 0.00000E+00, * 6.54077E-03, 3.69130E-04, 9.94419E-04, 8.42803E+01,-1.16124E-02, * -7.74414E-03,-1.68844E-03, 1.42809E-03,-1.92955E-03, 1.17225E-01, * -2.41512E-02, 1.50521E+04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 1.60261E+03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00,-3.54403E-04,-1.87270E-02, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 2.76439E-02, 6.43207E-03,-3.54300E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-2.80221E-02, 8.11228E+01,-6.75255E-04, 0.00000E+00/ DATA PH3/ * -1.05162E-02,-3.48292E-03,-6.97321E-03, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-1.45546E-03,-1.31970E-02,-3.57751E-03,-1.09021E+00, * -1.50181E-02,-7.12841E-03,-6.64590E-03,-3.52610E-03,-1.87773E-02, * -2.22432E-03,-3.93895E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C HOT O DENSITY DATA PI1/ * 6.04050E-02, 1.57034E+00, 2.99387E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-1.51018E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00,-8.61650E+00, 1.26454E-02, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 5.50878E-03, 0.00000E+00, 0.00000E+00, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 6.23881E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 8.47001E-02, 1.70147E-01, * -9.45934E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PI2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PI3/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C S PARAM DATA PJ1/ * 9.56827E-01, 6.20637E-02, 3.18433E-02, 0.00000E+00, 0.00000E+00, * 3.94900E-02, 0.00000E+00, 0.00000E+00,-9.24882E-03,-7.94023E-03, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.74712E+02, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 2.74677E-03, 0.00000E+00, 1.54951E-02, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00,-6.99007E-04, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 1.24362E-02,-5.28756E-03, 8.47001E-02, 1.70147E-01, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PJ2/ * 0.00000E+00, 2.47425E-05, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PJ3/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C TURBO DATA PK1/ * 1.09930E+00, 3.90631E+00, 3.07165E+00, 9.86161E-01, 1.63536E+01, * 4.63830E+00, 1.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 1.28840E+00, 3.10302E-02, 1.18339E-01, * 1.00000E+00, 7.00000E-01, 1.15020E+00, 3.44689E+00, 1.28840E+00, * 1.00000E+00, 1.08738E+00, 1.22947E+00, 1.10016E+00, 7.34129E-01, * 1.15241E+00, 2.22784E+00, 7.95046E-01, 4.01612E+00, 4.47749E+00, * 1.23435E+02,-7.60535E-02, 1.68986E-06, 7.44294E-01, 1.03604E+00, * 1.72783E+02, 1.15020E+00, 3.44689E+00,-7.46230E-01, 9.49154E-01/ C LOWER BOUNDARY DATA PTM/ L 1.04130E+03, 3.86000E+02, 1.95000E+02, 1.66728E+01, 2.13000E+02, L 1.20000E+02, 2.40000E+02, 1.87000E+02,-2.00000E+00, 0.00000E+00/ DATA PDM/ L 2.45600E+07, 6.71072E-06, 1.00000E+02, 0.00000E+00, 1.10000E+02, L 1.00000E+01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, C L 8.59400E+10, 1.00000E+00, 1.05000E+02,-8.00000E+00, 1.10000E+02, L 1.00000E+01, 9.00000E+01, 2.00000E+00, 0.00000E+00, 0.00000E+00, C L 2.81000E+11, 0.00000E+00, 1.05000E+02, 2.80000E+01, 2.89500E+01, L 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, C L 3.30000E+10, 2.68270E-01, 1.05000E+02, 1.00000E+00, 1.10000E+02, L 1.00000E+01, 1.10000E+02,-1.00000E+01, 0.00000E+00, 0.00000E+00, C L 1.33000E+09, 1.19615E-02, 1.05000E+02, 0.00000E+00, 1.10000E+02, L 1.00000E+01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, C L 1.76100E+05, 1.00000E+00, 9.50000E+01,-8.00000E+00, 1.10000E+02, L 1.00000E+01, 9.00000E+01, 2.00000E+00, 0.00000E+00, 0.00000E+00, C L 1.00000E+07, 1.00000E+00, 1.05000E+02,-8.00000E+00, 1.10000E+02, L 1.00000E+01, 9.00000E+01, 2.00000E+00, 0.00000E+00, 0.00000E+00, C L 1.00000E+06, 1.00000E+00, 1.05000E+02,-8.00000E+00, 5.50000E+02, L 7.60000E+01, 9.00000E+01, 2.00000E+00, 0.00000E+00, 4.00000E+03/ C TN1(2) DATA PL1/ * 1.00858E+00, 4.56011E-02,-2.22972E-02,-5.44388E-02, 5.23136E-04, * -1.88849E-02, 5.23707E-02,-9.43646E-03, 6.31707E-03,-7.80460E-02, * -4.88430E-02, 0.00000E+00, 0.00000E+00,-7.60250E+00, 0.00000E+00, * -1.44635E-02,-1.76843E-02,-1.21517E+02, 2.85647E-02, 0.00000E+00, * 0.00000E+00, 6.31792E-04, 0.00000E+00, 5.77197E-03, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-8.90272E+03, 3.30611E-03, 3.02172E-03, 0.00000E+00, * -2.13673E-03,-3.20910E-04, 0.00000E+00, 0.00000E+00, 2.76034E-03, * 2.82487E-03,-2.97592E-04,-4.21534E-03, 8.47001E-02, 1.70147E-01, * 8.96456E-03, 0.00000E+00,-1.08596E-02, 0.00000E+00, 0.00000E+00/ DATA PL2/ * 5.57917E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 9.65405E-03, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN1(3) DATA PM1/ * 9.39664E-01, 8.56514E-02,-6.79989E-03, 2.65929E-02,-4.74283E-03, * 1.21855E-02,-2.14905E-02, 6.49651E-03,-2.05477E-02,-4.24952E-02, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.19148E+01, 0.00000E+00, * 1.18777E-02,-7.28230E-02,-8.15965E+01, 1.73887E-02, 0.00000E+00, * 0.00000E+00, 0.00000E+00,-1.44691E-02, 2.80259E-04, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 2.16584E+02, 3.18713E-03, 7.37479E-03, 0.00000E+00, * -2.55018E-03,-3.92806E-03, 0.00000E+00, 0.00000E+00,-2.89757E-03, * -1.33549E-03, 1.02661E-03, 3.53775E-04, 8.47001E-02, 1.70147E-01, * -9.17497E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PM2/ * 3.56082E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-1.00902E-02, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN1(4) DATA PN1/ * 9.85982E-01,-4.55435E-02, 1.21106E-02, 2.04127E-02,-2.40836E-03, * 1.11383E-02,-4.51926E-02, 1.35074E-02,-6.54139E-03, 1.15275E-01, * 1.28247E-01, 0.00000E+00, 0.00000E+00,-5.30705E+00, 0.00000E+00, * -3.79332E-02,-6.24741E-02, 7.71062E-01, 2.96315E-02, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 6.81051E-03,-4.34767E-03, 8.66784E-02, * 1.58727E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 1.07003E+01,-2.76907E-03, 4.32474E-04, 0.00000E+00, * 1.31497E-03,-6.47517E-04, 0.00000E+00,-2.20621E+01,-1.10804E-03, * -8.09338E-04, 4.18184E-04, 4.29650E-03, 8.47001E-02, 1.70147E-01, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PN2/ * -4.04337E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-9.52550E-04, * 8.56253E-04, 4.33114E-04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.21223E-03, * 2.38694E-04, 9.15245E-04, 1.28385E-03, 8.67668E-04,-5.61425E-06, * 1.04445E+00, 3.41112E+01, 0.00000E+00,-8.40704E-01,-2.39639E+02, * 7.06668E-01,-2.05873E+01,-3.63696E-01, 2.39245E+01, 0.00000E+00, * -1.06657E-03,-7.67292E-04, 1.54534E-04, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN1(5) TN2(1) DATA PO1/ * 1.00320E+00, 3.83501E-02,-2.38983E-03, 2.83950E-03, 4.20956E-03, * 5.86619E-04, 2.19054E-02,-1.00946E-02,-3.50259E-03, 4.17392E-02, * -8.44404E-03, 0.00000E+00, 0.00000E+00, 4.96949E+00, 0.00000E+00, * -7.06478E-03,-1.46494E-02, 3.13258E+01,-1.86493E-03, 0.00000E+00, * -1.67499E-02, 0.00000E+00, 0.00000E+00, 5.12686E-04, 8.66784E-02, * 1.58727E-01,-4.64167E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 4.37353E-03,-1.99069E+02, 0.00000E+00,-5.34884E-03, 0.00000E+00, * 1.62458E-03, 2.93016E-03, 2.67926E-03, 5.90449E+02, 0.00000E+00, * 0.00000E+00,-1.17266E-03,-3.58890E-04, 8.47001E-02, 1.70147E-01, * 0.00000E+00, 0.00000E+00, 1.38673E-02, 0.00000E+00, 0.00000E+00/ DATA PO2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.60571E-03, * 6.28078E-04, 5.05469E-05, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-1.57829E-03, * -4.00855E-04, 5.04077E-05,-1.39001E-03,-2.33406E-03,-4.81197E-04, * 1.46758E+00, 6.20332E+00, 0.00000E+00, 3.66476E-01,-6.19760E+01, * 3.09198E-01,-1.98999E+01, 0.00000E+00,-3.29933E+02, 0.00000E+00, * -1.10080E-03,-9.39310E-05, 1.39638E-04, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN2(2) DATA PP1/ * 9.81637E-01,-1.41317E-03, 3.87323E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-3.58707E-02, * -8.63658E-03, 0.00000E+00, 0.00000E+00,-2.02226E+00, 0.00000E+00, * -8.69424E-03,-1.91397E-02, 8.76779E+01, 4.52188E-03, 0.00000E+00, * 2.23760E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-7.07572E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, * -4.11210E-03, 3.50060E+01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00,-8.36657E-03, 1.61347E+01, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00,-1.45130E-02, 0.00000E+00, 0.00000E+00/ DATA PP2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.24152E-03, * 6.43365E-04, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.33255E-03, * 2.42657E-03, 1.60666E-03,-1.85728E-03,-1.46874E-03,-4.79163E-06, * 1.22464E+00, 3.53510E+01, 0.00000E+00, 4.49223E-01,-4.77466E+01, * 4.70681E-01, 8.41861E+00,-2.88198E-01, 1.67854E+02, 0.00000E+00, * 7.11493E-04, 6.05601E-04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN2(3) DATA PQ1/ * 1.00422E+00,-7.11212E-03, 5.24480E-03, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-5.28914E-02, * -2.41301E-02, 0.00000E+00, 0.00000E+00,-2.12219E+01,-1.03830E-02, * -3.28077E-03, 1.65727E-02, 1.68564E+00,-6.68154E-03, 0.00000E+00, * 1.45155E-02, 0.00000E+00, 8.42365E-03, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-4.34645E-03, 0.00000E+00, 0.00000E+00, 2.16780E-02, * 0.00000E+00,-1.38459E+02, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 7.04573E-03,-4.73204E+01, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 1.08767E-02, 0.00000E+00, 0.00000E+00/ DATA PQ2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-8.08279E-03, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 5.21769E-04, * -2.27387E-04, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 3.26769E-03, * 3.16901E-03, 4.60316E-04,-1.01431E-04, 1.02131E-03, 9.96601E-04, * 1.25707E+00, 2.50114E+01, 0.00000E+00, 4.24472E-01,-2.77655E+01, * 3.44625E-01, 2.75412E+01, 0.00000E+00, 7.94251E+02, 0.00000E+00, * 2.45835E-03, 1.38871E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN2(4) TN3(1) DATA PR1/ * 1.01890E+00,-2.46603E-02, 1.00078E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-6.70977E-02, * -4.02286E-02, 0.00000E+00, 0.00000E+00,-2.29466E+01,-7.47019E-03, * 2.26580E-03, 2.63931E-02, 3.72625E+01,-6.39041E-03, 0.00000E+00, * 9.58383E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-1.85291E-03, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 1.39717E+02, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 9.19771E-03,-3.69121E+02, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00,-1.57067E-02, 0.00000E+00, 0.00000E+00/ DATA PR2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-7.07265E-03, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-2.92953E-03, * -2.77739E-03,-4.40092E-04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.47280E-03, * 2.95035E-04,-1.81246E-03, 2.81945E-03, 4.27296E-03, 9.78863E-04, * 1.40545E+00,-6.19173E+00, 0.00000E+00, 0.00000E+00,-7.93632E+01, * 4.44643E-01,-4.03085E+02, 0.00000E+00, 1.15603E+01, 0.00000E+00, * 2.25068E-03, 8.48557E-04,-2.98493E-04, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN3(2) DATA PS1/ * 9.75801E-01, 3.80680E-02,-3.05198E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 3.85575E-02, * 5.04057E-02, 0.00000E+00, 0.00000E+00,-1.76046E+02, 1.44594E-02, * -1.48297E-03,-3.68560E-03, 3.02185E+01,-3.23338E-03, 0.00000E+00, * 1.53569E-02, 0.00000E+00,-1.15558E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 4.89620E-03, 0.00000E+00, 0.00000E+00,-1.00616E-02, * -8.21324E-03,-1.57757E+02, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 6.63564E-03, 4.58410E+01, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00,-2.51280E-02, 0.00000E+00, 0.00000E+00/ DATA PS2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 9.91215E-03, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-8.73148E-04, * -1.29648E-03,-7.32026E-05, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-4.68110E-03, * -4.66003E-03,-1.31567E-03,-7.39390E-04, 6.32499E-04,-4.65588E-04, * -1.29785E+00,-1.57139E+02, 0.00000E+00, 2.58350E-01,-3.69453E+01, * 4.10672E-01, 9.78196E+00,-1.52064E-01,-3.85084E+03, 0.00000E+00, * -8.52706E-04,-1.40945E-03,-7.26786E-04, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN3(3) DATA PU1/ * 9.60722E-01, 7.03757E-02,-3.00266E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.22671E-02, * 4.10423E-02, 0.00000E+00, 0.00000E+00,-1.63070E+02, 1.06073E-02, * 5.40747E-04, 7.79481E-03, 1.44908E+02, 1.51484E-04, 0.00000E+00, * 1.97547E-02, 0.00000E+00,-1.41844E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 5.77884E-03, 0.00000E+00, 0.00000E+00, 9.74319E-03, * 0.00000E+00,-2.88015E+03, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00,-4.44902E-03,-2.92760E+01, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 2.34419E-02, 0.00000E+00, 0.00000E+00/ DATA PU2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 5.36685E-03, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-4.65325E-04, * -5.50628E-04, 3.31465E-04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-2.06179E-03, * -3.08575E-03,-7.93589E-04,-1.08629E-04, 5.95511E-04,-9.05050E-04, * 1.18997E+00, 4.15924E+01, 0.00000E+00,-4.72064E-01,-9.47150E+02, * 3.98723E-01, 1.98304E+01, 0.00000E+00, 3.73219E+03, 0.00000E+00, * -1.50040E-03,-1.14933E-03,-1.56769E-04, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN3(4) DATA PV1/ * 1.03123E+00,-7.05124E-02, 8.71615E-03, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-3.82621E-02, * -9.80975E-03, 0.00000E+00, 0.00000E+00, 2.89286E+01, 9.57341E-03, * 0.00000E+00, 0.00000E+00, 8.66153E+01, 7.91938E-04, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 4.68917E-03, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 7.86638E-03, 0.00000E+00, 0.00000E+00, 9.90827E-03, * 0.00000E+00, 6.55573E+01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00,-4.00200E+01, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 7.07457E-03, 0.00000E+00, 0.00000E+00/ DATA PV2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 5.72268E-03, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-2.04970E-04, * 1.21560E-03,-8.05579E-06, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-2.49941E-03, * -4.57256E-04,-1.59311E-04, 2.96481E-04,-1.77318E-03,-6.37918E-04, * 1.02395E+00, 1.28172E+01, 0.00000E+00, 1.49903E-01,-2.63818E+01, * 0.00000E+00, 4.70628E+01,-2.22139E-01, 4.82292E-02, 0.00000E+00, * -8.67075E-04,-5.86479E-04, 5.32462E-04, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TN3(5) SURFACE TEMP TSL DATA PW1/ * 1.00828E+00,-9.10404E-02,-2.26549E-02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-2.32420E-02, * -9.08925E-03, 0.00000E+00, 0.00000E+00, 3.36105E+01, 0.00000E+00, * 0.00000E+00, 0.00000E+00,-1.24957E+01,-5.87939E-03, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 2.79765E+01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.01237E+03, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00,-1.75553E-02, 0.00000E+00, 0.00000E+00/ DATA PW2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 3.29699E-03, * 1.26659E-03, 2.68402E-04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.17894E-03, * 1.48746E-03, 1.06478E-04, 1.34743E-04,-2.20939E-03,-6.23523E-04, * 6.36539E-01, 1.13621E+01, 0.00000E+00,-3.93777E-01, 2.38687E+03, * 0.00000E+00, 6.61865E+02,-1.21434E-01, 9.27608E+00, 0.00000E+00, * 1.68478E-04, 1.24892E-03, 1.71345E-03, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TGN3(2) SURFACE GRAD TSLG DATA PX1/ * 1.57293E+00,-6.78400E-01, 6.47500E-01, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-7.62974E-02, * -3.60423E-01, 0.00000E+00, 0.00000E+00, 1.28358E+02, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 4.68038E+01, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-1.67898E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 2.90994E+04, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 3.15706E+01, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PX2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TGN2(1) TGN1(2) DATA PY1/ * 8.60028E-01, 3.77052E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-1.17570E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 7.77757E-03, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 1.01024E+02, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 6.54251E+02, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ DATA PY2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00,-1.56959E-02, * 1.91001E-02, 3.15971E-02, 1.00982E-02,-6.71565E-03, 2.57693E-03, * 1.38692E+00, 2.82132E-01, 0.00000E+00, 0.00000E+00, 3.81511E+02, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C TGN3(1) TGN2(2) DATA PZ1/ * 1.06029E+00,-5.25231E-02, 3.73034E-01, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 3.31072E-02, * -3.88409E-01, 0.00000E+00, 0.00000E+00,-1.65295E+02,-2.13801E-01, * -4.38916E-02,-3.22716E-01,-8.82393E+01, 1.18458E-01, 0.00000E+00, * -4.35863E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00,-1.19782E-01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 2.62229E+01, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00,-5.37443E+01, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00,-4.55788E-01, 0.00000E+00, 0.00000E+00/ DATA PZ2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 3.84009E-02, * 3.96733E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 5.05494E-02, * 7.39617E-02, 1.92200E-02,-8.46151E-03,-1.34244E-02, 1.96338E-02, * 1.50421E+00, 1.88368E+01, 0.00000E+00, 0.00000E+00,-5.13114E+01, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 5.11923E-02, 3.61225E-02, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 2.00000E+00/ C SEMIANNUAL MULT SAM DATA PAA1/ * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, * 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00/ DATA PAA2/ * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, * 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00/ C MIDDLE ATMOSPHERE AVERAGES DATA PAVGM/ M 2.61000E+02, 2.64000E+02, 2.29000E+02, 2.17000E+02, 2.17000E+02, M 2.23000E+02, 2.86760E+02,-2.93940E+00, 2.50000E+00, 0.00000E+00/ end module msise00_data
src/msise00/fortran/msise00_data.f
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++! !   Futility Development Group    ! !              All rights reserved.           ! !                         ! ! Futility is a jointly-maintained, open-source project between the University ! ! of Michigan and Oak Ridge National Laboratory.  The copyright and license ! ! can be found in LICENSE.txt in the head directory of this repository.   ! !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++! PROGRAM testGeom_Line #include "UnitTest.h" USE ISO_FORTRAN_ENV USE UnitTest USE IntrType USE Constants_Conversion USE ParameterLists USE Geom IMPLICIT NONE TYPE(PointType) :: point,point2,point3 TYPE(PointType) :: points(2),points2(2),points3(2) TYPE(LineType) :: line1,line2,lines(2),dis INTEGER(SIK) :: ldim(2) REAL(SRK) :: d,mu1,mu2,s(2) LOGICAL(SBK) :: bool CREATE_TEST('Test Geom') CALL eParams%setQuietMode(.TRUE.) CALL eParams%setStopOnError(.FALSE.) REGISTER_SUBTEST('Test Lines',TestLine) FINALIZE_TEST() ! !=============================================================================== CONTAINS ! !------------------------------------------------------------------------------- SUBROUTINE TestLine !The LineType constructor allocates sp and ep, care should !be taken not to code memory leaks. This is why clearPoints() exists. COMPONENT_TEST('%clear()') !Initialize by hand CALL line1%p1%init(DIM=2,X=0.0_SRK,Y=0.0_SRK) CALL line1%p2%init(DIM=2,X=1.0_SRK,Y=1.0_SRK) ! !Test clear CALL line1%clear() bool=.NOT.(line1%p1%dim /= 0 .OR. line1%p2%dim /= 0 .OR. & ALLOCATED(line1%p1%coord) .OR. ALLOCATED(line1%p2%coord)) ASSERT(bool, 'line1%clear()') !Redundant call to clear CALL line1%clear() ! !Test init COMPONENT_TEST('%init()') CALL point2%init(DIM=3,X=0.1_SRK,Y=0.2_SRK,Z=0.3_SRK) CALL point3%init(DIM=3,X=0.4_SRK,Y=0.5_SRK,Z=0.6_SRK) CALL line1%set(point2,point3) bool=.NOT.(line1%p1%dim /= 3 .OR. line1%p2%dim /= 3 .OR. & line1%p1%coord(1) /= 0.1_SRK .OR. line1%p1%coord(2) /= 0.2_SRK .OR. & line1%p1%coord(3) /= 0.3_SRK .OR. line1%p2%coord(1) /= 0.4_SRK .OR. & line1%p2%coord(2) /= 0.5_SRK .OR. line1%p2%coord(3) /= 0.6_SRK) ASSERT(bool, 'line1%set(...)') CALL line1%clear() !Redundant call to test input error CALL line1%set(point,point2) bool = .NOT.(line1%p1%dim /= 0 .OR. line1%p2%dim /= 0 .OR. & ALLOCATED(line1%p1%coord) .OR. ALLOCATED(line1%p2%coord)) ASSERT(bool, 'line1%set(...)') CALL line1%clear() ! !Test getDim COMPONENT_TEST('%getDim()') CALL line1%set(point2,point3) ASSERT(line1%getDim() == 3, 'line1%getDim()') CALL line1%clear() !Redundant call to test input error ASSERT(line1%getDim() == 0, 'line1%getDim()') ! !Test length COMPONENT_TEST('%length()') CALL line1%set(point2,point3) d=line1%length() ASSERT(d .APPROXEQ. 0.519615242270663_SRK, 'line1%length()') ! !Test midpoint COMPONENT_TEST('%midpoint()') point=line1%midpoint() bool = .NOT.(point%dim /= 3 .OR. .NOT.(point%coord(1) .APPROXEQ. 0.25_SRK) .OR. & .NOT.(point%coord(2) .APPROXEQ. 0.35_SRK) .OR. & .NOT.(point%coord(3) .APPROXEQ. 0.45_SRK)) ASSERT(bool, 'line1%midpoint()') ! !Test intersect !2D COMPONENT_TEST('%intersectLine()') CALL line1%clear() CALL line1%p1%init(DIM=2,X=0.0_SRK,Y=0.0_SRK) CALL line1%p2%init(DIM=2,X=0.0_SRK,Y=1.0_SRK) CALL line2%p1%init(DIM=2,X=1.0_SRK,Y=0.0_SRK) CALL line2%p2%init(DIM=2,X=1.0_SRK,Y=1.0_SRK) !Overlap point=line1%intersectLine(line1) ASSERT(point%dim == -2, 'line1%intersectLine(...)') !disjoint point=line1%intersectLine(line2) ASSERT(point%dim == -3, 'line1%intersectLine(...)') !Normal CALL line1%clear() CALL line2%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/0.0_SRK,1.0_SRK/)) CALL line2%p1%init(COORD=(/-0.5_SRK,0.5_SRK/)) CALL line2%p2%init(COORD=(/1.0_SRK,0.5_SRK/)) point=line1%intersectLine(line2) bool = .NOT.(point%dim /= 2 .OR. .NOT.(point%coord(1) .APPROXEQ. 0.0_SRK) .OR. & .NOT.(point%coord(2) .APPROXEQ. 0.5_SRK)) ASSERT(bool, 'line1%intersectLine(...)') !Test for within rounding error of intersect CALL line1%clear() CALL line2%clear() CALL line1%p1%init(COORD=(/0.23706666666670007_SRK,-0.3041650000000002_SRK/)) CALL line1%p2%init(COORD=(/0.23706666666670007_SRK, 0.64833499999999977_SRK/)) CALL line2%p1%init(COORD=(/-0.11302999999999996_SRK,-0.30416500000000024_SRK/)) CALL line2%p2%init(COORD=(/0.93725999999999998_SRK,-0.30416500000000024_SRK/)) point=line1%intersectLine(line2) ASSERT(point%dim == 2,'line1%intersectLine(...)') bool=ALL(point%coord .APPROXEQ. (/0.23706666666670007_SRK,-0.3041650000000002_SRK/)) ASSERT(bool,'%coord') !3D CALL line1%clear() CALL line2%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/1.0_SRK,1.0_SRK,1.0_SRK/)) CALL line2%p1%init(COORD=(/0.0_SRK,0.0_SRK,1.0_SRK/)) CALL line2%p2%init(COORD=(/1.0_SRK,0.0_SRK,1.0_SRK/)) !Overlap point=line1%intersectLine(line1) ASSERT(point%dim == -2, 'line1%intersectLine(...)') !disjoint point=line1%intersectLine(line2) ASSERT(point%dim == -3, 'line1%intersectLine(...)') !Normal CALL line1%clear() CALL line2%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/1.0_SRK,1.0_SRK,1.0_SRK/)) CALL line2%p1%init(COORD=(/1.0_SRK,0.0_SRK,0.0_SRK/)) CALL line2%p2%init(COORD=(/0.0_SRK,1.0_SRK,1.0_SRK/)) point=line1%intersectLine(line2) bool = .NOT.(point%dim /= 3 .OR. .NOT.(point%coord(1) .APPROXEQ. 0.5_SRK) .OR. & .NOT.(point%coord(2) .APPROXEQ. 0.5_SRK) .OR. & .NOT.(point%coord(3) .APPROXEQ. 0.5_SRK)) ASSERT(bool, 'line1%intersectLine(...)') !Redundant calls to test error checking. CALL line2%clear() point=line1%intersectLine(line2) !mismatched dimensions ASSERT(point%dim == -1, 'point=line1%intersectLine(line2)') CALL line1%clear() CALL line1%p1%init(DIM=1,X=0.5_SRK) CALL line1%p2%init(DIM=1,X=0.0_SRK) point=line1%intersectLine(line1) ASSERT(point%dim == -2, '1-D line1%intersectLine(...)') CALL line1%clear() CALL line2%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/0.0_SRK,1.0_SRK/)) CALL line2%p1%init(COORD=(/-0.5_SRK,2.5_SRK/)) CALL line2%p2%init(COORD=(/1.0_SRK,2.5_SRK/)) point=line1%intersectLine(line2) ASSERT(point%dim == -3, 'line1%intersectLine(...)') !Test for %distance2Line(...) COMPONENT_TEST('%distance2Line()') !Line dimension error check CALL line1%clear() CALL line2%clear() CALL dis%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/0.0_SRK,1.0_SRK/)) CALL line2%p1%init(COORD=(/0.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%p2%init(COORD=(/1.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%distance2Line(line1,dis,mu1,mu2) bool = .NOT.(dis%p1%dim /= -1 .AND. dis%p2%dim /= -1) ASSERT(bool, 'line2%distance2Line(...)') !Line input check CALL line1%clear() CALL line2%clear() CALL dis%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/0.0_SRK,0.0_SRK,0.0_SRK/)) CALL line2%p1%init(COORD=(/0.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%p2%init(COORD=(/1.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%distance2Line(line1,dis,mu1,mu2) bool = .NOT.(dis%p1%dim /= -1 .AND. dis%p2%dim /= -1) ASSERT(bool, 'line2%distance2Line(...)') !Overlap CALL line1%clear() CALL dis%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line1%p2%init(COORD=(/1.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%distance2Line(line1,dis,mu1,mu2) bool = .NOT.(dis%p1%dim /= -2 .AND. dis%p2%dim /= -2) ASSERT(bool, 'line2%distance2Line(...)') !Parallel CALL line1%clear() CALL line2%clear() CALL dis%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/1.0_SRK,0.0_SRK,0.0_SRK/)) CALL line2%p1%init(COORD=(/0.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%p2%init(COORD=(/1.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%distance2Line(line1,dis,mu1,mu2) bool = .NOT.(dis%p1%dim /= -3 .AND. dis%p2%dim /= -3) ASSERT(bool, 'line2%distance2Line(...)') !Normal with interscetion CALL line1%clear() CALL line2%clear() CALL dis%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/0.0_SRK,0.0_SRK,1.0_SRK/)) CALL line2%p1%init(COORD=(/0.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%p2%init(COORD=(/1.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%distance2Line(line1,dis,mu1,mu2) bool = .NOT.(dis%getDim() /= 3 .OR. mu1 /= 0._SRK .OR. mu2 /= -1._SRK & .OR. dis%p1 /= line2%p1 .OR. dis%length() > EPSREAL) ASSERT(bool, 'line2%distance2Line(...)') !Normal without interscetion CALL line1%clear() CALL line2%clear() CALL dis%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/0.0_SRK,1.0_SRK,0.0_SRK/)) CALL line2%p1%init(COORD=(/0.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%p2%init(COORD=(/1.0_SRK,0.0_SRK,-1.0_SRK/)) CALL line2%distance2Line(line1,dis,mu1,mu2) bool = .NOT.(dis%getDim() /= 3 .OR. mu1 /= 0._SRK .OR. mu2 /= 0._SRK & .OR. dis%p1 /= line2%p1 .OR. dis%p2 /= line1%p1) ASSERT(bool, 'line2%distance2Line(...)') !Test for %distance2Point(...) COMPONENT_TEST('%distance2Point()') CALL line1%clear() CALL point%clear() CALL line1%p1%init(COORD=(/0.0_SRK/)) CALL line1%p2%init(COORD=(/1.0_SRK/)) CALL point%init(COORD=(/-0.5_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 0.25_SRK ASSERT(bool, '1-D line1%distance2Point(...)') CALL point%clear() CALL point%init(COORD=(/0.5_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 0.0_SRK ASSERT(bool, '1-D line1%distance2Point(...)') CALL point%clear() CALL point%init(COORD=(/1.5_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 0.25_SRK ASSERT(bool, '1-D line1%distance2Point(...)') CALL line1%clear() CALL point%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/1.0_SRK,1.0_SRK/)) CALL point%init(COORD=(/-0.5_SRK/)) ASSERT(line1%distance2Point(point) == -1.0_SRK, '2-D line1%distance2Point(...)') CALL point%clear() CALL point%init(COORD=(/0.5_SRK,0.5_SRK/)) ASSERT(line1%distance2Point(point) .APPROXEQ. 0.0_SRK, '2-D line1%distance2Point(...)') CALL point%clear() CALL point%init(COORD=(/0.0_SRK,0.5_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 0.125_SRK ASSERT(bool, '2-D line1%distance2Point(...)') CALL point%clear() CALL point%init(COORD=(/2.0_SRK,0.5_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 1.25_SRK ASSERT(bool, '2-D line1%distance2Point(...)') CALL point%clear() CALL point%init(COORD=(/-0.5_SRK,-1.0_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 1.25_SRK ASSERT(bool, '2-D line1%distance2Point(...)') CALL line1%clear() CALL point%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/1.0_SRK,1.0_SRK,1.0_SRK/)) CALL point%init(COORD=(/0.5_SRK,0.5_SRK,0.5_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 0.0_SRK ASSERT(bool, '3-D line1%distance2Point(...)') CALL point%clear() CALL point%init(COORD=(/0.5_SRK,0.5_SRK,0.0_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 0.1666666666666667_SRK ASSERT(bool, '3-D line1%distance2Point(...)') CALL point%clear() CALL point%init(COORD=(/1.0_SRK,1.0_SRK,2.0_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 1.0_SRK ASSERT(bool, '3-D line1%distance2Point(...)') CALL point%clear() CALL point%init(COORD=(/0.0_SRK,0.0_SRK,-1.0_SRK/)) bool = line1%distance2Point(point) .APPROXEQ. 1.0_SRK ASSERT(bool, '3-D line1%distance2Point(...)') !Test pointIsLeft COMPONENT_TEST('%pointIsLeft()') CALL point%clear() CALL point%init(COORD=(/0.0_SRK,1.0_SRK,-1.0_SRK/)) ASSERT(line1%pointIsLeft(point),'Point (0.0,1.0,-1.0)') CALL point%clear() CALL point%init(COORD=(/2.0_SRK,1.0_SRK,-10.0_SRK/)) ASSERT(.NOT.line1%pointIsLeft(point),'Point (2.0,1.0,-10.0)') CALL point%clear() CALL point%init(COORD=(/0.5_SRK,0.5_SRK,0.5_SRK/)) ASSERT(.NOT.line1%pointIsLeft(point),'Point (0.5,0.5,0.5)') !Test pointIsLeft CALL point%clear() CALL point%init(COORD=(/2.0_SRK,1.0_SRK,-10.0_SRK/)) COMPONENT_TEST('%pointIsRight()') ASSERT(line1%pointIsRight(point),'Point (2.0,1.0,-10.0)') CALL point%clear() CALL point%init(COORD=(/0.0_SRK,1.0_SRK,-1.0_SRK/)) ASSERT(.NOT.line1%pointIsRight(point),'Point (0.0,1.0,-1.0)') CALL point%clear() CALL point%init(COORD=(/0.5_SRK,0.5_SRK,0.5_SRK/)) ASSERT(.NOT.line1%pointIsLeft(point),'Point (0.5,0.5,0.5)') !Test for equivalence operation COMPONENT_TEST('OPERATOR(==)') line2=line1 ASSERT(line1 == line2,'3-D line equivalence') CALL line1%clear() CALL line2%clear() CALL line1%p1%init(COORD=(/0.0_SRK,0.0_SRK/)) CALL line1%p2%init(COORD=(/1.0_SRK,1.0_SRK/)) line2=line1 ASSERT(line1 == line2,'2-D line equivalence') CALL line2%clear() CALL line2%p1%init(COORD=(/0.0_SRK,0.0_SRK,0.0_SRK/)) CALL line2%p2%init(COORD=(/1.0_SRK,1.0_SRK,1.0_SRK/)) ASSERT(.NOT.(line1 == line2),'2-D and 3-D line non-equivalence') CALL points2%clear() CALL points3%clear() CALL points2(1)%init(DIM=3,X=0.5_SRK,Y=0.6_SRK,Z=0.7_SRK) CALL points2(2)%init(DIM=2,X=0.5_SRK,Y=0.6_SRK) points3=points2 points3(1)%coord=points3(1)%coord+0.1_SRK points3(2)%coord=points3(2)%coord+0.1_SRK !This no longer works with Intel 12 COMPONENT_TEST('Elemental %set()') CALL lines%set(points2,points3) ! CALL lines(1)%set(points2(1),points3(1)) ! CALL lines(2)%set(points2(2),points3(2)) bool = .NOT.(lines(1)%p1%dim /= 3 .OR. lines(1)%p2%dim /= 3 .OR. & ANY(.NOT.(lines(1)%p1%coord .APPROXEQ. (/0.5_SRK,0.6_SRK,0.7_SRK/))) .OR. & ANY(.NOT.(lines(1)%p2%coord .APPROXEQ. (/0.6_SRK,0.7_SRK,0.8_SRK/))) .OR. & lines(2)%p1%dim /= 2 .OR. lines(2)%p2%dim /= 2 .OR. & ANY(.NOT.(lines(2)%p1%coord .APPROXEQ. (/0.5_SRK,0.6_SRK/))) .OR. & ANY(.NOT.(lines(2)%p2%coord .APPROXEQ. (/0.6_SRK,0.7_SRK/)))) ASSERT(bool, 'lines%set(...)') COMPONENT_TEST('Elemental %getDim()') ldim=lines%getDim() bool = .NOT.(ldim(1) /= 3 .OR. ldim(2) /= 2) ASSERT(bool, 'lines%getDim()') COMPONENT_TEST('Elemental %length()') s=lines%length() bool = .NOT.(.NOT.(s(1) .APPROXEQ. 0.173205080756888_SRK) .OR. & .NOT.(s(2) .APPROXEQ. 0.141421356237309_SRK)) ASSERT(bool, 'lines%length()') COMPONENT_TEST('Elemental %midPoint()') points=lines%midPoint() bool = .NOT.(ANY(.NOT.(points(1)%coord .APPROXEQ. (/0.55_SRK,0.65_SRK,0.75_SRK/))) .OR. & ANY(.NOT.(points(2)%coord .APPROXEQ. (/0.55_SRK,0.65_SRK/)))) ASSERT(bool, 'lines%midPoint()') COMPONENT_TEST('Elemental %intersectLine()') points=lines%intersectLine(lines) bool = .NOT.(points(1)%dim /= -2 .OR. points(2)%dim /= -2) ASSERT(bool, 'lines%intersectLine(...)') !diss=lines%distance2Line(lines) ! IF(diss(1)%p(1)%dim /= -2 .OR. diss(2)%p(1)%dim /= -2) THEN ! WRITE(*,*) 'lines%distance2Line(...) FAILED!' ! STOP 666 ! ELSE ! WRITE(*,*) ' Passed: lines%distance2Line(...)' ! ENDIF ! COMPONENT_TEST('Elemental %distance2Point()') points=lines%midPoint() s=lines%distance2Point(points) bool = .NOT.(ANY(.NOT.(s .APPROXEQ. 0.0_SRK))) ASSERT(bool, 'lines%distance2Point(...)') COMPONENT_TEST('Elemental %clear()') CALL lines%clear() bool = .NOT.((lines(1)%p1%dim /= 0) .OR. (lines(1)%p2%dim /= 0) .OR. & (lines(2)%p1%dim /= 0) .OR. (lines(2)%p2%dim /= 0) .OR. & ALLOCATED(lines(1)%p1%coord) .OR. ALLOCATED(lines(1)%p2%coord) .OR. & ALLOCATED(lines(2)%p1%coord) .OR. ALLOCATED(lines(2)%p2%coord)) ASSERT(bool, 'lines%clear(...)') ENDSUBROUTINE TestLine ENDPROGRAM testGeom_Line
unit_tests/testGeom_Line/testGeom_Line.f90
!> !! @file m_global_parameters.f90 !! @brief Contains module m_global_parameters !! @author S. Bryngelson, K. Schimdmayer, V. Coralic, J. Meng, K. Maeda, T. Colonius !! @version 1.0 !! @date JUNE 06 2019 !> @brief This module contains all of the parameters characterizing the !! computational domain, simulation algorithm, stiffened equation of !! state and finally, the formatted database file(s) structure. MODULE m_global_parameters ! Dependencies ============================================================= USE mpi !< Message passing interface (MPI) module USE m_derived_types !< Definitions of the derived types ! ========================================================================== IMPLICIT NONE !> @name Logistics !> @{ INTEGER :: num_procs !< Number of processors INTEGER , PARAMETER :: num_stcls_min = 5 !< Mininum # of stencils INTEGER , PARAMETER :: path_len = 400 !< Maximum path length INTEGER , PARAMETER :: name_len = 50 !< Maximum name length REAL(KIND(0d0)), PARAMETER :: dflt_real = -1d6 !< Default real value INTEGER , PARAMETER :: dflt_int = -100 !< Default integer value REAL(KIND(0d0)), PARAMETER :: sgm_eps = 1d-16 !< Segmentation tolerance CHARACTER(LEN = path_len) :: case_dir !< Case folder location !> @} ! Computational Domain Parameters ========================================== INTEGER :: proc_rank !< Rank of the local processor !> @name Number of cells in the x-, y- and z-coordinate directions !> @{ INTEGER :: m, m_root INTEGER :: n INTEGER :: p !> @} !> @name Cylindrical coordinates (either axisymmetric or full 3D) !> @{ LOGICAL :: cyl_coord INTEGER :: grid_geometry !> @} !> @name Global number of cells in each direction !> @{ INTEGER :: m_glb, n_glb, p_glb !> @} INTEGER :: num_dims !< Number of spatial dimensions !> @name Cell-boundary locations in the x-, y- and z-coordinate directions !> @{ REAL(KIND(0d0)), ALLOCATABLE, DIMENSION(:) :: x_cb, x_root_cb, y_cb, z_cb REAL(KIND(0d0)), ALLOCATABLE, DIMENSION(:) :: coarse_x_cb, coarse_y_cb, coarse_z_cb !> @} !> @name Cell-center locations in the x-, y- and z-coordinate directions !> @{ REAL(KIND(0d0)), ALLOCATABLE, DIMENSION(:) :: x_cc, x_root_cc, y_cc, z_cc !> @} !> Cell-width distributions in the x-, y- and z-coordinate directions !> @{ REAL(KIND(0d0)), ALLOCATABLE, DIMENSION(:) :: dx, dy, dz !> @} INTEGER :: buff_size !< !! Number of cells in buffer region. For the variables which feature a buffer !! region, this region is used to store information outside the computational !! domain based on the boundary conditions. INTEGER :: t_step_start !< First time-step directory INTEGER :: t_step_stop !< Last time-step directory INTEGER :: t_step_save !< Interval between consecutive time-step directory ! NOTE: The variables m_root, x_root_cb and x_root_cc contain the grid data ! of the defragmented computational domain. They are only used in 1D. For ! serial simulations, they are equal to m, x_cb and x_cc, respectively. ! ========================================================================== !> @name Simulation Algorithm Parameters !> @{ INTEGER :: model_eqns !< Multicomponent flow model INTEGER :: num_fluids !< Number of different fluids present in the flow LOGICAL :: adv_alphan !< Advection of the last volume fraction LOGICAL :: mpp_lim !< Maximum volume fraction limiter INTEGER :: sys_size !< Number of unknowns in the system of equations INTEGER :: weno_order !< Order of accuracy for the WENO reconstruction LOGICAL :: mixture_err !< Mixture error limiter LOGICAL :: alt_soundspeed !< Alternate sound speed !> @} !> @name Annotations of the structure, i.e. the organization, of the state vectors !> @{ TYPE(bounds_info) :: cont_idx !< Indexes of first & last continuity eqns. TYPE(bounds_info) :: mom_idx !< Indexes of first & last momentum eqns. INTEGER :: E_idx !< Index of energy equation TYPE(bounds_info) :: adv_idx !< Indexes of first & last advection eqns. TYPE(bounds_info) :: internalEnergies_idx !< Indexes of first & last internal energy eqns. TYPE(bub_bounds_info) :: bub_idx !< Indexes of first & last bubble variable eqns. INTEGER :: gamma_idx !< Index of specific heat ratio func. eqn. INTEGER :: alf_idx !< Index of specific heat ratio func. eqn. INTEGER :: pi_inf_idx !< Index of liquid stiffness func. eqn. !> @} !> @name Boundary conditions in the x-, y- and z-coordinate directions !> @{ TYPE(bounds_info) :: bc_x, bc_y, bc_z !> @} LOGICAL :: parallel_io !< Format of the data files INTEGER, ALLOCATABLE, DIMENSION(:) :: proc_coords !< !! Processor coordinates in MPI_CART_COMM INTEGER, ALLOCATABLE, DIMENSION(:) :: start_idx !< !! Starting cell-center index of local processor in global grid TYPE(mpi_io_var), PUBLIC :: MPI_IO_DATA !> @name MPI info for parallel IO with Lustre file systems !> @{ CHARACTER(LEN = name_len) :: mpiiofs INTEGER :: mpi_info_int !> @} INTEGER, PRIVATE :: ierr ! ========================================================================== TYPE(physical_parameters), DIMENSION(num_fluids_max) :: fluid_pp !< !! Database of the physical parameters of each of the fluids that is present !! in the flow. These include the stiffened gas equation of state parameters, !! the Reynolds numbers and the Weber numbers. ! ========================================================================== ! Formatted Database File(s) Structure Parameters ========================== INTEGER :: format !< Format of the database file(s) LOGICAL :: coarsen_silo INTEGER :: precision !< Floating point precision of the database file(s) !> @name Size of the ghost zone layer in the x-, y- and z-coordinate directions. !! The definition of the ghost zone layers is only necessary when using the !! Silo database file format in multidimensions. These zones provide VisIt !! with the subdomain connectivity information that it requires in order to !! produce smooth plots. !> @{ TYPE(bounds_info) :: offset_x, offset_y, offset_z !> @} !> @name The list of all possible flow variables that may be written to a database !! file. It includes partial densities, density, momentum, velocity, energy, !! pressure, volume fraction(s), specific heat ratio function, specific heat !! ratio, liquid stiffness function, liquid stiffness, primitive variables, !! conservative variables, speed of sound, the vorticity, !! and the numerical Schlieren function. !> @{ LOGICAL, DIMENSION(num_fluids_max) :: alpha_rho_wrt LOGICAL :: rho_wrt LOGICAL, DIMENSION(3) :: mom_wrt LOGICAL, DIMENSION(3) :: vel_wrt INTEGER :: flux_lim LOGICAL, DIMENSION(3) :: flux_wrt LOGICAL, DIMENSION(num_fluids_max) :: kappa_wrt LOGICAL :: E_wrt LOGICAL :: pres_wrt LOGICAL, DIMENSION(num_fluids_max) :: alpha_wrt LOGICAL :: gamma_wrt LOGICAL :: heat_ratio_wrt LOGICAL :: pi_inf_wrt LOGICAL :: pres_inf_wrt LOGICAL :: prim_vars_wrt LOGICAL :: cons_vars_wrt LOGICAL :: c_wrt LOGICAL, DIMENSION(3) :: omega_wrt LOGICAL :: schlieren_wrt !> @} !> @name Options for Fourier decomposition in the azimuthal direction if 3D !! cylindrical coordinates are used !> @{ LOGICAL :: fourier_decomp TYPE(bounds_info) :: fourier_modes !> @} REAL(KIND(0d0)), DIMENSION(num_fluids_max) :: schlieren_alpha !< !! Amplitude coefficients of the numerical Schlieren function that are used !! to adjust the intensity of numerical Schlieren renderings for individual !! fluids. This enables waves and interfaces of varying strenghts and in all !! of the fluids to be made simulatenously visible on a single plot. INTEGER :: fd_order !< !! The order of the finite-difference (fd) approximations of the first-order !! derivatives that need to be evaluated when vorticity and/or the numerical !! Schlieren function are to be outputted to the formatted database file(s). INTEGER :: fd_number !< !! The finite-difference number is given by MAX(1, fd_order/2). Essentially, !! it is a measure of the half-size of the finite-difference stencil for the !! selected order of accuracy. ! ========================================================================== !> @name Reference parameters for Tait EOS !> @{ REAL(KIND(0d0)) :: rhoref, pref !> @} !> @name Bubble modeling variables and parameters !> @{ INTEGER :: nb REAL(KIND(0d0)) :: R0ref REAL(KIND(0d0)) :: Ca, Web, Re_inv REAL(KIND(0d0)), DIMENSION(:), ALLOCATABLE :: weight, R0, V0 LOGICAL :: bubbles LOGICAL :: polytropic LOGICAL :: polydisperse INTEGER :: thermal !< 1 = adiabatic, 2 = isotherm, 3 = transfer REAL(KIND(0d0)) :: R_n, R_v, phi_vn, phi_nv, Pe_c, Tw REAL(KIND(0d0)), DIMENSION(:), ALLOCATABLE :: k_n, k_v, pb0, mass_n0, mass_v0, Pe_T REAL(KIND(0d0)), DIMENSION(:), ALLOCATABLE :: Re_trans_T, Re_trans_c, Im_trans_T, Im_trans_c, omegaN REAL(KIND(0d0)) :: poly_sigma !> @} ! Mathematical and Physical Constants ====================================== REAL(KIND(0d0)), PARAMETER :: pi = 3.141592653589793d0 ! ========================================================================== CONTAINS !> Assigns default values to user inputs prior to reading !! them in. This allows for an easier consistency check of !! these parameters once they are read from the input file. SUBROUTINE s_assign_default_values_to_user_inputs() ! ------------------ INTEGER :: i !< Generic loop iterator ! Logistics case_dir = ' ' ! Computational domain parameters m = dflt_int m_root = dflt_int n = dflt_int p = dflt_int cyl_coord = .FALSE. t_step_start = dflt_int t_step_stop = dflt_int t_step_save = dflt_int ! Simulation algorithm parameters model_eqns = dflt_int num_fluids = dflt_int adv_alphan = .FALSE. weno_order = dflt_int mixture_err = .FALSE. alt_soundspeed = .FALSE. bc_x%beg = dflt_int bc_x%end = dflt_int bc_y%beg = dflt_int bc_y%end = dflt_int bc_z%beg = dflt_int bc_z%end = dflt_int ! Fluids physical parameters DO i = 1, num_fluids_max fluid_pp(i)%gamma = dflt_real fluid_pp(i)%pi_inf = dflt_real END DO ! Formatted database file(s) structure parameters format = dflt_int precision = dflt_int coarsen_silo = .FALSE. alpha_rho_wrt = .FALSE. rho_wrt = .FALSE. mom_wrt = .FALSE. vel_wrt = .FALSE. flux_lim = dflt_int flux_wrt = .FALSE. parallel_io = .FALSE. kappa_wrt = .FALSE. E_wrt = .FALSE. pres_wrt = .FALSE. alpha_wrt = .FALSE. gamma_wrt = .FALSE. heat_ratio_wrt = .FALSE. pi_inf_wrt = .FALSE. pres_inf_wrt = .FALSE. prim_vars_wrt = .FALSE. cons_vars_wrt = .FALSE. c_wrt = .FALSE. omega_wrt = .FALSE. schlieren_wrt = .FALSE. schlieren_alpha = dflt_real fourier_decomp = .FALSE. fourier_modes%beg = dflt_int fourier_modes%end = dflt_int fd_order = dflt_int ! Tait EOS rhoref = dflt_real pref = dflt_real ! Bubble modeling bubbles = .FALSE. R0ref = dflt_real nb = dflt_int polydisperse= .FALSE. poly_sigma = dflt_real END SUBROUTINE s_assign_default_values_to_user_inputs ! ---------------- !> Computation of parameters, allocation procedures, and/or !! any other tasks needed to properly setup the module SUBROUTINE s_initialize_global_parameters_module() ! ---------------------- INTEGER :: i, fac ! Setting m_root equal to m in the case of a 1D serial simulation IF(num_procs == 1 .AND. n == 0) m_root = m ! Gamma/Pi_inf Model =============================================== IF(model_eqns == 1) THEN ! Setting number of fluids num_fluids = 1 ! Annotating structure of the state and flux vectors belonging ! to the system of equations defined by the selected number of ! spatial dimensions and the gamma/pi_inf model cont_idx%beg = 1 cont_idx%end = cont_idx%beg mom_idx%beg = cont_idx%end + 1 mom_idx%end = cont_idx%end + num_dims E_idx = mom_idx%end + 1 adv_idx%beg = E_idx + 1 adv_idx%end = adv_idx%beg + 1 gamma_idx = adv_idx%beg pi_inf_idx = adv_idx%end sys_size = adv_idx%end ! ================================================================== ! Volume Fraction Model (5-equation model) ========================= ELSE IF(model_eqns == 2) THEN ! Annotating structure of the state and flux vectors belonging ! to the system of equations defined by the selected number of ! spatial dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 mom_idx%end = cont_idx%end + num_dims E_idx = mom_idx%end + 1 adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids IF( (adv_alphan .NEQV. .TRUE.) .AND. & (num_fluids > 1)) adv_idx%end = adv_idx%end - 1 sys_size = adv_idx%end IF (bubbles) THEN alf_idx = adv_idx%end ELSE alf_idx = 0 END IF IF (bubbles) THEN bub_idx%beg = sys_size+1 bub_idx%end = sys_size+2*nb IF (polytropic .NEQV. .TRUE.) THEN bub_idx%end = sys_size+4*nb END IF sys_size = bub_idx%end ALLOCATE( bub_idx%rs(nb), bub_idx%vs(nb) ) ALLOCATE( bub_idx%ps(nb), bub_idx%ms(nb) ) ALLOCATE( weight(nb),R0(nb),V0(nb) ) DO i = 1, nb IF (polytropic .NEQV. .TRUE.) THEN fac = 4 ELSE fac = 2 END IF bub_idx%rs(i) = bub_idx%beg+(i-1)*fac bub_idx%vs(i) = bub_idx%rs(i)+1 IF (polytropic .NEQV. .TRUE.) THEN bub_idx%ps(i) = bub_idx%vs(i)+1 bub_idx%ms(i) = bub_idx%ps(i)+1 END IF END DO IF (nb == 1) THEN weight(:) = 1d0 R0(:) = 1d0 V0(:) = 0d0 ELSE IF (nb > 1) THEN CALL s_simpson(nb) V0(:) = 0d0 ELSE STOP 'Invalid value of nb' END IF IF (polytropic .NEQV. .TRUE.) THEN CALL s_initialize_nonpoly ELSE rhoref = 1.d0 pref = 1.d0 END IF END IF ! ================================================================== ! Volume Fraction Model (6-equation model) ========================= ELSE IF(model_eqns == 3) THEN ! Annotating structure of the state and flux vectors belonging ! to the system of equations defined by the selected number of ! spatial dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 mom_idx%end = cont_idx%end + num_dims E_idx = mom_idx%end + 1 adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids IF(adv_alphan .NEQV. .TRUE.) adv_idx%end = adv_idx%end - 1 internalEnergies_idx%beg = adv_idx%end + 1 internalEnergies_idx%end = adv_idx%end + num_fluids sys_size = internalEnergies_idx%end ELSE IF(model_eqns == 4) THEN cont_idx%beg = 1 ! one continuity equation cont_idx%end = 1 !num_fluids mom_idx%beg = cont_idx%end + 1 ! one momentum equation in each mom_idx%end = cont_idx%end + num_dims E_idx = mom_idx%end + 1 ! one energy equation adv_idx%beg = E_idx + 1 adv_idx%end = adv_idx%beg !one volume advection equation alf_idx = adv_idx%end sys_size = alf_idx !adv_idx%end IF (bubbles) THEN bub_idx%beg = sys_size+1 bub_idx%end = sys_size+2*nb IF (polytropic .NEQV. .TRUE.) THEN bub_idx%end = sys_size+4*nb END IF sys_size = bub_idx%end ALLOCATE( bub_idx%rs(nb), bub_idx%vs(nb) ) ALLOCATE( bub_idx%ps(nb), bub_idx%ms(nb) ) ALLOCATE( weight(nb),R0(nb),V0(nb) ) DO i = 1, nb IF (polytropic .NEQV. .TRUE.) THEN fac = 4 ELSE fac = 2 END IF bub_idx%rs(i) = bub_idx%beg+(i-1)*fac bub_idx%vs(i) = bub_idx%rs(i)+1 IF (polytropic .NEQV. .TRUE.) THEN bub_idx%ps(i) = bub_idx%vs(i)+1 bub_idx%ms(i) = bub_idx%ps(i)+1 END IF END DO IF (nb == 1) THEN weight(:) = 1d0 R0(:) = 1d0 V0(:) = 0d0 ELSE IF (nb > 1) THEN CALL s_simpson(nb) V0(:) = 0d0 ELSE STOP 'Invalid value of nb' END IF IF (polytropic .NEQV. .TRUE.) THEN CALL s_initialize_nonpoly ELSE rhoref = 1.d0 pref = 1.d0 END IF END IF END IF ! ================================================================== ALLOCATE(MPI_IO_DATA%view(1:sys_size)) ALLOCATE(MPI_IO_DATA%var(1:sys_size)) DO i = 1, sys_size ALLOCATE(MPI_IO_DATA%var(i)%sf(0:m,0:n,0:p)) MPI_IO_DATA%var(i)%sf => NULL() END DO ! Size of the ghost zone layer is non-zero only when post-processing ! the raw simulation data of a parallel multidimensional computation ! in the Silo-HDF5 format. If this is the case, one must also verify ! whether the raw simulation data is 2D or 3D. In the 2D case, size ! of the z-coordinate direction ghost zone layer must be zeroed out. IF(num_procs == 1 .OR. format /= 1 .OR. n == 0) THEN offset_x%beg = 0 offset_x%end = 0 offset_y%beg = 0 offset_y%end = 0 offset_z%beg = 0 offset_z%end = 0 ELSEIF(p == 0) THEN offset_z%beg = 0 offset_z%end = 0 END IF ! Determining the finite-difference number and the buffer size. Note ! that the size of the buffer is unrelated to the order of the WENO ! scheme. Rather, it is directly dependent on maximum size of ghost ! zone layers and possibly the order of the finite difference scheme ! used for the computation of vorticity and/or numerical Schlieren ! function. buff_size = MAX( offset_x%beg, offset_x%end, offset_y%beg, & offset_y%end, offset_z%beg, offset_z%end ) IF(ANY(omega_wrt) .OR. schlieren_wrt) THEN fd_number = MAX(1, fd_order/2) buff_size = buff_size + fd_number END IF ! Allocating the grid variables in the x-coordinate direction ALLOCATE(x_cb(-1-offset_x%beg : m + offset_x%end)) ALLOCATE(x_cc( -buff_size : m + buff_size )) ALLOCATE( dx( -buff_size : m + buff_size )) ! Allocating grid variables in the y- and z-coordinate directions IF(n > 0) THEN ALLOCATE(y_cb(-1-offset_y%beg : n + offset_y%end)) ALLOCATE(y_cc( -buff_size : n + buff_size )) ALLOCATE( dy( -buff_size : n + buff_size )) IF(p > 0) THEN ALLOCATE(z_cb(-1-offset_z%beg : p + offset_z%end)) ALLOCATE(z_cc( -buff_size : p + buff_size )) ALLOCATE( dz( -buff_size : p + buff_size )) END IF ! Allocating the grid variables, only used for the 1D simulations, ! and containing the defragmented computational domain grid data ELSE ALLOCATE(x_root_cb(-1:m_root)) ALLOCATE(x_root_cc( 0:m_root)) END IF IF (coarsen_silo) THEN ALLOCATE(coarse_x_cb(-1-offset_x%beg : (m/2) + offset_x%end)) IF (n > 0) THEN ALLOCATE(coarse_y_cb(-1-offset_y%beg : (n/2) + offset_y%end)) IF (p > 0) ALLOCATE(coarse_z_cb(-1-offset_z%beg : (p/2) + offset_z%end)) END IF END IF IF (cyl_coord .NEQV. .TRUE.) THEN ! Cartesian grid grid_geometry = 1 ELSEIF (cyl_coord .AND. p == 0) THEN ! Axisymmetric cylindrical grid grid_geometry = 2 ELSE ! Fully 3D cylindrical grid grid_geometry = 3 END IF END SUBROUTINE s_initialize_global_parameters_module ! -------------------- !> Subroutine to initialize variable for non-polytropic gas modeling processes SUBROUTINE s_initialize_nonpoly INTEGER :: ir REAL(KIND(0.D0)) :: rhol0 REAL(KIND(0.D0)) :: pl0 REAL(KIND(0.D0)) :: uu REAL(KIND(0.D0)) :: D_m REAL(KIND(0.D0)) :: temp REAL(KIND(0.D0)) :: omega_ref REAL(KIND(0.D0)), DIMENSION(Nb) :: chi_vw0 REAL(KIND(0.D0)), DIMENSION(Nb) :: cp_m0 REAL(KIND(0.D0)), DIMENSION(Nb) :: k_m0 REAL(KIND(0.D0)), DIMENSION(Nb) :: rho_m0 REAL(KIND(0.D0)), DIMENSION(Nb) :: x_vw ! polytropic index used to compute isothermal natural frequency REAL(KIND(0.D0)), PARAMETER :: k_poly = 1.D0 ! universal gas constant REAL(KIND(0.D0)), PARAMETER :: Ru = 8314.D0 ! liquid physical properties REAL(KIND(0.D0)) :: mul0, ss, pv, gamma_v, M_v, mu_v ! gas physical properties REAL(KIND(0.D0)) :: gamma_m, gamma_n, M_n, mu_n rhol0 = rhoref pl0 = pref ALLOCATE( pb0(nb), mass_n0(nb), mass_v0(nb), Pe_T(nb) ) ALLOCATE( k_n(nb), k_v(nb), omegaN(nb) ) ALLOCATE( Re_trans_T(nb), Re_trans_c(nb), Im_trans_T(nb), Im_trans_c(nb) ) pb0(:) = dflt_real mass_n0(:) = dflt_real mass_v0(:) = dflt_real Pe_T(:) = dflt_real omegaN(:) = dflt_real mul0 = fluid_pp(1)%mul0 ss = fluid_pp(1)%ss pv = fluid_pp(1)%pv gamma_v = fluid_pp(1)%gamma_v M_v = fluid_pp(1)%M_v mu_v = fluid_pp(1)%mu_v k_v(:) = fluid_pp(1)%k_v gamma_n = fluid_pp(2)%gamma_v M_n = fluid_pp(2)%M_v mu_n = fluid_pp(2)%mu_v k_n(:) = fluid_pp(2)%k_v gamma_m = gamma_n IF (thermal==2 ) gamma_m = 1.d0 !isothermal temp = 293.15D0 D_m = 0.242D-4 uu = DSQRT( pl0/rhol0 ) omega_ref = 3.D0*k_poly*Ca + 2.D0*( 3.D0*k_poly-1.D0 )/Web !!! thermal properties !!! ! gas constants R_n = Ru/M_n R_v = Ru/M_v ! phi_vn & phi_nv (phi_nn = phi_vv = 1) phi_vn = ( 1.D0+DSQRT(mu_v/mu_n)*(M_n/M_v)**(0.25D0) )**2 & / ( DSQRT(8.D0)*DSQRT(1.D0+M_v/M_n) ) phi_nv = ( 1.D0+DSQRT(mu_n/mu_v)*(M_v/M_n)**(0.25D0) )**2 & / ( DSQRT(8.D0)*DSQRT(1.D0+M_n/M_v) ) ! internal bubble pressure pb0 = pl0 + 2.D0*ss/( R0ref*R0 ) ! mass fraction of vapor chi_vw0 = 1.D0/( 1.D0+R_v/R_n*(pb0/pv-1.D0) ) ! specific heat for gas/vapor mixture cp_m0 = chi_vw0*R_v*gamma_v/( gamma_v-1.D0 ) & + ( 1.D0-chi_vw0 )*R_n*gamma_n/( gamma_n-1.D0 ) ! mole fraction of vapor x_vw = M_n*chi_vw0/( M_v+(M_n-M_v)*chi_vw0 ) ! thermal conductivity for gas/vapor mixture k_m0 = x_vw*k_v/( x_vw+(1.D0-x_vw)*phi_vn ) & + ( 1.D0-x_vw )*k_n/( x_vw*phi_nv+1.D0-x_vw ) ! mixture density rho_m0 = pv/( chi_vw0*R_v*temp ) ! mass of gas/vapor computed using dimensional quantities mass_n0 = 4.D0*( pb0-pv )*pi/( 3.D0*R_n*temp*rhol0 )*R0**3 mass_v0 = 4.D0*pv*pi/( 3.D0*R_v*temp*rhol0 )*R0**3 ! Peclet numbers Pe_T = rho_m0*cp_m0*uu*R0ref/k_m0 Pe_c = uu*R0ref/D_m ! nondimensional properties R_n = rhol0*R_n*temp/pl0 R_v = rhol0*R_v*temp/pl0 k_n = k_n/k_m0 k_v = k_v/k_m0 pb0 = pb0/pl0 pv = pv/pl0 ! bubble wall temperature, normalized by T0, in the liquid ! keeps a constant (cold liquid assumption) Tw = 1.D0 ! natural frequencies omegaN = DSQRT( 3.D0*k_poly*Ca+2.D0*(3.D0*k_poly-1.D0)/(Web*R0) )/R0 pl0 = 1.d0 DO ir = 1,Nb CALL s_transcoeff( omegaN(ir)*R0(ir),Pe_T(ir)*R0(ir), & Re_trans_T(ir),Im_trans_T(ir) ) CALL s_transcoeff( omegaN(ir)*R0(ir),Pe_c*R0(ir), & Re_trans_c(ir),Im_trans_c(ir) ) END DO Im_trans_T = 0d0 Im_trans_c = 0d0 rhoref = 1.d0 pref = 1.d0 END SUBROUTINE s_initialize_nonpoly !> Subroutine to compute the transfer coefficient for non-polytropic gas modeling SUBROUTINE s_transcoeff( omega,peclet,Re_trans,Im_trans ) REAL(KIND(0.D0)), INTENT(IN) :: omega REAL(KIND(0.D0)), INTENT(IN) :: peclet REAL(KIND(0.D0)), INTENT(OUT) :: Re_trans REAL(KIND(0.D0)), INTENT(OUT) :: Im_trans COMPLEX :: trans, c1, c2, c3 COMPLEX :: imag = ( 0.,1. ) REAL(KIND(0.D0)) :: f_transcoeff c1 = imag*omega*peclet c2 = CSQRT( c1 ) c3 = ( CEXP(c2)-CEXP(-c2) )/( CEXP(c2)+CEXP(-c2) ) ! TANH(c2) trans = ( (c2/c3-1.D0)**(-1)-3.D0/c1 )**( -1 ) ! transfer function Re_trans = DBLE( trans ) Im_trans = AIMAG( trans ) END SUBROUTINE s_transcoeff !> Subroutine to initialize parallel infrastructure SUBROUTINE s_initialize_parallel_io() ! -------------------------------- num_dims = 1 + MIN(1,n) + MIN(1,p) ALLOCATE(proc_coords(1:num_dims)) IF (parallel_io .NEQV. .TRUE.) RETURN ! Option for Lustre file system (Darter/Comet/Stampede) WRITE(mpiiofs, '(A)') '/lustre_' mpiiofs = TRIM(mpiiofs) CALL MPI_INFO_CREATE(mpi_info_int, ierr) CALL MPI_INFO_SET(mpi_info_int, 'romio_ds_write', 'disable', ierr) ! Option for UNIX file system (Hooke/Thomson) ! WRITE(mpiiofs, '(A)') '/ufs_' ! mpiiofs = TRIM(mpiiofs) ! mpi_info_int = MPI_INFO_NULL ALLOCATE(start_idx(1:num_dims)) END SUBROUTINE s_initialize_parallel_io ! ------------------------------ !> Deallocation procedures for the module SUBROUTINE s_finalize_global_parameters_module() ! ------------------- INTEGER :: i ! Deallocating the grid variables for the x-coordinate direction DEALLOCATE(x_cb, x_cc, dx) ! Deallocating grid variables for the y- and z-coordinate directions IF(n > 0) THEN DEALLOCATE(y_cb, y_cc, dy) IF(p > 0) DEALLOCATE(z_cb, z_cc, dz) ! Deallocating the grid variables, only used for the 1D simulations, ! and containing the defragmented computational domain grid data ELSE DEALLOCATE(x_root_cb, x_root_cc) END IF IF (coarsen_silo) THEN DEALLOCATE(coarse_x_cb) IF (n > 0) THEN DEALLOCATE(coarse_y_cb) IF (p > 0) DEALLOCATE(coarse_z_cb) END IF END IF DEALLOCATE(proc_coords) IF (parallel_io) THEN DEALLOCATE(start_idx) DO i = 1, sys_size MPI_IO_DATA%var(i)%sf => NULL() END DO DEALLOCATE(MPI_IO_DATA%var) DEALLOCATE(MPI_IO_DATA%view) END IF END SUBROUTINE s_finalize_global_parameters_module ! ----------------- !> Computes the bubble number density n from the conservative variables !! @param vftmp is the void fraction !! @param nRtmp is the bubble number density times the bubble radii !! @param ntmp is the output number bubble density SUBROUTINE s_comp_n_from_cons( vftmp,nRtmp,ntmp ) REAL(KIND(0.D0)), INTENT(IN) :: vftmp REAL(KIND(0.D0)), DIMENSION(nb), INTENT(IN) :: nRtmp REAL(KIND(0.D0)), INTENT(OUT) :: ntmp REAL(KIND(0.D0)) :: nR3 CALL s_quad( nRtmp**3,nR3 ) !returns itself if NR0 = 1 ntmp = DSQRT( (4.d0*pi/3.d0)*nR3/vftmp ) END SUBROUTINE s_comp_n_from_cons !> Computes the bubble number density n from the primitive variables !! @param vftmp is the void fraction !! @param Rtmp is the bubble radii !! @param ntmp is the output number bubble density SUBROUTINE s_comp_n_from_prim( vftmp,Rtmp,ntmp ) REAL(KIND(0.D0)), INTENT(IN) :: vftmp REAL(KIND(0.D0)), DIMENSION(nb), INTENT(IN) :: Rtmp REAL(KIND(0.D0)), INTENT(OUT) :: ntmp REAL(KIND(0.D0)) :: R3 CALL s_quad( Rtmp**3,R3 ) !returns itself if NR0 = 1 ntmp = (3.d0/(4.d0*pi)) * vftmp/R3 END SUBROUTINE s_comp_n_from_prim !> Computes the quadrature for polydisperse bubble populations !! @param func is the bubble dynamic variables for each bin !! @param mom is the computed moment SUBROUTINE s_quad( func,mom ) REAL(KIND(0.D0)), DIMENSION(nb), INTENT(IN) :: func REAL(KIND(0.D0)), INTENT(OUT) :: mom mom = DOT_PRODUCT( weight,func ) END SUBROUTINE s_quad !> Computes the Simpson weights for quadrature !! @param Npt is the number of bins that represent the polydisperse bubble population SUBROUTINE s_simpson( Npt ) INTEGER, INTENT(IN) :: Npt INTEGER :: ir REAL(KIND(0.D0)) :: R0mn REAL(KIND(0.D0)) :: R0mx REAL(KIND(0.D0)) :: dphi REAL(KIND(0.D0)) :: tmp REAL(KIND(0.D0)) :: sd REAL(KIND(0.D0)), DIMENSION(Npt) :: phi ! nondiml. min. & max. initial radii for numerical quadrature !sd = 0.05D0 !R0mn = 0.75D0 !R0mx = 1.3D0 sd = poly_sigma R0mn = 0.8D0*DEXP(-2.8D0 * sd) R0mx = 0.2D0*DEXP( 9.5D0 * sd) + 1.D0 ! phi = ln( R0 ) & return R0 DO ir = 1,Npt phi(ir) = DLOG( R0mn ) & + DBLE( ir-1 )*DLOG( R0mx/R0mn )/DBLE( Npt-1 ) R0(ir) = DEXP( phi(ir) ) END DO dphi = phi(2) - phi(1) ! weights for quadrature using Simpson's rule DO ir = 2,Npt-1 ! Gaussian tmp = DEXP( -0.5D0*(phi(ir)/sd)**2 )/DSQRT( 2.D0*pi )/sd IF ( MOD(ir,2)==0 ) THEN weight(ir) = tmp*4.D0*dphi/3.D0 ELSE weight(ir) = tmp*2.D0*dphi/3.D0 END IF END DO tmp = DEXP( -0.5D0*(phi(1)/sd)**2 )/DSQRT( 2.D0*pi )/sd weight(1) = tmp*dphi/3.D0 tmp = DEXP( -0.5D0*(phi(Npt)/sd)**2 )/DSQRT( 2.D0*pi )/sd weight(Npt) = tmp*dphi/3.D0 END SUBROUTINE s_simpson END MODULE m_global_parameters
src/post_process_code/m_global_parameters.f90
Coach David Whitmire is a retired physical education Teachers in the Davis Joint Unified School District teacher and head football coach at Davis Senior High School. Coach Whitmire led the DHS Football Davis High football team for 20 years, from 1980 to 1999. Under his tenure, the Blue Devils had a record of 131684, including 18 winning seasons, five league titles, and Davis Highs only Section Championship in football (in 1988). Whitmire retired from teaching in 2006. He grew up in Davis and Graduates of the Davis Joint Unified School District graduated from Davis High School in 1964. Media http://www.cifsjs.org/pastchamps/champssportpdfs/footballsjschampions.pdf CIF SacJoaquin Section Division 1 Football Champions (PDF) http://www.davisenterprise.com/articles/2006/07/08/sports/blue_devils/191spt0.txt Retirement Story DavisEnterprise.com http://www.sacbee.com/content/sports/columns/davidson/story/14269576p15080637c.html Retirement Story SACBEE.com (login required) 20060721 02:10:44 nbsp Coach Whitmire was my 9th grade Biology teacher at Emerson Junior High School in 197273. He taught science, P.E. and coached the 9th grade football team, and other school sports. We were the Emerson Trojans, with purple and white as the school colors. He was a great teacher. Users/SharlaDaly 20061025 15:17:15 nbsp He was my 10th grade P.E. teacher. He was quite cool, and you could tell he was really proud to be apart of Davis High. I still see him sometimes at football games, most recently the homecoming game. Users/CecilioPadilla 20070223 12:10:13 nbsp He we was my PE teacher, his son is now a coach Users/StevenDaubert
lab/davisWiki/Dave_Whitmire.f
subroutine sdastp (x, y, yprime, neq, ldd, sdasf, info, h, wt, & idid, phi, delta, e, wm, iwork, & rwork, alpha, beta, gamma, psi, sigma, k) c Copyright (c) 2006, Math a la Carte, Inc. c>> 2008-10-24 sdastp Krogh Declared snrm2 c>> 2008-08-26 sdastp Hanson add argument of leading dimension to sdasf c>> 2006-05-18 sdastp Hanson Install test for inconsistent constraints c>> 2006-04-14 sdastp Krogh Zero high differences on order increase. c>> 2003-03-05 sdastp Hanson Install Soderlind stepsize code. c>> 2002-06-26 sdastp Krogh Insured iwork(lk) has current value. c>> 2001-12-12 sdastp Krogh Changed code for reverse communication c>> 2001-11-23 sdastp Krogh Changed many names per library conventions. c>> 2001-11-04 sdastp Krogh Fixes for F77 and conversion to single c>> 2001-11-01 sdastp Hanson Provide code to Math a la Carte. c--S replaces "?": ?dastp, ?dasj, ?dasco, ?dasin, ?dasf, c-- & ?dasnm, ?daslv, ?daslx, ?dasdb, ?dasgh, ?nrm2, ?copy c***BEGIN PROLOGUE SDASTP c***SUBSIDIARY c***PURPOSE Perform one step of the SDASLX integration. c***LIBRARY SLATEC (SDASLX) c***TYPE DOUBLE PRECISION (SDASTP-S, SDASTP-D) c***AUTHOR Petzold, Linda R., (LLNL) c***DESCRIPTION c----------------------------------------------------------------------- c SDASTP SOLVES A SYSTEM OF DIFFERENTIAL/ c ALGEBRAIC EQUATIONS OF THE FORM c G(X,Y,YPRIME) = 0, FOR ONE STEP (NORMALLY c FROM X TO X+H). c c THE METHODS USED ARE MODIFIED DIVIDED c DIFFERENCE,FIXED LEADING COEFFICIENT c FORMS OF BACKWARD DIFFERENTIATION c FORMULAS. THE CODE ADJUSTS THE STEPSIZE c AND ORDER TO CONTROL THE LOCAL ERROR PER c STEP. c c c THE PARAMETERS REPRESENT c X -- INDEPENDENT VARIABLE c Y -- SOLUTION VECTOR AT X c YPRIME -- DERIVATIVE OF SOLUTION VECTOR AFTER SUCCESSFUL STEP c NEQ -- NUMBER OF EQUATIONS TO BE INTEGRATED c SDASF -- EXTERNAL USER-SUPPLIED SUBROUTINE c TO EVALUATE THE RESIDUAL. THE CALL IS c CALL SDASF(X,Y,YPRIME,DELTA,D,LDD,C,IRES,RWORK,IWORK) c X,Y,YPRIME ARE INPUT. DELTA IS OUTPUT. c ON INPUT, IRES=0. SDASF SHOULD ALTER IRES ONLY c IF IT ENCOUNTERS AN ILLEGAL VALUE OF Y OR A c STOP CONDITION. SET IRES=-1 IF AN INPUT VALUE c OF Y IS ILLEGAL, AND SDASTP WILL TRY TO SOLVE c THE PROBLEM WITHOUT GETTING IRES = -1. IF c IRES=-2, SDASTP RETURNS CONTROL TO THE CALLING c PROGRAM WITH IDID = -1. IRES CAN ALSO BE SET TO C LARGE NEGATIVE VALUES TO SET DEBUGGING PRINT. c H -- APPROPRIATE STEP SIZE FOR NEXT STEP. c NORMALLY DETERMINED BY THE CODE c WT -- VECTOR OF WEIGHTS FOR ERROR CRITERION. c IDID -- COMPLETION CODE WITH THE FOLLOWING MEANINGS: c IDID= 1 -- THE STEP WAS COMPLETED SUCCESSFULLY c IDID=-1 -- IRES EQUAL TO -2 WAS ENCOUNTERED, c AND CONTROL IS BEING RETURNED TO c THE CALLING PROGRAM c IDID=-4 -- THE CORRECTOR COULD NOT CONVERGE c BECAUSE IRES WAS EQUAL TO MINUS ONE c IDID=-6 -- THE ERROR TEST FAILED REPEATEDLY c IDID=-7 -- THE CORRECTOR COULD NOT CONVERGE c IDID=-8 -- THE ITERATION MATRIX IS SINGULAR c IDID=-9 -- THE CORRECTOR COULD NOT CONVERGE. c THERE WERE REPEATED ERROR TEST c FAILURES ON THIS STEP. c PHI -- ARRAY OF DIVIDED DIFFERENCES USED BY c SDASTP. THE LENGTH IS NEQ*(K+1),WHERE c K IS THE MAXIMUM ORDER c DELTA,E -- WORK VECTORS FOR SDASTP OF LENGTH NEQ c WM,IWORK -- REAL AND INTEGER ARRAYS STORING c MATRIX INFORMATION SUCH AS THE MATRIX c OF PARTIAL DERIVATIVES,PERMUTATION c VECTOR, AND VARIOUS OTHER INFORMATION. c RWORK -- THE USUAL WORK ARRAY. c ALPHA, BETA, GAMMA, PSI, SIGMA -- USED FOR INTEGRATION c COEFFICIENTS. c K -- THE CURRENT INTEGRATION ORDER. c c THE OTHER PARAMETERS ARE INFORMATION c WHICH IS NEEDED INTERNALLY BY SDASTP TO c CONTINUE FROM STEP TO STEP. c c----------------------------------------------------------------------- c***ROUTINES CALLED SDASJ, SDASNM, SDASLV, SDASIN c***REVISION HISTORY (YYMMDD) c 830315 DATE WRITTEN c 901009 Finished conversion to SLATEC 4.0 format (F.N.Fritsch) c 901019 Merged changes made by C. Ulrich with SLATEC 4.0 format. c 901026 Added explicit declarations for all variables and minor c cosmetic changes to prologue. (FNF) c 981119 Replaced RES, JAC by SDASF, RJH. c***END PROLOGUE SDASTP c integer neq, ldd, idid, iwork(*), k, info(16) real x, y(*), yprime(*), h, wt(*), phi(neq,*), & delta(*), e(*), wm(*), rwork(*), alpha(*), beta(*), & gamma(*), psi(*), sigma(*) external sdasf c external sdasj, sdasnm, sdaslv, sdasin, snrm2 real sdasnm c integer i,ires, j, j1, kdiff, km1, knew, kp1, kp2, & m, maxit, ncf, nef, nsf, nsp1 real alpha0, alphas, cjlast, ck, delnrm, enorm, erk, & erkm1, erkm2, erkp1, err, est, hnew, oldnrm, pnorm, & r, rate, temp1, temp2, terk, terkm1, terkm2, terkp1, & xold, xrate, sc C SDASGH -- computes the new stepsize. There are three controllers C one can choose: H211b(b=4), PI.4.2 and standard C control. C CTRNM -- the name of controller: C CTRNM = H211B4: H221B(B=4) controller <= only one used C = PI42: PI.4.2 controller C = STAND: standard controller C default controller is H211b4 <= only one used real ESTOLD, RATIO logical convgd c data maxit/4/ data xrate/0.25e0/ integer locate c c POINTERS INTO IWORK integer lml, lmu, lires, ldelt, lwm, lmxord, lk, lkold, lmat, & lcnstr, lns, lnstl, lnst, lnre, lnje, letf, lctf, lnpd, & ljcalc, lphase, revloc, mxstep, le, lwt, lphi, ntemp, lipvt parameter (lml=1, lmu=2, lires=3, ldelt=4, lwm=5, lmxord=6, lk=7, & lkold=8, lmat=9, lcnstr=10, lns=11, lnstl=12, lnst=13, & lnre=14, lnje=15, letf=16, lctf=17, lnpd=18, ljcalc=19, & lphase=20, revloc=21, mxstep=22, le=23, lwt=24, lphi=25, & ntemp=26, lipvt=31) c c POINTERS INTO RWORK integer lcj, ltstop, lhmax, lh, ltn, lcjold, lhold, lnjac, & lround, lhmin, lalpha, lbeta, lgamma, lpsi, lsigma, ldelta parameter (lcj=1, ltstop=2, lhmax=3, lh=4, ltn=5, lcjold=6, & lhold=7, lnjac=8, lround=9, lhmin=10, lalpha=11, lbeta=17, & lgamma=23, lpsi=29, lsigma=35, ldelta=46) c c POINTERS INTO INFO integer itol, iout, istop, imat, idb, imaxh, ih0, iord, icnstr, & inityp, ixstep parameter (itol=2, iout=3, istop=4, imat=5, idb=6, imaxh=7, & ih0=8, iord=9, icnstr=10, inityp=11, ixstep= 12) integer ISMOOT, IFIRST parameter (ISMOOT=13, IFIRST=16) real conrate, snrm2 save c c----------------------------------------------------------------------- c BLOCK 1. c INITIALIZE. ON THE FIRST CALL,SET c THE ORDER TO 1 AND INITIALIZE c OTHER VARIABLES. c----------------------------------------------------------------------- c c INITIALIZATIONS FOR ALL CALLS c***FIRST EXECUTABLE STATEMENT SDASTP locate = mod(iwork(revloc), 8) if (locate .gt. 0) then ires = iwork(lires) iwork(revloc) = iwork(revloc) / 8 go to (130, 140, 145, 190, 230, 260, 286), locate end if c No reverse communication active if (locate .lt. 0) then c FIRST STEP INITIALIZATIONS iwork(letf) = 0 iwork(lctf) = 0 rwork(lhold) = 0.0e0 psi(1) = h rwork(lcjold) = 1.0e0/h rwork(lcj) = rwork(lcjold) rwork(lnjac) = 100.e0 iwork(ljcalc) = -1 delnrm = 1.0e0 iwork(lphase) = 0 iwork(lns) = 0 iwork(revloc) = 0 RATIO =1.E0 end if c Not doing reverse communication idid = 1 xold = x ncf = 0 nsf = 0 nef = 0 c----------------------------------------------------------------------- c BLOCK 2 c COMPUTE COEFFICIENTS OF FORMULAS FOR c THIS STEP. c----------------------------------------------------------------------- 20 continue k = iwork(lk) kp1 = k + 1 kp2 = k + 2 km1 = k - 1 xold = x if ((h.ne.rwork(lhold)) .or. (k.ne.iwork(lkold))) iwork(lns) = 0 iwork(lns) = min(iwork(lns) + 1, iwork(lkold) + 2) nsp1 = iwork(lns) + 1 if (kp1 .lt. iwork(lns)) go to 40 c beta(1) = 1.0e0 alpha(1) = 1.0e0 temp1 = h gamma(1) = 0.0e0 sigma(1) = 1.0e0 do 30 i=2, kp1 temp2 = psi(i-1) psi(i-1) = temp1 beta(i) = beta(i-1)*psi(i-1)/temp2 temp1 = temp2 + h alpha(i) = h/temp1 sigma(i) = (i-1)*sigma(i-1)*alpha(i) gamma(i) = gamma(i-1) + alpha(i-1)/h 30 continue psi(kp1) = temp1 40 continue c c COMPUTE ALPHAS, ALPHA0 alphas = 0.0e0 alpha0 = 0.0e0 do 50 i=1, k alphas = alphas - 1.0e0/i alpha0 = alpha0 - alpha(i) 50 continue c c COMPUTE LEADING COEFFICIENT RWORK(LCJ) cjlast = rwork(lcj) rwork(lcj) = -alphas/h c c COMPUTE VARIABLE STEPSIZE ERROR COEFFICIENT CK ck = abs(alpha(kp1)+alphas-alpha0) ck = max(ck,alpha(kp1)) c c DECIDE WHETHER NEW JACOBIAN IS NEEDED temp1 = (1.0e0-xrate)/(1.0e0+xrate) temp2 = 1.0e0/temp1 if ((rwork(lcj)/rwork(lcjold).lt.temp1) .or. & (rwork(lcj)/rwork(lcjold).gt.temp2)) iwork(ljcalc) = -1 if (rwork(lcj) .ne. cjlast) rwork(lnjac) = 100.e0 c c CHANGE PHI TO PHI STAR if (kp1 .lt. nsp1) go to 80 do 70 j=nsp1, kp1 do 60 i=1, neq 60 phi(i,j) = beta(j)*phi(i,j) 70 continue 80 continue c c UPDATE TIME x = x + h c c----------------------------------------------------------------------- c BLOCK 3 c PREDICT THE SOLUTION AND DERIVATIVE, c AND SOLVE THE CORRECTOR EQUATION c----------------------------------------------------------------------- c c stepping past TOUT. Y(:)} is obtained by interpolation. c YPRIME(:) is obtained by interpolation. c 4 The integration has paused for reverse communication. Respond c based on the values of IRES c Task Interupted c -1 IRES set to -2 by the user. c -2 Accuracy requested exceeds machine precision. RTOL and ATOL c have been increased. c -3 There have been too many steps between output points. c Quit or Restart Integration c c FIRST,PREDICT THE SOLUTION AND DERIVATIVE 90 continue do 100 i=1, neq y(i) = phi(i,1) 100 yprime(i) = 0.0e0 do 120 j=2, kp1 do 110 i=1, neq y(i) = y(i) + phi(i,j) 110 yprime(i) = yprime(i) + gamma(j)*phi(i,j) 120 continue pnorm = sdasnm(neq,y,wt,rwork,iwork) c c SOLVE THE CORRECTOR EQUATION USING A c MODIFIED NEWTON SCHEME. convgd = .true. m = 0 iwork(lnre) = iwork(lnre) + 1 ires = 1 if (info(idb) .ne. 0) call sdasdb(2, neq, x, y, yprime, & info, rwork, iwork, ires, rwork, rwork) if (iwork(lmat) .ge. 0) then call sdasf (x, y, yprime, delta, wm, LDD, rwork(lcj), & ires, rwork, iwork) else iwork(lires) = ires c Need to put locations [from E(*)] to DELTA(*). iwork(revloc) = 8 * iwork(revloc) + 1 return end if c REVERSE ENTRY 1: 130 continue if (info(idb) .ne. 0) call sdasdb(3, neq, x, y, yprime, & info, rwork, iwork, ires, rwork, rwork) if (ires .lt. 0) then if (ires .ge. -2) go to 290 info(idb) = -ires ires = 0 end if c c IF INDICATED,REEVALUATE THE c ITERATION MATRIX PD = DG/DY + RWORK(LCJ)*DG/DYPRIME c (WHERE G(X,Y,YPRIME)=0). SET c IWORK(LJCALC) TO 0 AS AN INDICATOR THAT c THIS HAS BEEN DONE. if (iwork(ljcalc) .ne. -1) go to 150 iwork(lnje) = iwork(lnje) + 1 iwork(ljcalc) = 0 c REVERSE ENTRY 2: 140 continue call sdasj (neq, ldd, x, y, yprime, delta,h, wt, e, & wm, iwork, rwork, sdasf, info, ires) if (iwork(revloc) .ne. 0) then if (iwork(revloc) .lt. 0) then iwork(revloc) = 3 else iwork(revloc) = 8 * iwork(revloc) + 2 end if return end if c REVERSE ENTRY 3: 145 continue rwork(lcjold) = rwork(lcj) rwork(lnjac) = 100.e0 if (ires .lt. 0) then if (ires .ge. -2) go to 290 info(idb) = -ires ires = 0 end if if (ires .ne. 0) go to 290 nsf = 0 c c c INITIALIZE THE ERROR ACCUMULATION VECTOR E. 150 continue do 160 i=1, neq 160 e(i) = 0.0e0 c c c CORRECTOR LOOP. 170 continue c c MULTIPLY RESIDUAL BY TEMP1 TO ACCELERATE CONVERGENCE temp1 = 2.0e0/(1.0e0+rwork(lcj)/rwork(lcjold)) do 180 i=1, neq 180 delta(i) = delta(i)*temp1 c c COMPUTE A NEW ITERATE (BACK-SUBSTITUTION). c STORE THE CORRECTION IN DELTA. call sdaslv (neq, ldd, x, y, yprime, delta, sdasf, info, & iwork, rwork) if (iwork(revloc) .lt. 0) then iwork(revloc) = 4 return end if c REVERSE ENTRY 4: 190 continue if (info(idb) .ne. 0) call sdasdb(4, neq, x, y, yprime, & info, rwork, iwork, ires, wt, rwork) c c UPDATE Y, E, AND YPRIME do 200 i=1, neq y(i) = y(i) - delta(i) e(i) = e(i) - delta(i) 200 yprime(i) = yprime(i) - rwork(lcj)*delta(i) c c TEST FOR CONVERGENCE OF THE ITERATION delnrm = sdasnm(neq,delta,wt,rwork,iwork) C C Set convergence rate allowed as Soderlind proposes: CONRATE=0.125E0 IF(INFO(ISMOOT) .ne. 0) CONRATE=.33E0 if (delnrm .le. 100.e0 * rwork(lround) * pnorm) go to 250 if (m .gt. 0) go to 210 oldnrm = delnrm go to 220 210 rate = (delnrm/oldnrm)**(1.0e0/m) if (rate .gt. 0.90e0) go to 240 rwork(lnjac) = rate / (1.0e0 - rate) 220 CONTINUE if ((rwork(lnjac) * delnrm) .le. CONRATE) go to 250 c c THE CORRECTOR HAS NOT YET CONVERGED. c UPDATE M AND TEST WHETHER THE c MAXIMUM NUMBER OF ITERATIONS HAVE c BEEN TRIED. m = m + 1 if (m .ge. maxit) go to 240 c c EVALUATE THE RESIDUAL c AND GO BACK TO DO ANOTHER ITERATION iwork(lnre) = iwork(lnre) + 1 ires = 1 if (info(idb) .ne. 0) call sdasdb(2, neq, x, y, yprime, & info, rwork, iwork, ires, rwork, rwork) if (iwork(lmat) .ge. 0) then call sdasf (x, y, yprime, delta, wm, LDD, rwork(lcj), & ires, rwork, iwork) else iwork(lires) = ires iwork(revloc) = 5 return end if c REVERSE ENTRY 5: 230 continue if (info(idb) .ne. 0) call sdasdb(3, neq, x, y, yprime, & info, rwork, iwork, ires, rwork, rwork) if (ires .lt. 0) then if (ires .ge. -2) go to 290 info(idb) = -ires ires = 0 end if go to 170 c THE CORRECTOR FAILED TO CONVERGE IN MAXIT c ITERATIONS. IF THE ITERATION MATRIX c IS NOT CURRENT,RE-DO THE STEP WITH c A NEW ITERATION MATRIX. 240 continue if (iwork(ljcalc) .eq. 0) go to 290 iwork(ljcalc) = -1 go to 90 c THE ITERATION HAS CONVERGED. IF CONSTRAINTS on SOLUTION are c REQUIRED, SET THE SOLUTION, IF THE PERTURBATION c TO DO IT IS SMALL ENOUGH. IF THE CHANGE IS TOO LARGE, THEN c CONSIDER THE CORRECTOR ITERATION TO HAVE FAILED. c Also have an option right here to project back onto constraints. c This is primarily for problems that started with index > 1. 250 if (iwork(lcnstr) .eq. 0) go to 300 C Define weights to use for projecting back to constraints. DO 255 I=1,NEQ C DELTA(I)=ONE/WT(I) DELTA(I)=WT(I) c DELTA(I)=sqrt(WT(I)) 255 CONTINUE ires = 5 if (info(idb) .ne. 0) call sdasdb(2, neq, x, y, yprime, & info, rwork, iwork, ires, rwork, rwork) if (iwork(lmat) .gt. 0) then call sdasf (x, y, yprime, delta, wm, LDD, rwork(lcj), & ires, rwork, iwork) else iwork(lires) = ires c Need to put constraint change in DELTA(*). iwork(revloc) = 6 return end if c REVERSE ENTRY 6: 260 continue if (info(idb) .ne. 0) call sdasdb(3, neq, x, y, yprime, & info, rwork, iwork, ires, rwork, rwork) if (ires .lt. 0) then if (ires .ge. -2) go to 290 info(idb) = -ires ires = 0 end if c The user has computed info for constraints. Compute a single weig c least-distance Newton step back to the constraints. Put move into c delta(:). if (abs(iwork(lmat)) .le. 4) & call sdasco (wm(neq+1), ldd, neq, wt, delta) c If ldd .eq. neq there are no constraints. Nothing needs c to be done. if(ldd .eq. neq) go to 300 delnrm = sdasnm(neq,delta,wt,rwork,iwork) sc = sdasnm(neq,e,wt,rwork,iwork) if (delnrm .le. sc ) then do 270 i=1, neq 270 e(i) = e(i) - delta(i) else do 280 i=1, neq c Scale change so it is no larger that the current size of e(:). 280 e(i) = e(i) - (sc/delnrm)*delta(i) end if C Check if the residual norm for the linear system was positive. C If so then compare this value with what a perturbation in y implies C for a perturbation in the constraints. if(delta(neq+1) .eq. 0) go to 300 C Save a copy of the solution call scopy(neq, y, 1, delta, 1) C Perturb the solution values in units of the largest amount of C error allowed on each component. A random number could be used C here instead of 1, -1, 1, .... sc=1 do 285 i = 1,neq y(i) = y(i) + sc/wt(i) sc = -sc 285 continue ires = 5 sc = delta(neq+1) if (iwork(lmat) .gt. 0) then call sdasf (x, y, yprime, delta, wm, LDD, rwork(lcj), & ires, rwork, iwork) else iwork(lires) = ires iwork(revloc) = 7 return end if c REVERSE ENTRY 7: 286 continue c Compute the residual norm on the constraints with the c perturbation. delnrm = snrm2(ldd-neq,delta(neq+1),1) c If the solution residual norm is almost as large c as the perturbation norm then there is a serious problem. if(sc .ge. 0.5*delnrm)then c This is the error flag assigned to this condition. IDID = -30 c These values are needed to respond to the error condition. delta(1)=sc delta(2)=delnrm return end if C Restore the solution if the system appears consistent. call scopy(neq, delta, 1, y, 1) go to 300 c c c EXITS FROM BLOCK 3 c NO CONVERGENCE WITH CURRENT ITERATION c MATRIX,OR SINGULAR ITERATION MATRIX 290 convgd = .false. if (ires .eq. -2) then idid = -1 return end if c 300 iwork(ljcalc) = 1 if (.not.convgd) go to 490 c----------------------------------------------------------------------- c BLOCK 4 c ESTIMATE THE ERRORS AT ORDERS K,K-1,K-2 c AS IF CONSTANT STEPSIZE WAS USED. ESTIMATE c THE LOCAL ERROR AT ORDER K AND TEST c stepping past TOUT. Y(:)} is obtained by interpolation. c YPRIME(:) is obtained by interpolation. c 4 The integration has paused for reverse communication. Respond c based on the values of IRES. c Task Interupted c -1 IRES set to -2 by the user. c -2 Accuracy requested exceeds machine precision. RTOL and ATOL c have been increased. c -3 There have been too many steps between output points. c Quit or Restart Integration c c WHETHER THE CURRENT STEP IS SUCCESSFUL. c----------------------------------------------------------------------- c c ESTIMATE ERRORS AT ORDERS K,K-1,K-2 IF(INFO(IFIRST) .NE. 0) ESTOLD = EST enorm = sdasnm(neq,e,wt,rwork,iwork) erk = sigma(k+1)*enorm terk = (k+1)*erk est = erk knew = k if (k .eq. 1) go to 350 c To check if order should be decreased do 310 i=1, neq delta(i) = phi(i,kp1) + e(i) 310 continue erkm1 = sigma(k)*sdasnm(neq,delta,wt,rwork,iwork) terkm1 = k*erkm1 if (k .gt. 2) go to 320 if (terkm1 .le. 0.5e0*terk) go to 340 go to 350 320 continue do 330 i=1, neq 330 delta(i) = phi(i,k) + delta(i) erkm2 = sigma(k-1)*sdasnm(neq,delta,wt,rwork,iwork) terkm2 = (k-1)*erkm2 if (max(terkm1,terkm2) .gt. terk) go to 350 c LOWER THE ORDER 340 continue knew = k - 1 est = erkm1 c c c CALCULATE THE LOCAL ERROR FOR THE CURRENT STEP c TO SEE IF THE STEP WAS SUCCESSFUL 350 continue err = ck*enorm if (err .gt. 1.0e0) go to 490 c----------------------------------------------------------------------- c BLOCK 5 c THE STEP IS SUCCESSFUL. DETERMINE c THE BEST ORDER AND STEPSIZE FOR c THE NEXT STEP. UPDATE THE DIFFERENCES c FOR THE NEXT STEP. c----------------------------------------------------------------------- idid = 1 iwork(lnst) = iwork(lnst) + 1 kdiff = k - iwork(lkold) iwork(lkold) = k rwork(lhold) = h c c c ESTIMATE THE ERROR AT ORDER K+1 UNLESS: c ALREADY DECIDED TO LOWER ORDER, OR c ALREADY USING MAXIMUM ORDER, OR c STEPSIZE NOT CONSTANT, OR c ORDER RAISED IN PREVIOUS STEP if ((knew .eq. km1) .or. (k .eq. iwork(lmxord))) iwork(lphase) = 1 if (iwork(lphase) .eq. 0) go to 400 if (knew .eq. km1) go to 390 if (k .eq. iwork(lmxord)) go to 410 C Free the order and let the error sequence decide if the order C gets increased or otherwise changed. if (INFO(ISMOOT) .ne. 0 .and. ((kp1 .ge. iwork(lns)) * .or. (kdiff .eq. 1))) go to 410 do 360 i = 1, neq c stepping past TOUT. Y(:)} is obtained by interpolation. c YPRIME(:) is obtained by interpolation. c 4 The integration has paused for reverse communication. Respond c based on the values of IRES. c Task Interupted c -1 IRES set to -2 by the user. c -2 Accuracy requested exceeds machine precision. RTOL and ATOL c have been increased. c -3 There have been too many steps between output points. c Quit or Restart Integration c 360 delta(i) = e(i) - phi(i,kp2) erkp1 = (1.0e0/(k+2))*sdasnm(neq,delta,wt,rwork,iwork) terkp1 = (k+2)*erkp1 if (k .gt. 1) go to 370 if (terkp1 .ge. 0.5e0*terk) go to 410 go to 380 370 if (terkm1 .le. min(terk,terkp1)) go to 390 if (terkp1.ge.terk .or. k.eq.iwork(lmxord)) go to 410 c c RAISE ORDER 380 k = kp1 est = erkp1 if (k .lt. iwork(lmxord)) then do 385 i = 1, neq phi(i,k+2) = 0.e0 385 continue end if go to 410 c c LOWER ORDER 390 k = km1 est = erkm1 go to 410 c c IF IWORK(LPHASE) = 0, INCREASE ORDER BY 1 AND MULTIPLY STEPSIZE BY c FACTOR 2 400 k = kp1 IF(INFO(IFIRST) .EQ. 0) ESTOLD = EST C Selectively use Soderlind's smoothing: IF(info(ISMOOT).ne. 0) THEN hnew = h*2.0e0 h = hnew go to 440 END IF c c c DETERMINE THE APPROPRIATE STEPSIZE FOR c THE NEXT STEP. 410 CONTINUE IF(info(ISMOOT).ne.0) THEN hnew = h temp2 = k + 1 r = (2.0e0*est+0.0001e0)**(-1.0e0/temp2) if (r .lt. 2.0e0) go to 420 hnew = 2.0e0*h go to 430 420 if (r .gt. 1.0e0) go to 430 r = max(0.5e0,min(0.9e0,r)) hnew = h*r 430 h = hnew go to 440 ELSE C New Soderlind logic goes here: temp2 = k + 1 call sdasgh(EST,ESTOLD,RATIO,H,HNEW,TEMP2) h=hnew END IF c c UPDATE DIFFERENCES FOR NEXT STEP 440 continue if (iwork(lkold) .eq. iwork(lmxord)) go to 460 do 450 i=1, neq 450 phi(i,kp2) = e(i) 460 continue do 470 i=1, neq 470 phi(i,kp1) = phi(i,kp1) + e(i) do 480 j1=2, kp1 j = kp1 - j1 + 1 do 475 i=1, neq phi(i,j) = phi(i,j) + phi(i,j+1) 475 continue 480 continue iwork(lk) = k INFO(IFIRST) = 1 return c----------------------------------------------------------------------- c BLOCK 6 c THE STEP IS UNSUCCESSFUL. RESTORE X,PSI,PHI c DETERMINE APPROPRIATE STEPSIZE FOR c CONTINUING THE INTEGRATION, OR EXIT WITH c AN ERROR FLAG IF THERE HAVE BEEN MANY c FAILURES. c----------------------------------------------------------------------- 490 iwork(lphase) = 1 c c RESTORE X,PHI,PSI x = xold if (kp1 .lt. nsp1) go to 520 do 510 j=nsp1, kp1 temp1 = 1.0e0/beta(j) do 500 i=1, neq 500 phi(i,j) = temp1*phi(i,j) 510 continue 520 continue do 530 i=2, kp1 530 psi(i-1) = psi(i) - h c c c TEST WHETHER FAILURE IS DUE TO CORRECTOR ITERATION c OR ERROR TEST if (convgd) go to 560 iwork(lctf) = iwork(lctf) + 1 c c c THE NEWTON ITERATION FAILED TO CONVERGE WITH c A CURRENT ITERATION MATRIX. DETERMINE THE CAUSE c OF THE FAILURE AND TAKE APPROPRIATE ACTION. if (ires .eq. 0) go to 540 c c THE ITERATION MATRIX IS SINGULAR. REDUCE c THE STEPSIZE BY A FACTOR OF 4. IF c THIS HAPPENS THREE TIMES IN A ROW ON c THE SAME STEP, RETURN WITH AN ERROR FLAG nsf = nsf + 1 r = 0.25e0 h = h*r if ((nsf.lt.3) .and. (abs(h) .ge. rwork(lhmin))) go to 600 idid = -8 go to 590 c c c THE NEWTON ITERATION FAILED TO CONVERGE FOR A REASON c OTHER THAN A SINGULAR ITERATION MATRIX. IF IRES = -2, THEN c RETURN. OTHERWISE, REDUCE THE STEPSIZE AND TRY AGAIN, UNLESS c TOO MANY FAILURES HAVE OCCURRED. 540 continue if (ires .eq. -2) then idid = -1 else ncf = ncf + 1 r = 0.25e0 h = h*r if ((ncf.lt.10) .and. (abs(h) .ge. rwork(lhmin))) go to 600 idid = -7 if (ires .eq. -1) idid = -4 if (nef .ge. 3) idid = -9 end if go to 590 c c c THE NEWTON SCHEME CONVERGED, AND THE CAUSE c OF THE FAILURE WAS THE ERROR ESTIMATE c EXCEEDING THE TOLERANCE. 560 nef = nef + 1 iwork(letf) = iwork(letf) + 1 if (nef .gt. 1) go to 570 c c ON FIRST ERROR TEST FAILURE, KEEP CURRENT ORDER OR LOWER c ORDER BY ONE. COMPUTE NEW STEPSIZE BASED ON DIFFERENCES c OF THE SOLUTION. k = knew temp2 = k + 1 IF(INFO(ISMOOT) .ne. 0) THEN r = 0.90e0*(2.0e0*est+0.0001e0)**(-1.0e0/temp2) r = max(0.25e0,min(0.9e0,r)) h = h*r ELSE CALL sdasgh(EST,ESTOLD,RATIO,H,HNEW,TEMP2) H = HNEW END IF if (abs(h) .ge. rwork(lhmin)) go to 600 idid = -6 go to 590 c c ON SECOND ERROR TEST FAILURE, USE THE CURRENT ORDER OR c DECREASE ORDER BY ONE. REDUCE THE STEPSIZE BY A FACTOR OF c FOUR. 570 if (nef .gt. 2) go to 580 iwork(lk) = knew h = 0.25e0*h if (abs(h) .ge. rwork(lhmin)) go to 600 idid = -6 go to 590 c c ON THIRD AND SUBSEQUENT ERROR TEST FAILURES, SET THE ORDER TO c ONE AND REDUCE THE STEPSIZE BY A FACTOR OF FOUR. 580 iwork(lk) = 1 h = 0.25e0*h if (abs(h) .ge. rwork(lhmin)) go to 600 idid = -6 go to 590 c c FOR ALL CRASHES, RESTORE Y TO ITS LAST VALUE, c INTERPOLATE TO FIND YPRIME AT LAST X, AND RETURN 590 continue call sdasin (x, x, y, yprime, neq, k, phi, psi) k=k return c c c GO BACK AND TRY THIS STEP AGAIN 600 CONTINUE go to 20 c c------END OF SUBROUTINE SDASTP------ end
src/MATH77/sdastp.f
A number of products have their origins in Davis, including: Afghan Pepper Company Afghan Pepper Company hot sauce not in production yet BRÜBAR Energy Bars http://diamondtrustgame.com/buy.php Diamond Trust of London Nintendo DS game (http://www.kickstarter.com/projects/1443658586/diamondtrustoflondon More Info) Moller International Flying cars (https://www.youtube.com/watch?vJ7dJvFoTx3Q sort of...) Schilling Robotics Robotic arms and Schilling Robotics Remotely operated submersible vehicles Serenade agricultural fungicide, created by AgraQuest Embedded JK microsystems Single Board Computers Mori Seiki http://www.dmgmoriseikiusa.com/nhxseries/nhx4000 NHX4000 horizontal machining centers The Philosophers Stoneground sprouted almond butter Sudwerk Sudwerk beer, including Aggie Lager UC Davis Olive Oil Users/BillKendrick Tux Paint Former Davis products: FlavrSavr tomato, created by CalGene LLC Square Tomato YummyDummy Chocolate Company YummyDummy Chocolate Canned Fruit Cocktail was invented by Dr. Cruess, for whom Cruess Hall is named
lab/davisWiki/Local_Products.f
! SPDX-Identifier: MIT module test_example use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test implicit none private public :: collect_example !> Single precision real numbers integer, parameter :: sp = selected_real_kind(6) !> Double precision real numbers integer, parameter :: dp = selected_real_kind(15) !> Char length for integers integer, parameter :: i1 = selected_int_kind(2) !> Short length for integers integer, parameter :: i2 = selected_int_kind(4) !> Length of default integers integer, parameter :: i4 = selected_int_kind(9) !> Long length for integers integer, parameter :: i8 = selected_int_kind(18) contains !> Collect all exported unit tests subroutine collect_example(testsuite) !> Collection of tests type(unittest_type), allocatable, intent(out) :: testsuite(:) testsuite = [ & new_unittest("success", test_success), & new_unittest("failure", test_failure, should_fail=.true.), & new_unittest("failure-message", test_failure_message, should_fail=.true.), & new_unittest("skipped", test_skipped), & new_unittest("expression", test_expression), & new_unittest("expression-fail", test_expression_fail, should_fail=.true.), & new_unittest("expression-message", test_expression_message, should_fail=.true.), & new_unittest("real-single-abs", test_rsp_abs), & new_unittest("real-single-rel", test_rsp_rel), & new_unittest("real-single-abs-fail", test_rsp_abs_fail, should_fail=.true.), & new_unittest("real-single-rel-fail", test_rsp_rel_fail, should_fail=.true.), & new_unittest("real-single-abs-message", test_rsp_abs_message, should_fail=.true.), & new_unittest("real-double-abs", test_rdp_abs), & new_unittest("real-double-rel", test_rdp_rel), & new_unittest("real-double-abs-fail", test_rdp_abs_fail, should_fail=.true.), & new_unittest("real-double-rel-fail", test_rdp_rel_fail, should_fail=.true.), & new_unittest("real-double-abs-message", test_rdp_abs_message, should_fail=.true.), & new_unittest("complex-single-abs", test_csp_abs), & new_unittest("complex-single-rel", test_csp_rel), & new_unittest("complex-single-abs-fail", test_csp_abs_fail, should_fail=.true.), & new_unittest("complex-single-rel-fail", test_csp_rel_fail, should_fail=.true.), & new_unittest("complex-single-abs-message", test_csp_abs_message, should_fail=.true.), & new_unittest("complex-double-abs", test_cdp_abs), & new_unittest("complex-double-rel", test_cdp_rel), & new_unittest("complex-double-abs-fail", test_cdp_abs_fail, should_fail=.true.), & new_unittest("complex-double-rel-fail", test_cdp_rel_fail, should_fail=.true.), & new_unittest("complex-double-abs-message", test_cdp_abs_message, should_fail=.true.), & new_unittest("integer-char", test_i1), & new_unittest("integer-char-fail", test_i1_fail, should_fail=.true.), & new_unittest("integer-char-message", test_i1_message, should_fail=.true.), & new_unittest("integer-short", test_i2), & new_unittest("integer-short-fail", test_i2_fail, should_fail=.true.), & new_unittest("integer-short-message", test_i2_message, should_fail=.true.), & new_unittest("integer-default", test_i4), & new_unittest("integer-default-fail", test_i4_fail, should_fail=.true.), & new_unittest("integer-default-message", test_i4_message, should_fail=.true.), & new_unittest("integer-long", test_i8), & new_unittest("integer-long-fail", test_i8_fail, should_fail=.true.), & new_unittest("integer-long-message", test_i8_message, should_fail=.true.), & new_unittest("logical-default-true", test_l4_true), & new_unittest("logical-default-false", test_l4_false), & new_unittest("logical-default-fail", test_l4_fail, should_fail=.true.), & new_unittest("logical-default-message", test_l4_message, should_fail=.true.), & new_unittest("character", test_char), & new_unittest("character-fail", test_char_fail, should_fail=.true.), & new_unittest("character-message", test_char_message, should_fail=.true.) & ] end subroutine collect_example subroutine test_success(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, 0) end subroutine test_success subroutine test_failure(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, 7) end subroutine test_failure subroutine test_failure_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, 4, "Custom message describing the error") end subroutine test_failure_message subroutine test_skipped(error) !> Error handling type(error_type), allocatable, intent(out) :: error call skip_test(error, "This test is always skipped") end subroutine test_skipped subroutine test_expression(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, index("info!", "!") > 0) end subroutine test_expression subroutine test_expression_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, index("info!", "?") > 0) end subroutine test_expression_fail subroutine test_expression_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, index("info!", "!") == 0, 'index("info!", "!") == 0') end subroutine test_expression_message subroutine test_rsp_abs(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(sp) :: val val = 3.3_sp call check(error, val, 3.3_sp, thr=sqrt(epsilon(val))) end subroutine test_rsp_abs subroutine test_rsp_rel(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(sp) :: val val = 3.3_sp call check(error, val, 3.3_sp, rel=.true.) end subroutine test_rsp_rel subroutine test_rsp_abs_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(sp) :: val val = 1.0_sp call check(error, val, 2.0_sp) end subroutine test_rsp_abs_fail subroutine test_rsp_rel_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(sp) :: val val = 1.0_sp call check(error, val, 1.5_sp, rel=.true.) end subroutine test_rsp_rel_fail subroutine test_rsp_abs_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(sp) :: val val = 1.0_sp call check(error, val, 1.5_sp, message="Actual value is not 1.5") end subroutine test_rsp_abs_message subroutine test_rdp_abs(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(dp) :: val val = 3.3_dp call check(error, val, 3.3_dp, thr=sqrt(epsilon(val))) end subroutine test_rdp_abs subroutine test_rdp_rel(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(dp) :: val val = 3.3_dp call check(error, val, 3.3_dp, rel=.true.) end subroutine test_rdp_rel subroutine test_rdp_abs_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(dp) :: val val = 1.0_dp call check(error, val, 2.0_dp) end subroutine test_rdp_abs_fail subroutine test_rdp_rel_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(dp) :: val val = 1.0_dp call check(error, val, 1.5_dp, rel=.true.) end subroutine test_rdp_rel_fail subroutine test_rdp_abs_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error real(dp) :: val val = 1.0_dp call check(error, val, 1.5_dp, message="Actual value is not 1.5") end subroutine test_rdp_abs_message subroutine test_csp_abs(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(sp) :: val val = cmplx(3.3_sp, 1.0_sp, sp) call check(error, val, cmplx(3.3_sp, 1.0_sp, sp), thr=sqrt(epsilon(abs(val)))) end subroutine test_csp_abs subroutine test_csp_rel(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(sp) :: val val = cmplx(3.3_sp, 1.0_sp, sp) call check(error, val, cmplx(3.3_sp, 1.0_sp, sp), rel=.true.) end subroutine test_csp_rel subroutine test_csp_abs_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(sp) :: val val = cmplx(1.0_sp, 2.0_sp, sp) call check(error, val, cmplx(2.0_sp, 1.0_sp, sp)) end subroutine test_csp_abs_fail subroutine test_csp_rel_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(sp) :: val val = cmplx(1.0_sp, 1.5_sp, sp) call check(error, val, cmplx(1.5_sp, 1.0_sp, sp), rel=.true.) end subroutine test_csp_rel_fail subroutine test_csp_abs_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(sp) :: val val = cmplx(1.0_sp, 1.5_sp, sp) call check(error, val, cmplx(1.5_sp, 1.0_sp, sp), message="Actual value is not 1.5+1.0i") end subroutine test_csp_abs_message subroutine test_cdp_abs(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(dp) :: val val = cmplx(3.3_dp, 1.0_dp, dp) call check(error, val, cmplx(3.3_dp, 1.0_dp, dp), thr=sqrt(epsilon(real(val)))) end subroutine test_cdp_abs subroutine test_cdp_rel(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(dp) :: val val = cmplx(3.3_dp, 1.0_dp, dp) call check(error, val, cmplx(3.3_dp, 1.0_dp, dp), rel=.true.) end subroutine test_cdp_rel subroutine test_cdp_abs_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(dp) :: val val = cmplx(1.0_dp, 2.0_dp, dp) call check(error, val, cmplx(2.0_dp, 1.0_dp, dp)) end subroutine test_cdp_abs_fail subroutine test_cdp_rel_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(dp) :: val val = cmplx(1.0_dp, 1.5_dp, dp) call check(error, val, cmplx(1.5_dp, 1.0_dp, dp), rel=.true.) end subroutine test_cdp_rel_fail subroutine test_cdp_abs_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error complex(dp) :: val val = cmplx(1.0_dp, 1.5_dp, dp) call check(error, val, cmplx(1.5_dp, 1.0_dp, dp), message="Actual value is not 1.5+1.0i") end subroutine test_cdp_abs_message subroutine test_i1(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i1) :: val val = 3_i1 call check(error, val, 3_i1) end subroutine test_i1 subroutine test_i1_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i1) :: val val = 3_i1 call check(error, val, -4_i1) end subroutine test_i1_fail subroutine test_i1_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i1) :: val val = -3_i1 call check(error, val, 7_i1, "Actual value is not seven") end subroutine test_i1_message subroutine test_i2(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i2) :: val val = 3_i2 call check(error, val, 3_i2) end subroutine test_i2 subroutine test_i2_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i2) :: val val = 3_i2 call check(error, val, -4_i2) end subroutine test_i2_fail subroutine test_i2_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i2) :: val val = -3_i2 call check(error, val, 7_i2, "Actual value is not seven") end subroutine test_i2_message subroutine test_i4(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i4) :: val val = 3_i4 call check(error, val, 3_i4) end subroutine test_i4 subroutine test_i4_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i4) :: val val = 3_i4 call check(error, val, -4_i4) end subroutine test_i4_fail subroutine test_i4_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i4) :: val val = -3_i4 call check(error, val, 7_i4, "Actual value is not seven") end subroutine test_i4_message subroutine test_i8(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i8) :: val val = 3_i8 call check(error, val, 3_i8) end subroutine test_i8 subroutine test_i8_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i8) :: val val = 3_i8 call check(error, val, -4_i8) end subroutine test_i8_fail subroutine test_i8_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error integer(i8) :: val val = -3_i8 call check(error, val, 7_i8, "Actual value is not seven") end subroutine test_i8_message subroutine test_l4_true(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, .true., .true.) end subroutine test_l4_true subroutine test_l4_false(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, .false., .false.) end subroutine test_l4_false subroutine test_l4_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, .true., .false.) end subroutine test_l4_fail subroutine test_l4_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error call check(error, .false., .true., "Logical value is not true") end subroutine test_l4_message subroutine test_char(error) !> Error handling type(error_type), allocatable, intent(out) :: error character(len=:), allocatable :: val val = "positive" call check(error, val, "positive") end subroutine test_char subroutine test_char_fail(error) !> Error handling type(error_type), allocatable, intent(out) :: error character(len=:), allocatable :: val val = "positive" call check(error, val, "negative") end subroutine test_char_fail subroutine test_char_message(error) !> Error handling type(error_type), allocatable, intent(out) :: error character(len=:), allocatable :: val val = "positive" call check(error, val, "negative", "Character string should be negative") end subroutine test_char_message end module test_example
test/test_example.f90
!> Orchid -- 2D/3D Euler/MagnetoHydroDynamics solver. !> Copyright (C) Butakov Oleg 2019. Module orchid_solver_config Interface Pure & Subroutine config_test() Bind(c, name='orchid_solver_scanner_test') End Subroutine config_test End Interface End Module orchid_solver_config
OrchidSolver/OrchidConfig.f90
SUBROUTINE slDFLI (STRING, NSTRT, DRESLT, JFLAG) *+ * - - - - - - - * D F L I * - - - - - - - * * Convert free-format input into double precision floating point * * Given: * STRING c string containing number to be decoded * NSTRT i pointer to where decoding is to start * DRESLT d current value of result * * Returned: * NSTRT i advanced to next number * DRESLT d result * JFLAG i status: -1 = -OK, 0 = +OK, 1 = null, 2 = error * * Notes: * * 1 The reason DFLTIN has separate OK status values for + * and - is to enable minus zero to be detected. This is * of crucial importance when decoding mixed-radix numbers. * For example, an angle expressed as deg, arcmin, arcsec * may have a leading minus sign but a zero degrees field. * * 2 A TAB is interpreted as a space, and lowercase characters * are interpreted as uppercase. * * 3 The basic format is the sequence of fields #^.^@#^, where * # is a sign character + or -, ^ means a string of decimal * digits, and @, which indicates an exponent, means D or E. * Various combinations of these fields can be omitted, and * embedded blanks are permissible in certain places. * * 4 Spaces: * * . Leading spaces are ignored. * * . Embedded spaces are allowed only after +, -, D or E, * and after the decomal point if the first sequence of * digits is absent. * * . Trailing spaces are ignored; the first signifies * end of decoding and subsequent ones are skipped. * * 5 Delimiters: * * . Any character other than +,-,0-9,.,D,E or space may be * used to signal the end of the number and terminate * decoding. * * . Comma is recognized by DFLTIN as a special case; it * is skipped, leaving the pointer on the next character. * See 13, below. * * 6 Both signs are optional. The default is +. * * 7 The mantissa ^.^ defaults to 1. * * 8 The exponent @#^ defaults to D0. * * 9 The strings of decimal digits may be of any length. * * 10 The decimal point is optional for whole numbers. * * 11 A "null result" occurs when the string of characters being * decoded does not begin with +,-,0-9,.,D or E, or consists * entirely of spaces. When this condition is detected, JFLAG * is set to 1 and DRESLT is left untouched. * * 12 NSTRT = 1 for the first character in the string. * * 13 On return from DFLTIN, NSTRT is set ready for the next * decode - following trailing blanks and any comma. If a * delimiter other than comma is being used, NSTRT must be * incremented before the next call to DFLTIN, otherwise * all subsequent calls will return a null result. * * 14 Errors (JFLAG=2) occur when: * * . a +, -, D or E is left unsatisfied; or * * . the decimal point is present without at least * one decimal digit before or after it; or * * . an exponent more than 100 has been presented. * * 15 When an error has been detected, NSTRT is left * pointing to the character following the last * one used before the error came to light. This * may be after the point at which a more sophisticated * program could have detected the error. For example, * DFLTIN does not detect that '1D999' is unacceptable * (on a computer where this is so) until the entire number * has been decoded. * * 16 Certain highly unlikely combinations of mantissa & * exponent can cause arithmetic faults during the * decode, in some cases despite the fact that they * together could be construed as a valid number. * * 17 Decoding is left to right, one pass. * * 18 See also FLOTIN and INTIN * * Called: slICHF * * P.T.Wallace Starlink 18 March 1999 * * Copyright (C) 1999 Rutherford Appleton Laboratory * * License: * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see SLA_CONDITIONS); if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * Copyright (C) 1995 Association of Universities for Research in Astronomy Inc. *- IMPLICIT NONE CHARACTER*(*) STRING INTEGER NSTRT DOUBLE PRECISION DRESLT INTEGER JFLAG INTEGER NPTR,MSIGN,NEXP,NDP,NVEC,NDIGIT,ISIGNX,J DOUBLE PRECISION DMANT,DIGIT * Current character NPTR=NSTRT * Set defaults: mantissa & sign, exponent & sign, decimal place count DMANT=0D0 MSIGN=1 NEXP=0 ISIGNX=1 NDP=0 * Look for sign 100 CONTINUE CALL slICHF(STRING,NPTR,NVEC,NDIGIT,DIGIT) GO TO ( 400, 100, 800, 500, 300, 200, 9110, 9100, 9110),NVEC * 0-9 SP D/E . + - , ELSE END * Negative 200 CONTINUE MSIGN=-1 * Look for first leading decimal 300 CONTINUE CALL slICHF(STRING,NPTR,NVEC,NDIGIT,DIGIT) GO TO ( 400, 300, 800, 500, 9200, 9200, 9200, 9200, 9210),NVEC * 0-9 SP D/E . + - , ELSE END * Accept leading decimals 400 CONTINUE DMANT=DMANT*1D1+DIGIT CALL slICHF(STRING,NPTR,NVEC,NDIGIT,DIGIT) GO TO ( 400, 1310, 900, 600, 1300, 1300, 1300, 1300, 1310),NVEC * 0-9 SP D/E . + - , ELSE END * Look for decimal when none preceded the point 500 CONTINUE CALL slICHF(STRING,NPTR,NVEC,NDIGIT,DIGIT) GO TO ( 700, 500, 9200, 9200, 9200, 9200, 9200, 9200, 9210),NVEC * 0-9 SP D/E . + - , ELSE END * Look for trailing decimals 600 CONTINUE CALL slICHF(STRING,NPTR,NVEC,NDIGIT,DIGIT) GO TO ( 700, 1310, 900, 1300, 1300, 1300, 1300, 1300, 1310),NVEC * 0-9 SP D/E . + - , ELSE END * Accept trailing decimals 700 CONTINUE NDP=NDP+1 DMANT=DMANT*1D1+DIGIT GO TO 600 * Exponent symbol first in field: default mantissa to 1 800 CONTINUE DMANT=1D0 * Look for sign of exponent 900 CONTINUE CALL slICHF(STRING,NPTR,NVEC,NDIGIT,DIGIT) GO TO (1200, 900, 9200, 9200, 1100, 1000, 9200, 9200, 9210),NVEC * 0-9 SP D/E . + - , ELSE END * Exponent negative 1000 CONTINUE ISIGNX=-1 * Look for first digit of exponent 1100 CONTINUE CALL slICHF(STRING,NPTR,NVEC,NDIGIT,DIGIT) GO TO (1200, 1100, 9200, 9200, 9200, 9200, 9200, 9200, 9210),NVEC * 0-9 SP D/E . + - , ELSE END * Use exponent digit 1200 CONTINUE NEXP=NEXP*10+NDIGIT IF (NEXP.GT.100) GO TO 9200 * Look for subsequent digits of exponent CALL slICHF(STRING,NPTR,NVEC,NDIGIT,DIGIT) GO TO (1200, 1310, 1300, 1300, 1300, 1300, 1300, 1300, 1310),NVEC * 0-9 SP D/E . + - , ELSE END * Combine exponent and decimal place count 1300 CONTINUE NPTR=NPTR-1 1310 CONTINUE NEXP=NEXP*ISIGNX-NDP * Skip if net exponent negative IF (NEXP.LT.0) GO TO 1500 * Positive exponent: scale up 1400 CONTINUE IF (NEXP.LT.10) GO TO 1410 DMANT=DMANT*1D10 NEXP=NEXP-10 GO TO 1400 1410 CONTINUE IF (NEXP.LT.1) GO TO 1600 DMANT=DMANT*1D1 NEXP=NEXP-1 GO TO 1410 * Negative exponent: scale down 1500 CONTINUE IF (NEXP.GT.-10) GO TO 1510 DMANT=DMANT/1D10 NEXP=NEXP+10 GO TO 1500 1510 CONTINUE IF (NEXP.GT.-1) GO TO 1600 DMANT=DMANT/1D1 NEXP=NEXP+1 GO TO 1510 * Get result & status 1600 CONTINUE J=0 IF (MSIGN.EQ.1) GO TO 1610 J=-1 DMANT=-DMANT 1610 CONTINUE DRESLT=DMANT * Skip to end of field 1620 CONTINUE CALL slICHF(STRING,NPTR,NVEC,NDIGIT,DIGIT) GO TO (1720, 1620, 1720, 1720, 1720, 1720, 9900, 1720, 9900),NVEC * 0-9 SP D/E . + - , ELSE END 1720 CONTINUE NPTR=NPTR-1 GO TO 9900 * Exits * Null field 9100 CONTINUE NPTR=NPTR-1 9110 CONTINUE J=1 GO TO 9900 * Errors 9200 CONTINUE NPTR=NPTR-1 9210 CONTINUE J=2 * Return 9900 CONTINUE NSTRT=NPTR JFLAG=J END
iraf.v2161/math/slalib/dfltin.f
Spiders are ubiquitous in Davis. Cellar spiders, aka Daddy Long Legs, are probably the most common and least harmful, though the Black Widow spiders have also been noted in the area. Brown recluse spiders are not found in Davis; people commonly misidentify brown colored spiders as Brown recluse spiders. Some people think of spiders as pests, but the truth is that spiders feed on flies, mosquitoes, cockroaches, etc., thus keeping populations of exterminators many others pests in check. Spiders are arthropods of the class Arachnida and the order Araneae. They are related to mites, ticks and scorpions, although they differ from them in that they have two body segments, all have poison glands in their chelicera, or jaws, and have a spinneret, or silk producing gland on their abdomen. Some types spin webs, some use their webs as bolas, some use their webs to create trap doors. Some spiders rarely use their webs at all. The largest group of spiders is the Salticidae, or the jumping spiders. There are many, many different spiders to be found outside, from flower spiders, to jumping spiders, and even fairly large garden spiders, which can be over an inch long from tip of cephalothorax to end of abdomen. Indoors, the most common spider is probably the Daddy Long Legs (not to be mistaken for the Harvestman arachnid) or Cellar spider, spiders of the family Pholcidae. They can also be identified with the cobwebby, hammocklike webs they commonly spin in houses. You probably have this spider in your apartment. Contrary to urban myth, these spiders are completely harmless to humans, whether alive or ground up into a powder. A possible domestic spider also includes the Black Widow Spider, a member of the genus Latrodectus. Unlike the aforementioned Cellar spider, the females pack a potent venom capable of harming an adult human, though it is not usually fatal. They are identified by their black or brown color, and large abdomen. Females also have the red hourglass on their underside which identifies them as widows. They commonly can inhabit sheds and other generally disused structures, and lay hanging sacs of eggs. Some places I have found widows include under the cement bike lock structures that are all over the campus, and the old shed near the Bee Biology building. Davis is full of black widows. I have several times found them under the lids of the recycling containers here. Theyre pretty shy, dont like light, and move relatively slowly. Davis is also home to wolf spiders and jumping spiders. Spiders can be found almost anywhere where insects, their primary prey, can be found. In other words, almost anywhere. Spiderlings can use their silk to balloon long distances, and distribute themselves over a wide range. Species Black Widow Black Widows wiki:WikiPedia:Daddy_longlegs_spider Daddy Long Legs wiki:WikiPedia:Phidippus_audax Daring Jumping Spider Images These are all local species, but not all photos are of local spiders. If you see a good example of one, please snap a picture so we can see our local eight legged beasties. Im not sure this is true. Could someone with better knowledge remove nonlocal spiders below? It would be very helpful. Users/NumiaCairaguas Davis is in the range for all the spiders listed below. Ask a professor? Maybe someone wants to classify these (taken in Users/WesHardaker my yard): Found this guy creeping on the carpet when I first moved into my apartment last fall Users/JournaL I found this generic brown spider in my bathtub. I feel like these are pretty common here, but I dont know what kind of spider it is. To learn more about creepy crawlies inhabiting Davis our town, please take a look at our Town Wildlife. 20070327 12:53:45 nbsp My scout master back in the day made us totally fear the brown recluse. Those things will mess you up. If you dont die your flesh like turns to liquid. Nasty things! Users/BradBenedict 20070327 15:18:17 nbsp Professor Kimsey (he teaches the zoology class, BIS 1B) told me that Brown Recluse Spiders dont live in California. I want to see references that say otherwise, or else that spider should be removed from this page. Users/NumiaCairaguas I know multiple people who have been bitten by Brown Recluse in Ca Daubert Kimsey was right. See http://en.wikipedia.org/wiki/Brown_recluse_spider#Distribution , or AlexMandels link in the comment thrad below. Its a very, very common mistake, so I doubt they actually were the brown recluse spiders. users/edwins ES 20070327 15:18:53 nbsp ...I forgot to say please. :) Users/NumiaCairaguas 20070327 15:21:32 nbsp I looked up info on BRs a while back because my wife thought she saw one... everything thing I found said they didnt exist in central CA (though some had been supposedly seen in southern CA, those references were really weak) Users/WesHardaker I looked this up a while ago too, and had found that the natural range of Brown Recluse did not include much of California if any part (South Eastern near Arizona was the most likely). I did however here recently that they have been spotted in CA as invasive species brought in by accident in some places. Its unclear wether there is a self sustaining population anywhere in the state though. This http://www.ipm.ucdavis.edu/PMG/PESTNOTES/pn7468.html UCR ANR page appears to have the most comprehensive and reliable information. Users/AlexMandel 20070717 09:15:20 nbsp I snapped a shot of that black and white jumping spider. It thought it was really pretty, but it seems there is a better picture up here. Does anyone know if it has a common name? Users/CarlosOverstreet 20070718 07:53:13 nbsp The wikipedia link under the picture, assuming youre talking about the same one Im thinking of, says its a jumping spider. And if you dont like them the only place you can live is greenland... Users/WesHardaker 20130209 11:59:12 nbsp Want to participate in a local Citizen Science Project? As of 2012 Explorit Science Center has been doing a Citizen Science Project concerning spider distribution in Yolo County. Anyone who takes photos anywhere in Yolo County is invited to participate and help build up the database. Participants are asked to register at http://www.explorit.org/csp/registration to get an ID number as an official participant and then sign up with Explorits Where Is My Spider Project at iNaturalist.org at http://www.inaturalist.org/projects/whereismyspider. A pilot was run in 2012 and as of 2013 the project is starting over using iNaturalist. There are smart phone apps for recording observations on iNaturalist! Users/AnneHance
lab/davisWiki/Spiders.f
integer function strcmp (str1, str2) integer str1 (100), str2 (100) integer i i = 1 23000 if (.not.(str1 (i) .eq. str2 (i)))goto 23002 if (.not.(str1 (i) .eq. -2))goto 23003 strcmp=(0) return 23003 continue 23001 i = i + 1 goto 23000 23002 continue if (.not.(str1 (i) .eq. -2))goto 23005 strcmp = -1 goto 23006 23005 continue if (.not.(str2 (i) .eq. -2))goto 23007 strcmp = + 1 goto 23008 23007 continue if (.not.(str1 (i) .lt. str2 (i)))goto 23009 strcmp = -1 goto 23010 23009 continue strcmp = +1 23010 continue 23008 continue 23006 continue return end
iraf.v2161/unix/boot/spp/rpp/ratlibf/strcmp.f
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2019 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine hgstiffness(s,elas,a,gs) ! ! hourglass control stiffness for 8-node solid mean strain element ! ! Reference: Flanagan, D.P., Belytschko, T.; "Uniform strain hexahedron ! and quadrilateral with orthogonal Hourglass control". Int. J. Num. ! Meth. Engg., Vol. 17, 679-706, 1981. ! ! author: Otto-Ernst Bernhardi ! implicit none ! integer ii1,jj1,ii,jj,m1 ! real*8 s(60,60),gs(8,4),a,elas(1),hgls,ahr ! intent(in) elas,a,gs ! intent(inout) s ! ahr=elas(1)*a c write(6,*) "stiffness:", ahr ! jj1=1 do jj=1,8 ii1=1 do ii=1,jj hgls=0.0d0 do m1=1,4 hgls=hgls+gs(jj,m1)*gs(ii,m1) enddo hgls=hgls*ahr s(ii1,jj1)=s(ii1,jj1)+hgls s(ii1+1,jj1+1)=s(ii1+1,jj1+1)+hgls s(ii1+2,jj1+2)=s(ii1+2,jj1+2)+hgls ii1=ii1+3 enddo jj1=jj1+3 enddo return end
ccx_prool/CalculiX/ccx_2.16/src/hgstiffness.f
! integrator.f90 ! !> Module with the integration routines. ! !> @copyright !> 2015 Lesley De Cruz & Jonathan Demaeyer. !> See LICENSE.txt for license information. ! !---------------------------------------------------------------------------! ! !> @remark !> This module actually contains the Heun algorithm routines. !> The user can modify it according to its preferred integration scheme. !> For higher-order schemes, additional buffers will probably have to be defined. ! !--------------------------------------------------------------------------- MODULE integrator USE params, only: ndim USE tensor, only:sparse_mul3 USE aotensor_def, only: aotensor IMPLICIT NONE ! PRIVATE PUBLIC !STEVE: needed to finalize buf arrays externally REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: buf_y1 !< Buffer to hold the intermediate position (Heun algorithm) REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: buf_f0 !< Buffer to hold tendencies at the initial position REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: buf_f1 !< Buffer to hold tendencies at the intermediate position PUBLIC :: init_integrator, step CONTAINS !> Routine to initialise the integration buffers. SUBROUTINE init_integrator INTEGER :: AllocStat ALLOCATE(buf_y1(0:ndim),buf_f0(0:ndim),buf_f1(0:ndim) ,STAT=AllocStat) IF (AllocStat /= 0) then print *, "init_integrator:: AllocStat = ", AllocStat STOP "*** Not enough memory ! ***" ENDIF END SUBROUTINE init_integrator !> Routine computing the tendencies of the model !> @param t Time at which the tendencies have to be computed. Actually not needed for autonomous systems. !> @param y Point at which the tendencies have to be computed. !> @param res vector to store the result. !> @remark Note that it is NOT safe to pass `y` as a result buffer, !> as this operation does multiple passes. SUBROUTINE tendencies(t,y,res) REAL(KIND=8), INTENT(IN) :: t REAL(KIND=8), DIMENSION(0:ndim), INTENT(IN) :: y REAL(KIND=8), DIMENSION(0:ndim), INTENT(OUT) :: res CALL sparse_mul3(aotensor, y, y, res) END SUBROUTINE tendencies !> Routine to perform an integration step (Heun algorithm). The incremented time is returned. !> @param y Initial point. !> @param t Actual integration time !> @param dt Integration timestep. !> @param res Final point after the step. SUBROUTINE step(y,t,dt,res) REAL(KIND=8), DIMENSION(0:ndim), INTENT(IN) :: y REAL(KIND=8), INTENT(INOUT) :: t REAL(KIND=8), INTENT(IN) :: dt REAL(KIND=8), DIMENSION(0:ndim), INTENT(OUT) :: res CALL tendencies(t,y,buf_f0) buf_y1 = y+dt*buf_f0 CALL tendencies(t+dt,buf_y1,buf_f1) res=y+0.5*(buf_f0+buf_f1)*dt t=t+dt END SUBROUTINE step END MODULE integrator
fortran_split/coupled/rk2_integrator.f90
!+ Source module "src_radiation" !------------------------------------------------------------------------------ MODULE src_radiation !------------------------------------------------------------------------------ ! ! Description: ! The module "radiation" performs calculations related to the ! parameterization of radiative transfer. ! Driving routine is the model procedure "organize_radiation", which ! calls the main routine "fesft" of the radiation package. ! Additionally, some diagnostics and gridpoint output is done. ! ! All global variables of the model that are used by the interface routine ! "organize_radiation" are imported by USE statements below. ! ! The program package for the parameterization of radiative transfer consists ! of following routines: ! fesft, coe_so, coe_th, inv_so, ivs_th, opt_so and opt_th. ! ! All parametric data that are required by these routines are defined in the ! data module data_radiation. ! ! Additionally, the routine init_radiation has to be called once before the ! first call of the driving routine fesft for the radiation package in the ! driving routine organize_radiation. Aerdis is a small help routine to ! receive some parameters for the vertical distribution of background ! aerosol in the driving routine. ! ! The parameterization package has been provided by B. Ritter in a ! Plug-compatible Fortran77-Version. Some technical modifications have been ! done for the F90-Version: ! Internal communication by common-blocks is replaced by module parameters, ! scalars and arrays defined in module data_radiation. ! ! Current Code Owner: DWD, Bodo Ritter ! phone: +49 69 8062 2703 ! fax: +49 69 8062 3721 ! email: [email protected] ! ! History: ! Version Date Name ! ---------- ---------- ---- ! 1.1 1998/03/11 Guenter Doms ! Initial release ! 1.4 1998/05/22 Guenter Doms ! Inclusion of control parameter l2tls to select time levels ! according to the time integration scheme used. ! 1.8 1998/08/03 Ulrich Schaettler ! Elmination of dependency from module data_io ! 1.20 1999/01/07 Guenther Doms ! Renaming of some global variables ! 1.24 1999/03/01 Guenther Doms ! Inclusion of the new prognostic 3-D array 'qi'. ! 1.29 1999/05/11 Ulrich Schaettler ! Adapted interfaces to utility-modules ! 1.30 1999/06/24 Matthias Raschendofer ! Use from module data_constants: rvd_m_o, lhop, b234w. ! Use form module data_fields: rcld. ! Use form module data-runcontrol: itype_wcld, icldm_rad. ! Use form module meteo_utilities: cloud_diag ! 1.32 1999/08/24 Guenther Doms ! top_con and bas_con removed from the use-list ! 1.34 1999/12/10 Ulrich Schaettler ! Use new timing routines ! 1.39 2000/05/03 Ulrich Schaettler ! Use variables klv800 and klv400 from data_modelconfig. ! 2.18 2002/07/16 Reinhold Schrodin ! Eliminated variable rhde, use cf_snow instead ! Use new variable for soil moisture in case of multi-layer soil model ! 3.5 2003/09/02 Ulrich Schaettler ! Avoid global communication by providing the fields phi_tot, rla_tot ! 3.6 2003/12/11 Reinhold Schrodin ! Adaptations for multi-layer soil model ! 3.7 2004/02/18 Ulrich Schaettler ! Replace local logical variable lcl_ice by global variable lprog_qi ! Renamed alb (alb_rad), phi (rlat), rla (rlon) ! 3.16 2005/07/22 Reinhold Schrodin ! Use variables for_e and for_d from data_fields, csalb_snow_fd and ! csalb_snow_fe from data_soil ! 3.18 2006/03/03 Ulrich Schaettler ! Really included all the *.incf files in src_radiation.f90 ! Add variables and fields used by the lake model FLake ! Some additionals for the Climate LM Version ! 3.21 2006/12/04 Burkhardt Rockel, Ulrich Schaettler ! Added A2 scenarios for CO2; renamed variable sodwdir to sodwddm ! Use alternatively t_g for determining soil type of grid cell ! Use new NL variables from data_constants: clc_diag, q_crit ! 3.22 2007/01/24 Axel Seifert ! Adapted a constant for computation of cloud cover of ice clouds ! V3_23 2007/03/30 Matthias Raschendorfer, Matteo Buzzi ! Moving 'clc_diag' and 'q_crit' to MODULE data_turbulence. ! Calculation of topographical correction if lradtopo=.TRUE. ! V4_1 2007/12/04 Ulrich Schaettler ! Bug correction (found out by Catherine Meissner, IMK Karlsruhe): ! The downward and upward component have to be changed in call to SR fesft ! V4_3 2008/02/25 Ulrich Schaettler ! There were also other downward and upward component in the wrong order ! V4_4 2008/07/16 Ulrich Schaettler ! Eliminated timing variables which are unused ! Changed NL parameter lyear_360 to itype_calendar, to have several options ! V4_8 2009/02/16 Ulrich Schaettler; Guenther Zaengl ! Included additional (output) fields (for CLM: Uli) ! Use p0hl (reference pressure at half levels) for full consistency with ! new reference atmosphere implementation ! V4_9 2009/07/16 Ulrich Schaettler ! Removed boundary exchange for radiation averaging (now in organize_physics) ! Introduced full 3D fields of local variables in organize_radiation for a ! better vectorization of the interpolation for radiation averaging ! Implemented COSMO-ART features (with ifdef) ! V4_10 2009/09/11 Matthias Raschendorfer, Jan-Peter Schulz ! Bug correction for the case "icldm_rad==2" when coud ice is present. ! Modifications for the new seaice scheme (Jan-Peter Schulz) ! Additional vector optimizations by NEC ! V4_11 2009/11/30 Ekaterina Machulskaya, Juergen Helmert ! Adaptations for running with multi-layer snow model ! Implemented options for aerosol distribution and use of an external ! emissivity map (JH) ! V4_12 2010/05/11 Ulrich Schaettler ! Renamed t0 to t0_melt because of conflicting names ! Bug fix in call to exchg_boundaries (wrong vertical dimension) (Lucio Torrisi) ! Init and use unified variables for all aerosol-types (JH) ! Compute additional fields for sunshine duration (Oli Fuhrer) ! Adaptations in the COSMO-ART part ! V4_13 2010/05/11 Michael Gertz ! Adaptions to SVN ! V4_17 2011/02/24 Ulrich Blahak ! Adapted interface of exchg_boundaries; corrected kzdims(1:20) -> kzdims(1:24); ! eliminated my_peri_neigh ! V4_18 2011/05/26 Ulrich Schaettler ! Use local 2D array zskyview and use 1D slice of it (because global array is ! allocated only for lradtopo, but was used in SR interfaces) ! Smoothing field swdifu_s (for output) after coarse grid computation ! Use of lgas and call to SR calcjval of COSMO-ART only for lgas (Christoph Knote) ! Bug fix for computing qc_rad, qi_rad in case of a coarser grid (Victor Venema) ! V4_20 2011/08/31 Juergen Helmert / Victor Venema ! Bug correction in the sub grid scale cloudiness ! Replaced arguments p0 and pp in SR cloud_diag by p_tot (Uli Schaettler) ! Bug fix in setting full variables after coarse radiation step (TR) ! ! CPS: Updated by Markus Übel(C4) based on the TerrSysMPV1.0 formulation in cosmo4.11 ! Sep 05 2013: Fixed sun angle and aerosol for periodic boundary condition (as discussion ! with Uli Blahak) : P. Shrestha ! Jan 21 2014: Update for masked simulation on calculation of parallel albedo ! for sea points : P.Shrestha (see zpalp estimation for ocean) ! ! Code Description: ! Language: Fortran 90. ! Software Standards: "European Standards for Writing and ! Documenting Exchangeable Fortran 90 Code". !============================================================================== ! ! Declarations: ! ! Modules used: USE data_parameters, ONLY : & ireals, & ! KIND-type parameter for real variables iintegers ! KIND-type parameter for standard integer variables !------------------------------------------------------------------------------ USE data_modelconfig, ONLY : & ! 1. vertical coordinate parameters and related variables ! ------------------------------------------------------- sigmr, & ! sigma-coordinate refering to PMSL half level ! 2. horizontal and vertical sizes of the fields and related variables ! -------------------------------------------------------------------- ie, & ! number of grid points in zonal direction ie_tot, & ! the same for the total field je, & ! number of grid points in meridional direction ke, & ! number of grid points in vertical direction ke1, & ! ke+1 czmls, & ! depth of the soil layers in meters ! 3. start- and end-indices for the computations in the horizontal layers ! ----------------------------------------------------------------------- ! These variables give the start- and the end-indices of the ! forecast for the prognostic variables in a horizontal layer. ! Note, that the indices for the wind-speeds u and v differ from ! the other ones because of the use of the staggered Arakawa-C-grid. ! zonal direction istart, & ! start index for the forecast of w, t, qd, qw and pp iend, & ! end index for the forecast of w, t, qd, qw and pp istartpar, & ! start index for computations in the parallel program iendpar, & ! end index for computations in the parallel program ! meridional direction jstart, & ! start index for the forecast of w, t, qd, qw and pp jend, & ! end index for the forecast of w, t, qd, qw and pp jstartpar, & ! start index for computations in the parallel program jendpar, & ! end index for computations in the parallel program ! 4. variables for the time discretization and related variables ! -------------------------------------------------------------- dt, & ! long time-step !CPS00 degrad, & ! factor for transforming degree to rad ! 5. constants for the horizontal rotated grid and related variables ! ------------------------------------------------------------------ pollon, & ! longitude of the rotated north pole (in degrees, E>0) pollat, & ! latitude of the rotated north pole (in degrees, N>0) !CPS00 ! 7. Layer index corresponding to a specified pressure ! ---------------------------------------------------- klv800, & ! k index of the LM-mainlevel, on 800 HPa klv500, & ! k index of the LM-mainlevel, on 500 HPa klv400 ! k index of the LM-mainlevel, on 400 HPa ! end of data_modelconfig !------------------------------------------------------------------------------ USE data_constants , ONLY : & ! 1. mathematical constants ! ------------------------- pi, & ! circle constant ! 2. physical constants and related variables ! ------------------------------------------- t0_melt, & ! melting temperature of ice r_v, & ! gas constant for water vapor rdv, & ! r_d / r_v o_m_rdv, & ! 1 - r_d/r_v rvd_m_o, & ! r_v/r_d - 1 cp_d, & ! specific heat of dry air at constant pressure cpdr, & ! 1 / cp_d rdocp, & ! r_d / cp_d lh_v, & ! latent heat of vapourization lhocp, & ! lh_v/cp_d g, & ! acceleration due to gravity sigma, & ! Boltzmann-constant solc, & ! solar constant ! 3. constants for parametrizations ! --------------------------------- b1, & ! variables for computing the saturation vapour pressure b2w, & ! over water (w) and ice (i) b2i, & ! -- " -- b3, & ! -- " -- b4w, & ! -- " -- b4i, & ! -- " -- b234w, & ! b2w * (b3 - b4w) uc1, & ! variable for computing the rate of cloud cover in uc2, & ! the unsaturated case ucl ! -- " -- ! end of data_constants !------------------------------------------------------------------------------ USE data_turbulence , ONLY : & ! 1. tuning constants for statistical cloud scheme: ! ------------------------------------------------------------ clc_diag, & ! cloud cover at saturation in statistical cloud diagnostic q_crit ! critical value for normalized over-saturation !------------------------------------------------------------------------------ USE data_fields , ONLY : & ! 1. constant fields for the reference atmosphere (unit) ! ----------------------------------------------- p0 , & ! reference pressure at full levels ( pa ) p0hl , & ! reference pressure at half levels ( Pa ) dp0 , & ! pressure thickness depth_lk , & ! lake depth ( m ) ! 2. external parameter fields (unit) ! ---------------------------- soiltyp , & ! type of the soil (keys 0-9) -- vio3 , & ! vertical integrated ozone contents (pa O3) hmo3 , & ! ozone maximum ( pa ) rlat , & ! geographical latitude ( rad ) rlon , & ! geographical longitude ( rad ) rlattot , & ! geographical latitude ( rad ) rlontot , & ! geographical longitude ( rad ) aer_su , & ! monthly aerosol climatology sulfate drops (0 - 1) aer_du , & ! monthly aerosol climatology total dust (0 - 1) aer_or , & ! monthly aerosol climatology organic (water sol.) (0 - 1) aer_bc , & ! monthly aerosol climatology black carbon (0 - 1) aer_ss , & ! monthly aerosol climatology sea salt (0 - 1) emis_rad , & ! thermal surface emissivity (0 - 1) aerlan , & ! aerosol-distribution for rural areas -- aerurb , & ! aerosol-distribution for urban areas -- aerdes , & ! aerosol-distribution for desert areas -- aersea , & ! aerosol-distribution for sea -- plcov , & ! fraction of plant cover -- llandmask , & ! landpoint mask for_e , & ! ground fraction covered by evergreen forest -- for_d , & ! ground fraction covered by deciduous forest -- ! 3. prognostic variables (unit) ! ----------------------- t , & ! temperature ( k ) qv , & ! specific water vapor content (kg/kg) qc , & ! specific cloud water content (kg/kg) qi , & ! specific cloud ice content (kg/kg) pp , & ! deviation from the reference pressure ( pa ) ! 5. fields for surface values and soil model variables (unit ) ! ----------------------------------------------------- ps , & ! surface pressure ( pa ) t_s , & ! surface temperature ( K ) t_snow , & ! temperature of the snow-surface ( k ) t_snow_mult, & ! temperature of the snow-surface ( k ) t_g , & ! weighted surface temperature ( k ) w_snow , & ! water content of snow (m H2O) w_g1 , & ! water content of the upper soil layer (m H2O) w_so ! multi-layer soil moisture (m H2O) USE data_fields , ONLY : & ! fields for prognostic variables of the lake model FLake or ocean ! variables t_ice , & ! temperature of ice/water surface ( K ) h_ice , & ! lake/sea ice thickness ( m ) ! 6. fields that are computed in the parametrization and dynamics (unit ) ! --------------------------------------------------------------- ! turbulence statistics in the atmosphere ! (defined on full levels) rcld , & ! standard deviation of the saturation deficit -- ! fields of the radiation sohr , & ! rate of solar heating ( k/s ) thhr , & ! rate of thermal heating ( k/s ) clc_sgs , & ! subgrid-scale stratiform cloud cover -- alb_rad , & ! albedo of the ground -- sobs , & ! solar radiation at the ground ( w/m2) thbs , & ! thermal radiation at the ground ( w/m2) pabs , & ! photosynthetic active radiation at the ground ( w/m2) sobt , & ! solar radiation at the upper boundary ( w/m2) ! of the atmosphere thbt , & ! thermal radiation at the upper boundary ( w/m2) ! of the atmosphere clch , & ! cloud cover with high clouds -- clcm , & ! cloud cover with medium clouds -- clcl , & ! cloud cover with low clouds -- clct , & ! total cloud cover -- freshsnow , & ! weighting function indicating 'freshness' of snow in ! upper few centimeters of snow cover ( -- ) sun_el , & ! sun elevation angle (deg ) sun_azi , & ! sun azimuth angle (deg ) ! and for the Climate-LM Version sodwddm , & ! downward direct solar radiative flux / smu0 ( W/m2) qc_rad , & ! subgrid-scale specific cloud water content (kg/kg) qi_rad , & ! subgrid-scale specific ice water content (kg/kg) ! fields of the convection clc_con , & ! cloud cover due to convection -- ! fields for the radiation correction scheme ! these are actual values swdir_s , & ! direct comp. of solar radiative flux at surface ( W/m2) swdifd_s , & ! diffuse downward comp. of short wave rad. flux ( W/m2) swdifu_s , & ! diffuse upward comp. of short wave rad. flux ( W/m2) lwd_s , & ! downward comp. of long wave rad. flux ( W/m2) lwu_s , & ! upward comp. of long wave rad. flux ( W/m2) ! this is the essential correction factor swdir_cor , & ! direct short wave radiation correction factor actual value ! these are topographic parameters skyview , & ! sky view slo_asp , & ! slope aspect slo_ang , & ! slope angle horizon , & ! horizon ! 7. fields for model output and diagnostics (unit ) ! ------------------------------------------ sod_t , & ! solar downward radiation at top of atmosphere ( ) asod_t ! averaged solar downward radiation at top ( ) ! end of data_fields !------------------------------------------------------------------------------ USE data_runcontrol , ONLY : & ! 1. start and end of the forecast ! -------------------------------- ntstep, & ! actual time step ! indices for permutation of three time levels nold , & ! corresponds to ntstep - 1 nnow , & ! corresponds to ntstep nnew , & ! corresponds to ntstep + 1 ! 3. controlling the physics ! -------------------------- lconv, & ! forecast with convection itype_aerosol,& ! type of aerosol map internal/external lemiss, & ! external emissivity map lgsp, & ! switch for grid-scale cloud and precipitation scheme lforest, & ! if .true., run with forest (evergreen and deciduous) lsoil, & ! forecast with soil model lseaice, & ! forecast with sea ice model llake, & ! forecst with lake model FLake l_cosmo_art, & ! if .TRUE., run the COSMO_ART nincrad, & ! time step increment for running the radiation nradcoarse, & ! radiation coarse-grid number of gpts per hor. direction !T.R. lradf_avg, & ! switch for filtering of radiative increments !T.R. nlgw, & ! number of prognostic soil water levels itype_wcld, & ! type of water cloud diagnosis icldm_rad, & ! mode of cloud representation in radiation parametr. lmulti_layer, & ! run multi-layer soil model lmulti_snow , & ! run multi-layer snow model lradtopo, & ! if .TRUE., calculate topographic correction of radiation nhori, & ! number of sectors for the horizont array by the topographic ! correction of the radiation ! and for the Climate-LM Version ico2_rad, & ! type of CO2 concentration in radiation parameterization ! 5. additional control variables ! ------------------------------- ltime, & ! lreproduce, & ! the results are reproducible in parallel mode l2tls , & ! forecast with 1-TL integration scheme lprog_qi, & ! if .TRUE., running with cloud ice lperi_x, & ! if lgen=.TRUE.: periodic boundary conditions (.TRUE.) in x-dir. ! or with Davies conditions (.FALSE.) lperi_y, & ! if lgen=.TRUE.: periodic boundary conditions (.TRUE.) in y-dir. ! or with Davies conditions (.FALSE.) l2dim, & ! 2 dimensional runs ! 9. Variables for Ascii file handling, time measuring, ... ! --------------------------------------------------------- itype_calendar,&! for specifying the calendar used ! 12. controlling verbosity of debug output ! ----------------------------------------- idbg_level, & ! to control the verbosity of debug output ldebug_rad, & ! if .TRUE., debug output for radiation lprintdeb_all ! .TRUE.: all tasks print debug output ! .FALSE.: only task 0 prints debug output ! end of data_runcontrol !------------------------------------------------------------------------------ USE data_soil , ONLY : & csalb , & ! csalbw , & ! csalb_p , & ! csalb_snow, & ! csalb_snow_min, & ! min. solar albedo of snow for forest free surfaces csalb_snow_max, & ! max. solar albedo of snow for forest free surfaces csalb_snow_fd , & ! solar albedo of snow for surfaces with deciduous forest csalb_snow_fe , & ! solar albedo of snow for surfaces with evergreen forest ctalb , & ! cdzw12 , & ! cdzw13 , & ! cf_snow ! end of data_soil !------------------------------------------------------------------------------ USE data_flake, ONLY : & ! flake_parameters h_Ice_min_flk , & ! Minimum ice thickness [m] tpl_T_f , & ! Fresh water freezing point [K] ! flake_albedo_ref albedo_whiteice_ref , & ! White ice albedo_blueice_ref , & ! Blue ice c_albice_MR ! Constant in the interpolation formula for ! the ice albedo (Mironov and Ritter 2004) !------------------------------------------------------------------------------ USE data_parallel, ONLY : & nprocx,isubpos, & num_compute, & ! number of compute PEs nboundlines, & ! number of boundary lines of the domain for which ! no forecast is computed = overlapping boundary ! lines of the subdomains ldatatypes, & ! if .TRUE.: use MPI-Datatypes for some communications ltime_barrier, & ! if .TRUE.: use additional barriers for determining the ! load-imbalance ncomm_type, & ! type of communication my_cart_id, & ! rank of this subdomain in the cartesian communicator my_cart_neigh, & ! neighbors of this subdomain in the cartesian grid icomm_cart, & ! communicator for the virtual cartesian topology ! that can be used by MPI_WAIT to identify the send imp_reals, & ! determines the correct REAL type used in the model ! for MPI imp_integers, & ! determines the correct INTEGER type used in the model ! for MPI sendbuf, & ! sending buffer for boundary exchange: ! 1-4 are used for sending, 5-8 are used for receiving isendbuflen ! length of one column of sendbuf !------------------------------------------------------------------------------ USE environment, ONLY : & exchg_boundaries!, & ! performs the boundary exchange between ! neighboring processors !------------------------------------------------------------------------------ USE data_radiation, ONLY : & idim_rad, & ! ie-dimension of the coarser grid istartrad, & ! start- and end-indices for computing the radiation iendrad, & ! (when running on a coarser grid, the input values for jstartrad, & ! fesft are computed on all grid points, to compute an jendrad, & ! average input over several grid points) iendparrad, & ! end-index just for preparations jendparrad, & ! end-index just for preparations ! Imported array data variables with intent (in) for init_radiation: jpgas, & ! Number of gases coali, & ! cobti, & ! pgas, & ! tgas, & ! jpsol , & ! Number of solar spectral intervals jpther , & ! Number of thermal spectral intervals jpspec , & ! =jpsol+jpther (Total number of spectral intervals) solant , & ! Fraction of solar energy at TOA contained in individual ! solar spectral intervals planck , & ! coefficients for the description of the fraction of the total ! black body radiation contained in an thermal spectral interval ! as a function (2.order polynomial) of temperature zketypr , & ! e-type continuum-coefficient for all spectral intervals ! (PA (H2O)**-2) at 296 K zketypa , & ! (r) following ROBERTS ET AL. 1976,(a) implicitly derived ! from the AFGL spectral data ztetypr , & ! constant for the temperature dependancy of e-type absorption ! for all intervals ztetypa , & ! (r) following ROBERTS ET AL. 1976,(a) implicitly derived ! from the AFGL spectral data zteref , & ! reference temperature grenze , & ! Limits of spectral intervals (for information only) ! absorption properties of atmospheric gases ncgas , & ! number of coefficients for each interval and gas (maximum=7) nfast , & ! control variable for choice between ESFT/FESFT method in ! each interval coai , & ! weigthing coefficients cobi , & ! absorption coefficients ! array data variables for opt_th and opt_so with intent (in): zaea, zaes, zaeg, zaef, & ! zlwe, zlwemn, zlwemx, & ! zlww, zlwg, & ! ziwe, ziwemn, ziwemx, & ! ziww, ziwg, & ! zrsc, & ! ! for albedo rad_csalbw !------------------------------------------------------------------------------ USE meteo_utilities, ONLY : cloud_diag USE utilities, ONLY : get_utc_date !------------------------------------------------------------------------------ #ifdef COSMOART USE data_cosmo_art, ONLY : & Eup , & ! upward flux (3. band of GRAALS) (W m-2) Edown , & ! downward flux (3. band of GRAALS) (W m-2) Edir , & ! direkt intensity (3. band of GRAALS) (W m-2) mmy , & ! cosinus of sun-zenith-angle in radiation (1) ! CK 20101204 lgas necessary to check if jvals need to be calculated lgas , & ! with gas phase chemistry lrad_dust , & ! mineral dust aerosols lrad_seas , & ! sea salt aerosols lrad_aero , & ! anthropogenic aerosols asym_ges , & ! asym_seas , & ! asym_aero , & ! tau_abs_dust , & ! tau_streu_dust, & ! tau_abs_seas , & ! tau_streu_seas, & ! tau_abs_aero , & ! tau_streu_aero ! USE art_papa, ONLY : calcjval #endif !============================================================================== IMPLICIT NONE !============================================================================== CONTAINS !============================================================================== !+ Module procedure in "Radiation" for initializing necessary variables !------------------------------------------------------------------------------ SUBROUTINE init_radiation !------------------------------------------------------------------------------ ! ! Description: ! The module procedure init_radiation initializes the data necessary for the ! the radiation scheme. It provides the constant aerosol arrays ! (aersea, aerlan, aerurb and aerdes) and processes the data variables ! provided by module data_radiation for the calculation of the absorption ! properties of atmospheric gases. ! The routine is called once at the beginning of a model run in order to ! convert the raw coffeicients from the data variables to those entities used ! in the radiation code. ! ! Method: ! - Computation of the inverse transformations (Legendre and Fourier) of a T10 ! representation of the four aerosol fields ! - scaling of absorption coefficients from the individual reference ! temperature and pressure to unified conditions, i.e. ! reference temperature = 273.15 K ! reference pressure = 1013.25 hPa ! !------------------------------------------------------------------------------ ! Subroutine arguments: None ! -------------------- ! Local arrays and scalars: ! ------------------------- INTEGER (KIND=iintegers) :: & i , j , jg , js , jc , & ! loop indices jzj, jzm1, jzm2, jzm, jzn, & ! indices for Legendre coefficients imn, imnc, imns, jmm, jnn, & ! ist REAL (KIND=ireals) :: & ! arrays for the T10 distrubution of zaesc(66) , zaess (55) , & ! sea type aerosols zaelc(66) , zaels (55) , & ! land type aerosols zaeuc(66) , zaeus (55) , & ! urban type aerosols zaedc(66) , zaeds (55) , & ! desert type aerosols zfaes(21) , zfael (21) , & ! coefficients for spectral zfaeu(21) , zfaed (21) , & ! expansion zalp (66) , & ! zsinphi , zcosphi , & ! zm, z2m, zre1, ze1, ze2, & ! zf1m, zf2m, zn, zn2, & ! zsin1, zsin2, zsin3, zsin4, zsin5, & ! zsin6, zsin7, zsin8, zsin9, zsin10, & ! zcos1, zcos2, zcos3, zcos4, zcos5, & ! zcos6, zcos7, zcos8, zcos9, zcos10 ! REAL (KIND=ireals) :: & zdzwb !- End of header !============================================================================== !------------------------------------------------------------------------------ ! Section 0: Data for the Fourier coefficients of the four aerosol types !------------------------------------------------------------------------------ DATA zaesc/ & +.6688E+00,-.1172E+00,-.1013E+00,+.1636E-01,-.3699E-01,+.1775E-01, & -.9635E-02,+.1290E-02,+.4681E-04,-.9106E-04,+.9355E-04, & -.7076E-01,-.1782E-01,+.1856E-01,+.1372E-01,+.8210E-04,+.2149E-02, & +.4856E-03,+.2231E-03,+.1824E-03,+.1960E-05, & +.2057E-01,+.2703E-01,+.2424E-01,+.9716E-02,+.1312E-02,-.8846E-03, & -.3347E-03,+.6231E-04,+.6397E-04, & -.3341E-02,-.1295E-01,-.4598E-02,+.3242E-03,+.8122E-03,-.2975E-03, & -.7757E-04,+.7793E-04, & +.4455E-02,-.1584E-01,-.2551E-02,+.1174E-02,+.1335E-04,+.5112E-04, & +.5605E-04, & +.7412E-04,+.1857E-02,-.1917E-03,+.4460E-03,+.1767E-04,-.5281E-04, & -.5043E-03,+.2467E-03,-.2497E-03,-.2377E-04,-.3954E-04, & +.2666E-03,-.8186E-03,-.1441E-03,-.1904E-04, & +.3337E-03,-.1696E-03,-.2503E-04, & +.1239E-03,-.9983E-04, & -.5283E-04_ireals / DATA zaess/ & -.3374E-01,-.3247E-01,-.1012E-01,+.6002E-02,+.5190E-02,+.7784E-03, & -.1090E-02,+.3294E-03,+.1719E-03,-.5866E-05, & -.4124E-03,-.3742E-01,-.5054E-02,+.3430E-02,+.5513E-03,-.6235E-03, & +.2892E-03,-.9730E-04,+.7078E-04, & -.3300E-01,+.5104E-03,-.2156E-02,-.3194E-02,-.5079E-03,-.5517E-03, & +.4632E-04,+.5369E-04, & -.2731E-01,+.5126E-02,+.2241E-02,-.5789E-03,-.3048E-03,-.1774E-03, & +.1946E-05, & -.8247E-02,+.2338E-02,+.1021E-02,+.1575E-04,+.2612E-05,+.1995E-04, & -.1319E-02,+.1384E-02,-.4159E-03,-.2337E-03,+.5764E-04, & +.1495E-02,-.3727E-03,+.6075E-04,-.4642E-04, & +.5368E-03,-.7619E-04,+.3774E-04, & +.1206E-03,-.4104E-06, & +.2158E-04 / DATA zaelc/ & +.1542E+00,+.8245E-01,-.1879E-03,+.4864E-02,-.5527E-02,-.7966E-02, & -.2683E-02,-.2011E-02,-.8889E-03,-.1058E-03,-.1614E-04, & +.4206E-01,+.1912E-01,-.9476E-02,-.6780E-02,+.1767E-03,-.5422E-03, & -.7753E-03,-.2106E-03,-.9870E-04,-.1721E-04, & -.9536E-02,-.9580E-02,-.1050E-01,-.5747E-02,-.1282E-02,+.2248E-03, & +.1694E-03,-.4782E-04,-.2441E-04, & +.5781E-03,+.6212E-02,+.1921E-02,-.1102E-02,-.8145E-03,+.2497E-03, & +.1539E-03,-.2538E-04, & -.3993E-02,+.9777E-02,+.4837E-03,-.1304E-02,+.2417E-04,-.1370E-04, & -.3731E-05, & +.1922E-02,-.5167E-03,+.4295E-03,-.1888E-03,+.2427E-04,+.4012E-04, & +.1529E-02,-.2120E-03,+.8166E-04,+.2579E-04,+.3488E-04, & +.2140E-03,+.2274E-03,-.3447E-05,-.1075E-04, & -.1018E-03,+.2864E-04,+.3442E-04, & -.1002E-03,+.7117E-04, & +.2045E-04 / DATA zaels/ & +.1637E-01,+.1935E-01,+.1080E-01,+.2784E-02,+.1606E-03,+.1860E-02, & +.1263E-02,-.2707E-03,-.2290E-03,-.9761E-05, & -.7317E-02,+.2465E-01,+.6799E-02,-.1913E-02,+.1382E-02,+.6691E-03, & +.1414E-03,+.3527E-04,-.5210E-04, & +.1873E-01,+.2977E-02,+.4650E-02,+.2509E-02,+.3680E-03,+.1481E-03, & -.6594E-04,-.5634E-04, & +.1592E-01,-.1875E-02,-.1093E-02,+.3022E-03,+.2625E-03,+.3252E-04, & -.3803E-04, & +.4218E-02,-.1843E-02,-.1351E-02,-.2952E-03,-.8171E-05,-.1473E-04, & +.9076E-03,-.1057E-02,+.2676E-03,+.1307E-03,-.3628E-04, & -.9158E-03,+.4335E-03,+.2927E-04,+.6602E-04, & -.3570E-03,+.5760E-04,-.3465E-04, & -.8535E-04,-.2011E-04, & +.6612E-06 / DATA zaeuc/ & +.8005E-01,+.7095E-01,+.2014E-01,-.1412E-01,-.2425E-01,-.1332E-01, & -.2904E-02,+.5068E-03,+.9369E-03,+.4114E-03,+.7549E-04, & +.1922E-01,+.2534E-01,+.2088E-01,+.1064E-01,+.1063E-02,-.2526E-02, & -.2091E-02,-.9660E-03,-.2030E-03,+.3865E-04, & -.9900E-02,-.5964E-02,+.2223E-02,+.4941E-02,+.3277E-02,+.1038E-02, & -.1480E-03,-.2844E-03,-.1208E-03, & +.3999E-02,+.6282E-02,+.2813E-02,+.1475E-02,+.4571E-03,-.1349E-03, & -.9011E-04,-.1936E-04, & +.1994E-02,+.3540E-02,+.8837E-03,+.1992E-03,+.3092E-04,-.7979E-04, & -.2664E-04, & -.5006E-04,+.6447E-03,+.5550E-03,+.1197E-03,+.6657E-04,+.1488E-04, & -.9141E-04,-.2896E-03,-.1561E-03,-.6524E-04,-.1559E-04, & -.1082E-03,-.4126E-03,-.1732E-03,-.8286E-04, & -.1993E-04,+.3850E-04,+.2870E-04, & +.4493E-04,+.4721E-04, & +.1338E-04 / DATA zaeus/ & +.6646E-02,+.8373E-02,+.5463E-02,+.4554E-02,+.3301E-02,+.5725E-03, & -.7482E-03,-.6222E-03,-.2603E-03,-.5127E-04, & -.3849E-04,+.9741E-02,+.8190E-02,+.5712E-02,+.3039E-02,+.5290E-03, & -.2044E-03,-.2309E-03,-.1160E-03, & +.9160E-02,+.1286E-01,+.1170E-01,+.5491E-02,+.1393E-02,-.6288E-04, & -.2715E-03,-.1047E-03, & +.4873E-02,+.3545E-02,+.3069E-02,+.1819E-02,+.6947E-03,+.1416E-03, & -.1538E-04, & -.4351E-03,-.1907E-02,-.5774E-03,-.2247E-03,+.5345E-04,+.9052E-04, & -.3972E-04,-.9665E-04,+.7912E-04,-.1094E-04,-.6776E-05, & +.2724E-03,+.1973E-03,+.6837E-04,+.4313E-04, & -.7174E-05,+.8527E-05,-.2160E-05, & -.7852E-04,+.3453E-06, & -.2402E-05 / DATA zaedc/ & +.2840E-01,+.1775E-01,-.1069E-01,-.1553E-01,-.3299E-02,+.3583E-02, & +.2274E-02,+.5767E-04,-.3678E-03,-.1050E-03,+.2133E-04, & +.2326E-01,+.1566E-01,-.3130E-02,-.8253E-02,-.2615E-02,+.1247E-02, & +.1059E-02,+.1196E-03,-.1303E-03,-.5094E-04, & +.1185E-01,+.7238E-02,-.1562E-02,-.3665E-02,-.1182E-02,+.4678E-03, & +.4448E-03,+.8307E-04,-.3468E-04, & +.5273E-02,+.3037E-02,-.4014E-03,-.1202E-02,-.4647E-03,+.5148E-04, & +.1014E-03,+.2996E-04, & +.2505E-02,+.1495E-02,+.2438E-03,-.1223E-03,-.7669E-04,-.1638E-04, & +.1869E-05, & +.1094E-02,+.6131E-03,+.1508E-03,+.1765E-04,+.1360E-05,-.7998E-06, & +.4475E-03,+.2737E-03,+.6430E-04,-.6759E-05,-.6761E-05, & +.1992E-03,+.1531E-03,+.4828E-04,+.5103E-06, & +.7454E-04,+.5917E-04,+.2152E-04, & +.9300E-05,+.9790E-05, & -.8853E-05 / DATA zaeds/ & +.9815E-02,+.8436E-02,+.1087E-02,-.2717E-02,-.1755E-02,-.1559E-03, & +.2367E-03,+.8808E-04,+.2001E-05,-.1244E-05, & +.1041E-01,+.8039E-02,+.1005E-02,-.1981E-02,-.1090E-02,+.1595E-05, & +.1787E-03,+.4644E-04,-.1052E-04, & +.6593E-02,+.3983E-02,-.1527E-03,-.1235E-02,-.5078E-03,+.3649E-04, & +.1005E-03,+.3182E-04, & +.3225E-02,+.1672E-02,-.7752E-04,-.4312E-03,-.1872E-03,-.1666E-04, & +.1872E-04, & +.1133E-02,+.5643E-03,+.7747E-04,-.2980E-04,-.2092E-04,-.8590E-05, & +.2988E-03,+.6714E-04,-.6249E-05,+.1052E-04,+.8790E-05, & +.1569E-03,-.1175E-04,-.3033E-04,-.9777E-06, & +.1101E-03,+.6827E-05,-.1023E-04, & +.4231E-04,+.4905E-05, & +.6229E-05 / !------------------------------------------------------------------------------ ! Begin Subroutine init_radiation !------------------------------------------------------------------------------ !------------------------------------------------------------------------------ ! Section 1: Compute the start- and end-indices !------------------------------------------------------------------------------ IF (nradcoarse > 1) THEN ! Set indices: ! iendparrad, jendparrad end of i-/j-index for preparations ! istartrad/jstartrad/iendrad/jendrad begin/end of i-/j-index for averaging IF (my_cart_neigh(1) == -1) THEN istartrad = 1 ELSE istartrad = istartpar-MOD(isubpos(my_cart_id,1)-1,nradcoarse) ENDIF iendrad=iend+ABS(MIN(nradcoarse,nboundlines)-MOD(isubpos(my_cart_id,1) & +iend-MAX(nboundlines,nradcoarse)-1,nradcoarse)) IF (iend == iendpar) iendrad=iend+MOD(iendrad-iend,nradcoarse) IF (my_cart_neigh(4) == -1) THEN jstartrad = 1 ELSE jstartrad = jstartpar-MOD(isubpos(my_cart_id,2)-1,nradcoarse) ENDIF jendrad=jend+ABS(MIN(nradcoarse,nboundlines)-MOD(isubpos(my_cart_id,2) & +jend-MAX(nboundlines,nradcoarse)-1,nradcoarse)) IF (jend == jendpar) jendrad=jend+MOD(jendrad-jend,nradcoarse) IF (my_cart_neigh(3) == -1) THEN iendparrad=iendpar ELSE iendparrad=iendrad ENDIF IF (my_cart_neigh(2) == -1) THEN jendparrad=jendpar ELSE jendparrad=jendrad ENDIF idim_rad = (iendrad-istartrad+nradcoarse)/nradcoarse IF (iendpar > iend) idim_rad = idim_rad + 1 ENDIF !------------------------------------------------------------------------------ ! Section 2: Calculation of the inverse Legendre and Fourier transformation !------------------------------------------------------------------------------ ! loops in i and j over model domain IF (itype_aerosol == 1) THEN zaea=RESHAPE((/0.0477, 0.0875, 0.1198, 0.0458, & 0.0387, 0.0439, 0.0599, 0.0396, & 0.0381, 0.0129, 0.0130, 0.1304, & 0.1757, 0.0949, 0.0653, 0.0795, & 0.0962, 0.2046, 0.4116, 0.0169, & 0.0204, 0.0263, 0.0348, 0.0361, & 0.0030, 0.0271, 0.0613, 0.0118, & 0.0160, 0.0231, 0.0287, 0.0127, & 0.0103, 0.000016,0.0000, 0.0087, & 0.0238, 0.0511, 0.0734, 0.0809/),(/8,5/)) zaes=RESHAPE((/0.1407, 0.4256, 1.0066, 0.0279, & 0.0391, 0.0445, 0.0485, 0.0362, & 0.6746, 0.8761, 1.0139, 0.0443, & 0.0624, 0.0921, 0.1491, 0.2327, & 0.0605, 0.2761, 0.7449, 0.0023, & 0.0034, 0.0051, 0.0065, 0.0045, & 0.0284, 0.5524, 0.9683, 0.0001, & 0.0004, 0.0024, 0.0049, 0.0030, & 0.0467, 0.3854, 1.1008, 0.0000, & 0.00005,0.0004, 0.0006, 0.0006/),(/8,5/)) zaeg=RESHAPE((/0.6989, 0.6329, 0.6418, 0.6243, & 0.7299, 0.7430, 0.7086, 0.8569, & 0.7833, 0.7575, 0.7456, 0.4997, & 0.6130, 0.7440, 0.7426, 0.7590, & 0.5753, 0.5867, 0.5957, 0.6027, & 0.6766, 0.6117, 0.5439, 0.6905, & 0.5170, 0.6674, 0.7004, 0.0340, & 0.0570, 0.1289, 0.1597, 0.1906, & 0.3751, 0.6353, 0.7259, 0.0037, & 0.0083, 0.0177, 0.0201, 0.0332/),(/8,5/)) zaef(:,:)= 0.0_ireals DO j = 1, je DO i = 1, ie !CPS01 ! Calculation of the values zalp for the sine of latitude (zsinphi) of the ! normalized Legendre associated functions. The limit wave number is 10. IF (lperi_x) THEN ! In case of periodic BCs, set a constant reference ! point for the aerosol distribution to make it equal everywhere ! in the domain. This reference point is chosen to be the reference point ! of the model domain as determined by pollon, pollat: zsinphi = SIN (degrad*(90.0_ireals-ABS(pollat))) ELSE zsinphi = SIN(rlat(i,j) ) END IF !CPS01 !CPS zsinphi = SIN(rlat(i,j) ) zcosphi = SQRT(1.-zsinphi**2) jzj = 2 zf1m = SQRT(3.0) zalp (1) = 1.0 zalp (2) = zf1m*zsinphi wave_number_loop : DO jzm1 = 1, 11 jzm = jzm1-1 zm = jzm z2m = zm + zm zre1 = SQRT(z2m+3.0) ze1 = 1.0/zre1 IF (jzm.NE.0) THEN zf2m = zf1m*zcosphi/SQRT(z2m) zf1m = zf2m*zre1 jzj = jzj + 1 zalp(jzj) = zf2m IF(jzm ==10) CYCLE wave_number_loop jzj = jzj + 1 zalp(jzj) = zf1m*zsinphi IF(jzm1==10) CYCLE wave_number_loop ENDIF jzm2 = jzm+2 DO jzn = jzm2, 10 zn = jzn zn2 = zn**2 ze2 = SQRT( (4.0*zn2-1.0)/(zn2-zm**2) ) jzj = jzj+1 zalp(jzj) = ze2*(zsinphi*zalp(jzj-1)-ze1*zalp(jzj-2)) ze1 = 1.0/ze2 ENDDO ENDDO wave_number_loop ! Legendre transform of aerosols zfaes(:) = 0.0_ireals zfael(:) = 0.0_ireals zfaeu(:) = 0.0_ireals zfaed(:) = 0.0_ireals imn = 0 imnc = 0 imns = 0 DO jmm = 1, 11 imn = imn + 1 DO jnn = jmm, 11 imnc = imnc + 1 zfaes(imn) = zfaes(imn)+zalp(imnc)*zaesc(imnc) zfael(imn) = zfael(imn)+zalp(imnc)*zaelc(imnc) zfaeu(imn) = zfaeu(imn)+zalp(imnc)*zaeuc(imnc) zfaed(imn) = zfaed(imn)+zalp(imnc)*zaedc(imnc) ENDDO IF(jmm.NE.1) THEN imn = imn+1 DO jnn = jmm, 11 imns = imns + 1 zfaes(imn) = zfaes(imn)+zalp(imns+11)*zaess(imns) zfael(imn) = zfael(imn)+zalp(imns+11)*zaels(imns) zfaeu(imn) = zfaeu(imn)+zalp(imns+11)*zaeus(imns) zfaed(imn) = zfaed(imn)+zalp(imns+11)*zaeds(imns) ENDDO ENDIF ENDDO ! Inverse Fourier transformation !CPS02 IF (lperi_y .OR. l2dim) THEN ! In case of periodic BCs, set a constant reference ! point for the aerosol distribution to make it equal everywhere ! in the domain. This reference point is chosen to be the reference point ! of the model domain as determined by pollon, pollat: zcos1 = COS(degrad*(pollon-SIGN(1.0_ireals,pollon)*180.0_ireals)) zsin1 = sin(degrad*(pollon-SIGN(1.0_ireals,pollon)*180.0_ireals)) ELSE zcos1 = COS(rlon(i,j) ) zsin1 = SIN(rlon(i,j) ) END IF !CPS02 !CPS zcos1 = COS(rlon(i,j) ) !CPS zsin1 = SIN(rlon(i,j) ) zcos2 = zcos1*zcos1 - zsin1*zsin1 zsin2 = zsin1*zcos1 + zcos1*zsin1 zcos3 = zcos2*zcos1 - zsin2*zsin1 zsin3 = zsin2*zcos1 + zcos2*zsin1 zcos4 = zcos3*zcos1 - zsin3*zsin1 zsin4 = zsin3*zcos1 + zcos3*zsin1 zcos5 = zcos4*zcos1 - zsin4*zsin1 zsin5 = zsin4*zcos1 + zcos4*zsin1 zcos6 = zcos5*zcos1 - zsin5*zsin1 zsin6 = zsin5*zcos1 + zcos5*zsin1 zcos7 = zcos6*zcos1 - zsin6*zsin1 zsin7 = zsin6*zcos1 + zcos6*zsin1 zcos8 = zcos7*zcos1 - zsin7*zsin1 zsin8 = zsin7*zcos1 + zcos7*zsin1 zcos9 = zcos8*zcos1 - zsin8*zsin1 zsin9 = zsin8*zcos1 + zcos8*zsin1 zcos10 = zcos9*zcos1 - zsin9*zsin1 zsin10 = zsin9*zcos1 + zcos9*zsin1 aersea(i,j) = zfaes(1) + 2.* ( zfaes(2 ) * zcos1 + zfaes(3 ) * zsin1 & + zfaes(4 ) * zcos2 + zfaes(5 ) * zsin2 & + zfaes(6 ) * zcos3 + zfaes(7 ) * zsin3 & + zfaes(8 ) * zcos4 + zfaes(9 ) * zsin4 & + zfaes(10) * zcos5 + zfaes(11) * zsin5 & + zfaes(12) * zcos6 + zfaes(13) * zsin6 & + zfaes(14) * zcos7 + zfaes(15) * zsin7 & + zfaes(16) * zcos8 + zfaes(17) * zsin8 & + zfaes(18) * zcos9 + zfaes(19) * zsin9 & + zfaes(20) * zcos10+ zfaes(21) * zsin10 ) aerlan(i,j) = zfael(1) + 2.* ( zfael(2 ) * zcos1 + zfael(3 ) * zsin1 & + zfael(4 ) * zcos2 + zfael(5 ) * zsin2 & + zfael(6 ) * zcos3 + zfael(7 ) * zsin3 & + zfael(8 ) * zcos4 + zfael(9 ) * zsin4 & + zfael(10) * zcos5 + zfael(11) * zsin5 & + zfael(12) * zcos6 + zfael(13) * zsin6 & + zfael(14) * zcos7 + zfael(15) * zsin7 & + zfael(16) * zcos8 + zfael(17) * zsin8 & + zfael(18) * zcos9 + zfael(19) * zsin9 & + zfael(20) * zcos10+ zfael(21) * zsin10 ) aerurb(i,j) = zfaeu(1) + 2.* ( zfaeu(2 ) * zcos1 + zfaeu(3 ) * zsin1 & + zfaeu(4 ) * zcos2 + zfaeu(5 ) * zsin2 & + zfaeu(6 ) * zcos3 + zfaeu(7 ) * zsin3 & + zfaeu(8 ) * zcos4 + zfaeu(9 ) * zsin4 & + zfaeu(10) * zcos5 + zfaeu(11) * zsin5 & + zfaeu(12) * zcos6 + zfaeu(13) * zsin6 & + zfaeu(14) * zcos7 + zfaeu(15) * zsin7 & + zfaeu(16) * zcos8 + zfaeu(17) * zsin8 & + zfaeu(18) * zcos9 + zfaeu(19) * zsin9 & + zfaeu(20) * zcos10+ zfaeu(21) * zsin10 ) aerdes(i,j) = zfaed(1) + 2.* ( zfaed(2 ) * zcos1 + zfaed(3 ) * zsin1 & + zfaed(4 ) * zcos2 + zfaed(5 ) * zsin2 & + zfaed(6 ) * zcos3 + zfaed(7 ) * zsin3 & + zfaed(8 ) * zcos4 + zfaed(9 ) * zsin4 & + zfaed(10) * zcos5 + zfaed(11) * zsin5 & + zfaed(12) * zcos6 + zfaed(13) * zsin6 & + zfaed(14) * zcos7 + zfaed(15) * zsin7 & + zfaed(16) * zcos8 + zfaed(17) * zsin8 & + zfaed(18) * zcos9 + zfaed(19) * zsin9 & + zfaed(20) * zcos10+ zfaed(21) * zsin10 ) aersea(i,j) = MAX( 0.0_ireals, MIN( 1.0_ireals, aersea(i,j) ) ) aerlan(i,j) = MAX( 0.0_ireals, MIN( 1.0_ireals, aerlan(i,j) ) ) aerurb(i,j) = MAX( 0.0_ireals, MIN( 1.0_ireals, aerurb(i,j) ) ) aerdes(i,j) = MAX( 0.0_ireals, MIN( 1.0_ireals, aerdes(i,j) ) ) ! end of loops over model domain ENDDO ENDDO ENDIF ! itype_aerosol = 1 IF (itype_aerosol == 2) THEN zaea=RESHAPE((/0.0345_ireals, 0.0511_ireals, 0.0847_ireals, 0.0336_ireals, & 0.0499_ireals, 0.0364_ireals, 0.0382_ireals, 0.0260_ireals, & 0.0457_ireals, 0.0018_ireals, 0.0015_ireals, 0.1361_ireals, & 0.2346_ireals, 0.1177_ireals, 0.0684_ireals, 0.0808_ireals, & 0.0707_ireals, 0.0689_ireals, 0.1557_ireals, 0.1258_ireals, & 0.1588_ireals, 0.1973_ireals, 0.2766_ireals, 0.1134_ireals, & 0.0597_ireals, 0.1077_ireals, 0.2095_ireals, 0.0299_ireals, & 0.0456_ireals, 0.0358_ireals, 0.0377_ireals, 0.0304_ireals, & 0.0103_ireals, 0.000016_ireals,0.0000_ireals, 0.0087_ireals, & 0.0238_ireals, 0.0511_ireals, 0.0734_ireals, 0.0809_ireals/),(/8,5/)) zaes=RESHAPE((/0.1030_ireals, 0.3977_ireals, 1.0680_ireals, 0.0084_ireals, & 0.0142_ireals, 0.0191_ireals, 0.0234_ireals, 0.0140_ireals, & 0.7894_ireals, 0.9734_ireals, 1.0110_ireals, 0.0307_ireals, & 0.0531_ireals, 0.0546_ireals, 0.0839_ireals, 0.2142_ireals, & 0.7157_ireals, 0.8698_ireals, 0.8604_ireals, 0.0645_ireals, & 0.0781_ireals, 0.1256_ireals, 0.2317_ireals, 0.1409_ireals, & 0.0859_ireals, 0.3442_ireals, 0.9496_ireals, 0.0067_ireals, & 0.0113_ireals, 0.0153_ireals, 0.0187_ireals, 0.0113_ireals, & 0.0467_ireals, 0.3854_ireals, 1.1008_ireals, 0.0000_ireals, & 0.00005_ireals,0.0004_ireals, 0.0006_ireals, 0.0006_ireals/),(/8,5/)) zaeg=RESHAPE((/0.6562_ireals, 0.6614_ireals, 0.7109_ireals, 0.5043_ireals, & 0.6486_ireals, 0.6814_ireals, 0.6489_ireals, 0.7799_ireals, & 0.8105_ireals, 0.7906_ireals, 0.7947_ireals, 0.4374_ireals, & 0.5203_ireals, 0.7076_ireals, 0.7246_ireals, 0.7535_ireals, & 0.6932_ireals, 0.6962_ireals, 0.7402_ireals, 0.4029_ireals, & 0.5587_ireals, 0.5618_ireals, 0.4520_ireals, 0.7120_ireals, & 0.6462_ireals, 0.6510_ireals, 0.6955_ireals, 0.5041_ireals, & 0.6482_ireals, 0.6805_ireals, 0.6477_ireals, 0.7753_ireals, & 0.3751_ireals, 0.6353_ireals, 0.7259_ireals, 0.0037_ireals, & 0.0083_ireals, 0.0177_ireals, 0.0201_ireals, 0.0332_ireals/),(/8,5/)) zaef(:,:) = 0.0_ireals ENDIF ! itype_aerosol = 2 !------------------------------------------------------------------------------ ! Section 3: Data for radiative transfer calculations !------------------------------------------------------------------------------ IF (my_cart_id == 0) THEN PRINT *,'*****************************************************' PRINT *,'* Radiative transfer calculations employ data *' PRINT *,'* provided in routine rad_aibi *' PRINT *,'*****************************************************' ENDIF ! Include reference pressure and temperature in *cobi* DO jg = 1, jpgas DO js = 1, jpspec DO jc = 1, ncgas(js,jg) cobi(jc,js,jg) = cobi(jc,js,jg) * (1./pgas(js,jg))**coali(jc,js,jg) & * ( tgas(js,jg))**cobti(jc,js,jg) ENDDO ENDDO ENDDO ! security settings, if a gas shall not be considered in an intervall ! where the esft will be used. DO jg = 1, jpgas DO js = 1, jpspec IF ( nfast(js) == 0 .AND. ncgas(js,jg) == 0 ) THEN ncgas (js,jg) = 1 coai (1,js,jg) = 1.00 cobi (1,js,jg) = 0.00 coali (1,js,jg) = 1.00 cobti (1,js,jg) = 1.00 END IF ENDDO ENDDO !------------------------------------------------------------------------------ ! Section 4: Precalculation of albedo of soil type as function of soil water ! content and depth of upper soil layer !------------------------------------------------------------------------------ ! Albedo of soil type (without vegetation) as function of soil water content ! (in mH2O) and depth of the upper soil layer zdzwb = 0.0_ireals IF (lmulti_layer) THEN zdzwb = 1.0_ireals / (2.0_ireals * czmls(1)) ELSE IF ( nlgw == 2 ) THEN zdzwb = 1.0_ireals / cdzw12 ELSE zdzwb = 1.0_ireals / cdzw13 ENDIF ENDIF DO ist = 1, 10 rad_csalbw(ist) = csalbw(ist) * zdzwb ENDDO !------------------------------------------------------------------------------ ! End of the subroutine !------------------------------------------------------------------------------ END SUBROUTINE init_radiation !============================================================================== !============================================================================== !+ Module procedure in "Radiation" !------------------------------------------------------------------------------ SUBROUTINE organize_radiation (ydate_ini) !------------------------------------------------------------------------------ ! ! Description: ! ! The module procedure organize_radiations forms the interface between ! the model and the radiation code adapted from the global model gm_e. ! ! Method: ! ! All variables that are required for the radiation code (i.e. input arrays ! and scalars) are provided or calculated from the model variabels. ! The results are stored as solar and thermal heating rates on the ! corresponding global arrays sohr and thhr. ! !------------------------------------------------------------------------------ ! ! T.R.: ! Die Variablen zfltf und zflsf (pfltf pflsf in fesft) wurden entfernt, da sie ! nicht weiterverwemdet werden. lcrf and ldebug wurden von Variablen zu ! Parametern. ! Methode fuer Strahlungsrechnung auf groeberem Gitter: ! Die Eingangsgroessen fuer die Routine fesft werden auf groeberes Gitter gemittelt ! (Variablennamen der gemittelten Groessen: XXX_rn). ! Dann Aufruf von fesft mit _rn-Variablen. ! Dann Zurueckspeichern auf LM-Gitter. ! Dann Abziehen der jeweils auf dem groben Gitter berechneten therm. Ausstrahlung und ! reflektierten Solarstrahlung. ! Dann Filtern der Strahlungsinkremente mit diskretem Filter (analog lconf_avg), ! falls lradf_avg==.TRUE. ! Dann Hinzufuegen der therm. Ausstrahlung (gemaess tg auf feinem Gitter) und der ! solaren Rueckstrahlung (gemaess Albedo auf feinem Gitter). ! Kurzerklaerung zu einigen Variablen: ! nradcoarse: Zahl der GP (je x-/y-Richtung, ueber die gemittelt wird ! 1 = wie bisher, 2 = 2-mal-2-Gebiet usw. ! lradave = interner Schalter, der abfragt, ob ueberhaupt gemittelt werden soll ! (ist true fuer nradcoarse > 1) ==> bei nradcoarse==1 wird nichts gemacht ! alb_rad am Ende, wie es ausgegeben wird, ist die originale Albedo! ! qc_rad und qi_rad sind ebenfalls originale Felder (urspruengliches LM-Gitter)! ! Version auk9_neu8. ! ! The variables zfltf and zflsf (pfltf,pflsf inside fesft) were removed since they ! are not used. lcrf and ldebug were made parameters. ! Method for radiation calculation on coarser grid: ! Input fields for subroutine fesft are averaged onto coarser grid (variable names ! of coarse-grid variables: XXX_rn). ! Then subroutine fesft is called with _rn variables. ! Then coarse-grid fields are stored back onto original (LM) grid. ! Then surface outgoing thermal radiation (calculated with coarse-grid t_g) and ! reflected solar radiation (calculated with coaerse-grid albedo) are substracted from ! thbs and sobs, resp. ! Then the radiative increments are filtered with discrete filter (analogous to ! lconf_avg), if lradf_avg == .true. ! Then surface outgoing thermal radiation (calculated with coarse-grid t_g) and ! reflected solar radiation (calculated with coaerse-grid albedo) are added to thbs ! and sobs, resp. ! ! nradcoarse: number of gridpoints (per x/y direction) to be averaged ! 1: as hitherto; 2: 2-times-2 area and so on ! lradave = internal switch, whether radiation calculation on coarser grid is applied ! at all (.true. for nradcoarse > 1) ==> if nradcoarse==1, then lradave=.false. and ! nothing new is done ! alb_rad at end, as in output, is original (LM fine-scale) albedo! ! qc_rad and qi_rad are also original (LM fine-scale) fields! !============================================================================== ! Parameterlist ! ------------- CHARACTER (LEN=10), INTENT(IN) :: & ydate_ini ! start of the forecast yyyymmddhh (year, month, day, hour) ! Local parameters: ! ---------------- LOGICAL, PARAMETER :: & lcrf = .FALSE. , & ldebug= .FALSE. REAL (KIND=ireals ), PARAMETER :: & zcent = 0.2500_ireals, & ! centre weight in a nine point stencil !T.R. zside = 0.1250_ireals, & ! weight for side points !T.R. zedge = 0.0625_ireals, & ! weight for edge points !T.R. zepclc = 1.0E-8_ireals, & ! avoids cloud cover =1.0 and = 0.0 zeph2o = 1.0E-9_ireals, & ! minimum value for specific humidity zepemu = 1.0E-9_ireals, & ! avoids cosine of zenith angle = 0.0 zclwcm = 1.0E-9_ireals, & ! avoids cloud water content = 0.0 rtod = 57.2957795_ireals ! conversion from radians to degrees ! the former parameter zqco2 = 0.5014E-3_ireals is now a variable ! (for specifying different co2 scenarios in the Climate-LM Version). ! It is set later in this subroutine dependent on the setting of the Namelist ! Parameter ico2_rad ! Local scalars: ! ------------- ! Input for the radiation routine fesft ! ------------------------------------- INTEGER (KIND=iintegers) :: & ki1sd, & ! start index for first array dimension ki1ed, & ! end index for first array dimension ki2sd, & ! start index for second array dimension ki2ed, & ! end index for second array dimension ki3sd, & ! start index for third array dimension ki3ed, & ! end index for third array dimension ! and the same for the computations ki1sc, & ! start index for first array computation ki1ec, & ! end index for first array computation ki2sc, & ! start index for second array computation ki2ec, & ! end index for second array computation ki3sc, & ! start index for third array computation ki3ec ! end index for third array computation LOGICAL :: & lradave, & ! internal switch whether radiation is coarse-grid ! T.R. lrady, & ! for radiation on coaerse-grid !T.R. lsolar(je) ! control switch for solar calculations REAL (KIND=ireals ) :: & zstb, & ! Stefan-Boltzman constant zsct ! solar constant (at time of year) INTEGER (KIND=iintegers) :: & kzdims(24), & j_rn,nradcoarse_y, & ! for radiation on coaerse grid! T.R. izz,ii,jz1, n, & ! for radiation on coaerse grid! T.R. i, j, js, k, i_ld, & ! loop indices over spatial dimensions nzx , i_std, i_etd,& ! time level of prognostic variables nzrad, & ! jj , itaja, & ! output from routine get_utc_dat ist , & ! loop index for soil type nztgpk, nzp, nzpa, & ! loop index for gridpoint output izstata, & ! error status at allocation !T.R. izstatd, & ! error status at deallocation !T.R. izerror, izdebug ! for error status REAL (KIND=ireals ) :: & zalbfak, & ! albedo correction factor !T.R. zfactor,zfactor_b, & ! for radiation on coaerse grid !T.R. zalbradtopo, & ! buz/T.R. zemissfac, & ! buz/T.R. zemissivity, & ! buz/T.R. ztrbga, zvobga, zstbga, & ! output from routine aerdis zaeops, zaeopl, zaeopu, & ! " zaeopd, ztrpt , zaeadm, & ! " zstunde, & ! output from routine get_utc_dat ztwo , ztho , & ! zdtzgl, zdek , & ! zsocof, zeit0 , & ! zdeksin,zdekcos, & ! zmaxmu0(je) ,zeitrad, & ! zsinphi,zcosphi, zcosthi, & ! zsnow , zvege , & ! zph ,zsigma , zdthdz , & ! zpio ,zpiu , zpim , & ! zpnf ,zphf , zphfo , & ! zthvo ,zthvu , zuc , & ! zclwfac,zclwcmn, & ! zclwfs ,zclwcs , & ! zclics ,zclws , & ! zclick ,zclwck , zclwk, & ! zclwfk , & ! zcs ,zck , zfac , & ! zt_ice1,zt_ice2, & ! fgew ,fgee , fgqv , & ! name of statement functions ztt ,zzpv , zzpa , & ! dummy arguments of stat. func. zrealdiff, zsmu0_loc , & ! dummy arguments of stat. func. zsalb_snow, zsnow_alb , & ! zqdw, zsex, zf_ice, zdpo, & ! zdpn, x1, x2, phi_s CHARACTER (LEN=10) yrad1 ! output from routine get_utc_dat CHARACTER (LEN=22) yrad2 ! output from routine get_utc_dat CHARACTER (LEN=80) yzerrmsg ! for error message REAL (KIND=ireals ) :: & zyear, zqco2 ! for specifying different CO2 scenarios ! in the Climate-LM Version ! Local (automatic) arrays: ! ------------------------ REAL (KIND=ireals ) :: & ! Input for the radiation routine fesft ! zqdw (ie,ke ) , & ! Total water (qv+qc) ! zsex (ie,ke ) , & ! ! zf_ice (ie,ke ) , & ! ! zphl (ie,ke1) , & ! Pressure at half evels s ! zdpr (ie,ke ) , & ! Pressure thickness of layers zti (ie,je,ke1) , & ! Tempeature at layer boundaries zclc (ie,je,ke ) , & ! Cloud cover in each layer zwv (ie,je,ke ) , & ! Water vapour mixing ratio zsw (ie,je,ke ) , & ! Saturation water vapour mixing ratio over water zse (ie,je,ke ) , & ! Saturation water vapour mixing ratio over ice zclwc (ie,je,ke ) , & ! liquid water mixing ratio zciwc (ie,je,ke ) , & ! ice mixing ratio zduco2f(ie,je,ke ) , & ! CO2 content in layer zduo3f (ie,je,ke ) , & ! O3 content in layer zaeq1 (ie,je,ke ) , & ! Type1-Aerosole optical depth at 0.55 micrometer zaeq2 (ie,je,ke ) , & ! Type2 " zaeq3 (ie,je,ke ) , & ! Type3 " zaeq4 (ie,je,ke ) , & ! Type4 " zaeq5 (ie,je,ke ) , & ! Type5 " zapre (ie,je ) , & ! Surface pressure zsmu0 (ie,je ) , & ! Cosine of zenith angle zalth (ie,je ) , & ! Thermal surface albedo zalso (ie,je ) , & ! Solar surface albedo #ifdef COUP_OAS_COS zpalp (ie,je ) , & ! Direct albedo #endif ! other values for intermediate storage zclcmax(ie,je,ke ) , & ! zclcmin(ie,je,ke ) , & ! zclcm1 (ie,je) , & ! ! zclx (ie,ke ) , & ! ! Output from the radiation routine fesft zflt (ie,ke1) , & ! Thermal radiative flux at layer boundary zfls (ie,ke1) , & ! Solar radiative flux at layer boundary zflsdir(ie,ke1) , & ! solar direct downward radiative flux at ! layer boundary ! surface flux of photosynthetic active radiation and components zflpar (ie ) , & ! surface flux of photosynthetic acive radiation zflsp_par (ie ) , & ! direct component zflsd_par (ie ) , & ! diffuse downward component zflsu_par (ie ) , & ! diffuse upward component ! 2D fields for averaging and distribution, if working on a coarse grid zzflsp_par(ie,je) , & ! direct component zzflsd_par(ie,je) , & ! diffuse downward component zzflsu_par(ie,je) ! diffuse upward component REAL (KIND=ireals ) :: & ! corrected solar and thermal fluxes at layer boundary and components zfls_s (ie) , & ! Corrected solar zflt_s (ie) , & ! thermal zflsp (ie) , & ! direct component of solar radiative flux zflsd (ie) , & ! diffuse downward component of solar flux zflsu (ie) , & ! diffuse upward component of solar flux zfltd (ie) , & ! diffuse downward component of thermal flux zfltu (ie) , & ! diffuse upward component of thermal flux zskyview (ie,je) ! used as argument for SR fesft ! zfcor (ie,je) , & ! ! zslo_ang (ie) , & ! ! zslo_asp (ie) , & ! ! zhori (ie,nhori), & ! ! zzsmu0 (ie) , & ! ! zrlat (ie) , & ! ! zrlon (ie) REAL (KIND=ireals ) :: & ! Other local utility arrays zqcfo (ie,je), zqcfn , & zo3h (ie,je), & zqofo (ie,je), zqofn, & zaeqdo (ie,je), zaeqdn, & zaequo (ie,je), zaequn, & zaeqlo (ie,je), zaeqln, & zaeqso (ie,je), zaeqsn, & zaetr_top(ie,je), zaetr_bot, zaetr, & ! Constants for vertical distribution of aerosole ! (output from routine aerdis) zsign(ke1), zvdaes(ke1), zvdael(ke1), & zvdaeu(ke1), zvdaed(ke1), & zaeadk(3 ), t_test ! in case of nradcoarse > 1: fields on coarse grid: !T.R. REAL (KIND = ireals), ALLOCATABLE :: & tg_rn (: ) , & ! ground temperature tg_ra (:,:) , & ! ground temperature ! Input for the radiation routine fesft zti_rn (:,:) , & ! Tempeature at layer boundaries zdpr_rn (:,:) , & ! Pressure thickness of layers zclc_rn (:,:) , & ! Cloud cover in each layer zwv_rn (:,:) , & ! Water vapour mixing ratio zsw_rn (:,:) , & ! Saturation water vapour mixing ratio over water zclwc_rn (:,:) , & ! liquid water mixing ratio zciwc_rn (:,:) , & ! ice mixing ratio zduco2f_rn(:,:) , & ! CO2 content in layer zduo3f_rn (:,:) , & ! O3 content in layer zaeq1_rn (:,:) , & ! Type1-Aerosole optical depth at 0.55 micrometer zaeq2_rn (:,:) , & ! Type2 " zaeq3_rn (:,:) , & ! Type3 " zaeq4_rn (:,:) , & ! Type4 " zaeq5_rn (:,:) , & ! Type5 " zapre_rn (: ) , & ! Surface pressure zsmu0_rn (: ) , & ! Cosine of zenith angle zalth_rn (: ) , & ! Thermal surface albedo #ifdef COUP_OAS_COS zpalp_rn (: ) , & ! Solar diffuse albedo #endif zalso_rn (: ) ! Solar surface albedo REAL (KIND = ireals), ALLOCATABLE :: & ! Output from the radiation routine fesft zflt_rn (:,:) , & ! Thermal radiative flux at layer boundary zfls_rn (:,:) , & ! Solar radiative flux at layer boundary zflsdir_rn (:,:) , & ! solar direct downward radiative flux at layer boundary ! surface flux of photosynthetic active radiation and components zflpar_rn (: ) , & ! surface flux of photosynthetic acive radiation zflsp_par_rn (: ) , & ! direct component zflsu_par_rn (: ) , & ! diffuse upward component zflsd_par_rn (: ) , & ! diffuse downward component ! corrected solar and thermal fluxes at layer boundary and components zfls_s_rn (: ) , & ! corrected solar radiative flux zflt_s_rn (: ) , & ! thermal flux zflsp_rn (: ) , & ! direct component of solar flux at surface zflsd_rn (: ) , & ! diffuse downward component of solar flux zflsu_rn (: ) , & ! diffuse upward component of solar flux zfltd_rn (: ) , & ! diffuse downward component of thermal flux zfltu_rn (: ) , & ! diffuse upward component of thermal flux zskyv_rn (: ) , & ! diffuse upward component of thermal flux zalb_rad_ori(:,: ) , & ! albedo of original grid zsohr (:,:,:) , & ! rate of solar heating ( k/s ) zthhr (:,:,:) , & ! rate of thermal heating ( k/s ) zsobs (:,:) , & ! solar radiation at ground ( w/m2) zsobt (:,:) , & ! solar radiation at upper boundary of atmosphere zthbs (:,:) , & ! thermal radiation at ground ( w/m2) zthbt (:,:) , & ! thermal radiation at upper boundary of atmosphere zpabs (:,:) , & ! photosynthetic active radiation at ground ( w/m2) zsodwddm (:,:) , & ! 2D fields for averaging and distribution, if working on a coarse grid z_zzfltd (:,:) , & ! diffuse downward component of thermal flux z_zzfltu (:,:) , & ! diffuse upward component of thermal flux z_zzflsp (:,:) , & ! direct component of solar radiative flux z_zzflsd (:,:) , & ! diffuse downward component of solar flux z_zzflsu (:,:) , & ! diffuse upward component of solar flux ! photosynthetic active radiation at the ground ( w/m2): components z_zzflsp_par (:,:) , & ! direct component z_zzflsd_par (:,:) , & ! diffuse downward component z_zzflsu_par (:,:) ! diffuse upward component !- End of header !============================================================================== !------------------------------------------------------------------------------ ! Begin Subroutine organize_radiation !------------------------------------------------------------------------------ ! statement function to calculate saturation vapour pressure over water fgew(ztt) = b1 * EXP( b2w*(ztt - b3)/(ztt - b4w) ) ! ztt: temperature ! statement function to calculate saturation vapour pressure over ice fgee(ztt) = b1 * EXP( b2i*(ztt - b3)/(ztt - b4i) ) ! ztt: temperature ! statement function to calculate specific humitdity fgqv(zzpv,zzpa) = rdv*zzpv/(zzpa - o_m_rdv*zzpv) ! zzpv: vapour pressure ! zzpa: total air pressure !------------------------------------------------------------------------------ ! Section 1: Initializations !------------------------------------------------------------------------------ IF (ldebug_rad) THEN IF (lprintdeb_all) THEN izdebug = idbg_level ELSE IF (my_cart_id == 0) THEN izdebug = idbg_level ELSE izdebug = 0 ENDIF ENDIF ELSE izdebug = 0 ENDIF !---------------------------------------------------------------------------- ! Section 1.1: Some preparations and calculation of local utility variables !---------------------------------------------------------------------------- IF (izdebug > 10) THEN PRINT *, ' START organize_radiation' ENDIF ! select time level according to the integration scheme used IF ( l2tls ) THEN nzx = nnow ELSE nzx = nold ENDIF !---------------------------------------------------------------------------- ! Section 1.1a: calculate zenith angle !---------------------------------------------------------------------------- IF (izdebug > 10) THEN PRINT *, ' calculate zenith angle' ENDIF ! Calculation of zenith angle and related quantities nzrad = ntstep + nincrad/2-1 CALL get_utc_date ( nzrad, ydate_ini, dt, itype_calendar, yrad1, yrad2, & itaja, zstunde ) READ (yrad1(1:4),'(I4)') jj ztwo = 0.681 + 0.2422*(jj-1949)-(jj-1949)/4 ztho = 2.*pi*( REAL(itaja, ireals) -1.0 + ztwo )/365.2422 zdtzgl = 0.000075 + 0.001868*COS( ztho) - 0.032077*SIN( ztho) & - 0.014615*COS(2.*ztho) - 0.040849*SIN(2.*ztho) zdek = 0.006918 - 0.399912*COS( ztho) + 0.070257*SIN( ztho) & - 0.006758*COS(2.*ztho) + 0.000907*SIN(2.*ztho) & - 0.002697*COS(3.*ztho) + 0.001480*SIN(3.*ztho) zsocof = 1.000110 + 0.034221*COS( ztho) + 0.001280*SIN( ztho) & + 0.000719*COS(2.*ztho) + 0.000077*SIN(2.*ztho) zeit0 = pi*(zstunde-12.)/12. + zdtzgl zdeksin = SIN (zdek) zdekcos = COS (zdek) !---------------------------------------------------------------------------- ! Section 1.1b: choose CO2 scenario !---------------------------------------------------------------------------- IF (izdebug > 10) THEN PRINT *, ' choose CO2 scenario ' ENDIF ! Now set zqco2, dependent on the chosen CO2-Scenario zyear = REAL(jj,ireals) + REAL(itaja,ireals)/365.0_ireals SELECT CASE (ico2_rad) CASE (0) ! specific CO2 content of the atmosphere (=330 PPM) (default for DWD) zqco2 = 0.5014E-3_ireals CASE (1) ! time dependent CO2 content (fits of IPCC scenario values, taken from ECHAM5) ! A1B scenario (for 1950 <= zyear <= 2100) ! only CO2 zqco2 = (- 2.2915249519766070E+07_ireals & + 45714.032150104744_ireals * zyear & - 34.178190922262594_ireals * zyear*zyear & + 0.01134997524110402_ireals * zyear**3 & - 1.4124678138498344E-06_ireals * zyear**4) * 1.519E-06_ireals CASE (2) ! A1B scenario (for 1950 <= zyear <= 2100) ! eff. CO2 (i.e. CO2 & CH4 & N2O) zqco2 = ( -2.131843263017098E+07_ireals & + 42697.69425574343_ireals * zyear & - 32.04969808544885_ireals * zyear*zyear & + 0.010685253016710392_ireals * zyear**3 & - 1.3349801856070718E-06_ireals * zyear**4) * 1.519E-06_ireals CASE (3) ! B1 scenario (for 1950 <= zyear <= 2100) ! only CO2 zqco2 = (- 1.0401357268181011E+07_ireals & + 21152.707545487563_ireals * zyear & - 16.116691528852456_ireals * zyear*zyear & + 0.005452554505141226_ireals * zyear**3 & - 6.910849734430986E-07_ireals * zyear**4) * 1.519E-06_ireals CASE (4) ! B1 scenario (for 1950 <= zyear <= 2100) ! eff. CO2 (i.e. CO2 & CH4 & N2O) zqco2 = (- 7.716609874947305E+06_ireals & + 15881.335647116388_ireals * zyear & - 12.239258629216023_ireals * zyear*zyear & + 0.0041862325463834565_ireals * zyear**3 & - 5.361489502050553E-07 * zyear**4) * 1.519E-06_ireals CASE (5) ! A2 scenario (for 1950 <= zyear <= 2100) ! only CO2 zqco2 = ( 3.682237592956851E06_ireals & - 7547.069807360021_ireals * zyear & + 5.8133367065151145_ireals * zyear*zyear & - 0.001994454601121309_ireals * zyear**3 & + 2.571600007798381E-07_ireals * zyear**4 ) * 1.519E-06_ireals CASE (6) ! A2 scenario (for 1950 <= zyear <= 2100) ! eff. CO2 (i.e. CO2 & CH4 & N2O) zqco2 = ( - 340960.0590212098_ireals & + 403.20639583857496_ireals * zyear & - 0.074859345260926_ireals * zyear*zyear & - 0.00005743139714985962_ireals * zyear**3 & + 1.837122734626407E-08 * zyear**4) * 1.519E-06_ireals END SELECT !---------------------------------------------------------------------------- ! Section 1.1c: initialize background aerosol (aerdis) !---------------------------------------------------------------------------- IF (izdebug > 10) THEN PRINT *, ' initialize background aerosol (aerdis)' ENDIF ! The routine aerdis is called to recieve some parameters for the vertical ! distribution of background aerosol. zsign(1) = 0 DO k = 2, ke1 zsign(k) = sigmr(k) ENDDO CALL aerdis ( zsign, zvdaes, zvdael, zvdaeu, zvdaed, ke1, & ztrbga, zvobga, zstbga, zaeops, zaeopl, zaeopu, & zaeopd, ztrpt , zaeadk, zaeadm) !---------------------------------------------------------------------------- ! Section 1.1d: setting of boundaries and lradave !---------------------------------------------------------------------------- ! Setting of array boundaries and constant scalar input for routine fesft ki2sd = 1 ki2ed = 1 ki3sd = 1 ki3ed = ke ki2sc = 1 ki2ec = 1 ki3sc = 1 ki3ec = ke zstb = sigma zsct = zsocof*solc lradave = nradcoarse > 1 IF (lradave) THEN IF (izdebug > 10) THEN PRINT *, ' calculations for radiation averaging ', nradcoarse, lradave ENDIF IF (izdebug > 10) THEN PRINT *, ' memory allocation' ENDIF ! Allocate the fields for the coarser grid with idim_rad ! (has been computed in init_radiation) ALLOCATE ( zti_rn (idim_rad,ke1) , STAT=izstata ) ALLOCATE ( zdpr_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zclc_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zwv_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zsw_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zclwc_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zciwc_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zduco2f_rn(idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zduo3f_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zaeq1_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zaeq2_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zaeq3_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zaeq4_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zaeq5_rn (idim_rad,ke ) , STAT=izstata ) ALLOCATE ( zapre_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zsmu0_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zalth_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zalso_rn (idim_rad ) , STAT=izstata ) #ifdef COUP_OAS_COS ALLOCATE ( zpalp_rn (idim_rad ) , STAT=izstata ) #endif ALLOCATE ( zflt_rn (idim_rad,ke1) , STAT=izstata ) ALLOCATE ( zfls_rn (idim_rad,ke1) , STAT=izstata ) ALLOCATE ( zflsdir_rn(idim_rad,ke1) , STAT=izstata ) ALLOCATE ( zflpar_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zflsu_par_rn(idim_rad ) , STAT=izstata ) ALLOCATE ( zflsd_par_rn(idim_rad ) , STAT=izstata ) ALLOCATE ( zflsp_par_rn(idim_rad ) , STAT=izstata ) ALLOCATE ( tg_rn (ie) , STAT=izstata ) ALLOCATE ( tg_ra (ie,je) , STAT=izstata ) ALLOCATE ( zalb_rad_ori(ie,je) , STAT=izstata ) ALLOCATE ( zfls_s_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zflt_s_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zflsp_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zflsd_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zflsu_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zfltd_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zfltu_rn (idim_rad ) , STAT=izstata ) ALLOCATE ( zskyv_rn (idim_rad ) , STAT=izstata ) zti_rn(:,:) = 0.0_ireals zdpr_rn(:,:) = 0.0_ireals zclc_rn(:,:) = 0.0_ireals zwv_rn(:,:) = 0.0_ireals zsw_rn(:,:) = 0.0_ireals zclwc_rn(:,:) = 0.0_ireals zciwc_rn(:,:) = 0.0_ireals zduco2f_rn(:,:) = 0.0_ireals zduo3f_rn(:,:) = 0.0_ireals zaeq1_rn(:,:) = 0.0_ireals zaeq2_rn(:,:) = 0.0_ireals zaeq3_rn(:,:) = 0.0_ireals zaeq4_rn(:,:) = 0.0_ireals zaeq5_rn(:,:) = 0.0_ireals zalso_rn(:) = 0.0_ireals #ifdef COUP_OAS_COS zpalp_rn(:) = 0.0_ireals #endif zalth_rn(:) = 0.0_ireals zapre_rn(:) = 0.0_ireals zsmu0_rn(:) = 0.0_ireals zfls_s_rn(:) = 0.0_ireals zflt_s_rn(:) = 0.0_ireals zflsp_rn (:) = 0.0_ireals zflsd_rn (:) = 0.0_ireals zflsu_rn (:) = 0.0_ireals zfltd_rn (:) = 0.0_ireals zfltu_rn (:) = 0.0_ireals zskyv_rn (:) = 0.0_ireals ! Setting of array boundaries for routine fesft ki1sc=1 ki1ed=idim_rad ki1sd=1 ELSE !.NOT.lradave: IF (izdebug > 10) THEN PRINT *, ' settings for no radiation averaging' ENDIF ! Set zapre for the interface to fesft !CDIR COLLAPSE zapre(:,:) = p0hl(:,:,ke+1) istartrad = istartpar iendparrad = iendpar jstartrad = jstartpar jendparrad = jendpar ! Setting of array boundaries for routine fesft ki1sd = 1 ki1ed = ie ki1sc = istartpar ki1ec = iendpar ENDIF !lradave ! maximum (in-)cloud water content: 0.5% of specific humidity at saturation zclwfs=0.005 !0.5% of specific humidity at saturation in stratiform clouds zclwfk=0.010 !1.0% of specific humidity at saturation in convective clouds !---------------------------------------------------------------------------- ! Section 1.2: Determine sunshine-condition for every latitude (j-row) !---------------------------------------------------------------------------- IF (izdebug > 10) THEN PRINT *, ' determine sunshine conditions' ENDIF IF ((nprocx > 1) .AND. (lreproduce)) THEN zmaxmu0(:) = 0.0_ireals i_std = isubpos(my_cart_id,1) - nboundlines i_etd = isubpos(my_cart_id,3) + nboundlines ! DO js = jstartpar, jendpar DO js = jstartrad, jendparrad i_ld = 0 DO i = 1, ie_tot !CPS03 IF (lperi_y .OR. l2dim) THEN ! Similar thing for lperi_y=.true. or l2dim=.true.: ! Use the geogr. latitude of the model reference point: zsinphi = SIN (degrad*(90.0_ireals-ABS(pollat))) ELSE zsinphi = SIN (rlattot(i,js)) END IF ! IF (lperi_x) THEN ! In case of lperi_x=.true., use the solar time of the model reference point ! (as implied by pollon,pollat) to avoid boundary disturbances. ! The problem is that the "true" sun is not periodic, but has to be ! "artificially forced" to be periodic for periodic BCs. IF (pollat >= 0.0_ireals) THEN zeitrad = zeit0 + degrad*(pollon-SIGN(1.0_ireals,pollon)*180.0_ireals) ELSE zeitrad = zeit0 + degrad*pollon END IF ELSE zeitrad = zeit0 + rlontot(i,js) END IF zcosphi = SQRT(1.0_ireals - zsinphi**2) !CPS03 !CPS zsinphi = SIN (rlattot(i,js)) !CPS zcosphi = SQRT(1.0_ireals - zsinphi**2) !CPS zeitrad = zeit0 + rlontot(i,js) zcosthi = zdeksin * zsinphi + zdekcos * zcosphi * COS(zeitrad) zsmu0_loc = MAX (zcosthi, zepemu) IF ( (i >= i_std) .AND. (i <= i_etd) ) THEN i_ld = i_ld + 1 zsmu0(i_ld,js) = zsmu0_loc ! Sun azimuth and sun elevation (for computation of relative sunshine duration) buz sun_el(i_ld,js) = ASIN(zsmu0_loc) x1 = zdekcos * SIN(zeitrad) / COS(sun_el(i_ld,js)) x2 = ( SIN(rlat(i_ld,js)) * zdekcos * COS(zeitrad) - & COS(rlat(i_ld,js)) * zdeksin ) / COS(sun_el(i_ld,js)) IF (x2 < -1.0) x2 = -1.0_ireals IF (x2 > 1.0) x2 = 1.0_ireals phi_s = ACOS(x2) IF (x1 < 0) phi_s = - phi_s sun_azi(i_ld,js) = rtod*(phi_s + pi) sun_el(i_ld,js) = rtod*sun_el(i_ld,js) ENDIF zmaxmu0(js) = MAX (zsmu0_loc, zmaxmu0(js)) ENDDO ENDDO ELSE zmaxmu0(:) = 0.0_ireals ! DO js = jstartpar, jendpar ! DO i = istartpar, iendpar DO js = jstartrad, jendparrad DO i = istartrad, iendparrad !CPS For single processors------------------------------------------------- IF (lperi_y .OR. l2dim) THEN ! Similar thing for lperi_y=.true. or l2dim=.true.: ! Use the geogr. latitude of the model reference point: zsinphi = SIN (degrad*(90.0_ireals-ABS(pollat))) ELSE zsinphi = SIN (rlat(i,js)) END IF ! IF (lperi_x) THEN ! In case of lperi_x=.true., use the solar time of the model reference point ! (as implied by pollon,pollat) to avoid boundary disturbances. ! The problem is that the "true" sun is not periodic, but has to be ! "artificially forced" to be periodic for periodic BCs. IF (pollat >= 0.0_ireals) THEN zeitrad = zeit0 + degrad*(pollon-SIGN(1.0_ireals,pollon)*180.0_ireals) ELSE zeitrad = zeit0 + degrad*pollon END IF ELSE zeitrad = zeit0 + rlon(i,js) END IF zcosphi = SQRT(1.0_ireals - zsinphi**2) !CPS------------------------------------------------ !CPS zsinphi = SIN (rlat(i,js)) !CPS zcosphi = SQRT(1.0_ireals - zsinphi**2) !CPS zeitrad = zeit0 + rlon(i,js) zcosthi = zdeksin * zsinphi + zdekcos * zcosphi * COS(zeitrad) zsmu0(i,js) = MAX (zcosthi, zepemu) zmaxmu0(js) = MAX (zsmu0(i,js), zmaxmu0(js)) ENDDO ENDDO DO js = jstartrad, jendparrad DO i = istartrad, iendparrad ! Sun azimuth and sun elevation (for computation of relative sunshine duration) buz sun_el(i,js) = ASIN(zsmu0(i,js)) x1 = zdekcos * SIN(zeitrad) / COS(sun_el(i,js)) x2 = ( SIN(rlat(i,js)) * zdekcos * COS(zeitrad) - & COS(rlat(i,js)) * zdeksin ) / COS(sun_el(i,js)) IF (x2 < -1.0) x2 = -1.0_ireals IF (x2 > 1.0) x2 = 1.0_ireals phi_s = ACOS(x2) IF (x1 < 0) phi_s = - phi_s sun_azi(i,js) = rtod*(phi_s + pi) sun_el(i,js) = rtod*sun_el(i,js) ENDDO ENDDO ENDIF #ifdef COSMOART IF(l_cosmo_art) THEN DO js = jstartpar, jendpar DO i = istartpar, iendpar mmy(i,js) = zsmu0(i,js) ENDDO ENDDO ENDIF #endif !---------------------------------------------------------------------------- ! Section 1.3: Start of loop over the model domain from south to north !---------------------------------------------------------------------------- IF (izdebug > 10) THEN PRINT *, ' computation loop over model domain' ENDIF DO j = jstartrad, jendparrad ! jstartpar, jendpar IF (zmaxmu0(j) > zepemu) THEN lsolar(j) = .TRUE. ELSE lsolar(j) = .FALSE. ENDIF ENDDO !------------------------------------------------------------------------------ ! Section 2: Calculation of surface albedo taking soil type, ! vegetation and snow/ice conditions into account !------------------------------------------------------------------------------ DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar IF (lemiss) THEN zalth(i,j) = 1._ireals-emis_rad(i,j) ! geographical dependent thermal albedo ELSE zalth(i,j) = ctalb ENDIF ist = 10 ! In the following IF statement, t_snow has been used up to now. ! In NetCDF files, t_snow is undefined (-1E20) where no snow exists. ! This leads to ice-points over the whole sea. t_g could be used instead, ! but this changes the results and has to be tested more intensively. ! As an intermediate solution, we use t_snow, where it is defined, ! otherwise t_g (in grib-files, t_snow is defined as t_s, where no snow ! exists. IF(lmulti_snow) THEN IF (t_snow_mult(i,j,1,nzx) < 0.0_ireals) THEN t_test = t_g (i,j,nzx) ELSE t_test = t_snow_mult(i,j,1,nzx) ENDIF ELSE IF (t_snow(i,j,nzx) < 0.0_ireals) THEN t_test = t_g (i,j,nzx) ELSE t_test = t_snow(i,j,nzx) ENDIF ENDIF IF ( llandmask(i,j) .OR. t_test >= t0_melt - 1.7 ) THEN ist = NINT(soiltyp(i,j)) ! water (ist=9) and sea ice (ist=10) included ENDIF zalso(i,j) = csalb(ist) IF (lsoil .AND. llandmask(i,j)) THEN IF(lmulti_layer) THEN zalso(i,j) = csalb(ist) - rad_csalbw(ist)*w_so(i,j,1,nzx) ELSE zalso(i,j) = csalb(ist) - rad_csalbw(ist)*w_g1(i,j,nzx) ENDIF ENDIF ! lsoil, llandmask ENDDO IF (lseaice) THEN DO i = istartrad, iendparrad ! In case the sea ice model is used AND water point AND ice is present, ! compute ice albedo for water points with an empirical formula taken from GME. ! The ice albedo is the lower the warmer, and therefore wetter, the ice is. ! Use ice temperature at time level nnow (2-time level scheme in sea ice model). IF ((.NOT. llandmask(i,j)) .AND. (h_ice(i,j,nnow) > 0.0_ireals)) & zalso(i,j) = (1.0_ireals-0.3846_ireals*EXP(-0.35_ireals*(t0_melt-t_ice(i,j,nnow)))) & * csalb(10) ENDDO ENDIF IF (llake) THEN DO i = istartrad, iendparrad IF((depth_lk(i,j) > 0.0_ireals) .AND. & (h_ice (i,j,nnow) >= h_Ice_min_flk) ) THEN ! In case the lake model FLake is used AND lake point AND ice is present, ! compute ice albedo for lake points with an empirical formulation ! proposed by Mironov and Ritter (2004) for use in GME ! [ice_albedo=function(ice_surface_temperature)]. ! Use surface temperature at time level "nnow". zalso(i,j) = EXP(-c_albice_MR*(tpl_T_f-t_s(i,j,nnow))/tpl_T_f) zalso(i,j) = albedo_whiteice_ref * (1._ireals-zalso(i,j)) + & albedo_blueice_ref * zalso(i,j) ENDIF ENDDO ENDIF ! Snow cover and vegetation ! ------------------------- IF (lsoil) THEN DO i = istartrad, iendparrad ! istartpar, iendpar zvege= 0.0_ireals zsnow= 0.0_ireals IF (llandmask(i,j)) THEN IF (lmulti_layer) THEN ! consider effects of aging on solar snow albedo zsalb_snow = csalb_snow_min + & freshsnow(i,j)*(csalb_snow_max-csalb_snow_min) IF (lforest) THEN zsnow_alb = zsalb_snow*(1._ireals-for_e(i,j)-for_d(i,j)) & + csalb_snow_fe * for_e(i,j) & + csalb_snow_fd * for_d(i,j) ELSE zsnow_alb = zsalb_snow ENDIF ELSE zsnow_alb = csalb_snow ENDIF ! account for snow cover and plant cover and compute final solar ! snow albedo zvege = plcov(i,j) IF (w_snow(i,j,nzx) > 0.0_ireals) & zsnow = MIN(1.0_ireals, w_snow(i,j,nzx)/cf_snow) zalso(i,j) = zsnow * zsnow_alb + & (1.0_ireals - zsnow) * (zvege * csalb_p + (1.0_ireals - zvege) * zalso(i,j)) ENDIF ! llandmask ENDDO ENDIF ENDDO IF (lradave) THEN DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad zalb_rad_ori (i,j) = zalso (i,j) !T.R. fuer Albedokorrektur ENDDO ENDDO ENDIF #if defined COUP_OAS_COS !------------------------------------------------------------------------------ ! provide Community Land Model surface albedo instead of albedo above ! Only for land points (llandmask) !------------------------------------------------------------------------------ DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad IF (llandmask(i,j)) THEN zpalp (i,j) = alb_rad(i,j,1) zalso (i,j) = alb_rad(i,j,2) if (lradave) zalb_rad_ori(i,j) = alb_rad(i,j,2) ELSE !CPS need this for parallel radiation zpalp (i,j) = (1.0_ireals + & 0.5_ireals * ((1.0_ireals/zsmu0(i,j)) * (1.0_ireals/zalso(i,j) - 1.0_ireals))) & / (1.0_ireals + ((1.0_ireals/zsmu0(i,j)) * (1.0_ireals/zalso(i,j) - 1.0_ireals)))**2 !CPS need this for parallel radiation ENDIF ! llandmask ENDDO ENDDO #endif !------------------------------------------------------------------------------ ! Section 3: Set cloudiness and humidity on input for fesft; ! Store cloud cover on corresponding global arrays !------------------------------------------------------------------------------ !---------------------------------------------------------------------------- ! Section 3.1: Calculate water vapour saturation mixing ratios of ! over water and over ice !---------------------------------------------------------------------------- zt_ice1= t0_melt - 5.0_ireals zt_ice2= t0_melt - 25.0_ireals DO k = 1, ke DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar ! specific humidity (zwv) specific total water content (zqdw), ! specific humidity at saturation ! over water (zsw ) and ice (zse) zph = p0(i,j,k) + pp(i,j,k,nzx) zse (i,j,k) = fgqv ( fgee(t(i,j,k,nzx)), zph) zsw (i,j,k) = fgqv ( fgew(t(i,j,k,nzx)), zph) ENDDO ENDDO ENDDO !---------------------------------------------------------------------------- ! Section 3.2: Calculate stratiform cloud cover (non-convective) !---------------------------------------------------------------------------- IF ( icldm_rad == 0 ) THEN ! a) No interpretation of clouds at all for radiative calculations !----------------------------------------------------------------- DO k = 1, ke DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar zclwc(i,j,k) = 0.0_ireals zciwc(i,j,k) = 0.0_ireals zclc (i,j,k) = 0.0_ireals ENDDO ENDDO ENDDO ELSEIF ( icldm_rad == 1 ) THEN ! b) Only grid-sale water clouds are passed to the radiation routine !------------------------------------------------------------------- DO k = 1, ke DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar zclwc(i,j,k) = qc(i,j,k,nzx) IF (lprog_qi) THEN IF ( qc(i,j,k,nzx)+qi(i,j,k,nnow) > 0.0_ireals ) THEN zclc(i,j,k) = 1.0_ireals ELSE zclc(i,j,k) = 0.0_ireals END IF zciwc(i,j,k) = qi(i,j,k,nnow) ELSE IF ( qc(i,j,k,nzx) > 0.0_ireals ) THEN zclc(i,j,k) = 1.0_ireals ELSE zclc(i,j,k) = 0.0_ireals END IF zciwc(i,j,k) = 0.0_ireals ENDIF clc_sgs(i,j,k) = zclc(i,j,k) ENDDO ENDDO ENDDO ELSEIF (icldm_rad == 2) THEN ! c) Cloud cover and water content from statistical diagnosis !------------------------------------------------------------------- CALL cloud_diag(zclc,zclwc, & !istartpar,iendpar,js,js,1,ke, & istartrad,iendparrad,jstartrad,jendparrad,1,ke, & 1,ie, 1,je,1,ke, & ie,je,ke,ke1, & rdv,o_m_rdv,rvd_m_o,lhocp,t0_melt, & b1,b2w,b3,b4w,b234w,b2i,b4i, & uc1,uc2,ucl, clc_diag, q_crit, & t(:,:,:,nzx),qv(:,:,:,nzx),qc(:,:,:,nzx), & pp(:,:,:,nzx)+p0(:,:,:),rcld,ps(:,:,nzx), & itype_wcld) DO k = 1, ke DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar ! convective (in-)cloud water content ! as a function of specific humidity at saturation IF ( t(i,j,k,nzx) >= t0_melt ) THEN zclwck = zsw(i,j,k)*zclwfk ! ELSE zclwck = zse(i,j,k)*zclwfk ENDIF ! cloud cover of the non convective part of the grid box and cloud ice zcs = zclc(i,j,k) zciwc(i,j,k) = 0.0_ireals IF (lprog_qi) THEN ! if there is a grid scale cloud with cloud ice, ! even there might has been diagnosed subgrid scale water clouds, ! their water is thought to be distributed over the ! whole grid volume: IF ( qi(i,j,k,nnow) > 0.0_ireals ) THEN zcs = 1.0_ireals ENDIF zciwc(i,j,k) = qi(i,j,k,nnow) ENDIF clc_sgs(i,j,k) = zcs ! convective cloud cover zck = clc_con(i,j,k) ! grid scale cloud cover and water contend zclc (i,j,k) = zcs + zck*(1.0-zcs) zclwc(i,j,k) = zclwc(i,j,k)*(1.0-zck) + zclwck*zck ENDDO ENDDO ENDDO ELSEIF ( icldm_rad == 4 .OR. icldm_rad == 3 ) THEN ! a) Standard diagnosis ! --------------------- DO k = 1, ke DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar ! Critical relative humidity as function of thermal stability zph = p0(i,j,k) + pp(i,j,k,nzx) zsigma = zph / ps(i,j,nzx) zdthdz = 0.0 zsex = zsw(i,j,k) zqdw = qv(i,j,k,nzx) + qc(i,j,k,nzx) IF (lprog_qi) THEN zf_ice = 1.0_ireals - MIN( 1.0_ireals, MAX( 0.0_ireals, & (t(i,j,k,nzx)-zt_ice2)/(zt_ice1-zt_ice2) ) ) zqdw = zqdw + qi(i,j,k,nnow) zsex = zsw(i,j,k) * (1.0_ireals - zf_ice) + zse(i,j,k)*zf_ice ENDIF IF(k == ke) THEN zpio = ( 1.0E-5 *( p0(i,j,k)+pp(i,j,k,nzx) ) )**rdocp zpiu = ( 1.0E-5 * ps(i,j,nzx) )**rdocp zpim = 0.5*(zpio+zpiu) zthvo = t (i,j,k ,nzx)/zpio zthvu = t_g(i,j, nzx)/zpiu zdthdz = zthvo - zthvu ELSE IF(zsigma.GT.0.95) THEN zpio = ( 1.0E-5 *( p0(i,j,k )+pp(i,j,k ,nzx) ) )**rdocp zpiu = ( 1.0E-5 *( p0(i,j,k+1)+pp(i,j,k+1,nzx) ) )**rdocp zpim = 0.5*(zpio+zpiu) zthvo = t(i,j,k ,nzx)/zpio zthvu = t(i,j,k+1,nzx)/zpiu zdthdz = zthvo - zthvu + (lh_v*cpdr/zpim)*(qv(i,j,k,nzx)-qv(i,j,k+1,nzx)) ENDIF ! grid scale cloud cover as function of relative humidity zuc = 0.95 - uc1*zsigma*(1.-zsigma)*(1.+uc2*(zsigma-0.5)) zcs = MAX ( 0.0_ireals, & MIN ( 1.0_ireals, (zqdw/zsex-zuc)/(ucl-zuc) ) )**2 ! Corrections and limitations IF ( (zsigma > 0.95_ireals) .AND. (zdthdz < 0.0_ireals) ) THEN zcs = 0.0_ireals ! no cloud cover in unstable stratification ENDIF IF ( qc(i,j,k,nzx) > 0.0_ireals ) THEN ! grid scale clouds IF ( llandmask(i,j) .AND. k < ke ) zcs = 1.0_ireals ENDIF IF (lprog_qi) THEN IF (qi(i,j,k,nnow) > 1.0E-7_ireals) THEN zcs = 1.0_ireals ! grid scale clouds with cloud ice ENDIF ENDIF ! store grid-scale cloud cover on global array clc_sgs(i,j,k) = zcs ! Maximum in-cloud water content: 1.0% of specific humidity at saturation ! except for convective clouds (fixed) ! Standard diagnosis IF (lprog_qi) THEN zclws = 0.005*zsex zclwcs = zclws*(1.0_ireals-zf_ice) zclics = zclws*zf_ice ! Check for grid-scale water or ice-clouds ! Now change in zclwcs only if qc(i,j,k,nzx) > 0.0 IF ( qc(i,j,k,nzx) > 0.0_ireals ) THEN ! grid scale cloud water zclwcs = MAX( zclwcs, 0.5_ireals*qc(i,j,k,nzx) ) ENDIF ! Now change in zclics only if qi(i,j,k,nzx) > 1.0E-7 IF ( qi(i,j,k,nnow) > 1.0E-7_ireals ) THEN ! grid scale cloud ice zclics = MAX( zclics, 0.5_ireals*qi(i,j,k,nnow) ) ENDIF ! Convective cloud water / ice content zclwk = MAX( 2.0_ireals*zclws, 0.0002_ireals ) zclwck = zclwk*(1.0_ireals-zf_ice) zclick = zclwk*zf_ice ! Reduce the cloud cover of ice clouds in the upper troposphere ! for the diagnosis of clch and clct IF ((k <= klv500) .AND. (zclwcs <= 1.0E-10_ireals) .AND. & (zclics > 0.0_ireals) ) THEN clc_sgs(i,j,k) = clc_sgs(i,j,k)*MIN( 1._ireals, MAX(0.2_ireals, & ( LOG(zclics) - LOG(1.E-7_ireals) )/ & ( LOG(5.E-5_ireals) - LOG(1.E-7_ireals) )) ) ENDIF ! set area-average cloud water/ice content zclwc(i,j,k) = zclwck*clc_con(i,j,k) + & zclwcs*clc_sgs(i,j,k)*(1.0_ireals-clc_con(i,j,k)) zciwc(i,j,k) = zclick*clc_con(i,j,k) + & zclics*clc_sgs(i,j,k)*(1.0_ireals-clc_con(i,j,k)) ELSE zclwcs = 0.005*zsw(i,j,k) zclwck = MAX( zclwcs, 0.0002_ireals ) IF ( qc(i,j,k,nzx) > 0.0 ) THEN ! grid scale clouds zclwcs = MAX( zclwcs, 0.5*qc(i,j,k,nzx) ) ENDIF ! set area-average cloud water/ice content zclwc(i,j,k) = zclwck*clc_con(i,j,k) + & zclwcs*clc_sgs(i,j,k)*(1.0_ireals-clc_con(i,j,k)) ! set area average cloud ice content (in-cloud) zciwc(i,j,k) = 0.0_ireals ENDIF ! calculate combined cloud cover zclc (i,j,k) = clc_sgs(i,j,k) + & clc_con(i,j,k)*( 1.0_ireals - clc_sgs(i,j,k) ) ENDDO ENDDO ENDDO ENDIF ! icldm_rad ! Restrictions for radiative calculations ! ------------------------------------ DO k = 1, ke DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar zwv (i,j,k) = MIN( MAX(zeph2o,qv(i,j,k,nzx)), zsw(i,j,k) ) zclc (i,j,k) = MAX( zepclc, MIN(1.0_ireals-zepclc,zclc(i,j,k)) ) zclwc(i,j,k) = MAX( zclwcm, zclwc(i,j,k) ) zciwc(i,j,k) = MAX( zclwcm, zciwc(i,j,k) ) ! set qc_rad, qi_rad qc_rad(i,j,k) = zclwc(i,j,k) qi_rad(i,j,k) = zciwc(i,j,k) ENDDO ENDDO ENDDO !---------------------------------------------------------------------------- ! Section 3.3: Calculate and store total cloud cover for 3 integral layers ! (high, medium, low) !---------------------------------------------------------------------------- DO j = jstartpar, jendpar DO i = istartpar, iendpar zclcm1(i,j) = 1.0 - zclc(i,j,1) ENDDO ENDDO DO j = jstartpar, jendpar !CDIR UNROLL=10 DO k = 2, ke DO i = istartpar, iendpar zclcmax(i,j,k) = 1.0_ireals - MAX(zclc(i,j,k), zclc(i,j,k-1)) zclcmin(i,j,k) = 1.0_ireals / (1.0_ireals - zclc(i,j,k-1)) ENDDO ENDDO ENDDO DO j = jstartpar, jendpar !CDIR UNROLL=10 DO k = 2, klv400 DO i = istartpar, iendpar zclcm1(i,j) = zclcm1(i,j) * zclcmax(i,j,k) * zclcmin(i,j,k) ENDDO ENDDO ENDDO DO j = jstartpar, jendpar DO i = istartpar, iendpar clch (i,j) = 1.0 - zclcm1(i,j) - zepclc ENDDO ENDDO DO j = jstartpar, jendpar !CDIR UNROLL=10 DO k = klv400+1, ke DO i = istartpar, iendpar zclcm1(i,j) = zclcm1(i,j)* zclcmax(i,j,k) * zclcmin(i,j,k) ENDDO ENDDO ENDDO DO j = jstartpar, jendpar DO i = istartpar, iendpar clct (i,j) = 1.0 - zclcm1(i,j) - zepclc zclcm1(i,j) = 1.0 - zclc(i,j,klv400+1) ENDDO ENDDO DO j = jstartpar, jendpar !CDIR UNROLL=10 DO k = klv400+2,klv800 DO i = istartpar, iendpar zclcm1(i,j) = zclcm1(i,j) * zclcmax(i,j,k) * zclcmin(i,j,k) ENDDO ENDDO ENDDO DO j = jstartpar, jendpar DO i = istartpar, iendpar clcm (i,j) = 1.0 - zclcm1(i,j) - zepclc zclcm1(i,j) = 1.0 - zclc(i,j,klv800+1) ENDDO ENDDO DO j = jstartpar, jendpar !CDIR UNROLL=10 DO k = klv800+2,ke DO i= istartpar, iendpar zclcm1(i,j) = zclcm1(i,j) * zclcmax(i,j,k) * zclcmin(i,j,k) ENDDO ENDDO ENDDO DO j = jstartpar, jendpar DO i= istartpar, iendpar clcl (i,j) = 1.0 - zclcm1(i,j) - zepclc ENDDO ENDDO !------------------------------------------------------------------------------ ! Section 4: Set pressure and temperature on input for fesft; !------------------------------------------------------------------------------ ! Surface pressure, half level pressure and pressure thickness. ! At present, pressure is replaced by model reference pressure ! for radiation calculations ! The following local variables have been replaced by the global variables ! DO i = istartrad, iendparrad ! istartpar, iendpar ! zapre(i) = p0hl(i,js,ke+1) ! zphl(i,ke+1) = zapre(i) ! ENDDO ! DO k = 1, ke ! DO i = istartrad, iendparrad ! istartpar, iendpar ! zdpr(i,k) = dp0(i,js,k) ! zphl(i,k) = p0hl(i,js,k) ! ENDDO ! ENDDO ! Temperatures at layer boundaries DO k = 2, ke DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar zpnf = p0hl(i,j,k ) zphf = p0 (i,j,k ) zphfo = p0 (i,j,k-1) zti(i,j,k) = (t(i,j,k-1,nzx)*zphfo*(zphf - zpnf ) & + t(i,j,k ,nzx)*zphf *(zpnf - zphfo) ) & * (1./(zpnf *(zphf - zphfo))) ENDDO ENDDO ENDDO DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar zpnf = p0hl (i,j,2) zphf = p0 (i,j,1) zti(i,j,ke1) = t_g(i,j,nzx) zti(i,j, 1) = t (i,j,1,nzx) - zphf*(t(i,j,1,nzx)-zti(i,j,2))/(zphf - zpnf) ENDDO ENDDO !------------------------------------------------------------------------------ ! Section 5: Calculate amounts of absorbers (CO2, O3, Aerosol) !------------------------------------------------------------------------------ #ifdef COSMOART ! Change climatology for dust IF (l_cosmo_art .AND. lrad_dust) THEN DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar IF (itype_aerosol == 1) THEN aerdes(i,j) = 0.0_ireals ELSEIF (itype_aerosol == 2) THEN aer_du(i,j) = 0.0_ireals ENDIF ENDDO ENDDO ENDIF #endif IF (itype_aerosol == 1) THEN DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar zdpo = p0hl(i,j,1) zo3h (i,j) = SQRT(hmo3(i,j))**3 zqcfo (i,j) = zqco2*zdpo zaeqso (i,j) = zaeops*aersea(i,j)*zvdaes(1) zaeqlo (i,j) = zaeopl*aerlan(i,j)*zvdael(1) zaequo (i,j) = zaeopu*aerurb(i,j)*zvdaeu(1) zaeqdo (i,j) = zaeopd*aerdes(i,j)*zvdaed(1) zaetr_top(i,j) = 1.0_ireals zqofo (i,j) = vio3(i,j)*SQRT(zdpo**3)/(SQRT(zdpo**3) + zo3h(i,j)) ENDDO ENDDO ELSEIF (itype_aerosol == 2) THEN ! new Tegen aerosol climatology: no multiplication with tau(max) as climatology not normalised! DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar zdpo = p0hl(i,j,1) zo3h (i,j) = SQRT(hmo3(i,j))**3 zqcfo (i,j) = zqco2*zdpo zaeqso (i,j) = aer_ss(i,j) *zvdaes(1) zaeqlo (i,j) =( aer_or(i,j)+aer_su(i,j) )*zvdael(1) zaequo (i,j) = aer_bc(i,j) *zvdaeu(1) zaeqdo (i,j) = aer_du(i,j) *zvdaed(1) zaetr_top(i,j) = 1.0_ireals zqofo (i,j) = vio3(i,j)*SQRT(zdpo**3)/(SQRT(zdpo**3) + zo3h(i,j)) ENDDO ENDDO ENDIF IF (itype_aerosol == 1) THEN DO j = jstartrad, jendparrad ! jstartpar, jendpar !CDIR UNROLL=10 DO k = 1, ke DO i = istartrad, iendparrad ! istartpar, iendpar zdpn = p0hl(i,j,k+1) zaeqsn = zaeops*aersea(i,j)*zvdaes(k+1) zaeqln = zaeopl*aerlan(i,j)*zvdael(k+1) zaequn = zaeopu*aerurb(i,j)*zvdaeu(k+1) zaeqdn = zaeopd*aerdes(i,j)*zvdaed(k+1) zaetr_bot = zaetr_top(i,j) * ( MIN (1.0_ireals, zti(i,j,k)/zti(i,j,k+1)) )**ztrpt zqcfn = zqco2 * zdpn zqofn = vio3(i,j)*SQRT(zdpn**3)/(SQRT(zdpn**3) + zo3h(i,j)) zduco2f(i,j,k) = zqcfn-zqcfo(i,j) zduo3f (i,j,k) = zqofn-zqofo(i,j) zaetr = SQRT(zaetr_bot*zaetr_top(i,j)) zaeq1(i,j,k) = (1.-zaetr) * (ztrbga*dp0(i,j,k)+zaeqln-zaeqlo(i,j)+zaeqdn-zaeqdo(i,j)) zaeq2(i,j,k) = (1.-zaetr) * ( zaeqsn-zaeqso(i,j) ) zaeq3(i,j,k) = (1.-zaetr) * ( zaequn-zaequo(i,j) ) zaeq4(i,j,k) = zaetr * zvobga*dp0(i,j,k) zaeq5(i,j,k) = zaetr * zstbga*dp0(i,j,k) zqcfo(i,j) = zqcfn zqofo(i,j) = zqofn zaetr_top(i,j) = zaetr_bot zaeqso(i,j) = zaeqsn zaeqlo(i,j) = zaeqln zaequo(i,j) = zaequn zaeqdo(i,j) = zaeqdn ENDDO ENDDO ENDDO ELSEIF (itype_aerosol == 2) THEN ! new Tegen aerosol climatology: no multiplication with tau(max) as climatology not normalised! DO j = jstartrad, jendparrad ! jstartpar, jendpar !CDIR UNROLL=10 DO k = 1, ke DO i = istartrad, iendparrad ! istartpar, iendpar zdpn = p0hl(i,j,k+1) zaeqsn = aer_ss(i,j) * zvdaes(k+1) zaeqln = (aer_or(i,j)+aer_su(i,j)) * zvdael(k+1) zaequn = aer_bc(i,j) * zvdaeu(k+1) zaeqdn = aer_du(i,j) * zvdaed(k+1) zaetr_bot = zaetr_top(i,j) * ( MIN (1.0_ireals, zti(i,j,k)/zti(i,j,k+1)) )**ztrpt zqcfn = zqco2 * zdpn zqofn = vio3(i,j)*SQRT(zdpn**3)/(SQRT(zdpn**3) + zo3h(i,j)) zduco2f(i,j,k) = zqcfn-zqcfo(i,j) zduo3f (i,j,k) = zqofn-zqofo(i,j) zaetr = SQRT(zaetr_bot*zaetr_top(i,j)) zaeq1(i,j,k) = (1.0_ireals-zaetr)*( ztrbga*dp0(i,j,k) + zaeqln - zaeqlo(i,j) ) zaeq2(i,j,k) = (1.0_ireals-zaetr)*(zaeqsn-zaeqso(i,j)) zaeq3(i,j,k) = (1.0_ireals-zaetr)*(zaeqdn-zaeqdo(i,j)) zaeq4(i,j,k) = (1.0_ireals-zaetr)*(zaequn-zaequo(i,j)) zaeq5(i,j,k) = zaetr * zstbga*dp0(i,j,k) zqcfo(i,j) = zqcfn zqofo(i,j) = zqofn zaetr_top(i,j) = zaetr_bot zaeqso(i,j) = zaeqsn zaeqlo(i,j) = zaeqln zaequo(i,j) = zaequn zaeqdo(i,j) = zaeqdn ENDDO ENDDO ENDDO ENDIF !------------------------------------------------------------------------------ ! Section 6: Correction factors for radiation in complex topography !------------------------------------------------------------------------------ IF (lradtopo) THEN IF (izdebug > 10) THEN PRINT *,' organize_radiation with lradtopo = ', lradtopo ENDIF !US: Careful: this does NOT work with nradcoarse > 1!!! CALL calc_rad_corrections (slo_ang, slo_asp, horizon, zsmu0, & rlat, rlon, zdeksin, zdekcos, zeit0, swdir_cor, & ie, je, nhori, istartpar, iendpar, jstartpar, jendpar, & izdebug) ! and set zskyview (1-dimensional slice) DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar zskyview(i,j) = skyview(i,j) ENDDO ENDDO ELSE ! Set default value for skyview DO j = jstartrad, jendparrad ! jstartpar, jendpar DO i = istartrad, iendparrad ! istartpar, iendpar zskyview(i,j) = 1.0_ireals ENDDO ENDDO ENDIF !------------------------------------------------------------------------------ ! Section 7: Average input values for fesft on nradcoarse**2 gridpoints !------------------------------------------------------------------------------ loop_south_north: DO js = jstartrad, jendparrad ! jstartpar, jendpar IF (lradave) THEN IF (jendpar > jend .AND. js > jendrad) THEN lrady=.FALSE. IF ( js == jendpar ) THEN lrady=.TRUE. nradcoarse_y=jendpar-jendrad ENDIF ELSE j_rn=MOD(-jstartrad+js+1,nradcoarse) lrady=.FALSE. IF (MOD(j_rn,nradcoarse) == 0) THEN IF (js > nradcoarse-1) THEN lrady=.TRUE. nradcoarse_y=nradcoarse ENDIF ENDIF ENDIF IF (lrady) THEN zfactor=1.0_ireals/(REAL(nradcoarse)*REAL(nradcoarse_y)) IF ( iendpar > iend .AND. iendpar > iendrad ) THEN zfactor_b=1.0_ireals/(REAL(nradcoarse_y)*REAL(iendpar-iendrad)) ENDIF ENDIF IF (lrady) THEN ! Atmosphere izz = (iendrad-istartrad+nradcoarse) / nradcoarse !US IF (js < jendpar) THEN IF (nradcoarse_y == 2) THEN DO k=1,ke DO n = 1, izz i = istartrad + (n-1) * nradcoarse zti_rn (n,k) = zti_rn (n,k) + zti (i,js-1,k) + zti (i+1,js-1,k) + zti (i,js,k) + zti (i+1,js,k) zdpr_rn (n,k) = zdpr_rn (n,k) + dp0 (i,js-1,k) + dp0 (i+1,js-1,k) + dp0 (i,js,k) + dp0 (i+1,js,k) zclc_rn (n,k) = zclc_rn (n,k) + zclc (i,js-1,k) + zclc (i+1,js-1,k) + zclc (i,js,k) + zclc (i+1,js,k) zwv_rn (n,k) = zwv_rn (n,k) + zwv (i,js-1,k) + zwv (i+1,js-1,k) + zwv (i,js,k) + zwv (i+1,js,k) zsw_rn (n,k) = zsw_rn (n,k) + zsw (i,js-1,k) + zsw (i+1,js-1,k) + zsw (i,js,k) + zsw (i+1,js,k) zclwc_rn (n,k) = zclwc_rn (n,k) + zclwc (i,js-1,k) + zclwc (i+1,js-1,k) + zclwc (i,js,k) + zclwc (i+1,js,k) zciwc_rn (n,k) = zciwc_rn (n,k) + zciwc (i,js-1,k) + zciwc (i+1,js-1,k) + zciwc (i,js,k) + zciwc (i+1,js,k) zduco2f_rn(n,k) = zduco2f_rn(n,k) + zduco2f(i,js-1,k) + zduco2f(i+1,js-1,k) + zduco2f(i,js,k) + zduco2f(i+1,js,k) zduo3f_rn (n,k) = zduo3f_rn (n,k) + zduo3f (i,js-1,k) + zduo3f (i+1,js-1,k) + zduo3f (i,js,k) + zduo3f (i+1,js,k) zaeq1_rn (n,k) = zaeq1_rn (n,k) + zaeq1 (i,js-1,k) + zaeq1 (i+1,js-1,k) + zaeq1 (i,js,k) + zaeq1 (i+1,js,k) zaeq2_rn (n,k) = zaeq2_rn (n,k) + zaeq2 (i,js-1,k) + zaeq2 (i+1,js-1,k) + zaeq2 (i,js,k) + zaeq2 (i+1,js,k) zaeq3_rn (n,k) = zaeq3_rn (n,k) + zaeq3 (i,js-1,k) + zaeq3 (i+1,js-1,k) + zaeq3 (i,js,k) + zaeq3 (i+1,js,k) zaeq4_rn (n,k) = zaeq4_rn (n,k) + zaeq4 (i,js-1,k) + zaeq4 (i+1,js-1,k) + zaeq4 (i,js,k) + zaeq4 (i+1,js,k) zaeq5_rn (n,k) = zaeq5_rn (n,k) + zaeq5 (i,js-1,k) + zaeq5 (i+1,js-1,k) + zaeq5 (i,js,k) + zaeq5 (i+1,js,k) ENDDO ! n ENDDO ! k ELSE ! nradcoarse_y == 1 DO k=1,ke DO n = 1, izz i = istartrad + (n-1) * nradcoarse zti_rn (n,k) = zti_rn (n,k) + zti (i,js,k) + zti (i+1,js,k) zdpr_rn (n,k) = zdpr_rn (n,k) + dp0 (i,js,k) + dp0 (i+1,js,k) zclc_rn (n,k) = zclc_rn (n,k) + zclc (i,js,k) + zclc (i+1,js,k) zwv_rn (n,k) = zwv_rn (n,k) + zwv (i,js,k) + zwv (i+1,js,k) zsw_rn (n,k) = zsw_rn (n,k) + zsw (i,js,k) + zsw (i+1,js,k) zclwc_rn (n,k) = zclwc_rn (n,k) + zclwc (i,js,k) + zclwc (i+1,js,k) zciwc_rn (n,k) = zciwc_rn (n,k) + zciwc (i,js,k) + zciwc (i+1,js,k) zduco2f_rn(n,k) = zduco2f_rn(n,k) + zduco2f(i,js,k) + zduco2f(i+1,js,k) zduo3f_rn (n,k) = zduo3f_rn (n,k) + zduo3f (i,js,k) + zduo3f (i+1,js,k) zaeq1_rn (n,k) = zaeq1_rn (n,k) + zaeq1 (i,js,k) + zaeq1 (i+1,js,k) zaeq2_rn (n,k) = zaeq2_rn (n,k) + zaeq2 (i,js,k) + zaeq2 (i+1,js,k) zaeq3_rn (n,k) = zaeq3_rn (n,k) + zaeq3 (i,js,k) + zaeq3 (i+1,js,k) zaeq4_rn (n,k) = zaeq4_rn (n,k) + zaeq4 (i,js,k) + zaeq4 (i+1,js,k) zaeq5_rn (n,k) = zaeq5_rn (n,k) + zaeq5 (i,js,k) + zaeq5 (i+1,js,k) ENDDO ! n ENDDO ! k ENDIF ! nradcoarse_y DO k = 1, ke DO n = 1, izz zti_rn (n,k) = zti_rn (n,k) * zfactor zdpr_rn (n,k) = zdpr_rn (n,k) * zfactor zclc_rn (n,k) = zclc_rn (n,k) * zfactor zwv_rn (n,k) = zwv_rn (n,k) * zfactor zsw_rn (n,k) = zsw_rn (n,k) * zfactor zclwc_rn (n,k) = zclwc_rn (n,k) * zfactor zciwc_rn (n,k) = zciwc_rn (n,k) * zfactor zduco2f_rn(n,k) = zduco2f_rn(n,k) * zfactor zduo3f_rn (n,k) = zduo3f_rn (n,k) * zfactor zaeq1_rn (n,k) = zaeq1_rn (n,k) * zfactor zaeq2_rn (n,k) = zaeq2_rn (n,k) * zfactor zaeq3_rn (n,k) = zaeq3_rn (n,k) * zfactor zaeq4_rn (n,k) = zaeq4_rn (n,k) * zfactor zaeq5_rn (n,k) = zaeq5_rn (n,k) * zfactor ENDDO ! n ENDDO ! k ! Treatment at the eastern boundary IF (iendpar > iend) THEN i = iendpar izz = izz+1 IF (nradcoarse_y == 2) THEN DO k = 1, ke zti_rn (izz,k) = zti_rn (izz,k) + zti (i,js-1,k) + zti (i,js,k) zdpr_rn (izz,k) = zdpr_rn (izz,k) + dp0 (i,js-1,k) + dp0 (i,js,k) zclc_rn (izz,k) = zclc_rn (izz,k) + zclc (i,js-1,k) + zclc (i,js,k) zwv_rn (izz,k) = zwv_rn (izz,k) + zwv (i,js-1,k) + zwv (i,js,k) zsw_rn (izz,k) = zsw_rn (izz,k) + zsw (i,js-1,k) + zsw (i,js,k) zclwc_rn (izz,k) = zclwc_rn (izz,k) + zclwc (i,js-1,k) + zclwc (i,js,k) zciwc_rn (izz,k) = zciwc_rn (izz,k) + zciwc (i,js-1,k) + zciwc (i,js,k) zduco2f_rn(izz,k) = zduco2f_rn(izz,k) + zduco2f(i,js-1,k) + zduco2f(i,js,k) zduo3f_rn (izz,k) = zduo3f_rn (izz,k) + zduo3f (i,js-1,k) + zduo3f (i,js,k) zaeq1_rn (izz,k) = zaeq1_rn (izz,k) + zaeq1 (i,js-1,k) + zaeq1 (i,js,k) zaeq2_rn (izz,k) = zaeq2_rn (izz,k) + zaeq2 (i,js-1,k) + zaeq2 (i,js,k) zaeq3_rn (izz,k) = zaeq3_rn (izz,k) + zaeq3 (i,js-1,k) + zaeq3 (i,js,k) zaeq4_rn (izz,k) = zaeq4_rn (izz,k) + zaeq4 (i,js-1,k) + zaeq4 (i,js,k) zaeq5_rn (izz,k) = zaeq5_rn (izz,k) + zaeq5 (i,js-1,k) + zaeq5 (i,js,k) ENDDO ! k ELSE ! nradcoarse_y == 1 DO k = 1, ke zti_rn (izz,k) = zti_rn (izz,k) + zti (i,js,k) zdpr_rn (izz,k) = zdpr_rn (izz,k) + dp0 (i,js,k) zclc_rn (izz,k) = zclc_rn (izz,k) + zclc (i,js,k) zwv_rn (izz,k) = zwv_rn (izz,k) + zwv (i,js,k) zsw_rn (izz,k) = zsw_rn (izz,k) + zsw (i,js,k) zclwc_rn (izz,k) = zclwc_rn (izz,k) + zclwc (i,js,k) zciwc_rn (izz,k) = zciwc_rn (izz,k) + zciwc (i,js,k) zduco2f_rn(izz,k) = zduco2f_rn(izz,k) + zduco2f(i,js,k) zduo3f_rn (izz,k) = zduo3f_rn (izz,k) + zduo3f (i,js,k) zaeq1_rn (izz,k) = zaeq1_rn (izz,k) + zaeq1 (i,js,k) zaeq2_rn (izz,k) = zaeq2_rn (izz,k) + zaeq2 (i,js,k) zaeq3_rn (izz,k) = zaeq3_rn (izz,k) + zaeq3 (i,js,k) zaeq4_rn (izz,k) = zaeq4_rn (izz,k) + zaeq4 (i,js,k) zaeq5_rn (izz,k) = zaeq5_rn (izz,k) + zaeq5 (i,js,k) ENDDO ! k ENDIF DO k = 1, ke zti_rn (izz,k) = zti_rn (izz,k) * zfactor_b zdpr_rn (izz,k) = zdpr_rn (izz,k) * zfactor_b zclc_rn (izz,k) = zclc_rn (izz,k) * zfactor_b zwv_rn (izz,k) = zwv_rn (izz,k) * zfactor_b zsw_rn (izz,k) = zsw_rn (izz,k) * zfactor_b zclwc_rn (izz,k) = zclwc_rn (izz,k) * zfactor_b zciwc_rn (izz,k) = zciwc_rn (izz,k) * zfactor_b zduco2f_rn(izz,k) = zduco2f_rn(izz,k) * zfactor_b zduo3f_rn (izz,k) = zduo3f_rn (izz,k) * zfactor_b zaeq1_rn (izz,k) = zaeq1_rn (izz,k) * zfactor_b zaeq2_rn (izz,k) = zaeq2_rn (izz,k) * zfactor_b zaeq3_rn (izz,k) = zaeq3_rn (izz,k) * zfactor_b zaeq4_rn (izz,k) = zaeq4_rn (izz,k) * zfactor_b zaeq5_rn (izz,k) = zaeq5_rn (izz,k) * zfactor_b ENDDO ! k ENDIF ! Rand_x ! Surface izz = (iendrad-istartrad+nradcoarse) / nradcoarse IF (nradcoarse_y == 2) THEN DO n = 1, izz i = istartrad + (n-1) * nradcoarse zti_rn (n,ke+1) = zti_rn (n,ke+1) + zti (i,js-1,ke+1) + zti (i+1,js-1,ke+1) + zti (i,js,ke+1) + zti (i+1,js,ke+1) zalso_rn(n) = zalso_rn(n) + zalso(i,js-1) + zalso(i+1,js-1) + zalso(i,js) + zalso(i+1,js) #ifdef COUP_OAS_COS zpalp_rn(n) = zpalp_rn(n) + zpalp(i,js-1) + zpalp(i+1,js-1) + zpalp(i,js) + zpalp(i+1,js) #endif zalth_rn(n) = zalth_rn(n) + zalth(i,js) + zalth(i+1,js-1) + zalth(i,js) + zalth(i+1,js) zapre_rn(n) = zapre_rn(n) + p0hl (i,js,ke+1) + p0hl (i+1,js-1,ke+1) + p0hl (i,js,ke+1) + p0hl (i+1,js,ke+1) zsmu0_rn(n) = zsmu0_rn(n) + zsmu0(i,js) + zsmu0(i+1,js-1) + zsmu0(i,js) + zsmu0(i+1,js) ENDDO ! n ELSE ! nradcoarse_y == 1 DO n = 1, izz i = istartrad + (n-1) * nradcoarse zti_rn (n,ke+1) = zti_rn (n,ke+1) + zti (i,js,ke+1) + zti (i+1,js,ke+1) zalso_rn(n) = zalso_rn(n) + zalso(i,js) + zalso(i+1,js) #ifdef COUP_OAS_COS zpalp_rn(n) = zpalp_rn(n) + zpalp(i,js) + zpalp(i+1,js) #endif zalth_rn(n) = zalth_rn(n) + zalth(i,js) + zalth(i+1,js) zapre_rn(n) = zapre_rn(n) + p0hl (i,js,ke+1) + p0hl (i+1,js,ke+1) zsmu0_rn(n) = zsmu0_rn(n) + zsmu0(i,js) + zsmu0(i+1,js) ENDDO ! n ENDIF ! js < jendpar DO n = 1, izz zti_rn (n,ke+1) = zti_rn (n,ke+1) * zfactor zalso_rn(n) = zalso_rn(n) * zfactor #ifdef COUP_OAS_COS zpalp_rn(n) = zpalp_rn(n) * zfactor #endif zalth_rn(n) = zalth_rn(n) * zfactor zapre_rn(n) = zapre_rn(n) * zfactor zsmu0_rn(n) = zsmu0_rn(n) * zfactor ENDDO ! n ! Treatment at the eastern boundary IF (iendpar > iend) THEN izz = izz+1 i = iendpar IF (nradcoarse_y == 2) THEN zti_rn (izz,ke+1) = zti_rn (izz,ke+1) + zti (i,js-1,ke+1) + zti (i,js,ke+1) zalso_rn(izz) = zalso_rn(izz) + zalso(i,js-1) + zalso(i,js) #ifdef COUP_OAS_COS zpalp_rn(izz) = zpalp_rn(izz) + zpalp(i,js-1) + zpalp(i,js) #endif zalth_rn(izz) = zalth_rn(izz) + zalth(i,js-1) + zalth(i,js) zapre_rn(izz) = zapre_rn(izz) + p0hl (i,js-1,ke+1) + p0hl (i,js,ke+1) zsmu0_rn(izz) = zsmu0_rn(izz) + zsmu0(i,js-1) + zsmu0(i,js) ELSE ! nradcoarse_y == 1 zti_rn (izz,ke+1) = zti_rn (izz,ke+1) + zti (i,js,ke+1) zalso_rn(izz) = zalso_rn(izz) + zalso(i,js) #ifdef COUP_OAS_COS zpalp_rn(izz) = zpalp_rn(izz) + zpalp(i,js) #endif zalth_rn(izz) = zalth_rn(izz) + zalth(i,js) zapre_rn(izz) = zapre_rn(izz) + p0hl (i,js,ke+1) zsmu0_rn(izz) = zsmu0_rn(izz) + zsmu0(i,js) ENDIF ! zti_rn (izz,ke+1) = zti_rn (izz,ke+1) * zfactor_b zalso_rn(izz) = zalso_rn(izz) * zfactor_b #ifdef COUP_OAS_COS zpalp_rn(izz) = zpalp_rn(izz) * zfactor_b #endif zalth_rn(izz) = zalth_rn(izz) * zfactor_b zapre_rn(izz) = zapre_rn(izz) * zfactor_b zsmu0_rn(izz) = zsmu0_rn(izz) * zfactor_b ENDIF !Rand_x ! Setting of first-dimension array boundary for routine fesft ki1ec=izz ! set default value for sykview; lradtopo must not be chosen with nradcoarse > 1 zskyv_rn(:) = 1.0_ireals #ifdef COUP_OAS_COS !MU: change to 4.11 (zskyv_rn instead of skyview) CALL fesft & (zti_rn, zdpr_rn, zclc_rn, zwv_rn, zsw_rn, & zclwc_rn, zciwc_rn, zduco2f_rn, zduo3f_rn, & zaeq1_rn, zaeq2_rn, zaeq3_rn, zaeq4_rn, zaeq5_rn, & zapre_rn, zsmu0_rn, zalso_rn, zalth_rn, zskyv_rn, & swdir_cor, zstb, zsct, zpalp_rn, & ki1sd, ki1ed, ki2sd, ki2ed, ki3sd, ki3ed, & ki1sc, ki1ec, ki2sc, ki2ec, ki3sc, ki3ec, & lsolar(js),lcrf, .FALSE., izdebug, js, & zflt_rn, zfls_rn, zflt_s_rn, zfls_s_rn, zflsdir_rn, & zfltd_rn, zfltu_rn, zflsd_rn, zflsu_rn, zflsp_rn, & zflpar_rn, zflsu_par_rn, zflsd_par_rn, zflsp_par_rn) #else CALL fesft & (zti_rn, zdpr_rn, zclc_rn, zwv_rn, zsw_rn, & zclwc_rn, zciwc_rn, zduco2f_rn, zduo3f_rn, & zaeq1_rn, zaeq2_rn, zaeq3_rn, zaeq4_rn, zaeq5_rn, & zapre_rn, zsmu0_rn, zalso_rn, zalth_rn, zskyv_rn, & swdir_cor, zstb, zsct, & ki1sd, ki1ed, ki2sd, ki2ed, ki3sd, ki3ed, & ki1sc, ki1ec, ki2sc, ki2ec, ki3sc, ki3ec, & lsolar(js),lcrf, .FALSE., izdebug, js, & zflt_rn, zfls_rn, zflt_s_rn, zfls_s_rn, zflsdir_rn, & zfltd_rn, zfltu_rn, zflsd_rn, zflsu_rn, zflsp_rn, & zflpar_rn, zflsu_par_rn, zflsd_par_rn, zflsp_par_rn) #endif ! Store back results from fesft DO k=1,ke DO ii=0,nradcoarse-1 izz=0 DO i=istartrad,iendrad,nradcoarse izz=izz+1 zflt(i+ii,k) = zflt_rn(izz,k) zfls(i+ii,k) = zfls_rn(izz,k) ! zdpr(i+ii,k) = zdpr_rn(izz,k) ENDDO !i ENDDO !ii ENDDO !k IF (iendpar > iend) THEN !CDIR NOVECTOR DO i=iendrad+1,iendpar,nradcoarse izz=izz+1 !CDIR NOVECTOR DO ii=0,(iendpar-iendrad)-1 DO k=1,ke zflt(i+ii,k) = zflt_rn(izz,k) zfls(i+ii,k) = zfls_rn(izz,k) ! zdpr(i+ii,k) = zdpr_rn(izz,k) ENDDO !k ENDDO !i ENDDO !ii ENDIF ! for the Climate-LM Version: solar direct radiation DO k=1,ke1 DO ii=0,nradcoarse-1 izz=0 DO i=istartrad,iendrad,nradcoarse izz=izz+1 zflsdir(i+ii,k) = zflsdir_rn(izz,k) ENDDO !i ENDDO !ii ENDDO !k IF (iendpar > iend) THEN !CDIR NOVECTOR DO i=iendrad+1,iendpar,nradcoarse izz=izz+1 !CDIR NOVECTOR DO ii=0,(iendpar-iendrad)-1 DO k=1,ke1 zflsdir(i+ii,k) = zflsdir_rn(izz,k) ENDDO !k ENDDO !ii ENDDO !i ENDIF DO ii=0,nradcoarse-1 izz=0 DO i=istartrad,iendrad,nradcoarse izz=izz+1 zflt (i+ii,ke1) = zflt_rn (izz,ke1) zfls (i+ii,ke1) = zfls_rn (izz,ke1) zflt_s (i+ii) = zflt_s_rn (izz) zfls_s (i+ii) = zfls_s_rn (izz) zalso (i+ii,js) = zalso_rn (izz) #ifdef COUP_OAS_COS zpalp (i+ii,js) = zpalp_rn (izz) #endif tg_rn (i+ii) = zti_rn (izz,ke1) zfltu (i+ii) = zfltu_rn (izz) zfltd (i+ii) = zfltd_rn (izz) zflsu (i+ii) = zflsu_rn (izz) zflsd (i+ii) = zflsd_rn (izz) zflsp (i+ii) = zflsp_rn (izz) zflpar (i+ii) = zflpar_rn (izz) zflsu_par(i+ii) = zflsu_par_rn(izz) zflsd_par(i+ii) = zflsd_par_rn(izz) zflsp_par(i+ii) = zflsp_par_rn(izz) ENDDO !i ENDDO IF (iendpar > iend) THEN DO i=iendrad+1,iendpar,nradcoarse izz=izz+1 DO ii=0,(iendpar-iendrad)-1 zflt (i+ii,ke1) = zflt_rn (izz,ke1) zfls (i+ii,ke1) = zfls_rn (izz,ke1) zflt_s (i+ii) = zflt_s_rn (izz) zfls_s (i+ii) = zfls_s_rn (izz) zalso (i+ii,js) = zalso_rn (izz) #ifdef COUP_OAS_COS zpalp (i+ii,js) = zpalp_rn (izz) #endif tg_rn (i+ii) = zti_rn (izz,ke1) zfltu (i+ii) = zfltu_rn (izz) zfltd (i+ii) = zfltd_rn (izz) zflsu (i+ii) = zflsu_rn (izz) zflsd (i+ii) = zflsd_rn (izz) zflsp (i+ii) = zflsp_rn (izz) zflpar (i+ii) = zflpar_rn (izz) zflsu_par(i+ii) = zflsu_par_rn(izz) zflsd_par(i+ii) = zflsd_par_rn(izz) zflsp_par(i+ii) = zflsp_par_rn(izz) ENDDO !ii ENDDO !i ENDIF !------------------------------------------------------------------------ ! ! Section 6: Heating rates and radiation budget at surface ! !------------------------------------------------------------------------ DO k = 1, ke DO jz1 = js-nradcoarse_y+1, js DO i = istartrad, iendparrad ! zfac = g/(cp_d*dp0 (i,js,k)) zfac = g/(cp_d*dp0 (i,jz1,k)) !US zfac = g/(cp_d*zdpr(i,k)) sohr(i,jz1,k) = 0.0_ireals ! IF (zsmu0(i,js) > zepemu) THEN IF (zsmu0(i,jz1) > zepemu) THEN sohr(i,jz1,k) = zfac * (zfls(i,k)-zfls(i,k+1)) ENDIF thhr(i,jz1,k) = zfac * (zflt(i,k)-zflt(i,k+1)) ENDDO ENDDO ENDDO ! for the Climate-LM Version: solar direct radiation DO jz1 = js-nradcoarse_y+1, js DO i = istartrad, iendparrad sodwddm(i,jz1) = 0.0_ireals IF (zsmu0(i,jz1) > zepemu) THEN sodwddm(i,jz1) = zflsdir(i,ke1) / zsmu0(i,jz1) ENDIF ENDDO DO i = istartrad, iendparrad sobs(i,jz1) = 0.0_ireals pabs(i,jz1) = 0.0_ireals sobt(i,jz1) = 0.0_ireals swdir_s (i,jz1) = zflsp(i) swdifd_s(i,jz1) = zflsd(i) swdifu_s(i,jz1) = zflsu(i) lwd_s (i,jz1) = zfltd(i) lwu_s (i,jz1) = zfltu(i) zzflsp_par (i,jz1) = zflsp_par(i) zzflsd_par (i,jz1) = zflsd_par(i) zzflsu_par (i,jz1) = zflsu_par(i) ! IF (zsmu0(i,js) > zepemu) THEN IF (zsmu0(i,jz1) > zepemu) THEN sobs(i,jz1) = zfls_s(i) pabs(i,jz1) = zflpar(i) sobt(i,jz1) = zfls (i, 1) ENDIF thbs (i,jz1) = zflt_s(i) tg_ra (i,jz1) = tg_rn (i) thbt (i,jz1) = zflt (i, 1) #ifdef COUP_OAS_COS alb_rad (i,jz1,1) = zpalp (i,js) alb_rad (i,jz1,2) = zalso (i,js) #else alb_rad (i,jz1) = zalso (i,js) #endif ENDDO ENDDO zti_rn(:,:) = 0.0_ireals zdpr_rn(:,:) = 0.0_ireals zclc_rn(:,:) = 0.0_ireals zwv_rn(:,:) = 0.0_ireals zsw_rn(:,:) = 0.0_ireals zclwc_rn(:,:) = 0.0_ireals zciwc_rn(:,:) = 0.0_ireals zduco2f_rn(:,:) = 0.0_ireals zduo3f_rn(:,:) = 0.0_ireals zaeq1_rn(:,:) = 0.0_ireals zaeq2_rn(:,:) = 0.0_ireals zaeq3_rn(:,:) = 0.0_ireals zaeq4_rn(:,:) = 0.0_ireals zaeq5_rn(:,:) = 0.0_ireals zalso_rn(:) = 0.0_ireals #ifdef COUP_OAS_COS zpalp_rn(:) = 0.0_ireals #endif zalth_rn(:) = 0.0_ireals zapre_rn(:) = 0.0_ireals zsmu0_rn(:) = 0.0_ireals zfls_s_rn(:) = 0.0_ireals zflt_s_rn(:) = 0.0_ireals zflsp_rn (:) = 0.0_ireals zflsd_rn (:) = 0.0_ireals zflsu_rn (:) = 0.0_ireals zfltd_rn (:) = 0.0_ireals zfltu_rn (:) = 0.0_ireals ENDIF !lrady ELSE ! .NOT. lradave: !------------------------------------------------------------------------------ ! Section 8: Calculation of radiation fluxes in routine fesft !------------------------------------------------------------------------------ #ifdef COUP_OAS_COS !MU: change to 4.11 (zskyview(:,js) instead of skyview) CALL fesft & (zti (:,js,:), dp0 (:,js,:), zclc (:,js,:), zwv (:,js,:), zsw (:,js,:), & zclwc(:,js,:), zciwc(:,js,:), zduco2f(:,js,:), zduo3f(:,js,:), & zaeq1(:,js,:), zaeq2(:,js,:), zaeq3 (:,js,:), zaeq4 (:,js,:), zaeq5(:,js,:), & zapre(:,js), zsmu0(:,js), zalso (:,js), zalth (:,js), zskyview(:,js), & swdir_cor(:,js), zstb, zsct, zpalp (:,js), & ki1sd, ki1ed, ki2sd, ki2ed, ki3sd, ki3ed, & ki1sc, ki1ec, ki2sc, ki2ec, ki3sc, ki3ec, & lsolar(js), lcrf, lradtopo, izdebug, js, & zflt, zfls, zflt_s, zfls_s, zflsdir, & zfltd, zfltu, zflsd, zflsu, zflsp, & zflpar, zflsu_par, zflsd_par, zflsp_par) #else CALL fesft & (zti (:,js,:), dp0 (:,js,:), zclc (:,js,:), zwv (:,js,:), zsw (:,js,:), & zclwc(:,js,:), zciwc(:,js,:), zduco2f(:,js,:), zduo3f(:,js,:), & zaeq1(:,js,:), zaeq2(:,js,:), zaeq3 (:,js,:), zaeq4 (:,js,:), zaeq5(:,js,:), & zapre(:,js), zsmu0(:,js), zalso (:,js), zalth (:,js), zskyview(:,js), & swdir_cor(:,js), zstb, zsct, & ki1sd, ki1ed, ki2sd, ki2ed, ki3sd, ki3ed, & ki1sc, ki1ec, ki2sc, ki2ec, ki3sc, ki3ec, & lsolar(js), lcrf, lradtopo, izdebug, js, & zflt, zfls, zflt_s, zfls_s, zflsdir, & zfltd, zfltu, zflsd, zflsu, zflsp, & zflpar, zflsu_par, zflsd_par, zflsp_par) #endif !------------------------------------------------------------------------------ ! Section 9: Heating rates and radiation budget at surface !------------------------------------------------------------------------------ DO k = 1, ke DO i = istartpar, iendpar zfac = g/(cp_d*dp0 (i,js,k)) sohr(i,js,k) = 0.0 IF (zsmu0(i,js) > zepemu) THEN sohr(i,js,k) = zfac * (zfls(i,k)-zfls(i,k+1)) ENDIF thhr(i,js,k) = zfac * (zflt(i,k)-zflt(i,k+1)) ENDDO ENDDO DO i = istartpar, iendpar sobs (i,js) = 0.0 pabs (i,js) = 0.0 sobt (i,js) = 0.0 swdir_s (i,js) = 0.0 swdifd_s(i,js) = 0.0 swdifu_s(i,js) = 0.0 lwd_s (i,js) = 0.0 lwu_s (i,js) = 0.0 IF (zsmu0(i,js) > zepemu) THEN sobs (i,js) = zfls_s(i) pabs (i,js) = zflpar(i) sobt (i,js) = zfls (i, 1) END IF thbs (i,js) = zflt_s(i) thbt (i,js) = zflt (i, 1) #ifdef COUP_OAS_COS alb_rad (i,js,1) = zpalp (i,js) alb_rad (i,js,2) = zalso (i,js) #else alb_rad (i,js) = zalso (i,js) #endif swdir_s (i,js) = zflsp(i) swdifd_s(i,js) = zflsd(i) swdifu_s(i,js) = zflsu(i) lwd_s (i,js) = zfltd(i) lwu_s (i,js) = zfltu(i) zzflsp_par(i,js) = zflsp_par(i) zzflsd_par(i,js) = zflsd_par(i) zzflsu_par(i,js) = zflsu_par(i) ENDDO ! for the Climate-LM Version: solar direct parallel radiation at the surface DO i = istartpar, iendpar sodwddm(i,js) = 0.0_ireals IF (zsmu0(i,js) > zepemu) THEN sodwddm(i,js) = zflsdir(i,ke1) / zsmu0(i,js) ENDIF ENDDO ENDIF !lradave !------------------------------------------------------------------------------- ! end of loop over the model domain from south to north !------------------------------------------------------------------------------- ENDDO loop_south_north IF (lradave) THEN DEALLOCATE ( zti_rn , STAT=izstatd ) DEALLOCATE ( zdpr_rn , STAT=izstatd ) DEALLOCATE ( zclc_rn , STAT=izstatd ) DEALLOCATE ( zwv_rn , STAT=izstatd ) DEALLOCATE ( zsw_rn , STAT=izstatd ) DEALLOCATE ( zclwc_rn , STAT=izstatd ) DEALLOCATE ( zciwc_rn , STAT=izstatd ) DEALLOCATE ( zduco2f_rn , STAT=izstatd ) DEALLOCATE ( zduo3f_rn , STAT=izstatd ) DEALLOCATE ( zaeq1_rn , STAT=izstatd ) DEALLOCATE ( zaeq2_rn , STAT=izstatd ) DEALLOCATE ( zaeq3_rn , STAT=izstatd ) DEALLOCATE ( zaeq4_rn , STAT=izstatd ) DEALLOCATE ( zaeq5_rn , STAT=izstatd ) DEALLOCATE ( zapre_rn , STAT=izstatd ) DEALLOCATE ( zsmu0_rn , STAT=izstatd ) DEALLOCATE ( zalth_rn , STAT=izstatd ) DEALLOCATE ( zalso_rn , STAT=izstatd ) #ifdef COUP_OAS_COS DEALLOCATE ( zpalp_rn , STAT=izstatd ) #endif DEALLOCATE ( zflt_rn , STAT=izstatd ) DEALLOCATE ( zfls_rn , STAT=izstatd ) DEALLOCATE ( zflpar_rn , STAT=izstatd ) DEALLOCATE ( zflsu_par_rn , STAT=izstatd ) DEALLOCATE ( zflsd_par_rn , STAT=izstatd ) DEALLOCATE ( zflsp_par_rn , STAT=izstatd ) DEALLOCATE ( zflsdir_rn , STAT=izstatd ) DEALLOCATE ( tg_rn , STAT=izstatd ) DEALLOCATE ( zfls_s_rn , STAT=izstatd ) DEALLOCATE ( zflt_s_rn , STAT=izstatd ) DEALLOCATE ( zflsp_rn , STAT=izstatd ) DEALLOCATE ( zflsd_rn , STAT=izstatd ) DEALLOCATE ( zflsu_rn , STAT=izstatd ) DEALLOCATE ( zfltd_rn , STAT=izstatd ) DEALLOCATE ( zfltu_rn , STAT=izstatd ) DO js=jstartpar,jendpar DO i = istartpar,iendpar thbs (i,js) = thbs(i,js) + zstb*(1._ireals - ctalb)*(tg_ra(i,js)**4) ! this was eliminated in testsuite 3.4 ! but keep it for the moment to reproduce results with Version 3.22 #ifdef COUP_OAS_COS zalbfak = 1._ireals/(1._ireals-alb_rad(i,js,2)) #else zalbfak = 1._ireals/(1._ireals-alb_rad(i,js)) #endif sobs (i,js) = sobs(i,js) * zalbfak pabs (i,js) = pabs(i,js) * zalbfak ENDDO ENDDO DEALLOCATE ( tg_ra, STAT=izstatd ) IF (lradf_avg) THEN !!$ IF (num_compute > 1) THEN kzdims(1:24)=(/ke,ke,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0/) #ifdef COUP_OAS_COS !MU: some changes compared to 4.11 CALL exchg_boundaries & (9, sendbuf, isendbuflen, imp_reals, icomm_cart, num_compute, ie, je, & kzdims, jstartpar, jendpar, 1, nboundlines, my_cart_neigh, & lperi_x, lperi_y, l2dim, & 20000+ntstep, .FALSE., ncomm_type, izerror, yzerrmsg, & thhr(:,:,:),sohr(:,:,:),thbs(:,:),thbt(:,:), & sobs(:,:),sobt(:,:),pabs(:,:),alb_rad(:,:,:), sodwddm(:,:), & swdir_s(:,:), swdifd_s(:,:), swdifu_s(:,:), lwd_s(:,:), & lwu_s(:,:), zzflsp_par(:,:),zzflsd_par(:,:),zzflsu_par(:,:) ) #else CALL exchg_boundaries & (9, sendbuf, isendbuflen, imp_reals, icomm_cart, num_compute, ie, je, & kzdims, jstartpar, jendpar, 1, nboundlines, my_cart_neigh, & lperi_x, lperi_y, l2dim, & 20000+ntstep, .FALSE., ncomm_type, izerror, yzerrmsg, & thhr(:,:,:),sohr(:,:,:),thbs(:,:),thbt(:,:), & sobs(:,:),sobt(:,:),pabs(:,:),alb_rad(:,:), sodwddm(:,:), & swdir_s(:,:), swdifd_s(:,:), swdifu_s(:,:), lwd_s(:,:), & lwu_s(:,:), zzflsp_par(:,:),zzflsd_par(:,:),zzflsu_par(:,:) ) #endif !!$ ENDIF ALLOCATE ( zsohr (ie,je,ke), STAT=izstata ) ALLOCATE ( zthhr (ie,je,ke), STAT=izstata ) ALLOCATE ( zsobs (ie,je) , STAT=izstata ) ALLOCATE ( zsobt (ie,je) , STAT=izstata ) ALLOCATE ( zthbs (ie,je) , STAT=izstata ) ALLOCATE ( zthbt (ie,je) , STAT=izstata ) ALLOCATE ( zpabs (ie,je) , STAT=izstata ) ALLOCATE ( zsodwddm (ie,je) , STAT=izstata ) ALLOCATE ( z_zzflsp (ie,je) , STAT=izstata ) ALLOCATE ( z_zzflsd (ie,je) , STAT=izstata ) ALLOCATE ( z_zzflsu (ie,je) , STAT=izstata ) ALLOCATE ( z_zzflsp_par(ie,je) , STAT=izstata ) ALLOCATE ( z_zzflsd_par(ie,je) , STAT=izstata ) ALLOCATE ( z_zzflsu_par(ie,je) , STAT=izstata ) ALLOCATE ( z_zzfltd (ie,je) , STAT=izstata ) ALLOCATE ( z_zzfltu (ie,je) , STAT=izstata ) zthhr (:,:,:) = thhr (:,:,:) zsohr (:,:,:) = sohr (:,:,:) zthbs (:,:) = thbs (:,:) zthbt (:,:) = thbt (:,:) zsobs (:,:) = sobs (:,:) zsobt (:,:) = sobt (:,:) zpabs (:,:) = pabs (:,:) zsodwddm (:,:) = sodwddm (:,:) z_zzflsp (:,:) = swdir_s (:,:) z_zzflsd (:,:) = swdifd_s (:,:) z_zzflsu (:,:) = swdifu_s (:,:) z_zzfltd (:,:) = lwd_s (:,:) z_zzfltu (:,:) = lwu_s (:,:) z_zzflsp_par (:,:) = zzflsp_par (:,:) z_zzflsd_par (:,:) = zzflsd_par (:,:) z_zzflsu_par (:,:) = zzflsu_par (:,:) DO k=1,ke DO js=jstart,jend DO i = istart,iend thhr(i,js,k) = ( zcent*zthhr(i,js,k) & + zside*( zthhr(i-1,js,k ) + zthhr(i+1,js,k ) & + zthhr(i,js-1,k ) + zthhr(i,js+1,k ) ) & + zedge*( zthhr(i-1,js-1,k) + zthhr(i+1,js-1,k) & + zthhr(i-1,js+1,k) + zthhr(i+1,js+1,k) ) ) sohr(i,js,k) = ( zcent*zsohr(i,js,k) & + zside*( zsohr(i-1,js,k ) + zsohr(i+1,js,k ) & + zsohr(i,js-1,k ) + zsohr(i,js+1,k ) ) & + zedge*( zsohr(i-1,js-1,k) + zsohr(i+1,js-1,k) & + zsohr(i-1,js+1,k) + zsohr(i+1,js+1,k) ) ) ENDDO ENDDO ENDDO !k DO k=1,ke1 DO js=jstart,jend DO i = istart,iend sodwddm(i,js) = ( zcent*zsodwddm(i,js) & + zside*( zsodwddm(i-1,js ) + zsodwddm(i+1,js ) & + zsodwddm(i,js-1 ) + zsodwddm(i,js+1 ) ) & + zedge*( zsodwddm(i-1,js-1) + zsodwddm(i+1,js-1) & + zsodwddm(i-1,js+1) + zsodwddm(i+1,js+1) ) ) ENDDO ENDDO ENDDO !k DO js=jstart,jend DO i = istart,iend thbs(i,js) = ( zcent*zthbs(i,js) & + zside*( zthbs(i-1,js ) + zthbs(i+1,js ) & + zthbs(i,js-1 ) + zthbs(i,js+1 ) ) & + zedge*( zthbs(i-1,js-1) + zthbs(i+1,js-1) & + zthbs(i-1,js+1) + zthbs(i+1,js+1) ) ) thbt(i,js) = ( zcent*zthbt(i,js) & + zside*( zthbt(i-1,js ) + zthbt(i+1,js ) & + zthbt(i,js-1 ) + zthbt(i,js+1 ) ) & + zedge*( zthbt(i-1,js-1) + zthbt(i+1,js-1) & + zthbt(i-1,js+1) + zthbt(i+1,js+1) ) ) sobs(i,js) = ( zcent*zsobs(i,js) & + zside*( zsobs(i-1,js ) + zsobs(i+1,js ) & + zsobs(i,js-1 ) + zsobs(i,js+1 ) ) & + zedge*( zsobs(i-1,js-1) + zsobs(i+1,js-1) & + zsobs(i-1,js+1) + zsobs(i+1,js+1) ) ) sobt(i,js) = ( zcent*zsobt(i,js) & + zside*( zsobt(i-1,js ) + zsobt(i+1,js ) & + zsobt(i,js-1 ) + zsobt(i,js+1 ) ) & + zedge*( zsobt(i-1,js-1) + zsobt(i+1,js-1) & + zsobt(i-1,js+1) + zsobt(i+1,js+1) ) ) pabs(i,js) = ( zcent*zpabs(i,js) & + zside*( zpabs(i-1,js ) + zpabs(i+1,js ) & + zpabs(i,js-1 ) + zpabs(i,js+1 ) ) & + zedge*( zpabs(i-1,js-1) + zpabs(i+1,js-1) & + zpabs(i-1,js+1) + zpabs(i+1,js+1) ) ) swdir_s(i,js) = ( zcent*z_zzflsp(i,js) & + zside*( z_zzflsp(i-1,js ) + z_zzflsp(i+1,js ) & + z_zzflsp(i,js-1 ) + z_zzflsp(i,js+1 ) ) & + zedge*( z_zzflsp(i-1,js-1) + z_zzflsp(i+1,js-1) & + z_zzflsp(i-1,js+1) + z_zzflsp(i+1,js+1) ) ) swdifd_s(i,js) = ( zcent*z_zzflsd(i,js) & + zside*( z_zzflsd(i-1,js ) + z_zzflsd(i+1,js ) & + z_zzflsd(i,js-1 ) + z_zzflsd(i,js+1 ) ) & + zedge*( z_zzflsd(i-1,js-1) + z_zzflsd(i+1,js-1) & + z_zzflsd(i-1,js+1) + z_zzflsd(i+1,js+1) ) ) swdifu_s(i,js) = ( zcent*z_zzflsu(i,js) & + zside*( z_zzflsu(i-1,js ) + z_zzflsu(i+1,js ) & + z_zzflsu(i,js-1 ) + z_zzflsu(i,js+1 ) ) & + zedge*( z_zzflsu(i-1,js-1) + z_zzflsu(i+1,js-1) & + z_zzflsu(i-1,js+1) + z_zzflsu(i+1,js+1) ) ) lwd_s(i,js) = ( zcent*z_zzfltd(i,js) & + zside*( z_zzfltd(i-1,js ) + z_zzfltd(i+1,js ) & + z_zzfltd(i,js-1 ) + z_zzfltd(i,js+1 ) ) & + zedge*( z_zzfltd(i-1,js-1) + z_zzfltd(i+1,js-1) & + z_zzfltd(i-1,js+1) + z_zzfltd(i+1,js+1) ) ) lwu_s(i,js) = ( zcent*z_zzfltu(i,js) & + zside*( z_zzfltu(i-1,js ) + z_zzfltu(i+1,js ) & + z_zzfltu(i,js-1 ) + z_zzfltu(i,js+1 ) ) & + zedge*( z_zzfltu(i-1,js-1) + z_zzfltu(i+1,js-1) & + z_zzfltu(i-1,js+1) + z_zzfltu(i+1,js+1) ) ) zzflsp_par(i,js) = ( zcent*z_zzflsp_par(i,js) & + zside*( z_zzflsp_par(i-1,js ) + z_zzflsp_par(i+1,js ) & + z_zzflsp_par(i,js-1 ) + z_zzflsp_par(i,js+1 ) ) & + zedge*( z_zzflsp_par(i-1,js-1) + z_zzflsp_par(i+1,js-1) & + z_zzflsp_par(i-1,js+1) + z_zzflsp_par(i+1,js+1) ) ) zzflsd_par(i,js) = ( zcent*z_zzflsd_par(i,js) & + zside*( z_zzflsd_par(i-1,js ) + z_zzflsd_par(i+1,js ) & + z_zzflsd_par(i,js-1 ) + z_zzflsd_par(i,js+1 ) ) & + zedge*( z_zzflsd_par(i-1,js-1) + z_zzflsd_par(i+1,js-1) & + z_zzflsd_par(i-1,js+1) + z_zzflsd_par(i+1,js+1) ) ) zzflsu_par(i,js) = ( zcent*z_zzflsu_par(i,js) & + zside*( z_zzflsu_par(i-1,js ) + z_zzflsu_par(i+1,js ) & + z_zzflsu_par(i,js-1 ) + z_zzflsu_par(i,js+1 ) ) & + zedge*( z_zzflsu_par(i-1,js-1) + z_zzflsu_par(i+1,js-1) & + z_zzflsu_par(i-1,js+1) + z_zzflsu_par(i+1,js+1) ) ) ENDDO !i ENDDO !js DEALLOCATE ( zsohr , STAT=izstatd ) DEALLOCATE ( zthhr , STAT=izstatd ) DEALLOCATE ( zsobs , STAT=izstatd ) DEALLOCATE ( zsobt , STAT=izstatd ) DEALLOCATE ( zthbs , STAT=izstatd ) DEALLOCATE ( zthbt , STAT=izstatd ) DEALLOCATE ( zpabs , STAT=izstatd ) DEALLOCATE ( zsodwddm , STAT=izstatd ) DEALLOCATE ( z_zzflsp , STAT=izstatd ) DEALLOCATE ( z_zzflsd , STAT=izstatd ) DEALLOCATE ( z_zzflsu , STAT=izstatd ) DEALLOCATE ( z_zzflsp_par, STAT=izstatd ) DEALLOCATE ( z_zzflsd_par, STAT=izstatd ) DEALLOCATE ( z_zzflsu_par, STAT=izstatd ) DEALLOCATE ( z_zzfltd , STAT=izstatd ) DEALLOCATE ( z_zzfltu , STAT=izstatd ) ENDIF !lradf_avg DO js=jstartpar,jendpar DO i = istartpar,iendpar thbs (i,js) = thbs(i,js) - zstb*(1._ireals - ctalb)*(t_g(i,js,nzx)**4) ! such it has been tested in testsuite 3.4 ! but keep it for the moment to reproduce results with Version 3.22 zalbfak = (1.0_ireals-zalb_rad_ori(i,js)) sobs (i,js) = sobs(i,js) * zalbfak pabs (i,js) = pabs(i,js) * zalbfak ! And this seems to be the better version ! swdifu_s(i,js) = ( swdir_s(i,js) + swdifd_s(i,js) ) * zalb_rad_ori(i,js) ! sobs(i,js) = swdir_s(i,js) + swdifd_s(i,js) - swdifu_s(i,js) ! pabs(i,js) = zzflsp_par(i,js)+zzflsd_par(i,js) - zzflsu_par(i,js) ENDDO !i ENDDO !js #ifdef COUP_OAS_COS alb_rad(:,:,2) = zalb_rad_ori(:,:) #else alb_rad(:,:) = zalb_rad_ori(:,:) #endif DEALLOCATE ( zalb_rad_ori, STAT=izstatd ) IF (lradtopo) THEN ! Storage of individual flux components for thermal radiative surface flux IF (.NOT. lemiss) THEN zemissivity = 1.0_ireals - ctalb ! surface emissivity zemissfac = zstb * (1.0_ireals - ctalb) ENDIF DO js = jstartpar,jendpar DO i = istartpar,iendpar ! Recompute surface thermal flux components based on ! lower boundary condition IF (lemiss) THEN lwd_s(i,js) = (thbs(i,js) + zstb*emis_rad(i,js)*t_g(i,js,nzx)**4) / emis_rad(i,js) ELSE lwd_s(i,js) = (thbs(i,js) + zemissfac*t_g(i,js,nzx)**4) / zemissivity ENDIF ! correction for thermal fluxes lwu_s(i,js) = lwd_s(i,js) - thbs(i,js) lwd_s(i,js) = lwd_s(i,js) * skyview(i,js) + & lwu_s(i,js) * (1.0_ireals - skyview(i,js)) thbs(i,js) = lwd_s(i,js) - lwu_s(i,js) IF (zsmu0(i,js) > zepemu) THEN ! correction for solar fluxes ! direct down corrected swdir_s(i,js) = swdir_cor(i,js) * swdir_s(i,js) ! diffuse down corrected swdifd_s(i,js) = swdifd_s(i,js) * skyview(i,js) & + swdifu_s(i,js) * (1.0_ireals-skyview(i,js)) ! diffuse up adapted to new other components #ifdef COUP_OAS_COS swdifu_s(i,js) = (swdir_s(i,js) + swdifd_s(i,js)) * alb_rad(i,js,2) #else swdifu_s(i,js) = (swdir_s(i,js) + swdifd_s(i,js)) * alb_rad(i,js) #endif sobs (i,js) = swdir_s(i,js) + swdifd_s(i,js) - swdifu_s(i,js) ! correction for solar fluxes of photosynthetic active radiation IF ( (zzflsp_par(i,js) > 0.0_ireals) .OR. & (zzflsd_par(i,js) > 0.0_ireals) ) THEN zalbradtopo = zzflsu_par(i,js) / & (zzflsp_par(i,js)+zzflsd_par(i,js)) ! direct down corrected zzflsp_par(i,js) = swdir_cor(i,js) * zzflsp_par(i,js) ! diffuse down corrected zzflsd_par(i,js) = zzflsd_par(i,js) * skyview(i,js) & + zzflsu_par(i,js) * (1.0_ireals-skyview(i,js)) ! diffuse up adapted to new other components zzflsu_par(i,js) = (zzflsp_par(i,js) + zzflsd_par(i,js)) & * zalbradtopo pabs(i,js) = zzflsp_par(i,js) + zzflsd_par(i,js) & - zzflsu_par(i,js) ELSE pabs(i,js) = 0.0_ireals ENDIF ELSE sobs(i,js) = 0.0_ireals pabs(i,js) = 0.0_ireals ENDIF ENDDO ENDDO ENDIF !lradtopo ENDIF !lradave ! Set some additional output parameters DO js = jstartpar,jendpar DO i = istartpar,iendpar sod_t(i,js) = zsct * zsmu0(i,js) ENDDO ENDDO #ifdef COSMOART IF(l_cosmo_art) THEN ! CK 20101204 Photolysis rates only need to be calculated if gases are ON If (lgas) CALL calcjval ENDIF #endif !------------------------------------------------------------------------------- ! End of the subroutine !------------------------------------------------------------------------------- END SUBROUTINE organize_radiation !============================================================================== !============================================================================== !+ Module procedure in "Radiation" !------------------------------------------------------------------------------ #ifdef COUP_OAS_COS !CPS we receive albedo for direct radiation also (palp) SUBROUTINE fesft( & pti , pdp , pclc , pwv , psw , pqlwc, pqiwc, pduco2, pduo3, & paeq1 , paeq2, paeq3 , paeq4, paeq5, & papre , psmu0, palso , palth, pskyview, pfcor, & psig , psct , palp , & ki1sd , ki1ed, ki2sd , ki2ed, ki3sd, ki3ed, & ki1sc , ki1ec, ki2sc , ki2ec, ki3sc, ki3ec, & lsolar, lcrf , lradtopo, idebug, jindex, & pflt , pfls , pflt_s, pfls_s, pflsdir, & pfltd , pfltu, pflsd , pflsu, pflsp, & pflpar, pflsu_par, pflsd_par, pflsp_par) #else SUBROUTINE fesft( & pti , pdp , pclc , pwv , psw , pqlwc, pqiwc, pduco2, pduo3, & paeq1 , paeq2, paeq3 , paeq4, paeq5, & papre , psmu0, palso , palth, pskyview, pfcor, & psig , psct , & ki1sd , ki1ed, ki2sd , ki2ed, ki3sd, ki3ed, & ki1sc , ki1ec, ki2sc , ki2ec, ki3sc, ki3ec, & lsolar, lcrf , lradtopo, idebug, jindex, & pflt , pfls , pflt_s, pfls_s, pflsdir, & pfltd , pfltu, pflsd , pflsu, pflsp, & pflpar, pflsu_par, pflsd_par, pflsp_par) #endif !------------------------------------------------------------------------------ ! ! Description: ! ! The module procedure fesft organizes the radiative transfer calculations. ! ! Method: ! ! This routine organizes the radiative transfer calculations by ! calling a set of dedicated routines for the calculation of ! basic optical properties (opt_th/opt_so), the derivation of ! layer coefficients (coe_th/coe_so) for an implicit delta-two- ! stream scheme (cf.Ritter and Geleyn, 1992) and the inversion ! (inv_th/inv_so) of the corresponding system matrix. These ! operations are performed seperately for thermal and solar parts ! of the spectrum and are embedded in loops over the various ! spectral intervals. Within each interval, a data-controlled ! decision is taken, whether the so-called ESFT or FESFT approach ! is used for the handling of gaseous absorption (cf. Ritter and ! Geleyn, 1992). ! Controlled by the logical input variable LCRF, the calculation ! of radiative fluxes in cloud-free conditions can be done in ! addition to the results for the given atmospheric cloud structure. ! (not implemented yet) ! Before the actual flux calculation starts, some preliminary steps ! provide utility arrays which are applicable to all spectral inter- ! vals (e.g. cloud geometry factors, integrated layer water content, etc.) ! !------------------------------------------------------------------------------ ! Subroutine arguments: ! -------------------- ! Input data ! ---------- INTEGER (KIND=iintegers), INTENT (IN) :: & ! indices for array dimensioning ki1sd, & ! start index for first array dimension ki1ed, & ! end index for first array dimension ki2sd, & ! start index for second array dimension ki2ed, & ! end index for second array dimension ki3sd, & ! start index for third array dimension ki3ed, & ! end index for third array dimension ! and the same for the computations ki1sc, & ! start index for first array computation ki1ec, & ! end index for first array computation ki2sc, & ! start index for second array computation ki2ec, & ! end index for second array computation ki3sc, & ! start index for third array computation ki3ec, & ! end index for third array computation ! for activating debug output jindex, & ! actual j-index computed idebug ! debug control switch LOGICAL , INTENT (IN) :: & lcrf, & ! control switch for cloud-free calcul. lsolar, & ! control switch for solar calculations lradtopo ! control switch for topographic corrections REAL (KIND=ireals ), INTENT (IN) :: & psig, & ! Stefan-Boltzman constant psct ! solar constant (at time of year) REAL (KIND=ireals ), INTENT (IN) :: & ! Temperature at layer boundaries, pressure thickness of layers, ! cloud cover in each layer, water vapour and saturation water ! vapour mixing ratio, liquid water and ice mixing ratio ! layer CO2 content and O3 content pti (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) , & ! (K) pdp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (Pa) pclc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (1) pwv (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (kg/kg) psw (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (kg/kg) pqlwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (kg/kg) pqiwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (kg/kg) pduco2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (Pa CO2) pduo3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (Pa O3) ! Aerorsole optical depth at 0.55 micrometer for five types paeq1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (1) paeq2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (1) paeq3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (1) paeq4 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (1) paeq5 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (1) ! Cosine of zenith angle, thermal and solar surface albedo psmu0 (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (1) palth (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (1) palso (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (1) #ifdef COUP_OAS_COS palp (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (1) ! Solar surface albedo for parallel radiation #endif ! External data and radiation corrections pskyview(ki1sd:ki1ed,ki2sd:ki2ed) , & ! pfcor (ki1sd:ki1ed,ki2sd:ki2ed) REAL (KIND=ireals ), INTENT (INOUT) :: & ! Surface pressure papre (ki1sd:ki1ed,ki2sd:ki2ed) ! (Pa) ! Output data ! ----------- REAL (KIND=ireals ), INTENT (OUT) :: & ! Thermal and solar radiative fluxes at each layer boundary ! dito for cloud-free conditions (TOA and surface only) pflt (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) , & ! (W/m**2) pfls (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) , & ! (W/m**2) ! corrected thermal and solar surface flux ! (if not lradtopo, just pflt(ke1) and pfls(ke1) pflt_s (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) pfls_s (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) ! and for the Climate LM Version: solar direct downward radiative flux pflsdir (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) , & ! (W/m**2) ! components of solar and thermal fluxes at surface ! (influenced by lradtopo for topographic corrections) pfltd (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) pfltu (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) pflsd (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) pflsu (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) pflsp (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) ! surface flux of photosynthetic active radiation and components pflpar (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) pflsu_par (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) pflsd_par (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (W/m**2) pflsp_par (ki1sd:ki1ed,ki2sd:ki2ed) ! (W/m**2) ! Local parameters: ! ---------------- INTEGER (KIND=iintegers), PARAMETER :: & j1b = 1, & ! debug point index first dimension j2b = 1 ! debug point index second dimension REAL (KIND=ireals ), PARAMETER :: & zepflx = 1.0E-8_ireals, & ! Minimum 'grey' flux to avoid 1./0. zrd = 287.05_ireals, & ! Ra (gas constant of dry air) zrvdm1 = 461.51_ireals/287.05_ireals-1.0_ireals, & ! Rv/Ra - 1 zrvd = 461.51_ireals/287.05_ireals, & ! Rv/Ra zepai = 0.0_ireals ! Could be used to save computing time for ! 'unimportant' gaseous absorption coefficients ! Local scalars: ! ------------- INTEGER (KIND=iintegers) :: & icrf, igase, & ! igasm1, igasz, & ! j1,j2,j3, & ! loop indices over spatial dimensions jc,jh2o,jco2,jo3, & ! loop indices over gaseous coefficients jspec,jspect, & ! loop indices over spectrum jg,jjg , & ! loop indices over gases icc,ih2o,ico2,io3 ! loop limit for gaseous absorption LOGICAL :: & ldebug_th , & ! debug control switch for thermal ldebug_so , & ! debug control switch for solar ldebug_opt_th , & ! debug control switch for opt_th ldebug_opt_so , & ! debug control switch for opt_so ldebug_inv_th , & ! debug control switch for inv_th ldebug_inv_so ! debug control switch for inv_so REAL (KIND=ireals ) :: & zet ,zaiprod, & ! zcoai,zcobi, & ! zemissivity, zalbedo ! ! Local arrays: ! ------------- INTEGER (KIND=iintegers) :: & icgas (3) ! REAL (KIND=ireals ) :: & zketyp (jpther) , & ! ztetyp (jpther) ! ! Local (automatic) arrays: ! ------------------------ ! Arrays local to *fesft* or required for communication with ! subroutines called from *fesft* REAL (KIND=ireals ) :: & ! 'Grey' and gaseous fluxes for individual spectral intervals ! "_c" means: corrected if lradtopo zflux (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! (W/m**2) zflux_c (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! (W/m**2) zfluxi (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! 1./(W/m**2) zfluxu (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! (W/m**2) zfluxu_c (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! (W/m**2) zfluxui (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! 1./(W/m**2) zfluxd (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! (W/m**2) zfluxd_c (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! (W/m**2) zfluxdi (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! 1./(W/m**2) zfgas (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! (W/m**2) zfgasu (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! (W/m**2) zfgasd (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) ! (W/m**2) REAL (KIND=ireals ) :: & pbbr (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! (W/m**2) Black body radiation at layer boundaries pflpt (ki1sd:ki1ed,ki2sd:ki2ed) , & ! Solar flux at TOA #if ! defined COUP_OAS_COS palp (ki1sd:ki1ed,ki2sd:ki2ed) , & ! Solar surface albedo for parallel radiation #endif pqsmu0 (ki1sd:ki1ed,ki2sd:ki2ed) , & ! Inverse of cosine of zenith angle palogt (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! ln T palogp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! ln p papra (ki1sd:ki1ed,ki2sd:ki2ed) , & ! (Pa) pressure at one level pduh2oc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! layer water vapour content (Pa), cloudy pduh2of (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! layer water vapour content (Pa), cloud-free) pdulwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (Pa H2O-liquid) layer !incloud liquid water content pduiwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (Pa H2O-ice) layer incloud ice content prholwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (kg/m**3) prhoiwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! (kg/m**3) zduetpc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! water vapour e-type contribution (cloudy) zduetpf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! water vapour e-type contribution (cloud-free) ! layer mean temperature, water vapour mixing ratio, utility arrays ztm (ki1sd:ki1ed,ki2sd:ki2ed) , & ! zzwv (ki1sd:ki1ed,ki2sd:ki2ed) , & ! zcpo (ki1sd:ki1ed,ki2sd:ki2ed) , & ! zcpn (ki1sd:ki1ed,ki2sd:ki2ed) , & ! zcmo (ki1sd:ki1ed,ki2sd:ki2ed) , & ! zcmn (ki1sd:ki1ed,ki2sd:ki2ed) ! REAL (KIND=ireals ) :: & ! Output data from opt_th/opt_so podac (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! absorption optical depth podaf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! in cloudy and free part podsc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! scattering optical depth podsf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! in cloudy and free part pbsfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! backscattering fraction pbsff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! in cloudy and free part pusfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! upscattering fraction pusff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! in cloudy and free part ! cloud geometry factors pca1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! pcb1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! pcc1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! pcd1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! pca2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! pcb2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! pcc2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! pcd2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) , & ! !fluxes calculated in inv_th/inv_so pflfd (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) , & ! (W/m**2) pflfu (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) , & ! (W/m**2) pflfp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) , & ! (W/m**2) pflcd (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) , & ! (W/m**2) pflcu (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) , & ! (W/m**2) pflcp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) ! (W/m**2) !- End of header !============================================================================== !------------------------------------------------------------------------------ ! Begin Subroutine fesft !------------------------------------------------------------------------------ !------------------------------------------------------------------------------ ! Section 1: Initializations !------------------------------------------------------------------------------ icrf = 0 ! Debug switches for lower level subroutines ldebug_th = .FALSE. ldebug_so = .FALSE. ldebug_opt_th = .FALSE. ldebug_opt_so = .FALSE. ldebug_inv_th = .FALSE. ldebug_inv_so = .FALSE. IF (idebug > 15) THEN PRINT *,' **** FESFT *********************** debug point : ',j1b,j2b ENDIF ! Preset output arrays DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflt (j1,j2,j3) = 0.0_ireals pfls (j1,j2,j3) = 0.0_ireals ! and for Climate-LM Version pflsdir(j1,j2,j3) = 0.0_ireals ENDDO ENDDO ENDDO #ifdef COSMOART IF(l_cosmo_art) THEN DO j3 = ki3sc, ki3ec+1 DO j1 = ki1sc, ki1ec Edir (j1,jindex,j3) = 0.0_ireals Edown(j1,jindex,j3) = 0.0_ireals Eup (j1,jindex,j3) = 0.0_ireals ENDDO ENDDO ENDIF #endif DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflpar (j1,j2) = 0.0_ireals pflsu_par(j1,j2) = 0.0_ireals pflsd_par(j1,j2) = 0.0_ireals pflsp_par(j1,j2) = 0.0_ireals pfls_s (j1,j2) = 0.0_ireals pflt_s (j1,j2) = 0.0_ireals pfltu (j1,j2) = 0.0_ireals pfltd (j1,j2) = 0.0_ireals pflsu (j1,j2) = 0.0_ireals pflsd (j1,j2) = 0.0_ireals pflsp (j1,j2) = 0.0_ireals ENDDO ENDDO ! Choice of e-type-absorption and temperature correction coefficients DO jspec = 1, jpther zketyp(jspec) = zketypa(jspec) ztetyp(jspec) = ztetypa(jspec) ENDDO ! cloud geometry factors ! first part for top layer DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pca2(j1,j2,ki3sc) = 1.0_ireals - pclc(j1,j2,ki3sc) pcd2(j1,j2,ki3sc) = 1.0_ireals zcpn(j1,j2) = MAX(pclc(j1,j2,ki3sc),pclc(j1,j2,ki3sc+1)) zcmn(j1,j2) = MIN(pclc(j1,j2,ki3sc),pclc(j1,j2,ki3sc+1)) pca2(j1,j2,ki3sc+1) = (1.0_ireals-zcpn(j1,j2))/pca2(j1,j2,ki3sc) pcd2(j1,j2,ki3sc+1) = zcmn(j1,j2) /pclc(j1,j2,ki3sc) ENDDO ENDDO ! first part for inner layers DO j3 = ki3sc+1, ki3ec-1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zcpo(j1,j2) = zcpn(j1,j2) zcmo(j1,j2) = zcmn(j1,j2) zcpn(j1,j2) = MAX (pclc(j1,j2,j3),pclc(j1,j2,j3+1)) zcmn(j1,j2) = MIN (pclc(j1,j2,j3),pclc(j1,j2,j3+1)) pca2(j1,j2,j3+1) = (1.-zcpn(j1,j2))/(1.-pclc(j1,j2,j3)) pca1(j1,j2,j3-1) = (1.-zcpo(j1,j2))/(1.-pclc(j1,j2,j3)) pcd2(j1,j2,j3+1) = zcmn(j1,j2)/pclc(j1,j2,j3) pcd1(j1,j2,j3-1) = zcmo(j1,j2)/pclc(j1,j2,j3) ENDDO ENDDO ENDDO ! first part for lowest layer DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pca1(j1,j2,ki3ec-1) = (1.-zcpn(j1,j2))/(1.-pclc(j1,j2,ki3ec)) pcd1(j1,j2,ki3ec-1) = zcmn(j1,j2)/pclc(j1,j2,ki3ec) pca1(j1,j2,ki3ec ) = 1.0_ireals pcd1(j1,j2,ki3ec ) = 1.0_ireals ENDDO ENDDO ! second part of geometry factors DO j3 = ki3sc, ki3ec DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pcb1(j1,j2,j3) = 1.-pca1(j1,j2,j3) pcc1(j1,j2,j3) = 1.-pcd1(j1,j2,j3) pcb2(j1,j2,j3) = 1.-pca2(j1,j2,j3) pcc2(j1,j2,j3) = 1.-pcd2(j1,j2,j3) ENDDO ENDDO ENDDO ! Optically relevant layer constituents ! (Note: CO2 and O3 amounts are provided by calling routine) DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec papra(j1,j2) = papre(j1,j2) ! surface pressure ENDDO ENDDO ! water vapour, liquid water and ice content, logarithm of layer ! mean temperature and pressure, absorber amount for e-type absorption DO j3 = ki3ec, ki3sc,-1 ! Bottom to top DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ztm (j1,j2) = 0.5*(pti(j1,j2,j3)+pti(j1,j2,j3+1)) papra (j1,j2) = papra(j1,j2) - 0.5*pdp(j1,j2,j3) palogt(j1,j2,j3) = LOG (ztm (j1,j2)) palogp(j1,j2,j3) = LOG (papra(j1,j2)) ! cloud-free: water vapour and e-type absorber amount zzwv (j1,j2 ) = MAX( (pwv(j1,j2,j3)-pclc(j1,j2,j3)*psw(j1,j2,j3)) & /(1.0_ireals-pclc(j1,j2,j3)) , 0.0_ireals) pduh2of(j1,j2,j3) = pdp(j1,j2,j3)*zzwv(j1,j2) zduetpf(j1,j2,j3) = pduh2of(j1,j2,j3)*pduh2of(j1,j2,j3) & *papra(j1,j2)*zrvd/pdp(j1,j2,j3) ! cloudy: water vapour, e-type absorber amount, liquid water and ice pdulwc (j1,j2,j3) = pdp(j1,j2,j3) * (pqlwc(j1,j2,j3)/pclc(j1,j2,j3)) pdulwc (j1,j2,j3) = MAX( pdulwc(j1,j2,j3), 0.0_ireals ) pduiwc (j1,j2,j3) = pdp(j1,j2,j3) * (pqiwc(j1,j2,j3)/pclc(j1,j2,j3)) pduiwc (j1,j2,j3) = MAX( pduiwc(j1,j2,j3), 0.0_ireals ) pduh2oc(j1,j2,j3) = pdp(j1,j2,j3) * psw(j1,j2,j3) zduetpc(j1,j2,j3) = pduh2oc(j1,j2,j3) * pduh2oc(j1,j2,j3) * & papra(j1,j2) * zrvd / pdp(j1,j2,j3) prholwc(j1,j2,j3) = (pqlwc(j1,j2,j3) / pclc(j1,j2,j3)) * papra(j1,j2) & / (zrd*ztm(j1,j2) * (1.+zrvdm1*psw(j1,j2,j3))) prhoiwc(j1,j2,j3) = (pqiwc(j1,j2,j3) / pclc(j1,j2,j3)) * papra(j1,j2) & / (zrd*ztm(j1,j2) * (1.+zrvdm1*psw(j1,j2,j3))) ! Secure minium for ice density for use in empirical function with ALOG prhoiwc(j1,j2,j3) = MAX (prhoiwc(j1,j2,j3),1.0E-06_ireals) papra (j1,j2 ) = papra(j1,j2) - 0.5_ireals * pdp(j1,j2,j3) ENDDO ENDDO ENDDO ! End of vertical loop ! Identify *papre* with top of model pressure (for Rayleigh scattering) DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec papre(j1,j2) = papra(j1,j2) ENDDO ENDDO #ifdef COSMOART ! aerosol optical properties for online radiation feedback IF(l_cosmo_art) THEN IF (lrad_dust) CALL rad_dust(jindex) IF (lrad_seas) CALL rad_seas(jindex) IF (lrad_aero) CALL rad_aero(jindex) ENDIF #endif 1 CONTINUE ! Address for backward jump to perform cloud-free calculations !------------------------------------------------------------------------------ ! Section 2: Thermal radiative flux calculations !------------------------------------------------------------------------------ ! Loop over thermal spectral intervals !================================================================ thermal_spectral_loop: DO jspec=jpsol+1,jpspec !================================================================ !---------------------------------------------------------------------------- ! Section 2.1: Initializations !---------------------------------------------------------------------------- jspect = jspec - jpsol ! Black body radiation at layer boundaries in spectral interval DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pbbr(j1,j2,j3)= ( planck(1,jspect) + pti(j1,j2,j3) & * ( planck(2,jspect) + pti(j1,j2,j3)*planck(3,jspect) ) ) & * psig * (pti(j1,j2,j3)**2)**2 ENDDO ENDDO ENDDO ! Optical properties of non-gaseous constituents IF (idebug > 10 ) THEN print *,' FESFT Call to opt_th for jspec: ',jspec ENDIF CALL opt_th( prholwc,pdulwc,prhoiwc,pduiwc, & paeq1 ,paeq2 ,paeq3 ,paeq4 , paeq5 , & ki1sd ,ki1ed,ki2sd,ki2ed,ki3sd,ki3ed, & jspec ,ki1sc ,ki1ec ,ki2sc , ki2ec , & ki3sc ,ki3ec ,ldebug_opt_th, & podac ,podaf ,podsc ,podsf , pbsfc ,pbsff ) ! Addition of e-type contribution IF (zketyp(jspect) /= 0.) THEN zet = 1./EXP(ztetyp(jspect)/zteref) DO j3 = ki3sc,ki3ec DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ztm(j1,j2) = 0.5*(pti(j1,j2,j3)+pti(j1,j2,j3+1)) podaf(j1,j2,j3) = podaf(j1,j2,j3) + zduetpf(j1,j2,j3) & * zet * EXP(ztetyp(jspect)/ztm(j1,j2)) * zketyp(jspect) podac(j1,j2,j3) = podac(j1,j2,j3) + zduetpc(j1,j2,j3) & * zet * EXP(ztetyp(jspect)/ztm(j1,j2)) * zketyp(jspect) ENDDO ENDDO ENDDO ENDIF !---------------------------------------------------------------------------- ! Section 2.2: Selection of ESFT or FESFT method for interval considered !---------------------------------------------------------------------------- !-------------------------------------------------------------- IF (nfast(jspec) == 0) THEN ! ESFT method !-------------------------------------------------------------- DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zflux(j1,j2,j3) = 0.0_ireals ! Preset flux in spectral interval ENDDO ENDDO ENDDO ! Loop over various absorption coefficients of each of the three gases ih2o = ncgas(jspec,1) ico2 = ncgas(jspec,2) io3 = ncgas(jspec,3) DO jh2o= 1,ih2o ! Loop over H2O coefficients DO jco2= 1,ico2 ! Loop over CO2 coefficients DO jo3= 1,io3 ! Loop over O3 coefficients zaiprod = coai(jh2o,jspec,1)*coai(jco2,jspec,2)*coai(jo3,jspec,3) IF (icrf.eq.0) THEN ! partially cloudy atmosphere call inv_th ( & pclc ,pca1 ,pca2 ,pcb1 ,pcb2 ,pcc1 ,pcc2 ,pcd1 ,pcd2 , & pduh2oc,pduh2of,pduco2,pduo3 ,palogp,palogt, & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff , & pbbr ,palth, & jspec ,jh2o ,jco2 ,jo3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed , & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec , ldebug_inv_th , & pflcu ,pflfu ,pflcd ,pflfd) ELSE ! 'cloud-free' atmosphere print *,' CRF not yet implemented' END IF ! Incrementation of flux in spectral interval DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zflux(j1,j2,j3) = zflux(j1,j2,j3) & + zaiprod * ( pflfu(j1,j2,j3) + pflcu(j1,j2,j3) & - pflfd(j1,j2,j3) - pflcd(j1,j2,j3) ) ENDDO ENDDO ENDDO ENDDO ! Loop over O3 absorption coefficients ENDDO ! Loop over CO2 absorption coefficients ENDDO ! Loop over H2O absorption coefficients !-------------------------------------------------------------- ELSE ! FESFT method !-------------------------------------------------------------- igase = 0 DO jg=1,3 icgas (jg) = 0 IF (ncgas(jspec,jg).GT.1) THEN igase = igase + 1 ENDIF ENDDO igasm1 = igase -1 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF (igase.le.1) THEN !(no 'grey' fluxes required) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfluxi(j1,j2,j3) = 1.0_ireals ENDDO ENDDO ENDDO ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ELSE ! more than 1 gas --> 'grey' fluxes required ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF (icrf.EQ.0) THEN ! partially cloudy atmosphere call inv_th ( & pclc ,pca1 ,pca2 ,pcb1 ,pcb2 ,pcc1 ,pcc2 ,pcd1 ,pcd2 , & pduh2oc,pduh2of,pduco2,pduo3 ,palogp,palogt, & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff , & pbbr ,palth, & jspec ,0 ,0 ,0 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed , & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec , ldebug_inv_th , & pflcu ,pflfu ,pflcd ,pflfd) ELSE ! 'cloud-free' atmosphere print *,' CRF not yet implemented' ENDIF ! Storage of 'grey' fluxes and their inverse (**igasm1) DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zflux (j1,j2,j3) = pflfu(j1,j2,j3) + pflcu(j1,j2,j3) & - pflfd(j1,j2,j3) - pflcd(j1,j2,j3) zfluxi(j1,j2,j3) = 1.0_ireals & / MIN( -zepflx, zflux(j1,j2,j3) )**igasm1 ENDDO ENDDO ENDDO ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDIF ! No.of relevant gases ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - igasz = 0 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DO jg = 3, 1, -1 ! Loop over gases ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF (ncgas(jspec,jg).GT.1) THEN ! include gas only, if necessary igasz = igasz + 1 DO jjg = 1,3 icgas(jjg) = 0 ! Set absorption coefficient index for all ENDDO ! gases to zero DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfgas(j1,j2,j3) = 0.0_ireals ! Preset 'gaseous' flux ENDDO ENDDO ENDDO icc = ncgas(jspec,jg) ! No.of relevant coefficients ! - - - - - - - - - - - - - - - - - - - - - - DO jc = icc,1,-1 ! Loop over absorption coefficients ! - - - - - - - - - - - - - - - - - - - - - - zcoai = coai(jc,jspec,jg) zcobi = cobi(jc,jspec,jg) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF ( ((zcoai.GE.zepai).AND.(zcobi.GT.0.0)) .OR. (igase.EQ.1) ) THEN ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve linear system, if necessary icgas(jg) = jc IF (icrf.EQ.0) THEN ! partially cloudy atmosphere call inv_th ( & pclc ,pca1 ,pca2 ,pcb1 ,pcb2 ,pcc1 ,pcc2 ,pcd1 ,pcd2 , & pduh2oc,pduh2of,pduco2,pduo3 ,palogp,palogt, & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff , & pbbr ,palth, & jspec ,icgas(1),icgas(2),icgas(3), & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed , & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec , ldebug_inv_th , & pflcu ,pflfu ,pflcd ,pflfd) ELSE ! 'cloud-free' atmosphere print *,' CRF not yet implemented' ENDIF ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ELSE ! use 'grey' fluxes directly ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflfu(j1,j2,j3) = zflux(j1,j2,j3) pflfd(j1,j2,j3) = 0.0_ireals pflcu(j1,j2,j3) = 0.0_ireals pflcd(j1,j2,j3) = 0.0_ireals ENDDO ENDDO ENDDO ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDIF ! Necessity to calculate fluxes ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfgas(j1,j2,j3) = zfgas(j1,j2,j3) + zcoai * ( pflfu(j1,j2,j3) & + pflcu(j1,j2,j3) - pflfd(j1,j2,j3) - pflcd(j1,j2,j3) ) ENDDO ENDDO ENDDO !????????????????????????????????????????????????????????????????? IF (ldebug_th) THEN print *,' FESFT in debug mode for thermal fluxes' print *,' only one interval/coefficient considered ' print *,'zfgas(j1b,j2b,ki3sc): ',zfgas(j1b,j2b,ki3sc) EXIT thermal_spectral_loop ENDIF !????????????????????????????????????????????????????????????????? ! - - - - - - - - - - - - - - - - - - - - - - ENDDO ! Loop over absorption coefficients ! - - - - - - - - - - - - - - - - - - - - - - ! Combination of inverse of 'grey' fluxes and actual gaseous flux DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfluxi(j1,j2,j3) = zfluxi(j1,j2,j3)*zfgas(j1,j2,j3) ENDDO ENDDO ENDDO IF (igasz.eq.igasm1) THEN ! Avoid unphysical pseudo-transmission DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfluxi(j1,j2,j3) = MIN( 1.0_ireals, & MAX( 0.0_ireals, zfluxi(j1,j2,j3) ) ) ENDDO ENDDO ENDDO ENDIF ENDIF ! Test, whether gas needs to be included ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - END DO ! End of loop over gases ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Store FESFT result in zflux DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zflux(j1,j2,j3) = zfluxi(j1,j2,j3) ENDDO ENDDO ENDDO !-------------------------------------------------------------- END IF ! ESFT/FESFT-Selection !-------------------------------------------------------------- !---------------------------------------------------------------------------- ! Section 2.3: Addition of flux for spectral interval to total thermal flux !---------------------------------------------------------------------------- IF (icrf.EQ.0) THEN ! Add flux at all levels DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflt(j1,j2,j3) = pflt(j1,j2,j3) + zflux(j1,j2,j3) ENDDO ENDDO ENDDO END IF ! End of spectral loop ! =============================================================== ENDDO thermal_spectral_loop ! =============================================================== !---------------------------------------------------------------------------- ! Section 2.4: Storage of components for thermal radiative surface flux !---------------------------------------------------------------------------- DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ! Recompute surface thermal flux components based on lower boundary ! condition (cf. Ritter and Geleyn (1992)) zemissivity = 1.0_ireals-palth(j1,j2) ! surface emissivity pfltd (j1,j2) = (pflt(j1,j2,ki3ec+1) + & zemissivity * psig * pti(j1,j2,ki3ec+1)**4) & / zemissivity pfltu (j1,j2) = pfltd(j1,j2) - pflt(j1,j2,ki3ec+1) pflt_s(j1,j2) = pflt(j1,j2,ki3ec+1) ENDDO ENDDO !NEC_CB Moved Debug-Prints of out the loop IF (idebug > 15) THEN IF ((j2b>=ki2sc).AND.(j2b<=ki2ec).AND.(j1b>=ki1sc).AND.(j1b<=ki1ec)) THEN j1=j1b j2=j2b WRITE (*,'(A32,2F16.6)') 'FESFT: zemissivity, palth', & zemissivity, palth(j1,j2) WRITE (*,'(A60, F16.6)') & 'FESFT: thermal fluxes before and after correction, skyview', & pskyview(j1,j2) WRITE (*,'(A32,2I4,3F16.6)') 'FESFT th before: net, down, up:', & j1, j2, pflt(j1,j2,ki3ec+1), pfltd(j1,j2), pfltu(j1,j2) ENDIF ENDIF IF (lradtopo) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ! corrected thermal balance ! correction as in Mueller and Scherrer (2005) pfltd (j1,j2) = pfltd(j1,j2) * pskyview(j1,j2) + & pfltu(j1,j2) * (1.0_ireals - pskyview(j1,j2)) pflt_s(j1,j2) = pfltd(j1,j2)-pfltu(j1,j2) ENDDO ENDDO !NEC_CB Moved Debug-Prints of out the loop IF (idebug > 15) THEN IF ((j2b>=ki2sc).AND.(j2b<=ki2ec).AND.(j1b>=ki1sc).AND.(j1b<=ki1ec)) THEN j1=j1b j2=j2b WRITE (*,'(A32,2I4,3F16.6)') 'FESFT th after: net,down,up:', & j1, j2, pflt_s(j1,j2), pfltd(j1,j2), pfltu(j1,j2) END IF END IF END IF !------------------------------------------------------------------------------ ! Section 3: Solar flux calculations, if required !------------------------------------------------------------------------------ IF (lsolar) THEN !---------------------------------------------------------------------------- ! Section 3.1: Initializations !---------------------------------------------------------------------------- ! Inverse of cosine of zenith angle and surface albedo for ! parallel radiation DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pqsmu0(j1,j2) = 1.0_ireals / psmu0(j1,j2) #if ! defined COUP_OAS_COS palp (j1,j2) = (1.0_ireals + & 0.5_ireals * (psmu0(j1,j2) * (1.0_ireals/palso(j1,j2) - 1.0_ireals))) & / (1.0_ireals + (psmu0(j1,j2) * (1.0_ireals/palso(j1,j2) - 1.0_ireals)))**2 #endif ENDDO ENDDO ! Loop over solar spectral intervals ! =============================================================== solar_spectral_loop: DO jspec = 1, jpsol ! =============================================================== ! Preset flux in spectral interval DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zflux (j1,j2,j3) = 0.0_ireals zfluxd(j1,j2,j3) = 0.0_ireals zfluxu(j1,j2,j3) = 0.0_ireals ENDDO ENDDO ENDDO ! Upper boundary condition and reference pressure for Rayleigh sc. DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflpt(j1,j2) = psct * solant(jspec) * psmu0(j1,j2) papra(j1,j2) = papre(j1,j2) * pqsmu0(j1,j2) ENDDO ENDDO ! Optical properties of non-gaseous constituents IF (idebug > 10) THEN print *,' FESFT Call to opt_so for jspec: ',jspec ENDIF CALL opt_so ( prholwc,pdulwc,prhoiwc,pduiwc, & paeq1 ,paeq2 ,paeq3 ,paeq4 , paeq5 , & pdp ,papra ,psmu0 ,pqsmu0, & ki1sd ,ki1ed,ki2sd,ki2ed,ki3sd,ki3ed, & jspec ,ki1sc ,ki1ec ,ki2sc , ki2ec , & ki3sc ,ki3ec ,ldebug_opt_so, & podac ,podaf ,podsc ,podsf , pbsfc ,pbsff ,& pusfc ,pusff ) !---------------------------------------------------------------------------- ! Section 3.2: Selection of ESFT or FESFT method for interval considered !---------------------------------------------------------------------------- !-------------------------------------------------------------- IF (nfast(jspec).eq.0) THEN ! ESFT method !-------------------------------------------------------------- ih2o = ncgas(jspec,1) ico2 = ncgas(jspec,2) io3 = ncgas(jspec,3) DO jh2o = 1, ih2o ! Loop over H2O coefficients DO jco2 = 1, ico2 ! Loop over CO2 coefficients DO jo3 = 1, io3 ! Loop over O3 coefficients zaiprod=coai(jh2o,jspec,1)*coai(jco2,jspec,2)*coai(jo3,jspec,3) IF (icrf.eq.0) THEN ! partially cloudy atmosphere CALL inv_so ( & pclc ,pca1 ,pca2 ,pcb1 ,pcb2 ,pcc1 ,pcc2 ,pcd1 ,pcd2 , & pflpt ,psmu0 ,pqsmu0,palp ,palso , & pduh2oc,pduh2of,pduco2,pduo3 ,palogp,palogt, & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff ,pusfc,pusff, & jspec ,jh2o ,jco2 ,jo3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec , ldebug_inv_so , & pflcu ,pflfu ,pflcd ,pflfd ,pflcp ,pflfp) ELSE ! cloud-free calculation print *,' CRF-Code not implemented yet' ENDIF ! Incrementation of flux in spectral interval DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zflux (j1,j2,j3) = zflux (j1,j2,j3) & + zaiprod * (pflfp(j1,j2,j3) + pflcp(j1,j2,j3)) zfluxd(j1,j2,j3) = zfluxd(j1,j2,j3) & + zaiprod * (pflfd(j1,j2,j3) + pflcd(j1,j2,j3)) zfluxu(j1,j2,j3) = zfluxu(j1,j2,j3) & + zaiprod * (pflfu(j1,j2,j3) + pflcu(j1,j2,j3)) ENDDO ENDDO ENDDO ENDDO ! Loop over O3 absorption coefficients ENDDO ! Loop over CO2 absorption coefficients ENDDO ! Loop over H2O absorption coefficients !-------------------------------------------------------------- ELSE ! FESFT method !-------------------------------------------------------------- igase = 0 DO jg = 1, 3 icgas(jg) = 0 IF (ncgas(jspec,jg).GT.1) THEN igase = igase + 1 ENDIF ENDDO igasm1 = igase -1 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF (igase.le.1) THEN !(no 'grey' fluxes required) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zflux (j1,j2,j3) = 1.0_ireals zfluxd (j1,j2,j3) = 1.0_ireals zfluxu (j1,j2,j3) = 1.0_ireals zfluxi (j1,j2,j3) = 1.0_ireals zfluxdi(j1,j2,j3) = 1.0_ireals zfluxui(j1,j2,j3) = 1.0_ireals ENDDO ENDDO ENDDO ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ELSE ! more than 1 gas --> 'grey' fluxes required ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF (icrf.eq.0) THEN ! partially cloudy atmosphere CALL inv_so ( & pclc ,pca1 ,pca2 ,pcb1 ,pcb2 ,pcc1 ,pcc2 ,pcd1 ,pcd2 ,& pflpt ,psmu0 ,pqsmu0,palp ,palso , & pduh2oc,pduh2of,pduco2,pduo3 ,palogp,palogt, & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff ,pusfc,pusff, & jspec ,0 ,0 ,0 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec , ldebug_inv_so , & pflcu ,pflfu ,pflcd ,pflfd ,pflcp ,pflfp) ELSE ! cloud-free calculation print *,' CRF-Code not implemented yet !!!' stop 'no-crf' ENDIF ! Storage of 'grey' fluxes and their inverse (**igasm1) DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfluxi (j1,j2,j3) = 1.0_ireals & / MAX (pflfp(j1,j2,j3)+pflcp(j1,j2,j3), zepflx) ** igasm1 zfluxdi(j1,j2,j3) = 1.0_ireals & / MAX (pflfd(j1,j2,j3)+pflcd(j1,j2,j3), zepflx) ** igasm1 zfluxui(j1,j2,j3) = 1.0_ireals & / MAX (pflfu(j1,j2,j3)+pflcu(j1,j2,j3), zepflx) ** igasm1 zflux (j1,j2,j3) = pflfp(j1,j2,j3) + pflcp(j1,j2,j3) zfluxd (j1,j2,j3) = pflfd(j1,j2,j3) + pflcd(j1,j2,j3) zfluxu (j1,j2,j3) = pflfu(j1,j2,j3) + pflcu(j1,j2,j3) ENDDO ENDDO ENDDO IF (ldebug_so) THEN print *,' FESFT in debug mode for solar fluxes' print *,' Grey fluxes ' DO j3=ki3sc,ki3ec+1 print *,'par/down/up : ',zflux (j1b,j2b,j3) & ,zfluxd(j1b,j2b,j3) & ,zfluxu(j1b,j2b,j3),j3 ENDDO ENDIF ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDIF ! No.of relevant gases ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - igasz = 0 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DO jg = 3, 1, -1 ! Loop over gases ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF (ncgas(jspec,jg).GT.1) THEN ! include gas only, if necessary igasz = igasz + 1 DO jjg = 1,3 icgas(jjg) = 0 ENDDO ! Initialize 'gaseous' fluxes DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfgas (j1,j2,j3) = 0.0_ireals zfgasd(j1,j2,j3) = 0.0_ireals zfgasu(j1,j2,j3) = 0.0_ireals ENDDO ENDDO ENDDO ! - - - - - - - - - - - - - - - - - - - - - - icc = ncgas(jspec,jg) DO jc = icc,1,-1 ! Loop over absorption coefficients ! - - - - - - - - - - - - - - - - - - - - - - zcoai = coai(jc,jspec,jg) zcobi = cobi(jc,jspec,jg) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF ( ((zcoai.GE.zepai).AND.(zcobi.GT.0.0)) .OR. (igase.EQ.1) ) THEN ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve linear system, if necessary icgas(jg) = jc IF (icrf.eq.0) THEN ! partially cloudy atmosphere CALL inv_so ( & pclc ,pca1 ,pca2 ,pcb1 ,pcb2 ,pcc1 ,pcc2 ,pcd1 ,pcd2 , & pflpt ,psmu0 ,pqsmu0,palp ,palso , & pduh2oc,pduh2of,pduco2,pduo3 ,palogp,palogt, & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff ,pusfc,pusff, & jspec ,icgas(1),icgas(2),icgas(3), & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec , ldebug_inv_so , & pflcu ,pflfu ,pflcd ,pflfd ,pflcp ,pflfp) ELSE ! cloud-free clculations print *,'crf-code not yet implemented' stop 'no-crf' ENDIF ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ELSE ! use 'grey' fluxes directly ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflfp(j1,j2,j3) = zflux (j1,j2,j3) pflcp(j1,j2,j3) = 0.0_ireals pflfd(j1,j2,j3) = zfluxd(j1,j2,j3) pflcd(j1,j2,j3) = 0.0_ireals pflfu(j1,j2,j3) = zfluxu(j1,j2,j3) pflcu(j1,j2,j3) = 0.0_ireals ENDDO ENDDO ENDDO ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDIF ! Necessity to calculate fluxes ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfgas (j1,j2,j3) = zfgas (j1,j2,j3) & + zcoai * (pflfp(j1,j2,j3) + pflcp(j1,j2,j3)) zfgasd(j1,j2,j3) = zfgasd(j1,j2,j3) & + zcoai * (pflfd(j1,j2,j3) + pflcd(j1,j2,j3)) zfgasu(j1,j2,j3) = zfgasu(j1,j2,j3) & + zcoai * (pflfu(j1,j2,j3) + pflcu(j1,j2,j3)) ENDDO ENDDO ENDDO !????????????????????????????????????????????????????????????????? IF (ldebug_so) THEN print *,' FESFT in debug mode for solar fluxes' print *,' only one interval/coefficient considered ' print *,' zcoai = ',zcoai DO j3=ki3sc,ki3ec+1 print *,'zfgas(j1b,j2b,j3): ',zfgas(j1b,j2b,j3) ENDDO EXIT solar_spectral_loop ENDIF !????????????????????????????????????????????????????????????????? ! - - - - - - - - - - - - - - - - - - - - - - ENDDO ! Loop over absorption coefficients ! - - - - - - - - - - - - - - - - - - - - - - ! Combination of inverse of 'grey' fluxes and actual gaseous flux DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfluxi (j1,j2,j3) = zfluxi (j1,j2,j3) * zfgas (j1,j2,j3) zfluxdi(j1,j2,j3) = zfluxdi(j1,j2,j3) * zfgasd(j1,j2,j3) zfluxui(j1,j2,j3) = zfluxui(j1,j2,j3) * zfgasu(j1,j2,j3) ENDDO ENDDO ENDDO IF (igasz.eq.igasm1) THEN ! Avoid unphysical pseudo-transmission DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zfluxi (j1,j2,j3) = MIN( 1.0_ireals, & MAX( 0.0_ireals, zfluxi (j1,j2,j3)) ) zfluxdi(j1,j2,j3) = MIN( 1.0_ireals, & MAX( 0.0_ireals, zfluxdi(j1,j2,j3)) ) zfluxui(j1,j2,j3) = MIN( 1.0_ireals, & MAX( 0.0_ireals, zfluxui(j1,j2,j3)) ) ENDDO ENDDO ENDDO END IF END IF ! Test, whether gas needs to be included ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - END DO ! End of loop over gases ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Store FESFT result in zflux DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zflux (j1,j2,j3) = zfluxi (j1,j2,j3) zfluxd(j1,j2,j3) = zfluxdi(j1,j2,j3) zfluxu(j1,j2,j3) = zfluxui(j1,j2,j3) ENDDO ENDDO ENDDO !-------------------------------------------------------------- END IF ! ESFT/FESFT-Selection !-------------------------------------------------------------- !---------------------------------------------------------------------------- ! Section 3.3: Compute corrected fluxes, if lradtopo !---------------------------------------------------------------------------- IF (lradtopo) THEN IF (idebug > 15) THEN WRITE (*,'(A60,2F16.6)') & 'FESFT: solar fluxes before and after, skyview, fcor', & pskyview(j1b,j2b), pfcor(j1b,j2b) WRITE (*,'(A32,2I4,3F16.6)') 'FESFT: zfluxd, zflux, zfluxu', & j1b, j2b, zfluxd(j1b,j2b,ki3ec+1), zflux(j1b,j2b,ki3ec+1), & zfluxu(j1b,j2b,ki3ec+1) zalbedo = zfluxu(j1b,j2b,ki3ec+1) / & (zflux(j1b,j2b,ki3ec+1)+zfluxd(j1b,j2b,ki3ec+1)) WRITE (*,'(A32,2F16.6)') 'albedo, palso', zalbedo, palso(j1b,j2b) ENDIF DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zalbedo = zfluxu(j1,j2,ki3ec+1) / & (zflux(j1,j2,ki3ec+1)+zfluxd(j1,j2,ki3ec+1)) ! direct down corrected zflux_c (j1,j2,ki3ec+1) = pfcor(j1,j2) * zfluxi(j1,j2,ki3ec+1) ! diffuse down corrected zfluxd_c(j1,j2,ki3ec+1) = & zfluxdi(j1,j2,ki3ec+1) * pskyview(j1,j2) & + zfluxui(j1,j2,ki3ec+1) * (1.0_ireals-pskyview(j1,j2)) ! diffuse up adapted to new other components zfluxu_c(j1,j2,ki3ec+1) = & (zflux_c(j1,j2,ki3ec+1) + zfluxd_c(j1,j2,ki3ec+1)) * zalbedo ENDDO ENDDO IF (idebug > 15) THEN WRITE (*,'(A42,2I4,3F16.6)') & 'FESFT corrected: zfluxd, zflux, zfluxu', j1b, j2b, & zfluxd_c(j1b,j2b,ki3ec+1), zflux_c(j1b,j2b,ki3ec+1), & zfluxu_c(j1b,j2b,ki3ec+1) ENDIF ENDIF !---------------------------------------------------------------------------- ! Section 3.4: Addition of flux for spectral interval to total solar flux !---------------------------------------------------------------------------- IF (icrf == 0) THEN ! Add flux at all levels DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pfls(j1,j2,j3) = pfls (j1,j2,j3) & + zflux(j1,j2,j3) + zfluxd(j1,j2,j3) - zfluxu(j1,j2,j3) ! for the Climate-LM Version IF ( (.NOT. lradtopo) .OR. (pfcor(j1,j2) /= 0.0_ireals) ) THEN pflsdir(j1,j2,j3) = pflsdir (j1,j2,j3) + zflux(j1,j2,j3) ! the else part just lets pflsdir untouched ENDIF ENDDO ENDDO ENDDO ! Store individual components of solar flux at surface IF (lradtopo) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflsu (j1,j2) = pflsu (j1,j2) + zfluxu_c(j1,j2,ki3ec+1) pflsd (j1,j2) = pflsd (j1,j2) + zfluxd_c(j1,j2,ki3ec+1) pflsp (j1,j2) = pflsp (j1,j2) + zflux_c (j1,j2,ki3ec+1) pfls_s(j1,j2) = pfls_s(j1,j2) + zflux_c (j1,j2,ki3ec+1) & + zfluxd_c(j1,j2,ki3ec+1) - zfluxu_c(j1,j2,ki3ec+1) ENDDO ENDDO ELSE DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflsu (j1,j2) = pflsu (j1,j2) + zfluxu (j1,j2,ki3ec+1) pflsd (j1,j2) = pflsd (j1,j2) + zfluxd (j1,j2,ki3ec+1) pflsp (j1,j2) = pflsp (j1,j2) + zflux (j1,j2,ki3ec+1) pfls_s(j1,j2) = pfls_s(j1,j2) + zflux (j1,j2,ki3ec+1) & + zfluxd (j1,j2,ki3ec+1) - zfluxu (j1,j2,ki3ec+1) ENDDO ENDDO ENDIF IF (idebug > 15) THEN WRITE (*,'(A40,3F16.6)') 'FESFT: diff_up, diff_down, dir_down', & pflsu(j1b,j2b), pflsd(j1b,j2b), pflsp(j1b,j2b) ENDIF IF (jspec == 3) THEN ! Photosynthetic active radiation IF (lradtopo) THEN ! T.R. DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflsu_par(j1,j2) = pflsu_par (j1,j2) + zfluxu_c(j1,j2,ki3ec+1) pflsd_par(j1,j2) = pflsd_par (j1,j2) + zfluxd_c(j1,j2,ki3ec+1) pflsp_par(j1,j2) = pflsp_par (j1,j2) + zflux_c (j1,j2,ki3ec+1) pflpar (j1,j2) = pflpar (j1,j2) + zflux_c (j1,j2,ki3ec+1) & + zfluxd_c(j1,j2,ki3ec+1) - zfluxu_c(j1,j2,ki3ec+1) ENDDO ENDDO ELSE DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflsu_par(j1,j2) = pflsu_par (j1,j2) + zfluxu(j1,j2,ki3ec+1) pflsd_par(j1,j2) = pflsd_par (j1,j2) + zfluxd(j1,j2,ki3ec+1) pflsp_par(j1,j2) = pflsp_par (j1,j2) + zflux (j1,j2,ki3ec+1) pflpar (j1,j2) = pflpar (j1,j2) + zflux (j1,j2,ki3ec+1) & + zfluxd (j1,j2,ki3ec+1) - zfluxu (j1,j2,ki3ec+1) ENDDO ENDDO ENDIF ENDIF !(jspec == 3) ENDIF #ifdef COSMOART IF(l_cosmo_art) THEN IF (jspec == 3) THEN IF (lradtopo) THEN DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec Edir (j1,jindex,j3) = zflux_c(j1,j2,j3) Edown(j1,jindex,j3) = zfluxd_c(j1,j2,j3) Eup (j1,jindex,j3) = zfluxu_c(j1,j2,j3) ENDDO ENDDO ENDDO ELSE DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec Edir (j1,jindex,j3) = zflux(j1,j2,j3) Edown(j1,jindex,j3) = zfluxd(j1,j2,j3) Eup (j1,jindex,j3) = zfluxu(j1,j2,j3) ENDDO ENDDO ENDDO ENDIF ENDIF ENDIF #endif ! End of solar spectral loop ! =============================================================== ENDDO solar_spectral_loop ! =============================================================== ENDIF ! Test, whether solar calculation or not !------------------------------------------------------------------------------ ! Section 4: Repeat calculations for cloud-free fluxes !------------------------------------------------------------------------------ ! Repeat calculations for cloud-free fluxes if switch for CRF ! is set to .true. and cloud-free fluxes have not yet been ! computed IF (.NOT. lcrf) THEN !T.R.: pfltf & pflsf removed ! DO j2 = ki2sc, ki2ec ! DO j1 = ki1sc, ki1ec ! pflsf(j1,j2,1) = pfls(j1,j2,ki3sc ) ! pflsf(j1,j2,2) = pfls(j1,j2,ki3ec+1) ! pfltf(j1,j2,1) = pflt(j1,j2,ki3sc ) ! pfltf(j1,j2,2) = pflt(j1,j2,ki3ec+1) ! ENDDO ! ENDDO ELSE IF (icrf.eq.0) THEN ! Branch to cloud-free calculations only once icrf = 1 GO TO 1 ENDIF !------------------------------------------------------------------------------ ! End of the subroutine !------------------------------------------------------------------------------ END SUBROUTINE fesft !============================================================================== !============================================================================== !+ Module procedure in "Radiation" !------------------------------------------------------------------------------ SUBROUTINE coe_th ( & pduh2oc,pduh2of,pduco2 ,pduo3 ,palogp ,palogt , & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff , & ki3 ,kspec ,kh2o ,kco2 ,ko3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec, & ldebug , & pa1c ,pa1f ,pa2c ,pa2f ,pa3c ,pa3f) !------------------------------------------------------------------------------ ! ! Description: ! ! The module procedure coe_th calculates the optical effects of atmospheric ! layers on thermal radiation based on basic optical properties of non-gaseous ! constituents and gaseous absorption coefficients selected through the ! corresponding control variables in the argument list. ! This routine computes layer effects (transmissivity, reflectivity ! and emmisivity) in the thermal part of the radiative spectrum ! both for the cloud-free and the cloudy part of a model layer. ! The calculation is based on the implicit delt-two-stream equations ! (cf. Ritter and Geleyn, 1992) and uses basic optical properties ! (i.e. absorption and scattering optical depth and backscattered ! fraction for non-gaseous atmospheric constituents as well as ! gaseous absorption properties) as input. ! ! Method: ! ! - addition of individual gaseous absorption effects to the optical ! properties of the non-gaseous constituents ! - determination of layer effects (cf. Zdunkowski et al., 1982, 1986 ! and Ritter and Geleyn, 1992) ! !------------------------------------------------------------------------------ ! Subroutine arguments: ! -------------------- ! Input data ! ---------- INTEGER (KIND=iintegers), INTENT (IN) :: & ki1sd, & ! start index for first array dimension ki1ed, & ! end index for first array dimension ki2sd, & ! start index for second array dimension ki2ed, & ! end index for second array dimension ki3sd, & ! start index for third array dimension ki3ed, & ! end index for third array dimension ! and the same for the computations ki1sc, & ! start index for first array computation ki1ec, & ! end index for first array computation ki2sc, & ! start index for second array computation ki2ec, & ! end index for second array computation ki3sc, & ! start index for third array computation ki3ec, & ! end index for third array computation ki3 , & ! vertical layer considered kspec, & ! spectral interval considered kh2o , & ! table index for h2o absorption properties kco2 , & ! table index for co2 absorption properties ko3 ! table index for o3 absorption properties LOGICAL , INTENT (IN) :: & ldebug ! debug control switch REAL (KIND=ireals ), INTENT (IN) :: & ! opticall relevant gas quantities (Pa) pduh2oc(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! h2o inside cloud pduh2of(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! h2o out of cloud pduco2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! co2 content pduo3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! o3 content ! Logarithm of layer mean temperature and pressure palogt (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ln T palogp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ln p ! Optical properties of non-gaseous constituents (..c=cloudy; ..f=free) podsc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! podsf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! podac (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! podaf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! pbsfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! pbsff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) ! ! Output data ! ----------- REAL (KIND=ireals ), INTENT (OUT) :: & pa1c (ki1sd:ki1ed,ki2sd:ki2ed), & ! transmissivity in cloud pa1f (ki1sd:ki1ed,ki2sd:ki2ed), & ! transmissivity cloud-free pa2c (ki1sd:ki1ed,ki2sd:ki2ed), & ! reflectivity in cloud pa2f (ki1sd:ki1ed,ki2sd:ki2ed), & ! reflectivity cloud-free pa3c (ki1sd:ki1ed,ki2sd:ki2ed), & ! emissivity in cloud pa3f (ki1sd:ki1ed,ki2sd:ki2ed) ! emissivity cloud-free ! Local parameters: ! ---------------- REAL (KIND=ireals ), PARAMETER :: & zargli = 80.0 , & ! argument limit for EXP ztsec = 1.0E-35 , & ! (=exp(-zargli) avoids ALOG(0.0) zodmax = 1.0E+6 , & ! maximum allowed optical depth zudiff = 2.0 , & ! Diffusivity factors for gases and other constituents zangfa = 1.648721271 ! exp(0.5) INTEGER (KIND=iintegers), PARAMETER :: & j1b = 1, & ! debug point index first dimension j2b = 1 ! debug point index second dimension ! Local scalars: ! ------------- INTEGER (KIND=iintegers) :: & j1,j2,j3 ! loop indices over spatial dimensions REAL (KIND=ireals ) :: & zeps, ztau, zrho, zodgf, zodgc, zod1, zod2 ! End of header !============================================================================== !------------------------------------------------------------------------------ ! Begin Subroutine coe_th !------------------------------------------------------------------------------ j3 = ki3 IF (ldebug) THEN print *,'**** coe_th ******************************' print *,'**** debug point : ',j1b,j2b print *,'**** coe_th kspec=',kspec print *,'**** coe_th j3 =',j3 print *,'**** coe_th kh2o =',kh2o print *,'**** coe_th kco2 =',kco2 print *,'**** coe_th ko3 =',ko3 print *,'**** pduh2of(j1b,j2b,j3)=',pduh2of(ki1sc,j2b,j3) print *,'**** pduh2oc(j1b,j2b,j3)=',pduh2oc(ki1sc,j2b,j3) print *,'**** pduco2 (j1b,j2b,j3)=',pduco2 (ki1sc,j2b,j3) print *,'**** pduo3 (j1b,j2b,j3)=',pduo3 (ki1sc,j2b,j3) print *,'**** palogp (j1b,j2b,j3)=',palogp (ki1sc,j2b,j3) print *,'**** palogt (j1b,j2b,j3)=',palogt (ki1sc,j2b,j3) print *,'**** cobi (kh2o,kspec,1) =',cobi (kh2o,kspec,1) print *,'**** cobi (kco2,kspec,2) =',cobi (kco2,kspec,2) print *,'**** cobi (ko3 ,kspec,3) =',cobi (ko3 ,kspec,3) print *,'**** coali(kh2o,kspec,1) =',coali (kh2o,kspec,1) print *,'**** coali(kco2,kspec,2) =',coali (kco2,kspec,2) print *,'**** coali(ko3 ,kspec,3) =',coali (ko3 ,kspec,3) print *,'**** cobti(kh2o,kspec,1) =',cobti(kh2o,kspec,1) print *,'**** cobti(kco2,kspec,2) =',cobti(kco2,kspec,2) print *,'**** cobti(ko3 ,kspec,3) =',cobti(ko3 ,kspec,3) ENDIF ! Optical depth of gases DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zodgf = 0.0 ! Initialisation IF (kco2.ne.0) then ! Include CO2 contribution zodgf = zodgf + pduco2(j1,j2,j3) * (cobi(kco2,kspec,2) & * EXP ( coali(kco2,kspec,2) * palogp(j1,j2,j3) & -cobti(kco2,kspec,2) * palogt(j1,j2,j3))) ENDIF ! CO2 !US IF (ldebug) print *,'**** zodgf(CO2) =',zodgf IF (ko3 /= 0) THEN ! Include O3 contribution zodgf = zodgf + pduo3 (j1,j2,j3) * (cobi(ko3 ,kspec,3)* & EXP ( coali(ko3 ,kspec,3) * palogp(j1,j2,j3) & -cobti(ko3 ,kspec,3) * palogt(j1,j2,j3))) ENDIF !US IF (ldebug) print *,'**** zodgf(CO2+O3) =',zodgf ! Cloudy = cloud free for CO2 and O3 : zodgc = zodgf IF (kh2o /= 0) THEN ! Include H2O contribution zodgf = zodgf + pduh2of(j1,j2,j3)* (cobi(kh2o,kspec,1)* & EXP ( coali(kh2o,kspec,1) * palogp(j1,j2,j3) & -cobti(kh2o,kspec,1) * palogt(j1,j2,j3))) zodgc = zodgc + pduh2oc(j1,j2,j3)* (cobi(kh2o,kspec,1)* & EXP ( coali(kh2o,kspec,1) * palogp(j1,j2,j3) & -cobti(kh2o,kspec,1) * palogt(j1,j2,j3))) ENDIF !------------------------------------------------------------------------------ !US IF (ldebug) print *,'**** zodgf(CO2+O3+H2O) =',zodgf !US IF (ldebug) print *,'**** zodgc(CO2+O3+H2O) =',zodgc zodgf = MIN (zodgf, zodmax) zodgc = MIN (zodgc, zodmax) !US IF (ldebug) print *,'**** nach securit auf optical depth ' !US IF (ldebug) print *,'**** zodgf(CO2+O3+H2O) =',zodgf !US IF (ldebug) print *,'**** zodgc(CO2+O3+H2O) =',zodgc ! Pseudo-optical depth in cloud-free part of layer zod2 = zudiff * pbsff(j1,j2,j3) * podsf(j1,j2,j3) zod1 = zod2 + zudiff * podaf(j1,j2,j3) zod1 = zod1 + zangfa * zodgf !US IF (ldebug) THEN !US print *,'**** cloud-free zod1 (j1b,j2b)=',zod1 !US print *,'**** cloud-free zod2 (j1b,j2b)=',zod2 !US ENDIF ! Layer coefficients in cloud-free part of layer zeps=SQRT(zod1*zod1-zod2*zod2) IF (zeps.LT.zargli) THEN ztau = EXP (-zeps) ELSE ztau = ztsec END IF zrho = zod2/(zod1+zeps) pa1f(j1,j2)=ztau*(1.-(zrho**2))*(1./(1.-(zrho**2)*(ztau**2))) pa2f(j1,j2)=zrho*(1.-(ztau**2))*(1./(1.-(zrho**2)*(ztau**2))) pa3f(j1,j2)=(1.-pa1f(j1,j2)+pa2f(j1,j2))/(zod1+zod2) !US IF (ldebug) THEN !US print *,'**** cloud-free pa1f (j1b,j2b)=',pa1f (j1b,j2b) !US print *,'**** cloud-free pa2f (j1b,j2b)=',pa2f (j1b,j2b) !US print *,'**** cloud-free pa3f (j1b,j2b)=',pa3f (j1b,j2b) !US ENDIF ! Pseudo-optical depth in cloudy part of layer zod2 = zudiff * pbsfc(j1,j2,j3) * podsc(j1,j2,j3) zod1 = zod2 + zudiff * podac(j1,j2,j3) zod1 = zod1 + zangfa * zodgc ! Layer coefficients in cloudy part of layer zeps=SQRT(zod1*zod1-zod2*zod2) IF (zeps.LT.zargli) THEN ztau = EXP (-zeps) ELSE ztau = ztsec END IF zrho = zod2/(zod1+zeps) pa1c(j1,j2)=ztau*(1.-(zrho**2))*(1./(1.-(zrho**2)*(ztau**2))) pa2c(j1,j2)=zrho*(1.-(ztau**2))*(1./(1.-(zrho**2)*(ztau**2))) pa3c(j1,j2)=(1.-pa1c(j1,j2)+pa2c(j1,j2))/(zod1+zod2) ENDDO ENDDO !------------------------------------------------------------------------------ ! End of the subroutine !------------------------------------------------------------------------------ END SUBROUTINE coe_th !============================================================================== !============================================================================== !+ Module procedure in "Radiation" !------------------------------------------------------------------------------ SUBROUTINE coe_so ( & pduh2oc,pduh2of,pduco2 ,pduo3 ,palogp ,palogt , & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff ,pusfc ,pusff , & psmu0 ,pqsmu0 , & ki3 ,kspec ,kh2o ,kco2 ,ko3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec, & ldebug , & pa1c ,pa1f ,pa2c ,pa2f ,pa3c ,pa3f , & pa4c ,pa4f ,pa5c ,pa5f ) !------------------------------------------------------------------------------ ! ! Description: ! ! The module procedure coe_so calculates the optical effects of atmospheric ! layers on solar radiation based on basic optical properties of non-gaseous ! constituents and gaseous absorption coefficients selected through the ! corresponding control variables. ! This routine computes layer effects (transmissivity, reflectivity) ! for diffuse and direct solar radiation both for the cloudy and the ! cloud-free part of a model layer. ! The calculation is based on the implicit delt-two-stream equations ! (cf. Ritter and Geleyn, 1992) and uses basic optical properties ! (i.e. absorption and scattering optical depth, backscattered and ! upscattered fraction for non-gaseous atmospheric constituents and ! gaseous absorption properties) as input. ! ! Method: ! ! - addition of individual gaseous absorption effects to the optical ! properties of the non-gaseous constituents ! (optical depth multiplied by alpha1 to alpha4) ! ! - determination of layer effects (cf. Zdunkowski et al., 1982, 1986 ! and Ritter and Geleyn, 1992) ! - the resonance case for those effects related to the direct solar ! radiation is avoided by a small displacement of the local inverse ! of the cosine of the zenith angle (if necessary) ! !------------------------------------------------------------------------------ ! Subroutine arguments: ! -------------------- ! Input data ! ---------- INTEGER (KIND=iintegers), INTENT (IN) :: & ki1sd, & ! start index for first array dimension ki1ed, & ! end index for first array dimension ki2sd, & ! start index for second array dimension ki2ed, & ! end index for second array dimension ki3sd, & ! start index for third array dimension ki3ed, & ! end index for third array dimension ! and the same for the computations ki1sc, & ! start index for first array computation ki1ec, & ! end index for first array computation ki2sc, & ! start index for second array computation ki2ec, & ! end index for second array computation ki3sc, & ! start index for third array computation ki3ec, & ! end index for third array computation ki3 , & ! vertical layer considered kspec, & ! spectral interval considered kh2o , & ! table index for h2o absorption properties kco2 , & ! table index for co2 absorption properties ko3 ! table index for o3 absorption properties LOGICAL , INTENT (IN) :: & ldebug ! debug control switch REAL (KIND=ireals ), INTENT (IN) :: & ! opticall relevant gas quantities (Pa) pduh2oc(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! h2o inside cloud pduh2of(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! h2o out of cloud pduco2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! co2 content pduo3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! o3 content ! Logarithm of layer mean temperature and pressure palogt (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ln T palogp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ln p ! Optical properties of non-gaseous constituents (..c=cloudy; ..f=free) podsc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! podsf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! podac (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! podaf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! pbsfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! pbsff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! pusfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! pusff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! psmu0 (ki1sd:ki1ed,ki2sd:ki2ed) , & ! cosine of zenith angle pqsmu0 (ki1sd:ki1ed,ki2sd:ki2ed) ! inverse of cosine ... ! Output data ! ----------- REAL (KIND=ireals ), INTENT (OUT) :: & pa1c (ki1sd:ki1ed,ki2sd:ki2ed), & ! direct radiation transmis- pa1f (ki1sd:ki1ed,ki2sd:ki2ed), & ! sivity cloudy/cloud-free pa2c (ki1sd:ki1ed,ki2sd:ki2ed), & ! direct radition downward pa2f (ki1sd:ki1ed,ki2sd:ki2ed), & ! scattering cloudy/cloud-free pa3c (ki1sd:ki1ed,ki2sd:ki2ed), & ! direct radiation upward pa3f (ki1sd:ki1ed,ki2sd:ki2ed), & ! scattering cloudy/cloud-free pa4c (ki1sd:ki1ed,ki2sd:ki2ed), & ! diffuse flux transmissivity pa4f (ki1sd:ki1ed,ki2sd:ki2ed), & ! cloudy/cloud-free pa5c (ki1sd:ki1ed,ki2sd:ki2ed), & ! diffuse flux reflectivity pa5f (ki1sd:ki1ed,ki2sd:ki2ed) ! cloudy/cloud-free ! Local parameters: ! ---------------- REAL (KIND=ireals ), PARAMETER :: & zargli = 80.0 , & ! argument limit for EXP ztsec = 1.0E-35 , & ! (=exp(-zargli) avoids ALOG(0.0) zodmax = 1.0E+6 , & ! maximum allowed optical depth zepres = 1.0E-7 , & ! for resonance case avoidance ! 32bit-accuracy (1.E-14 for 64bit machine) zudiff = 2.0 , & ! Diffusivity factors for gases and other constituents zangfa = 1.648721271 ! exp(0.5) INTEGER (KIND=iintegers), PARAMETER :: & j1b = 1, & ! debug point index first dimension j2b = 1 ! debug point index second dimension ! Local scalars: ! ------------- INTEGER (KIND=iintegers) :: & j1,j2,j3 ! loop indices over spatial dimensions REAL (KIND=ireals ) :: & zeps, & ! ze,zm,zg1,zg2,ze1mwf,zmu0if ! REAL (KIND=ireals ) :: & zodgf, zodgc, zod1, zod2, zod3, zod4, zod5 !- End of header !============================================================================== !------------------------------------------------------------------------------ ! Begin Subroutine coe_so !------------------------------------------------------------------------------ j3 = ki3 IF (ldebug) THEN print *,'**** coe_so ******************************' print *,'**** debug point index : ',j1b,j2b print *,'**** coe_so kspec=',kspec print *,'**** coe_so j3 =',j3 print *,'**** coe_so kh2o =',kh2o print *,'**** coe_so kco2 =',kco2 print *,'**** coe_so ko3 =',ko3 print *,'**** pduh2of(j1b,j2b,j3)=',pduh2of(j1b,j2b,j3) print *,'**** pduh2oc(j1b,j2b,j3)=',pduh2oc(j1b,j2b,j3) print *,'**** pduco2 (j1b,j2b,j3)=',pduco2 (j1b,j2b,j3) print *,'**** pduo3 (j1b,j2b,j3)=',pduo3 (j1b,j2b,j3) print *,'**** psmu0 (j1b,j2b) =',psmu0 (j1b,j2b) ENDIF ! Optical depth of gases DO j2 = ki2sc , ki2ec DO j1 = ki1sc, ki1ec zodgf = 0.0_ireals ! Initialisation IF (kco2 /= 0) THEN ! Include CO2 contribution zodgf = zodgf + pduco2(j1,j2,j3)* (cobi(kco2,kspec,2)* & EXP ( coali(kco2,kspec,2) * palogp(j1,j2,j3) & -cobti(kco2,kspec,2) * palogt(j1,j2,j3))) ENDIF ! CO2 !US IF (ldebug) print *,'**** zodgf(CO2) =',zodgf IF (ko3 /= 0) THEN ! Include O3 contribution zodgf = zodgf + pduo3 (j1,j2,j3)* (cobi(ko3 ,kspec,3)* & EXP ( coali(ko3 ,kspec,3) * palogp(j1,j2,j3) & -cobti(ko3 ,kspec,3) * palogt(j1,j2,j3))) ENDIF !US IF (ldebug) print *,'**** zodgf(CO2+O3) =',zodgf ! Cloudy = cloud free for CO2 and O3 : zodgc = zodgf IF (kh2o /= 0) THEN ! Include H2O contribution zodgf = zodgf + pduh2of(j1,j2,j3)* (cobi(kh2o,kspec,1)* & EXP ( coali(kh2o,kspec,1) * palogp(j1,j2,j3) & -cobti(kh2o,kspec,1) * palogt(j1,j2,j3))) zodgc = zodgc + pduh2oc(j1,j2,j3)* (cobi(kh2o,kspec,1)* & EXP ( coali(kh2o,kspec,1) * palogp(j1,j2,j3) & -cobti(kh2o,kspec,1) * palogt(j1,j2,j3))) ENDIF !US IF (ldebug) print *,'**** zodgf(CO2+O3+H2O) =',zodgf !US IF (ldebug) print *,'**** zodgc(CO2+O3+H2O) =',zodgc zodgf = MIN (zodgf, zodmax) zodgc = MIN (zodgc, zodmax) !US IF (ldebug) print *,'**** nach securit auf optical depth ' !US IF (ldebug) print *,'**** zodgf(CO2+O3+H2O) =',zodgf !US IF (ldebug) print *,'**** zodgc(CO2+O3+H2O) =',zodgc ! Pseudo-optical depth in cloud-free part of layer zod2 = zudiff * pbsff(j1,j2,j3) * podsf(j1,j2,j3) zod1 = zod2 + zudiff * podaf(j1,j2,j3) zod3 = pusff(j1,j2,j3) * podsf(j1,j2,j3) zod4 = podsf(j1,j2,j3) - zod3 zod5 = podsf(j1,j2,j3) + podaf(j1,j2,j3) zod1 = zod1 + zangfa * zodgf zod5 = zod5 + zodgf !US IF (ldebug) THEN !US print *,'**** cloud-free zod1 (j1b,j2b) =',zod1 !US print *,'**** cloud-free zod2 (j1b,j2b) =',zod2 !US print *,'**** cloud-free zod3 (j1b,j2b) =',zod3 !US print *,'**** cloud-free zod4 (j1b,j2b) =',zod4 !US print *,'**** cloud-free zod5 (j1b,j2b) =',zod5 !US ENDIF ! Layer coefficients in cloud-free part of layer zeps=SQRT(zod1*zod1-zod2*zod2) IF (zeps.LT.zargli) THEN ze = EXP (-zeps) ELSE ze = ztsec END IF zm = zod2/(zod1+zeps) pa4f(j1,j2)=ze*(1.-(zm**2))*(1./(1.-(zm**2)*(ze**2))) pa5f(j1,j2)=zm*(1.-(ze**2))*(1./(1.-(zm**2)*(ze**2))) ze1mwf = zeps / zod5 zmu0if = ze1mwf + SIGN ( MAX(ABS(pqsmu0(j1,j2)-ze1mwf),zepres) & ,(pqsmu0(j1,j2)-ze1mwf) ) zod3 = zod3 * zmu0if zod4 = zod4 * zmu0if zod5 = zod5 * zmu0if IF (zod5.LT.zargli) THEN pa1f(j1,j2) = EXP (-zod5) ELSE pa1f(j1,j2) = ztsec END IF zg1 = ( zod3*(zod5-zod1) -zod2*zod4) /(zod5*zod5 - zeps*zeps) zg2 =-( zod4*(zod5+zod1) +zod2*zod3) /(zod5*zod5 - zeps*zeps) pa2f(j1,j2) = zg2*(pa1f(j1,j2)-pa4f(j1,j2)) -zg1*pa5f(j1,j2)*pa1f(j1,j2) pa3f(j1,j2) = zg1*(1.-pa4f(j1,j2)*pa1f(j1,j2)) -zg2*pa5f(j1,j2) !US IF (ldebug) THEN !US print *,'**** cloud-free pa1f (j1b,j2b) =',pa1f (j1b,j2b) !US print *,'**** cloud-free pa2f (j1b,j2b) =',pa2f (j1b,j2b) !US print *,'**** cloud-free pa3f (j1b,j2b) =',pa3f (j1b,j2b) !US print *,'**** cloud-free pa4f (j1b,j2b) =',pa4f (j1b,j2b) !US print *,'**** cloud-free pa5f (j1b,j2b) =',pa5f (j1b,j2b) !US ENDIF ! Pseudo-optical depth in cloudy part of layer zod2 = zudiff * pbsfc(j1,j2,j3) * podsc(j1,j2,j3) zod1 = zod2 + zudiff * podac(j1,j2,j3) zod3 = pusfc(j1,j2,j3) * podsc(j1,j2,j3) zod4 = podsc(j1,j2,j3) - zod3 zod5 = podsc(j1,j2,j3) + podac(j1,j2,j3) zod1 = zod1 + zangfa * zodgc zod5 = zod5 + zodgc !US IF (ldebug) THEN !US print *,'**** cloudy zod1 (j1b,j2b) =',zod1 !US print *,'**** cloudy zod2 (j1b,j2b) =',zod2 !US print *,'**** cloudy zod3 (j1b,j2b) =',zod3 !US print *,'**** cloudy zod4 (j1b,j2b) =',zod4 !US print *,'**** cloudy zod5 (j1b,j2b) =',zod5 !US ENDIF ! Layer coefficients in cloudy part of layer zeps=SQRT(zod1*zod1-zod2*zod2) IF (zeps.LT.zargli) THEN ze = EXP (-zeps) ELSE ze = ztsec END IF zm = zod2/(zod1+zeps) pa4c(j1,j2)=ze*(1.-(zm**2))*(1./(1.-(zm**2)*(ze**2))) pa5c(j1,j2)=zm*(1.-(ze**2))*(1./(1.-(zm**2)*(ze**2))) ze1mwf = zeps / zod5 zmu0if = ze1mwf + SIGN ( MAX(ABS(pqsmu0(j1,j2)-ze1mwf),zepres) & ,(pqsmu0(j1,j2)-ze1mwf) ) zod3 = zod3 * zmu0if zod4 = zod4 * zmu0if zod5 = zod5 * zmu0if IF (zod5.LT.ZARGLI) THEN pa1c(j1,j2) = EXP (-zod5) ELSE pa1c(j1,j2) = ztsec END IF zg1 = ( zod3*(zod5-zod1) -zod2*zod4) /(zod5*zod5 - zeps*zeps) zg2 =-( zod4*(zod5+zod1) +zod2*zod3) /(zod5*zod5 - zeps*zeps) pa2c(j1,j2) = zg2*(pa1c(j1,j2)-pa4c(j1,j2)) -zg1*pa5c(j1,j2)*pa1c(j1,j2) pa3c(j1,j2) = zg1*(1.-pa4c(j1,j2)*pa1c(j1,j2)) -zg2*pa5c(j1,j2) ENDDO ENDDO IF (ldebug) THEN print *,'**** cloudy pa1c (j1b,j2b) =',pa1c (j1b,j2b) print *,'**** cloudy pa2c (j1b,j2b) =',pa2c (j1b,j2b) print *,'**** cloudy pa3c (j1b,j2b) =',pa3c (j1b,j2b) print *,'**** cloudy pa4c (j1b,j2b) =',pa4c (j1b,j2b) print *,'**** cloudy pa5c (j1b,j2b) =',pa5c (j1b,j2b) ENDIF !------------------------------------------------------------------------------- ! End of the subroutine !------------------------------------------------------------------------------- END SUBROUTINE coe_so !============================================================================== !============================================================================== !+ Module procedure in "Radiation" !------------------------------------------------------------------------------ SUBROUTINE inv_th ( & pclc ,pca1 ,pca2 ,pcb1 ,pcb2 ,pcc1 ,pcc2 ,pcd1 ,pcd2 , & pduh2oc,pduh2of,pduco2,pduo3 ,palogp,palogt, & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff , & pbbr ,palth, & kspec ,kh2o ,kco2 ,ko3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec , ldebug , & pflcu ,pflfu ,pflcd ,pflfd) !------------------------------------------------------------------------------ ! ! Description: ! ! The module procedure inv_th solves a linear equation system for thermal ! fluxes using a Gaussian elimination-backsubstitution algorithm dedicated ! to the specific structure of the system matrix. ! ! Method: ! ! - setting of the RHS of the system using the layer boundary black ! body radiation and allowing for partial cloud cover in each layer ! - solution of the equation system including the lower boundary ! condition ! - matrix coefficients are calculated in the course of the elimination ! step for one layer at a time through a call to routine *coe_th* ! - the final result, i.e. the so-called black body flux differences ! (cf.Ritter and Geleyn, 1992) are stored seperately for cloudy and ! cloud-free part of each layer boundary ! !------------------------------------------------------------------------------ ! Subroutine arguments: ! -------------------- ! Input data ! ---------- INTEGER (KIND=iintegers), INTENT (IN) :: & ki1sd, & ! start index for first array dimension ki1ed, & ! end index for first array dimension ki2sd, & ! start index for second array dimension ki2ed, & ! end index for second array dimension ki3sd, & ! start index for third array dimension ki3ed, & ! end index for third array dimension ! and the same for the computations ki1sc, & ! start index for first array computation ki1ec, & ! end index for first array computation ki2sc, & ! start index for second array computation ki2ec, & ! end index for second array computation ki3sc, & ! start index for third array computation ki3ec, & ! end index for third array computation kspec, & ! spectral interval considered kh2o , & ! table index for h2o absorption properties kco2 , & ! table index for co2 absorption properties ko3 ! table index for o3 absorption properties LOGICAL , INTENT (IN) :: & ldebug ! debug control switch REAL (KIND=ireals ), INTENT (IN) :: & pclc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud cover pca1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pca2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcb1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcb2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcc1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcc2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcd1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcd2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pbbr (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! black body radiation palth (ki1sd:ki1ed,ki2sd:ki2ed) ! surface albedo ! Input data to be passed to *coe_th* REAL (KIND=ireals ), INTENT (IN) :: & ! layer gas contents (cloudy and cloud-free, if distinction necessary) pduh2oc(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! h2o-vapour cloudy pduh2of(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! h2o-vapour cloud-free pduco2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! co2 pduo3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! o3 ! optical properties of 'grey' constituents (cloudy and cloud-free) podsc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! scattering optical depth podsf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! scattering optical depth podac (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! absorption optical depth podaf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! absorption optical depth pbsfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! backscatter fraction pbsff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! backscatter fraction palogp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ln(p) palogt (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) ! ln(T) ! Output data ! ----------- REAL (KIND=ireals ), INTENT (OUT) :: & pflcu (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! flux up cloudy pflfu (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! flux up cloud-free pflcd (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! flux down cloudy pflfd (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) ! flux down cloud-free ! Local parameters: ! ---------------- INTEGER (KIND=iintegers), PARAMETER :: & j1b = 1, & ! debug point index first dimension j2b = 1 ! debug point index second dimension ! Local scalars: ! ------------- INTEGER (KIND=iintegers) :: & j1,j2,j3 ! loop indices over spatial dimensions LOGICAL :: & ldebug_coe_th ! debug switch for *coe_th* REAL (KIND=ireals ) :: & ztd1 ,ztd2 ,ztd3 ,ztd4 ,ztd5 ,ztd6 , ztd7, & ! ztds1,ztds2,ztds3,ztus1 ! ! Local (automatic) arrays: ! ------------------------ REAL (KIND=ireals ) :: & ! layer properties calculated in *coe_th* pa1c (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa1f (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa2c (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa2f (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa3c (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa3f (ki1sd:ki1ed,ki2sd:ki2ed), & ! ! Utility arrays ztu1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu4 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu5 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu6 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu7 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu8 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu9 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) ! !- End of header !============================================================================== !------------------------------------------------------------------------------ ! Begin Subroutine inv_th !------------------------------------------------------------------------------ ldebug_coe_th = .FALSE. ! Upper boundary condition DO j3 = ki3sc, ki3ec+1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflfd(j1,j2,j3) = pbbr(j1,j2,j3) pflcd(j1,j2,j3) = 0.0_ireals ENDDO ENDDO ENDDO IF (ldebug) THEN print *,' *** INV_TH **************************' print *,' *** debug point : ',j1b,j2b print *,'pflfd(j1b,j2b,ki3sc) : ',pflfd(j1b,j2b,ki3sc) print *,'pflcd(j1b,j2b,ki3sc) : ',pflcd(j1b,j2b,ki3sc) ENDIF ! Determine effects of first layer in *coe_th* CALL coe_th ( pduh2oc,pduh2of,pduco2 ,pduo3 ,palogp ,palogt , & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff , & ki3sc ,kspec ,kh2o ,kco2 ,ko3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec, & ldebug_coe_th , & pa1c ,pa1f ,pa2c ,pa2f ,pa3c ,pa3f) ! Set RHS DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflfu(j1,j2,ki3sc) = (1.-pclc(j1,j2,ki3sc))*pa3f(j1,j2)* & (pbbr(j1,j2,ki3sc)-pbbr(j1,j2,ki3sc+1)) pflcu(j1,j2,ki3sc) = pclc(j1,j2,ki3sc) *pa3c(j1,j2)* & (pbbr(j1,j2,ki3sc)-pbbr(j1,j2,ki3sc+1)) pflfd(j1,j2,ki3sc+1) = -pflfu(j1,j2,ki3sc) pflcd(j1,j2,ki3sc+1) = -pflcu(j1,j2,ki3sc) ENDDO ENDDO ! Elimination for first layer DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflfu(j1,j2,ki3sc) = pflfu(j1,j2,ki3sc ) + pa2f(j1,j2) * & (pca2 (j1,j2,ki3sc) * pflfd(j1,j2,ki3sc)) pflfd(j1,j2,ki3sc+1) = pflfd(j1,j2,ki3sc+1) + pa1f(j1,j2) * & (pca2 (j1,j2,ki3sc) * pflfd(j1,j2,ki3sc)) pflcu(j1,j2,ki3sc) = pflcu(j1,j2,ki3sc ) + pa2c(j1,j2) * & (pcb2 (j1,j2,ki3sc) * pflfd(j1,j2,ki3sc)) pflcd(j1,j2,ki3sc+1) = pflcd(j1,j2,ki3sc+1) + pa1c(j1,j2) * & (pcb2 (j1,j2,ki3sc) * pflfd(j1,j2,ki3sc)) ENDDO ENDDO IF (ldebug) THEN print *,' after elimination' print *,'pflfd(j1b,j2b,ki3sc+1) : ',pflfd(j1b,j2b,ki3sc+1) ENDIF ! Store some utitlity variables for first layer DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ztu1(j1,j2,ki3sc) = 0.0_ireals ztu2(j1,j2,ki3sc) = pca1(j1,j2,ki3sc)*pa1f(j1,j2) ztu3(j1,j2,ki3sc) = pcc1(j1,j2,ki3sc)*pa1f(j1,j2) ztu4(j1,j2,ki3sc) = pcb1(j1,j2,ki3sc)*pa1c(j1,j2) ztu5(j1,j2,ki3sc) = pcd1(j1,j2,ki3sc)*pa1c(j1,j2) ztu6(j1,j2,ki3sc) = pca1(j1,j2,ki3sc)*pa2f(j1,j2) ztu7(j1,j2,ki3sc) = pcc1(j1,j2,ki3sc)*pa2f(j1,j2) ztu8(j1,j2,ki3sc) = pcb1(j1,j2,ki3sc)*pa2c(j1,j2) ztu9(j1,j2,ki3sc) = pcd1(j1,j2,ki3sc)*pa2c(j1,j2) ENDDO ENDDO ! Vertical loop DO j3 = ki3sc+1, ki3ec ! Determine effect of the layer in *coe_th* CALL coe_th ( pduh2oc,pduh2of,pduco2 ,pduo3 ,palogp ,palogt , & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff , & j3 ,kspec ,kh2o ,kco2 ,ko3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec, & ldebug_coe_th , & pa1c ,pa1f ,pa2c ,pa2f ,pa3c ,pa3f) ! Set RHS DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflfu(j1,j2,j3 ) = (1.0_ireals - pclc(j1,j2,j3)) * pa3f(j1,j2) & * (pbbr(j1,j2,j3) - pbbr(j1,j2,j3+1)) pflcu(j1,j2,j3 ) = pclc(j1,j2,j3) * pa3c(j1,j2) & * (pbbr(j1,j2,j3) - pbbr(j1,j2,j3+1)) pflfd(j1,j2,j3+1) = - pflfu(j1,j2,j3) pflcd(j1,j2,j3+1) = - pflcu(j1,j2,j3) ENDDO ENDDO IF (ldebug) THEN print *,' in vertical loop j3=',j3 print *,'pflfd(j1b,j2b,j3+1) : ',pflfd(j1b,j2b,j3+1) ENDIF ! Elimination and storage of utility variables DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ztd1 = 1./(1.-pa2f(j1,j2)*( pca2(j1,j2,j3)*ztu6(j1,j2,j3-1) & +pcc2(j1,j2,j3)*ztu8(j1,j2,j3-1))) pflfu(j1,j2,j3) = ztd1*( pflfu(j1,j2,j3) + & pa2f(j1,j2)*( pca2(j1,j2,j3)*pflfd(j1,j2,j3) & +pcc2(j1,j2,j3)*pflcd(j1,j2,j3))) ztu1 (j1,j2,j3) = ztd1* & pa2f(j1,j2)*( pca2(j1,j2,j3)*ztu7(j1,j2,j3-1) & +pcc2(j1,j2,j3)*ztu9(j1,j2,j3-1)) ztu2 (j1,j2,j3) = ztd1*pa1f(j1,j2)*pca1(j1,j2,j3) ztu3 (j1,j2,j3) = ztd1*pa1f(j1,j2)*pcc1(j1,j2,j3) ztd2 = pa2c(j1,j2)*( pcb2(j1,j2,j3)*ztu6(j1,j2,j3-1) & + pcd2(j1,j2,j3)*ztu8(j1,j2,j3-1)) ztd3 = 1./(1.-pa2c(j1,j2)*( pcb2(j1,j2,j3)*ztu7(j1,j2,j3-1) & +pcd2(j1,j2,j3)*ztu9(j1,j2,j3-1)) & -ztd2*ztu1(j1,j2,j3)) pflcu(j1,j2,j3) = ztd3*( pflcu(j1,j2,j3) + & pa2c(j1,j2)*( pcb2(j1,j2,j3)*pflfd(j1,j2,j3) & +pcd2(j1,j2,j3)*pflcd(j1,j2,j3)) & + ztd2*pflfu(j1,j2,j3)) ztu4 (j1,j2,j3) = ztd3*( pa1c(j1,j2)*pcb1(j1,j2,j3)+ztd2*ztu2(j1,j2,j3)) ztu5 (j1,j2,j3) = ztd3*( pa1c(j1,j2)*pcd1(j1,j2,j3)+ztd2*ztu3(j1,j2,j3)) ztd4 = pa1f(j1,j2)*( pca2(j1,j2,j3)*ztu6(j1,j2,j3-1) & +pcc2(j1,j2,j3)*ztu8(j1,j2,j3-1)) ztd5 = pa1f(j1,j2)*( pca2(j1,j2,j3)*ztu7(j1,j2,j3-1) & +pcc2(j1,j2,j3)*ztu9(j1,j2,j3-1)) pflfd(j1,j2,j3+1) = pflfd(j1,j2,j3+1) & +pa1f(j1,j2)*( pca2(j1,j2,j3)*pflfd(j1,j2,j3) & +pcc2(j1,j2,j3)*pflcd(j1,j2,j3)) & + ztd4*pflfu(j1,j2,j3) + ztd5*pflcu(j1,j2,j3) ztu6 (j1,j2,j3) = pa2f(j1,j2)*pca1(j1,j2,j3) & +ztd4*ztu2(j1,j2,j3)+ztd5*ztu4(j1,j2,j3) ztu7 (j1,j2,j3) = pa2f(j1,j2)*pcc1(j1,j2,j3) & +ztd4*ztu3(j1,j2,j3)+ztd5*ztu5(j1,j2,j3) ztd6 = pa1c(j1,j2)*( pcb2(j1,j2,j3)*ztu6(j1,j2,j3-1) & +pcd2(j1,j2,j3)*ztu8(j1,j2,j3-1)) ztd7 = pa1c(j1,j2)*( pcb2(j1,j2,j3)*ztu7(j1,j2,j3-1) & +pcd2(j1,j2,j3)*ztu9(j1,j2,j3-1)) pflcd(j1,j2,j3+1) = pflcd(j1,j2,j3+1) & +pa1c(j1,j2)*( pcb2(j1,j2,j3)*pflfd(j1,j2,j3) & +pcd2(j1,j2,j3)*pflcd(j1,j2,j3)) & + ztd6*pflfu(j1,j2,j3) + ztd7*pflcu(j1,j2,j3) ztu8(j1,j2,j3) = pa2c(j1,j2)*pcb1(j1,j2,j3) & +ztd6*ztu2(j1,j2,j3)+ztd7*ztu4(j1,j2,j3) ztu9(j1,j2,j3) = pa2c(j1,j2)*pcd1(j1,j2,j3) & +ztd6*ztu3(j1,j2,j3)+ztd7*ztu5(j1,j2,j3) ENDDO ENDDO IF (ldebug) THEN print *,' after elimination in vertical loop j3=',j3 print *,'pflfd(j1b,j2b,j3+1) : ',pflfd(j1b,j2b,j3+1) ENDIF ENDDO ! End of vertical loop over layers ! Elimination and backsubstitution at the surface DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ztds1 =1./(1.-palth(j1,j2)*ztu6(j1,j2,ki3ec)) pflfu(j1,j2,ki3ec+1)= ztds1 *palth(j1,j2)*pflfd(j1,j2,ki3ec+1) ztus1 =ztds1 *palth(j1,j2)*ztu7(j1,j2,ki3ec) ztds2 =palth(j1,j2)*ztu8(j1,j2,ki3ec) ztds3 =1./(1.-palth(j1,j2)*ztu9(j1,j2,ki3ec)-ztds2*ztus1) pflcu(j1,j2,ki3ec+1)=ztds3*( palth(j1,j2)*pflcd(j1,j2,ki3ec+1) & +ztds2 *pflfu(j1,j2,ki3ec+1)) pflfu(j1,j2,ki3ec+1)=pflfu(j1,j2,ki3ec+1)+ztus1*pflcu(j1,j2,ki3ec+1) ENDDO ENDDO ! Layer-by-layer backsubstitution DO j3 =ki3ec,ki3sc,-1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflcd(j1,j2,j3+1) = pflcd(j1,j2,j3+1) + ztu8 (j1,j2,j3) & * pflfu(j1,j2,j3+1) + ztu9 (j1,j2,j3) * pflcu(j1,j2,j3+1) pflfd(j1,j2,j3+1) = pflfd(j1,j2,j3+1) + ztu6 (j1,j2,j3) & * pflfu(j1,j2,j3+1) + ztu7 (j1,j2,j3) * pflcu(j1,j2,j3+1) pflcu(j1,j2,j3 ) = pflcu(j1,j2,j3 ) + ztu4 (j1,j2,j3) & * pflfu(j1,j2,j3+1) + ztu5 (j1,j2,j3) * pflcu(j1,j2,j3+1) pflfu(j1,j2,j3 ) = pflfu(j1,j2,j3 ) + ztu2 (j1,j2,j3) & * pflfu(j1,j2,j3+1) + ztu3 (j1,j2,j3) * pflcu(j1,j2,j3+1) & + ztu1 (j1,j2,j3) * pflcu(j1,j2,j3) ENDDO ENDDO IF (ldebug) THEN print *,' after backsubst. in vertical loop j3=',j3 print *,'pflfd(j1b,j2b,j3+1) : ',pflfd(j1b,j2b,j3+1) ENDIF ENDDO !------------------------------------------------------------------------------ ! End of the subroutine !------------------------------------------------------------------------------ END SUBROUTINE inv_th !============================================================================== !============================================================================== !+ Module procedure in "Radiation" !------------------------------------------------------------------------------ SUBROUTINE inv_so ( & pclc ,pca1 ,pca2 ,pcb1 ,pcb2 ,pcc1 ,pcc2 ,pcd1 ,pcd2 , & pflpt ,psmu0 ,pqsmu0,palp ,palso , & pduh2oc,pduh2of,pduco2,pduo3 ,palogp,palogt, & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff ,pusfc,pusff, & kspec ,kh2o ,kco2 ,ko3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed , & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec , ldebug , & pflcu ,pflfu ,pflcd ,pflfd ,pflcp ,pflfp) !------------------------------------------------------------------------------ ! ! Description: ! ! The module procedure inv_so solves the linear system of equations for ! solar fluxes. ! The routine solves a linear equation system for solar fluxes using ! a Gaussian elimination-backsubstitution algorithm dedicated to the ! specific structure of the system matrix. ! ! Method: ! ! - setting of the RHS of the system using the parallel solar radiation ! at the top of the atmosphere and allowing for partial cloud cover ! - solution of the equation system including the lower boundary ! condition ! - matrix coefficients are calculated in the course of the elimination ! step for one layer at a time through a call to routine *coe_so* ! - the final result, i.e. upward and downward diffuse and parallel ! solar fluxes are stored seperately for cloudy and cloud-free parts ! of each layer boundary ! !------------------------------------------------------------------------------ ! Subroutine arguments: ! -------------------- ! Input data ! ---------- INTEGER (KIND=iintegers), INTENT (IN) :: & ki1sd, & ! start index for first array dimension ki1ed, & ! end index for first array dimension ki2sd, & ! start index for second array dimension ki2ed, & ! end index for second array dimension ki3sd, & ! start index for third array dimension ki3ed, & ! end index for third array dimension ! and the same for the computations ki1sc, & ! start index for first array computation ki1ec, & ! end index for first array computation ki2sc, & ! start index for second array computation ki2ec, & ! end index for second array computation ki3sc, & ! start index for third array computation ki3ec, & ! end index for third array computation kspec, & ! spectral interval considered kh2o , & ! table index for h2o absorption properties kco2 , & ! table index for co2 absorption properties ko3 ! table index for o3 absorption properties LOGICAL , INTENT (IN) :: & ldebug ! debug control switch REAL (KIND=ireals ), INTENT (IN) :: & pclc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud cover pca1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pca2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcb1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcb2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcc1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcc2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcd1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pcd2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! cloud geometry factor pflpt (ki1sd:ki1ed,ki2sd:ki2ed), & ! parallel solar flux at TOA palp (ki1sd:ki1ed,ki2sd:ki2ed), & ! surface albedo for parallel palso (ki1sd:ki1ed,ki2sd:ki2ed) ! and for diffuse radiation ! Input data to be passed to *coe_so* REAL (KIND=ireals ), INTENT (IN) :: & ! layer gas contents (cloudy and cloud-free, if distinction necessary) pduh2oc(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! h2o-vapour cloudy pduh2of(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! h2o-vapour cloud-free pduco2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! co2 pduo3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! o3 ! optical properties of 'grey' constituents (cloudy and cloud-free) podsc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! scattering optical depth podsf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! scattering optical depth podac (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! absorption optical depth podaf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! absorption optical depth pbsfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! backscatter fraction pbsff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! backscatter fraction pusfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! upscatter fraction pusff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! upscatter fraction palogp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ln(p) palogt (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ln(T) psmu0 (ki1sd:ki1ed,ki2sd:ki2ed), & ! cosine of zenith angle pqsmu0(ki1sd:ki1ed,ki2sd:ki2ed) ! 1./cosine of zenith angle ! Output data ! ----------- REAL (KIND=ireals ), INTENT (OUT) :: & pflcu (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! flux up cloudy pflfu (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! flux up cloud-free pflcd (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! flux down cloudy pflfd (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! flux down cloud-free pflcp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1), & ! flux par. cloudy pflfp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed+1) ! flux par. cloud-free ! Local parameters: ! ---------------- INTEGER (KIND=iintegers), PARAMETER :: & j1b = 1, & ! debug point index first dimension j2b = 1 ! debug point index second dimension ! Local scalars: ! ------------- INTEGER (KIND=iintegers) :: & j1,j2,j3 ! loop indices over spatial dimensions LOGICAL :: & ldebug_coe_so ! debug switch for *coe_so* REAL (KIND=ireals ) :: & ztd1 ,ztd2 ,ztd3 ,ztd4 ,ztd5 ,ztd6 , ztd7, & ! ztds1,ztds2,ztds3,ztus1 ! ! Local (automatic) arrays: ! ------------------------ REAL (KIND=ireals ) :: & ! layer properties calculated in *coe_so* pa1c (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa1f (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa2c (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa2f (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa3c (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa4f (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa4c (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa5f (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa5c (ki1sd:ki1ed,ki2sd:ki2ed), & ! pa3f (ki1sd:ki1ed,ki2sd:ki2ed), & ! ! Utility arrays ztu1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu4 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu5 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu6 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu7 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu8 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! ztu9 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) ! !- End of header !============================================================================== !------------------------------------------------------------------------------ ! Begin Subroutine inv_so !------------------------------------------------------------------------------ ldebug_coe_so = .FALSE. ! Upper boundary condition DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflfp(j1,j2,ki3sc) = pflpt(j1,j2) pflcp(j1,j2,ki3sc) = 0.0_ireals pflfd(j1,j2,ki3sc) = 0.0_ireals pflcd(j1,j2,ki3sc) = 0.0_ireals ENDDO ENDDO IF (ldebug) THEN print *,' *** INV_SO **************************' print *,' *** Debug point: ',j1b,j2b print *,'pflfp(j1b,j2b,ki3sc) : ',pflfp(j1b,j2b,ki3sc) print *,'pflcp(j1b,j2b,ki3sc) : ',pflcp(j1b,j2b,ki3sc) print *,'pflfp(j1b,j2b,ki3sc) : ',pflfp(j1b,j2b,ki3sc) print *,'pflcd(j1b,j2b,ki3sc) : ',pflcd(j1b,j2b,ki3sc) ENDIF ! Determine effects of first layer in *coe_so* CALL coe_so ( & pduh2oc,pduh2of,pduco2 ,pduo3 ,palogp ,palogt , & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff ,pusfc ,pusff , & psmu0 ,pqsmu0 , & ki3sc ,kspec ,kh2o ,kco2 ,ko3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec, & ldebug_coe_so , & pa1c ,pa1f ,pa2c ,pa2f ,pa3c ,pa3f , & pa4c ,pa4f ,pa5c ,pa5f ) ! Top layer elimination DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflfu(j1,j2,ki3sc ) = pa3f(j1,j2) * pca2(j1,j2,ki3sc) *pflfp(j1,j2,ki3sc) pflfp(j1,j2,ki3sc+1) = pa1f(j1,j2) * pca2(j1,j2,ki3sc) *pflfp(j1,j2,ki3sc) pflfd(j1,j2,ki3sc+1) = pa2f(j1,j2) * pca2(j1,j2,ki3sc) *pflfp(j1,j2,ki3sc) pflcu(j1,j2,ki3sc ) = pa3c(j1,j2) * pcb2(j1,j2,ki3sc) *pflfp(j1,j2,ki3sc) pflcp(j1,j2,ki3sc+1) = pa1c(j1,j2) * pcb2(j1,j2,ki3sc) *pflfp(j1,j2,ki3sc) pflcd(j1,j2,ki3sc+1) = pa2c(j1,j2) * pcb2(j1,j2,ki3sc) *pflfp(j1,j2,ki3sc) ENDDO ENDDO IF (ldebug) THEN print *,' *** INV_SO **************************' print *,'pflfu(j1b,j2b,ki3sc) : ',pflfu(j1b,j2b,ki3sc) print *,'pflcu(j1b,j2b,ki3sc) : ',pflcu(j1b,j2b,ki3sc) print *,'pflfd(j1b,j2b,ki3sc+1): ',pflfd(j1b,j2b,ki3sc+1) print *,'pflcd(j1b,j2b,ki3sc+1): ',pflcd(j1b,j2b,ki3sc+1) print *,'pa1f (j1b,j2b) : ',pa1f (j1b,j2b) print *,'pa1c (j1b,j2b) : ',pa1c (j1b,j2b) print *,'pa2f (j1b,j2b) : ',pa2f (j1b,j2b) print *,'pa2c (j1b,j2b) : ',pa2c (j1b,j2b) print *,'pa3f (j1b,j2b) : ',pa3f (j1b,j2b) print *,'pa3c (j1b,j2b) : ',pa3c (j1b,j2b) ENDIF ! Storage of utility arrays for the top layer DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ztu1(j1,j2,1) = 0.0_ireals ztu2(j1,j2,1) = pca1(j1,j2,1) * pa4f(j1,j2) ztu3(j1,j2,1) = pcc1(j1,j2,1) * pa4f(j1,j2) ztu4(j1,j2,1) = pcb1(j1,j2,1) * pa4c(j1,j2) ztu5(j1,j2,1) = pcd1(j1,j2,1) * pa4c(j1,j2) ztu6(j1,j2,1) = pca1(j1,j2,1) * pa5f(j1,j2) ztu7(j1,j2,1) = pcc1(j1,j2,1) * pa5f(j1,j2) ztu8(j1,j2,1) = pcb1(j1,j2,1) * pa5c(j1,j2) ztu9(j1,j2,1) = pcd1(j1,j2,1) * pa5c(j1,j2) ENDDO ENDDO ! Suczessive layer-by-layer elimination DO j3 = ki3sc+1, ki3ec ! Loop over vertical ! Determine effects of layer in *coe_so* CALL coe_so ( & pduh2oc,pduh2of,pduco2 ,pduo3 ,palogp ,palogt , & podsc ,podsf ,podac ,podaf ,pbsfc ,pbsff ,pusfc ,pusff , & psmu0 ,pqsmu0 , & j3 ,kspec ,kh2o ,kco2 ,ko3 , & ki1sd ,ki1ed ,ki2sd ,ki2ed ,ki3sd ,ki3ed, & ki1sc ,ki1ec ,ki2sc ,ki2ec ,ki3sc ,ki3ec, & ldebug_coe_so , & pa1c ,pa1f ,pa2c ,pa2f ,pa3c ,pa3f , & pa4c ,pa4f ,pa5c ,pa5f ) ! Elimination DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ztd1 = 1./(1.-pa5f(j1,j2)*(pca2(j1,j2,j3)*ztu6(j1,j2,j3-1) & +pcc2(j1,j2,j3)*ztu8(j1,j2,j3-1))) pflfu(j1,j2,j3) = ztd1*( & pa3f(j1,j2)*( pca2(j1,j2,j3)*pflfp(j1,j2,j3) & +pcc2(j1,j2,j3)*pflcp(j1,j2,j3) ) & +pa5f(j1,j2)*( pca2(j1,j2,j3)*pflfd(j1,j2,j3) & +pcc2(j1,j2,j3)*pflcd(j1,j2,j3) ) ) ztu1 (j1,j2,j3) = ztd1*pa5f(j1,j2)* & ( pca2(j1,j2,j3)*ztu7(j1,j2,j3-1) & +pcc2(j1,j2,j3)*ztu9(j1,j2,j3-1)) ztu2(j1,j2,j3) = ztd1*pa4f(j1,j2)*pca1(j1,j2,j3) ztu3(j1,j2,j3) = ztd1*pa4f(j1,j2)*pcc1(j1,j2,j3) ztd2 = pa5c(j1,j2)*( pcb2(j1,j2,j3)*ztu6(j1,j2,j3-1) & +pcd2(j1,j2,j3)*ztu8(j1,j2,j3-1) ) ztd3 = 1./( 1.-pa5c(j1,j2)*(pcb2(j1,j2,j3)*ztu7(j1,j2,j3-1) & +pcd2(j1,j2,j3)*ztu9(j1,j2,j3-1))& - ztd2*ztu1(j1,j2,j3) ) pflcu(j1,j2,j3) = ztd3 *( & pa3c(j1,j2)*( pcb2(j1,j2,j3)*pflfp(j1,j2,j3) & +pcd2(j1,j2,j3)*pflcp(j1,j2,j3) ) & +pa5c(j1,j2)*( pcb2(j1,j2,j3)*pflfd(j1,j2,j3) & +pcd2(j1,j2,j3)*pflcd(j1,j2,j3) ) & +ztd2*pflfu(j1,j2,j3) ) ztu4(j1,j2,j3) = ztd3 *( pa4c(j1,j2)*pcb1(j1,j2,j3)+ztd2*ztu2(j1,j2,j3) ) ztu5(j1,j2,j3) = ztd3 *( pa4c(j1,j2)*pcd1(j1,j2,j3)+ztd2*ztu3(j1,j2,j3) ) pflfp(j1,j2,j3+1) = pa1f(j1,j2)*(pca2(j1,j2,j3)*pflfp(j1,j2,j3) & +pcc2(j1,j2,j3)*pflcp(j1,j2,j3)) pflcp(j1,j2,j3+1) = pa1c(j1,j2)*(pcb2(j1,j2,j3)*pflfp(j1,j2,j3) & +pcd2(j1,j2,j3)*pflcp(j1,j2,j3)) ztd4 = pa4f(j1,j2)*( pca2(j1,j2,j3)*ztu6(j1,j2,j3-1) & +pcc2(j1,j2,j3)*ztu8(j1,j2,j3-1) ) ztd5 = pa4f(j1,j2)*( pca2(j1,j2,j3)*ztu7(j1,j2,j3-1) & +pcc2(j1,j2,j3)*ztu9(j1,j2,j3-1) ) pflfd(j1,j2,j3+1) = pa2f(j1,j2)*(pca2(j1,j2,j3)*pflfp(j1,j2,j3) & +pcc2(j1,j2,j3)*pflcp(j1,j2,j3)) & +pa4f(j1,j2)*(pca2(j1,j2,j3)*pflfd(j1,j2,j3) & +pcc2(j1,j2,j3)*pflcd(j1,j2,j3)) & +ztd4*pflfu(j1,j2,j3) + ztd5*pflcu(j1,j2,j3) ztu6(j1,j2,j3) = pa5f(j1,j2)*pca1(j1,j2,j3) & + ztd4*ztu2(j1,j2,j3) + ztd5*ztu4(j1,j2,j3) ztu7(j1,j2,j3) = pa5f(j1,j2)*pcc1(j1,j2,j3) & + ztd4*ztu3(j1,j2,j3) + ztd5*ztu5(j1,j2,j3) ztd6 = pa4c(j1,j2)*( pcb2(j1,j2,j3)*ztu6(j1,j2,j3-1) & +pcd2(j1,j2,j3)*ztu8(j1,j2,j3-1) ) ztd7 = pa4c(j1,j2)*( pcb2(j1,j2,j3)*ztu7(j1,j2,j3-1) & +pcd2(j1,j2,j3)*ztu9(j1,j2,j3-1) ) pflcd(j1,j2,j3+1) = pa2c(j1,j2)*(pcb2(j1,j2,j3)*pflfp(j1,j2,j3) & +pcd2(j1,j2,j3)*pflcp(j1,j2,j3)) & + pa4c(j1,j2)*(pcb2(j1,j2,j3)*pflfd(j1,j2,j3) & +pcd2(j1,j2,j3)*pflcd(j1,j2,j3)) & +ztd6*pflfu(j1,j2,j3) + ztd7*pflcu(j1,j2,j3) ztu8(j1,j2,j3) = pa5c(j1,j2)*pcb1(j1,j2,j3) & + ztd6*ztu2(j1,j2,j3) + ztd7*ztu4(j1,j2,j3) ztu9(j1,j2,j3) = pa5c(j1,j2)*pcd1(j1,j2,j3) & + ztd6*ztu3(j1,j2,j3) + ztd7*ztu5(j1,j2,j3) ENDDO ENDDO IF (ldebug) THEN print *,' inv_so j3=',j3 print *,'pflfu(j1b,j2b,j3) : ',pflfu(j1b,j2b,j3) print *,'pflcu(j1b,j2b,j3) : ',pflcu(j1b,j2b,j3) print *,'pflfd(j1b,j2b,j3+1): ',pflfd(j1b,j2b,j3+1) print *,'pflcd(j1b,j2b,j3+1): ',pflcd(j1b,j2b,j3+1) print *,'pflfp(j1b,j2b,j3+1): ',pflfp(j1b,j2b,j3+1) print *,'pflcp(j1b,j2b,j3+1): ',pflcp(j1b,j2b,j3+1) print *,'ztu1 (j1b,j2b,j3) : ',ztu1 (j1b,j2b,j3) print *,'ztu2 (j1b,j2b,j3) : ',ztu2 (j1b,j2b,j3) print *,'ztu3 (j1b,j2b,j3) : ',ztu3 (j1b,j2b,j3) print *,'ztu4 (j1b,j2b,j3) : ',ztu4 (j1b,j2b,j3) print *,'ztu5 (j1b,j2b,j3) : ',ztu5 (j1b,j2b,j3) print *,'ztu6 (j1b,j2b,j3) : ',ztu6 (j1b,j2b,j3) print *,'ztu7 (j1b,j2b,j3) : ',ztu7 (j1b,j2b,j3) print *,'ztu8 (j1b,j2b,j3) : ',ztu8 (j1b,j2b,j3) print *,'ztu9 (j1b,j2b,j3) : ',ztu9 (j1b,j2b,j3) print *,' .....' ENDIF END DO ! Vertical loop ! Elimination and back-substitution at surface DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ztds1 = 1./(1.-palso(j1,j2)*ztu6(j1,j2,ki3ec)) pflfu(j1,j2,ki3ec+1)= ztds1 *(palp (j1,j2)*pflfp(j1,j2,ki3ec+1) & +palso(j1,j2)*pflfd(j1,j2,ki3ec+1)) ztus1 = ztds1*palso(j1,j2)*ztu7(j1,j2,ki3ec) ztds2 = palso(j1,j2)*ztu8(j1,j2,ki3ec) ztds3 = 1./(1.-palso(j1,j2)*ztu9(j1,j2,ki3ec)-ztds2*ztus1) pflcu(j1,j2,ki3ec+1) = ztds3 *(palp (j1,j2)*pflcp(j1,j2,ki3ec+1) & +palso(j1,j2)*pflcd(j1,j2,ki3ec+1) & +ztds2 *pflfu(j1,j2,ki3ec+1)) pflfu(j1,j2,ki3ec+1) = pflfu(j1,j2,ki3ec+1) +ztus1*pflcu(j1,j2,ki3ec+1) ENDDO ENDDO IF (ldebug) THEN print *,' inv_so surface ------------------------------' print *,'pflfu(j1b,j2b,ki3ec+1) : ',pflfu(j1b,j2b,ki3ec+1) print *,'pflcu(j1b,j2b,ki3ec+1) : ',pflcu(j1b,j2b,ki3ec+1) print *,'palp (j1b,j2b): ',palp (j1b,j2b) print *,'palso(j1b,j2b): ',palso(j1b,j2b) print *,'ztds1 ',ztds1 print *,'ztds2 ',ztds2 print *,'ztds3 ',ztds3 print *,'ztus1 ',ztus1 print *,' .....' ENDIF ! Layer-by-layer backsubstitution IF (ldebug) print *,' inv_so BACKSUBSTITUTION' !------------------------------------------------------------------------------ DO j3 = ki3ec, ki3sc, -1 DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec pflcd(j1,j2,j3+1) = pflcd(j1,j2,j3+1) & + ztu8(j1,j2,j3)*pflfu(j1,j2,j3+1) & + ztu9(j1,j2,j3)*pflcu(j1,j2,j3+1) pflfd(j1,j2,j3+1) = pflfd(j1,j2,j3+1) & + ztu6(j1,j2,j3)*pflfu(j1,j2,j3+1) & + ztu7(j1,j2,j3)*pflcu(j1,j2,j3+1) pflcu(j1,j2,j3 ) = pflcu(j1,j2,j3 ) & + ztu4(j1,j2,j3)*pflfu(j1,j2,j3+1) & + ztu5(j1,j2,j3)*pflcu(j1,j2,j3+1) pflfu(j1,j2,j3 ) = pflfu(j1,j2,j3 ) & + ztu2(j1,j2,j3)*pflfu(j1,j2,j3+1) & + ztu3(j1,j2,j3)*pflcu(j1,j2,j3+1) & + ztu1(j1,j2,j3)*pflcu(j1,j2,j3) ENDDO ENDDO IF (ldebug) THEN print *,' inv_so j3=',j3 print *,'pflfu(j1b,j2b,j3) : ',pflfu(j1b,j2b,j3) print *,'pflcu(j1b,j2b,j3) : ',pflcu(j1b,j2b,j3) print *,'pflfd(j1b,j2b,j3+1): ',pflfd(j1b,j2b,j3+1) print *,'pflcd(j1b,j2b,j3+1): ',pflcd(j1b,j2b,j3+1) ENDIF ENDDO !------------------------------------------------------------------------------ ! End of the subroutine !------------------------------------------------------------------------------ END SUBROUTINE inv_so !============================================================================== !============================================================================== !+ Module procedure in "Radiation" !------------------------------------------------------------------------------ SUBROUTINE opt_th(prholwc,pdulwc,prhoiwc,pduiwc, & paeq1 ,paeq2 ,paeq3 ,paeq4 , paeq5 , & ki1sd ,ki1ed ,ki2sd ,ki2ed , ki3sd ,ki3ed, & kspec ,ki1sc ,ki1ec ,ki2sc , ki2ec , & ki3sc ,ki3ec ,ldebug, & podac ,podaf ,podsc ,podsf , pbsfc ,pbsff ) !------------------------------------------------------------------------------ ! ! Description: ! ! The module procedure opt_th calculates the optical properties of the ! non-gaseous constituents for one spectral interval in the thermal part ! of the spectrum. ! Purpose is the calculation of (absorption and scattering) optical ! depth and backward scattered fraction of diffuse radiation (excluding ! the contribution by gaseous constituents). ! ! Method: ! ! - determination of optical properies (i.e. extinction coefficient, ! single scattering albedo and asymetry factor of the phase function) ! using approximate relations for cloud water and cloud ice and ! combination of five type of aerosols ! ! - calculation of optical depth (scattering and absorption) and back- ! scattered fraction suitable for use in an implicit delta-two-stream ! scheme ! !------------------------------------------------------------------------------ ! Subroutine arguments: ! -------------------- ! Input data ! ---------- INTEGER (KIND=iintegers), INTENT (IN) :: & ki1sd, & ! start index for first array dimension ki1ed, & ! end index for first array dimension ki2sd, & ! start index for second array dimension ki2ed, & ! end index for second array dimension ki3sd, & ! start index for third array dimension ki3ed, & ! end index for third array dimension kspec, & ! selected spectral interval ! and the same for the computations ki1sc, & ! start index for first array computation ki1ec, & ! end index for first array computation ki2sc, & ! start index for second array computation ki2ec, & ! end index for second array computation ki3sc, & ! start index for third array computation ki3ec ! end index for third array computation LOGICAL , INTENT (IN) :: & ldebug ! debug control switch REAL (KIND=ireals ), INTENT (IN) :: & ! Liquid and ice water density and content within for the cloudy ! part of each layer prholwc(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & prhoiwc(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & pdulwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & pduiwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! Aerosole contents (optical depths at 0.55 micrometer) for 5 types paeq1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & paeq2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & paeq3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & paeq4 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & paeq5 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) ! Output data ! ----------- REAL (KIND=ireals ), INTENT (OUT) :: & podac (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! absorption optical depth podaf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! in cloudy and free part podsc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! scattering optical depth podsf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! in cloudy and free part pbsfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! backscattering fraction pbsff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) ! in cloudy and free part ! Local parameters: ! ---------------- REAL (KIND=ireals ), PARAMETER :: & z1dg = 1.0/9.80665, & ! 1./g z1d8 = 0.125 , & ! 1./8 zepopd = 1.0E-6 , & ! Security constant for optical depth zepssa = 1.0E-6 ! Security constant for single scattering albedo INTEGER (KIND=iintegers), PARAMETER :: & j1b = 22, & ! debug point index first dimension j2b = 1 ! debug point index second dimension ! Local scalars: ! ------------- INTEGER (KIND=iintegers) :: & j1,j2,j3, & ! loop indices over spatial dimensions ja ! local loop index REAL (KIND=ireals ) :: & ! individual optical properties of liquid water and ice z_lwe, z_iwe, & ! extinction coefficient z_lww, z_iww, & ! single scattering coefficient z_lwg, z_iwg, & ! asymetry factor z_lwf, z_iwf, & ! forward scattered fraction zzg ! Local (automatic) arrays: ! ------------------------ ! optical properties (absorption, scattering, backscatter fraction) ! for liquid water, ice and total aerosole REAL (KIND=ireals ) :: & zlwoda (ki1sd:ki1ed,ki2sd:ki2ed), & ! zlwods (ki1sd:ki1ed,ki2sd:ki2ed), & ! zlwb0 (ki1sd:ki1ed,ki2sd:ki2ed), & ! ziwoda (ki1sd:ki1ed,ki2sd:ki2ed), & ! ziwods (ki1sd:ki1ed,ki2sd:ki2ed), & ! ziwb0 (ki1sd:ki1ed,ki2sd:ki2ed), & ! zaeoda (ki1sd:ki1ed,ki2sd:ki2ed), & ! zaeods (ki1sd:ki1ed,ki2sd:ki2ed), & ! zaeb0 (ki1sd:ki1ed,ki2sd:ki2ed) ! !- End of header !============================================================================== !------------------------------------------------------------------------------ ! Begin Subroutine opt_th !------------------------------------------------------------------------------ IF (ldebug) THEN print *,' **** opt-th start ********************' print *,' **** debug point : ',j1b,j2b ENDIF DO ja=1,5 zaef(kspec,ja) = zaeg(kspec,ja)**2 ! forward sc.fraction f.aerosols ENDDO IF (ldebug) THEN DO ja=1,5 print *,'ja, zaef(kspec,ja): ',ja,zaef(kspec,ja) ENDDO ENDIF IF (ldebug) print *,' In opt-th vor vertical loop' ! Vertical loop ! ------------- DO j3 = ki3sc, ki3ec IF (ldebug) print *,' In opt-th j3 = ',j3 ! Optical properties of liquid water and ice as function of the specific ! liquid water and ice content DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec ! Liquid water z_lwg = zlwg(1,kspec) + zlwg(2,kspec)*prholwc(j1,j2,j3) z_lwg = MAX (0.0_ireals,MIN(1.0_ireals,z_lwg)) z_lwf = z_lwg*z_lwg z_lww = zlww(1,kspec) + zlww(2,kspec)*prholwc(j1,j2,j3) z_lww = MAX(zepssa,MIN(1.0_ireals,z_lww)) z_lwe = z1dg * (zlwe(1,kspec) + zlwe(2,kspec)/ & (zlwe(3,kspec)*prholwc(j1,j2,j3)+zlwe(4,kspec))) z_lwe = MAX(zlwemn(kspec),MIN(zlwemx(kspec),z_lwe)) zlwoda(j1,j2)= z_lwe *pdulwc(j1,j2,j3) * (1.-z_lww) zlwods(j1,j2)= z_lwe *pdulwc(j1,j2,j3) * z_lww * (1.-z_lwf) zlwb0 (j1,j2)= z1d8*(4.+z_lwg)/(1.+z_lwg) ! Ice z_iwg = ziwg(1,kspec) + ziwg(2,kspec)* LOG(prhoiwc(j1,j2,j3)) z_iwg = MAX(0.0_ireals,MIN(1.0_ireals,z_iwg)) z_iwf = z_iwg*z_iwg z_iww = ziww(1,kspec) + ziww(2,kspec)* LOG(prhoiwc(j1,j2,j3)) z_iww = MAX(1.E-12_ireals , MIN (1.0_ireals , z_iww) ) z_iwe = z1dg * (ziwe(1,kspec) + ziwe(2,kspec)/ & (ziwe(3,kspec)*prhoiwc(j1,j2,j3)+ziwe(4,kspec))) z_iwe = MAX(ziwemn(kspec),MIN(ziwemx(kspec),z_iwe )) ziwoda(j1,j2) = z_iwe * pduiwc(j1,j2,j3)*(1.0-z_iww) ziwods(j1,j2) = z_iwe * pduiwc(j1,j2,j3)* z_iww *(1.-z_iwf) ziwb0 (j1,j2) = z1d8*(4.+z_iwg)/(1.+z_iwg) END DO END DO IF (ldebug) THEN print *,' prholwc (j1b,j2b) :',prholwc (j1b,j2b,j3) print *,' pdulwc (j1b,j2b) :',pdulwc (j1b,j2b,j3) print *,' zlwoda (j1b,j2b) :',zlwoda (j1b,j2b) print *,' zlwods (j1b,j2b) :',zlwods (j1b,j2b) print *,' zlwb0 (j1b,j2b) :',zlwb0 (j1b,j2b) print *,' z_lwg :',z_lwg print *,' z_lwf :',z_lwf print *,' z_lww :',z_lww print *,' z_lwe :',z_lwe print *,' prhoiwc (j1b,j2b) :',prhoiwc (j1b,j2b,j3) print *,' pduiwc (j1b,j2b) :',pduiwc (j1b,j2b,j3) print *,' ziwoda (j1b,j2b) :',ziwoda (j1b,j2b) print *,' ziwods (j1b,j2b) :',ziwods (j1b,j2b) print *,' ziwb0 (j1b,j2b) :',ziwb0 (j1b,j2b) ENDIF ! Aerosoles DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) & + paeq2(j1,j2,j3)*zaea(kspec,2) & + paeq3(j1,j2,j3)*zaea(kspec,3) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = & ( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) ) & +( paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2)) ) & +( paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) ) & +( paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) ) & +( paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) ) zzg= & ((paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)))*zaeg(kspec,1) & +(paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2)))*zaeg(kspec,2) & +(paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)))*zaeg(kspec,3) & +(paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)))*zaeg(kspec,4) & +(paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)))*zaeg(kspec,5)) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO #ifdef COSMOART IF(l_cosmo_art) THEN IF ((lrad_dust) .AND. (.NOT. lrad_seas) .AND. (.NOT. lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) + tau_abs_dust(j1,j3,kspec) & + paeq2(j1,j2,j3)*zaea(kspec,2) & + paeq3(j1,j2,j3)*zaea(kspec,3) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))+ & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2)) & + paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2)) & + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg=( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) + & tau_streu_dust(j1,j3,kspec)* & (1.-(asym_ges(j1,j3,kspec)**2))*asym_ges(j1,j3,kspec) & + paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2))*zaeg(kspec,2) & + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5)) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((lrad_dust) .AND. (.NOT. lrad_seas) .AND. (lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) + tau_abs_dust(j1,j3,kspec) & + paeq2(j1,j2,j3)*zaea(kspec,2) & + paeq3(j1,j2,j3)*zaea(kspec,3) + tau_abs_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2)) & +paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2)) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2)) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg= ( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2))*asym_ges(j1,j3,kspec) & + paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2))*zaeg(kspec,2) & + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.))*asym_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((.NOT. lrad_dust) .AND. (.NOT. lrad_seas) .AND. (lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) & + paeq2(j1,j2,j3)*zaea(kspec,2) & + paeq3(j1,j2,j3)*zaea(kspec,3) + tau_abs_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) & +paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2)) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))+ & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.)) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg=( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) & +paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2))*zaeg(kspec,2) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.))*asym_aero(j1,j3,kspec) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((lrad_dust) .AND. (lrad_seas) .AND. (.NOT.lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) + tau_abs_dust(j1,j3,kspec) & + tau_abs_seas(j1,j3,kspec)& + paeq3(j1,j2,j3)*zaea(kspec,3) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))+ & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2)) & + tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2)) & + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg=( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2))*asym_ges(j1,j3,kspec) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2))*asym_seas(j1,j3,kspec) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((.NOT. lrad_dust) .and. (lrad_seas) .and. (.NOT. lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) & + tau_abs_seas(j1,j3,kspec) & + paeq3(j1,j2,j3)*zaea(kspec,3) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) & + tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2))& + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg= ( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2))*asym_seas(j1,j3,kspec) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((lrad_dust) .AND. (lrad_seas) .AND. (lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) + tau_abs_dust(j1,j3,kspec) & + tau_abs_seas(j1,j3,kspec) & + paeq3(j1,j2,j3)*zaea(kspec,3) + tau_abs_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2)) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2)) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2)) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg= ( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2))*asym_ges(j1,j3,kspec) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2))*asym_seas(j1,j3,kspec) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.))*asym_aero(j1,j3,kspec) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((.NOT. lrad_dust) .AND. (lrad_seas) .AND. (lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) & + tau_abs_seas(j1,j3,kspec) & + paeq3(j1,j2,j3)*zaea(kspec,3) + tau_abs_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2.)) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.)) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg=( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2.))*asym_seas(j1,j3,kspec) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.))*asym_aero(j1,j3,kspec) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ENDIF ENDIF #endif IF (ldebug) THEN print *,' zaeoda (j1b,j2b) :',zaeoda (j1b,j2b) print *,' zaeods (j1b,j2b) :',zaeods (j1b,j2b) print *,' zaeb0 (j1b,j2b) :',zaeb0 (j1b,j2b) ENDIF ! Combined effects ! a) cloud free part of each layer DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec podaf(j1,j2,j3) = MAX(zaeoda(j1,j2), zepopd) podsf(j1,j2,j3) = MAX(zaeods(j1,j2), zepopd) pbsff(j1,j2,j3) = zaeb0 (j1,j2) ENDDO ENDDO IF (ldebug) THEN print *,' podaf (j1b,j2b,j3) :',podaf (j1b,j2b,j3) print *,' podsf (j1b,j2b,j3) :',podsf (j1b,j2b,j3) print *,' pbsff (j1b,j2b,j3) :',pbsff (j1b,j2b,j3) ENDIF ! b) cloudy part of each layer DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec podac(j1,j2,j3) = MAX( zlwoda (j1,j2) + ziwoda (j1,j2) + zaeoda(j1,j2),& zepopd) podsc(j1,j2,j3) = MAX( zlwods (j1,j2) + ziwods (j1,j2) + zaeods(j1,j2),& zepopd) podsc(j1,j2,j3) = MIN( podsc(j1,j2,j3), & (1.0_ireals-zepssa) * (podac(j1,j2,j3)+podsc(j1,j2,j3))) pbsfc(j1,j2,j3) = ( zlwb0 (j1,j2)*zlwods (j1,j2) & + ziwb0 (j1,j2)*ziwods (j1,j2) & + zaeb0 (j1,j2)*zaeods (j1,j2) ) / podsc(j1,j2,j3) ENDDO ENDDO IF (ldebug) THEN print *,' podac (j1b,j2b,j3) :',podac (j1b,j2b,j3) print *,' podsc (j1b,j2b,j3) :',podsc (j1b,j2b,j3) print *,' pbsfc (j1b,j2b,j3) :',pbsfc (j1b,j2b,j3) ENDIF ! End of vertical loop ! -------------------- ENDDO !------------------------------------------------------------------------------ ! End of the subroutine !------------------------------------------------------------------------------ END SUBROUTINE opt_th !============================================================================== !============================================================================== !+ Module procedure in "Radiation" !------------------------------------------------------------------------------ SUBROUTINE opt_so(prholwc,pdulwc,prhoiwc,pduiwc, & paeq1 ,paeq2 ,paeq3 ,paeq4 , paeq5 , & pdp ,papra ,psmu0 ,pqsmu0, & ki1sd ,ki1ed ,ki2sd ,ki2ed , ki3sd , ki3ed, & kspec ,ki1sc ,ki1ec ,ki2sc , ki2ec , & ki3sc ,ki3ec ,ldebug, & podac ,podaf ,podsc ,podsf , pbsfc ,pbsff , & pusfc ,pusff ) !------------------------------------------------------------------------------ ! ! Description: ! ! The module procedure opt_so calculates the optical properties of the ! non-gaseous constituents for one spectral interval in the solar part ! of the spectrum. ! Purpose is the calculation of (absorption and scattering) optical ! depth and backward scattered fraction for diffuse and upward scattered ! fraction for direct solar radiation (excluding the contribution by ! gaseous constituents). ! ! Method: ! ! - determination of optical properies (i.e. extinction coefficient, ! single scattering albedo and asymetry factor of the phase function) ! using approximate relations for Rayleigh effects, cloud water, ! cloud ice and a combination of five type of aerosols ! ! - calculation of optical depth (scattering and absorption), back- ! scattered and upscattered fraction of radiation suitable for use ! in an implicit delta-two-stream scheme ! !------------------------------------------------------------------------------ ! Subroutine arguments: ! -------------------- ! Input data ! ---------- INTEGER (KIND=iintegers), INTENT (IN) :: & ki1sd, & ! start index for first array dimension ki1ed, & ! end index for first array dimension ki2sd, & ! start index for second array dimension ki2ed, & ! end index for second array dimension ki3sd, & ! start index for third array dimension ki3ed, & ! end index for third array dimension ! and the same for the computations ki1sc, & ! start index for first array computation ki1ec, & ! end index for first array computation ki2sc, & ! start index for second array computation ki2ec, & ! end index for second array computation ki3sc, & ! start index for third array computation ki3ec, & ! end index for third array computation kspec ! selected spectral interval LOGICAL , INTENT (IN) :: & ldebug ! debug control switch REAL (KIND=ireals ), INTENT (IN) :: & ! Liquid and ice water density and content within for the cloudy ! part of each layer prholwc(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & prhoiwc(ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & pdulwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & pduiwc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! Aerosole contents (optical depths at 0.55 micrometer) for 5 types paeq1 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & paeq2 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & paeq3 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & paeq4 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & paeq5 (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! pressure thickness of layers pdp (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! zenith angle and it's inverse psmu0 (ki1sd:ki1ed,ki2sd:ki2ed) , & pqsmu0 (ki1sd:ki1ed,ki2sd:ki2ed) REAL (KIND=ireals ), INTENT (INOUT) :: & ! mean layer pressure (TOA on input) papra (ki1sd:ki1ed,ki2sd:ki2ed) ! Output data ! ----------- REAL (KIND=ireals ), INTENT (OUT) :: & podac (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! absorption optical depth podaf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! in cloudy and free part podsc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! scattering optical depth podsf (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! in cloudy and free part pbsfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! backscattering fraction pbsff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! in cloudy and free part pusfc (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed), & ! upward scattered fraction pusff (ki1sd:ki1ed,ki2sd:ki2ed,ki3sd:ki3ed) ! in cloudy and free part ! Local parameters: ! ---------------- REAL (KIND=ireals ), PARAMETER :: & z1dg = 1.0/9.80665, & ! 1./g z1d8 = 0.125 , & ! 1./8 zepopd = 1.0E-6 , & ! Security constant for optical depth zepssa = 1.0E-6 ! Security constant for single scattering albedo INTEGER (KIND=iintegers), PARAMETER :: & j1b = 1, & ! debug point index first dimension j2b = 1 ! debug point index second dimension ! Local scalars: ! ------------- INTEGER (KIND=iintegers) :: & j1,j2,j3, & ! loop indices over spatial dimensions ja , & ! local loop index isp ! (=kspec, but shorter for notation purposes) REAL (KIND=ireals ) :: & ! individual optical properties of liquid water and ice z_lwe, z_iwe, & ! extinction coefficient z_lww, z_iww, & ! single scattering coefficient z_lwg, z_iwg, & ! asymetry factor z_lwf, z_iwf, & ! forward scattered fraction zzg ! Local (automatic) arrays: ! ------------------------ ! optical properties (absorption, scattering, back- and upscatter fraction) ! for liquid water, ice and total aerosole ! for Rayleigh scattering, only the optical depth is stored as array, since ! back- and upscatter fractions are constant (=0.5) REAL (KIND=ireals ) :: & zlwoda (ki1sd:ki1ed,ki2sd:ki2ed), & ! zlwods (ki1sd:ki1ed,ki2sd:ki2ed), & ! zlwb0 (ki1sd:ki1ed,ki2sd:ki2ed), & ! zlwb (ki1sd:ki1ed,ki2sd:ki2ed), & ! ziwoda (ki1sd:ki1ed,ki2sd:ki2ed), & ! ziwods (ki1sd:ki1ed,ki2sd:ki2ed), & ! ziwb0 (ki1sd:ki1ed,ki2sd:ki2ed), & ! ziwb (ki1sd:ki1ed,ki2sd:ki2ed), & ! zaeoda (ki1sd:ki1ed,ki2sd:ki2ed), & ! zaeods (ki1sd:ki1ed,ki2sd:ki2ed), & ! zaeb0 (ki1sd:ki1ed,ki2sd:ki2ed), & ! zaeb (ki1sd:ki1ed,ki2sd:ki2ed), & ! zraods (ki1sd:ki1ed,ki2sd:ki2ed) ! !- End of header !============================================================================== !------------------------------------------------------------------------------ ! Begin Subroutine opt_so !------------------------------------------------------------------------------ isp = kspec IF (ldebug) THEN print *,' **** opt-so start **********************' print *,' **** debug point : ',j1b,j2b print *,' **** interval : ',isp ENDIF DO ja=1,5 zaef(isp,ja) = zaeg(isp,ja)**2 ! forward sc.fraction f.aerosols ENDDO IF (ldebug) THEN DO ja=1,5 print *,'ja, zaef(isp,ja): ',ja,zaef(isp,ja) ENDDO ENDIF IF (ldebug) print *,' In opt-so vor vertical loop' ! Vertical loop ! ------------ DO j3=ki3sc,ki3ec if (ldebug) print *,' In opt-so j3 = ',j3 ! Optical properties of liquid water and ice as function of the specific ! liquid water and ice content DO j2=ki2sc,ki2ec DO j1=ki1sc,ki1ec ! liquid water effects z_lwg = zlwg(1,isp) + zlwg(2,isp)*prholwc(j1,j2,j3) z_lwg = MAX(0.0_ireals,MIN(1.0_ireals,z_lwg)) z_lwf = z_lwg*z_lwg z_lww = zlww(1,isp) + zlww(2,isp)*prholwc(j1,j2,j3) z_lww = MAX(zepssa,MIN(1.0-zepssa,z_lww)) z_lwe = z1dg * (zlwe(1,isp) + zlwe(2,isp)/ & (zlwe(3,isp)*prholwc(j1,j2,j3)+zlwe(4,isp))) z_lwe = MAX(zlwemn(isp),MIN(zlwemx(isp),z_lwe)) zlwoda(j1,j2) = z_lwe*pdulwc(j1,j2,j3)*(1.0-z_lww) zlwods(j1,j2) = z_lwe*pdulwc(j1,j2,j3)* z_lww *(1.-z_lwf) zlwb0 (j1,j2) = z1d8*(4.+z_lwg)/(1.+z_lwg) zlwb (j1,j2) = 0.5-0.75*psmu0(j1,j2)*z_lwg/(1.+z_lwg) ! ice water effects z_iwg = ziwg(1,isp) + ziwg(2,isp)* LOG(prhoiwc(j1,j2,j3)) z_iwg = MAX(0.0_ireals,MIN(1.0_ireals,z_iwg)) z_iwf = z_iwg*z_iwg z_iww = ziww(1,isp) + ziww(2,isp)* LOG(prhoiwc(j1,j2,j3)) z_iww = MAX(zepssa,MIN(1.0_ireals-zepssa,z_iww)) z_iwe = z1dg * (ziwe(1,isp) + ziwe(2,isp)/ & (ziwe(3,isp)*prhoiwc(j1,j2,j3)+ziwe(4,isp))) z_iwe = MAX(ziwemn(isp),MIN(ziwemx(isp),z_iwe )) ziwoda(j1,j2) = z_iwe*pduiwc(j1,j2,j3)*(1.0-z_iww) ziwods(j1,j2) = z_iwe*pduiwc(j1,j2,j3)* z_iww *(1.-z_iwf) ziwb0 (j1,j2) = z1d8*(4.+z_iwg)/(1.+z_iwg) ziwb (j1,j2) = 0.5-0.75*psmu0(j1,j2)*z_iwg/(1.+z_iwg) END DO END DO IF (ldebug) THEN print *,' prholwc (j1b,j2b) :',prholwc (j1b,j2b,j3) print *,' pdulwc (j1b,j2b) :',pdulwc (j1b,j2b,j3) print *,' zlwoda (j1b,j2b) :',zlwoda (j1b,j2b) print *,' zlwods (j1b,j2b) :',zlwods (j1b,j2b) print *,' zlwb0 (j1b,j2b) :',zlwb0 (j1b,j2b) print *,' zlwb (j1b,j2b) :',zlwb (j1b,j2b) print *,' z_lwg :',z_lwg print *,' z_lwf :',z_lwf print *,' z_lww :',z_lww print *,' z_lwe :',z_lwe print *,' prhoiwc (j1b,j2b) :',prhoiwc (j1b,j2b,j3) print *,' pduiwc (j1b,j2b) :',pduiwc (j1b,j2b,j3) print *,' ziwoda (j1b,j2b) :',ziwoda (j1b,j2b) print *,' ziwods (j1b,j2b) :',ziwods (j1b,j2b) print *,' ziwb0 (j1b,j2b) :',ziwb0 (j1b,j2b) print *,' ziwb (j1b,j2b) :',ziwb (j1b,j2b) ENDIF ! Optical properties of five aerosol types combined DO j2=ki2sc,ki2ec DO j1=ki1sc,ki1ec zaeoda(j1,j2)= & paeq1(j1,j2,j3)*zaea(isp,1)+paeq2(j1,j2,j3)*zaea(isp,2)+ & paeq3(j1,j2,j3)*zaea(isp,3)+paeq4(j1,j2,j3)*zaea(isp,4)+ & paeq5(j1,j2,j3)*zaea(isp,5) zaeods(j1,j2)= & ( paeq1(j1,j2,j3)*zaes(isp,1)*(1.-zaef(isp,1)) ) & +( paeq2(j1,j2,j3)*zaes(isp,2)*(1.-zaef(isp,2)) ) & +( paeq3(j1,j2,j3)*zaes(isp,3)*(1.-zaef(isp,3)) ) & +( paeq4(j1,j2,j3)*zaes(isp,4)*(1.-zaef(isp,4)) ) & +( paeq5(j1,j2,j3)*zaes(isp,5)*(1.-zaef(isp,5)) ) zzg=( & (paeq1(j1,j2,j3)*zaes(isp,1)*(1.-zaef(isp,1)))*zaeg(isp,1) & +(paeq2(j1,j2,j3)*zaes(isp,2)*(1.-zaef(isp,2)))*zaeg(isp,2) & +(paeq3(j1,j2,j3)*zaes(isp,3)*(1.-zaef(isp,3)))*zaeg(isp,3) & +(paeq4(j1,j2,j3)*zaes(isp,4)*(1.-zaef(isp,4)))*zaeg(isp,4) & +(paeq5(j1,j2,j3)*zaes(isp,5)*(1.-zaef(isp,5)))*zaeg(isp,5)) & / MAX( zaeods(j1,j2),zepopd) zaeb0(j1,j2) = z1d8*(4.+zzg)/(1.+zzg) zaeb (j1,j2) = 0.5-0.75*psmu0(j1,j2)*zzg/(1.+zzg) ENDDO ENDDO #ifdef COSMOART IF(l_cosmo_art) THEN IF ((lrad_dust) .AND. (.NOT.lrad_seas) .AND. (.NOT. lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) + tau_abs_dust(j1,j3,kspec) & + paeq2(j1,j2,j3)*zaea(kspec,2) & + paeq3(j1,j2,j3)*zaea(kspec,3) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))+ & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2)) & + paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2)) & + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg=( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2))*asym_ges(j1,j3,kspec) & +paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2))*zaeg(kspec,2) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((lrad_dust) .AND. (.NOT. lrad_seas) .AND. (lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) + tau_abs_dust(j1,j3,kspec) & + paeq2(j1,j2,j3)*zaea(kspec,2) & + paeq3(j1,j2,j3)*zaea(kspec,3) + tau_abs_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2)) & + paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2)) & + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2)) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg= (paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2))*asym_ges(j1,j3,kspec) & + paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2))*zaeg(kspec,2) & + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.))*asym_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((.NOT. lrad_dust) .AND. (.NOT. lrad_seas) .AND. (lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) & + paeq2(j1,j2,j3)*zaea(kspec,2) & + paeq3(j1,j2,j3)*zaea(kspec,3) + tau_abs_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) & +paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2)) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))+ & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.)) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg=( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) & +paeq2(j1,j2,j3)*zaes(kspec,2)*(1.-zaef(kspec,2))*zaeg(kspec,2) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.))*asym_aero(j1,j3,kspec) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((lrad_dust) .AND. (lrad_seas) .AND. (.NOT. lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) + tau_abs_dust(j1,j3,kspec) & + tau_abs_seas(j1,j3,kspec)& + paeq3(j1,j2,j3)*zaea(kspec,3) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))+ & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2)) & + tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2)) & + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg=( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2))*asym_ges(j1,j3,kspec) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2))*asym_seas(j1,j3,kspec) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((.NOT.lrad_dust) .AND. (lrad_seas) .AND. (.NOT. lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) & + tau_abs_seas(j1,j3,kspec) & + paeq3(j1,j2,j3)*zaea(kspec,3) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) & + tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2))& + paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) & + paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & + paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg= ( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2))*asym_seas(j1,j3,kspec) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((lrad_dust) .AND. (lrad_seas) .AND. (lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) + tau_abs_dust(j1,j3,kspec) & + tau_abs_seas(j1,j3,kspec) & + paeq3(j1,j2,j3)*zaea(kspec,3) + tau_abs_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2)) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2)) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2)) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg= ( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) + & tau_streu_dust(j1,j3,kspec)*(1.-(asym_ges(j1,j3,kspec)**2))*asym_ges(j1,j3,kspec) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2))*asym_seas(j1,j3,kspec) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.))*asym_aero(j1,j3,kspec) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ELSEIF ((.NOT. lrad_dust) .AND. (lrad_seas) .AND. (lrad_aero)) THEN DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zaeoda(j1,j2) = paeq1(j1,j2,j3)*zaea(kspec,1) & + tau_abs_seas(j1,j3,kspec) & + paeq3(j1,j2,j3)*zaea(kspec,3) + tau_abs_aero(j1,j3,kspec) & + paeq4(j1,j2,j3)*zaea(kspec,4) & + paeq5(j1,j2,j3)*zaea(kspec,5) zaeods(j1,j2) = paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1)) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2.)) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3)) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.)) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4)) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5)) zzg=( paeq1(j1,j2,j3)*zaes(kspec,1)*(1.-zaef(kspec,1))*zaeg(kspec,1) & +tau_streu_seas(j1,j3,kspec)*(1.-(asym_seas(j1,j3,kspec)**2.))*asym_seas(j1,j3,kspec) & +paeq3(j1,j2,j3)*zaes(kspec,3)*(1.-zaef(kspec,3))*zaeg(kspec,3) + & tau_streu_aero(j1,j3,kspec)*(1.-(asym_aero(j1,j3,kspec)**2.))*asym_aero(j1,j3,kspec) & +paeq4(j1,j2,j3)*zaes(kspec,4)*(1.-zaef(kspec,4))*zaeg(kspec,4) & +paeq5(j1,j2,j3)*zaes(kspec,5)*(1.-zaef(kspec,5))*zaeg(kspec,5) ) & / MAX( zaeods(j1,j2),zepopd) zaeb0 (j1,j2) = z1d8*(4.+zzg)/(1.+zzg) ENDDO ENDDO ENDIF ENDIF #endif IF (ldebug) THEN print *,' zaeoda (j1b,j2b) :',zaeoda (j1b,j2b) print *,' zaeods (j1b,j2b) :',zaeods (j1b,j2b) print *,' zaeb0 (j1b,j2b) :',zaeb0 (j1b,j2b) print *,' zaeb (j1b,j2b) :',zaeb (j1b,j2b) ENDIF ! Optical thickness for Rayleigh scattering DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec zraods(j1,j2) = zrsc(isp) * pdp(j1,j2,j3) / (1.0_ireals + zrsc(isp) * & (papra(j1,j2) + 0.5_ireals * pdp(j1,j2,j3) * pqsmu0(j1,j2))) papra (j1,j2) = papra(j1,j2) + pdp(j1,j2,j3) * pqsmu0(j1,j2) ENDDO ENDDO IF (ldebug) THEN ! print *,' Rayleigh coefficient:',zrsc(isp) ! print *,' Papra (j1b,j2b) :',papra (j1b,j2b) ! print *,' Pqsmu0 (j1b,j2b) :',pqsmu0 (j1b,j2b) ! print *,' Pdp (j1b,j2b) :',pdp (j1b,j2b,j3) print *,' zraods (j1b,j2b) :',zraods (j1b,j2b) ENDIF !----------------------------------------------------------------------- ! Linear combination of individual contributions ! a) cloud free part of layer DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec podaf(j1,j2,j3) = MAX ( zaeoda(j1,j2) , zepopd) podsf(j1,j2,j3) = MAX ( zaeods(j1,j2) + zraods(j1,j2), zepopd) podsf(j1,j2,j3) = MIN ( podsf (j1,j2,j3), & (1.0_ireals-zepssa) * (podaf(j1,j2,j3) + podsf(j1,j2,j3)) ) pbsff(j1,j2,j3) = (zaeb0(j1,j2) * zaeods(j1,j2) & + 0.5_ireals * zraods(j1,j2)) / podsf(j1,j2,j3) pusff(j1,j2,j3) = (zaeb (j1,j2) * zaeods(j1,j2) & + 0.5_ireals * zraods(j1,j2)) / podsf(j1,j2,j3) ENDDO ENDDO !------------------------------------------------------------------------------- ! b) cloudy part of layer DO j2 = ki2sc, ki2ec DO j1 = ki1sc, ki1ec podac(j1,j2,j3) = zlwoda(j1,j2) + ziwoda(j1,j2) + zaeoda(j1,j2) podsc(j1,j2,j3) = zlwods(j1,j2) + ziwods(j1,j2) & + zaeods(j1,j2) + zraods(j1,j2) podac(j1,j2,j3) = MAX( podac(j1,j2,j3), zepopd) podsc(j1,j2,j3) = MAX( podsc(j1,j2,j3), zepopd) podsc(j1,j2,j3) = MIN( podsc(j1,j2,j3), & (1.0_ireals-zepssa) * (podac(j1,j2,j3) + podsc(j1,j2,j3))) pbsfc(j1,j2,j3)= (zlwb0(j1,j2) * zlwods(j1,j2) & + ziwb0(j1,j2) * ziwods(j1,j2) + zaeb0(j1,j2) * zaeods(j1,j2) & + 0.5 * zraods(j1,j2)) / podsc(j1,j2,j3) pusfc(j1,j2,j3)= (zlwb (j1,j2) * zlwods(j1,j2) & + ziwb (j1,j2) * ziwods(j1,j2) + zaeb (j1,j2) * zaeods(j1,j2) & + 0.5 * zraods(j1,j2)) / podsc(j1,j2,j3) ENDDO ENDDO ! End of vertical loop END DO IF (ldebug) THEN print *,' podaf (j1b,j2b,1) :',podaf (j1b,j2b,1) print *,' podsf (j1b,j2b,1) :',podsf (j1b,j2b,1) print *,' pbsff (j1b,j2b,1) :',pbsff (j1b,j2b,1) print *,' pusff (j1b,j2b,1) :',pusff (j1b,j2b,1) print *,' podac (j1b,j2b,1) :',podac (j1b,j2b,1) print *,' podsc (j1b,j2b,1) :',podsc (j1b,j2b,1) print *,' pbsfc (j1b,j2b,1) :',pbsfc (j1b,j2b,1) print *,' pusfc (j1b,j2b,1) :',pusfc (j1b,j2b,1) print *,' -------------------------------------------------' ENDIF !------------------------------------------------------------------------------ ! End of the subroutine !------------------------------------------------------------------------------ END SUBROUTINE opt_so !============================================================================== !============================================================================== !+ Module procedure in "Radiation" !------------------------------------------------------------------------------ SUBROUTINE aerdis ( petah, pvdaes, pvdael, pvdaeu, pvdaed, klevp1, & ptrbga, pvobga, pstbga, paeops, paeopl, paeopu, & paeopd, ptrpt , paeadk, paeadm ) !------------------------------------------------------------------------------ ! ! Description: ! ! The module procedure aerdis provides parameters for the vertical distribution ! of aerosols (based on the original code of J.F. Geleyn (ECMWF, 4.11.82). ! ! The routine computes the values PVDAE* (* = s, l, u or d for sea, land ! urban or desert) of a surfach-normalised vertical distribution of aerosols' ! optical depth from the argument petah (vertical coordinate) at klevp1 levels. ! It also sets values for non-geograpically weighted total optical depths (at ! 55 micrometer wavelength) paeopn for the same four types and similar optical ! depths diveded by pressure for bachground well-mixed aerosols of three types ! p**bga (** = tr, vo or st for tropospheric, volcanic (stratosperic ashes) or ! stratosperic (sulfuric type)). It finally sets values for the power to be ! applied to a temperature ratio smaller than two in order to obtain an index ! one in the stratosphere and zero in the troposphere with a relatively smooth ! transistion (ptrpt), as well as for adsorption coefficients fo water to the ! three type of troposperic aerosols (paeadk) with a minimum value ( in the ! whole atmosphere) for the sum of the products paeadk by the optical depths ! divided by pressure thickness: paeadm. ! ! Method: ! ! Straightforward, equivalent heights are given in meters (8434 for the ! atmosphere) and tropospheric and stratospheric pressure boundary values ! are set at 101325 and 19330 Pascal. ! !------------------------------------------------------------------------------ ! Subroutine arguments: ! -------------------- ! Input data ! ---------- INTEGER (KIND=iintegers), INTENT (IN) :: & klevp1 ! number of model layer interfaces REAL (KIND=ireals ), INTENT (IN) :: & petah(klevp1) ! normalized vertical coordinate at half levels ! Output data ! ----------- REAL (KIND=ireals ), INTENT (OUT) :: & pvdaes(klevp1), & ! normalized vertical distribution (sea) pvdael(klevp1), & ! normalized vertical distribution (land) pvdaeu(klevp1), & ! normalized vertical distribution (urban) pvdaed(klevp1), & ! normalized vertical distrubution (desert) ptrbga , & ! b. optical depths div. by pressure (tropospheric) pvobga , & ! b. optical depths div. by pressure (volcanic) pstbga , & ! b. optical depths div. by pressure (stratospheric) paeops , & ! total opt. depths for ver. varying aerosols (sea) paeopl , & ! total opt. depths for ver. varying aerosols (land) paeopu , & ! total opt. depths for ver. varying aerosols (urban) paeopd , & ! total opt. depths for ver. varying aerosols (desert) ptrpt , & ! temperature exponent for the stratosperic definition paeadk(3) , & ! constants for definition of the quantity of water paeadm ! vapour that will be adsorbed to the dry aerosols to ! form moist aerosols ! Local parameters: ! ------------- REAL (KIND=ireals), PARAMETER :: & zhss = 8434.0_ireals/1000.0_ireals , & ! zhsl = 8434.0_ireals/1000.0_ireals , & ! zhsu = 8434.0_ireals/1000.0_ireals , & ! zhsd = 8434.0_ireals/3000.0_ireals ! !- End of header !============================================================================== !------------------------------------------------------------------------------ ! Begin Subroutine aerdis !------------------------------------------------------------------------------ pvdaes(1) = 0.0_ireals pvdael(1) = 0.0_ireals pvdaeu(1) = 0.0_ireals pvdaed(1) = 0.0_ireals IF(petah(1).NE.0.) THEN pvdaes(1) = petah(1)**zhss pvdael(1) = petah(1)**zhsl pvdaeu(1) = petah(1)**zhsu pvdaed(1) = petah(1)**zhsd END IF pvdaes(2:klevp1) = petah(2:klevp1)**zhss pvdael(2:klevp1) = petah(2:klevp1)**zhsl pvdaeu(2:klevp1) = petah(2:klevp1)**zhsu pvdaed(2:klevp1) = petah(2:klevp1)**zhsd ptrbga = 0.03_ireals / (101325.0_ireals - 19330.0_ireals) pvobga = 0.007_ireals / 19330.0_ireals pstbga = 0.045_ireals / 19330.0_ireals paeops = 0.05_ireals paeopl = 0.2_ireals paeopu = 0.1_ireals paeopd = 1.9_ireals ptrpt = 30.0_ireals paeadk(1) = 0.3876E-03_ireals paeadk(2) = 0.6693E-02_ireals paeadk(3) = 0.8563E-03_ireals paeadm = 2.6000E-10_ireals !------------------------------------------------------------------------------ ! End of the subroutine !------------------------------------------------------------------------------ END SUBROUTINE aerdis !============================================================================== !============================================================================== SUBROUTINE calc_rad_corrections (thetain, phi, horizonte, smu0, rlati, & rloni, deksini, dekcosi, zeit0i, fcor, & idim, jdim, nhordim, isc, iec, jsc, jec, idbg) !------------------------------------------------------------------------------ ! ! Description: ! Compute parameters swdir_cor needed for the grid scale topographic ! correction of direct solar radiation at the surface. ! If correction option is chosen, this subroutine is called before fesft. ! Following Mueller and Sherrer (2005), MWR ! !------------------------------------------------------------------------------ ! Variables of the parameter list INTEGER (KIND=iintegers), INTENT (IN) :: & idim, jdim, nhordim, & ! field dimensions isc, iec, jsc, jec, & ! start and end indices for computation idbg ! for debug output REAL (KIND=ireals ), INTENT (IN) :: & thetain (idim,jdim), & ! slope angle phi (idim,jdim), & ! slope aspect horizonte(idim,jdim,nhordim), & ! horizont rlati (idim,jdim), & ! latitude (geogr) [rad] rloni (idim,jdim), & ! longitude(geogr) [rad] smu0 (idim,jdim) ! sun zenith angle REAL (KIND=ireals ), INTENT (IN) :: & deksini, & ! sin of sun declination angle dekcosi, & ! cos of sun declination angle zeit0i !T.R. ! Output of the routine REAL (KIND=ireals ), INTENT (OUT) :: & fcor (idim,jdim) ! Local parameters and variables REAL (KIND=ireals), PARAMETER :: & zepemu = 1.0E-07, & rtod = 57.2957795 ! radiantas to degrees REAL (KIND=ireals) :: & zeitrad, & ! T.R. phi_s, & ! phi_sun (idim,jdim), & ! sun azimuth angle [rad] theta_sun(idim,jdim), & ! sun elevation angle [rad] theta (idim,jdim), & ! theta for computation x1,x2,ha_sun ! INTEGER (KIND=iintegers) :: & ii,shadow,i,k,j LOGICAL :: & lshade, lslope_aspect !switches !------------------------------------------------------------------------------ lshade = .TRUE. lslope_aspect = .TRUE. DO j = jsc, jec DO i = isc, iec ! sun elevation angle theta_sun(i,j) = ASIN(smu0(i,j)) ! sun azimuth angle zeitrad = zeit0i + rloni(i,j) !T.R. x1 = dekcosi * SIN(zeitrad) / COS(theta_sun(i,j)) x2 = ( SIN(rlati(i,j)) * dekcosi * COS(zeitrad) - & COS(rlati(i,j)) * deksini ) / COS(theta_sun(i,j)) IF (x2 < -1) x2 = -1 IF (x2 > 1) x2 = 1 phi_s = COS(x2) IF (x1 < 0) phi_s = - phi_s phi_sun(i,j) = phi_s + pi ! sun elevation angle corrected by refraction (enpiric formula, A.H.Siemer(1988)) theta_sun(i,j) = theta_sun(i,j) + (1.569000_ireals - theta_sun(i,j)) / & (185.5_ireals + 3620.0_ireals * theta_sun(i,j)) ! night or day IF (theta_sun(i,j) < 0.0) THEN theta_sun(i,j) = 0.0_ireals ENDIF ! compute shadow ! the horizon has a spatial resolution of 360/nhordim degrees. a distance weighted ! linear interpolation is done between the two neighboring points. ii = INT(rtod*phi_sun(i,j)/(360.0_ireals/nhordim)) IF (ii >= nhordim) THEN ii = nhordim - 1 ENDIF k = MOD(ii+1,24) IF (horizonte(i,j,k+1) > 90.0_ireals .OR. horizonte(i,j,k+1) < 0.0_ireals) THEN PRINT *,'!!ERROR!!, horizon_angle > 90deg or < 0deg',horizonte(i,j,k+1) !US there shall be no stop in a parallel program!!! STOP ENDIF ha_sun = (horizonte(i,j,k+1)*(rtod*phi_sun(i,j)-15*ii)+ & horizonte(i,j,ii+1)*(15*(ii+1)-rtod*phi_sun(i,j)))/15.0 ! compute shadowmask shadow = 1 IF (rtod*theta_sun (i,j) < ha_sun .AND. lshade) THEN shadow = 0 ENDIF ! compute fcor ! slope angle and aspect switched off IF (.NOT. lslope_aspect) THEN theta(i,j) = 0.0_ireals ELSE theta(i,j) = thetain(i,j) ENDIF IF (theta_sun(i,j) > 0.01_ireals) THEN ! Mueller and Scherrer (2005) formula (MWR) ! fcor(i,j) = shadow * (1 + ( tan(theta(i,j)) / tan(theta_sun(i,j)) )*& ! cos( phi_sun(i,j) - phi(i,j)) ) ! New formula (lower correction, theoretically correct derived) fcor(i,j) = shadow * ( COS(theta(i,j)) + (SIN(theta(i,j))/TAN(theta_sun(i,j)) )*& COS( phi_sun(i,j) - phi(i,j)) ) ELSE fcor(i,j) = 1.0 ENDIF ! Consistency check to avoid negative corrections: ! active in situations with low sun elevation (slope angles > sun elevation) ! when the slope aspect is greater than the daily maxima or smaller than the ! daily minima of the sun azimuth angle (during the sunshine time, a kind ! of self shading effect). IF (fcor(i,j) < 0.0_ireals) THEN fcor(i,j) = 0.0 ENDIF IF ( (idbg > 20) .AND. (i == 4) ) THEN PRINT *, ' calc_rad_corrections: debug point: ', i, j PRINT *, ' deksini, dekcosi, zeitrad = ', deksini, dekcosi, zeitrad PRINT *, ' rlat, rlon, theta, phi, smu0 = ', rlati(i,j), rloni(i,j), & theta(i,j), phi(i,j), smu0(i,j) PRINT *, ' ii, k, horizon = ', ii, k, horizonte(i,j,ii+1), horizonte(i,j,k+1) PRINT *, ' ha_sun, theta_sun, phi_sun = ', ha_sun, rtod*theta_sun(i,j), & rtod*phi_sun(i,j) IF ( (shadow == 0) .AND. (theta_sun(i,j) > 0.01_ireals) ) THEN PRINT *, ' calc_rad_corrections: ', 'DAY-SHADOW' ENDIF IF ( (shadow == 1) .AND. (theta_sun(i,j) > 0.01_ireals) ) THEN PRINT *, ' calc_rad_corrections: ', 'DAY-SUN' ENDIF IF (theta_sun(i,j) <= 0.01_ireals ) then PRINT *, ' calc_rad_corrections: ', 'NIGHT' ENDIF PRINT *, ' calc_rad_corrections: fcor ', fcor(i,j) ENDIF ENDDO ENDDO END SUBROUTINE calc_rad_corrections !============================================================================== END MODULE src_radiation
bldsva/intf_oas3/cosmo4_21/tsmp/src_radiation.f90
C %W% %G% subroutine hotchg C process /CHANGE_BUS_TYPES commands. include 'ipfinc/parametr.inc' include 'ipfinc/alpha.inc' include 'ipfinc/arcntl.inc' include 'ipfinc/area.inc' include 'ipfinc/blank.inc' include 'ipfinc/branch.inc' include 'ipfinc/bus.inc' include 'ipfinc/cbsorc.inc' include 'ipfinc/cbus.inc' include 'ipfinc/coment.inc' include 'ipfinc/ecvar.inc' include 'ipfinc/ikk.inc' include 'ipfinc/intbus.inc' include 'ipfinc/lfiles.inc' include 'ipfinc/lndpcp.inc' include 'ipfinc/ordsta.inc' include 'ipfinc/prt.inc' include 'ipfinc/qsdup.inc' include 'ipfinc/slnopt.inc' include 'ipfinc/snput.inc' include 'ipfinc/tbx.inc' include 'ipfinc/tran.inc' include 'ipfinc/xdata.inc' include 'ipfinc/basval.inc' include 'ipfinc/miscfile.inc' common /is_batch / is_batch integer find_bus, error, findex, ptr, num_delltcs, offset, & inpold character bs_code*1, bus1*8, word(100)*60, capital*132, & bigbuf*512, comprs*512, tag*24, word2(10)*60, & tempfilename*60 logical found, chgbrn, plist, finished_1, finished_2 real cv(1), ci(1), cz(1) external find_bus tbx_loaded = 0 xdt_flag = .false. plist = .true. c*** Fix for base cases prior to version 4 (lskp is now set in rddtai) if ( lskp .ne. 1 .and. basval(8)(1:2) .eq. 'PF') then write (errbuf(1), 11) 11 format(' CHANGE_BUS_TYPES is illegal with vintage PF60xx ', & 'base cases (history files) --') write (errbuf(2), 12) 12 format(' unless the case is resolved with the new IPF/BPF', & ' version.') write (errbuf(3), 13) 13 format(' / CHANGE_BUS_TYPES command ignored.') if (is_batch .eq. 0) then call prterx ('E',3) else call prterx ('F',3) endif return elseif ( lskp .ne. 1) then write (errbuf(1), 21) 21 format(' CHANGE_BUS_TYPES is invalid with a failed solution in & the base case history file.') write (errbuf(2), 22) 22 format(' Regenerate the base case to start with a solved base c &ase') write (errbuf(3), 23) 23 format(' / CHANGE_BUS_TYPES command ignored.') if (is_batch .eq. 0) then call prterx ('E',3) else call prterx ('F',3) endif return endif chgbrn = .false. num_delltcs = 0 C / CHANGE_BUS_TYPES, BQ=B, LTC=OFF, AREAS=<area_1,...>, C BG=BQ, C BG=B , C BQ=BF , C BT=B , C BX=B , C BX=BF, C ZONES=<zone_1,...> C LIST=ON C > EXCLUDE_BUSES C B bus_name bkv C B bus_name bkv C C > LINE_DROP_COMPENSATORS C BG bus_name bkv, ##% C BG bus_name bkv, ##% C C > REACTIVE_COMPENSATION C BG bus_name bkv, ##%, ## C BG bus_name bkv, ##%, ## call space (1) write (outbuf,90 ) buf(1:80) 90 format (' CHANGE_BUS_TYPES text: (',a,')') call prtout (1) inpold = inp buf = capital(buf) if (index (buf,'CHANGE_BUS') .ne. 0 .or. 1 index (buf,'CHANGEBUS') .ne. 0) then C C Check for and concatenate continuation records. C bigbuf = comprs (buf) 298 last = lastch (bigbuf) if (bigbuf(last:last) .eq. '-') then read (inp, 260, end=261) buf 260 format (a) call space (1) write (outbuf,90) buf(1:80) call prtout (1) buf = capital(buf) bigbuf(last:) = comprs(buf) go to 298 261 buf = '( END ) HOTCHG' card = buf(1:1) endif call uscan(bigbuf, word, nwrd, '=', ' ,/\\<>()') jwrd = nwrd C C Initialize IKK array: C C (1,*) (not used) C (2,*) = 0 : bus is not eligible for type change. C 1 : bus is eligible for type change. C 2 : (generation is dropped, therefore ineligible C for allocation) C (3,*) = I (cross index to TBX array) C (4,*) = NC (forced BG -> BG retention because of line drop C compensation) C (5,*) = J (LTC index of controlled bus) C do nb = 1, ntot ikk(1,nb) = 0 ikk(2,nb) = 1 ikk(3,nb) = 0 ikk(4,nb) = 0 ikk(5,nb) = 0 enddo c c Load LINE_DROP_COMPENSATION from any prior /CHANGE_BUS_TYPE c do i = 1, numldc nb = lndpcp(1,i) ikk(4,nb) = i enddo do i = 1, ntotb ltyp = tbx(1,i) if (ltyp .lt. 10) then nb = tbx(2,i) if (ordtbx .eq. 2) nb = opt2inp(nb) ikk(3,nb) = i endif enddo do i = 1, ntota ltyp = mod (ltran(10,i), 10) if (ltyp .eq. 1 .or. ltyp .eq. 2 .or. ltyp .eq. 4) then kc = ltran(2,i) if (kc .eq. -1) then nb = ltran(1,i) else if (kc .eq. -2) then nb = ltran(9,i) else if (kc .gt. 0) then nb = kc else nb = ltran(1,i) endif C C If NB is already controlled by a different LTC, C flag the opposite terminal as LTC controlled. C if (ikk(5,nb) .eq. 0) then else if (nb .eq. ltran(1,i)) then nb = ltran(9,i) else nb = ltran(1,i) endif if (ordltc .eq. 2) nb = opt2inp(nb) ikk(5,nb) = i else nb = ltran(1,i) C C If NB is already controlled by a different LTC, C flag the opposite terminal as LTC controlled. C if (ikk(5,nb) .ne. 0) then nb = ltran(9,i) endif if (ordltc .eq. 2) nb = opt2inp(nb) ikk(5,nb) = i endif enddo C C Search for FILE = <file_name> C i = 1 finished_1 = (i .ge. jwrd) do while (.not. finished_1) if (word(i)(1:4) .eq. 'FILE') then C C Check for "=" separator. C if (word(i+1) .ne. '=') then last = lastch (word(i)) write (errbuf(1), 84) word(i)(1:last) 84 format('Keyword (',a,') in / CHANGE_BUS_TYPES ', & 'text is not followed with an "=" sign.') call prterx ('W', 1) next = i + 1 else next = i + 2 endif finished_1 = .true. tempfilename = word(next) inpold = inp inp = lunscr1 ierror = 0 call opnfil(inp, tempfilename, ierror) if (ierror .ne. 0) inp = inpold offset = next - i + 1 do j = next+1, jwrd word(j-offset) = word(j) enddo jwrd = jwrd - offset nwrd = jwrd else i = i + 1 finished_1 = (i .ge. jwrd) endif enddo C C Search for LIST = ON C i = 1 finished_1 = (i .ge. jwrd) do while (.not. finished_1) if (word(i)(1:4) .eq. 'LIST') then C C Check for "=" separator. C if (word(i+1) .ne. '=') then last = lastch (word(i)) write (errbuf(1), 84) word(i)(1:last) call prterx ('W', 1) next = i + 1 else next = i + 2 endif finished_1 = .true. if (word(next) .eq. 'OFF') plist = .false. offset = next - i + 1 do j = next+1, jwrd word(j-offset) = word(j) enddo jwrd = jwrd - offset nwrd = jwrd else i = i + 1 finished_1 = (i .ge. jwrd) endif enddo C C Search for AREAS = <area_1,...> C do i = 1, jwrd if (word(i)(1:4) .eq. 'AREA') then nwrd = i - 1 C C Check for "=" separator. C if (word(i+1) .ne. '=') then last = lastch (word(i)) write (errbuf(1), 84) word(i)(1:last) call prterx ('W', 1) next = i + 1 else next = i + 2 endif do nb = 1, ntot ikk(2,nb) = 0 enddo do j = next, jwrd do k = 1, ntotc if (arcnam(k) .eq. word(j)) then do nb = 1, ntot if (jarzn(nb) .eq. k) then ikk(2,nb) = 1 endif enddo go to 350 endif enddo last = lastch (word(j)) write (errbuf(1), 340) word(j)(1:last) 340 format('Interchange area (',a,') is not in system') call prterx ('W', 1) 350 continue enddo go to 410 else if (word(i)(1:4) .eq. 'ZONE') then nwrd = i - 1 C C Check for "=" separator. C if (word(i+1) .ne. '=') then last = lastch (word(i)) write (errbuf(1), 84) word(i)(1:last) call prterx ('W', 1) next = i + 1 else next = i + 2 endif do nb = 1, ntot ikk(2,nb) = 0 enddo do j = next, jwrd found = .false. do nb = 1, ntot if (zone(nb) .eq. word(j)) then ikk(2,nb) = 1 found = .true. endif enddo if (.not.found) then last = lastch (word(j)) write (errbuf(1), 380) word(j)(1:last) 380 format('Zone (',a,') is not in system') call prterx ('W', 1) endif enddo go to 410 endif enddo 410 continue C C Read next card, check for >EXCLUDE qualifier. C 10250 read (inp, 260, end=10450) buf call space (1) write (outbuf, 90) buf(1:80) call prtout (1) finished_1 = .false. do while (.not. finished_1) card = buf(1:1) if (card .eq. '.') then read (inp, 260, end=10450) buf write (outbuf, 90) buf(1:80) call prtout (1) else if (card .eq. '>') then if (findex(buf(2:10),'EXCLUDE') .ne. 0) then C C > EXCLUDE_BUSSES < C finished_2 = .false. do while (.not. finished_2) read (inp, 260, end=10450) buf card = buf(1:1) call space (1) write (outbuf, 90) buf(1:80) call prtout (1) if (card .eq. '.') then else if (card .eq. 'B') then read (buf, 10280) bus1, base1 10280 format (bz, t7, a8, f4.0) nb = find_bus (bus1, base1) if (nb .le. 0) then write (errbuf(1),10290) bus1, base1 10290 format ('EXCLUDE_BUS (', a8, f6.1, & ') is not in system.') call prterx ('W', 1) else ikk(2,nb) = 0 endif else finished_2 = .true. endif enddo else if (findex(buf(2:10),'LINE') .ne. 0 .or. & findex(buf(2:10),'REACTIVE') .ne. 0) then C C > LINE_DROP_COMPENSATORS C > REACTIVE_COMPENSATION C call uscan(buf(2:), word2, nwrd2, '=', ' ,') tag = word2(1) last = lastch (tag) finished_2 = .false. do while (.not. finished_2) read (inp, 260, end=10450) buf card = buf(1:1) call space (1) write (outbuf, 90) buf(1:80) call prtout (1) if (card .eq. '.') then else if (card .eq. 'B') then read (buf, 10294) bus1, base1 10294 format (bz, t7, a8, f4.0) nb = find_bus (bus1, base1) error = 0 if (nb .le. 0) then write (errbuf(1), 10296) tag(1:last), bus1, base1 10296 format (a, ' bus (', a8, f6.1, 1 ') is not in system.') call prterx ('W', 1) error = 1 else if (kbsdta(1,nb) .eq. 8) then ikk(4,nb) = numldc + 1 mb = kbsdta(13,nb) if (mb .eq. 0 .or. mb .eq. nb) then ptr = kbsdta(16,nb) mb = ky(ptr) else ptr = kbsdta(16,nb) found = .false. do while (ptr .gt. 0 .and. .not. found) if (ky(ptr) .eq. mb) then found = .true. else ptr = brnch_nxt(ptr) endif enddo if (.not. found) then write (errbuf(1), 10300) tag(1:last), bus1, & base1, bus(mb), base(mb) 10300 format (a, ' bus (', a8, f6.1, 1 ') is controlling a remote bus (', a8, 2 f6.1, ')') call prterx ('W', 1) error = 1 endif endif else call typno (bs_code, kbsdta(1,nb)) write (errbuf(1), 10304) tag(1:last), bus1, & base1, 'B'//bs_code 10304 format (a, ' (', a8, f6.1, 1 ') is illegal type "', a, '".') call prterx ('W', 1) error = 1 endif if (error .eq. 0) then call uscan(buf(20:), word2, nwrd2, '=', ' ,%') pct = ftn_atof (word2(1)) if (pct .le. 0.0 .or. pct .gt. 100.0) then write (errbuf(1), 10310) tag(1:last), bus1, & base1, pct 10310 format (a, ' bus (', a8, f6.1, & ') has an unconventional percentage (', f6.1, & ')') call prterx ('W', 1) endif do i = 1, numldc if (lndpcp(1,i) .eq. nb) then write (errbuf(1), 10312) tag(1:last), bus1, & base1 10312 format ('Duplicate ', a, ' buses (', & a8, f6.1, ') ignored.)') call prterx ('W', 1) go to 10318 endif enddo if (numldc .ge. 20) then write (errbuf(1), 10316) 20, tag(1:last), bus1, & base1 10316 format ('More than ', i3, 1x, a, & ' records. Bus (', a8, f6.1, ') ignored.)') call prterx ('W', 1) else numldc = numldc + 1 lndpcp(1,numldc) = nb drppct(numldc) = pct / 100.0 kt = inp2opt(nb) vk = dsqrt (e(kt) ** 2 + f(kt) ** 2) if (tag(1:4) .eq. 'LINE') then lndp_type(numldc) = 1 lndpcp(2,numldc) = mb c c Compute voltage c mt = inp2opt(mb) vm = dsqrt (e(mt) ** 2 + f(mt) ** 2) vmax_ldc(numldc) = drppct(numldc) * vk & + (1.0 - drppct(numldc)) * vm vmin_ldc(numldc) = vmax_ldc(numldc) xc_ldc(numldc) = 0.0 else lndp_type(numldc) = 2 lndpcp(2,numldc) = 0 xbase = ftn_atof (word2(2)) if (xbase .eq. 0.0) xbase = bmva xc_ldc(numldc) = 0.01 * pct * bmva / xbase cz(1) = xc_ldc(numldc) ci(1) = qnetu(kt) / vk cv(1) = vk - ci(1) * cz(1) vmax_ldc(numldc) = cv(1) vmin_ldc(numldc) = cv(1) endif endif endif else finished_2 = .true. endif 10318 continue enddo else write (errbuf(1), 10430) buf(1:20) 10430 format('Unrecognized /CHANGE_BUS_TYPE command (', 1 a,').') call prterx ('W', 1) endif else finished_1 = .true. endif enddo go to 10453 10450 buf = '( END ) HOTCHG' card = buf(1:1) 10453 if (inp .ne. inpold) then inp = inpold read (inp, 260, end=10451) buf go to 10452 10451 buf = '( END ) HOTCHG' 10452 card = buf(1:1) endif C C Write header C call forbtm write (outbuf, 10454) 10454 format (t53, ' Summary of /CHANGE_BUS_TYPES Conversion ') call shdlod(1) write (outbuf, 411) 411 format ('0BUS', t18, 'LTC disabled?', t34, 'Zone', 1 t40, 'Bus Type', t50, '-- Shunt (MVAR) --', 2 t72, '-- Generation (MVAR) --', 3 t98, '-- Voltage Original Final --') call shdlod(2) write (outbuf, 412) 412 format (t40, 'old new', t48, ' Orig Final Removed', 1 t72, ' Orig Min Max Removed', 2 t98, ' Vact Vmin Vmax Vmin Vmax') call shdlod(3) outbuf = ' ' call shdlod(4) call shdlod(5) call fortop C C First pass. Convert type BG LINE_DROP_COMPENSATOR and type C BG REACTIVE_COMPSENSATION generators to type BG, controlling C themselves. C do i = 1, numldc nb = lndpcp(1,i) if (ikk(4,nb) .ne. 0) then kt = inp2opt(nb) jtbx = ikk(3,nb) jltc = ikk(5,nb) kbsdta(13,nb) = nb if (ordtbx .eq. 1) then tbx(8,jtbx) = nb else tbx(8,jtbx) = kt endif C C Reset type conversion flag to prevent duplicate C type change. C ikk(2,nb) = 0 endif enddo do i = 2, nwrd, 3 if (word(i) .eq. 'BQ') then C C Check for "=" separator. C if (word(i+1) .ne. '=') then last = lastch (word(i)) write (errbuf(1), 84) word(i)(1:last) if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif endif C C BQ --> B* unconditionally. C BQ --> B if PGEN, QGEN, or QGEN_limits = 0. C BQ --> BQ otherwise. C if (word(i+2) .eq. 'B ' .or. word(i+2) .eq. 'B*') then do nb = 1, ntot if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 7) 1 then kt = inp2opt(nb) jtbx = ikk(3,nb) jltc = ikk(5,nb) qmach = busdta(9,nb) - busdta(10,nb) if (abs (qmach) .le. 0.5 .or. 1 word(i+2) .eq. 'B*') then call chgbty (nb, 1, jtbx, jltc, plist) else call chgbty (nb, 7, jtbx, jltc, plist) endif endif enddo else if (word(i+2) .eq. 'BF' .or. word(i+2) .eq. 'BF*') 1 then C C BQ --> BF* unconditionally. C BQ --> BF if PGEN, QGEN, or QGEN_limits = 0. C BQ --> BQ otherwise. C do nb = 1, ntot if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 7) 1 then kt = inp2opt(nb) jtbx = ikk(3,nb) jltc = ikk(5,nb) vksq = e(kt) ** 2 + f(kt) ** 2 qmach = busdta(9,nb) - busdta(10,nb) if (abs (qmach) .le. 0.5 .or. 1 word(i+2) .eq. 'BF*') then call chgbty (nb, 1, jtbx, jltc, plist) else call chgbty (nb, 7, jtbx, jltc, plist) endif endif enddo else write (errbuf(1), 420) word(i), word(i+2) 420 format('Illegal bus type conversion (', a2,') > (', 1 a2,') ignored') if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif go to 440 endif else if (word(i) .eq. 'BG') then C C BG --> BQ* unconditionally. C BG --> BQ if PGEN, QGEN, or QGEN_limits = 0. C C Check for "=" separator. C if (word(i+1) .ne. '=') then last = lastch (word(i)) write (errbuf(1), 84) word(i)(1:last) if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif endif if (word(i+2) .eq. 'BQ' .or. word(i+2) .eq. 'BQ*') then do nb = 1, ntot if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 8) 1 then kt = inp2opt(nb) jtbx = ikk(3,nb) jltc = ikk(5,nb) qmach = busdta(9,nb) - busdta(10,nb) if (abs (qmach) .le. 0.5 .or. 1 word(i+2) .eq. 'BQ*') then call chgbty (nb, 1, jtbx, jltc, plist) else call chgbty (nb, 7, jtbx, jltc, plist) endif endif enddo else if (word(i+2) .eq. 'B ' .or. word(i+2) .eq. 'B*') 1 then C C BG --> B* unconditionally. C BG --> B if PGEN, QGEN, or QGEN_limits = 0. C do nb = 1, ntot if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 1) 1 then kt = inp2opt(nb) jtbx = ikk(3,nb) jltc = ikk(5,nb) qmach = busdta(9,nb) - busdta(10,nb) if (abs (qmach) .le. 0.5 .or. 1 word(i+2) .eq. 'BQ*') then call chgbty (nb, 1, jtbx, jltc, plist) endif endif enddo else if (word(i+2) .eq. 'BF' .or. word(i+2) .eq. 'BF*') 1 then C C BG --> BF* unconditionally. C BG --> BF if PGEN, QGEN, or QGEN_limits = 0. C do nb = 1, ntot if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 7) 1 then kt = inp2opt(nb) jtbx = ikk(3,nb) jltc = ikk(5,nb) qmach = busdta(9,nb) - busdta(10,nb) if (abs (qmach) .le. 0.5 .or. 1 word(i+2) .eq. 'BQ*') then call chgbty (nb, 13, jtbx, jltc, plist) endif endif enddo else write (errbuf(1), 420) word(i), word(i+2) if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif go to 440 endif else if (word(i) .eq. 'BT') then C C BT --> B C C Check for "=" separator. C if (word(i+1) .ne. '=') then last = lastch (word(i)) write (errbuf(1), 84) word(i)(1:last) if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif endif if (word(i+2) .eq. 'B ') then C C Set flag to compress BRNCH array. C do nb = 1, ntot if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 10) 1 then jtbx = ikk(3,nb) jltc = ikk(5,nb) if (jltc .eq. 0) then write (errbuf(1), 10425) bus(nb), base(nb), 1 word(i), word(i+2) 10425 format(' Bus ', a8, f6.1, & ' type is changed from (', a2,') to (', & a2, ') but has no LTC control.') call prterx ('W', 1) else chgbrn = .true. call chgbty (nb, -1, jtbx, jltc, plist) endif endif enddo else write (errbuf(1), 420) word(i), word(i+2) if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif go to 440 endif else if (word(i) .eq. 'BX') then C C BX --> B C BX --> B* C C Check for "=" separator. C if (word(i+1) .ne. '=') then last = lastch (word(i)) write (errbuf(1), 84) word(i)(1:last) if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif endif if (word(i+2) .eq. 'B ' .or. word(i+2) .eq. 'B*') then do nb = 1, ntot if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 11) 1 then jtbx = ikk(3,nb) jltc = ikk(5,nb) call chgbty (nb, 1, jtbx, jltc, plist) endif enddo else if (word(i+2) .eq. 'BF' .or. word(i+2) .eq. 'BF*') 1 then C C BX --> BF C BX --> BF* C do nb = 1, ntot if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 11) 1 then jtbx = ikk(3,nb) jltc = ikk(5,nb) call chgbty (nb, 13, jtbx, jltc, plist) endif enddo else write (errbuf(1), 420) word(i), word(i+2) if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif go to 440 endif else if (word(i) .eq. 'LTC') then C C LTC --> OFF C C C Check for "=" separator. C if (word(i+1) .ne. '=') then last = lastch (word(i)) write (errbuf(1), 84) word(i)(1:last) if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif endif if (word(i+2) .eq. 'OFF') then C C Set flag to compress BRNCH array. C do nb = 1, ntot if (ikk(2,nb) .eq. 1 .and. ikk(5,nb) .gt. 0) then jtbx = ikk(3,nb) ktyp = kbsdta(1,nb) jltc = ikk(5,nb) C C Exclude d-c commutating LTC's. C Changing a bus type to itself is a magic C code to delete a connected LTC. C if (ktyp .ne. 5 .and. ktyp .ne. 12) then chgbrn = .true. num_delltcs = num_delltcs + 1 call chgbty (nb, -ktyp, jtbx, jltc, plist) endif endif enddo else write (errbuf(1), 10427) word(i), word(i+2) 10427 format('Illegal LTC option (', a3,') > (', 1 a6,') ignored') if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif go to 440 endif else write (errbuf(1), 430) word(i), word(i+2) 430 format('Unrecognized bus type conversion (', a2,') > (', 1 a2,') ignored') if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif go to 440 endif 440 continue enddo else write (errbuf(1),180 ) 180 format('Illegal / CHANGE_BUS_TYPES command.') errbuf(2) = ' ' write (errbuf(3),182) buf(1:80) 182 format (' (',a80,')') if (is_batch .eq. 0) then call prterx ('E',1) else call prterx ('F',1) endif return endif if (num_delltcs .gt. 0) then write (outbuf, 736) num_delltcs/2 736 format ('0 / CHANGE_BUS_TYPES has deleted ', i3, 1 ' LTC''s from system') endif outbuf = ' ' call shdlod (1) call shdlod (2) call shdlod (3) call shdlod (4) call shdlod (5) outbuf = '0End of /CHANGE_BUS_TYPE' call prtout(1) call forbtm return end
ipf/hotchg.f
module multinomial_diffusion_module use ml_layout_module use define_bc_module use bc_module use multifab_physbc_module use BoxLibRNGs use bl_rng_module use bl_random_module use probin_common_module, only: n_cells use probin_reactdiff_module, only: nspecies, D_Fick, cross_section, use_bl_rng implicit none private public :: multinomial_diffusion contains ! advances n_old to n_new using multinomial diffusion subroutine multinomial_diffusion(mla,n_old,n_new,diff_coef_face, & dx,dt,the_bc_tower) type(ml_layout), intent(in ) :: mla type(multifab) , intent(in ) :: n_old(:) type(multifab) , intent(inout) :: n_new(:) type(multifab) , intent(in ) :: diff_coef_face(:,:) real(kind=dp_t), intent(in ) :: dx(:,:),dt type(bc_tower) , intent(in ) :: the_bc_tower ! local integer :: n,nlevs,i,dm,spec type(bl_prof_timer),save :: bpt nlevs = mla%nlevel dm = mla%dim call build(bpt,"multinomial_diffusion") ! set new state to zero everywhere, including ghost cells do n=1,nlevs call multifab_setval(n_new(n),0.d0,all=.true.) end do ! copy old state into new in valid region only do n=1,nlevs call multifab_copy_c(n_new(n),1,n_old(n),1,nspecies,0) end do ! update with multinomial diffusion, each grid in isolation call multinomial_diffusion_update(mla,n_new,diff_coef_face,dx,dt,the_bc_tower) ! call sum_boundary to deal with grid boundaries do n=1,nlevs call multifab_sum_boundary(n_new(n),1) end do ! properly fill n_new ghost cells do n=1,nlevs call multifab_fill_boundary(n_new(n)) call multifab_physbc(n_new(n),1,scal_bc_comp,nspecies, & the_bc_tower%bc_tower_array(n),dx_in=dx(n,:)) end do call destroy(bpt) end subroutine multinomial_diffusion subroutine multinomial_diffusion_update(mla,n_new,diff_coef_face,dx,dt,the_bc_tower) type(ml_layout), intent(in ) :: mla type(multifab) , intent(inout) :: n_new(:) ! Old state on input, new state on output in valid region, or increment in ghosts type(multifab) , intent(in ) :: diff_coef_face(:,:) real(kind=dp_t), intent(in ) :: dx(:,:),dt type(bc_tower) , intent(in ) :: the_bc_tower ! local integer :: n,nlevs,i,dm,ng_n,ng_d real(kind=dp_t) :: dv ! Cell volume integer :: lo(mla%dim), hi(mla%dim) real(kind=dp_t), pointer :: np(:,:,:,:) real(kind=dp_t), pointer :: dxp(:,:,:,:) real(kind=dp_t), pointer :: dyp(:,:,:,:) real(kind=dp_t), pointer :: dzp(:,:,:,:) nlevs = mla%nlevel dm = mla%dim ng_n = n_new(1)%ng ng_d = diff_coef_face(1,1)%ng dv = product(dx(1,1:dm))*cross_section ! cannot use OpenMP with tiling since each cell is responsible for updating ! cells possibly outside of its file. OpenMP could be added at the k loop level ! with reduction tricks do n=1,nlevs do i=1,nfabs(n_new(n)) np => dataptr(n_new(n),i) dxp => dataptr(diff_coef_face(n,1),i) dyp => dataptr(diff_coef_face(n,2),i) lo = lwb(get_box(n_new(n),i)) hi = upb(get_box(n_new(n),i)) select case (dm) case (2) if(n_cells(2)==1) then ! This is really a 1D domain ! Note the in this case the second dimension of dxp has bounds of (0:0) call multinomial_diffusion_update_1d(np(:,0,1,:),ng_n, & dxp(:,0,1,:),ng_d, & lo(1),hi(1),dx(n,1),dt,dv) else call multinomial_diffusion_update_2d(np(:,:,1,:),ng_n, & dxp(:,:,1,:),dyp(:,:,1,:),ng_d, & lo,hi,dx(n,:),dt,dv) end if case (3) dzp => dataptr(diff_coef_face(n,3),i) call multinomial_diffusion_update_3d(np(:,:,:,:),ng_n, & dxp(:,:,:,:),dyp(:,:,:,:),dzp(:,:,:,:),ng_d, & lo,hi,dx(n,:),dt,dv) end select end do end do end subroutine multinomial_diffusion_update ! For 1D we want to be more efficient by sampling only two binomials instead of 4 subroutine multinomial_diffusion_update_1d(n_new,ng_n,diffx,ng_d,lo,hi,dx,dt,dv) integer , intent(in ) :: lo,hi,ng_n,ng_d real(kind=dp_t), intent(inout) :: n_new(lo-ng_n:,:) ! Old state on input, new state on output real(kind=dp_t), intent(in) :: diffx(lo-ng_d:,:) real(kind=dp_t), intent(in ) :: dx,dt,dv ! local integer :: i,j,comp,n_total,n_sum,n_change integer, allocatable :: cell_update(:,:) ! Avoid stack overflows and put this on the heap instead integer, parameter :: n_faces=2 integer :: fluxes(n_faces) ! Number of particles jumping out of this cell to each of the neighboring cells real(kind=dp_t) :: probabilities(n_faces) allocate(cell_update(lo-1:hi+1,nspecies)) cell_update = 0.d0 do comp=1,nspecies do i=lo,hi probabilities = (/diffx(i, comp)*dt/dx**2, & diffx(i+1,comp)*dt/dx**2/) if(sum(probabilities)>1.0_dp_t) & call bl_error("Explicit CFL stability limit violated for multinomial diffusion") if (use_bl_rng) then call MultinomialRNG(samples=fluxes, n_samples=n_faces, & N=max(0, nint(n_new(i,comp)*dv)), p=probabilities, & engine=rng_eng_diffusion%p) else call MultinomialRNG(samples=fluxes, n_samples=n_faces, & N=max(0, nint(n_new(i,comp)*dv)), p=probabilities) end if ! lo-x face cell_update(i ,comp) = cell_update(i ,comp) - fluxes(1) cell_update(i-1,comp) = cell_update(i-1,comp) + fluxes(1) ! hi-x face cell_update(i ,comp) = cell_update(i ,comp) - fluxes(2) cell_update(i+1,comp) = cell_update(i+1,comp) + fluxes(2) end do end do ! increment n_new for all components but remember to convert back to number densities from number of molecules n_new(lo-1:hi+1,1:nspecies) = n_new(lo-1:hi+1,1:nspecies) + & cell_update(lo-1:hi+1,1:nspecies) / dv deallocate(cell_update) end subroutine multinomial_diffusion_update_1d subroutine multinomial_diffusion_update_2d(n_new,ng_n,diffx,diffy,ng_d,lo,hi,dx,dt,dv) integer , intent(in ) :: lo(:),hi(:),ng_n,ng_d real(kind=dp_t), intent(inout) :: n_new(lo(1)-ng_n:,lo(2)-ng_n:,:) ! Old state on input, new state on output real(kind=dp_t), intent(in) :: diffx(lo(1)-ng_d:,lo(2)-ng_d:,:) real(kind=dp_t), intent(in) :: diffy(lo(1)-ng_d:,lo(2)-ng_d:,:) real(kind=dp_t), intent(in ) :: dx(:),dt,dv ! local integer :: i,j,comp,n_total,n_sum,n_change integer, allocatable :: cell_update(:,:,:) ! Avoid stack overflows and put this on the heap instead integer, parameter :: n_faces=4 integer :: fluxes(n_faces) ! Number of particles jumping out of this cell to each of the neighboring cells real(kind=dp_t) :: probabilities(n_faces) allocate(cell_update(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,nspecies)) cell_update = 0.d0 do comp=1,nspecies do j=lo(2),hi(2) do i=lo(1),hi(1) probabilities = (/diffx(i ,j,comp)*dt/dx(1)**2, & diffx(i+1,j,comp)*dt/dx(1)**2, & diffy(i,j ,comp)*dt/dx(2)**2, & diffy(i,j+1,comp)*dt/dx(2)**2/) !write(*,*) "species=", comp, " probability=", sum(probabilities), "D=", diffx(i ,j,comp), " dt=", dt, " dx=", dx(1) if(sum(probabilities)>1.0_dp_t) & call bl_error("Explicit CFL stability limit violated for multinomial diffusion") if (use_bl_rng) then call MultinomialRNG(samples=fluxes, n_samples=n_faces, & N=max(0, nint(n_new(i,j,comp)*dv)), p=probabilities, & engine=rng_eng_diffusion%p) else call MultinomialRNG(samples=fluxes, n_samples=n_faces, & N=max(0, nint(n_new(i,j,comp)*dv)), p=probabilities) end if ! lo-x face cell_update(i ,j,comp) = cell_update(i ,j,comp) - fluxes(1) cell_update(i-1,j,comp) = cell_update(i-1,j,comp) + fluxes(1) ! hi-x face cell_update(i ,j,comp) = cell_update(i ,j,comp) - fluxes(2) cell_update(i+1,j,comp) = cell_update(i+1,j,comp) + fluxes(2) ! lo-y face cell_update(i,j ,comp) = cell_update(i,j ,comp) - fluxes(3) cell_update(i,j-1,comp) = cell_update(i,j-1,comp) + fluxes(3) ! hi-y face cell_update(i,j ,comp) = cell_update(i,j ,comp) - fluxes(4) cell_update(i,j+1,comp) = cell_update(i,j+1,comp) + fluxes(4) end do end do end do ! increment n_new for all components but remember to convert back to number densities from number of molecules n_new(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,1:nspecies) = & n_new(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,1:nspecies) & + cell_update(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,1:nspecies) / dv deallocate(cell_update) end subroutine multinomial_diffusion_update_2d subroutine multinomial_diffusion_update_3d(n_new,ng_n,diffx,diffy,diffz,ng_d,lo,hi,dx,dt,dv) integer , intent(in ) :: lo(:),hi(:),ng_n,ng_d real(kind=dp_t), intent(inout) :: n_new(lo(1)-ng_n:,lo(2)-ng_n:,lo(3)-ng_n:,:) ! Old state on input, new state on output real(kind=dp_t), intent(in) :: diffx(lo(1)-ng_d:,lo(2)-ng_d:,lo(3)-ng_d:,:) real(kind=dp_t), intent(in) :: diffy(lo(1)-ng_d:,lo(2)-ng_d:,lo(3)-ng_d:,:) real(kind=dp_t), intent(in) :: diffz(lo(1)-ng_d:,lo(2)-ng_d:,lo(3)-ng_d:,:) real(kind=dp_t), intent(in ) :: dx(:),dt,dv ! local integer :: i,j,k,comp,n_total,n_sum,n_change integer, allocatable :: cell_update(:,:,:,:) ! Avoid stack overflows and put this on the heap instead integer, parameter :: n_faces=6 integer :: fluxes(n_faces) ! Number of particles jumping out of this cell to each of the neighboring cells real(kind=dp_t) :: probabilities(n_faces) allocate(cell_update(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,lo(3)-1:hi(3)+1,nspecies)) cell_update = 0.d0 do comp=1,nspecies do k=lo(3),hi(3) do j=lo(2),hi(2) do i=lo(1),hi(1) probabilities = (/diffx(i ,j,k,comp)*dt/dx(1)**2, & diffx(i+1,j,k,comp)*dt/dx(1)**2, & diffy(i,j ,k,comp)*dt/dx(2)**2, & diffy(i,j+1,k,comp)*dt/dx(2)**2, & diffz(i,j,k ,comp)*dt/dx(3)**2, & diffz(i,j,k+1,comp)*dt/dx(3)**2/) if(sum(probabilities)>1.0_dp_t) & call bl_error("Explicit CFL stability limit violated for multinomial diffusion") if (use_bl_rng) then call MultinomialRNG(samples=fluxes, n_samples=n_faces, & N=max(0, nint(n_new(i,j,k,comp)*dv)), p=probabilities, & engine=rng_eng_diffusion%p) else call MultinomialRNG(samples=fluxes, n_samples=n_faces, & N=max(0, nint(n_new(i,j,k,comp)*dv)), p=probabilities) end if ! lo-x face cell_update(i ,j,k,comp) = cell_update(i ,j,k,comp) - fluxes(1) cell_update(i-1,j,k,comp) = cell_update(i-1,j,k,comp) + fluxes(1) ! hi-x face cell_update(i ,j,k,comp) = cell_update(i ,j,k,comp) - fluxes(2) cell_update(i+1,j,k,comp) = cell_update(i+1,j,k,comp) + fluxes(2) ! lo-y face cell_update(i,j ,k,comp) = cell_update(i,j ,k,comp) - fluxes(3) cell_update(i,j-1,k,comp) = cell_update(i,j-1,k,comp) + fluxes(3) ! hi-y face cell_update(i,j ,k,comp) = cell_update(i,j ,k,comp) - fluxes(4) cell_update(i,j+1,k,comp) = cell_update(i,j+1,k,comp) + fluxes(4) ! lo-z face cell_update(i,j,k ,comp) = cell_update(i,j,k ,comp) - fluxes(5) cell_update(i,j,k-1,comp) = cell_update(i,j,k-1,comp) + fluxes(5) ! hi-z face cell_update(i,j,k ,comp) = cell_update(i,j,k ,comp) - fluxes(6) cell_update(i,j,k+1,comp) = cell_update(i,j,k+1,comp) + fluxes(6) end do end do end do end do ! increment n_new for all components but remember to convert back to number densities from number of molecules n_new(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,lo(3)-1:hi(3)+1,1:nspecies) = & n_new(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,lo(3)-1:hi(3)+1,1:nspecies) & + cell_update(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,lo(3)-1:hi(3)+1,1:nspecies) / dv deallocate(cell_update) end subroutine multinomial_diffusion_update_3d end module multinomial_diffusion_module
src/src_reactDiff/multinomial_diffusion.f90
c------------------------------------------------------------- c PROGRAM : main c------------------------------------------------------------- program main implicit none integer i, n, step real*8 gamma, en, answer, error real*8 result, tol, false_position write(*,*)'Enter n, gamma, answer' read(*,*) n, gamma, answer en = -0.1d0 step = 10 tol = 1.0d0/step write(*,*) '--------------------------------------------' write(*,*) 'Molecular Vibrations : Quadratic Potential' write(*,*) ' ' write(*,*) 'step = step size for simpson integration' write(*,*) 'tol = tolerance for false position method' write(*,*) 'n = ',n write(*,*) 'gamma = ',gamma write(*,*) 'Energy = Quantised energy level En' write(*,*) '--------------------------------------------' write(*,*) ' step tol Energy Error' write(*,*) '--------------------------------------------' do 100 i = 0, 5, +1 result = false_position(n, gamma, step, en, tol) error = dabs(answer - result) write(*,20) step, tol, result, error 20 format(i8, f9.7, f14.10, e14.6) step = step*10 tol = 1.0d0/step 100 continue write(*,*) '--------------------------------------------' end c------------------------------------------------------------- c FUNCTION : xin c------------------------------------------------------------- double precision function xin(en) implicit none real*8 en xin = (3.0d0-dsqrt(en + 1.0d0))/2.0d0 return end c------------------------------------------------------------- c FUNCTION : xout c------------------------------------------------------------- double precision function xout(en) implicit none real*8 en xout = (3.0d0+dsqrt(en + 1.0d0))/2.0d0 return end c------------------------------------------------------------- c FUNCTION : f c------------------------------------------------------------- double precision function f(en, n, gamma, step) implicit none integer*4 n, step real*8 xin, xout, simpson real*8 en, gamma, xi, xo, pi pi = 4*atan(1.0d0) xi = xin(en) xo = xout(en) f = gamma*simpson(step,xi,xo,en) - pi*(dfloat(n) + 0.5d0) return end c------------------------------------------------------------- c FUNCTION : g c PURPOSE : integrand c------------------------------------------------------------- double precision function g(en, x) implicit none real*8 en, x, v, arg arg = en - v(x) if (dabs(arg) .lt. 1.0E-14) then g = 0.0d0 else g = dsqrt(arg) endif return end c------------------------------------------------------------- c FUNCTION : v c PURPOSE : potential c------------------------------------------------------------- double precision function v(x) implicit none real*8 x v = 4*(x-1)*(x-2) return end c------------------------------------------------------------- c FUNCTION : simpson c------------------------------------------------------------- double precision function simpson(step, a, b, en) implicit none integer*4 step, i, factor real*8 a, b, en real*8 h, sum, x, g i = 0 factor = 4 sum = 0.0d0 x = 0.0d0 h = (b-a)/dfloat(step) do 300 i = 1, (step-1), +1 x = a+i*h if (factor .eq. 2) then sum = sum + 2.0d0*g(en,x) factor = 4 else sum = sum + 4.0d0*g(en,x) factor = 2 endif 300 continue sum = sum + g(en,a) + g(en,b) sum = (h*sum)/3.0d0 simpson = sum return end c------------------------------------------------------------- c FUNCTION : false_position c PURPOSE : calculates and returns the root of the function c : f, after position x1, to a tolerance of tolx c : using the false position method. The parameter c : step determines the accuracy to which the function c : f can be calculated to. c------------------------------------------------------------- double precision function false_position(n,gamma,step, > start,tolx) implicit none integer*4 step, n real*8 start, tolx, gamma real*8 f real*8 x1, x2, f1, f2, x3, f3, h h = 0.3d0 x1 = start x2 = x1 + h f1 = f(x1,n,gamma,step) f2 = f(x2,n,gamma,step) do while (f1*f2 .ge. 0.0d0) x2 = x2 + h f2 = f(x2,n,gamma,step) 90 format(f15.8, f15.8) end do x3 = x2 - f2*(x2-x1)/(f2-f1) f3 = f(x3,n,gamma,step) do while (dabs(f3) .gt. tolx) if (f1*f3 .lt. 0.0d0) then x2 = x3 else x1 = x3 endif f1 = f(x1,n,gamma,step) f2 = f(x2,n,gamma,step) x3 = x2 - f2*(x2-x1)/(f2-f1) f3 = f(x3,n,gamma,step) end do false_position = x3 return end
quadratic.f
!———————————————————————————————————————————————————————————————————————————————————————— !---- SUB MODULE TO HANDLE FILES !———————————————————————————————————————————————————————————————————————————————————————— module two_column_file_with_x_and_y ! known bugs: not working if total point count < 3 implicit none !private !———————————————————————————————————————————————————————————————————————————————————————— type, public :: file ! type for two column file character(len=100) :: filename ! it has filename and must be given from outside logical :: isset ! = true if file is not "", else false integer :: file_id ! it is assigned file ID - it is free integer :: lines ! it is file line count real, allocatable :: x(:), y(:) ! first and second column [has to be sorted on x] logical :: homogeneous_mesh ! if mesh is homogeneous real :: dx ! dx, if mesh is homogeneous end type file ! functions public :: set_filename public :: file_is_set public :: assign_file_id public :: get_lines_count public :: assign_x_and_y public :: assign_dx public :: print_info public :: linear_interp !———————————————————————————————————————————————————————————————————————————————————————— contains !———————————————————————————————————————————————————————————————————————————————————————— subroutine set_filename(this,input) implicit none type(file) :: this character(*), intent(in) :: input !integer,parameter :: seed = 61 900 format (" # WARNING: ZERO VALID LINES FOUND. ZERO VALUES WILL BE USED FOR: ", A) !call srand(seed) this % homogeneous_mesh = .false. this % filename = input this % isset = .true. if (input == "") then this % isset = .false. return end if call assign_file_id (this) call get_lines_count(this) if (this % lines == 0) this % isset = .false. if (this % isset) call assign_x_and_y(this) if (this % isset) call assign_dx(this) if (.not.this % isset) write(*,900) trim(this % filename) end subroutine set_filename !———————————————————————————————————————————————————————————————————————————————————————— function file_is_set(this) implicit none type(file) :: this logical :: file_is_set file_is_set = this % isset end function file_is_set !———————————————————————————————————————————————————————————————————————————————————————— subroutine assign_file_id (this) implicit none !type(file), intent(in) :: this type(file) :: this logical itsopen integer :: FID itsopen = .true. !initial value to trigger check below do while ( itsopen ) ! it will stop when FID is unique FID = 115 + mod(irand(0),1500) inquire(unit=FID, opened=itsopen) end do 800 format (" # TWO COLUMN MODULE: FILE OPENED: ", A) write(*,800) trim(this % filename) this % file_id = FID end subroutine assign_file_id !———————————————————————————————————————————————————————————————————————————————————————— subroutine get_lines_count(this) implicit none type(file) :: this logical :: exist integer :: file_lines_count, EOF character(10) :: dummy ! 800 format (" # FILE OPENED: ",A) ! 810 format (" # FILE CLOSED: ",A) ! 900 format (" # FILE READING ERROR: ",A) 910 format (" # FILE DOES NOT EXIST: ",A) inquire(file = trim(this % filename), exist=exist) if (exist) then open(this % file_id, file=trim(this % filename), status="old", action="read") !write(*,800) trim(this % filename) else write(*,910) trim(this % filename) end if file_lines_count = -1 EOF = 0 do while ( EOF == 0 ) !until end of file read(this % file_id,*,iostat=EOF) dummy !write(*,*) "string= ", dummy, "EOF= ", EOF if (EOF > 0) then ! some reading error !write(*,900) this % file_id elseif (EOF < 0) then ! end of file or file is closed !rewind(this % file_ID) close(this % file_id) !write(*,810) trim(this % filename) end if if ( dummy == '') then ! empty string elseif( & dummy(1:1) == '!' .or. & dummy(1:1) == '#' .or. & dummy(1:1) == '$' .or. & dummy(1:1) == '%' .or. & dummy(1:1) == '/' .or. & dummy(1:1) == '&' .or. & dummy(1:1) == '[' .or. & dummy(1:1) == ']' .or. & dummy(1:1) == '{' .or. & dummy(1:1) == '}' .or. & dummy(1:1) == ':' .or. & dummy(1:1) == ';' .or. & dummy(1:1) == '@' .or. & dummy(1:1) == '<' .or. & dummy(1:1) == '>' .or. & dummy(1:1) == ' ' .or. & dummy(1:1) == '*' ) then else file_lines_count = file_lines_count + 1 !write(*,*) "line ccount = ", file_lines_count endif end do this % lines = file_lines_count end subroutine get_lines_count !———————————————————————————————————————————————————————————————————————————————————————— subroutine assign_x_and_y (this) !use all_mod implicit none type(file) :: this logical :: exist integer :: i integer :: tn, ts(300), te(300) character :: inp*300 allocate (this % x(1:this % lines)); this % x = 0.0 allocate (this % y(1:this % lines)); this % y = 0.0 inquire(file=trim(this % filename), exist=exist) if (exist) then open(this % file_id, file=trim(this % filename), status="old", action="read") end if do i=1, this % lines call ReadC(this % file_id,inp,tn,ts,te) read(inp(ts(1):te(1)),*) this % x(i) read(inp(ts(2):te(2)),*) this % y(i) !write(*,*) "x=", this % x(i), "f= ",this % y(i) end do close(this % file_id) !write(*,810) this % filename end subroutine assign_x_and_y !———————————————————————————————————————————————————————————————————————————————————————— subroutine assign_dx (this) implicit none type(file) :: this real :: dx_0 integer :: i 275 format (" # File", A, " has not homogeneous mesh ") ! output style 285 format (" # File", A, " has homogeneous mesh ") ! output style this % dx = 0. dx_0 = abs( this % x(2) - this % x(1) ) do i = 2, this % lines - 1 this % dx = this % x(i+1) - this % x(i) if ( abs( this % dx - dx_0 ) > 1.0D-16 ) then write(*,275) trim(this % filename) return end if end do this % homogeneous_mesh = .true. write(*,285) trim(this % filename) return end subroutine assign_dx !———————————————————————————————————————————————————————————————————————————————————————— subroutine print_info (this) implicit none type(file) :: this integer :: i 225 format (" # 2-column filetype: ") ! output style 235 format (" # name : ", A) ! output style 240 format (" # status : ", A) ! output style 245 format (" # file_ID : ", I6) ! output style 255 format (" # ", A6, A12, A12) ! output style 265 format (" # ", I6, F12.8, F12.8) ! output style write(*,225) write(*,235) trim(this % filename) write(*,240) this % isset write(*,245) this % file_id write(*,255) "line", "x", "y" do i = 1, this % lines write(*,265) i, this % x(i), this % y(i) end do end subroutine print_info !———————————————————————————————————————————————————————————————————————————————————————— ! function linear_interp (this, x) ! x is an array of real numbers ! implicit none ! type(file) :: this ! real, intent (in) :: x(:) ! !real, optional, intent (in) :: x ! real, allocatable :: linear_interp(:) ! integer :: i, j ! ! allocate(linear_interp(1:size(x))); ! linear_interp = 0.0 ! ! we need to find interval, where x has falled ! ! but first, we need to make sure it is not extrapolation ! do j = 1, size(x) ! if ( ( x(j) > this % x(this % lines) ) .or. ( x(j) < this % x(1) ) ) then ! return ! go out of function ! end if ! do i = 1, this % lines - 1 ! check all inner intervals ! if ( ( x(j) <= this % x(i+1) ) .and. ( x(j) >= this % x(i) ) ) then ! linear_interp = this % y(i) + (this % y(i+1) - this % y(i))*(x(j) - this % x(i))/(this % x(i+1) - this % x(i)) ! return ! go out of function ! end if ! end do ! end do ! ! end function linear_interp !———————————————————————————————————————————————————————————————————————————————————————— function linear_interp (this, x) ! x is a real number implicit none type(file) :: this real, intent (in) :: x real :: linear_interp integer :: i linear_interp = 0.0 if (.not. this % isset) return ! we need to find interval, where x has fallen ! but first, we need to make sure it is not extrapolation !if ( ( x > this % x(this % lines) ) .or. ( x < this % x(1) ) ) then ! return ! go out of function !end if i = int (x / this % dx) + 1 if ( x > this % x(this % lines) .or. i == this % lines ) then linear_interp = this % y(this % lines) return ! go out of function end if if ( x < this % x(1) ) then linear_interp = this % y(1) return ! go out of function end if if ( this % homogeneous_mesh ) then ! if mesh if homogeneous linear_interp = this % y(i) + (this % y(i+1) - this % y(i))*(x - this % x(i))/(this % x(i+1) - this % x(i)) return ! go out of function else do i = 1, this % lines - 1 ! check all inner intervals if ( ( x <= this % x(i+1) ) .and. ( x >= this % x(i) ) ) then linear_interp = this % y(i) + (this % y(i+1) - this % y(i))*(x - this % x(i))/(this % x(i+1) - this % x(i)) return ! go out of function end if end do end if end function linear_interp ! function linear_interp (this, x) ! x is a poiner to array or number ! implicit none ! type(file) :: this ! real, pointer, intent (in) :: x ! real, allocatable :: linear_interp ! integer :: i ! ! linear_interp = 0.0 ! ! we need to find interval, where x has falled ! ! but first, we need to make sure it is not extrapolation ! ! if ( ( x > this % x(this % lines) ) .or. ( x < this % x(1) ) ) then ! return ! go out of function ! end if ! do i = 1, this % lines - 1 ! check all inner intervals ! if ( ( x <= this % x(i+1) ) .and. ( x >= this % x(i) ) ) then ! linear_interp = this % y(i) + (this % y(i+1) - this % y(i))*(x - this % x(i))/(this % x(i+1) - this % x(i)) ! return ! go out of function ! end if ! end do ! end function linear_interp !———————————————————————————————————————————————————————————————————————————————————————— end module two_column_file_with_x_and_y !———————————————————————————————————————————————————————————————————————————————————————— !program module_test ! use two_column_file_with_x_and_y ! implicit none ! type(file) :: a , b ! ! call set_filename(a,"/home/palkine/Fortran/Projects/combustion/T-FlowS-comb-Problem-3-CalcPS/Problem1/tables/density_of_x.dat") !call print_info(a) ! !call set_filename(b,"/home/palkine/Fortran/Projects/combustion/T-FlowS-comb-Problem-3-CalcPS/Problem1/tables/viscosity_of_x.dat") !call print_info(b) ! ! ! !end program ! !!———————————————————————————————————————————————————————————————————————————————————————— !!---- Just working example !!———————————————————————————————————————————————————————————————————————————————————————— !module class_Circle !implicit none !real :: pi = 3.1415926535897931d0 ! class-wide private constant ! !class, public :: Circle !real :: radius ! contains ! procedure :: area => circle_area ! procedure :: print => circle_print !end class Circle !contains ! function circle_area(this) result(area) ! class(Circle), intent(in) :: this ! real :: area ! area = pi * this%radius**2 ! end function circle_area ! ! subroutine circle_print(this) ! class(Circle), intent(in) :: this ! real :: area ! area = this%area() ! Call the class-bound function ! print *, 'Circle: r = ', this%radius, ' area = ', area ! end subroutine circle_print !end module class_Circle !program circle_test ! use class_Circle ! implicit none ! ! class(Circle) :: c ! Declare a variable of type Circle. ! c = Circle(1.5) ! Use the implicit constructor, radius = 1.5. ! call c%print ! Call the type-bound subroutine !end program circle_test
Library/two_column_file_with_x_and_y.f90
subroutine axisopt(fsq, r00, iresidue, ivac) use vsvd use vparams, only: zero, one, nthreed implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer :: iresidue, ivac real(rprec) :: fsq, r00 C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec), parameter :: smax = 0.998_dp real(rprec), parameter :: smin = 0.985_dp character*(60), parameter :: optbegin = 1 'Begin variation of Raxis to minimize total RMS error' C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- real(rprec) :: delstep, dedrmax, factor, delerr, 1 dedr, rstepx1 real(rprec), save :: delstep_old, errmax, errold, rstepx, 1 raxold, scale C----------------------------------------------- if (iresidue.lt.1 .or. errsvd*1.e6_dp.lt.one .or. 1 fsq.gt.fturnon_axis .or. ivac .le.2) return ! ! MOVE R-AXIS BASED ON dR/dt = (-dEsvd/dR) ! LIMIT MAXIMUM RSTEPX TO RSTEPX0 ! TRY TO FIND ZERO-CROSSING IN dEsvd/dR (ESTIMATED NUMERICALLY) ! if (iresidue .eq. 1) then !First time through iresidue = 2 raxold = r00 errold = errsvd errmax = zero rstepx = rstepx0 scale = smax if (iopt_raxis .gt. 0) then write (*, 115) optbegin write (nthreed, 115) optbegin endif else delerr = errsvd - errold !delta E-svd delstep = r00 - raxold !delta R-axis if (delerr.ne.zero .and. abs(delstep).gt.1.e-3_dp*rstepx0) then dedr = delerr/delstep errmax = max(errmax,errsvd) dedrmax = 2.0*errmax/rwidth rstepx1 = min(one,abs(dedr)/dedrmax)*rsfac*rstepx0 factor = sign(one,(-dedr)) !Move in -dE/dR direction rstepx = rstepx1*factor scale = smax if (delstep*delstep_old .le. zero) scale = smin delstep_old = delstep raxold = r00 errold = errsvd endif endif rsfac = scale*rsfac c-5/1/96 raxmse = raxmse + rstepx raxmse = raxold + rstepx 115 format(2x,a) end subroutine axisopt subroutine chisq(amat_i, amat_p, data, idata, isize, itotal) use vmec_main use vsvd use vspline implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer :: itotal integer, dimension(*) :: idata, isize real(rprec), dimension(isnodes,*) :: amat_i real(rprec), dimension(ipnodes,*) :: amat_p real(rprec), dimension(*) :: data C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: i, n, i1, ispec, is(5), ip(5), j2 real(rprec) :: delsq, delp, dels character*(130) label C----------------------------------------------- ! ! COMPUTES CHI**2 FROM DIFFERENT SUBROUTINES AT VARIOUS TIME-STEPS ! WRITTEN BY D.K. LEE (3/93) ! chisqerr(:jchix) = zero do i = 1, itotal delsq = (sum(ystark(:isnodes)*amat_i(:isnodes,i)) + 1 sum(ythom(:ipnodes)*amat_p(:ipnodes,i))-data(i))**2 if (i.ge.idata(ithom0) .and. i<idata(ithom0)+isize(ithom0)) 1 then chisqerr(ithom0) = chisqerr(ithom0) + delsq else if (i.ge.idata(istark0) .and. i<idata(istark0) 1 +isize(istark0)) then i1 = i - idata(istark0) + 1 if (i1 .eq. islope) then chisqerr(islope0) = delsq else if (i1 .eq. icurrout) then chisqerr(icurr0) = delsq else chisqerr(istark0) = chisqerr(istark0) + delsq endif else if (i.ge.idata(idiam0) .and. i<idata(idiam0) 1 +isize(idiam0)) then chisqerr(idiam0) = chisqerr(idiam0) + delsq else if (i.ge.idata(iflxs0) .and. i<idata(iflxs0) 1 +isize(iflxs0)) then chisqerr(iflxs0) = chisqerr(iflxs0) + delsq else if (i.ge.idata(ibrzfld) .and. i<idata(ibrzfld) 1 +isize(ibrzfld)) then chisqerr(ibrzfld) = chisqerr(ibrzfld) + delsq endif end do ! errsvd = sum(chisqerr(:jchix)) if (.not.lpprof) errsvd = errsvd - chisqerr(ithom0) if (iequi.ne.1 .or. .not.lrecon) return if (.not.lpprof) then write (nthreed, 15) else write (nthreed, 10) endif if (lpprof) then do n = 1, nchistp write (nthreed, 20) nchi2(n), chi2(ithom0,n), 1 chi2(istark0,n), chi2(icurr0,n), chi2(idiam0,n), 2 chi2(iflxs0,n), chi2(ibrzfld,n), chi2(jchix1,n) end do else do n = 1, nchistp write (nthreed, 20) nchi2(n), chi2(istark0,n), 1 chi2(icurr0,n), chi2(idiam0,n), chi2(iflxs0,n), 2 chi2(ibrzfld,n), chi2(jchix1,n) end do endif ! ! PRINT OUT MATRIX ELEMENTS (5 EACH FOR PRESSURE, IOTA) ! write (nthreed, 200) delp = (ipnodes - 1)/4. dels = (isnodes - 1)/4. ip(1) = 1 is(1) = 1 ip(2:4) = ip(1) + int((((/(j2,j2=2,4)/)) - 1)*delp) is(2:4) = is(1) + int((((/(j2,j2=2,4)/)) - 1)*dels) ip(5) = ipnodes is(5) = isnodes write (label, 210) ip(1), ip(2), ip(3), ip(4), ip(5), is(1), 1 is(2), is(3), is(4), is(5) write (nthreed, 220) label ispec = 0 do i = 1, itotal if (i.ge.idata(ithom0) .and. 1 i.lt.idata(ithom0)+isize(ithom0)) then i1 = i - idata(ithom0) + 1 call printmatrix (amat_p(1,i), amat_i(1,i), data(i), i, 1 i1, ip, is, ' PRES (') else if (i.ge.idata(istark0) .and. i<idata(istark0) 1 +isize(istark0)) then i1 = i - idata(istark0) + 1 if (i1 .eq. islope) then ispec = ispec - 1 call printmatrix (amat_p(1,i), amat_i(1,i), data(i), 1 i, 1, ip, is, ' IOTA0 (') else if (i1 .eq. icurrout) then ispec = ispec - 1 call printmatrix (amat_p(1,i), amat_i(1,i), data(i), 1 i, 1, ip, is, ' CURRENT (') else call printmatrix (amat_p(1,i), amat_i(1,i), data(i), 1 i, i1 + ispec, ip, is, ' MSE (') endif else if (i.ge.idata(idiam0) .and. i<idata(idiam0) 1 +isize(idiam0)) then i1 = i - idata(idiam0) + 1 call printmatrix (amat_p(1,i), amat_i(1,i), data(i), i, 1 i1, ip, is, ' DIAMAG (') else if (i.ge.idata(iflxs0) .and. i<idata(iflxs0) 1 +isize(iflxs0)) then i1 = i - idata(iflxs0) + 1 call printmatrix (amat_p(1,i), amat_i(1,i), data(i), i, 1 i1, ip, is, ' FLUXES (') else if (i.ge.idata(ibrzfld) .and. i<idata(ibrzfld) 1 +isize(ibrzfld)) then i1 = i - idata(ibrzfld) + 1 call printmatrix (amat_p(1,i), amat_i(1,i), data(i), i, 1 i1, ip, is, ' BR-BZ (') endif end do 20 format(i6,1p8e12.4) 10 format(/,30x,'ABSOLUTE CHI-SQ ERROR BY DATA TYPE'/,30x, 1 '(NOT NORMED BY NUMBER DATA POINTS)'/,20x, 2 'NOTE: STARK CHISQ MAY BE EVALUATED AT REDISTRIBUTED KNOTS'/, 3 ' ITER Thomscat Stark',5x,'Current',5x,'Diamag.',5x, 4 'Saddle',6x,' B-Loops',6x,'TOTAL',/,1x,5('-'),7(2x,10('-'))) 15 format(/,30x,'ABSOLUTE CHI-SQ ERROR BY DATA TYPE'/,30x, 1 '(NOT NORMED BY NUMBER DATA POINTS)'/,20x, 2 'NOTE: STARK CHISQ MAY BE EVALUATED AT REDISTRIBUTED KNOTS'/, 3 ' ITER Stark',5x,'Current',5x,'Diamag.',5x,'Saddle',6x, 4 ' B-Loops',6x,'TOTAL',/,1x,5('-'),7(2x,10('-'))) 200 format(//,38x,'SPLINE MATRIX ELEMENTS BY DATA TYPE'/,30x, 1 ' AI(i,j)*iota(j) + AP(i,j)*[mu0*pres(j)] = DATA(i)'/,30x, 2 ' NOTE: DATA(I) IS THE RAW DATA NORMED TO SIGMA(I)'//) 210 format(' I TYPE DATA(I)',' AP(I,',i2,') AP(I,',i2, 1 ') AP(I,',i2,') AP(I,',i2,')',' AP(I,',i2,') AI(I,',i2, 2 ') AI(I,',i2,') AI(I,',i2,')',' AI(I,',i2,') AI(I,',i2,')') 220 format(a,/,3x,'-',3x,4('-'),9x,7('-'),10(2x,8('-'))) end subroutine chisq subroutine printmatrix(amatp, amati, data, i, i1, ip, is, type) use vparams, only: rprec, nthreed implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer i, i1 real(rprec) data character*(10) type integer, dimension(*) :: ip, is real(rprec), dimension(*) :: amatp, amati C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: k C----------------------------------------------- write (nthreed, 10) i, type, i1, data, (amatp(ip(k)),k=1,5), ( 1 amati(is(k)),k=1,5) 10 format(1x,i3,a10,i2,')',1p11e10.2) end subroutine printmatrix subroutine store_chisq use vmec_main use vsvd use vspline implicit none C----------------------------------------------- ! ! COMPUTES CHI**2 FROM DIFFERENT SUBROUTINES AT VARIOUS TIME-STEPS ! WRITTEN BY D.K. LEE (3/93) ! if (mod(iter2,nstep).ne.10 .and. iequi.eq.0) return chisqerr(jchix1) = sum(chisqerr(:jchix)) if (.not.lpprof) chisqerr(jchix1) = chisqerr(jchix1) 1 - chisqerr(ithom0) nchistp = nchistp + 1 if (nchistp .gt. mstp) return chi2(:,nchistp) = chisqerr nchi2(nchistp) = iter2 - 10 if (iequi .eq. 1) nchi2(nchistp) = iter2 if (iter2 .eq. 10) nchi2(nchistp) = 1 end subroutine store_chisq subroutine findphi(reven, rodd, rmeas, dse, dso, rmid, ismeas, 1 iumeas, indexr, npts) use vmec_main use realspace implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer npts integer, dimension(npts) :: ismeas, iumeas integer, dimension(2*ns) :: indexr real(rprec), dimension(ns,nzeta,*) :: reven, rodd real(rprec), dimension(npts) :: rmeas, dse, dso real(rprec), dimension(2*ns) :: rmid C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: i, k, itemp, jtemp, i1, j1, ns2 C----------------------------------------------- ! ! THIS ROUTINE FINDS THE LOWER FLUX INDEX [=INDEXS] CORRESPONDING ! TO THE MEASURED VALUE [=RMEAS] OF (R,Z=0) ALONG THE MIDPLANE ! (THETA=0 OR PI). ! THE QUANTITIES RMEAS(K=1,NPTS) ARE INTERPOLATED AS FOLLOWS: ! ! RMEAS(K) = R[ISMEAS(K),IUMEAS(K)]*[1-DSO(K)] + ! R[ISMEAS(K)+1,IUMEAS(K)]*DSO(K) ! ! BECAUSE OF THE SQRT(S) BEHAVIOUR OF R IN THE FIRST RADIAL ZONE, ! THE ACTUAL S-INTERPOLAND IN THE FIRST ZONE IS DSO(K)**2 = DSE(K). ! IN ALL OTHER ZONES, DSE(K) = DSO(K). ! if (npts .le. 0) return ns2 = 2*ns ! ! COMPUTE THE GRID VALUES (S-COORDINATE) OF R ALONG THE MIDPLANE, ! STARTING AT THETA=PI (I=NTHETHA2) AND ENDING AT THETA=0 (I=1) ! rmid(:ns) = reven(indexr(:ns),1,ntheta2) + sqrts(indexr(:ns)) 1 *rodd(indexr(:ns),1,ntheta2) rmid(ns+1:ns2) = reven(indexr(ns+1:ns2),1,1) + 1 sqrts(indexr(ns+1:ns2))*rodd(indexr(ns+1:ns2),1,1) ! ! FIND THE RADIAL ZONE INDEX [=ITEMP], WHICH BRACKETS THE MEASURED R-VALUE ! ! RMID(ITEMP-1) .le. RMEAS .le. RMID(ITEMP) ! do k = 1, npts itemp = 0 do i = 1, ns2 - 1 if (rmeas(k) .lt. rmid(i)) then itemp = i go to 100 endif end do itemp = ns2 ! ! FIND FLUX-COORDINATE S-INDEX [=ISMEAS], POLOIDAL ANGLE ! INDEX [=IUMEAS], AND INTERPOLAND [=DSO] ! 100 continue if (itemp.gt.1 .and. itemp.lt.ns2) then i1 = itemp - 1 jtemp = indexr(itemp) j1 = indexr(i1) dso(k) = (rmeas(k)-rmid(i1))/(rmid(itemp)-rmid(i1)) if (j1 .lt. jtemp) then !THETA = 0 ismeas(k) = j1 iumeas(k) = 1 else ismeas(k) = jtemp dso(k) = 1.0 - dso(k) iumeas(k) = ntheta2 endif else dso(k) = 1.0 ismeas(k) = indexr(itemp) - 1 ! IGNORE MEASURED POINTS OUTSIDE GRID if (itemp.eq.1 .or. rmeas(k).gt.rmid(ns2-1)) dso(k) = -1.0 if (itemp .eq. ns2) iumeas(k) = 1 endif ! ! ACCOUNT FOR SQRT(S) SINGULARITY IN 1st ZONE ! DSE IS THE S-FRACTIONAL INTERPOLAND ! dse(k) = dso(k) if (ismeas(k) .eq. 1) dse(k) = dso(k)*dso(k) end do end subroutine findphi subroutine fixrecon(ier) use vmec_main use vsvd use vspline implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer ier C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec), parameter :: angle_variance = 0.3_dp real(rprec), parameter :: radial_variance = 0.3_dp real(rprec), parameter :: p_threshold = 1.e-3_dp real(rprec), parameter :: c1p5 = 1.5_dp integer, parameter :: inode_max = 15 C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer, dimension(itse) :: isortp integer, dimension(1) :: isamax integer :: istat1 = 0, istat2 = 0, istat3 = 0, ii, i, ineg 1 , ipos, ipmax, ioff, ileft, n, n1, icount, index, ind, m, m1 real(rprec) :: delstark, datapos, dataneg real(rprec), dimension(imse+1) :: datalsq_s, stark_temp real(rprec) :: datamax, datamin, t1, rneg, 1 rpos, datanorm, presmax, presin, presout, presmin, tsign real(rprec), dimension(itse) :: 1 datalsq_p, ythom0, y2thom0, qtemp logical :: l1v(imse), l4v(itse) C----------------------------------------------- ! ! ! INDEX OF LOCAL VARIABLES ! ! needflx =NEEDIT, loop required for flux match ! >=ISYMCOIL, loop required but flux computed by ! invoking symmetry in Z ! =IDONTNEED, loop not required for flux match ! needbfld =NEEDIT, loop required for B-field match ! =ISAMECOIL, loop at same position as previous loop ! >=ISYMCOIL, loop required but B-field computed ! by invoking symmetry in Z ! =IDONTNEED, loop not required in B-field match ! dsiext connected flux loop signals due to external coils ! plflux array of measured (inferred) plasma contrib. to flux loops ! plbfld array of measured (inferred) plasma contrib. to B-loops ! call free_mem_recon ier = 0 ! ! ONLY QUANTITIES INDEPENDENT OF RADIAL MESH CAN GO HERE ! ! STARK-DATA CONSISTENCY CHECK ! delstark = tan(dcon*angle_variance) ! ! SORT STARK DATA IN ASCENDING ORDER IN R-SPACE ! AND RE-INDEX DATASTARK, SIGMA_STARK ARRAYS ON ASCENDING RSTARK ARRAY ! ! SCALE MOTIONAL STARK DATA TO RADIANS ! RSTARK = R position along Z=0 plane of measurement ! DATASTARK = ARCTAN ( Bpol/Btor ) at RSTARK, in degrees ! AND IS CONVERTED TO Bpol/Btor ! ii = 0 l1v(:imse) = (rstark(:imse) .gt. zero) do i = 1, imse if (l1v(i)) ii = ii + 1 end do if (ii .ne. imse) then print *, 'There is a zero in the RSTARK array ?!' ier = 1 return endif allocate (indexs1(imse+3), indexu1(imse+3), isortr(imse+3), 1 isorts(imse+3), delse1(imse+3), delso1(imse+3), 2 starkcal(imse+3), qmeas(imse+3), qcalc(imse+3), 3 fpsical(imse+3), stark_weight(imse+3), 4 rsort(imse+3), rsort0(imse+3), stat=istat1) if (istat1 .ne. 0) then print *, ' ISTAT1 = ', istat1, ' ALLOCATING INDEXS1' stop endif datalsq_s(:imse) = datastark(:imse) stark_temp(:imse) = sigma_stark(:imse) call sort_data (rstark, isorts, imse) do i = 1, imse datastark(i) = datalsq_s(isorts(i)) sigma_stark(i) = stark_temp(isorts(i)) if (sigma_stark(i) .ge. cbig) then print *, 'SIGMA_STARK missing' ier = 1 return endif if (sigma_stark(i) .lt. zero) sigma_stark(i) = 1 abs(sigma_stark(i)*datastark(i)) !CONVERT TO Bpol/Btor ... applying profile offsets along the way! datastark(i) = tan(dcon*(datastark(i)+mseangle_offset+ 1 mseangle_offsetm*mseprof(i))) sigma_stark(i) = tan(dcon*sigma_stark(i)) if (sigma_stark(i) .eq. zero) sigma_stark(i) = 0.1*delstark end do rstarkmin = rstark(1) rstarkmax = rstark(imse) ! ! NEED FOR SCALING EDGE IOTA ! HERE, SINCE RSTARK IS ORDERED, DATAMAX -> RIGHT OF AXIS ! AND DATAMIN -> LEFT OF AXIS ! ! GET RC0MSE (ESTIMATE FOR MAGNETIC AXIS) ! rwidth = radial_variance*(rbc(0,1)+abs(rbs(0,1))) if (imse .gt. 0) then datamax = datastark(imse) datamin = datastark(1) rc0mse = 0. ineg = 1 c !NO ZERO CROSSING: FIND MIN ANYHOW if (datamax * datamin.gt.zero) then !NO ZERO CROSSING: FIND MIN ANYHOW datamin = abs(datamin) do i = 2,imse t1 = abs(datastark(i)) if (t1.lt.datamin) then datamin = t1 ineg = i endif end do if (ineg.eq.imse) ineg = ineg-1 ipos = ineg + 1 goto 310 else if (( datamax*signiota.lt.zero ) .or. > (datamin*signiota.gt.zero)) then datastark = -datastark endif ! ! ALLOW FOR POSSIBLE MULTIPLE ZERO CROSSINGS (WIGGLES) IN DATA ! do i = 1, imse if (datastark(i)*signiota .le. zero) then ineg = i !LEFT OF MAGNETIC AXIS else exit !RIGHT OF MAGNETIC AXIS endif end do do i = imse, ineg + 1, -1 if (datastark(i)*signiota .le. zero) then exit !LEFT OF MAGNETIC AXIS else ipos = i !RIGHT OF MAGNETIC AXIS endif end do 310 continue rneg = rstark(ineg) rpos = rstark(ipos) dataneg = datastark(ineg) datapos = datastark(ipos) endif !End of if(imse>0) if (datapos .ne. dataneg) then rc0mse = (datapos*rneg - dataneg*rpos)/(datapos - dataneg) rwidth=delstark*abs((rneg-rpos)/(datapos-dataneg))+rwidth endif if (ipos .gt. ineg + 1) rc0mse = 0.5_dp*(rpos + rneg) ! ! ESTIMATE MAGNETIC AXIS FROM RAXIS ! raxmse = rc0mse if (rc0mse.eq.0.0_dp .or. iopt_raxis.ne.1) raxmse = raxis(0,1) rstepx0 = 0.005_dp*rwidth ! ! COMPUTE SPLINES IN R-SPACE FOR MATCHING IOTA(0) ! datanorm = zero delse1(:imse) = one qcalc(:imse) = one/sigma_stark(:imse)**2 datalsq_s(:imse) = datastark(:imse)*qcalc(:imse) scstark = sum(abs(datastark(:imse)/sigma_stark(:imse))) datanorm = sum(abs(datastark(:imse))) scstark = datanorm/scstark c04-96 call setspline(rstark,qcalc,datalsq_s,stark_temp,ystark0, c04-96 > y2stark0,delse1,0.1*tensi/scstark**2,imse,NATUR) ! ! DETERMINE NUMBER OF IOTA KNOTS IN SQRT(S)-SPACE ! if (isnodes .le. 0) then isnodes = min(inode_max,imse + 1) isnodes = max(5,isnodes) !At least 5 spline knots endif if (isnodes .lt. 5) stop 'MUST PICK ISNODES > 4' write (nthreed, *) 1 'Number of iota-spline knots (in s-space): ', isnodes allocate (nk_ia(isnodes), nk_ib(isnodes), hstark(isnodes), 1 y2stark(isnodes), ystark(isnodes), sknots(isnodes), stat=istat1) if (istat1 .ne. 0) then print *, ' ISTAT1 = ', istat1, ' ALLOCATING NK_IA' stop endif ! ! COMPUTES NODES IN SQRT(S) SPACE FOR SPLINES ! THIS ASSUMES A FIXED NO - ISNODES - OF KNOTS ! THIS MAY NOT PRESERVE ISNODES. ! ALSO, IT IS NOT NECESSARY TO TAKE EQUALLY SPACED KNOTS IN ! SQRT(S) SPACE. INDEED, THE FOLLOWING CHOICES ARE POSSIBLE: ! ! SKNOTS(I) = HNODES*(I-1) .eq.> EQUAL-SPACED IN SQRT(S) ! ! SKNOTS(I) = SQRT(HNODES*(I-1)) .eq.> EQUAL-SPACED IN S ! ! DO NOT - UNDER ANY CIRCUMSTANCES - CHANGE THE ARGUMENTS TO ! THE SPLINT, GETSPLINE, SETUP_INT ROUTINES FROM SQRTS,SHALF ! TO SQRTS**2, SHALF**2 TO DO S-INTERPOLATION. RATHER, CHANGE ! SKNOTS (AND PKNOTS) ACCORDING TO THE ABOVE FORMULA. THIS IS ! ABSOLUTELY CRUCIAL, SINCE ONLY IN SQRT(S) SPACE DO THE ! FIRST DERIVATIVE BOUNDARY CONDITIONS, d IOTA/d SQRT(S) = 0 ! (SIMILAR FOR P) APPLY AT THE AXIS, S=0. ! ! do i = 1, isnodes sknots(i) = real(i - 1,rprec)/(isnodes - 1) end do hstark(:isnodes-1) = sknots(2:isnodes) - sknots(:isnodes-1) ! ! SET UP DATA ARRAY SCALE FACTORS ! ACTUAL PRESSURE = PRESPEAK * PFAC * P(INTERNAL) ! IF (LPOFR) THEN DATA ARE INPUT vs R (REAL SPACE) ! IF (.NOT.LPOFR),DATA ARE INPUT vs S (FLUX SPACE) ! if (itse .eq. 0) call getpresprofile !!Simulate 'data' if (itse .gt. 0) then allocate (sthom(itse), delse2(itse), delso2(itse), pcalc(itse), 1 indexs2(itse), indexu2(itse), stat=istat1) if (istat1 .ne. 0) then print *, ' ISTAT1 = ', istat1, ' ALLOCATING STHOM' stop endif datathom(:itse) = datathom(:itse)*presfac presmax = maxval(datathom(:itse)) ! ! SORT DATA IN ASCENDING ORDER IN R-SPACE (LPOFR) OR S-SPACE(.NOT.LPOFR) ! AND RE-INDEX DATATHOM, SIGMA_THOM ARRAYS ON ASCENDING RTHOM ARRAY datalsq_p(:itse) = datathom(:itse) qtemp(:itse) = sigma_thom(:itse) call sort_data (rthom, isortp, itse) if (lpofr) then do i = 1, itse datathom(i) = datalsq_p(isortp(i)) rthom(i) = rthom(i) + pres_offset if (rthom(i) .le. zero) then print *, 'Check units of PRES_OFFSET: rthom < 0!' ier = 1 return endif if (datathom(i) .eq. presmax) ipmax = i sigma_thom(i) = qtemp(isortp(i)) if (sigma_thom(i) .ge. cbig) then print *, 'SIGMA_THOM missing' ier = 1 return endif if (sigma_thom(i) .lt. zero) then sigma_thom(i) = abs(sigma_thom(i)*datathom(i)) else if (sigma_thom(i) .gt. zero) then sigma_thom(i) = presfac*sigma_thom(i) else sigma_thom(i) = p_threshold*presmax endif endif end do else do i = 1, itse datathom(i) = datalsq_p(isortp(i)) sthom(i) = rthom(i) if (datathom(i) .eq. presmax) ipmax = i sigma_thom(i) = qtemp(isortp(i)) if (sigma_thom(i) .ge. cbig) then print *, 'SIGMA_THOM missing' ier = 1 return endif if (sigma_thom(i) .lt. zero) then sigma_thom(i) = abs(sigma_thom(i)*datathom(i)) else if (sigma_thom(i) .gt. zero) then sigma_thom(i) = presfac*sigma_thom(i) else sigma_thom(i) = p_threshold*presmax endif endif end do endif ! ! THROW AWAY NOISY (SMALL) PRESSURE DATA BELOW P_THRESHOLD ! STARTING FROM PEAK WORKING TO LARGER, SMALLER R ! ineg = ipmax ipos = ipmax do while(ineg.gt.1 .and. 1 datathom(ineg-1).ge.p_threshold*presmax) ineg = ineg - 1 end do do while(ipos.lt.itse .and. 1 datathom(ipos+1).ge.p_threshold*presmax) ipos = ipos + 1 end do itse = ipos - ineg + 1 ioff = ineg - 1 do i = 1, itse datathom(i) = datathom(ioff+i) end do do i = 1, itse rthom(i) = rthom(ioff+i) end do do i = 1, itse sigma_thom(i) = sigma_thom(ioff+i) end do ! ! COMPUTE PRESSURE AND 1/SIGMA SPLINES IN R-SPACE (OR S-SPACE) ! a. PRESSURE SPLINE ! datanorm = zero delse2(:itse) = one pcalc(:itse) = one/sigma_thom(:itse)**2 datalsq_p(:itse) = datathom(:itse)*pcalc(:itse) scthom = sum(abs(datathom(:itse)/sigma_thom(:itse))) datanorm = sum(abs(datathom(:itse))) scthom = datanorm/scthom call setspline (rthom, pcalc, datalsq_p, qtemp, ythom0, 1 y2thom0, delse2, 0.1*tensp/scthom**2, itse, natur) ! ! FIND PRESSURE PEAK USING SMOOTHED DATA ! isamax = maxloc(ythom0(:itse)) i = isamax(1) pthommax = ythom0(i) rthompeak = rthom(i) ileft = 0 !Count data points to left of peak l4v(:itse) = rthom(:itse) < rthompeak do i = 1, itse if (l4v(i)) ileft = ileft + 1 end do if (ipnodes .le. 0) then ipnodes = max(ileft + 1,itse - ileft) ipnodes = min(inode_max,ipnodes) ipnodes = max(5,ipnodes) !At least 5 spline knots if (.not.lpprof) ipnodes = 7 endif if (ipnodes < 5) stop 'MUST PICK IPNODES > 4' write (nthreed, *) 1 'Number of pressure-spline knots (in s-space): ', ipnodes allocate( nk_pa(ipnodes), nk_pb(ipnodes), ythom(ipnodes), 1 y2thom(ipnodes), hthom(ipnodes), pknots(ipnodes) ) if (istat1 .ne. 0) then print *, ' ISTAT1 = ', istat1, ' ALLOCATION NK_PA' stop endif ! ! COMPUTE NODES IN SQRT(S) SPACE FOR SPLINES ! (SEE COMMENTS ABOVE PRECEDING SKNOTS(I) CALCULATION) ! do i = 1, ipnodes pknots(i) = real(i - 1,rprec)/(ipnodes - 1) end do hthom(:ipnodes-1) = pknots(2:ipnodes) - pknots(:ipnodes-1) ! ! COMPUTE MINOR RADII FOR DETERMINING PHIEDGE ! if (lpofr) then rthommax = rthom(itse) rthommin = rthom(1) presin = datathom(1) presout = datathom(itse) presmin = min(presin,presout) ipresin = 0 ipresout = 0 if (presin .eq. presmin) then ipresin = 1 if (presout.le.c1p5*presmin .or. presout<=0.1_dp*presmax) 1 ipresout = 1 else ipresout = 1 if(presin.le.c1p5*presmin .or. presin<=0.1_dp*presmax) 1 ipresin=1 endif else ipresin = 0 !Only use theta=0 in pofs ipresout = 1 endif endif !End of if(itse.gt.0) test ! ! COMPUTE INDICES OF FLUX LOOP MEASUREMENTS NEEDED FOR ! LOOP SIGNAL MATCHING ! ALSO COMPUTE CONNECTED EXTERNAL POLOIDAL FLUX ARRAY if (.not.lfreeb) then nflxs = 0 nobser = 0 nobd = 0 nbsets = 0 end if nmeasurements = imse + itse + 2 + nflxs !!1 for diamag, 1 for edge MSE do n = 1, nobser needflx(n) = idontneed iconnect(1,nobd+n) = n !For outputting absolute flux if (lasym) cycle ! Save Index of up-down symmetric spatial observation points do n1 = 1,n-1 if ((xobser(n1).eq. xobser(n)) .and. > (zobser(n1).eq.-zobser(n))) needflx(n) = n1 enddo end do do n = 1, nobd dsiext(n) = zero if (sigma_flux(n) .lt. zero) sigma_flux(n) = 1 abs(sigma_flux(n)*dsiobt(n)) if (sigma_flux(n) .eq. zero) sigma_flux(n) = 0.0001 do icount = 1, 4 index = iconnect(icount,n) tsign = sign(1,index) if(index.ne.0)dsiext(n) = dsiext(n)+psiext(abs(index))*tsign end do end do do n = 1,nflxs index = indxflx(n) if (index.gt.0) then plflux(index) = dsiobt(index) - dsiext(index) !n-th connected PLASMA flux do icount = 1,4 ind = abs(iconnect(icount,index)) if ((ind.gt.0).and.(needflx(ind).eq.IDONTNEED)) 1 needflx(ind) = NEEDIT enddo endif enddo ! ! COMPUTE INDICES OF EXTERNAL BFIELD MEASUREMENTS NEEDED ! FOR SIGNAL MATCHING ! FOR MULTIPLE ANGLES AT THE SAME R,Z,PHI LOCATION, IT IS ! ASSUMED THE LOOP DATA ARE CONSECUTIVELY ORDERED ! do n = 1, nbsets nmeasurements = nmeasurements + nbfld(n) do m = 1,nbcoils(n) needbfld(m,n) = IDONTNEED if( (m.gt.1).and.(rbcoil(m,n).eq.rbcoil(m-1,n)).and. 1 (zbcoil(m,n).eq.zbcoil(m-1,n)) )needbfld(m,n)=ISAMECOIL if( sigma_b(m,n).lt.zero )sigma_b(m,n) = 1 abs(sigma_b(m,n) * bbc(m,n)) if( sigma_b(m,n).eq.zero )sigma_b(m,n) = 0.0001 if (lasym) cycle ! CHECK FOR ANTISYMMETRIC SITUATED COIL FOR M1 < M, N <= NSETS do n1 = 1, nbsets do m1 = 1, m-1 if( (rbcoil(m1,n1).eq.rbcoil(m,n)) .and. 1 (zbcoil(m1,n1).eq.-zbcoil(m,n)).and. 2 (abcoil(m1,n1).eq.abcoil(m,n)) ) 3 needbfld(m,n) = n1 + nbsets*(m1-1) enddo enddo enddo enddo do n1 = 1, nbsets do m1 = 1,nbfld(n1) index = indxbfld(m1,n1) if( index.gt.0 )then !m-th PLASMA B-field plbfld(index,n1) = bbc(index,n1) - bcoil(index,n1) if( needbfld(index,n1).eq.IDONTNEED ) 1 needbfld(index,n1) = NEEDIT endif enddo enddo end subroutine fixrecon subroutine getpresprofile use vmec_main use vsvd implicit none C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: i real(rprec) :: sigmin C----------------------------------------------- ! ! WRITE OVER THOMPSON DATA ! lpofr = .false. !!these data are at s-half nodes lpprof = .false. itse = 10 pthommax = datathom(1) !!compute in final version sigmin = 0.03*pthommax do i = 1, itse rthom(i) = real(i - 1,rprec)/(itse - 1) datathom(i) = (pthommax - sigmin)*(1. - rthom(i))**2 + sigmin sigma_thom(i) = 0.2*pthommax end do end subroutine getpresprofile subroutine getgreen use vsvd use vparams, only: twopi implicit none C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: jnm, i real(rprec), dimension(10) :: ak, bk real(rprec), dimension(9) :: ae, be real(rprec), dimension(jngrn) :: ye, yk, sqrt1u real(rprec):: dqk2, qk2, eta, alg, sum1, suma, sum2, 1 sumb, sum3, sumc, sum4, sumd C----------------------------------------------- data ak/3.0072519903686507E-04_dp, 3.9684709020989806E-03_dp, 1 1.0795990490591656E-02_dp, 1.0589953620989356E-02_dp, 2 7.5193867218083799E-03_dp, 8.9266462945564728E-03_dp, 3 1.4942029142282098E-02_dp, 3.0885173001899746E-02_dp, 4 9.6573590301742396E-02_dp, 1.3862943611198872e+0_dp/ data bk/6.6631752464607272E-05_dp, 1.7216147097986537E-03_dp, 1 9.2811603829686118E-03_dp, 2.0690240005100891E-02_dp, 2 2.9503729348688723E-02_dp, 3.7335546682286003E-02_dp, 3 4.8827155048118076E-02_dp, 7.0312495459546653E-02_dp, 4 1.2499999999764055e-1_dp, 5.0000000000000000e-1_dp/ data ae/3.2519201550638976E-04_dp, 4.3025377747931137E-03_dp, 1 1.1785841008733922E-02_dp, 1.1841925995501268E-02_dp, 2 9.0355277375409049E-03_dp, 1.1716766944657730E-02_dp, 3 2.1836131405486903E-02_dp, 5.6805223329308374E-02_dp, 4 4.4314718058336844E-1_dp/ data be/7.2031696345715643E-05_dp, 1.8645379184063365E-03_dp, 1 1.0087958494375104E-02_dp, 2.2660309891604169E-02_dp, 2 3.2811069172721030E-02_dp, 4.2672510126591678E-02_dp, 3 5.8592707184265347E-02_dp, 9.3749995116366946E-02_dp, 4 2.4999999999746159E-1_dp/ ! ! Compute "Green's Functions" for Poloidal Flux, 2*pi*R*A-sub-phi, ! BR, and BZ at point (XT,ZT) due to unit current (mu0*I = 1) at (XS,ZS) ... ! modified to interpolate on k**2 - 3-34-92 - sph ! jnm = jngrn - 1 odqk2 = (jnm) dqk2 = 1.0_dp/odqk2 do i = 2, jnm qk2 = dqk2*(i - 1) qsq(i) = qk2 eta = 1 - qk2 alg = log(eta) sum1 = ((((ak(1)*eta+ak(2))*eta+ak(3))*eta+ak(4))*eta+ak(5))* 1 eta + ak(6) suma = (((sum1*eta + ak(7))*eta+ak(8))*eta+ak(9))*eta + ak(10) sum2 = ((((bk(1)*eta+bk(2))*eta+bk(3))*eta+bk(4))*eta+bk(5))* 1 eta + bk(6) sumb = (((sum2*eta + bk(7))*eta+bk(8))*eta+bk(9))*eta + bk(10) yk(i) = suma - alg*sumb sum3 = (((ae(1)*eta+ae(2))*eta+ae(3))*eta+ae(4))*eta sumc = (((((sum3 + ae(5))*eta+ae(6))*eta+ae(7))*eta+ae(8))*eta+ 1 ae(9))*eta sum4 = (((be(1)*eta+be(2))*eta+be(3))*eta+be(4))*eta sumd = (((((sum4 + be(5))*eta+be(6))*eta+be(7))*eta+be(8))*eta+ 1 be(9))*eta ye(i) = sumc - alg*sumd + 1 yf(i) = ((1 + eta)*yk(i)-2*ye(i))/qk2 end do ye(1) = 0.25_dp*twopi ye(jngrn) = 1 yk(1) = ye(1) yk(jngrn) = 2*yk(jnm) - yk(jngrn-2) yf(1) = 0. yf(jngrn) = 2*yf(jnm) - yf(jngrn-2) qsq(1) = 0 qsq(jngrn) = 1 sqrt1u = sqrt(qsq(:jngrn))/twopi c !Factor of 1/2 from sqrt(4*xs*xt) yek(:jngrn) = 0.5_dp*sqrt1u*(ye(:jngrn)-yk(:jngrn)) yeq(:jngrn) = 0.25_dp*qsq(:jngrn)*sqrt1u*ye(:jngrn) c !Factor of 2 absorbed by sqrt(4 xt xs) yf(:jngrn) = twopi*sqrt1u*yf(:jngrn) dyek(:jnm) = (yek(2:jnm+1)-yek(:jnm))*odqk2 dyeq(:jnm) = (yeq(2:jnm+1)-yeq(:jnm))*odqk2 dyf(:jnm) = (yf(2:jnm+1)-yf(:jnm))*odqk2 end subroutine getgreen subroutine getlim use vmec_main use realspace use vsvd implicit none C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec), parameter :: resup = 3.0_dp real(rprec), parameter :: resdn = 0.5_dp real(rprec), parameter :: eps = 0.005_dp C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: ntheta_2pi, nphi_plane, i, 1 nthtot, iexpand, ishrink, ionlim, n, 2 limpts, nonlim, nexpand, nshrink, ilim0, nlim0 real(rprec), dimension(2*ntheta1) :: 1 rbdy, zbdy, rubdy, zubdy real(rprec) :: fshrink, distmax, fexpand C----------------------------------------------- c c DETERMINES WHEN PLASMA TOUCHES LIMITER c USE DOUBLE THE NO. OF THETA POINTS FOR INCREASED RESOLUTION c ntheta_2pi = ntheta1 nphi_plane = 1 !Pick a phi plane (phi = 0 for now) rbdy(:ntheta3*2-1:2) = r1(ns*nphi_plane:ns*ntheta3*nphi_plane:ns* 1 nphi_plane,0) + r1(ns*nphi_plane:ns*ntheta3*nphi_plane:ns* 2 nphi_plane,1) zbdy(:ntheta3*2-1:2) = z1(ns*nphi_plane:ns*ntheta3*nphi_plane:ns* 1 nphi_plane,0) + z1(ns*nphi_plane:ns*ntheta3*nphi_plane:ns* 2 nphi_plane,1) rubdy(:ntheta3*2-1:2) = ru(ns*nphi_plane:ns*ntheta3*nphi_plane:ns* 1 nphi_plane,0) + ru(ns*nphi_plane:ns*ntheta3*nphi_plane:ns* 2 nphi_plane,1) zubdy(:ntheta3*2-1:2) = zu(ns*nphi_plane:ns*ntheta3*nphi_plane:ns* 1 nphi_plane,0) + zu(ns*nphi_plane:ns*ntheta3*nphi_plane:ns* 2 nphi_plane,1) if (.not.lasym) then ! FOR NOW, THIS ONLY WORKS FOR NZETA=1 (PHI=0 PLANE) ! TO EXTEND TO OTHER PHI PLANES, MUST USE IREFLECT(NZETA) do i = 1, ntheta_2pi - ntheta2 rbdy(2*(ntheta2+i)-1) = rbdy(2*(ntheta1-ntheta2-i)+3) end do do i = 1, ntheta_2pi - ntheta2 zbdy(2*(ntheta2+i)-1) = -zbdy(2*(ntheta1-ntheta2-i)+3) end do do i = 1, ntheta_2pi - ntheta2 rubdy(2*(ntheta2+i)-1) = -rubdy(2*(ntheta1-ntheta2-i)+3) end do do i = 1, ntheta_2pi - ntheta2 zubdy(2*(ntheta2+i)-1) = zubdy(2*(ntheta1-ntheta2-i)+3) end do end if ! ! FIND EVEN INDEXED POINTS BY INTERPOLATION ! nthtot = 2*ntheta_2pi rbdy(nthtot) = .5_dp*(rbdy(1)+rbdy(nthtot-1)) zbdy(nthtot) = .5_dp*(zbdy(1)+zbdy(nthtot-1)) rubdy(nthtot) = .5_dp*(rubdy(1)+rubdy(nthtot-1)) zubdy(nthtot) = .5_dp*(zubdy(1)+zubdy(nthtot-1)) rbdy(2:(ntheta_2pi-1)*2:2) = .5_dp*(rbdy(3:ntheta_2pi*2-1:2) + 1 rbdy(:ntheta_2pi*2-3:2)) zbdy(2:(ntheta_2pi-1)*2:2) = .5_dp*(zbdy(3:ntheta_2pi*2-1:2) + 1 zbdy(:ntheta_2pi*2-3:2)) rubdy(2:(ntheta_2pi-1)*2:2) = .5_dp*(rubdy(3:ntheta_2pi*2-1:2)+ 1 rubdy(:ntheta_2pi*2-3:2)) zubdy(2:(ntheta_2pi-1)*2:2) = .5_dp*(zubdy(3:ntheta_2pi*2-1:2)+ 1 zubdy(:ntheta_2pi*2-3:2)) fshrink = 0.0_dp distmax = sum(rbdy(:nthtot)**2) + sum(zbdy(:nthtot)**2) fexpand = distmax iexpand = 0 ishrink = 0 ionlim = 0 do n = 1, nlim limpts = limitr(n) call cauchy (rbdy, zbdy, rubdy, zubdy, rlim(:,n), zlim(:,n), 1 reslim(:,n), seplim(:,n), distmax, nthtot, limpts) do i = 1,limpts c LIMITER POINT ON PLASMA if( (abs(reslim(i,n)-resdn).lt.eps) )then ! .gt. .or. (abs(reslim(i,n)).gt.resup) )then ionlim = i nonlim = n c LIMITER POINT OUTSIDE PLASMA else if( reslim(i,n).lt.RESDN )then if( seplim(i,n).le.fexpand )then fexpand = seplim(i,n) iexpand = i nexpand = n endif c LIMITER POINT INSIDE PLASMA else if( reslim(i,n).ge.RESDN )then if( seplim(i,n).gt.fshrink )then fshrink = seplim(i,n) ishrink = i nshrink = n endif endif enddo end do c c LOGIC: IF THERE IS A LIMITER POINT INSIDE PLASMA, THEN MUST c SHRINK CONTOUR. OTHERWISE, IF THERE IS AT LEAST ONE LIMITER c POINT ON CONTOUR, AND ALL THE REST OUTSIDE, DO NOT CHANGE ANYTHING. c FINALLY, IF ALL LIMITER POINTS ARE OUTSIDE PLASMA, EXPAND PLASMA c TO OSCULATE WITH LIMITER c if (ishrink .gt. 0) then gphifac = -sqrt(fshrink) ilim0 = ishrink nlim0 = nshrink else if (ionlim .gt. 0) then gphifac = 0. ilim0 = ionlim nlim0 = nonlim else if (iexpand .gt. 0) then gphifac = sqrt(fexpand) ilim0 = iexpand nlim0 = nexpand endif dlim_min = gphifac rlim_min = rlim(ilim0,nlim0) zlim_min = zlim(ilim0,nlim0) c overall damping in time, rsfac/sqrt(rsfac) = sqrt(rsfac) gphifac = gphifac/r01 if (abs(gphifac) .gt. 0.04*one) 1 gphifac = 0.04*gphifac/abs(gphifac) gphifac = 0.20*gphifac/sqrt(rsfac) end subroutine getlim subroutine cauchy(rbdy, zbdy, rubdy, zubdy, rlim, zlim, residue, 1 sep, distmax, ntheta, nlim) use vparams, only: twopi, dp, rprec implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer, intent(in) :: ntheta, nlim real(rprec), intent(in) :: distmax real(rprec), dimension(ntheta), intent(in) :: 1 rbdy, zbdy, rubdy, zubdy real(rprec), dimension(nlim) :: rlim, zlim, residue, sep C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec), parameter :: zero=0, p5=0.5_dp, two=2 C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: n, i, imin, imax real(rprec), dimension(ntheta) :: dsq, dsepdu real(rprec), dimension(ntheta) :: x1u, y1u real(rprec) :: delu, dmin, delta_d, alpha, gam0 C----------------------------------------------- c Check that the points (rlim(i),zlim(i)) are inside boundary surface c using Cauchys theorem in "complex"-plane (for a fixed c toroidal plane, nphi=const. It is assumed that rbdy, zbdy are c extended around the full interval, 0-2pi, in theta. c with rbdy(1) = rbdy(ntheta+1) (i.e., ntheta intervals) c c Because of numerical inaccuracies, instead of testing on c res = 0 (outside), res = 1 (inside), we use the test: c res >= .5, inside; res < .5, outside c********************************************************************** c c LOCAL VARIABLE ARRAYS c c dsq: Distance squared between limiter point and plasma boundary c sep: Minimum dsq for each limiter point c dsepdu: .5* d(dsq)/d(theta) c residue: Contour integral of 1/(X-rlim)in complex X=(R,Z) plane c delu = twopi/ntheta dmin = 1.E-20_DP*distmax do n = 1, nlim residue(n) = zero x1u = rbdy(:ntheta) - rlim(n) y1u = zbdy(:ntheta) - zlim(n) dsq(:ntheta) = x1u*x1u + y1u*y1u dsepdu(:ntheta) = x1u*rubdy(:ntheta) + y1u*zubdy(:ntheta) residue(n) = residue(n) + sum((x1u*zubdy(:ntheta) - 1 y1u*rubdy(:ntheta))/(dsq(:ntheta)+dmin)) residue(n) = residue(n)/ntheta ! ! Find actual minimum distance from nth limiter point to boundary ! sep(n) = distmax do i = 1,ntheta if( dsq(i).le.sep(n) )then imin = i sep(n) = dsq(i) endif enddo ! gamu = two*abs(dsepdu(imin))*delu if (dsepdu(imin) .le. zero) then imax = 1 + mod(imin,ntheta) else imax = imin imin = imax - 1 if (imin .eq. 0) imin = ntheta endif delta_d = two*(dsepdu(imax)-dsepdu(imin)) alpha = delta_d/delu ! gamu = gamu/delta_d ! sep(n) = sep(n) - p5*alpha*gamu**2 if (alpha .ne. zero) 1 gam0 = 0.5_dp - (dsq(imax)-dsq(imin))/(alpha*delu**2) sep(n) = dsq(imin) - p5*alpha*(gam0*delu)**2 if (sep(n) .lt. zero) sep(n) = zero end do end subroutine cauchy subroutine newprofil(phipog) use vmec_main use vacmod use realspace use vforces, lu => czmn, lv => crmn use vsvd use vspline use xstuff implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- real(rprec), dimension(*) :: phipog C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: icount, inodes, js integer, save :: idata(jchix), isize(jchix) !INCREMENTAL UPDATES real(rprec), dimension(ipnodes + isnodes) :: datalsq, wten real(rprec), dimension(1+nrzt) :: r12sqr real(rprec) :: amat_lsq(isnodes+ipnodes,isnodes+ipnodes), 1 djac_p(ipnodes,nmeasurements), djac_i(isnodes,nmeasurements) real(rprec), dimension(nmeasurements) :: datainput real(rprec) :: treconon, delt1, pfac0, aminout, 1 aminin, ymin, pfactor, treconoff C----------------------------------------------- ! IDATA: GIVES STARTING INDEX IN DATAINPUT ARRAY ! FOR STORING EACH OF THE DATA TYPES ! ISIZE: GIVES NUMBER OF DATA STARTING AT IDATA ! INDEXING OF DJAC ARRAY (ASSUMES K STARTS AT 0) inodes = isnodes + ipnodes call second0 (treconon) ! Unfreeze magnetic axis if (iresidue.eq.0 .and. fsq*1.e6_dp.lt.one) iresidue = 1 delt1 = one/real(ipedsvd,rprec) if (iresidue .eq. 0) delt1 = one ! ! COMPUTE AVERAGE RADIAL FORCE BALANCE CONSTRAINT ! call radfor (pfac0) pfac = pfac + delt1*(pfac0 - pfac) ! ! UPDATE PHI SCALE FACTOR (PHIFAC) ! SCALE TOROIDAL FLUX TO MATCH PRESSURE WIDTH OR LIMITER ! aminout = max(rthommax,rstarkmax) - r00 aminin = r00 - min(rthommin,rstarkmin) apres = (aminin*ipresin + aminout*ipresout)/(ipresin +ipresout) aminor = ((r00 - rinner)*ipresin + (router - r00)*ipresout)/ 1 (ipresin + ipresout) if (imatch_phiedge.ne.1 .and. ivac.gt.1 .or. imatch_phiedge.eq.3 1 .and. (.not.lfreeb)) then call newphi (phipog) call gettflux endif icount = 0 if (.not.(mod(iter2 - iter1,ipedsvd).ne.0 .and. iequi.eq.0 1 .and. iresidue.gt.0)) then ! ! SETUP COMMON BLOCKS FOR FLUX-MATCHING ROUTINES ! if (iphidiam + nflxs + nbfldn.gt.0 .or. iequi.gt.0) then r12sqr(2:nrzt) = sqrt(armn_o(2:nrzt)) call flux_init (phipog) endif ! ! COMPUTE MATRIX ELEMENTS FOR THOMPSON SCATTERING DATA ! idata(ithom0) = icount + 1 call getthom(djac_i(1,idata(ITHOM0)), djac_p(1,idata(ITHOM0)), 1 datainput(idata(ITHOM0)), r1(1:,0), r1(1:,1), isize(ITHOM0)) icount = icount + isize(ithom0) ! ! COMPUTE MOTIONAL STARK EFFECT. THIS CALL ALSO INITIALIZES ! THE ALSQ, DATALSQ ARRAYS AND SETS UP THE SPLINE NODES. ! idata(istark0) = icount + 1 call getmse(djac_i(1,idata(ISTARK0)), djac_p(1,idata(ISTARK0)), 1 datainput(idata(ISTARK0)), r1(1:,0), r1(1:,1),lu, 2 lu(1+nrzt), zu(1:,0), zu(1:,1), phipog, isize(ISTARK0)) icount = icount + isize(istark0) ! ! COMPUTE MATRIX ELEMENTS FOR DIAMAGNETIC FLUX LOOP ! idata(idiam0) = icount + 1 call getdiam (djac_i(1,idata(idiam0)), djac_p(1,idata(idiam0)) 1 , datainput(idata(idiam0)), isize(idiam0)) icount = icount + isize(idiam0) ! ! COMPUTE MATRIX ELEMENTS FOR EXTERNAL POLOIDAL FLUXES ! idata(iflxs0) = icount + 1 call getflux (djac_i(1,idata(iflxs0)), djac_p(1,idata(iflxs0)) 1 , datainput(idata(iflxs0)), r12sqr, clmn_e(1), clmn_o(1), 2 blmn_o(1), armn_o(1), blmn_e(1), azmn_o(1), isize(iflxs0)) icount = icount + isize(iflxs0) ! ! COMPUTE MATRIX ELEMENTS FOR EXTERNAL MAGNETIC FIELD MATCHING ! idata(ibrzfld) = icount + 1 call getbfld (djac_i(1,idata(ibrzfld)), djac_p(1,idata(ibrzfld) 1 ), datainput(idata(ibrzfld)), r12sqr, azmn_o(1), blmn_o(1), 2 clmn_e(1), clmn_o(1), armn_o(1), blmn_e(1), isize(ibrzfld)) icount = icount + isize(ibrzfld) ! ! SQUARE DATA MATRIX ELEMENTS AND STORE IN ALSQ ! if (icount .gt. nmeasurements) stop 'icount>nmeasurements' if (iequi .eq. 0) then call sgemvmm (djac_i, djac_p, amat_lsq, datainput, datalsq, 1 wten, icount, isnodes, ipnodes, inodes) ! ! COMPUTE IOTA, PRESSURE SPLINE COEFFICIENTS ! call set_dual (datalsq, hstark, ystark, y2stark, hthom, 1 ythom, y2thom, wten, amat_lsq, isnodes, ipnodes, inodes) if (.not.lpprof) then ymin = minval(ythom(1:ipnodes)) ythom(:ipnodes) = ythom(:ipnodes) - ymin endif ! ! COMPUTE IOTA, PRESSURE AT R(js) FROM SPLINED INPUT ! DATA ALONG THE MIDPLANE ! call splint (sknots, ystark, y2stark, isnodes, sqrts, 1 isplinef, zero, ns) call splint (sknots, ystark, y2stark, isnodes, shalf(2), 1 isplineh(2), zero, ns1) call splint (pknots, ythom, y2thom, ipnodes, sqrts, psplinef 1 , zero, ns) call splint (pknots, ythom, y2thom, ipnodes, shalf(2), 1 psplineh(2), zero, ns1) pfactor = dmu0*pthommax !!*pfac moved to getthom do js = 1,ns isplinef(js) = isplinef(js) - iotaf(js) isplineh(js) = isplineh(js) - iotas(js) psplinef(js) = pfactor*psplinef(js) - presf(js) psplineh(js) = pfactor*psplineh(js) - mass(js) end do endif ! iequi>0 ! ! COMPUTE CHISQ ! call chisq (djac_i, djac_p, datainput, idata, isize, icount) endif ! mod(iter2-iter1,ipedsvd) == 0 if (iequi .eq. 0) then ! ! UPDATE PRESSURE SPLINE AND ESTABLISH INTERNAL ! (CODE) UNITS OF PRESSURE. P(real) = dmu0 * pthommax * P(splined) ! WHERE P(code-units) = mu0 * P(real) ! SMOOTH TIME VARIATION OF PROFILES ! do js = 1,ns iotaf(js) = iotaf(js) + delt1*isplinef(js) iotas(js) = iotas(js) + delt1*isplineh(js) presf(js) = presf(js) + delt1*psplinef(js) mass(js) = mass(js) + delt1*psplineh(js) end do endif ! ! STORE CHISQ ! call store_chisq ! ! OPTIMIZE MAGNETIC AXIS POSITION BY MINIMIZING RMS ERROR ! RETURNS RAXMSE AS UPDATED GUESS FOR NEW AXIS POSITION ! TO BE USED IN SUBROUTINE RESIDUE ! call axisopt (fsq, r00, iresidue, ivac) ! Compute force to fix axis at RAXMSE grmse = -0.05*(r00 - raxmse) call second0 (treconoff) timer(6) = timer(6) + (treconoff - treconon) end subroutine newprofil subroutine flux_init(phipog) use vmec_main use vmec_params, only: signgs use vforces, only : r12=>armn_o, gsqrt=>azmn_o, orsq=>blmn_o use vsvd use realspace implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- real(rprec), dimension(*) :: phipog C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec), parameter :: p5 = 0.5_dp, c1p5 = 1.5_dp C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: l, js real(rprec), external :: dot_g C----------------------------------------------- ! ! COMPUTE OBSERVATION POINT - INVARIANT FUNCTIONS OF RADIUS ! CURRENT = PHIP * INTEGRAL(0,2pi)[ guu / gsqrt] (on full mesh) ! RM2 = < R**(-2) > ! VRM2 = V` * RM2 (V` = 2pi * VP) ! ORSQ = SQRT(G) * R**(-2) (on half mesh) ! ! MUST HAVE GONE THROUGH NEWPROFILE DETERMINATION OF IOTA AT ! LEAST ONCE, OTHERWISE IOTAS IS UNDEFINED! ! if (iresidue .le. 0) return current(1) = zero presint(1) = one do l = 2,nrzt-1 orsq(l) = p5*( phipog(l) + phipog(l+1) ) * 1 (ru0(l)*ru0(l) + zu0(l)*zu0(l)) enddo do l = ns,nrzt,ns orsq(l) = ( c1p5*phipog(l) - p5*phipog(l-1) ) * 1 (ru0(l)*ru0(l) + zu0(l)*zu0(l)) enddo do js = 2, ns current(js) = twopi*DOT_G(nznt,orsq(js),ns,wint(js),ns) presint(js) = one end do do l = 2, nrzt orsq(l) = gsqrt(l)/r12(l)**2 end do do js = 2, ns vrm2(js) = twopi*DOT_G(nznt,orsq(js),ns,wint(js),ns) rm2(js) = vrm2(js)/(twopi*signgs*vp(js)) ovrm2(js) = one/vrm2(js) ochip(js) = one/(phip(js)*iotas(js)) presph(js) = presf(js) - presf(js - 1) end do end subroutine flux_init subroutine getbfld(amat_i, amat_p, data_array, r12sqr, 1 gsqrt, orsq, gobsr1, gobsz1, r12, z12, kcbfld) use vmec_main use vmec_params, only: signgs use vsvd use realspace, only: wint use vspline, only: hthom, hstark implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer kcbfld real(rprec), dimension(isnodes,*) :: amat_i real(rprec), dimension(ipnodes,*) :: amat_p real(rprec), dimension(*) :: data_array real(rprec), dimension(nrzt) :: r12sqr, 1 gsqrt, orsq, gobsr1, gobsz1, r12, z12 C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: js, n1, m1, iobs, isym, iobsmax, iloop, 1 msym, nsym, indexbfld, l, lk real(rprec), dimension(:), allocatable :: gobsz2, gobsr2 real(rprec):: tpisg, sumir, sumiz, wscaleb, sumpr, 1 sumpz, deltab, plasbfld, coscoil, sincoil, t2, t1 C---------------------------------------------- ! IRESIDUE > 0, OTHERWISE FLUX_INIT NOT CALLED YET kcbfld = 0 if (iresidue.le.0 .or. (nbfldn.eq.0 .and. iequi.eq.0))return allocate( gobsz2(nrzt), gobsr2(nrzt), stat=l) if (l .ne. 0) stop 'allocation problem in getbfld' ! ! COMPUTE "GREEN'S FUNCTION" KERNEL ONLY FOR NEEDED OBSERVATION POINTS ! (OR FOR FINAL OUTPUT IF IEQUI=1) ! GOBSR1 = BR, GOBSZ1 = BZ ! IF A (BR,BZ) OR (BRHO,BTHETA) PAIR, JUST CALL GRNBFLD ONCE ! if (any(rm2(2:ns) .eq. zero)) stop 'rm2 = 0' tpisg = twopi * signgs !Positive volume integral do n1 = 1, nbsets do m1 = 1, nbcoils(n1) isym = needbfld(m1,n1) if (isym.eq.needit .or. iequi.eq.1) then call grnbfld(r12sqr,r12,z12,gobsr1,gobsz1,nrzt,m1,n1) do l = 2,nrzt gobsr2(l) = gobsr1(l)*orsq(l) gobsr1(l) = gobsr1(l)*gsqrt(l) gobsz2(l) = gobsz1(l)*orsq(l) gobsz1(l) = gobsz1(l)*gsqrt(l) end do ! ! DO INTEGRAL OVER ANGLES (ALL INTEGRALS ARE FROM THETA=0,TWOPI) ! do js = 2, ns sumir = zero sumiz = zero sumpr = zero sumpz = zero do lk = js,nrzt,ns sumir = sumir + gobsr2(lk)*wint(lk) sumpr = sumpr + gobsr1(lk)*wint(lk) sumiz = sumiz + gobsz2(lk)*wint(lk) sumpz = sumpz + gobsz1(lk)*wint(lk) enddo imb(js,m1,n1,1) = tpisg*sumir pmb(js,m1,n1,1) = (-tpisg*sumpr) + imb(js,m1,n1,1) 1 /rm2(js) imb(js,m1,n1,2) = tpisg*sumiz pmb(js,m1,n1,2) = (-tpisg*sumpz) + imb(js,m1,n1,2) 1 /rm2(js) end do else if (isym .eq. ISAMECOIL) then !Same coil position as previous coil do js = 2,ns imb(js,m1,n1,1) = imb(js,m1-1,n1,1) pmb(js,m1,n1,1) = pmb(js,m1-1,n1,1) imb(js,m1,n1,2) = imb(js,m1-1,n1,2) pmb(js,m1,n1,2) = pmb(js,m1-1,n1,2) enddo endif enddo !m1 enddo !n1 ! ! CHECK FOR SYMMETRIC COIL (MAY BE IN DIFFERENT COIL SET, ! SO HAD TO MOVE OUT OF M1,N1 LOOP ABOVE) ! do n1 = 1,nbsets do m1 = 1,nbcoils(n1) isym = needbfld(m1,n1) if (isym .ge. ISYMCOIL) then msym = 1 + (isym-1)/nbsets nsym = 1 + mod(isym-1,nbsets) do js = 2,ns !BR(-Z) = -BR(Z), BZ(-Z) = BZ(Z) imb(js,m1,n1,1) =-imb(js,msym,nsym,1) pmb(js,m1,n1,1) =-pmb(js,msym,nsym,1) imb(js,m1,n1,2) = imb(js,msym,nsym,2) pmb(js,m1,n1,2) = pmb(js,msym,nsym,2) enddo endif enddo enddo ! ! COMPUTE SPLINE MATRIX ELEMENTS BY INTEGRATING OVER RADIUS ! do 2000 iloop = 0,iequi !iequi = 0 normally, = 1 at end do n1 = 1, nbsets iobsmax = nbfld(n1) if (iloop .eq. 1) iobsmax = nbcoils(n1) if (iobsmax .gt. 0) then do 1000 iobs = 1, iobsmax indexbfld = indxbfld(iobs,n1) if (iloop .eq. 1) indexbfld = iobs if (indexbfld .le. 0) goto 1000 coscoil = cos( abcoil(indexbfld,n1) ) sincoil = sin( abcoil(indexbfld,n1) ) do js = 2,ns pmb(js,0,n1,1) = ochip(js) * > (pmb(js,indexbfld,n1,1)*coscoil + > pmb(js,indexbfld,n1,2)*sincoil) imb(js,0,n1,1) = ovrm2(js) * > (imb(js,indexbfld,n1,1)*coscoil + > imb(js,indexbfld,n1,2)*sincoil) end do if (iloop .eq. 0) then deltab = plbfld(indexbfld,n1) kcbfld = kcbfld + 1 call splinint (imb(1,0,n1,1), current, 1 amat_i(1,kcbfld), hstark, u_ib, u1_ib, 2 w_ib, w1_ib, nk_ib, isnodes, intder, ns) call splinint (pmb(1,0,n1,1), presint, 1 amat_p(1,kcbfld), hthom, u_pb, u1_pb, w_pb, 2 w1_pb, nk_pb, ipnodes, intder, ns) wscaleb = one/sigma_b(indexbfld,n1) data_array(kcbfld) = wscaleb*deltab t2 = dmu0*pthommax !!*pfac moved to getthom amat_i(:,kcbfld) = wscaleb*amat_i(:,kcbfld) wscaleb = wscaleb*t2 amat_p(:,kcbfld) = wscaleb*amat_p(:,kcbfld) else !Store plasma fluxes in EXTFLX for output plasbfld = zero do js = 2, ns t1 = current(js)*iotaf(js) - current(js-1)* 1 iotaf(js - 1) plasbfld = plasbfld + pmb(js,0,n1,1)* 1 presph(js) + imb(js,0,n1,1)*t1 end do plbfld(iobs,n1) = plasbfld endif 1000 continue endif enddo !n1 2000 continue deallocate( gobsz2, gobsr2, stat=l) end subroutine getbfld subroutine getdiam(amat_i, amat_p, data_array, kcdiam) use vmec_main use vmec_params, only: signgs use realspace use vforces, only : r12=>armn_o, ru12=>azmn_e use vsvd use vspline implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer kcdiam real(rprec), dimension(isnodes,*) :: amat_i real(rprec), dimension(ipnodes,*) :: amat_p real(rprec), dimension(*) :: data_array C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- integer, parameter :: ilimit = 2 C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: js, lk, l real(rprec), dimension(ns) :: gp, gi, gip real(rprec), dimension(isnodes) :: amat2_i real(rprec) :: wdiam, z12, tv, ti, t2, sum1 C----------------------------------------------- kcdiam = 0 if (iphidiam.eq.0 .or. iresidue.lt.ilimit) return ! ! COMPUTE FIT TO DIAMAGNETIC SIGNAL, USING EQUILIBRIUM RELATION ! (modified 7/96 by SPH) ! ! PHI-DIAMAG = 2*pi*INT[ Gp dp/ds + Gi d(<Bu>)/ds ] ! ! where ! ! Gp = Ru * Z * <sqrt(g)> /(R * phip) ! Gi = Ru * Z * iota / R ! kcdiam = kcdiam + 1 c-7/96 dNewPhiedge = signgs*twopi*hs*SSUM_1(ns1,phip(2),1) c-7/96 VacPhiedge = signgs*bsubvvac*hs*SSUM_1(ns1,vrm2(2),1) c-7/96 delphid0 = VacPhiedge - dNewPhiedge wdiam = one/sigma_delphid gp(1) = zero gi(1) = zero do js = 2, ns gp(js) = zero do lk = 1, nznt l = js + ns*(lk - 1) z12 = .5_dp*(z1(l,0)+z1(l-1,0)+shalf(l)*(z1(l,1)+z1(l-1,1))) gp(js) = gp(js) + ru12(l)*z12/r12(l)*wint(l) end do end do ! ! NOTE: gip terms comes from linearizing the iota*d/ds[current*iota] ! terms ! do js = 2, ns tv = twopi*vp(js)/phip(js) ti = -gp(js)*signgs*wdiam gi(js) = ti*iotas(js) gp(js) = -gp(js)*tv*wdiam gip(js) = ti*(current(js)*iotaf(js)-current(js-1)*iotaf(js-1)) end do call splinint (gi, current, amat_i(1,kcdiam), hstark, u_ib, u1_ib 1 , w_ib, w1_ib, nk_ib, isnodes, intder, ns) call splinint (gip(2), current(2), amat2_i, hstark, u_ia, u1_ia, 1 w_ia, w1_ia, nk_ia, isnodes, intfun, ns1) call splinint (gp, presint, amat_p(1,kcdiam), hthom, u_pb, u1_pb, 1 w_pb, w1_pb, nk_pb, ipnodes, intder, ns) amat_i(:isnodes,kcdiam) = amat_i(:isnodes,kcdiam) + amat2_i(: 1 isnodes) t2 = dmu0*pthommax !!*pfac moved to getthom amat_p(:ipnodes,kcdiam) = t2*amat_p(:ipnodes,kcdiam) sum1 = sum(iotas(2:ns)*gip(2:ns)) data_array(kcdiam) = wdiam*phidiam + sum1 if (iequi .eq. 0) then ! ! Eliminate p variation until well-converged ! !@ do i = 1,ipnodes !@ data_array(kcdiam) = data_array(kcdiam) - !@ > amat_p(i,kcdiam)*ythom(i) !@ amat_p(i,kcdiam) = 0. !@ end do ! ! FINAL OUTPUT (ALSO USE FOR DEBUGGING) ! else ! ! Integrate by parts ! delphid = gp(ns)*presf(ns) + gi(ns)*iotaf(ns)*current(ns) - 1 gp(2)*presf(1) - gi(2)*current(1)*iotaf(1) do js = 2, ns1 delphid = delphid - presf(js)*(gp(js+1)-gp(js)) - iotaf(js)* 1 current(js)*(gi(js+1)-gi(js)) end do delphid = delphid/wdiam endif !@ do js = 2,ns !@ end do !@ !@ sumi = sum(amat_i(:isnodes,kcdiam)*ystark(:isnodes)) !@ > - sum(amat2_i(isnodes)*ystark(:isnodes)) !@ sump = DOT_G(ipnodes,amat_p(1,kcdiam),1,ythom,1) !@ !@ write(*,1212)delphid,(sumi+sump)/wdiam,delphid0 !@ 1212 format(' DelPhid = ',1pe10.3,' PhiD = ',1pe10.3, !@ > ' DelPhid0 = ',1pe10.3) end subroutine getdiam subroutine getflux(amat_i, amat_p, data_array, r12sqr, 1 gobser1, gobser2, orsq, r12, z12, gsqrt, kcflux) use vmec_main use vmec_params, only: signgs use realspace use vsvd use vspline use vparams, only: zero implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer kcflux real(rprec), dimension(isnodes,*) :: amat_i real(rprec), dimension(ipnodes,*) :: amat_p real(rprec), dimension(*) :: data_array real(rprec), dimension(nrzt) :: r12sqr, 1 gobser1, gobser2, orsq, r12, z12, gsqrt C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: js, l, iloop, iobsmax, iobs, index, indexflx, 1 isym, n1, lk real(rprec) :: t1, t2, tpisg, sign0, sumi, sump, delta C----------------------------------------------- ! IRESIDUE > 0, OTHERWISE FLUX_INIT NOT CALLED YET! kcflux = 0 if (iresidue.le.0 .or. (nflxs.eq.0 .and. iequi.eq.0)) return ! ! COMPUTES MATRIX ELEMENTS NEEDED TO RELATE OBSERVED FLUX ! MEASUREMENTS TO CURRENT AND PRESSURE EXPANSION COEFFICIENTS ! R12,Z12 ARE THE PLASMA R,Z COORDINATES AT THE HALF ! RADIAL NODE POINTS ! ! ! COMPUTE SYMMETRIZED PSI(R,Z)+PSI(R,-Z) FLUX "GREEN'S FUNCTION" ! ! ! COMPUTE "GREEN'S FUNCTION" KERNEL ONLY FOR NEEDED OBSERVATION POINTS ! (OR FOR FINAL OUTPUT IF IEQUI=1) ! tpisg = twopi*signgs !Positive volume integral do n1 = 1, nobser isym = needflx(n1) if (isym.eq.needit .or. iequi.eq.1) then call grnflx (r12sqr, r12, z12, gobser1, nrzt, n1) do l = 2,nrzt gobser2(l) = gobser1(l)*orsq(l) gobser1(l) = gobser1(l)*gsqrt(l) end do ! ! DO INTEGRAL OVER ANGLES (ALL INTEGRALS ARE FROM THETA=0,TWOPI) ! IM = <G/R**2>, PM = <G(1/R**2/<R**-2> - 1)> ! do js = 2, ns sumi = zero sump = zero do lk = js ,nrzt, ns sumi = sumi + gobser2(lk)*wint(lk) sump = sump + gobser1(lk)*wint(lk) enddo im(js,n1) = tpisg*sumi pm(js,n1) = (-tpisg*sump) + im(js,n1)/rm2(js) end do else if( isym.ge.ISYMCOIL )then !only for up-down symmetric plasmas do js = 2,ns im(js,n1) = im(js,isym) pm(js,n1) = pm(js,isym) enddo endif enddo !n1 loop ! ! COMPUTE SPLINE MATRIX ELEMENTS BY INTEGRATING OVER RADIUS ! do 2000 iloop = 0,iequi !iequi = 0 normally, = 1 at end iobsmax = nflxs if( iloop.eq.1 )iobsmax = nobd + nobser do 1000 iobs = 1,iobsmax indexflx = indxflx(iobs) if( iloop.eq.1 )indexflx = iobs if( indexflx.le.0 )go to 1000 do js = 2,ns pm(js,0) = zero im(js,0) = zero enddo do l = 1,4 !This could be halved by using symmetry index = iconnect(l,indexflx) if( index.ne.0 )then sign0 = 1.0 if( index.lt.0 )then sign0 = -sign0 index = -index endif do js = 2,ns pm(js,0) = pm(js,0) + sign0*pm(js,index) im(js,0) = im(js,0) + sign0*im(js,index) enddo endif enddo do js = 2,ns pm(js,0) = pm(js,0)*ochip(js) im(js,0) = im(js,0)*ovrm2(js) enddo if (iloop .eq. 0) then kcflux = kcflux + 1 delta = plflux(indexflx) call splinint (im, current, amat_i(1,kcflux), hstark, 1 u_ib, u1_ib, w_ib, w1_ib, nk_ib, isnodes, intder, 2 ns) call splinint (pm, presint, amat_p(1,kcflux), hthom, 1 u_pb, u1_pb, w_pb, w1_pb, nk_pb, ipnodes, intder, 2 ns) t1 = one/sigma_flux(indexflx) data_array(kcflux) = t1*delta amat_i(:,kcflux) = t1*amat_i(:,kcflux) t2 = t1*dmu0*pthommax !!*pfac moved to getthom amat_p(:,kcflux) = t2*amat_p(:,kcflux) else !Store plasma fluxes in PLFLUX for output plflux(indexflx) = zero do js = 2, ns plflux(indexflx) = plflux(indexflx) + pm(js,0)* 1 presph(js) + im(js,0)*(current(js)*iotaf(js)- 2 current(js-1)*iotaf(js-1)) end do endif 1000 continue 2000 continue end subroutine getflux subroutine getmse(amat_i, amat_p, data_array, re, ro, lue, luo, 1 zue, zuo, phipog, kcstark) use vmec_main use vmec_params, only: signgs use realspace use vsvd use vspline implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer kcstark real(rprec), dimension(isnodes,*) :: amat_i real(rprec), dimension(ipnodes,*) :: amat_p real(rprec), dimension(*) :: data_array real(rprec), dimension(ns,nzeta,*) :: 1 re, ro, lue, luo, zue, zuo real(rprec), dimension(*) :: phipog C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec), parameter :: c1p5 = 1.5_dp C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: lt, i, js, ks, j, irnodes real(rprec), dimension(ns,ntheta2) :: luef, luof real(rprec) :: dlu, dzu, guu1, edgeiota, guu2, edgefactor, 1 wedge, t1 real(rprec), save :: facedge C----------------------------------------------- ! ! THIS SUBROUTINE COMPUTES THE LEAST-SQUARES AMATRIX AND DATA ! ARRAYS FOR MATCHING TO THE MSE DATA AT EQUALLY-SPACED KNOTS ! IN SQRT(PHI-FLUX) SPACE (ISNODES, INCLUDING S=0 AND S=1) ! ! THE RANGE OF MSE DATA IS EXTENDED TO INCLUDE S=1 BY USING THE ! CURRENT MATCHING CONDITION TO CONSTRAIN IOTA(S=1) ! ! COMING INTO THIS ROUTINE, THE RSTARK, DATASTARK HAVE BEEN ! PREVIOUSLY ORDERED SO RSTARK(1) < RSTARK(2) < .... ! ! ! COMPUTE FULL MESH VALUES OF LAMBDA ! call lamfull (luef, luof, lue, luo) ! ! COMPUTE OUTER EDGE PITCH (IOTA) TO MATCH TOTAL CURRENT ! IOTA(EDGE) = MU0 * IPLASMA/ 2 * PI *< Guu/SQRTg > PHIP(s=1) ! NEED THIS TO SPLINE IOTA OVER FULL S-RANGE ( 0 .le. S .le.1 ) ! guu1 = dot_product(c1p5*wint(ns:nrzt:ns)*guu(ns:nrzt:ns), 1 phipog(ns:nrzt:ns)) guu2 = dot_product(cp5*wint(ns-1:nrzt-1:ns)*guu(ns-1:nrzt-1:ns), 1 phipog(ns-1:nrzt-1:ns)) if (iresidue.eq.0 .or. iotaf(ns).eq.zero) then facedge = one else if (mod(iter2 - iter1,ipedsvd) .eq. 0) then facedge = (guu1*iotas(ns) - guu2*iotas(ns1))/(iotaf(ns)*(guu1 1 - guu2)) endif edgefactor = facedge*(guu1 - guu2)*signgs*twopi edgeiota = currv/edgefactor irnodes = max(0,imse) + 1 lt = 1 !Outer R edge dlu = luef(ns,lt) + luof(ns,lt) wedge = (zue(ns,1,lt)+zuo(ns,1,lt))/(dlu*router) rstark(irnodes) = router datastark(irnodes) = wedge*edgeiota !Edge pitch sigma_stark(irnodes) = abs(sigma_current*wedge/edgefactor) ! ! THROW AWAY POINTS OUTSIDE GRID ! NOTE: IF ONLY OUTER POINT KEPT, THE CALL TO SORT IS UNNECESSARY ! rsort0(:irnodes) = rstark(:irnodes) call sort_data (rsort0,isortr,irnodes) kcstark = 0 do i = 1,irnodes j = isortr(i) if( ((rsort0(i).gt.rinner) .and. > (rsort0(i).le.router)) .or. (iequi.ne.0) )then kcstark = kcstark+1 rsort(kcstark) = rsort0(i) !kcstark <= i starkcal(kcstark) = datastark(j) !sorted data array qcalc(kcstark) = one/sigma_stark(j) !qcalc = sorted weight array endif enddo ! ! COMPUTE IOTA(0) FROM SLOPE AT RSTARK=R00 ! c04-96 kcstark = kcstark+1 c04-96 rsort(kcstark) = r00 !Magnetic axis (s=0) c04-96 qcalc(kcstark) = 1.0/scstark c04-96 c04-96 if( imse.gt.0 )then c04-96 slope0 = 1.0 c04-96 call splint(rstark,ystark0,y2stark0, c04-96 > imse,r00,dum,slope0,1) c04-96 starkcal(kcstark) = r00*slope0*luef(1,1)/dkappa c04-96 else c04-96c EXTEND BOUNDARY POINTS TO INCLUDE FULL RANGE IN THETA c04-96 starkcal(kcstark) = ai(0) c04-96 endif ! ! FIND S,THETA INDICES FOR RSORT ARRAY ! call findphi (re, ro, rsort, delse1, delso1, rmid, indexs1, 1 indexu1, indexr, kcstark) ! ! COMPUTE MATRIX ELEMENTS FOR IOTA SPLINE NODES CORRESPONDING ! TO ORDERED RSORT ARRAY ( = RSORT S ) ! if (kcstark .gt. nmse) stop 'kcstark>nmse' call getspline (amat_i, sknots, hstark, delse1, hs, indexs1, 1 isorts, kcstark, isnodes) ! ! MATCH TO STARK MSE DATA ACCORDING TO THE FORMULA: ! ! Bz/Btor = IOTA*Zu/[ R*(1+LAMu) ] ! ! NOTE: QCALC, DATA = STARKCAL CORRESPOND TO RSORT_S(I) ! WITH INDEX KS = ISORTS(I) (INDEXED ON RSORT BEFORE IT WAS SORTED) ! SAME IS TRUE FOR DELSE,O1, INDEXS1, INDEXU1 ! islope = 0 do i = 1, kcstark c !Index BEFORE sorting on sknots (indexed on rsort) ks = isorts(i) js = indexs1(ks) lt = indexu1(ks) ! ! COMPUTE WEIGHT(J) = Zu / (R * [1 + LAMu]), WHICH IS THE FACTOR ! RELATING MSE PITCH = WEIGHT(J) * IOTA(J) TO ROTATIONAL TRANSFORM. ! ! ON ENTRY INTO THIS LOOP, ! QCALC = 1/SIGMA_STARK ! dlu = (one - delse1(ks))*luef(js,lt) + delse1(ks)*luef(js+1,lt 1 ) + (one - delso1(ks))*sqrts(js)*luof(js,lt) + delso1(ks)* 2 sqrts(js+1)*luof(js+1,lt) dzu = (one - delse1(ks))*zue(js,1,lt) + delse1(ks)*zue(js+1,1, 1 lt) + (one - delso1(ks))*sqrts(js)*zuo(js,1,lt) + delso1(ks 2 )*sqrts(js+1)*zuo(js+1,1,lt) stark_weight(ks) = dzu/(rsort(ks)*dlu) if (rsort(ks) .eq. router) icurrout = i c04-96 if( rsort(ks).eq.r00 )then !IOTA(0) c04-96 islope = i c04-96 stark_weight(ks) = abs(wedge) !Need in c04-96 starkcal(ks) = weight(ks)*starkcal(ks) !Need for c04-96 data_array(i) = starkcal(ks) * qcalc(ks) c04-96 amat_i(1,i) = amat_i(1,i) * stark_weight(ks) * qcalc(ks) c04-96 else data_array(i) = starkcal(ks)*qcalc(ks) t1 = stark_weight(ks)*qcalc(ks) amat_i(:isnodes,i) = t1*amat_i(:isnodes,i) c04-96 endif if (i.eq.icurrout .and. qcalc(ks).eq.zero) stop 'CURR ERR' end do imse2 = kcstark amat_p(:,:kcstark) = zero end subroutine getmse subroutine gettflux use vsvd implicit none C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec) :: p01=1.e-2_dp, zero = 0.0_dp C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- real(rprec) :: tfac, phifac0 C----------------------------------------------- ! ! UPDATE PHIEDGE SCALE FACTOR BY THE FORMULA ! FDOT/F = -2*(1 - apres/aminor), WHERE F = PHISCALE ! tfac = p01*rsfac if (imatch_phiedge .eq. 0) then if (aminor .eq. zero) then phifac0 = phifac else phifac0 = phifac*(apres/aminor) end if gphifac = tfac*(phifac0 - phifac) else if (imatch_phiedge .eq. 2) then call getlim gphifac = tfac*phifac*gphifac endif end subroutine gettflux subroutine getthom(amat_i, amat_p, data_array, re, ro, kcthom) use vmec_main use vsvd use vspline implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer kcthom real(rprec), dimension(isnodes,*) :: amat_i real(rprec), dimension(ipnodes,*) :: amat_p real(rprec), dimension(*) :: data_array real(rprec), dimension(ns,nzeta,*) :: re, ro C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: i, ks integer, dimension(itse + 2) :: isortp real(rprec), dimension(itse) :: datalsq_p real(rprec), dimension(itse + 2) :: rgrid real(rprec):: sig_fac, t1 real(rprec) :: rmat1u(itse) logical :: l1v(itse) C----------------------------------------------- ! ! THIS SUBROUTINE COMPUTES THE LEAST-SQUARES AMATRIX AND DATA ! ARRAYS FOR MATCHING TO THE PRESSURE DATA AT EQUALLY-SPACED KNOTS ! IN SQRT(PHI-FLUX) SPACE (IPNODES, INCLUDING S=0 AND S=1) ! ! COMING INTO THIS ROUTINE, THE RTHOM, DATATHOM HAVE BEEN ! PREVIOUSLY ORDERED SO RTHOM(1) < RTHOM(2) < .... ! ! IF (LPOFR), user has input P(R,Z) ! If (.NOT.LPOFR), then user has input P(s), not P(R) ! if (.not.lpofr) then !p(R) or p(s) ? ! CONSTRUCT RTHOM BASED ON P(s) rthom(:itse) = sthom(:itse) call pofs (re, ro, ns, rthom, itse) rthommax = rthom(itse) rthommin = rthom(1) endif ! ! IF NO PRESSURE DATA, MAKE SURE CHISQ-THOM <= CHI_TARGET ! sig_fac = one ! ! CONSTRUCT EVERYTHING BASED ON P(R) ! FOR POINTS OUTSIDE GRID, SET R = either rmin,rmax ! kcthom = 0 if (itse .gt. 0) then l1v(:itse) = .false. datalsq_p(:itse) = datathom(:itse)*pfac !sorted data array sigma_thom(:itse) = sigma_thom(:itse)/sig_fac pcalc(:itse) = 1.0/sigma_thom(:itse) !pcalc = sorted sigma array rmat1u(:itse) = rthom(:itse) where (rmat1u(:itse) .lt. rinner) rmat1u(:itse) = rinner elsewhere l1v(:itse) = rmat1u(:itse) .gt. router end where where (l1v(:itse)) rmat1u(:itse) = router rgrid(kcthom+1:itse+kcthom) = rmat1u(:itse) kcthom = itse + kcthom endif ! ! FIND S,THETA INDICES FOR GRIDDED R-THOM ARRAY (RGRID) ! call findphi (re, ro, rgrid, delse2, delso2, rmid, indexs2, 1 indexu2, indexr, kcthom) ! ! COMPUTE MATRIX ELEMENTS FOR PRESSURE SPLINE NODES CORRESPONDING ! TO ORDERED RGRID ARRAY ! call getspline (amat_p, pknots, hthom, delse2, hs, indexs2, 1 isortp, kcthom, ipnodes) ! ! MATCH PRESSURE SPLINE KNOTS TO THOMSON SCATTERING DATA ! ! ON ENTRY INTO THIS LOOP, PCALC = 1/SIGMA_THOM ! do i = 1, kcthom ks = isortp(i) !Index BEFORE sorting on pknots (indexed data_array(i) = datalsq_p(ks)*pcalc(ks) t1 = pthommax*pcalc(ks) amat_p(:ipnodes,i) = t1*amat_p(:ipnodes,i) end do if (.not.lpofr) rthompeak = rgrid(isortp(1)) itse2 = kcthom amat_i(:,:itse2) = zero end subroutine getthom subroutine grnbfld(xsqr, xs, zs, br, bz, idim, nobs1, nobs2) use vsvd use vparams, only: one implicit none C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec), parameter :: four=4.0_dp, p5=0.5_dp C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer idim, nobs1, nobs2 real(rprec), dimension(idim) :: xsqr, xs, zs, br, bz C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer j, i1, i2 real(rprec) :: xt, zt, xtsqr, xt4, oxt, zrp, zrm, xvv, 1 fxu, sqrxu, qqp, qqm, delqp, delqm, yeqp, yeqm, brp, brm C----------------------------------------------- ! ! COMPUTE BR = (ZT-ZS)/RT/SQRT(4*RT*RS) * F1(k) ! BZ = 1/SQRT(4*RT*RS)*[RS/RT * F2(k) - F1(k)] ! WHERE F1 = k/2pi[ (E(k) - K(k)) + q1(k)*E(k) ] ! F2 = k/(2pi) [ q1(k)*E(k) ] ! q1 = .5*k**2/(1. - k**2) [Most singular piece near k=1] ! k**2 = 4*RT*RS/[(RT+RS)**2 + (ZT-ZS)**2] ! xt = rbcoil(nobs1,nobs2) zt = zbcoil(nobs1,nobs2) xtsqr = p5/rbcoilsqr(nobs1,nobs2) !1/2 from symmetrizing xt4 = four*xt oxt = one/xt do j = 2,idim zrp = zt - zs(j) zrm = zt + zs(j) xvv =(xt + xs(j))**2 fxu = xs(j)*xt4 sqrxu = xtsqr/xsqr(j) qqp = fxu/(xvv + zrp*zrp) qqm = fxu/(xvv + zrm*zrm) ! ! WHICH INDEX LIES BELOW ? ! i1 = int(qqp*odqk2) + 1 i2 = int(qqm*odqk2) + 1 ! ! LINEAR INTERPOLATION ! delqp = qqp - qsq(i1) delqm = qqm - qsq(i2) yeqp = (yeq(i1) + delqp*dyeq(i1))/(one - qqp) yeqm = (yeq(i2) + delqm*dyeq(i2))/(one - qqm) brp = yek(i1) + delqp*dyek(i1) brm = yek(i2) + delqm*dyek(i2) br(j) = sqrxu*oxt*(zrp*(brp+yeqp) + zrm*(brm+yeqm)) bz(j) = sqrxu*((xs(j)*oxt-1.0)*(yeqp + yeqm) - (brp + brm)) enddo end subroutine grnbfld subroutine grnflx(xsqr, xs, zs, ansp, idim, nobs) use vsvd implicit none C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec), parameter :: p5 =0.5_dp, four=4.0_dp C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer idim, nobs real(rprec), dimension(idim) :: xsqr, xs, zs, ansp C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: i1, i2, j real(rprec) :: xt, zt, xtsqr, xt4, 4 zrp, zrm, xvv, fxu, sqrxu, qqp, qqm C----------------------------------------------- ! ! EVALUATES "GREEN'S" FUNCTION FOR POLOIDAL FLUX AT INTERIOR ! POINTS XS,ZS AND OBSERVATION POINT XT,ZT (ANSP) ! (RECALL THETA INTEGRATION ONLY FROM ZERO TO PI, SO NEED ! TO REFLECT ZS TO -ZS, AT LEAST IN UP-DOWN SYMMETRIC CASE) ! xt = xobser(nobs) zt = zobser(nobs) xtsqr = p5*xobsqr(nobs) !1/2 factor from averaging up,down xt4 = four*xt do j = 2,idim zrp = zt - zs(j) zrm = zt + zs(j) xvv =(xt + xs(j))**2 fxu = xs(j)*xt4 sqrxu = xsqr(j)*xtsqr qqp = fxu/(xvv + zrp*zrp) !k**2 for zplasma > 0 qqm = fxu/(xvv + zrm*zrm) !k**2 for zplasma < 0 ! ! WHICH INDEX LIES BELOW ? ! i1 = int(qqp*odqk2) + 1 i2 = int(qqm*odqk2) + 1 ! ! LINEAR INTERPOLATION ! ansp(j) = sqrxu *( ( yf(i1)+(qqp-qsq(i1))*dyf(i1) ) > + ( yf(i2)+(qqm-qsq(i2))*dyf(i2) ) ) enddo end subroutine grnflx subroutine pofs(re, ro, ns, rthom, itse) use kind_spec implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer ns, itse real(rprec), dimension(ns) :: re, ro real(rprec), dimension(*) :: rthom C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: j, js, i real(rprec), dimension(ns) :: s real(rprec) :: sqrjs, rt2, ds C----------------------------------------------- ! ! Interpolate Rmid = Re + Ro to get R(s) ! ! THIS ROUTINE INTERPOLATES THE RTHOM "S-SPACE" ARRAY ! ONTO THE INSTANTANEOUS RMID ARRAY ! ON INPUT, RTHOM IS THE S-VALUE ARRAY FOR THOMPSON DATA ! ON OUTPUT,RTHOM IS THE CORRESPONDING (THETA=0) RMID ARRAY ! do j = 1, ns s(j) = real(j - 1,rprec)/(ns - 1) end do js = 1 do i = 1, itse rt2 = rthom(i) 100 continue if (rt2.ge.s(js) .and. rt2.le.s(js+1)) then ds = (rt2 - s(js))/(s(js+1)-s(js)) sqrjs = sqrt(rt2) rthom(i) = re(js) + (re(js+1)-re(js))*ds + sqrjs* 1 (ro(js)+(ro(js+1)-ro(js))*ds) else js = js + 1 if (js < ns) go to 100 endif end do end subroutine pofs subroutine radfor(pfac0) use vmec_main use vmec_params, only: signgs use vforces, only : r12=>armn_o, gsqrt=>azmn_o, gor=>clmn_o use realspace use vsvd implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- real(rprec) pfac0 C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec) :: p05 = 0.05, p5 = 0.5_dp, c1p5 = 1.5_dp C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: js real(rprec), dimension(ns) :: vpres real(rprec) :: delpres, pedge, t1 real(rprec), external :: dot_g C----------------------------------------------- ! ! COMPUTE VPRES, NEEDED FOR F00 PRESSURE BALANCE ! gor(2:nrzt) = gsqrt(2:nrzt) / r12(2:nrzt) do js = 2, ns vpres(js) =signgs*DOT_G(nznt,gor(js),ns,wint(js),ns) end do pedge = c1p5*pres(ns) - p5*pres(ns1) pressum0 = dot_product(wint(ns:nrzt:ns)*zu0(ns:nrzt:ns), 1 r1(ns:nrzt:ns,0)+r1(ns:nrzt:ns,1)) pressum0 = signgs*pedge*pressum0 pressum0 = pressum0 + hs*dot_product(vpres(2:ns),pres(2:ns)) if (pressum0 .eq. zero) pressum0 = one pfac0 = pfac if (iresidue .ge. 3) return !!AXIS MOVED BY FSQR IN RESIDUE ! ! COMPUTE AVERAGE FORCE BALANCE CONSTRAINT FOR FIXING R(0) ! (INTEGRAL OF RADIAL FORCE BALANCE,M=0,N=0, OVER S) ! if (1.e6_dp*fsq .le. one) then delpres = 0. delpres = -fsqsum0/pressum0 t1 = abs(delpres) if (t1 .gt. p05) delpres = p05*delpres/t1 !!Wait til close pfac0 = pfac*(one + delpres) endif end subroutine radfor subroutine readrecon use vmec_main use vsvd implicit none C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- character*(50), dimension(2), save :: raxis_message character*(50), dimension(4), save :: phiedge_message C----------------------------------------------- data raxis_message/'Magnetic axis position fixed', 1 'Magnetic axis position optimized'/ data phiedge_message/ 1 'Phiedge determined to match pressure minor radius', 2 'Phiedge matched to input value', 3 'Phiedge determined by limiter position', 4 'Phiedge determined by Ip'/ iphidiam = 0 if (imse > nmse) stop 'IMSE>NMSE' if (itse > ntse) stop 'ITSE>NTSE' if ((imse>0 .or. nflxs>0 .or. nbfldn>0) .and. itse.ge.0) then iresidue = 0 else lrecon = .false. end if if (.not.lrecon) return !No reconstruction matching ncurr = 0 !Just to be safe if (sigma_current .ge. cbig) stop 'SIGMA_CURRENT missing' if (sigma_delphid .ge. cbig) print *, ' SIGMA_DELPHID missing' if (sigma_current < zero) sigma_current = abs(sigma_current* 1 curtor) if (sigma_delphid < zero) sigma_delphid = abs(sigma_delphid* 1 phidiam) write (nthreed, 150) 150 format(/' DATA MATCHING PARAMETERS: ',/,1x,35('-')) write (nthreed, 155) imse, itse, nflxs, nobser, nobd, nbfldn, 1 nbcoilsn, sigma_current, 1.e3_dp*sigma_delphid, tensp, tensi, 2 tensi2, fpolyi, mseangle_offset, presfac, pres_offset, lpofr write (nthreed, 152) mseangle_offsetm 152 format('mse-angleM offset',/,f13.3) 155 format(' imse itse nflxs nobser nobd', 1' nbfldn nbcoils sigma_current(A) sigma_delphid(mWb)',/, 2 i7,6i11,3x,1pe15.3,4x,0pf17.3,/, 3 ' tension(p) tension(i) tension2(i) fpolyi ', 4 'mse-angle offset pres scale factor pressure offset lpofr',/, 5 3f13.3,f9.3,f18.3,f19.3,f16.3,6x,l1) write (nthreed, 200) 200 format(/,' LEGEND',/,1x,6('-')) if (curtor < cbig) then write (nthreed, 210) 1.e-6_dp*curtor else write (nthreed, *) 'Need toroidal plasma current' stop 15 endif 210 format(' Matching to toroidal current = ',f10.3,' [MA]') sigma_current = dmu0*sigma_current if (nflxs > 0) then write (nthreed, *) 'Fitting ', nflxs, 1 ' external flux loop measurements' else write (nthreed, *) 1 'Not fitting external flux loop measurements.' endif if (phidiam<cbig .and. sigma_delphid<cbig) then iphidiam = 1 write (nthreed, 220) 1.e3_dp*phidiam else write (nthreed, *) 'No fit to diamagnetic flux' endif 220 format(' Fitting diamagnetic flux = ',f10.3,' [mWb]') write (nthreed, *) raxis_message(iopt_raxis+1) write (nthreed, *) phiedge_message(imatch_phiedge+1) end subroutine readrecon subroutine sgemvmm(amat_i, amat_p, amatsq, b, bsq, wten, 1 mdata, niota, npres, nots) use kind_spec implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer mdata, niota, npres, nots real(rprec), dimension(niota,mdata) :: amat_i real(rprec), dimension(npres,mdata) :: amat_p real(rprec), dimension(nots,nots) :: amatsq real(rprec), dimension(mdata) :: b real(rprec), dimension(nots) :: bsq, wten C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- real(rprec), parameter :: zero = 0.0_dp C----------------------------------------------- C L o c a l V a r i a b l e s C----------------------------------------------- integer :: i, j, ioff, joff C----------------------------------------------- amatsq = zero bsq = zero ! ! INITIALIZE IOTA, PRESSURE DIAGONAL ELEMENTS (ALREADY 'SQUARED') ! ! ! COMPUTE LOWER DIAGONAL HALF OF SQUARE OF MATRIX ! A(trans)*A and A(trans)*B ! BY ADDING CONTRIBUTIONS FROM EXTERNAL MAGNETICS SIGNALS ! ! ! FIRST UPPER LEFT NIOTA X NIOTA BLOCK ! do i = 1, niota bsq(i) = bsq(i) + sum(b*amat_i(i,:)) do j = 1, i amatsq(i,j) = amatsq(i,j) + sum(amat_i(i,:)*amat_i(j,:)) end do end do ! ! LOWER NPRES X NIOTA BLOCK, NPRES X NPRES BLOCK ! do i = 1, npres ioff = i + niota bsq(ioff) = bsq(ioff) + sum(b*amat_p(i,:)) do j = 1, niota amatsq(ioff,j) = amatsq(ioff,j) + 1 sum(amat_p(i,:)*amat_i(j,:)) end do do j = 1, i joff = j + niota amatsq(ioff,joff) = amatsq(ioff,joff) + 1 sum(amat_p(i,:)*amat_p(j,:)) end do end do do i = 1, nots wten(i) = amatsq(i,i) amatsq(1:i-1,i) = amatsq(i,1:i-1) end do end subroutine sgemvmm subroutine smoothdata(nwout) use vmec_main use vsvd implicit none C----------------------------------------------- C D u m m y A r g u m e n t s C----------------------------------------------- integer :: nwout C----------------------------------------------- C L o c a l P a r a m e t e r s C----------------------------------------------- integer, parameter :: ndata_elems = 11 c----------------------------------------------- c L o c a l V a r i a b l e s c----------------------------------------------- integer :: npts, i, ndata1 real(rprec), dimension(2*ns-1) :: hmid,ymid,y2mid, 1 wmid,tenmid,requal real(rprec), dimension(:), pointer :: data c----------------------------------------------- ! ! spline output data onto equally-spaced r-mesh for plotting ! npts = 2*ns - 1 if (npts .le. 1) return do i = 1, npts if (i .le. ns) curint(i) = twopi/dmu0*buco(ns + 1 - i) if (i .gt. ns) curint(i) = twopi/dmu0*buco(i - ns + 1) end do do i = 1, npts wmid(i) = 1.0 tenmid(i) = 0.1 requal(i) = rmid(1) + ((i - 1)*(rmid(npts)-rmid(1)))/ 1 (npts - 1) end do do ndata1 = 1, ndata_elems select case (ndata1) case (1) data => datamse case (2) data => qmid case (3) data => shear case (4) data => presmid case (5) data => alfa case (6) data => curmid case (7) data => curint case (8) data => psimid case (9) data => ageo case (10) data => volpsi case (11) data => phimid end select call setspline (rmid, wmid, data, hmid, ymid, y2mid, tenmid, 1 tenmid(1), npts, natur) call splint (rmid, ymid, y2mid, npts, requal, data(1), 1 zero, npts) end do ! ! write out splined data ! write (nwout, 703) (datamse(i),requal(i),qmid(i),shear(i),presmid 1 (i),alfa(i),curmid(i),i=1,npts) write (nwout, 703) (rsort(i),atan(datastark(isortr(i)))/dcon,abs( 1 qmeas(i)),i=1,imse2 - 1) write (nwout, 703) (rthom(i),datathom(i),i=1,itse) 703 format(5e20.13) if (lmac) then write (nmac, 705) 705 FORMAT(//,' FOLLOWING DATA EQUALLY SPACED IN R-MIDPLANE'//, 1 ' RMID J-PHI SHEAR QMID', 2 ' MSE-PITCH PRESMID PSI AMID', 3 ' VOLUME PHI',/, 4 ' [M] [A/M**2] ', 5 ' [Deg] [Pa] [Wb] [M]', 6 ' [M**3] [Wb]',/) write (nmac, 707) (requal(i),curmid(i),shear(i),qmid(i), 1 datamse(i),presmid(i),psimid(i),ageo(i),volpsi(i), 2 phimid(i),i=1,npts) write (nmac, 709) phimid(2*ns-1), psimid(2*ns-1) end if 707 format(1p10e12.3) 709 format(/,' phi-edge =',t16,1pe12.3,t40,'psi-edge =',t56,1pe12.3) end subroutine smoothdata
src/vmec2000/reconstruct.f
! ! CalculiX - A 3-dimensional finite element program ! Copyright (C) 1998-2021 Guido Dhondt ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License as ! published by the Free Software Foundation(version 2); ! ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! ! islavactdof is the inverse of nactdof for active slave nodes: ! it links an active slave degree of freedom to the ! corresponding slave node position in field islavnode and the ! global (x-y-z) degree of freedom ! ! [in] nslavnode (i) for contraint i pointer into field islavnode ! [in] nmastnode (i)pointer into field imastnode for contact tie i ! [in] imastnode field storing the nodes of the master surfaces ! [out] islavactdof (i)=10*slavenodenumber+direction for active dof i ! [in] islavnode field storing the nodes of the slave surface ! subroutine genislavactdof(ntie,tieset,nactdof,nslavnode, & nmastnode,imastnode,islavactdof,islavnode,mi, & ithermal) ! ! Author : Samoela Rakotonanahary, Saskia Sitzmann ! ! genislavactdof get the field islavactdof in order to ! help calculating the tangential matrices. ! ! islavactdof is the inverse of nactdof for active slave nodes: ! it links an active slave degree of freedom to the ! corresponding slave node position in field islavnode and the ! global (x-y-z) degree of freedom ! implicit none ! character*81 tieset(3,*) ! integer i,j,k,ntie,node,nslavnode(*), & mi(*),nactdof(0:mi(2),*),nmastnode(*),imastnode(*), & islavactdof(*),islavnode(*),ithermal(*) ! ! ! ! close the contact.fbd file ! close(20) close(30) close(40) ! ! do not change the order here: slave nodes have to be treated ! last since two contact definitions can share an edge ! do i=1,ntie if(tieset(1,i)(81:81).ne.'C') cycle do j = nmastnode(i)+1,nmastnode(i+1) node=imastnode(j) do k=1,3 if (nactdof(k,node).le.0) cycle islavactdof(nactdof(k,node))=-(10*j+k) enddo if(ithermal(1).gt.1)then if (nactdof(0,node).le.0) cycle islavactdof(nactdof(0,node))=-(10*j+4) endif enddo enddo ! do i=1,ntie if(tieset(1,i)(81:81).ne.'C') cycle do j = nslavnode(i)+1,nslavnode(i+1) node=islavnode(j) do k=1,3 if (nactdof(k,node).le.0) cycle islavactdof(nactdof(k,node))=10*j+k enddo if(ithermal(1).gt.1)then if (nactdof(0,node).le.0) cycle islavactdof(nactdof(0,node))=(10*j+4) endif enddo enddo ! return end
ccx_prool/CalculiX/ccx_2.19/src/genislavactdof.f
! { dg-do run } ! { dg-require-effective-target lto } ! { dg-options "-flto" } ! ! Checks that the results of module procedures have the correct characteristics ! and that submodules use the module version of vtables (PR66762). This latter ! requires the -flto compile option. ! ! Contributed by Reinhold Bader <[email protected]> ! module mod_a implicit none type, abstract :: t_a end type t_a interface module subroutine p_a(this, q) class(t_a), intent(inout) :: this class(*), intent(in) :: q end subroutine module function create_a() result(r) class(t_a), allocatable :: r end function module subroutine print(this) class(t_a), intent(in) :: this end subroutine end interface end module mod_a module mod_b implicit none type t_b integer, allocatable :: I(:) end type t_b interface module function create_b(i) result(r) type(t_b) :: r integer :: i(:) end function end interface end module mod_b submodule(mod_b) imp_create contains module procedure create_b if (allocated(r%i)) deallocate(r%i) allocate(r%i, source=i) end procedure end submodule imp_create submodule(mod_a) imp_p_a use mod_b type, extends(t_a) :: t_imp type(t_b) :: b end type t_imp integer, parameter :: ii(2) = [1,2] contains module procedure create_a type(t_b) :: b b = create_b(ii) allocate(r, source=t_imp(b)) end procedure module procedure p_a select type (this) type is (t_imp) select type (q) type is (t_b) this%b = q class default call abort end select class default call abort end select end procedure p_a module procedure print select type (this) type is (t_imp) if (any (this%b%i .ne. [3,4,5])) call abort class default call abort end select end procedure end submodule imp_p_a program p use mod_a use mod_b implicit none class(t_a), allocatable :: a allocate(a, source=create_a()) call p_a(a, create_b([3,4,5])) call print(a) end program p ! { dg-final { cleanup-submodules "mod_a@imp_p_a" } } ! { dg-final { cleanup-submodules "mod_b@imp_create" } }
gcc-gcc-7_3_0-release/gcc/testsuite/gfortran.dg/submodule_6.f08
!------------------------------------------------------------------------------------------------------------- ! !> \file SortPick.f90 !> \brief Sort a double real vector (this vector is unchanged, the indices of this vector is sorted). !> \author W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery (modified by M.H.A. Piro) !> \sa CheckSolnPhaseAdd.f90 ! ! ! References: ! =========== ! ! This subroutine employs a simple sorting algorithm that was modified from: ! ! W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery, "Numerical Recipes in Fortran 90 ! (Second Edition)", Cambridge University Press, New York, 1996 ! ! ! Revisions: ! ========== ! ! Date Programmer Description of change ! ---- ---------- --------------------- ! 03/31/2011 M.H.A. Piro Modified the sort_pick subroutine from Numerical Recipes to ! return an integer vector representing the descending order of ! the real vector (unchanged). ! 02/06/2013 M.H.A. Piro Only proceed if n is positive. ! ! ! Purpose: ! ======== ! !> \details The purpose of this subroutine is to take a double real vector as input and return an integer vector !! representing the descending order of the real vector (unchanged). Although this sorting routine is by !! no means efficient for large problems, "it is meant to be invoked only for the most trivial sorting jobs, !! say, N < 20." ! ! ! Pertinent variables: ! ==================== ! !> \param[in] n An integer scalar represening the dimension of dVec. !> \param[in] dVec A double real vector that is to be sorted in descending order. !> \param[out] iVec An integer vector representing the index of coefficients of dVec in !! descending order. ! !------------------------------------------------------------------------------------------------------------- subroutine SortPick(n,dVec,iVec) implicit none integer :: i, j, k integer, intent(in) :: n integer, dimension(n), intent(out) :: iVec real(8), dimension(n), intent(in) :: dVec ! Only proceed if n is greater than zero: if (n > 0) then ! Initialize variables: iVec = 0 do i = 1, n iVec(i) = i end do ! Sort the indices on dVec in the iVec vector: LOOP_A: do j = 2, n LOOP_B: do i = j-1, 1, -1 if (dVec(iVec(i)) >= dVec(j)) exit LOOP_B k = iVec(i) iVec(i) = j iVec(i+1) = k end do LOOP_B end do LOOP_A end if return end subroutine SortPick
src/SortPick.f90
c c c ################################################### c ## COPYRIGHT (C) 1990 by Jay William Ponder ## c ## All Rights Reserved ## c ################################################### c c ############################################################# c ## ## c ## subroutine prtint -- output of internal coordinates ## c ## ## c ############################################################# c c c "prtint" writes out a set of Z-matrix internal c coordinates to an external disk file c c subroutine prtint (izmt) implicit none include 'sizes.i' include 'atmtyp.i' include 'atoms.i' include 'files.i' include 'inform.i' include 'titles.i' include 'zclose.i' include 'zcoord.i' integer i,k,izmt logical opened character*2 atmc character*5 bndc,angc character*43 fstr character*120 zmtfile c c c open the output unit if not already done c inquire (unit=izmt,opened=opened) if (.not. opened) then zmtfile = filename(1:leng)//'.int' call version (zmtfile,'new') open (unit=izmt,file=zmtfile,status='new') end if c c check for large systems needing extended formatting c atmc = 'i6' if (n .ge. 100000) atmc = 'i7' if (n .ge. 1000000) atmc = 'i8' if (digits .le. 6) then bndc = 'f10.5' angc = 'f10.4' else if (digits .le. 8) then bndc = 'f12.7' angc = 'f12.6' else bndc = 'f14.9' angc = 'f14.8' end if c c write out the number of atoms and the title c if (ltitle .eq. 0) then fstr = '('//atmc//')' write (izmt,fstr(1:4)) n else fstr = '('//atmc//',2x,a)' write (izmt,fstr(1:9)) n,title(1:ltitle) end if c c output of first three atoms is handled separately c fstr = '('//atmc//',2x,a3,i6,'//atmc//','//bndc//','//atmc// & ','//angc//','//atmc//','//angc//','//'i6)' if (n .ge. 1) & write (izmt,fstr) 1,name(1),type(1) if (n .ge. 2) & write (izmt,fstr) 2,name(2),type(2),iz(1,2),zbond(2) if (n .ge. 3) & write (izmt,fstr) 3,name(3),type(3),iz(1,3),zbond(3), & iz(2,3),zang(3) c c convert torsional angles to lie in standard range c do i = 4, n if (iz(4,i) .eq. 0) then do while (ztors(i) .lt. -180.0d0) ztors(i) = ztors(i) + 360.0d0 end do do while (ztors(i) .gt. 180.0d0) ztors(i) = ztors(i) - 360.0d0 end do end if end do c c output the fourth through final atoms c do i = 4, n write (izmt,fstr) i,name(i),type(i),iz(1,i),zbond(i), & iz(2,i),zang(i),iz(3,i),ztors(i),iz(4,i) end do c c addition and deletion of bonds as required c if (nadd.ne.0 .or. ndel.ne.0) then fstr = '(2'//atmc//')' write (izmt,'()') do i = 1, nadd write (izmt,fstr(1:5)) (iadd(k,i),k=1,2) end do if (ndel .ne. 0) write (izmt,'()') do i = 1, ndel write (izmt,fstr(1:5)) (idel(k,i),k=1,2) end do end if c c close the output unit if opened by this routine c if (.not. opened) close (unit=izmt) return end
HCsbLib/HCsbLib/HTLib2.Bioinfo/External.Tinker/src/tinker-6.2.06/prtint.f
! ################################################################################################################################## ! Begin MIT license text. ! _______________________________________________________________________________________________________ ! Copyright 2019 Dr William R Case, Jr ([email protected]) ! Permission is hereby granted, free of charge, to any person obtaining a copy of this software and ! associated documentation files (the "Software"), to deal in the Software without restriction, including ! without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ! copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to ! the following conditions: ! The above copyright notice and this permission notice shall be included in all copies or substantial ! portions of the Software and documentation. ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ! THE SOFTWARE. ! _______________________________________________________________________________________________________ ! End MIT license text. SUBROUTINE BD_SPOINT0 ( CARD, DELTA_SPOINT ) ! Processes SPOINT Bulk Data Cards to count the number of SPOINT's on one entry USE PENTIUM_II_KIND, ONLY : BYTE, LONG USE IOUNT1, ONLY : WRT_LOG, F04 USE SCONTR, ONLY : BLNK_SUB_NAM, IERRFL, JCARD_LEN, JF USE TIMDAT, ONLY : TSEC USE SUBR_BEGEND_LEVELS, ONLY : BD_SPOINT0_BEGEND USE BD_SPOINT0_USE_IFs IMPLICIT NONE CHARACTER(LEN=LEN(BLNK_SUB_NAM)):: SUBR_NAME = 'BD_SPOINT0' CHARACTER(LEN=*), INTENT(IN) :: CARD ! A Bulk Data card CHARACTER(LEN=JCARD_LEN) :: JCARD(10) ! The 10 fields of characters making up CARD CHARACTER( 8*BYTE) :: TOKEN ! The 1st 8 characters from a JCARD CHARACTER( 8*BYTE) :: TOKTYP ! An output from subr TOKCHK called herein INTEGER(LONG), INTENT(OUT) :: DELTA_SPOINT ! Number of SPOINT's defined on this B.D. SPOINT entry INTEGER(LONG) :: J ! DO loop index INTEGER(LONG) :: JERR = 0 ! Error indicator for several types of error in format #2 of input INTEGER(LONG) :: SPOINT1 = 0 ! An SPOINT number INTEGER(LONG) :: SPOINT2 = 0 ! An SPOINT number INTEGER(LONG), PARAMETER :: SUBR_BEGEND = BD_SPOINT0_BEGEND ! ********************************************************************************************************************************** IF (WRT_LOG >= SUBR_BEGEND) THEN CALL OURTIM WRITE(F04,9001) SUBR_NAME,TSEC 9001 FORMAT(1X,A,' BEGN ',F10.3) ENDIF ! ********************************************************************************************************************************** ! SPOINT Bulk Data Card routine ! FIELD ITEM ! ----- ------------ ! Format #1: ! 2-9 SPOINT ID's ! on optional continuation cards: ! 2-9 Grid ID's ! Format #2: ! 2 SPOINT ID 1 ! 3 "THRU" ! 4 SPOINT ID 2 ! Make JCARD from CARD CALL MKJCARD ( SUBR_NAME, CARD, JCARD ) ! Field 3 of SPOINT must have "THRU" or a SPOINT number or blank. TOKEN = JCARD(3)(1:8) ! Only send the 1st 8 chars of this JCARD. It has been left justified CALL TOKCHK ( TOKEN, TOKTYP ) ! TOKTYP must be THRU', 'INTEGR', or 'BLANK' DELTA_SPOINT = 0 ! ********************************************************************************************************************************** ! Format # 2 IF (TOKTYP == 'THRU ') THEN JERR = 0 IF (JCARD(2)(1:) /= ' ') THEN ! Get 1st SPOINT ID CALL I4FLD ( JCARD(2), JF(2), SPOINT1 ) ELSE JERR = JERR + 1 ENDIF IF (JCARD(4)(1:) /= ' ') THEN ! Get 2nd SPOINT ID CALL I4FLD ( JCARD(4), JF(4), SPOINT2 ) ELSE JERR = JERR + 1 ENDIF IF ((IERRFL(2)=='N') .AND. (IERRFL(4)=='N')) THEN ! Check SPOINT2 > SPOINT1 if there were no errors reading them IF (SPOINT2 <= SPOINT1) THEN JERR = JERR + 1 ENDIF ENDIF IF ((JERR == 0) .AND. (IERRFL(2) == 'N') .AND. (IERRFL(5) == 'N')) THEN DO J=1,SPOINT2-SPOINT1+1 DELTA_SPOINT = DELTA_SPOINT + 1 ENDDO ENDIF ! Format #1 ELSE IF ((TOKTYP == 'INTEGER ') .OR. (TOKTYP == 'BLANK ')) THEN JERR = 0 DO J=2,9 ! Get SPOINT ID's in fields 2 - 9 IF (JCARD(J)(1:) == ' ') THEN CYCLE ELSE CALL I4FLD ( JCARD(J), JF(J), SPOINT1 ) IF ((JERR == 0) .AND. (IERRFL(J) == 'N')) THEN DELTA_SPOINT = DELTA_SPOINT + 1 ENDIF ENDIF ENDDO ENDIF ! Reset DELTA_SPOINT back to 0 if there were errors (i.e. don't count this entry if there are errors) IF (JERR > 0) THEN DELTA_SPOINT = 0 ENDIF ! ********************************************************************************************************************************** IF (WRT_LOG >= SUBR_BEGEND) THEN CALL OURTIM WRITE(F04,9002) SUBR_NAME,TSEC 9002 FORMAT(1X,A,' END ',F10.3) ENDIF RETURN ! ********************************************************************************************************************************** END SUBROUTINE BD_SPOINT0
Source/LK1/L1A-BD/BD_SPOINT0.f90
| Error Code | Meaning | Solution | ------------------------------------------------------------------------------------------------------------------------------ | | The frontpage is missing even though you set | Change FRONTPAGE_TYPE to "DB" or | | 1001 | FRONTPAGE_TYPE to "FILE" and there is not an | replace the frontpage FILE or create | | | active DB entry page named "frontpage". | a DB page entry named "frontpage" | ------------------------------------------------------------------------------------------------------------------------------
core/ErrorCodes.f
program prog integer num(2) dimension num(2) end
fable/test/semantic_error/dims_repeated_in_dimension.f
C*********************************************************************** C Module: getvm.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 OUTVM(LU) C...PURPOSE Print STRIP SHEAR and BENDING QUANTITIES, ie. V, BM C Integrates spanload to get shear and bending moment C NOTE: only works for single surface at at time (ie. V,BM on each panel) C INCLUDE 'AVL.INC' REAL V(NSMAX), BM(NSMAX), YSTRP(NSMAX) CHARACTER*72 FNAMVB C 1 FORMAT(A) 2 FORMAT(A,I3,A) C WRITE(LU,10) TITLE(1:60),AMACH,ALFA/DTR,CLTOT,BETA/DTR,SREF,BREF 10 FORMAT(/' Shear/q and Bending Moment/q vs Y' & /' Configuration: ',A & /' Mach = ',F8.3, & /' alpha = ',F8.3,' CLtot = ',F8.3, & /' beta = ',F8.3, & //' Sref = ',F11.5 & /' Bref = ',F11.5) C C---- Process the surfaces one by one, calculating shear and bending on each, C with moments refered to Y=0 (centerline) C DO N = 1, NSURF J1 = JFRST(N) JN = J1 + NJ(N) - 1 C YMIN = 1.0E10 YMAX = -1.0E10 DO J = J1, JN IV = IJFRST(J) YMIN = MIN(YMIN,RV1(2,IV),RV2(2,IV)) YMAX = MAX(YMAX,RV1(2,IV),RV2(2,IV)) ENDDO C C------ Integrate spanload from first strip to last strip defined for C this surface to get shear and bending moment CNCLST = 0.0 BMLST = 0.0 WLST = 0.0 VLST = 0.0 C JF = J1 JL = JN JINC = 1 C C------ Integrate from first to last strip in surface DO J = JL, JF, -JINC JJ = JINC*(J - JF + JINC) C DY = 0.5*(WSTRIP(J)+WLST) YSTRP(JJ) = RLE(2,J) V(JJ) = VLST + 0.5*(CNC(J)+CNCLST) * DY BM(JJ) = BMLST + 0.5*(V(JJ)+VLST) * DY C VLST = V(JJ) BMLST = BM(JJ) CNCLST = CNC(J) WLST = WSTRIP(J) ENDDO C C------ Inboard edge Y,Vz,Mx VROOT = VLST + CNCLST * 0.5*DY BMROOT = BMLST + 0.5*(VROOT+VLST) * 0.5*DY VTIP = 0.0 BMTIP = 0.0 IF(IMAGS(N).GE.0) THEN YROOT = RLE1(2,J1) YTIP = RLE2(2,JN) ELSE YROOT = RLE2(2,J1) YTIP = RLE1(2,JN) ENDIF C DIR = 1.0 IF(YMIN+YMAX.LT.0.0) DIR = -1.0 C WRITE(LU,*) ' ' WRITE(LU,2) ' Surface: ',N,' ',STITLE(N) WRITE(LU,*) ' 2Ymin/Bref = ',2.0*YMIN/BREF WRITE(LU,*) ' 2Ymax/Bref = ',2.0*YMAX/BREF WRITE(LU,*) ' 2Y/Bref Vz/(q*Sref) Mx/(q*Bref*Sref)' C WRITE(LU,4) 2.*YROOT/BREF,VROOT/SREF,DIR*BMROOT/SREF/BREF DO J = 1, NJ(N) WRITE(LU,4) 2.*YSTRP(J)/BREF,V(J)/SREF,DIR*BM(J)/SREF/BREF ENDDO WRITE(LU,4) 2.*YTIP/BREF,VTIP/SREF,DIR*BMTIP/SREF/BREF 4 FORMAT(F10.4,G14.6,3X,G14.6) C C N = 0 C CALL GRPHIN(N,YSTRP,V) C CALL GRPHIN(NJ(N),YSTRP,V) C CALL GRPHIN(NJ(N),YSTRP,BM) C CALL GRPHPL ENDDO C RETURN END ! OUTVM
third_party/avl/src/getvm.f
program problem69 implicit none integer, parameter :: n=78498,limit=1000000 integer, dimension(n) :: primes integer :: i,temp ! https://primes.utm.edu/lists/small/100000.txt open(33,file='./data/problem69.dat') read(33,*) primes ! https://en.wikipedia.org/wiki/Euler%27s_totient_function ! $\frac{n}{\phi(n)} = \prod_{p|n}(\frac{p}{p-1})$ ! Factors with powers greater than one increase n but not n/phi(n). ! Small factors are preferable to large ones, so greedily multiply. temp=1 do i=1,n temp=temp*primes(i) if (temp>limit) then temp=temp/primes(i) go to 100 end if end do 100 continue print *, temp end program problem69
problem69.f08
-makelib xcelium_lib/xil_defaultlib -sv \ "/opt/Xilinx/Vivado/2018.1/data/ip/xpm/xpm_cdc/hdl/xpm_cdc.sv" \ "/opt/Xilinx/Vivado/2018.1/data/ip/xpm/xpm_memory/hdl/xpm_memory.sv" \ -endlib -makelib xcelium_lib/xpm \ "/opt/Xilinx/Vivado/2018.1/data/ip/xpm/xpm_VCOMP.vhd" \ -endlib -makelib xcelium_lib/xil_defaultlib \ "../../../../Sinewave Gen.srcs/sources_1/ip/buttons_vio/sim/buttons_vio.vhd" \ -endlib -makelib xcelium_lib/xil_defaultlib \ glbl.v -endlib
vivado/Sinewave Gen.ip_user_files/sim_scripts/buttons_vio/xcelium/run.f
!------------------------------------------------------------------------------- module mod_misc !----------------------------------------------------------------------------- ! !++ Used modules ! use mod_precision !----------------------------------------------------------------------------- implicit none private !----------------------------------------------------------------------------- ! !++ Public, including parameters ! include 'problem_size.inc' !----------------------------------------------------------------------------- ! !++ Public procedure ! public :: DEBUG_rapstart public :: DEBUG_rapend public :: DEBUG_rapreport public :: DEBUG_valuecheck interface DEBUG_valuecheck module procedure DEBUG_valuecheck_1D module procedure DEBUG_valuecheck_2D module procedure DEBUG_valuecheck_3D module procedure DEBUG_valuecheck_4D module procedure DEBUG_valuecheck_5D module procedure DEBUG_valuecheck_6D end interface DEBUG_valuecheck public :: MISC_make_idstr !--- make file name with a number public :: MISC_get_available_fid !--- get an available file ID public :: ADM_proc_stop public :: CONST_setup public :: GRD_setup public :: GRD_input_vgrid !----------------------------------------------------------------------------- ! !++ Public parameters & variables ! integer, public :: EX_CSTEP_diffusion = 0 integer, public :: EX_TSTEP_diffusion = 60 integer, public :: EX_CSTEP_divdamp3d = 0 integer, public :: EX_TSTEP_divdamp3d = 140 integer, public :: EX_fid integer, public :: EX_err character(len=1024), public :: EX_fname character(len=16), public :: EX_item real(RP), public :: EX_max real(RP), public :: EX_min real(RP), public :: EX_sum !----------------------------------------------------------------------------- ! !++ Private procedure ! private :: DEBUG_rapid !----------------------------------------------------------------------------- ! !++ Private parameters & variables ! integer, private, parameter :: DEBUG_rapnlimit = 100 integer, private :: DEBUG_rapnmax = 0 character(len=ADM_NSYS), private :: DEBUG_rapname(DEBUG_rapnlimit) real(8), private :: DEBUG_raptstr(DEBUG_rapnlimit) real(8), private :: DEBUG_rapttot(DEBUG_rapnlimit) integer, private :: DEBUG_rapnstr(DEBUG_rapnlimit) integer, private :: DEBUG_rapnend(DEBUG_rapnlimit) #ifdef _FIXEDINDEX_ real(DP), public :: GRD_gz (ADM_kall) real(DP), public :: GRD_gzh (ADM_kall) real(DP), public :: GRD_dgz (ADM_kall) real(DP), public :: GRD_dgzh (ADM_kall) real(DP), public :: GRD_rdgz (ADM_kall) real(DP), public :: GRD_rdgzh(ADM_kall) real(DP), public :: GRD_afac(ADM_kall) real(DP), public :: GRD_bfac(ADM_kall) real(DP), public :: GRD_cfac(ADM_kall) real(DP), public :: GRD_dfac(ADM_kall) #else real(DP), public, allocatable :: GRD_gz (:) ! gsi (z-star) coordinate real(DP), public, allocatable :: GRD_gzh (:) ! gsi (z-star) coordinate at the half point real(DP), public, allocatable :: GRD_dgz (:) ! d(gsi) real(DP), public, allocatable :: GRD_dgzh (:) ! d(gsi) at the half point real(DP), public, allocatable :: GRD_rdgz (:) real(DP), public, allocatable :: GRD_rdgzh(:) real(DP), public, allocatable :: GRD_afac (:) ! From the cell center value to the cell wall value real(DP), public, allocatable :: GRD_bfac (:) ! A(k-1/2) = ( afac(k) A(k) + bfac(k) * A(k-1) ) / 2 real(DP), public, allocatable :: GRD_cfac (:) ! From the cell wall value to the cell center value real(DP), public, allocatable :: GRD_dfac (:) ! A(k) = ( cfac(k) A(k+1/2) + dfac(k) * A(k-1/2) ) / 2 #endif !----------------------------------------------------------------------------- contains !----------------------------------------------------------------------------- function DEBUG_rapid( rapname ) result(id) implicit none character(len=*), intent(in) :: rapname integer :: id !--------------------------------------------------------------------------- if ( DEBUG_rapnmax >= 1 ) then do id = 1, DEBUG_rapnmax if( trim(rapname) == trim(DEBUG_rapname(id)) ) return enddo endif DEBUG_rapnmax = DEBUG_rapnmax + 1 id = DEBUG_rapnmax DEBUG_rapname(id) = trim(rapname) DEBUG_raptstr(id) = 0.D0 DEBUG_rapttot(id) = 0.D0 DEBUG_rapnstr(id) = 0 DEBUG_rapnend(id) = 0 end function DEBUG_rapid !----------------------------------------------------------------------------- subroutine DEBUG_rapstart( rapname ) implicit none character(len=*), intent(in) :: rapname real(8) :: time integer :: id !--------------------------------------------------------------------------- id = DEBUG_rapid( rapname ) call CPU_TIME(time) DEBUG_raptstr(id) = time DEBUG_rapnstr(id) = DEBUG_rapnstr(id) + 1 !write(ADM_LOG_FID,*) rapname, DEBUG_rapnstr(id) #ifdef _FAPP_ call fapp_start( rapname, id, 1 ) #endif return end subroutine DEBUG_rapstart !----------------------------------------------------------------------------- subroutine DEBUG_rapend( rapname ) implicit none character(len=*), intent(in) :: rapname real(8) :: time integer :: id !--------------------------------------------------------------------------- id = DEBUG_rapid( rapname ) call CPU_TIME(time) DEBUG_rapttot(id) = DEBUG_rapttot(id) + ( time-DEBUG_raptstr(id) ) DEBUG_rapnend(id) = DEBUG_rapnend(id) + 1 #ifdef _FAPP_ call fapp_stop( rapname, id, 1 ) #endif return end subroutine DEBUG_rapend !----------------------------------------------------------------------------- subroutine DEBUG_rapreport implicit none integer :: id !--------------------------------------------------------------------------- if ( DEBUG_rapnmax >= 1 ) then do id = 1, DEBUG_rapnmax if ( DEBUG_rapnstr(id) /= DEBUG_rapnend(id) ) then write(*,*) '*** Mismatch Report',id,DEBUG_rapname(id),DEBUG_rapnstr(id),DEBUG_rapnend(id) endif enddo write(ADM_LOG_FID,*) write(ADM_LOG_FID,*) '*** Computational Time Report' do id = 1, DEBUG_rapnmax write(ADM_LOG_FID,'(1x,A,I3.3,A,A,A,F10.3,A,I7)') & '*** ID=',id,' : ',DEBUG_rapname(id),' T=',DEBUG_rapttot(id),' N=',DEBUG_rapnstr(id) enddo else write(ADM_LOG_FID,*) write(ADM_LOG_FID,*) '*** Computational Time Report: NO item.' endif return end subroutine DEBUG_rapreport !----------------------------------------------------------------------------- subroutine DEBUG_valuecheck_1D( & varname, & var ) implicit none character(len=*), intent(in) :: varname real(RP), intent(in) :: var(:) !--------------------------------------------------------------------------- EX_item = trim (varname) EX_max = maxval(var) EX_min = minval(var) EX_sum = sum (var) write(ADM_LOG_FID,'(1x,A,A16,3(A,ES24.16))') '+check[',EX_item,'] max=',EX_max,',min=',EX_min,',sum=',EX_sum return end subroutine DEBUG_valuecheck_1D !----------------------------------------------------------------------------- subroutine DEBUG_valuecheck_2D( & varname, & var ) implicit none character(len=*), intent(in) :: varname real(RP), intent(in) :: var(:,:) !--------------------------------------------------------------------------- EX_item = trim (varname) EX_max = maxval(var) EX_min = minval(var) EX_sum = sum (var) write(ADM_LOG_FID,'(1x,A,A16,3(A,ES24.16))') '+check[',EX_item,'] max=',EX_max,',min=',EX_min,',sum=',EX_sum return end subroutine DEBUG_valuecheck_2D !----------------------------------------------------------------------------- subroutine DEBUG_valuecheck_3D( & varname, & var ) implicit none character(len=*), intent(in) :: varname real(RP), intent(in) :: var(:,:,:) !--------------------------------------------------------------------------- EX_item = trim (varname) EX_max = maxval(var) EX_min = minval(var) EX_sum = sum (var) write(ADM_LOG_FID,'(1x,A,A16,3(A,ES24.16))') '+check[',EX_item,'] max=',EX_max,',min=',EX_min,',sum=',EX_sum return end subroutine DEBUG_valuecheck_3D !----------------------------------------------------------------------------- subroutine DEBUG_valuecheck_4D( & varname, & var ) implicit none character(len=*), intent(in) :: varname real(RP), intent(in) :: var(:,:,:,:) !--------------------------------------------------------------------------- EX_item = trim (varname) EX_max = maxval(var) EX_min = minval(var) EX_sum = sum (var) write(ADM_LOG_FID,'(1x,A,A16,3(A,ES24.16))') '+check[',EX_item,'] max=',EX_max,',min=',EX_min,',sum=',EX_sum return end subroutine DEBUG_valuecheck_4D !----------------------------------------------------------------------------- subroutine DEBUG_valuecheck_5D( & varname, & var ) implicit none character(len=*), intent(in) :: varname real(RP), intent(in) :: var(:,:,:,:,:) !--------------------------------------------------------------------------- EX_item = trim (varname) EX_max = maxval(var) EX_min = minval(var) EX_sum = sum (var) write(ADM_LOG_FID,'(1x,A,A16,3(A,ES24.16))') '+check[',EX_item,'] max=',EX_max,',min=',EX_min,',sum=',EX_sum return end subroutine DEBUG_valuecheck_5D !----------------------------------------------------------------------------- subroutine DEBUG_valuecheck_6D( & varname, & var ) implicit none character(len=*), intent(in) :: varname real(RP), intent(in) :: var(:,:,:,:,:,:) !--------------------------------------------------------------------------- EX_item = trim (varname) EX_max = maxval(var) EX_min = minval(var) EX_sum = sum (var) write(ADM_LOG_FID,'(1x,A,A16,3(A,ES24.16))') '+check[',EX_item,'] max=',EX_max,',min=',EX_min,',sum=',EX_sum return end subroutine DEBUG_valuecheck_6D !----------------------------------------------------------------------------- subroutine MISC_make_idstr( & str, & prefix, & ext, & numID, & digit ) implicit none character(len=*), intent(out) :: str !< combined extention string character(len=*), intent(in) :: prefix !< prefix character(len=*), intent(in) :: ext !< extention ( e.g. .rgn ) integer, intent(in) :: numID !< number integer, optional, intent(in) :: digit !< digit logical, parameter :: NSTR_ZERO_START = .true. ! number of separated file starts from 0 ? integer, parameter :: NSTR_MAX_DIGIT = 6 ! digit of separated file character(len=128) :: rankstr integer :: setdigit !--------------------------------------------------------------------------- if ( NSTR_ZERO_START ) then write(rankstr,'(I128.128)') numID-1 else write(rankstr,'(I128.128)') numID endif if ( present(digit) ) then setdigit = digit else setdigit = NSTR_MAX_DIGIT endif rankstr(1:setdigit) = rankstr(128-(setdigit-1):128) rankstr(setdigit+1:128) = ' ' str = trim(prefix)//'.'//trim(ext)//trim(rankstr) ! -> prefix.ext00000 return end subroutine MISC_make_idstr !----------------------------------------------------------------------------- !> Search and get available machine id !> @return fid function MISC_get_available_fid() result(fid) implicit none integer :: fid integer, parameter :: min_fid = 7 !< minimum available fid integer, parameter :: max_fid = 99 !< maximum available fid logical :: i_opened !--------------------------------------------------------------------------- do fid = min_fid, max_fid inquire(fid,opened=i_opened) if( .NOT. i_opened ) return enddo end function MISC_get_available_fid !----------------------------------------------------------------------------- subroutine ADM_proc_stop stop end subroutine ADM_proc_stop !----------------------------------------------------------------------------- subroutine CONST_setup implicit none write(ADM_LOG_FID,*) '*** setup constants' PI = 4.E0_RP * atan( 1.0_RP ) EPS = epsilon(0.0_RP) write(ADM_LOG_FID,*) '*** PI = ', PI write(ADM_LOG_FID,*) '*** EPS = ', EPS return end subroutine CONST_setup !----------------------------------------------------------------------------- subroutine GRD_setup implicit none integer :: k !--------------------------------------------------------------------------- !--- < setting the vertical coordinate > --- allocate( GRD_gz (ADM_kall) ) allocate( GRD_gzh (ADM_kall) ) allocate( GRD_dgz (ADM_kall) ) allocate( GRD_dgzh (ADM_kall) ) allocate( GRD_rdgz (ADM_kall) ) allocate( GRD_rdgzh(ADM_kall) ) call GRD_input_vgrid(vgrid_fname) ! calculation of grid intervals ( cell center ) do k = ADM_kmin-1, ADM_kmax GRD_dgz(k) = GRD_gzh(k+1) - GRD_gzh(k) enddo GRD_dgz(ADM_kmax+1) = GRD_dgz(ADM_kmax) ! calculation of grid intervals ( cell wall ) do k = ADM_kmin, ADM_kmax+1 GRD_dgzh(k) = GRD_gz(k) - GRD_gz(k-1) enddo GRD_dgzh(ADM_kmin-1) = GRD_dgzh(ADM_kmin) ! calculation of 1/dgz and 1/dgzh do k = 1, ADM_kall GRD_rdgz (k) = 1.D0 / grd_dgz(k) GRD_rdgzh(k) = 1.D0 / grd_dgzh(k) enddo !---< vertical interpolation factor >--- allocate( GRD_afac (ADM_kall) ) allocate( GRD_bfac (ADM_kall) ) allocate( GRD_cfac (ADM_kall) ) allocate( GRD_dfac (ADM_kall) ) ! From the cell center value to the cell wall value ! A(k-1/2) = ( afac(k) A(k) + bfac(k) * A(k-1) ) / 2 do k = ADM_kmin, ADM_kmax+1 GRD_afac(k) = 2.D0 * ( GRD_gzh(k) - GRD_gz(k-1) ) / ( GRD_gz(k) - GRD_gz(k-1) ) enddo GRD_afac(ADM_kmin-1) = 2.D0 GRD_bfac(:) = 2.D0 - GRD_afac(:) ! From the cell wall value to the cell center value ! A(k) = ( cfac(k) A(k+1/2) + dfac(k) * A(k-1/2) ) / 2 do k = ADM_kmin, ADM_kmax GRD_cfac(k) = 2.D0 * ( GRD_gz(k) - GRD_gzh(k) ) / ( GRD_gzh(k+1) - GRD_gzh(k) ) enddo GRD_cfac(ADM_kmin-1) = 2.D0 GRD_cfac(ADM_kmax+1) = 0.D0 GRD_dfac(:) = 2.D0 - GRD_cfac(:) return end subroutine GRD_setup !----------------------------------------------------------------------------- subroutine GRD_input_vgrid( & fname ) !ESC! use mod_misc, only :& !ESC! MISC_get_available_fid !ESC! use mod_adm, only: & !ESC! ADM_proc_stop, & !ESC! ADM_vlayer implicit none character(len=*), intent(in) :: fname integer :: num_of_layer integer :: fid, ierr !--------------------------------------------------------------------------- fid = MISC_get_available_fid() open( unit = fid, & file = trim(fname), & status = 'old', & form = 'unformatted', & access = 'sequential', & iostat = ierr ) if ( ierr /= 0 ) then write(ADM_LOG_FID,*) 'xxx No vertical grid file : ', trim(fname) call ADM_proc_stop endif read(fid) num_of_layer if ( num_of_layer /= ADM_vlayer ) then write(ADM_LOG_FID,*) 'Msg : Sub[GRD_input_vgrid]/Mod[grid]' write(ADM_LOG_FID,*) ' *** inconsistency in number of vertical layers.' call ADM_proc_stop endif read(fid) GRD_gz read(fid) GRD_gzh close(fid) return end subroutine GRD_input_vgrid end module mod_misc
dckernel_setup/src/mod_misc.f90
Phi Beta Sigma is a service Fraternities fraternity founded at Howard University on January 9, 1914. It is historically AfricanAmericans African American.
lab/davisWiki/Phi_Beta_Sigma.f
SUBROUTINE ZACON(ZR, ZI, FNU, KODE, MR, N, YR, YI, NZ, RL, FNUL, * TOL, ELIM, ALIM) C***BEGIN PROLOGUE ZACON C***REFER TO ZBESK,ZBESH C C ZACON APPLIES THE ANALYTIC CONTINUATION FORMULA C C K(FNU,ZN*EXP(MP))=K(FNU,ZN)*EXP(-MP*FNU) - MP*I(FNU,ZN) C MP=PI*MR*CMPLX(0.0,1.0) C C TO CONTINUE THE K FUNCTION FROM THE RIGHT HALF TO THE LEFT C HALF Z PLANE C C***ROUTINES CALLED ZBINU,ZBKNU,ZS1S2,D1MACH,ZABS,ZMLT C***END PROLOGUE ZACON C COMPLEX CK,CONE,CSCL,CSCR,CSGN,CSPN,CY,CZERO,C1,C2,RZ,SC1,SC2,ST, C *S1,S2,Y,Z,ZN DOUBLE PRECISION ALIM, ARG, ASCLE, AS2, AZN, BRY, BSCLE, CKI, * CKR, CONER, CPN, CSCL, CSCR, CSGNI, CSGNR, CSPNI, CSPNR, * CSR, CSRR, CSSR, CYI, CYR, C1I, C1M, C1R, C2I, C2R, ELIM, FMR, * FN, FNU, FNUL, PI, PTI, PTR, RAZN, RL, RZI, RZR, SC1I, SC1R, * SC2I, SC2R, SGN, SPN, STI, STR, S1I, S1R, S2I, S2R, TOL, YI, YR, * YY, ZEROR, ZI, ZNI, ZNR, ZR, D1MACH, ZABS INTEGER I, INU, IUF, KFLAG, KODE, MR, N, NN, NW, NZ DIMENSION YR(N), YI(N), CYR(2), CYI(2), CSSR(3), CSRR(3), BRY(3) DATA PI / 3.14159265358979324D0 / DATA ZEROR,CONER / 0.0D0,1.0D0 / NZ = 0 ZNR = -ZR ZNI = -ZI NN = N CALL ZBINU(ZNR, ZNI, FNU, KODE, NN, YR, YI, NW, RL, FNUL, TOL, * ELIM, ALIM) IF (NW.LT.0) GO TO 90 C----------------------------------------------------------------------- C ANALYTIC CONTINUATION TO THE LEFT HALF PLANE FOR THE K FUNCTION C----------------------------------------------------------------------- NN = MIN0(2,N) CALL ZBKNU(ZNR, ZNI, FNU, KODE, NN, CYR, CYI, NW, TOL, ELIM, ALIM) IF (NW.NE.0) GO TO 90 S1R = CYR(1) S1I = CYI(1) FMR = DBLE(FLOAT(MR)) SGN = -DSIGN(PI,FMR) CSGNR = ZEROR CSGNI = SGN IF (KODE.EQ.1) GO TO 10 YY = -ZNI CPN = DCOS(YY) SPN = DSIN(YY) CALL ZMLT(CSGNR, CSGNI, CPN, SPN, CSGNR, CSGNI) 10 CONTINUE C----------------------------------------------------------------------- C CALCULATE CSPN=EXP(FNU*PI*I) TO MINIMIZE LOSSES OF SIGNIFICANCE C WHEN FNU IS LARGE C----------------------------------------------------------------------- INU = INT(SNGL(FNU)) ARG = (FNU-DBLE(FLOAT(INU)))*SGN CPN = DCOS(ARG) SPN = DSIN(ARG) CSPNR = CPN CSPNI = SPN IF (MOD(INU,2).EQ.0) GO TO 20 CSPNR = -CSPNR CSPNI = -CSPNI 20 CONTINUE IUF = 0 C1R = S1R C1I = S1I C2R = YR(1) C2I = YI(1) ASCLE = 1.0D+3*D1MACH(1)/TOL IF (KODE.EQ.1) GO TO 30 CALL ZS1S2(ZNR, ZNI, C1R, C1I, C2R, C2I, NW, ASCLE, ALIM, IUF) NZ = NZ + NW SC1R = C1R SC1I = C1I 30 CONTINUE CALL ZMLT(CSPNR, CSPNI, C1R, C1I, STR, STI) CALL ZMLT(CSGNR, CSGNI, C2R, C2I, PTR, PTI) YR(1) = STR + PTR YI(1) = STI + PTI IF (N.EQ.1) RETURN CSPNR = -CSPNR CSPNI = -CSPNI S2R = CYR(2) S2I = CYI(2) C1R = S2R C1I = S2I C2R = YR(2) C2I = YI(2) IF (KODE.EQ.1) GO TO 40 CALL ZS1S2(ZNR, ZNI, C1R, C1I, C2R, C2I, NW, ASCLE, ALIM, IUF) NZ = NZ + NW SC2R = C1R SC2I = C1I 40 CONTINUE CALL ZMLT(CSPNR, CSPNI, C1R, C1I, STR, STI) CALL ZMLT(CSGNR, CSGNI, C2R, C2I, PTR, PTI) YR(2) = STR + PTR YI(2) = STI + PTI IF (N.EQ.2) RETURN CSPNR = -CSPNR CSPNI = -CSPNI AZN = ZABS(CMPLX(ZNR,ZNI,kind=KIND(1.0D0))) RAZN = 1.0D0/AZN STR = ZNR*RAZN STI = -ZNI*RAZN RZR = (STR+STR)*RAZN RZI = (STI+STI)*RAZN FN = FNU + 1.0D0 CKR = FN*RZR CKI = FN*RZI C----------------------------------------------------------------------- C SCALE NEAR EXPONENT EXTREMES DURING RECURRENCE ON K FUNCTIONS C----------------------------------------------------------------------- CSCL = 1.0D0/TOL CSCR = TOL CSSR(1) = CSCL CSSR(2) = CONER CSSR(3) = CSCR CSRR(1) = CSCR CSRR(2) = CONER CSRR(3) = CSCL BRY(1) = ASCLE BRY(2) = 1.0D0/ASCLE BRY(3) = D1MACH(2) AS2 = ZABS(CMPLX(S2R,S2I,kind=KIND(1.0D0))) KFLAG = 2 IF (AS2.GT.BRY(1)) GO TO 50 KFLAG = 1 GO TO 60 50 CONTINUE IF (AS2.LT.BRY(2)) GO TO 60 KFLAG = 3 60 CONTINUE BSCLE = BRY(KFLAG) S1R = S1R*CSSR(KFLAG) S1I = S1I*CSSR(KFLAG) S2R = S2R*CSSR(KFLAG) S2I = S2I*CSSR(KFLAG) CSR = CSRR(KFLAG) DO 80 I=3,N STR = S2R STI = S2I S2R = CKR*STR - CKI*STI + S1R S2I = CKR*STI + CKI*STR + S1I S1R = STR S1I = STI C1R = S2R*CSR C1I = S2I*CSR STR = C1R STI = C1I C2R = YR(I) C2I = YI(I) IF (KODE.EQ.1) GO TO 70 IF (IUF.LT.0) GO TO 70 CALL ZS1S2(ZNR, ZNI, C1R, C1I, C2R, C2I, NW, ASCLE, ALIM, IUF) NZ = NZ + NW SC1R = SC2R SC1I = SC2I SC2R = C1R SC2I = C1I IF (IUF.NE.3) GO TO 70 IUF = -4 S1R = SC1R*CSSR(KFLAG) S1I = SC1I*CSSR(KFLAG) S2R = SC2R*CSSR(KFLAG) S2I = SC2I*CSSR(KFLAG) STR = SC2R STI = SC2I 70 CONTINUE PTR = CSPNR*C1R - CSPNI*C1I PTI = CSPNR*C1I + CSPNI*C1R YR(I) = PTR + CSGNR*C2R - CSGNI*C2I YI(I) = PTI + CSGNR*C2I + CSGNI*C2R CKR = CKR + RZR CKI = CKI + RZI CSPNR = -CSPNR CSPNI = -CSPNI IF (KFLAG.GE.3) GO TO 80 PTR = DABS(C1R) PTI = DABS(C1I) C1M = DMAX1(PTR,PTI) IF (C1M.LE.BSCLE) GO TO 80 KFLAG = KFLAG + 1 BSCLE = BRY(KFLAG) S1R = S1R*CSR S1I = S1I*CSR S2R = STR S2I = STI S1R = S1R*CSSR(KFLAG) S1I = S1I*CSSR(KFLAG) S2R = S2R*CSSR(KFLAG) S2I = S2I*CSSR(KFLAG) CSR = CSRR(KFLAG) 80 CONTINUE RETURN 90 CONTINUE NZ = -1 IF(NW.EQ.(-2)) NZ=-2 RETURN END
mathext/internal/amos/amoslib/zacon.f
! { dg-do compile } ! ! PR 37254: Reject valid PROCEDURE statement with implicit interface ! ! Original test case by Dominique d'Humieres <[email protected]> ! Modified by Janus Weil <[email protected]> real function proc3( arg1 ) integer :: arg1 proc3 = arg1+7 end function proc3 program myProg PROCEDURE () :: proc3 call proc4( proc3 ) contains subroutine proc4( arg1 ) PROCEDURE(real) :: arg1 print*, 'the func: ', arg1(0) end subroutine proc4 end program myProg
validation_tests/llvm/f18/gfortran.dg/proc_decl_22.f90
! ********************************************************************* ! * * ! * subroutine prfmtf * ! * * ! ********************************************************************* ! Single Precision Version 1.1 ! Written by Gordon A. Fenton, TUNS, Sun Jun 1 17:46:55 1997 ! Latest Update: Jul 1, 1997 ! ! PURPOSE prints a real number using f format ! ! This routine writes the real value `val' to an output file ! using the format ! ! l.r ! ! where `l' expands into as many digits as necessary, unless otherwise ! specified by the iw and id arguments, and `r' represents ! the digits to the right of the decimal place. Since this is a single ! precision subroutine, the maximum number of significant digits ! displayed will be 7 and by default no more than 7 digits will appear ! to the right of the decimal point. These defaults may be overridden ! by specifying non-negative values of iw and id, as discussed below. ! ! The floating point format will only be used if val is between 1.e+7 ! and 1.e-6 or zero. If val is outside this range, then a scientific format ! is used (see prfmte), and the values of iw and id are ignored. ! ! If both iw and id are negative, then the minimum width format required to ! represent the number is determined internally. ! ! If either iw or id are non-negative, then the format used to represent the ! number is one of the following; ! ! iw.id (iw and id non-negative) In this case, iw is the minimum total ! field width (including the decimal point) and id is the ! maximum number of digits to show to the right of the decimal ! place. For example, the format %7.2f implies that the number ! 12.345600 would be represented as ' 12.35'. If iw is too ! small to contain the number, it is increased accordingly. ! ! iw (id is negative) In this case, iw is the minimum field width ! (including the decimal point) used to represent the number. ! For example, the format %12f implies that the number 12.345600 ! would be represented as ' 12.3456'. If iw is less than ! the number of digits to the left of the decimal place, then ! iw is increased accordingly (except that if more than 7 digits ! are required, scientific notation is used). ! ! .id (iw is negative) In this case, id is the maximum number of ! digits to show to the right of the decimal place. For example, ! the format %.2f implies that the number 12.345600 would be ! represented as '12.35'. id must be less than or equal to ! seven. ! ! . (iw and id negative, but decimal point provided) In this case, ! the decimal point just implies that the value zero is ! represented as '0.', rather than just '0'. For example, the ! format %.f would represent the number zero as '0.'. ! ! Arguments to this routine are as follows; ! ! val real value containing the number to print. (input) ! ! iw integer containing the minimum total field width of the number ! to be printed. If iw is insufficient to contain the number, it ! is increased accordingly. If iw < 0, then it is assumed to not ! be set and a minimum value is computed internally. (input) ! ! id integer containing the maximum number of digits to show to the ! right of the decimal point. If id < 0, then it is assumed to ! not be set and the minimum number of digits to the right of ! the decimal point required to show the number is computed ! internally. (input) ! ! ldot logical flag which is true if a decimal point has been ! specified in the format descriptor. This is used only to ! decide whether to represent zero as '0.' (ldot true) or ! '0' (ldot false). (input) ! ! k output unit number to which the number is printed (without ! concluding newline character). (input) ! ! REVISION HISTORY: ! 1.1 corrected overrun on 7 sig digit numbers. (Jul 1/97) ! 1.2 calling routine now provides the iw.id format (Oct 1/01) !------------------------------------------------------------------------- subroutine prfmtf(val,iw,id,ldot,k) character fstr*256, d(10)*1 logical ldot, lround ! basic digits data d/'0','1','2','3','4','5','6','7','8','9'/ 1 format(a,$) ! get absolute value of val aval = abs(val) ! check 1.e-6 < |val| < 1.e+7 if( aval .ne. 0.0 ) then if( aval .lt. 1.e-6 .or. aval .gt. 1.e+7 ) then call prfmte(val,iw,id,k) return endif endif ! transfer iw and id to temp vars jw = iw jd = id ! check specification; iw > id md = 2 if( val .lt. 0.0 ) md = 3 if( (jw .ge. 0) .and. (jd .ge. 0) ) then if( jd .ge. jw ) jd = jw - md ! we like to keep at least 0. if( jd .lt. 0 ) jd = 0 endif ! pointer into fstr m = 1 ! special case: val = 0 --------------- if( val .eq. 0.0 ) then if( (jw .lt. 0) .and. (jd .lt. 0) ) then if( ldot ) then write(k,1) '0.' else write(k,1) '0' endif elseif( (jw .ge. 0) .and. (jd .lt. 0) ) then if( ldot ) then do 30 i = 1, jw-2 fstr(m:m) = ' ' m = m + 1 30 continue fstr(m:m+1) = '0.' write(k,1) fstr(1:m+1) else do 40 i = 1, jw-1 fstr(m:m) = ' ' m = m + 1 40 continue fstr(m:m) = '0' write(k,1) fstr(1:m) endif elseif( (jw .lt. 0) .and. (jd .ge. 0) ) then write(k,1) '0' else ! both iw and id are specified ib = jw - (jd + 2) do 50 i = 1, ib fstr(m:m) = ' ' m = m + 1 50 continue fstr(m:m+1) = '0.' m = m + 1 do 60 i = 1, jd m = m + 1 fstr(m:m) = '0' 60 continue write(k,1) fstr(1:m) endif return endif ! set sign --------------------------- if( val .lt. 0.0 ) then fstr(1:1) = '-' m = 2 endif lround = .false. ! derive magnitude of number 70 al = alog10(aval) im = int( al ) if( (aval .lt. 1.0) .and. (aval .ne. 10.**im) ) im = im - 1 ! get number of digits to left of decimal il = max0( md-1, im+md-1 ) ! we like to keep at least the 0. ! adjust iw if necessary and ! derive roundoff factor if( jw .ge. 0 ) then if( jd .ge. 0 ) then iwr = jw - (jd + 1) if( iwr .lt. il ) then jd = jd - (il - iwr) if( jd .lt. 0 ) then jw = jw - jd jd = 0 endif endif round = 0.5*10.**(-jd) ! show id digits to right of . else if( jw .lt. il ) jw = il if( aval .lt. 1.0 ) then iwr = min0( jw-md, 6-im ) ! for large iw, show 7 sig digits round = 0.5*10.**(-iwr) else iwr = min0( 6, jw-md ) - im round = 0.5*10.**(-iwr) endif endif else if( jd .lt. 0 ) then if( aval .lt. 1.0 ) then round = 0.5e-07 ! show only 7 digits to right of . else iwr = 6 - im ! show 7 sig digits round = 0.5*10.**(-iwr) endif else round = 0.5*10.**(-jd) endif endif ! apply round-off and go back to check im if( .not. lround ) then aval = aval + round lround = .true. go to 70 endif ! set up the basic number string idot = 0 ! leading zeros if val < 1 if( aval .lt. 1.0 ) then fstr(m:m+1) = '0.' idot = m+1 m = m + 2 do 80 i = 1, -im-1 fstr(m:m) = '0' m = m + 1 n = n + 1 80 continue endif ! the rest of the number, 7 digits max ! unless >= 1e+7 (which shouldn't happen) n = 0 ! the number of sig digits written t = aval ! normalize t i1 = im t = t/(10.**i1) 90 if( (n .lt. 7) .or. (idot .eq. 0) ) then ij = int( t ) fstr(m:m) = d(ij+1) n = n + 1 m = m + 1 if( i1 .eq. 0 ) then fstr(m:m) = '.' idot = m m = m + 1 endif t = (t - float( ij ))*10. i1 = i1 - 1 go to 90 endif m = m - 1 ! points at last digit in fstr ! eliminate trailing zeroes after . if( jw .lt. 0 ) then mm = 7 + idot if( jd .ge. 0 ) mm = jd+idot if( m .gt. mm ) m = mm do 100 i = m, idot, -1 if( fstr(i:i) .ne. '0' ) go to 110 m = m - 1 ! points at last non-zero digit 100 continue 110 if( m .eq. idot ) m = m - 1 ! don't show decimal if nothing after endif ! now write it out... if( (jw .lt. 0) .and. (jd .lt. 0) ) then ! no specification write(k,1) fstr(1:m) elseif( (jw .ge. 0) .and. (jd .lt. 0) ) then if( aval .lt. 1.0 ) then nb = jw - md - 6 + im mm = md + min0( jw-md, 6-im ) else nb = jw - md - 6 mm = min0( m, jw ) endif do 120 i = 1, nb write(k,1) ' ' 120 continue write(k,1) fstr(1:mm) elseif( (jw .lt. 0) .and. (jd .ge. 0) ) then ii = min0( idot+jd, m ) write(k,1) fstr(1:ii) else ! both iw and id are specified do 130 i = m+1, jd + idot fstr(i:i) = ' ' 130 continue mm = jd + idot do 140 i = mm, jw-1 write(k,1) ' ' 140 continue write(k,1) fstr(1:mm) endif ! all done return end
src/libs/gaf95/prfmtf.f95
C Copyright(C) 2008-2017 National Technology & Engineering Solutions of C 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 Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C C======================================================================= SUBROUTINE RWXYZ (NDBIN, NDBOUT, NDIM, NUMNP, NUMNPO, & IXNODE, CORD, CRDSCR) C======================================================================= C --*** RWXYZ *** (ALGEBRA) Read and write database coordinates C -- Written by Amy Gilkey - revised 11/30/87 C -- Modified for EXODUSIIV2 format 8/29/95 C -- C --RWXYZ reads and writes the coordinate array to the database. C --Deleted nodes are removed. C -- C --Parameters: C -- NDBIN, NDBOUT - IN - the input and output database file C -- NDIM - IN - the number of coordinates per node C -- NUMNP - IN - the number of nodes C -- NUMNPO - IN - the number of nodes C -- IXNODE - IN - the indices of the output nodes (iff NUMNPO <> NUMNP) C -- CORD - SCRATCH - coordinate I/O C -- CRDSCR - SCRATCH - coordinate I/O INTEGER NDBIN, NDBOUT INTEGER NDIM INTEGER NUMNP INTEGER IXNODE(*) REAL CORD(NUMNP,NDIM) REAL CRDSCR(NUMNPO,NDIM) if (ndim .eq. 2) then CALL EXGCOR(ndbin, cord(1,1), cord(1,2), rdum, ierr) else if (ndim .eq. 3) then CALL EXGCOR(ndbin, cord(1,1), cord(1,2), & cord(1,3), ierr) else call prterr('FATAL', 'Illegal model dimension') RETURN end if IF ((NUMNPO .GT. 0) .AND. (NDIM .GT. 0)) THEN IF (NUMNP .EQ. NUMNPO) THEN if (ndim .eq. 2) then CALL EXPCOR(ndbout, cord(1,1), cord(1,2), rdum, ierr) else if (ndim .eq. 3) then CALL EXPCOR(ndbout, cord(1,1), cord(1,2), & cord(1,3), ioerr) else call prterr('FATAL', 'Illegal model dimension') RETURN end if ELSE do 20 idim=1, ndim do 10 ix=1, numnpo crdscr(ix,idim) = cord(ixnode(ix),idim) 10 continue 20 continue if (ndim .eq. 2) then CALL EXPCOR(ndbout, crdscr(1,1), crdscr(1,2), & rdum, ioerr) else if (ndim .eq. 3) then CALL EXPCOR(ndbout, crdscr(1,1), crdscr(1,2), & crdscr(1,3), ioerr) else call prterr('FATAL', 'Illegal model dimension') end if END IF ELSE continue END IF RETURN END
packages/seacas/applications/algebra/ag_rwxyz.f