phy_implicit_test.f90

Path: physics/phy_implicit_test.f90
Last Update: Sat Jun 14 20:44:15 +0900 2008

phy_implicit モジュールのテストプログラム

Test program for "phy_implicit"

Authors:Yukiko YAMADA, Yasuhiro MORIKAWA
Version:$Id: phy_implicit_test.f90,v 1.4 2008-06-14 11:44:15 morikawa Exp $
Tag Name:$Name: dcpam4-20080626 $
Copyright:Copyright (C) GFD Dennou Club, 2007. All rights reserved.
License:See COPYRIGHT

Note that Japanese and English are described in parallel.

phy_implicit モジュールの動作テストを行うためのプログラムです. このプログラムがコンパイルできること, および実行時に プログラムが正常終了することを確認してください.

This program checks the operation of "phy_implicit" module. Confirm compilation and execution of this program.

Methods

Included Modules

phy_implicit constants dc_test dc_types dc_string dc_args gt4_history

Public Instance methods

Main Program :

[Source]

program phy_implicit_test
  use phy_implicit, only: PHYIMPL, Create, Close, PutLine, initialized, GetMatrices, Integrate
  use constants, only: CONST, Create, Get
  use dc_test, only: AssertEqual, AssertGreaterThan, AssertLessThan
  use dc_types, only: DP, STRING
  use dc_string, only: StoA, PutLine
  use dc_args, only: ARGS, Open, HelpMsg, Option, Debug, Help, Strict, Close
  use gt4_history, only: HistoryGet
  implicit none

  !---------------------------------------------------------
  !  実験の表題, モデルの名称, 所属機関名
  !  Title of a experiment, name of model, sub-organ
  !---------------------------------------------------------
  character(*), parameter:: title = 'phy_implicit_test $Name: dcpam4-20080626 $ :: ' // 'Test program of "phy_implicit" module'
  character(*), parameter:: source = 'dcpam4 ' // '(See http://www.gfd-dennou.org/library/dcpam)'
  character(*), parameter:: institution = 'GFD Dennou Club (See http://www.gfd-dennou.org)'

  !-------------------------------------------------------------------
  !  格子点数・最大全波数
  !  Grid points and maximum truncated wavenumber
  !-------------------------------------------------------------------
  integer, parameter:: imax = 32
                              ! 経度格子点数. 
                              ! Number of grid points in longitude
  integer, parameter:: jmax = 16
                              ! 緯度格子点数. 
                              ! Number of grid points in latitude
  integer, parameter:: kmax = 12
                              ! 鉛直層数. 
                              ! Number of vertical level

  !-----------------------------------------------------------------
  !  物理定数等の設定
  !  Configure physical constants etc.
  !-----------------------------------------------------------------
  type(CONST):: const_earth
  real(DP):: Grav      ! $ g $ .      重力加速度.     Gravitational acceleration
  real(DP):: Cp        ! $ C_p $ .    大気定圧比熱.   Specific heat of air at constant pressure
  real(DP):: EL        ! $ L $ .      水の凝結の潜熱. Latent heat of condensation of water vapor
  real(DP):: DelTime    ! $ \Delta t $ . タイムステップ. Time step

  !---------------------------------------------------------
  !  物理量
  !  Physical values
  !---------------------------------------------------------
  real(DP):: xy_SurfHeatCapacity (0:imax-1, 0:jmax-1)
                              ! 地表熱容量. 
                              ! Surface heat capacity
  integer:: xy_SurfCondition (0:imax-1, 0:jmax-1)
                              ! 地表状態. 
                              ! Surface condition
  real(DP):: xy_GroundTempFlux (0:imax-1, 0:jmax-1)
                              ! 地中熱フラックス. 
                              ! Ground temperature flux

  real(DP):: xyr_Press (0:imax-1, 0:jmax-1, 0:kmax)
                              ! $ p_s $ . 地表面気圧 (半整数レベル). 
                              ! Surface pressure (half level)
  real(DP):: xyr_UFlux (0:imax-1, 0:jmax-1, 0:kmax)
                              ! 東西風速フラックス. 
                              ! Zonal wind flux
  real(DP):: xyr_VFlux (0:imax-1, 0:jmax-1, 0:kmax)
                              ! 南北風速フラックス. 
                              ! Meridional wind flux
  real(DP):: xyr_TempFlux (0:imax-1, 0:jmax-1, 0:kmax)
                              ! 温度フラックス. 
                              ! Temperature flux
  real(DP):: xyr_QvapFlux (0:imax-1, 0:jmax-1, 0:kmax)
                              ! 比湿フラックス. 
                              ! Specific humidity flux
  real(DP):: xy_SurfUVMatrix (0:imax-1, 0:jmax-1)
                              !  速度陰解行列: 地表. 
                              ! Implicit matrix about velocity: surface
  real(DP):: xyaa_SurfTempMatrix (0:imax-1, 0:jmax-1, 0:1, -1:1)

                              ! 温度陰解行列: 地表. 
                              ! Implicit matrix about temperature: surface
  real(DP):: xyaa_SurfQvapMatrix (0:imax-1, 0:jmax-1, 0:1, -1:1)
                              ! 比湿陰解行列: 地表. 
                              ! Implicit matrix about specific humidity: surface
  real(DP):: xy_SurfRadSFlux (0:imax-1, 0:jmax-1)
                              ! 日射フラックス (地表面). 
                              ! Insolation flux on surface
  real(DP):: xy_SurfRadLFlux (0:imax-1, 0:jmax-1)
                              ! 長波フラックス (地表面). 
                              ! Long wave flux on surface
  real(DP):: xyza_UVMatrix (0:imax-1, 0:jmax-1, 0:kmax-1, -1:1)
                              ! 速度陰解行列. 
                              ! Implicit matrix about velocity 
  real(DP):: xyza_TempMatrix  (0:imax-1, 0:jmax-1, -1:kmax-1, -1:1)
                              ! 温度陰解行列. 
                              ! Implicit matrix about temperature
  real(DP):: xyza_QvapMatrix (0:imax-1, 0:jmax-1, 0:kmax-1, -1:1)
                              ! 比湿陰解行列. 
                              ! Implicit matrix about specific humidity
  real(DP):: xya_SurfRadLMatrix (0:imax-1, 0:jmax-1, -1:1)
                              ! $ T $ 陰解行列: 地表. 
                              ! $ T $ implicit matrix: surface

  real(DP):: xyz_DVerdiffUDt (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! 東西成分 鉛直拡散加速度. 
                              ! Zonal acceleration by vertical diffusion
  real(DP):: xyz_DVerdiffVDt (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! 南北成分 鉛直拡散加速度. 
                              ! Meridional acceleration by vertical diffusion
  real(DP):: xyz_DVerdiffTempDt (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! 鉛直拡散加熱率. 
                              ! Temperature tendency by vertical diffusion
  real(DP):: xy_DVerdiffSurfTempDt (0:imax-1, 0:jmax-1)
                              ! 地表面 鉛直拡散加熱率. 
                              ! Surface temperature tendency by vertical diffusion
  real(DP):: xyz_DVerdiffQvapDt (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! 鉛直拡散加湿率. 
                              ! Specific humidity tendency by vertical diffusion

  !---------------------------------------------------------
  !  作業変数
  !  Work variables
  !---------------------------------------------------------
  type(ARGS):: arg            ! コマンドライン引数. 
                              ! Command line arguments
  logical:: OPT_namelist      ! -N, --namelist オプションの有無. 
                              ! Existence of '-N', '--namelist' option
  character(STRING):: VAL_namelist
                              ! -N, --namelist オプションの値. 
                              ! Value of '-N', '--namelist' option
  type(PHYIMPL):: phy_impl00, phy_impl01, phy_impl02, phy_impl03
  logical:: err
  character(*), parameter:: subname = 'phy_implicit_test'
continue

  !---------------------------------------------------------
  !  コマンドライン引数の処理
  !  Command line arguments handling
  !---------------------------------------------------------
  call Open( arg )
  call HelpMsg( arg, 'Title', title )
  call HelpMsg( arg, 'Usage', './phy_implicit_test [Options]' )
  call HelpMsg( arg, 'Source', source )
  call HelpMsg( arg, 'Institution', institution )
  call Option( arg, StoA('-N', '--namelist'), OPT_namelist, VAL_namelist, help = 'NAMELIST filename' )
  call Debug( arg ) 
   call Help( arg ) 
   call Strict( arg, severe = .true. )
  call Close( arg )

  !---------------------------------------------------------
  !  物理定数の準備
  !  Prepare physical constants
  !---------------------------------------------------------
  call Create( const_earth ) ! (inout)

  DelTime = 600.0_DP

  call Get( constant = const_earth, Grav = Grav, Cp = Cp, EL = EL )                            ! (out)

  !---------------------------------------------------------
  !  地表面データの準備
  !  Prepare surface data
  !---------------------------------------------------------
  xy_SurfHeatCapacity = 0.0_DP
  xy_SurfCondition = 0
  xy_GroundTempFlux = 0.0_DP

  !---------------------------------------------------------
  !  初期設定テスト
  !  Initialization test
  !---------------------------------------------------------
  call Create( phy_impl = phy_impl00, imax = imax, jmax = jmax, kmax = kmax, Grav = Grav, Cp = Cp, EL = EL, DelTime = DelTime, xy_SurfHeatCapacity = xy_SurfHeatCapacity, xy_SurfCondition = xy_SurfCondition, xy_GroundTempFlux = xy_GroundTempFlux )        ! (in) 
  call PutLine( phy_impl = phy_impl00 ) ! (in)

  !---------------------------------------------------------
  !  GetMatrices テスト
  !  GetMatrices test
  !---------------------------------------------------------
  call HistoryGet( file = 'phy_implicit_test00.nc', varname = 'PressM', array = xyr_Press )                   ! (out)

  call GetMatrices( phy_impl = phy_impl00, xyr_Press = xyr_Press, xyr_UFlux = xyr_UFlux, xyr_VFlux = xyr_VFlux, xyr_TempFlux = xyr_TempFlux, xyr_QVapFlux = xyr_QVapFlux, xyza_UVMatrix = xyza_UVMatrix, xyza_TempMatrix = xyza_TempMatrix, xyza_QVapMatrix = xyza_QVapMatrix )                         ! (out)

  call PutLine( xyr_UFlux, indent = ' xyr_UFlux=' )
  call PutLine( xyr_VFlux, indent = ' xyr_VFlux=' )
  call PutLine( xyr_TempFlux, indent = ' xyr_TempFlux=' )
  call PutLine( xyr_QVapFlux, indent = ' xyr_QVapFlux=' )
  call PutLine( xyza_UVMatrix, indent = ' xyza_UVMatrix=' )
  call PutLine( xyza_TempMatrix, indent = ' xyza_TempMatrix=' )
  call PutLine( xyza_QVapMatrix, indent = ' xyza_QVapMatrix=' )

  !---------------------------------------------------------
  !  Integrate テスト
  !  Integrate test
  !---------------------------------------------------------
  xy_SurfRadSFlux     = 0.0_DP
  xy_SurfRadLFlux     = 0.0_DP
  xy_SurfUVMatrix     = 0.0_DP
  xyaa_SurfTempMatrix = 0.0_DP
  xyaa_SurfQVapMatrix = 0.0_DP
  xya_SurfRadLMatrix  = 0.0_DP

  call Integrate( phy_impl = phy_impl00, xyr_UFlux = xyr_UFlux, xyr_VFlux = xyr_VFlux, xyr_TempFlux = xyr_TempFlux, xy_SurfRadSFlux = xy_SurfRadSFlux, xy_SurfRadLFlux = xy_SurfRadLFlux, xyr_QVapFlux = xyr_QVapFlux, xyza_UVMatrix = xyza_UVMatrix, xyza_TempMatrix = xyza_TempMatrix, xyza_QVapMatrix = xyza_QVapMatrix, xy_SurfUVMatrix = xy_SurfUVMatrix, xyaa_SurfTempMatrix = xyaa_SurfTempMatrix, xyaa_SurfQVapMatrix = xyaa_SurfQVapMatrix, xya_SurfRadLMatrix = xya_SurfRadLMatrix, xyz_DVerdiffUDt = xyz_DVerdiffUDt, xyz_DVerdiffVDt = xyz_DVerdiffVDt, xyz_DVerdiffTempDt = xyz_DVerdiffTempDt, xy_DVerdiffSurfTempDt = xy_DVerdiffSurfTempDt, xyz_DVerdiffQVapDt = xyz_DVerdiffQVapDt )          ! (out)

  call PutLine( xyz_DVerdiffUDt, indent = ' xyz_DVerdiffUDt=' )
  call PutLine( xyz_DVerdiffVDt, indent = ' xyz_DVerdiffVDt=' )
  call PutLine( xyz_DVerdiffTempDt, indent = ' xyz_DVerdiffTempDt=' )
  call PutLine( xy_DVerdiffSurfTempDt, indent = ' xy_DVerdiffSurfTempDt=' )
  call PutLine( xyz_DVerdiffQVapDt, indent = ' xyz_DVerdiffQVapDt=' )

  !---------------------------------------------------------
  !  終了処理テスト
  !  Termination test
  !---------------------------------------------------------
  call Close( phy_impl = phy_impl00 ) ! (inout)
  call AssertEqual( 'termination test 1', answer = .false., check = initialized(phy_impl00) )
  call PutLine( phy_impl = phy_impl00 ) ! (in)

  call Close( phy_impl = phy_impl02, err = err )                            ! (out)
  call AssertEqual( 'termination test 2', answer = .true., check = err )

end program phy_implicit_test

[Validate]