dyn_as83_test.f90

Path: dynamics/dyn_as83_test.f90
Last Update: Thu Jul 26 17:33:32 JST 2007

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

Test program for "dyn_as83"

Authors:Yasuhiro MORIKAWA
Version:$Id: dyn_as83_test.f90,v 1.7 2007/07/26 08:33:32 morikawa Exp $
Tag Name:$Name: dcpam4-20070731 $
Copyright:Copyright (C) GFD Dennou Club, 2007. All rights reserved.

License::

Note that Japanese and English are described in parallel.

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

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

Methods

Included Modules

constants dyn_as83 dyn_spectral dc_test dc_types dc_string dc_args

Public Instance methods

Main Program :

[Source]

program dyn_as83_test
  use constants, only: CONST, Create, Get
  use dyn_as83, only: DYNAS83, Create, PutLine, Close, initialized
  use dyn_spectral, only: DYNSP, Create, Close, PutLine, GetCoriolis, GetSpectralCoeff, GetDiffCoeff, GetPhis
  use dc_test, only: AssertEqual, AssertGreaterThan, AssertLessThan
  use dc_types, only: DP, STRING
  use dc_string, only: StoA
  use dc_args, only: ARGS, Open, HelpMsg, Option, Debug, Help, Strict, Close
  implicit none

  !---------------------------------------------------------
  !  実験の表題, モデルの名称, 所属機関名
  !  Title of a experiment, name of model, sub-organ
  !---------------------------------------------------------
  character(*), parameter:: title = 'dyn_as83_test $Name: dcpam4-20070731 $ :: ' // 'Test program of "dyn_as83" 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)'

  !---------------------------------------------------------
  !  作業変数
  !  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(CONST):: const_earth
  real(DP):: PI         ! $ \pi $ .    円周率.         Circular constant
  real(DP):: RPlanet    ! $ a $ .      惑星半径.       Radius of planet
  real(DP):: Omega      ! $ \Omega $ . 回転角速度.     Angular velocity
  real(DP):: Grav       ! $ g $ .      重力加速度.     Gravitational acceleration
  real(DP):: Cp         ! $ C_p $ .    大気定圧比熱.   Specific heat of air at constant pressure
  real(DP):: RAir       ! $ R $ .      大気気体定数.   Gas constant of air
  real(DP):: EpsVT      ! $ 1/\epsilon_v - 1 $ .
  integer:: VisOrder    ! 超粘性の次数.  Order of hyper-viscosity
  real(DP):: EFoldTime  ! 最大波数に対する e-folding time. E-folding time for maximum wavenumber

  type(DYNSP):: dyn_sp00
  type(DYNAS83):: dyn_as00, dyn_as01, dyn_as02, dyn_as03, dyn_as04
  type(DYNAS83):: dyn_as05, dyn_as06, dyn_as07, dyn_as08, dyn_as09
  type(DYNAS83):: dyn_as10, dyn_as11, dyn_as12, dyn_as13
  real(DP):: DelTime
  real(DP), allocatable:: xy_Cori(:,:)
  integer, allocatable:: nmo(:,:,:)
  real(DP), allocatable:: wz_rn (:,:)
  real(DP), allocatable:: wz_DiffVorDiv (:,:)
  real(DP), allocatable:: wz_DiffTherm (:,:)
!  real(DP), allocatable:: wz_DiffVorDivWork (:,:)
!  real(DP), allocatable:: wz_DiffThermWork (:,:)
!  real(DP), allocatable:: w_Phis (:)
  logical:: err
continue

  !---------------------------------------------------------
  !  コマンドライン引数の処理
  !  Command line arguments handling
  !---------------------------------------------------------
  call Open( arg )
  call HelpMsg( arg, 'Title', title )
  call HelpMsg( arg, 'Usage', './dyn_as83_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 = 1800.0_DP

  call Get( constant = const_earth, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, VisOrder = VisOrder, EFoldTime = EFoldTime ) ! (out)

  !---------------------------------------------------------
  !  スペクトルデータの準備
  !  Prepare spectral data
  !---------------------------------------------------------
  call Create( dyn_sp = dyn_sp00, nmax = 21, imax = 64, jmax = 32, kmax = 20, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, VisOrder = VisOrder, EFoldTime = EFoldTime, DelTime = DelTime )                           ! (in)
  if ( allocated(xy_Cori) ) deallocate(xy_Cori)
  allocate( xy_Cori(0:63, 0:31) )
  call GetCoriolis( dyn_sp = dyn_sp00, xy_Cori = xy_Cori ) ! (out)
  if ( allocated(nmo) ) deallocate(nmo)
  allocate( nmo(1:2, 0:21, 0:21) )
  if ( allocated(wz_rn) ) deallocate(wz_rn)
  allocate( wz_rn(22**2, 0:19) )
  call GetSpectralCoeff( dyn_sp = dyn_sp00, nmo = nmo, wz_rn = wz_rn ) ! (out)
  if ( allocated(wz_DiffVorDiv) ) deallocate(wz_DiffVorDiv)
  allocate( wz_DiffVorDiv(22**2, 0:19) )
  if ( allocated(wz_DiffTherm) ) deallocate(wz_DiffTherm)
  allocate( wz_DiffTherm(22**2, 0:19) )
  call GetDiffCoeff( dyn_sp = dyn_sp00, wz_DiffVorDiv = wz_DiffVorDiv, wz_DiffTherm = wz_DiffTherm ) ! (out)

  !---------------------------------------------------------
  !  初期設定テスト
  !  Initialization test
  !---------------------------------------------------------
  call Create( dyn_as00, nmax = 21, imax = 64, jmax = 32, kmax = 12, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:11), wz_DiffVorDiv = wz_DiffVorDiv(:,0:11), wz_DiffTherm = wz_DiffTherm(:,0:11) )         ! (in)

  call PutLine( dyn_as00 ) ! (in)
  call AssertEqual( 'initialization test 1', answer = .true., check = initialized(dyn_as00) )

  err = .false.
  call Create( dyn_as00, nmax = 21, imax = 64, jmax = 32, kmax = 12, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:11), wz_DiffVorDiv = wz_DiffVorDiv(:,0:11), wz_DiffTherm = wz_DiffTherm(:,0:11), err = err)                                    ! (out)

  call AssertEqual( 'initialization test 2', answer = .true., check = err )

  !---------------------------------------------------------
  !  不正な引数に関してのテスト
  !  Invalid argument test
  !---------------------------------------------------------
  err = .false.
  call Create( dyn_as02, nmax = 0, imax = 64, jmax = 32, kmax = 12, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:11), wz_DiffVorDiv = wz_DiffVorDiv(:,0:11), wz_DiffTherm = wz_DiffTherm(:,0:11), err = err)                                    ! (out)

  call AssertEqual( 'invalid argument test 2', answer = .true., check = err )

  err = .false.
  call Create( dyn_as03, nmax = 21, imax = 0, jmax = 32, kmax = 12, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:11), wz_DiffVorDiv = wz_DiffVorDiv(:,0:11), wz_DiffTherm = wz_DiffTherm(:,0:11), err = err)                                    ! (out)


  call AssertEqual( 'invalid argument test 3', answer = .true., check = err )

  err = .false.
  call Create( dyn_as04, nmax = 21, imax = 64, jmax = 0, kmax = 12, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:11), wz_DiffVorDiv = wz_DiffVorDiv(:,0:11), wz_DiffTherm = wz_DiffTherm(:,0:11), err = err)                                    ! (out)

  call AssertEqual( 'invalid argument test 4', answer = .true., check = err )

  err = .false.
  call Create( dyn_as05, nmax = 21, imax = 64, jmax = 32, kmax = 0, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:0), wz_DiffVorDiv = wz_DiffVorDiv(:,0:0), wz_DiffTherm = wz_DiffTherm(:,0:0), err = err)                                    ! (out)

  call AssertEqual( 'invalid argument test 5', answer = .true., check = err )


  !---------------------------------------------------------
  !  鉛直次元自動設定テスト
  !  Vertical dimension auto setting test
  !---------------------------------------------------------
  err = .false.
  call Create( dyn_as06, nmax = 21, imax = 64, jmax = 32, kmax = 10, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:9), wz_DiffVorDiv = wz_DiffVorDiv(:,0:9), wz_DiffTherm = wz_DiffTherm(:,0:9), err = err)                                    ! (out)

  call AssertEqual( 'vertical dimension auto setting test 1', answer = .true., check = err )

  err = .false.
  call Create( dyn_as07, nmax = 21, imax = 64, jmax = 32, kmax = 2, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:1), wz_DiffVorDiv = wz_DiffVorDiv(:,0:1), wz_DiffTherm = wz_DiffTherm(:,0:1) )          ! (in)

  call AssertEqual( 'vertical dimension auto setting test 2', answer = .true., check = initialized(dyn_as07) )

  err = .false.
  call Create( dyn_as08, nmax = 21, imax = 64, jmax = 32, kmax = 12, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:11), wz_DiffVorDiv = wz_DiffVorDiv(:,0:11), wz_DiffTherm = wz_DiffTherm(:,0:11) )         ! (in)

  call AssertEqual( 'vertical dimension auto setting test 3', answer = .true., check = initialized(dyn_as08) )

  err = .false.
  call Create( dyn_as09, nmax = 21, imax = 64, jmax = 32, kmax = 16, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:15), wz_DiffVorDiv = wz_DiffVorDiv(:,0:15), wz_DiffTherm = wz_DiffTherm(:,0:15) )         ! (in)

  call AssertEqual( 'vertical dimension auto setting test 4', answer = .true., check = initialized(dyn_as09) )

  err = .false.
  call Create( dyn_as10, nmax = 21, imax = 64, jmax = 32, kmax = 20, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:19), wz_DiffVorDiv = wz_DiffVorDiv(:,0:19), wz_DiffTherm = wz_DiffTherm(:,0:19) )         ! (in)

  call AssertEqual( 'vertical dimension auto setting test 5', answer = .true., check = initialized(dyn_as10) )

  err = .false.
  call Create( dyn_as11, nmax = 21, imax = 64, jmax = 32, kmax = 3, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:2), wz_DiffVorDiv = wz_DiffVorDiv(:,0:2), wz_DiffTherm = wz_DiffTherm(:,0:2), r_SigmaSet = (/1.0_DP, 0.75_DP, 0.40_DP, 0.0_DP/) )  ! (in)

  call AssertEqual( 'vertical dimension manual setting test 1', answer = .true., check = initialized(dyn_as11) )

  err = .false.
  call Create( dyn_as12, nmax = 21, imax = 64, jmax = 32, kmax = 4, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:3), wz_DiffVorDiv = wz_DiffVorDiv(:,0:3), wz_DiffTherm = wz_DiffTherm(:,0:3), r_SigmaSet = (/1.0_DP, 0.75_DP, 0.40_DP, 0.0_DP/), err = err)                                           ! (out)

  call AssertEqual( 'vertical dimension manual setting test 2', answer = .true., check = err)

  err = .false.
  call Create( dyn_as13, nmax = 21, imax = 64, jmax = 32, kmax = 8, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:3), wz_DiffVorDiv = wz_DiffVorDiv(:,0:3), wz_DiffTherm = wz_DiffTherm(:,0:3), nmlfile = VAL_namelist )                             ! (in)

  call AssertEqual( 'vertical dimension NAMELIST setting test 1', answer = .true., check = initialized(dyn_as13) )

  !---------------------------------------------------------
  !  鉛直差分係数のテスト
  !  Coefficients for vertical difference test
  !---------------------------------------------------------
  err = .false.
  call Create( dyn_as12, nmax = 21, imax = 64, jmax = 32, kmax = 2, PI = PI, RPlanet = RPlanet, Grav = Grav, Omega = Omega, Cp = Cp, RAir = RAir, EpsVT = EpsVT, EFoldTime = EFoldTime, DelTime = DelTime, xy_Cori = xy_Cori, nmo = nmo, wz_rn = wz_rn(:,0:1), wz_DiffVorDiv = wz_DiffVorDiv(:,0:1), wz_DiffTherm = wz_DiffTherm(:,0:1), r_SigmaSet = (/1.0_DP, 0.50_DP, 0.0_DP/) )    ! (in)

  call AssertGreaterThan( 'coefficient Alpha in hydrostatic equation test 1', answer = (/8.99017939586975E-02_DP, 0.2857256619550060_DP/), check = dyn_as12 % z_HydroAlpha )

  call AssertLessThan( 'coefficient Alpha in hydrostatic equation test 2', answer = (/8.990179395869798E-02_DP, 0.2857256619550080_DP/), check = dyn_as12 % z_HydroAlpha )

  call AssertGreaterThan( 'coefficient Beta in hydrostatic equation test 1', answer = (/0.105922074037610_DP, 0.999999999999999_DP/), check = dyn_as12 % z_HydroBeta )

  call AssertLessThan( 'coefficient Beta in hydrostatic equation test 2', answer = (/0.1059220740376119_DP, 1.000000000000001_DP/), check = dyn_as12 % z_HydroBeta )

  call AssertGreaterThan( 'coefficient Kappa for vertical interpolation of temperature test 1', answer = (/0.2857256619550071_DP, 0.2857256619550070_DP/) - 1.0e-15_DP, check = dyn_as12 % z_TempInpolKappa )

  call AssertLessThan( 'coefficient Kappa for vertical interpolation of temperature test 2', answer = (/0.2857256619550071_DP, 0.2857256619550070_DP/) + 1.0e-15_DP, check = dyn_as12 % z_TempInpolKappa )

  call AssertGreaterThan( 'coefficient A for vertical interpolation of temperature test 1', answer = (/0.000000000000000E+00_DP, 0.9379980581875695_DP/) - 1.0e-15_DP, check = dyn_as12 % z_TempInpolA )

  call AssertLessThan( 'coefficient A for vertical interpolation of temperature test 2', answer = (/0.000000000000000E+00_DP, 0.9379980581875695_DP/) + 1.0e-15_DP, check = dyn_as12 % z_TempInpolA )

  call AssertGreaterThan( 'coefficient B for vertical interpolation of temperature test 1', answer = (/0.2418055297298259_DP, 0.000000000000000E+00_DP/) - 1.0e-15_DP, check = dyn_as12 % z_TempInpolB )

  call AssertLessThan( 'coefficient B for vertical interpolation of temperature test 2', answer = (/0.2418055297298259_DP, 0.000000000000000E+00_DP/) + 1.0e-15_DP, check = dyn_as12 % z_TempInpolB )


  !---------------------------------------------------------
  !  セミインプリシット行列のテスト
  !  Semi-implicit matrices test
  !---------------------------------------------------------
  call AssertGreaterThan( 'Semi-implicit matrix G test 1', answer = (/86112.00000000006_DP, 86112.00000000003_DP/) - 2.0e-10_DP, check = dyn_as12 % z_siMtxG )

  call AssertLessThan( 'Semi-implicit matrix G test 2', answer = (/86112.00000000006_DP, 86112.00000000003_DP/) + 1.0e-10_DP, check = dyn_as12 % z_siMtxG )

  call AssertGreaterThan( 'Semi-implicit matrix h test 1', answer = reshape((/   0.000000000000_DP, 26.97053818760929_DP, 85.71769858650207_DP, 58.74716039889282_DP/) - 1.0e-13_DP, (/2,2/)), check = dyn_as12 % zz_siMtxH, negative_support=.false. )

  call AssertLessThan( 'Semi-implicit matrix h test 2', answer = reshape((/   0.000000000000_DP, 26.97053818760929_DP, 85.71769858650207_DP, 58.74716039889282_DP/) + 1.0e-13_DP, (/2,2/)), check = dyn_as12 % zz_siMtxH )

  call AssertGreaterThan( 'Semi-implicit matrix Wh test 1', answer = reshape((/   0.000000000000_DP, 7741.623281371381_DP, 7741.623281371375_DP, 33725.56984179635_DP/) - 1.0e-10_DP, (/2,2/)), check = dyn_as12 % zz_siMtxWH, negative_support=.false. )

  call AssertLessThan( 'Semi-implicit matrix Wh test 2', answer = reshape((/   0.000000000000_DP, 7741.623281371381_DP, 7741.623281371375_DP, 33725.56984179635_DP/) + 1.0e-10_DP, (/2,2/)), check = dyn_as12 % zz_siMtxWH )

  call AssertGreaterThan( 'Semi-implicit matrix GC^{T} test 1', answer = reshape((/43056.00000000003_DP, 43056.00000000001_DP, 43056.00000000003_DP, 43056.00000000001_DP/) - 1.0e-10_DP, (/2,2/)), check = dyn_as12 % zz_siMtxGCt )

  call AssertLessThan( 'Semi-implicit matrix GC^{T} test 2', answer = reshape((/43056.00000000003_DP, 43056.00000000001_DP, 43056.00000000003_DP, 43056.00000000001_DP/) + 1.0e-10_DP, (/2,2/)), check = dyn_as12 % zz_siMtxGCt )

end program dyn_as83_test

[Validate]