!--
!----------------------------------------------------------------------
!     Copyright (c) 2019-2020 Shin-ichi Takehiro. All rights reserved.
!----------------------------------------------------------------------
!è¡¨é¡Œ  ua_deriv_mpi_module_sypack
!
!  spml/ua_deriv_mpi_module_sypack ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã¯çƒé¢ä¸Šã§ã®æµä½“é‹å‹•ã‚’
!  çƒé¢èª¿å’Œå‡½æ•°ã‚’ç”¨ã„ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«æ³•ã«ã‚ˆã£ã¦æ•°å€¤è¨ˆç®—ã™ã‚‹ãŸã‚ã®
!  ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ« ua_mpi_module_sypack ã®ä¸‹éƒ¨ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã§ã‚ã‚Š, ã‚¹ãƒšã‚¯ãƒˆãƒ«æ³•ã®
!  å¾®åˆ†è¨ˆç®—ã®ãŸã‚ã® Fortran90 é–¢æ•°ã‚’æä¾›ã™ã‚‹.
!
!  çƒé¢ä¸Šã® 1 å±¤ãƒ¢ãƒ‡ãƒ«ç”¨ u_deriv_mpi_module_sypack ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã‚’å¤šå±¤ãƒ¢ãƒ‡ãƒ«ç”¨ã«
!  æ‹¡å¼µã—ãŸã‚‚ã®ã§ã‚ã‚Š, åŒæ™‚ã«è¤‡æ•°å€‹ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿, æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
!  å¯¾ã™ã‚‹å¤‰æ›ãŒè¡Œãˆã‚‹.
!
!  å†…éƒ¨ã§ ISPACK3 ã® SYPACK ã® Fortran77 ã‚µãƒ–ãƒ«ãƒ¼ãƒãƒ³ã‚’å‘¼ã‚“ã§ã„ã‚‹.
!  ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ãŠã‚ˆã³æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã®æ ¼ç´æ–¹æ³•ã‚„å¤‰æ›ã®è©³ã—ã„è¨ˆç®—æ³•ã«
!  ã¤ã„ã¦ã¯ ISPACK3/SYPACK ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã‚’å‚ç…§ã•ã‚ŒãŸã„.
!
!å±¥æ´  2019/04/30  ç«¹åºƒçœŸä¸€
!      2020/08/05  ç«¹åºƒçœŸä¸€  xvb <=> pva ã¨ wb é–¢æ•°ã‚’è¿½åŠ
!      2020/08/11  ç«¹åºƒçœŸä¸€  bug fixed
!
!      åˆ¶é™
!         ãƒ»å¤‰æ›ã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿, ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®é…åˆ—ã®å¤§ãã•ã¯æ±ºã‚ã†ã¡
!
module ua_mpi_module_deriv
  !
  != ua_mpi_module_deriv
  !
  ! Authors:: Shin-ichi Takehiro, Youhei SASAKI
  ! Version:: $Id$
  ! Copyright&License:: See COPYRIGHT[link:../COPYRIGHT]
  !
  !== æ¦‚è¦
  !
  !  spml/ua_mpi_module_deriv ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã¯çƒé¢ä¸Šã§ã®æµä½“é‹å‹•ã‚’
  !  çƒé¢èª¿å’Œå‡½æ•°ã‚’ç”¨ã„ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«æ³•ã«ã‚ˆã£ã¦æ•°å€¤è¨ˆç®—ã™ã‚‹ãŸã‚ã®
  !  ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ« ua_mpi_module ã®ä¸‹éƒ¨ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã§ã‚ã‚Š, ã‚¹ãƒšã‚¯ãƒˆãƒ«æ³•ã®
  !  å¾®åˆ†è¨ˆç®—ã®ãŸã‚ã® Fortran90 é–¢æ•°ã‚’æä¾›ã™ã‚‹.
  !
  !  çƒé¢ä¸Šã® 1 å±¤ãƒ¢ãƒ‡ãƒ«ç”¨ u_deriv_mpi_module ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã‚’å¤šå±¤ãƒ¢ãƒ‡ãƒ«ç”¨ã«
  !  æ‹¡å¼µã—ãŸã‚‚ã®ã§ã‚ã‚Š, åŒæ™‚ã«è¤‡æ•°å€‹ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿, æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
  !  å¯¾ã™ã‚‹å¤‰æ›ãŒè¡Œãˆã‚‹.
  !
  !  å†…éƒ¨ã§ ISPACK3 ã® SYPACK ã® Fortran77 ã‚µãƒ–ãƒ«ãƒ¼ãƒãƒ³ã‚’å‘¼ã‚“ã§ã„ã‚‹.
  !  ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ãŠã‚ˆã³æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã®æ ¼ç´æ–¹æ³•ã‚„å¤‰æ›ã®è©³ã—ã„è¨ˆç®—æ³•ã«
  !  ã¤ã„ã¦ã¯ ISPACK3/SYPACK ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã‚’å‚ç…§ã•ã‚ŒãŸã„.
  !
  use dc_types, only: DP
  use dc_message, only : MessageNotify
  use w_mpi_module_base, only : im, jm, nm=>nn, jc=>jl
  use w_mpi_module_deriv
  use ua_mpi_module_base, only : &
       & pva_ua, ua_pva, xvb_ua, ua_xvb, pva_wb, wb_pva, &
       & xv_u, u_xv, pv_w, w_pv, pv_u, u_pv, &
       & ic, nc, nmc, nms, nme, kc, km, ua_wb, wb_ua, ua_wa, wa_ua

  implicit none

  real(DP), allocatable  :: rnu(:,:)
  ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³æ¼”ç®—ç”¨é…åˆ—(u_module ã¨äº’æ›æ€§ã‚’ä¿ã¤ãŸã‚)
  !
  ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã‚’è¨ˆç®—ã™ã‚‹ãŸã‚ã®ä¿‚æ•°
  ! é…åˆ—ã®ã‚µã‚¤ã‚ºã¯(nmc, 2)
  !
  ! r(L,1) ã«ã¯ L ç•ªç›®ã®æ ¼ç´ä½ç½®ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ã«å¯¾ã™ã‚‹ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³è¨ˆç®—ã®
  ! ä¿‚æ•° -n(n+1) ã®å€¤ãŒæ ¼ç´ã•ã‚Œã¦ã„ã‚‹.

  ! private im, jm, nm, nc, kc                  ! for Intel Fortran
  private

  public ua_deriv_mpi_Initial
  public ua_deriv_mpi_Finalize

  public ua_Lapla_ua, ua_LaplaInv_ua          ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨é€†æ¼”ç®—
  public ua_DLon_ua                           ! çµŒåº¦å¾®åˆ†
  public pva_GradLon_ua, pva_GradLat_ua       ! å‹¾é…åž‹å¾®åˆ†
  public xvb_GradLon_ua, xvb_GradLat_ua       ! å‹¾é…åž‹å¾®åˆ†
  public ua_DivLon_pva, ua_DivLat_pva         ! ç™ºæ•£åž‹å¾®åˆ†
  public ua_DivLon_xvb, ua_DivLat_xvb         ! ç™ºæ•£åž‹å¾®åˆ†
  public ua_Div_pva_pva                       ! ç™ºæ•£åž‹å¾®åˆ†
  public ua_Div_xvb_xvb                       ! ç™ºæ•£åž‹å¾®åˆ†
  public ua_JacobianMPI_ua_ua                 ! ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³
  public pva_GradLambda_ua, pva_GradMu_ua     ! å‹¾é…åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)
  public xvb_GradLambda_ua, xvb_GradMu_ua     ! å‹¾é…åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)
  public ua_DivLambda_pva, ua_DivMu_pva       ! ç™ºæ•£åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)
  public ua_DivLambda_xvb, ua_DivMu_xvb       ! ç™ºæ•£åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)

  public wb_Lapla_wb, wb_LaplaInv_wb          ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨é€†æ¼”ç®—
  public wb_DLon_wb                           ! çµŒåº¦å¾®åˆ†
  public pva_GradLon_wb, pva_GradLat_wb       ! å‹¾é…åž‹å¾®åˆ†
  public wb_DivLon_pva, wb_DivLat_pva         ! ç™ºæ•£åž‹å¾®åˆ†
  public wb_Div_pva_pva                       ! ç™ºæ•£åž‹å¾®åˆ†
  public wb_JacobianMPI_wb_wb                 ! ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³
  public pva_GradLambda_wb, pva_GradMu_wb     ! å‹¾é…åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)
  public wb_DivLambda_pva, wb_DivMu_pva       ! ç™ºæ•£åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)

  public u_Lapla_u, u_LaplaInv_u              ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨é€†æ¼”ç®—
  public u_DLon_u                             ! çµŒåº¦å¾®åˆ†
  public pv_GradLon_u, pv_GradLat_u           ! å‹¾é…åž‹å¾®åˆ†
  public xv_GradLon_u, xv_GradLat_u           ! å‹¾é…åž‹å¾®åˆ†
  public u_DivLon_pv, u_DivLat_pv             ! ç™ºæ•£åž‹å¾®åˆ†
  public u_DivLon_xv, u_DivLat_xv             ! ç™ºæ•£åž‹å¾®åˆ†
  public u_Div_pv_pv                          ! ç™ºæ•£åž‹å¾®åˆ†
  public u_Div_xv_xv                          ! ç™ºæ•£åž‹å¾®åˆ†
  public u_JacobianMPI_u_u                    ! ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³
  public pv_GradLambda_u, pv_GradMu_u         ! å‹¾é…åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)
  public xv_GradLambda_u, xv_GradMu_u         ! å‹¾é…åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)
  public u_DivLambda_pv, u_DivMu_pv           ! ç™ºæ•£åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)
  public u_DivLambda_xv, u_DivMu_xv           ! ç™ºæ•£åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)

  public w_Lapla_w, w_LaplaInv_w              ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨é€†æ¼”ç®—
  public w_DLon_w                             ! çµŒåº¦å¾®åˆ†
  public pv_GradLon_w, pv_GradLat_w           ! å‹¾é…åž‹å¾®åˆ†
  public w_DivLon_pv, w_DivLat_pv             ! ç™ºæ•£åž‹å¾®åˆ†
  public w_Div_pv_pv                          ! ç™ºæ•£åž‹å¾®åˆ†
  public w_JacobianMPI_w_w                    ! ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³
  public pv_GradLambda_w, pv_GradMu_w         ! å‹¾é…åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)
  public w_DivLambda_pv, w_DivMu_pv           ! ç™ºæ•£åž‹å¾®åˆ†(Î»,Î¼åº§æ¨™)

  public rn, rnu                              ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³æ¼”ç®—ç”¨é…åˆ—

contains

    !--------------- åˆæœŸåŒ– -----------------
    subroutine ua_deriv_mpi_initial
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«å¾®åˆ†è¨ˆç®—ã«å¿…è¦ã¨ãªã‚‹ä½œæ¥é ˜åŸŸã‚’è¨å®šã™ã‚‹.
      !
      ! ä»–ã®é–¢æ•°ã‚’å‘¼ã¶å‰ã«, æœ€åˆã«ã“ã®ã‚µãƒ–ãƒ«ãƒ¼ãƒãƒ³ã‚’å‘¼ã‚“ã§
      ! åˆæœŸè¨å®šã‚’ã—ãªã‘ã‚Œã°ãªã‚‰ãªã„.
      !
      ! ä¸Šä½ã‚µãƒ–ãƒ«ãƒ¼ãƒãƒ³ ua_mpi_Initial ã‚’ä½¿ç”¨ã™ã‚‹ã“ã¨.
      !

      call w_deriv_mpi_initial

      allocate(rnu(nmc,2))                    ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³æ¼”ç®—ç”¨é…åˆ—
      rnu = rn(nms:nme,:)

      call MessageNotify('M','ua_deriv_mpi_initial', &
           'ua_mpi_module_deriv (2020/08/11)is initialized')

    end subroutine ua_deriv_mpi_initial

    !--------------- å¾®åˆ†è¨ˆç®—(ua, å¤šå±¤) -----------------
    function ua_Lapla_ua(ua_data)
      !
      ! å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      !
      !    â–½^2 = 1/cos^2Ï†ãƒ»âˆ‚^2/âˆ‚Î»^2 + 1/cosÏ†ãƒ»âˆ‚/âˆ‚Ï†(cosÏ†âˆ‚/âˆ‚Ï†)
      !
      ! ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨ã¯, å¯¾å¿œã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
      ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã‚’ä½œç”¨ã•ã›ãŸãƒ‡ãƒ¼ã‚¿ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«å¤‰æ›ã®ã“ã¨ã§ã‚ã‚‹.
      !
      real(DP), intent(in)  :: ua_data(:,:)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_lapla_ua(nmc,size(ua_data,2))
      !(out) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      integer :: k

      do k=1,size(ua_data,2)
         ua_Lapla_ua(:,k) = rnu(:,1)*ua_data(:,k)
      enddo

    end function ua_Lapla_ua

    function ua_LaplaInv_ua(ua_data)
      !
      ! å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      !
      !    â–½^{-2}
      !      =[1/cos^2Ï†ãƒ»âˆ‚^2/âˆ‚Î»^2 + 1/cosÏ†ãƒ»âˆ‚/âˆ‚Ï†(cosÏ†âˆ‚/âˆ‚Ï†)]^{-1}
      !
      ! ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨ã¯, å¯¾å¿œã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
      ! é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã‚’ä½œç”¨ã•ã›ãŸãƒ‡ãƒ¼ã‚¿ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«å¤‰æ›ã®ã“ã¨ã§ã‚ã‚‹.
      !
      real(DP), intent(in)  :: ua_data(:,:)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_LaplaInv_ua(nmc,size(ua_data,2))
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      integer :: k

      do k=1,size(ua_data,2)
         ua_LaplaInv_ua(:,k) = rnu(:,2)*ua_data(:,k)
      enddo

    end function ua_LaplaInv_ua

    function ua_DLon_ua(ua_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«çµŒåº¦å¾®åˆ† âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã•ã›ã‚‹(å¤šå±¤ç”¨).
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®çµŒåº¦å¾®åˆ†ã¨ã¯, å¯¾å¿œã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
      ! çµŒåº¦å¾®åˆ†âˆ‚/âˆ‚Î»ã‚’ä½œç”¨ã•ã›ãŸãƒ‡ãƒ¼ã‚¿ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«å¤‰æ›ã®ã“ã¨ã§ã‚ã‚‹.
      !
      real(DP), intent(in)  :: ua_data(:,:)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_DLon_ua(nmc,size(ua_data,2))
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®çµŒåº¦å¾®åˆ†
      integer :: k

      real(DP) :: wb_data(nc,kc)

      wb_data = wb_ua(ua_data)
      do k=1,kc
         wb_data(:,k) = w_DLon_w(wb_data(:,k))
      enddo
      ua_DLon_ua = ua_wb(wb_data)

    end function ua_DLon_ua

    function pva_GradLon_ua(ua_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’
      ! ä½œç”¨ã•ã›ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: ua_data(nmc,km)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pva_GradLon_ua(0:ic-1,jc,km)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pva_GradLon_ua = pva_ua(ua_data,ipow=1,iflag=-1)

    end function pva_GradLon_ua

    function xvb_GradLon_ua(ua_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’
      ! ä½œç”¨ã•ã›ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: ua_data(nmc,km)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: xvb_GradLon_ua(0:im-1,jc,kc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      xvb_GradLon_ua = xvb_ua(ua_data,ipow=1,iflag=-1)

    end function xvb_GradLon_ua

    function pva_GradLat_ua(ua_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: ua_data(nmc,km)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pva_GradLat_ua(0:ic-1,jc,km)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pva_GradLat_ua = pva_ua(ua_data,ipow=1,iflag=1)

    end function pva_GradLat_ua

    function xvb_GradLat_ua(ua_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: ua_data(nmc,km)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: xvb_GradLat_ua(0:im-1,jc,kc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      xvb_GradLat_ua = xvb_ua(ua_data,ipow=1,iflag=1)

    end function xvb_GradLat_ua

    function ua_DivLon_pva(pva_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_data(0:ic-1,jc,kc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_DivLon_pva(nmc,km)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_DivLon_pva = ua_pva(pva_data,ipow=1,iflag=-1)

    end function ua_DivLon_pva

    function ua_DivLon_xvb(xvb_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xvb_data(0:im-1,jc,kc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_DivLon_xvb(nmc,km)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_DivLon_xvb = ua_xvb(xvb_data,ipow=1,iflag=-1)

    end function ua_DivLon_xvb

    function ua_DivLat_pva(pva_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚(f cosÏ†)/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_data(0:ic-1,jc,kc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_DivLat_pva(nmc,km)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_DivLat_pva = ua_pva(pva_data,ipow=1,iflag=1)

    end function ua_DivLat_pva

    function ua_DivLat_xvb(xvb_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚(f cosÏ†)/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xvb_data(0:im-1,jc,kc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_DivLat_xvb(nmc,km)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_DivLat_xvb = ua_xvb(xvb_data,ipow=1,iflag=1)

    end function ua_DivLat_xvb

    function ua_Div_pva_pva(pva_u,pva_v)
      !
      ! 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã‚’è¨ˆç®—ã—,
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã¨ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_u(0:ic-1,jc,kc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«çµŒåº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP), intent(in)  :: pva_v(0:ic-1,jc,kc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«ç·¯åº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_Div_pva_pva(nmc,km)
      !(out) 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_Div_pva_pva = ua_DivLon_pva(pva_u) + ua_DivLat_pva(pva_v)

    end function ua_Div_pva_pva

    function ua_Div_xvb_xvb(xvb_u,xvb_v)
      !
      ! 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã‚’è¨ˆç®—ã—,
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã¨ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xvb_u(0:im-1,jc,kc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«çµŒåº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP), intent(in)  :: xvb_v(0:im-1,jc,kc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«ç·¯åº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_Div_xvb_xvb(nmc,km)
      !(out) 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_Div_xvb_xvb = ua_DivLon_xvb(xvb_u) + ua_DivLat_xvb(xvb_v)

    end function ua_Div_xvb_xvb

    function ua_JacobianMPI_ua_ua(ua_a,ua_b)
      ! 2 ã¤ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³
      !
      !   J(f,g) = âˆ‚f/âˆ‚Î»ãƒ»âˆ‚g/âˆ‚Î¼ - âˆ‚g/âˆ‚Î»ãƒ»âˆ‚f/âˆ‚Î¼
      !          = âˆ‚f/âˆ‚Î»ãƒ»1/cosÏ†ãƒ»âˆ‚g/âˆ‚Ï†
      !             - âˆ‚g/âˆ‚Î»ãƒ»1/cosÏ†ãƒ»âˆ‚f/âˆ‚Ï†
      !
      ! ã‚’ä½œç”¨ã•ã›ã‚‹(å¤šå±¤ç”¨).
      !
      real(DP), intent(in) :: ua_a(nmc,km)
      !(in) 1ã¤ç›®ã®å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP), intent(in) :: ua_b(nmc,km)
      !(in) 2ã¤ç›®ã®å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)             :: ua_JacobianMPI_ua_ua(nmc,km)
      !(out) 2 ã¤ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³
      integer :: k

      real(DP) :: wb_a(nc,kc)
      real(DP) :: wb_b(nc,kc)

      wb_a = wb_ua(ua_a) ; wb_b = wb_ua(ua_b)

      do k=1,kc
         wb_a(:,k) = w_JacobianMPI_w_w(wb_a(:,k),wb_b(:,k))
      end do

      ua_JacobianMPI_ua_ua = ua_wb(wb_a)

    end function ua_JacobianMPI_ua_ua

    !--------------- å¾®åˆ†è¨ˆç®—(wb å¤šå±¤) -----------------
    function wb_Lapla_wb(wb_data)
      !
      ! å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      !
      !    â–½^2 = 1/cos^2Ï†ãƒ»âˆ‚^2/âˆ‚Î»^2 + 1/cosÏ†ãƒ»âˆ‚/âˆ‚Ï†(cosÏ†âˆ‚/âˆ‚Ï†)
      !
      ! ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨ã¯, å¯¾å¿œã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
      ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã‚’ä½œç”¨ã•ã›ãŸãƒ‡ãƒ¼ã‚¿ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«å¤‰æ›ã®ã“ã¨ã§ã‚ã‚‹.
      !
      real(DP), intent(in)  :: wb_data(:,:)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: wb_lapla_wb(nc,size(wb_data,2))
      !(out) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      integer :: k

      do k=1,size(wb_data,2)
         wb_Lapla_wb(:,k) = rn(:,1)*wb_data(:,k)
      enddo

    end function wb_Lapla_wb

    function wb_LaplaInv_wb(wb_data)
      !
      ! å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      !
      !    â–½^{-2}
      !      =[1/cos^2Ï†ãƒ»âˆ‚^2/âˆ‚Î»^2 + 1/cosÏ†ãƒ»âˆ‚/âˆ‚Ï†(cosÏ†âˆ‚/âˆ‚Ï†)]^{-1}
      !
      ! ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨ã¯, å¯¾å¿œã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
      ! é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã‚’ä½œç”¨ã•ã›ãŸãƒ‡ãƒ¼ã‚¿ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«å¤‰æ›ã®ã“ã¨ã§ã‚ã‚‹.
      !
      real(DP), intent(in)  :: wb_data(:,:)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: wb_LaplaInv_wb(nc,size(wb_data,2))
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      integer :: k

      do k=1,size(wb_data,2)
         wb_LaplaInv_wb(:,k) = rn(:,2)*wb_data(:,k)
      enddo

    end function wb_LaplaInv_wb

    function wb_DLon_wb(wb_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«çµŒåº¦å¾®åˆ† âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã•ã›ã‚‹(å¤šå±¤ç”¨).
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®çµŒåº¦å¾®åˆ†ã¨ã¯, å¯¾å¿œã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
      ! çµŒåº¦å¾®åˆ†âˆ‚/âˆ‚Î»ã‚’ä½œç”¨ã•ã›ãŸãƒ‡ãƒ¼ã‚¿ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«å¤‰æ›ã®ã“ã¨ã§ã‚ã‚‹.
      !
      real(DP), intent(in)  :: wb_data(:,:)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: wb_DLon_wb(nc,size(wb_data,2))
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®çµŒåº¦å¾®åˆ†
      integer :: k

      do k=1,kc
         wb_DLon_wb(:,k) = w_DLon_w(wb_data(:,k))
      enddo

    end function wb_DLon_wb

    function pva_GradLon_wb(wb_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’
      ! ä½œç”¨ã•ã›ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: wb_data(nc,kc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pva_GradLon_wb(0:ic-1,jc,km)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pva_GradLon_wb = pva_wb(wb_data,ipow=1,iflag=-1)

    end function pva_GradLon_wb

    function pva_GradLat_wb(wb_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: wb_data(nc,kc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pva_GradLat_wb(0:ic-1,jc,km)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pva_GradLat_wb = pva_wb(wb_data,ipow=1,iflag=1)

    end function pva_GradLat_wb

    function wb_DivLon_pva(pva_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_data(0:ic-1,jc,km)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: wb_DivLon_pva(nc,kc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      wb_DivLon_pva = wb_pva(pva_data,ipow=1,iflag=-1)

    end function wb_DivLon_pva

    function wb_DivLat_pva(pva_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚(f cosÏ†)/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_data(0:ic-1,jc,km)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: wb_DivLat_pva(nc,kc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      wb_DivLat_pva = wb_pva(pva_data,ipow=1,iflag=1)

    end function wb_DivLat_pva

    function wb_Div_pva_pva(pva_u,pva_v)
      !
      ! 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã‚’è¨ˆç®—ã—,
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã¨ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_u(0:ic-1,jc,km)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«çµŒåº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP), intent(in)  :: pva_v(0:ic-1,jc,km)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«ç·¯åº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: wb_Div_pva_pva(nc,kc)
      !(out) 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      wb_Div_pva_pva = wb_DivLon_pva(pva_u) + wb_DivLat_pva(pva_v)

    end function wb_Div_pva_pva

    function wb_JacobianMPI_wb_wb(wb_a,wb_b)
      ! 2 ã¤ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³
      !
      !   J(f,g) = âˆ‚f/âˆ‚Î»ãƒ»âˆ‚g/âˆ‚Î¼ - âˆ‚g/âˆ‚Î»ãƒ»âˆ‚f/âˆ‚Î¼
      !          = âˆ‚f/âˆ‚Î»ãƒ»1/cosÏ†ãƒ»âˆ‚g/âˆ‚Ï†
      !             - âˆ‚g/âˆ‚Î»ãƒ»1/cosÏ†ãƒ»âˆ‚f/âˆ‚Ï†
      !
      ! ã‚’ä½œç”¨ã•ã›ã‚‹(å¤šå±¤ç”¨).
      !
      real(DP), intent(in) :: wb_a(nc,kc)
      !(in) 1ã¤ç›®ã®å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP), intent(in) :: wb_b(nc,kc)
      !(in) 2ã¤ç›®ã®å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)             :: wb_JacobianMPI_wb_wb(nc,kc)
      !(out) 2 ã¤ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³
      integer :: k

      do k=1,kc
         wb_JacobianMPI_wb_wb(:,k) = w_JacobianMPI_w_w(wb_a(:,k),wb_b(:,k))
      end do

    end function wb_JacobianMPI_wb_wb

    !--------------- å¾®åˆ†è¨ˆç®—(u ä¸€å±¤) -----------------
    function u_Lapla_u(u_data)
      !
      ! å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      !
      !    â–½^2 = 1/cos^2Ï†ãƒ»âˆ‚^2/âˆ‚Î»^2 + 1/cosÏ†ãƒ»âˆ‚/âˆ‚Ï†(cosÏ†âˆ‚/âˆ‚Ï†)
      !
      ! ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨ã¯, å¯¾å¿œã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
      ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã‚’ä½œç”¨ã•ã›ãŸãƒ‡ãƒ¼ã‚¿ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«å¤‰æ›ã®ã“ã¨ã§ã‚ã‚‹.
      !
      real(DP), intent(in)  :: u_data(:)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_lapla_u(nmc)
      !(out) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³

      u_Lapla_u = rnu(:,1)*u_data

    end function u_Lapla_u

    function u_LaplaInv_u(u_data)
      !
      ! å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³
      !
      !    â–½^{-2}
      !      =[1/cos^2Ï†ãƒ»âˆ‚^2/âˆ‚Î»^2 + 1/cosÏ†ãƒ»âˆ‚/âˆ‚Ï†(cosÏ†âˆ‚/âˆ‚Ï†)]^{-1}
      !
      ! ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã¨ã¯, å¯¾å¿œã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
      ! é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³ã‚’ä½œç”¨ã•ã›ãŸãƒ‡ãƒ¼ã‚¿ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«å¤‰æ›ã®ã“ã¨ã§ã‚ã‚‹.
      !
      real(DP), intent(in)  :: u_data(:)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_LaplaInv_u(nmc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®é€†ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³

      u_LaplaInv_u = rnu(:,2)*u_data

    end function u_LaplaInv_u

    function u_DLon_u(u_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«çµŒåº¦å¾®åˆ† âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã•ã›ã‚‹(å¤šå±¤ç”¨).
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®çµŒåº¦å¾®åˆ†ã¨ã¯, å¯¾å¿œã™ã‚‹æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«
      ! çµŒåº¦å¾®åˆ†âˆ‚/âˆ‚Î»ã‚’ä½œç”¨ã•ã›ãŸãƒ‡ãƒ¼ã‚¿ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«å¤‰æ›ã®ã“ã¨ã§ã‚ã‚‹.
      !
      real(DP), intent(in)  :: u_data(:)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_DLon_u(nmc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®çµŒåº¦å¾®åˆ†

      real(DP) :: ua_data(nmc,1)

      ua_data(:,1) = u_data
      ua_data = ua_DLon_ua(ua_data)
      u_DLon_u = ua_data(:,1)

    end function u_DLon_u

    function pv_GradLon_u(u_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’
      ! ä½œç”¨ã•ã›ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: u_data(nmc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pv_GradLon_u(0:ic-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pv_GradLon_u = pv_u(u_data,ipow=1,iflag=-1)

    end function pv_GradLon_u

    function xv_GradLon_u(u_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’
      ! ä½œç”¨ã•ã›ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: u_data(nmc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: xv_GradLon_u(0:im-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      xv_GradLon_u = xv_u(u_data,ipow=1,iflag=-1)

    end function xv_GradLon_u

    function pv_GradLat_u(u_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: u_data(nmc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pv_GradLat_u(0:ic-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pv_GradLat_u = pv_u(u_data,ipow=1,iflag=1)

    end function pv_GradLat_u

    function xv_GradLat_u(u_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: u_data(nmc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: xv_GradLat_u(0:im-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      xv_GradLat_u = xv_u(u_data,ipow=1,iflag=1)

    end function xv_GradLat_u

    function u_DivLon_pv(pv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_data(0:ic-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_DivLon_pv(nmc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_DivLon_pv = u_pv(pv_data,ipow=1,iflag=-1)

    end function u_DivLon_pv

    function u_DivLon_xv(xv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xv_data(0:im-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_DivLon_xv(nmc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_DivLon_xv = u_xv(xv_data,ipow=1,iflag=-1)

    end function u_DivLon_xv

    function u_DivLat_pv(pv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚(f cosÏ†)/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_data(0:ic-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_DivLat_pv(nmc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_DivLat_pv = u_pv(pv_data,ipow=1,iflag=1)

    end function u_DivLat_pv

    function u_DivLat_xv(xv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚(f cosÏ†)/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xv_data(0:im-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_DivLat_xv(nmc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_DivLat_xv = u_xv(xv_data,ipow=1,iflag=1)

    end function u_DivLat_xv

    function u_Div_pv_pv(pv_Uvel,pv_Vvel)
      !
      ! 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã‚’è¨ˆç®—ã—,
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã¨ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_Uvel(0:ic-1,jc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«çµŒåº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP), intent(in)  :: pv_Vvel(0:ic-1,jc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«ç·¯åº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_Div_pv_pv(nmc)
      !(out) 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_Div_pv_pv = u_DivLon_pv(pv_Uvel) + u_DivLat_pv(pv_Vvel)

    end function u_Div_pv_pv

    function u_Div_xv_xv(xv_Uvel,xv_Vvel)
      !
      ! 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã‚’è¨ˆç®—ã—,
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã¨ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xv_Uvel(0:im-1,jc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«çµŒåº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP), intent(in)  :: xv_Vvel(0:im-1,jc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«ç·¯åº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_Div_xv_xv(nmc)
      !(out) 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_Div_xv_xv = u_DivLon_xv(xv_Uvel) + u_DivLat_xv(xv_Vvel)

    end function u_Div_xv_xv

    function u_JacobianMPI_u_u(u_a,u_b)
      ! 2 ã¤ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³
      !
      !   J(f,g) = âˆ‚f/âˆ‚Î»ãƒ»âˆ‚g/âˆ‚Î¼ - âˆ‚g/âˆ‚Î»ãƒ»âˆ‚f/âˆ‚Î¼
      !          = âˆ‚f/âˆ‚Î»ãƒ»1/cosÏ†ãƒ»âˆ‚g/âˆ‚Ï†
      !             - âˆ‚g/âˆ‚Î»ãƒ»1/cosÏ†ãƒ»âˆ‚f/âˆ‚Ï†
      !
      ! ã‚’ä½œç”¨ã•ã›ã‚‹(å¤šå±¤ç”¨).
      !
      real(DP), intent(in) :: u_a(nmc)
      !(in) 1ã¤ç›®ã®å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP), intent(in) :: u_b(nmc)
      !(in) 2ã¤ç›®ã®å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)             :: u_JacobianMPI_u_u(nmc)
      !(out) 2 ã¤ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã®ãƒ¤ã‚³ãƒ“ã‚¢ãƒ³

      real(DP) :: ua_a(nmc,1)
      real(DP) :: ua_b(nmc,1)
      real(DP) :: wa_a(nc,1)
      real(DP) :: wa_b(nc,1)

      ua_a(:,1) = u_a ; ua_b(:,1) = u_b
      wa_a = wa_ua(ua_a) ; wa_b = wa_ua(ua_b)
      wa_a(:,1) = w_JacobianMPI_w_w(wa_a(:,1),wa_b(:,1))
      ua_a = ua_wa(wa_a)
      u_JacobianMPI_u_u = ua_a(:,1)

    end function u_JacobianMPI_u_u

    !--------------- å¾®åˆ†è¨ˆç®—(u ä¸€å±¤) -----------------

    function pv_GradLon_w(w_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’
      ! ä½œç”¨ã•ã›ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: w_data(nc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pv_GradLon_w(0:ic-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pv_GradLon_w = pv_w(w_data,ipow=1,iflag=-1)

    end function pv_GradLon_w

    function pv_GradLat_w(w_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: w_data(nc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pv_GradLat_w(0:ic-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pv_GradLat_w = pv_w(w_data,ipow=1,iflag=1)

    end function pv_GradLat_w

    function w_DivLon_pv(pv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_data(0:ic-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: w_DivLon_pv(nc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      w_DivLon_pv = w_pv(pv_data,ipow=1,iflag=-1)

    end function w_DivLon_pv

    function w_DivLat_pv(pv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† 1/cosÏ†ãƒ»âˆ‚(f cosÏ†)/âˆ‚Ï† ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_data(0:ic-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: w_DivLat_pv(nc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      w_DivLat_pv = w_pv(pv_data,ipow=1,iflag=1)

    end function w_DivLat_pv

    function w_Div_pv_pv(pv_u,pv_v)
      !
      ! 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã‚’è¨ˆç®—ã—,
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã¨ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_u(0:ic-1,jc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«çµŒåº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP), intent(in)  :: pv_v(0:ic-1,jc)
      !(in) ãƒ™ã‚¯ãƒˆãƒ«ç·¯åº¦æˆåˆ†ã®æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: w_Div_pv_pv(nc)
      !(out) 2 ã¤ã®å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ãƒ™ã‚¯ãƒˆãƒ«æˆåˆ†ã¨ã™ã‚‹ç™ºæ•£ã®ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      w_Div_pv_pv = w_DivLon_pv(pv_u) + w_DivLat_pv(pv_v)

    end function w_Div_pv_pv

    !--------------- å¾®åˆ†è¨ˆç®— (Î»,Î¼åº§æ¨™ç³»ç”¨, ua å¤šå±¤) -----------------
    function pva_GradLambda_ua(ua_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: ua_data(nmc,km)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pva_GradLambda_ua(0:ic-1,jc,km)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pva_GradLambda_ua = pva_ua(ua_data,ipow=0,iflag=-1)

    end function pva_GradLambda_ua

    function xvb_GradLambda_ua(ua_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: ua_data(nmc,km)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: xvb_GradLambda_ua(0:im-1,jc,kc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      xvb_GradLambda_ua = xvb_ua(ua_data,ipow=0,iflag=-1)

    end function xvb_GradLambda_ua

    function pva_GradMu_ua(ua_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† (1-Î¼^2)âˆ‚/âˆ‚Î¼  (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: ua_data(nmc,km)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pva_GradMu_ua(0:ic-1,jc,km)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pva_GradMu_ua = pva_ua(ua_data,ipow=0,iflag=1)

    end function pva_GradMu_ua

    function xvb_GradMu_ua(ua_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† (1-Î¼^2)âˆ‚/âˆ‚Î¼  (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: ua_data(nmc,km)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: xvb_GradMu_ua(0:im-1,jc,kc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      xvb_GradMu_ua = xvb_ua(ua_data,ipow=0,iflag=1)

    end function xvb_GradMu_ua

    function ua_DivLambda_pva(pva_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/(1-Î¼^2)ãƒ»âˆ‚/âˆ‚Î» (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_data(0:ic-1,jc,km)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_DivLambda_pva(nmc,km)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_DivLambda_pva = ua_pva(pva_data,ipow=2,iflag=-1)

    end function ua_DivLambda_pva

    function ua_DivLambda_xvb(xvb_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/(1-Î¼^2)ãƒ»âˆ‚/âˆ‚Î» (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xvb_data(0:im-1,jc,kc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_DivLambda_xvb(nmc,km)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_DivLambda_xvb = ua_xvb(xvb_data,ipow=2,iflag=-1)

    end function ua_DivLambda_xvb

    function ua_DivMu_pva(pva_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Î¼ (Î¼=sinÏ†)ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_data(0:ic-1,jc,km)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_DivMu_pva(nmc,km)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_DivMu_pva = ua_pva(pva_data,ipow=2,iflag=1)

    end function ua_DivMu_pva

    function ua_DivMu_xvb(xvb_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Î¼ (Î¼=sinÏ†)ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xvb_data(0:im-1,jc,kc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: ua_DivMu_xvb(nmc,km)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      ua_DivMu_xvb = ua_xvb(xvb_data,ipow=2,iflag=1)

    end function ua_DivMu_xvb

    !--------------- å¾®åˆ†è¨ˆç®— (Î»,Î¼åº§æ¨™ç³»ç”¨, wb å¤šå±¤) -----------------
    function pva_GradLambda_wb(wb_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: wb_data(nc,kc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pva_GradLambda_wb(0:ic-1,jc,km)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pva_GradLambda_wb = pva_wb(wb_data,ipow=0,iflag=-1)

    end function pva_GradLambda_wb

    function pva_GradMu_wb(wb_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† (1-Î¼^2)âˆ‚/âˆ‚Î¼  (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: wb_data(nc,kc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pva_GradMu_wb(0:ic-1,jc,km)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pva_GradMu_wb = pva_wb(wb_data,ipow=0,iflag=1)

    end function pva_GradMu_wb

    function wb_DivLambda_pva(pva_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/(1-Î¼^2)ãƒ»âˆ‚/âˆ‚Î» (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_data(0:ic-1,jc,km)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: wb_DivLambda_pva(nc,kc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      wb_DivLambda_pva = wb_pva(pva_data,ipow=2,iflag=-1)

    end function wb_DivLambda_pva

    function wb_DivMu_pva(pva_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Î¼ (Î¼=sinÏ†)ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pva_data(0:ic-1,jc,km)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: wb_DivMu_pva(nc,kc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      wb_DivMu_pva = wb_pva(pva_data,ipow=2,iflag=1)

    end function wb_DivMu_pva

    !--------------- å¾®åˆ†è¨ˆç®— (Î»,Î¼åº§æ¨™ç³»ç”¨, u ä¸€å±¤) -----------------
    function pv_GradLambda_u(u_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: u_data(nmc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pv_GradLambda_u(0:ic-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pv_GradLambda_u = pv_u(u_data,ipow=0,iflag=-1)

    end function pv_GradLambda_u

    function xv_GradLambda_u(u_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: u_data(nmc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: xv_GradLambda_u(0:im-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      xv_GradLambda_u = xv_u(u_data,ipow=0,iflag=-1)

    end function xv_GradLambda_u

    function pv_GradMu_u(u_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† (1-Î¼^2)âˆ‚/âˆ‚Î¼  (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: u_data(nmc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pv_GradMu_u(0:ic-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pv_GradMu_u = pv_u(u_data,ipow=0,iflag=1)

    end function pv_GradMu_u

    function xv_GradMu_u(u_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† (1-Î¼^2)âˆ‚/âˆ‚Î¼  (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: u_data(nmc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: xv_GradMu_u(0:im-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      xv_GradMu_u = xv_u(u_data,ipow=0,iflag=1)

    end function xv_GradMu_u

    function u_DivLambda_pv(pv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/(1-Î¼^2)ãƒ»âˆ‚/âˆ‚Î» (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_data(0:ic-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_DivLambda_pv(nmc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_DivLambda_pv = u_pv(pv_data,ipow=2,iflag=-1)

    end function u_DivLambda_pv

    function u_DivLambda_xv(xv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/(1-Î¼^2)ãƒ»âˆ‚/âˆ‚Î» (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xv_data(0:im-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_DivLambda_xv(nmc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_DivLambda_xv = u_xv(xv_data,ipow=2,iflag=-1)

    end function u_DivLambda_xv

    function u_DivMu_pv(pv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Î¼ (Î¼=sinÏ†)ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_data(0:ic-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_DivMu_pv(nmc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_DivMu_pv = u_pv(pv_data,ipow=2,iflag=1)

    end function u_DivMu_pv

    function u_DivMu_xv(xv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Î¼ (Î¼=sinÏ†)ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: xv_data(0:im-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: u_DivMu_xv(nmc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      u_DivMu_xv = u_xv(xv_data,ipow=2,iflag=1)

    end function u_DivMu_xv

    !--------------- å¾®åˆ†è¨ˆç®— (Î»,Î¼åº§æ¨™ç³»ç”¨, w ä¸€å±¤) -----------------
    function pv_GradLambda_w(w_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹çµŒåº¦å¾®åˆ† âˆ‚/âˆ‚Î» ã‚’ä½œç”¨ã™ã‚‹(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: w_data(nc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pv_GradLambda_w(0:ic-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹çµŒåº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pv_GradLambda_w = pv_w(w_data,ipow=0,iflag=-1)

    end function pv_GradLambda_w

    function pv_GradMu_w(w_data)
      !
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å‹¾é…åž‹ç·¯åº¦å¾®åˆ† (1-Î¼^2)âˆ‚/âˆ‚Î¼  (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: w_data(nc)
      !(in) å…¥åŠ›ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: pv_GradMu_w(0:ic-1,jc)
      !(out) ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã‚’å‹¾é…åž‹ç·¯åº¦å¾®åˆ†ã—ãŸæ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿

      pv_GradMu_w = pv_w(w_data,ipow=0,iflag=1)

    end function pv_GradMu_w

    function w_DivLambda_pv(pv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹çµŒåº¦å¾®åˆ† 1/(1-Î¼^2)ãƒ»âˆ‚/âˆ‚Î» (Î¼=sinÏ†)
      ! ã‚’ä½œç”¨ã•ã›ã¦ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_data(0:ic-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: w_DivLambda_pv(nc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹çµŒåº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      w_DivLambda_pv = w_pv(pv_data,ipow=2,iflag=-1)

    end function w_DivLambda_pv

    function w_DivMu_pv(pv_data)
      !
      ! æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã«ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ† âˆ‚/âˆ‚Î¼ (Î¼=sinÏ†)ã‚’ä½œç”¨ã•ã›ã¦
      ! ã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¤‰æ›ã—ã¦è¿”ã™(å¤šå±¤ç”¨).
      !
      real(DP), intent(in)  :: pv_data(0:ic-1,jc)
      !(in) å…¥åŠ›æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿
      real(DP)              :: w_DivMu_pv(nc)
      !(out) æ ¼åç‚¹ãƒ‡ãƒ¼ã‚¿ã‚’ç™ºæ•£åž‹ç·¯åº¦å¾®åˆ†ã—ãŸã‚¹ãƒšã‚¯ãƒˆãƒ«ãƒ‡ãƒ¼ã‚¿

      w_DivMu_pv = w_pv(pv_data,ipow=2,iflag=1)

    end function w_DivMu_pv

    !--------------- çµ‚äº†å‡¦ç† -----------------
    subroutine ua_deriv_mpi_Finalize
      !
      ! ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã®çµ‚äº†å‡¦ç†(å‰²ã‚Šä»˜ã‘é…åˆ—ã®è§£æ”¾)ã‚’ãŠã“ãªã†.
      !

      deallocate(rnu)                    ! ãƒ©ãƒ—ãƒ©ã‚·ã‚¢ãƒ³æ¼”ç®—ç”¨é…åˆ—

      call w_deriv_mpi_Finalize

      call MessageNotify('M','ua_deriv_mpi_finalize',&
           'ua_mpi_module_deriv is finalized (2020/01/25) ')

    end subroutine ua_deriv_mpi_Finalize

end module ua_mpi_module_deriv