phy_cumulus_adjust_test.f90

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

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

Test program for "phy_cumulus_adjust"

Authors:Yukiko YAMADA, Yasuhiro MORIKAWA
Version:$Id: phy_cumulus_adjust_test.f90,v 1.7 2008-06-14 11:44:16 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_cumulus_adjust モジュールの動作テストを行うためのプログラムです. このプログラムがコンパイルできること, および実行時に プログラムが正常終了することを確認してください.

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

Methods

Included Modules

phy_cumulus_adjust constants dc_test dc_types dc_string dc_args gt4_history

Public Instance methods

Main Program :

[Source]

program phy_cumulus_adjust_test
  use phy_cumulus_adjust, only: PHYCUMAD, Create, Close, PutLine, initialized, Cumulus
  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: GT_HISTORY, HistoryCreate, HistoryAddVariable, HistoryPut, HistoryClose, HistoryAddAttr, HistoryGet
  implicit none

  !---------------------------------------------------------
  !  実験の表題, モデルの名称, 所属機関名
  !  Title of a experiment, name of model, sub-organ
  !---------------------------------------------------------
  character(*), parameter:: title = 'phy_cumulus_adjust_test $Name: dcpam4-20080626 $ :: ' // 'Test program of "phy_cumulus_adjust" 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 = 8
                              ! 鉛直層数. 
                              ! 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):: RAir      ! $ R $ .      大気気体定数.   Gas constant of air
  real(DP):: EL        ! $ L $ .      水の凝結の潜熱. Latent heat of condensation of water vapor
  real(DP):: RVap      ! $ R_v $ .    水蒸気気体定数. Gas constant of water vapor
  real(DP):: EpsV      ! $ \epsilon_v $ .        水蒸気分子量比. Molecular weight ratio of water vapor
  real(DP):: ES0       ! $ e^{*} $ (273K) .      0 ℃での飽和蒸気圧. Saturated vapor pressure at 0 degrees C
  real(DP):: DelTime    ! $ \Delta t $ . タイムステップ. Time step

  !-------------------------------------------------------------------
  !  軸データ
  !  Axes data
  !-------------------------------------------------------------------
  real(DP):: x_Lon (0:imax-1)
                              ! 経度. Longitude
  real(DP):: y_Lat (0:jmax-1)
                              ! 緯度. Latitude
  real(DP):: z_Sigma (0:kmax-1)
                              ! $ \sigma $ レベル (整数). 
                              ! Full $ \sigma $ level
  real(DP):: r_Sigma (0:kmax)
                              ! $ \sigma $ レベル (半整数). 
                              ! Half $ \sigma $ level
  real(DP):: x_Lon_Weight (0:imax-1)
                              ! 経度積分用座標重み. 
                              ! Weight for integration in longitude
  real(DP):: y_Lat_Weight (0:jmax-1)
                              ! 緯度積分用座標重み. 
                              ! Weight for integration in latitude
  real(DP):: z_DelSigma (0:kmax-1)
                              ! $ \Delta \sigma $ (整数). 
                              ! $ \Delta \sigma $ (Full)

  !---------------------------------------------------------
  !  物理量
  !  Physical values
  !---------------------------------------------------------
  real(DP), parameter:: PI = 3.1415926535897930_DP
                                ! $ \pi $ . 円周率. Circular constant

  real(DP):: xy_Ps (0:imax-1, 0:jmax-1)
                              ! $ p_s $ .   地表面気圧. Surface pressure
  real(DP):: xyz_Temp (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! $ T $ .     温度. Temperature
  real(DP):: xyz_QVap (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! $ q $ .     比湿. Specific humidity
  real(DP):: xyz_Press (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! $ p_s $ . 地表面気圧 (整数レベル). 
                              ! Surface pressure (full level)
  real(DP):: xyr_Press (0:imax-1, 0:jmax-1, 0:kmax)
                              ! $ p_s $ . 地表面気圧 (半整数レベル). 
                              ! Surface pressure (half level)
  real(DP):: xy_CumulusRain (0:imax-1, 0:jmax-1)
                              ! 積雲スキームによる降水量. 
                              ! Precipitation by cumulus scheme
  real(DP):: xyz_DCumulusTempDt (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! 積雲スキームによる温度変化率. 
                              ! Temperature tendency by cumulus scheme
  real(DP):: xyz_DCumulusQVapDt (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! 積雲スキームによる比湿変化率. 
                              ! Specific humidity tendency by cumulus scheme

  real(DP):: xyz_TempAns (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! $ T $ .     温度. Temperature
  real(DP):: xyz_QVapAns (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! $ q $ .     比湿. Specific humidity
  real(DP):: xy_CumulusRainAns (0:imax-1, 0:jmax-1)
                              ! 積雲スキームによる降水量. 
                              ! Precipitation by cumulus scheme
  real(DP):: xyz_DCumulusTempDtAns (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! 積雲スキームによる温度変化率. 
                              ! Temperature tendency by cumulus scheme
  real(DP):: xyz_DCumulusQVapDtAns (0:imax-1, 0:jmax-1, 0:kmax-1)
                              ! 積雲スキームによる比湿変化率. 
                              ! Specific humidity tendency by cumulus scheme

  !-------------------------------------------------------------------
  !  データ入出力
  !  Data I/O
  !-------------------------------------------------------------------
  type(GT_HISTORY):: gthist


  !---------------------------------------------------------
  !  作業変数
  !  Work variables
  !---------------------------------------------------------
  integer:: i, j, k           ! DO ループ用作業変数
                              ! Work variables for DO loop

  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(PHYCUMAD):: phy_cumad00, phy_cumad01, phy_cumad02, phy_cumad03
  logical:: err
  character(*), parameter:: subname = 'phy_cumulus_adjust_test'
continue

  !---------------------------------------------------------
  !  コマンドライン引数の処理
  !  Command line arguments handling
  !---------------------------------------------------------
  call Open( arg )
  call HelpMsg( arg, 'Title', title )
  call HelpMsg( arg, 'Usage', './phy_cumulus_adjust_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, RAir = RAir, EL = EL, RVap = RVap, EpsV = EpsV, ES0 = ES0 )             ! (out)

  !-------------------------------------------------------------------
  !  軸データの設定
  !  Configure axes data
  !-------------------------------------------------------------------
  call HistoryGet ( file = 'phy_cumulus_adjust_test00.nc', varname = 'lon', array = x_Lon, quiet = .true. )                 ! (out)
  x_Lon = x_Lon * PI / 180.0_DP

  call HistoryGet ( file = 'phy_cumulus_adjust_test00.nc', varname = 'lon_weight', array = x_Lon_Weight, quiet = .true. )                 ! (out)

  call HistoryGet ( file = 'phy_cumulus_adjust_test00.nc', varname = 'lat', array = y_Lat, quiet = .true. )                 ! (out)
  y_Lat = y_Lat * PI / 180.0_DP

  call HistoryGet ( file = 'phy_cumulus_adjust_test00.nc', varname = 'lat_weight', array = y_Lat_Weight, quiet = .true. )                 ! (out)

  call HistoryGet ( file = 'phy_cumulus_adjust_test00.nc', varname = 'sig', array = z_Sigma, quiet = .true. )                 ! (out)

  call HistoryGet ( file = 'phy_cumulus_adjust_test00.nc', varname = 'sigm', array = r_Sigma, quiet = .true. )                 ! (out)

  do k = 0, kmax - 1
    z_DelSigma(k) = r_Sigma(k) - r_Sigma(k+1)
  enddo

  !---------------------------------------------------------
  !  初期設定テスト
  !  Initialization test
  !---------------------------------------------------------
  call Create( phy_cumad = phy_cumad00, imax = imax, jmax = jmax, kmax = kmax, Grav = Grav, Cp = Cp, RAir = RAir, EL = EL, RVap = RVap, EpsV = EpsV, ES0 = ES0, DelTime = DelTime )
  call AssertEqual( 'initialization test 1', answer = .true., check = initialized(phy_cumad00) )
  call PutLine( phy_cumad = phy_cumad00 ) ! (in)

  !---------------------------------------------------------
  !  データ入力
  !  Input data
  !---------------------------------------------------------
  call HistoryGet ( file = 'phy_cumulus_adjust_test00.nc', varname = 'Temp', array = xyz_Temp, quiet = .true. )                ! (out)
  call HistoryGet ( file = 'phy_cumulus_adjust_test00.nc', varname = 'Ps', array = xy_Ps, quiet = .true. )                ! (out)
!!$  call HistoryGet ( &
!!$    & file = 'phy_cumulus_adjust_test00.nc', varname = 'QVap', & ! (in)
!!$    & array = xyz_QVap, quiet = .true. )                ! (out)

  do k = 0, kmax - 1
    xyz_Press(:,:,k) = xy_Ps * z_Sigma(k)
  end do

  do k = 0, kmax
    xyr_Press(:,:,k) = xy_Ps * r_Sigma(k)
  end do

  xyz_QVap = 1.0e-2

  call HistoryGet ( file = 'phy_cumulus_adjust_test01.nc', varname = 'Temp', array = xyz_TempAns, quiet = .true. )                ! (out)
  call HistoryGet ( file = 'phy_cumulus_adjust_test01.nc', varname = 'QVap', array = xyz_QVapAns, quiet = .true. )                ! (out)
  call HistoryGet ( file = 'phy_cumulus_adjust_test01.nc', varname = 'DCumulusTempDt', array = xyz_DCumulusTempDtAns, quiet = .true. )                ! (out)
  call HistoryGet ( file = 'phy_cumulus_adjust_test01.nc', varname = 'DCumulusQVapDt', array = xyz_DCumulusQVapDtAns, quiet = .true. )                ! (out)
  call HistoryGet ( file = 'phy_cumulus_adjust_test01.nc', varname = 'CumulusRain', array = xy_CumulusRainAns, quiet = .true. )                ! (out)


  !---------------------------------------------------------
  !  Cumulus テスト
  !  Cumulus test
  !---------------------------------------------------------
!!$  xyz_Temp = 273.0_DP
!!$  xyz_QVap = 1.0e-5_DP
!!$  xyz_Press = 1.0e+6_DP
!!$  xyr_Press = 1.0e+6_DP

  call Cumulus( phy_cumad = phy_cumad00, xyz_Temp = xyz_Temp, xyz_QVap = xyz_QVap, xyz_Press = xyz_Press, xyr_Press = xyr_Press, xy_Rain = xy_CumulusRain, xyz_DTempDt = xyz_DCumulusTempDt, xyz_DQVapDt = xyz_DCumulusQVapDt )              ! (out)

!!$  call PutLine ( xyz_Temp, indent = ' xyz_Temp=')
!!$  call PutLine ( xyz_QVap, indent = ' xyz_QVap=')
!!$  call PutLine ( xy_CumulusRain, indent = ' xy_CumulusRain=')
!!$  call PutLine ( xyz_DCumulusTempDt, indent = ' xyz_DCumulusTempDt=')
!!$  call PutLine ( xyz_DCumulusQvapDt, indent = ' xyz_DCumulusQvapDt=')

  call AssertEqual( 'Cumulus test (Temp)', answer = xyz_TempAns, check = xyz_Temp, significant_digits = 15, ignore_digits = -15 )
  call AssertEqual( 'Cumulus test (QVap)', answer = xyz_QVapAns, check = xyz_QVap, significant_digits = 15, ignore_digits = -15 )
  call AssertEqual( 'Cumulus test (DCumulusTempDt)', answer = xyz_DCumulusTempDtAns, check = xyz_DCumulusTempDt, significant_digits = 15, ignore_digits = -15 )
  call AssertEqual( 'Cumulus test (DCumulusQVapDt)', answer = xyz_DCumulusQVapDtAns, check = xyz_DCumulusQVapDt, significant_digits = 15, ignore_digits = -15 )
  call AssertEqual( 'Cumulus test (CumulusRain)', answer = xy_CumulusRainAns, check = xy_CumulusRain, significant_digits = 14, ignore_digits = -15 )

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

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


!!$  !----------------------------------------------------------------
!!$  !  データ出力
!!$  !  Output data
!!$  !----------------------------------------------------------------
!!$  call HistoryCreate( &
!!$    & history = gthist, &                                ! (out)
!!$    & file = 'phy_cumulus_adjust_test01.nc', &        ! (in)
!!$    & title = title, &                                   ! (in)
!!$    & source = source, institution = institution, &      ! (in)
!!$    & dims = StoA('lon', 'lat', 'sig', 'sigm'), &        ! (in)
!!$    & dimsizes = (/imax, jmax, kmax, kmax + 1/), &       ! (in)
!!$    & longnames = &
!!$    &  StoA('longitude', 'latitude', &
!!$    &       'sigma at layer midpoints', &
!!$    &       'sigma at layer end-points (half level)'), & ! (in)
!!$    & units = StoA('degree_east', 'degree_north', &
!!$    &              '1', '1') )                           ! (out)
!!$
!!$  call HistoryPut( &
!!$    & history = gthist, &               ! (out)
!!$    & varname = 'lon', array = x_Lon * 180.0_DP / PI )  ! (in)
!!$
!!$  call HistoryPut( &
!!$    & history = gthist, &               ! (out)
!!$    & varname = 'lat', array = y_Lat * 180.0_DP / PI  ) ! (in)
!!$  call HistoryPut( &
!!$    & history = gthist, &                ! (out)
!!$    & varname = 'sig', array = z_Sigma ) ! (in)
!!$  call HistoryPut( &
!!$    & history = gthist, &                 ! (out)
!!$    & varname = 'sigm', array = r_Sigma ) ! (in)
!!$
!!$  call HistoryAddAttr( &
!!$    & history = gthist, &                    ! (inout)
!!$    & varname = 'lon', attrname = 'standard_name', & ! (in)
!!$    & value = 'longitude' )                          ! (in)
!!$  call HistoryAddAttr( &
!!$    & history = gthist, &                    ! (inout)
!!$    & varname = 'lat', attrname = 'standard_name', & ! (in)
!!$    & value = 'latitude' )                           ! (in)
!!$
!!$  call HistoryAddAttr( &
!!$    & history = gthist, &                              ! (inout)
!!$    & varname = 'sig', attrname = 'standard_name', &   ! (in)
!!$    & value = 'atmosphere_sigma_coordinate' )          ! (in)
!!$  call HistoryAddAttr( &
!!$    & history = gthist, &                              ! (inout)
!!$    & varname = 'sigm', attrname = 'standard_name', &  ! (in)
!!$    & value = 'atmosphere_sigma_coordinate' )          ! (in)
!!$  call HistoryAddAttr( &
!!$    & history = gthist, &                         ! (inout)
!!$    & varname = 'sig', attrname = 'positive', &   ! (in)
!!$    & value = 'down' )                            ! (in)
!!$  call HistoryAddAttr( &
!!$    & history = gthist, &                         ! (inout)
!!$    & varname = 'sigm', attrname = 'positive', &  ! (in)
!!$    & value = 'down' )                            ! (in)
!!$
!!$
!!$  call HistoryAddVariable( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'Temp', &                  ! (in)
!!$    & dims = StoA('lon', 'lat', 'sig'), &  ! (in)
!!$    & longname = 'temperature', &          ! (in)
!!$    & units = 'K', xtype = 'double' )      ! (in)
!!$  call HistoryPut( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'Temp', array = xyz_Temp ) ! (in)
!!$
!!$  call HistoryAddVariable( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'QVap', &                  ! (in)
!!$    & dims = StoA('lon', 'lat', 'sig'), &  ! (in)
!!$    & longname = 'specific humidity', &          ! (in)
!!$    & units = 'kg kg-1', xtype = 'double' )      ! (in)
!!$  call HistoryPut( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'QVap', array = xyz_QVap ) ! (in)
!!$
!!$  call HistoryAddVariable( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'DCumulusTempDt', &            ! (in)
!!$    & dims = StoA('lon', 'lat', 'sig'), &  ! (in)
!!$    & longname = 'cumulus condensation heating', &          ! (in)
!!$    & units = 'K s-1', xtype = 'double' )      ! (in)
!!$  call HistoryPut( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'DCumulusTempDt', array = xyz_DCumulusTempDt ) ! (in)
!!$
!!$  call HistoryAddVariable( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'DCumulusQVapDt', &            ! (in)
!!$    & dims = StoA('lon', 'lat', 'sig'), &  ! (in)
!!$    & longname = 'cumulus condensation moistening', &  ! (in)
!!$    & units = 'kg kg-1 s-1', xtype = 'double' )      ! (in)
!!$  call HistoryPut( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'DCumulusQVapDt', array = xyz_DCumulusQVapDt ) ! (in)
!!$
!!$  call HistoryAddVariable( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'CumulusRain', &            ! (in)
!!$    & dims = StoA('lon', 'lat'), &  ! (in)
!!$    & longname = 'precipitation by cumulus scheme', &  ! (in)
!!$    & units = 'W m-2', xtype = 'double' )      ! (in)
!!$  call HistoryPut( &
!!$    & history = gthist, &                  ! (inout)
!!$    & varname = 'CumulusRain', array = xy_CumulusRain ) ! (in)
!!$
!!$  call HistoryClose( history = gthist ) ! (inout)

end program phy_cumulus_adjust_test

[Validate]