phy_neg_moist_test_prepnc00.f90

Path: physics/phy_neg_moist_test_prepnc00.f90
Last Update: Sun Sep 23 07:24:58 +0900 2007

phy_neg_moist_test 用 netCDF ファイル生成プログラム

NetCDF file generation program for "phy_neg_moist_test"

Authors:Yasuhiro MORIKAWA
Version:$Id: phy_neg_moist_test_prepnc00.f90,v 1.1 2007-09-22 22:24:58 morikawa Exp $
Tag Name:$Name: dcpam4-20080609-1 $
Copyright:Copyright (C) GFD Dennou Club, 2007. All rights reserved.
License:See COPYRIGHT

Note that Japanese and English are described in parallel.

phy_neg_moist_test で使用する netCDF ファイルを作成する開発者用 プログラムです.

This is a program for developers that generates netCDF data for "phy_neg_moist_test"

Methods

Included Modules

intavr_operate spline_data constants dc_test dc_types dc_string dc_args gt4_history

Public Instance methods

Main Program :

[Source]

program phy_neg_moist_test_prepnc00
  use intavr_operate, only: INTAVROPR, Create, Close, PutLine, initialized, AvrLonLat_xy
  use spline_data, only: SPLDAT, Create, Close, PutLine, initialized, GetSpline
  use constants, only: CONST, Create, Get
  use dc_test, only: AssertEqual
  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_neg_moist_test_prepnc00 $Name: dcpam4-20080609-1 $ :: ' // 'NetCDF file generation program for "phy_neg_moist_test"'
  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:: imax = 32         ! 経度格子点数. 
                              ! Number of grid points in longitude
  integer:: jmax = 16         ! 緯度格子点数. 
                              ! Number of grid points in latitude
  integer:: kmax = 12         ! 鉛直層数. 
                              ! Number of vertical level

  !-----------------------------------------------------------------
  !  物理定数の設定
  !  Configure physical constants
  !-----------------------------------------------------------------
  real(DP):: RAir       ! $ R $ .      大気気体定数.   Gas constant of air
  real(DP):: Grav       ! $ g $ .      重力加速度.     Gravitational acceleration

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

  !---------------------------------------------------------
  !  物理量
  !  Physical values
  !---------------------------------------------------------
  real(DP), allocatable:: xyr_Press (:,:,:)
                              ! $ P_s $ . 地表面気圧 (半整数レベル). 
                              ! Surface pressure (half level)
  real(DP), allocatable:: xyz_QVap (:,:,:)
                              ! $ q (t-\Delta t) $ .     比湿. Specific humidity

  real(DP):: QVapMax
                              ! 比湿の最大値
                              ! Maximum value of specific humidity
  real(DP), allocatable:: x_QVapCoeff (:)
                              ! 比湿の係数
                              ! Specific humidity coefficient
  real(DP), allocatable:: y_QVapCoeff (:)
                              ! 比湿の係数
                              ! Specific humidity coefficient
  real(DP), allocatable:: z_QVapCoeff (:)
                              ! 比湿の係数
                              ! Specific humidity coefficient

  real(DP):: QVapAvrLonLatSig
                              ! 比湿の全球平均. 
                              ! Global mean specific humidity

  !---------------------------------------------------------
  !  データ入出力
  !  Data I/O
  !---------------------------------------------------------
  type(GT_HISTORY):: gthist
  character(STRING):: default_output_file = 'phy_neg_moist_test00.nc'
  character(STRING):: output_file

  !---------------------------------------------------------
  !  作業変数
  !  Work variables
  !---------------------------------------------------------
  type(ARGS):: arg            ! コマンドライン引数. 
                              ! Command line arguments
  logical:: OPT_output        ! -o, --output オプションの有無. 
                              ! Existence of '-o', '--output' option
  character(STRING):: VAL_output
                              ! -o, --output オプションの値. 
                              ! Value of '-o', '--output' option

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


  type(CONST):: const_earth
  type(INTAVROPR):: intavr_opr
  type(SPLDAT):: spl_dat_qvapx, spl_dat_qvapy, spl_dat_qvapz
  real(DP):: PI  ! $ \pi $ .    円周率.         Circular constant
continue

  !---------------------------------------------------------
  !  コマンドライン引数の処理
  !  Command line arguments handling
  !---------------------------------------------------------
  call Open( arg )
  call HelpMsg( arg, 'Title', title )
  call HelpMsg( arg, 'Usage', './phy_neg_moist_test_prepnc00 [Options]' )
  call HelpMsg( arg, 'Source', source )
  call HelpMsg( arg, 'Institution', institution )
  call Option( arg, StoA('-o', '--output'), OPT_output, VAL_output, help = 'Output filename (default: ' // trim(default_output_file) // ' )' )
  call Debug( arg ) 
   call Help( arg ) 
   call Strict( arg, severe = .true. )
  call Close( arg )

  if ( VAL_output == '' ) then
    output_file = default_output_file
  else
    output_file = VAL_output
  end if

  !---------------------------------------------------------
  !  物理定数の設定
  !  Configure a physical constant
  !---------------------------------------------------------
  call Create( constant = const_earth )   ! (inout)
  call Get( constant = const_earth, PI = PI, RAir = RAir, Grav = Grav ) ! (out)

  !---------------------------------------------------------
  !  軸データの設定
  !  Configure axes data
  !---------------------------------------------------------
  allocate( x_Lon (0:imax-1) )
  allocate( x_Lon_Weight (0:imax-1) )
  allocate( y_Lat (0:jmax-1) )
  allocate( y_Lat_Weight (0:jmax-1) )
  allocate( z_Sigma (0:kmax-1) )
  allocate( r_Sigma (0:kmax) )

  x_Lon = (/  0.0,   11.25,  22.5,   33.75,  45.0,  56.25,  67.5,   78.75, 90.0,  101.25, 112.5,  123.75, 135.0, 146.25, 157.5,  168.75, 180.0,  191.25, 202.5,  213.75, 225.0, 236.25, 247.5,  258.75, 270.0,  281.25, 292.5,  303.75, 315.0, 326.25, 337.5,  348.75 /)

  x_Lon_Weight = 0.196349540849362

  y_Lat = (/ -81.65059, -70.83464, -59.95486, -49.06072, -38.16121, -27.25921, -16.35593,  -5.45204, 5.45204,  16.35593,  27.25921,  38.16121, 49.06072,  59.95486,  70.83464,  81.65059 /)

  y_Lat_Weight = (/ 0.0271524594117541, 0.0622535239386478, 0.0951585116824929, 0.124628971255534, 0.149595988816577,  0.169156519395003,  0.182603415044924,  0.189450610455069, 0.189450610455069,  0.182603415044924,  0.169156519395003,  0.149595988816577, 0.124628971255534,  0.0951585116824929, 0.0622535239386478, 0.0271524594117541 /)

  z_Sigma = (/ 0.994997,  0.9799879, 0.9499499,  0.8897859, 0.7996277, 0.689378,  0.5641075,  0.4286365, 0.2879657, 0.1572454, 0.07398598, 0.02074752 /)

  r_Sigma = (/ 1.0,  0.99, 0.97, 0.93, 0.85, 0.75, 0.63, 0.5,  0.36, 0.22, 0.1,  0.05, 0.0 /)

  !---------------------------------------------------------
  !  気圧 (半整数レベル) の設定
  !  Configure pressure on half level
  !---------------------------------------------------------
  allocate( xyr_Press(0:imax-1, 0:jmax-1, 0:kmax) )
  call HistoryGet( file = 'phy_interpolate_test01.nc', varname = 'PressM', array = xyr_Press )                   ! (out)

  !---------------------------------------------------------
  !  比湿の設定
  !  Configure specific humidity
  !---------------------------------------------------------
  QVapMax = 2.0e-5_DP
  allocate( xyz_QVap(0:imax-1, 0:jmax-1, 0:kmax-1) )
  allocate( x_QVapCoeff (0:imax-1) )
  allocate( y_QVapCoeff (0:jmax-1) )
  allocate( z_QVapCoeff (0:kmax-1) )

  call Create( spl_dat = spl_dat_qvapx, knots_num = 8, x_knots = (/  0.0_DP,   45.0_DP,  90.0_DP,  135.0_DP, 180.0_DP,  225.0_DP, 270.0_DP, 315.0_DP /), x_value = (/  0.5_DP,  0.8_DP, 1.0_DP, 0.8_DP, 0.5_DP -0.01_DP, 0.3_DP, -0.01_DP/) ) ! (in)
  call GetSpline( spl_dat = spl_dat_qvapx, a_Dim = x_Lon, a_Data = x_QVapCoeff ) ! (out)
  call PutLine(x_QVapCoeff, indent=' x_QVapCoeff=')

  call Create( spl_dat = spl_dat_qvapy, knots_num = 13, x_knots = (/ -90.0_DP, -75.0_DP, -60.0_DP, -45.0_DP, -30.0_DP, -15.0_DP, 0.0_DP,  15.0_DP,  30.0_DP,  45.0_DP,  60.0_DP,  75.0_DP, 90.0_DP /), x_value = (/  0.05_DP, 0.1_DP, 0.2_DP, 0.4_DP, 0.7_DP, 0.9_DP, 1.0_DP,  0.9_DP, 0.7_DP, 0.4_DP, 0.2_DP, 0.1_DP, 0.05_DP /) )   ! (in)
  call GetSpline( spl_dat = spl_dat_qvapy, a_Dim = y_Lat, a_Data = y_QVapCoeff ) ! (out)
  call PutLine(y_QVapCoeff, indent=' y_QVapCoeff=')

  call Create( spl_dat = spl_dat_qvapz, knots_num = 3, x_knots = (/  1.0_DP, 0.5_DP, 0.0_DP /), x_value = (/  1.0_DP, 0.5_DP, 0.0_DP /) )  ! (in)

  call GetSpline( spl_dat = spl_dat_qvapz , a_Dim = z_Sigma, a_Data = z_QVapCoeff )  ! (out)

  call PutLine(z_QVapCoeff, indent=' z_QVapCoeff=')

  do k = 0, kmax - 1
    do j = 0, jmax - 1
      do i = 0, imax - 1
        xyz_QVap(i,j,k) = QVapMax * x_QVapCoeff(i) * y_QVapCoeff(j) * z_QVapCoeff(k)
      end do
    end do
  end do
  call PutLine(xyz_QVap, indent=' xyz_QVap=')

  call Create( intavr_opr = intavr_opr, imax = imax, jmax = jmax, PI = PI )                           ! (in)
  QVapAvrLonLatSig = 0.0_DP
  do k = 0, kmax-1
    QVapAvrLonLatSig = QVapAvrLonLatSig + AvrLonLat_xy( xyz_QVap(:,:,k), intavr_opr )
  end do

  !----------------------------------------------------------------
  !  データ出力
  !  Output data
  !----------------------------------------------------------------
  call HistoryCreate( history = gthist, file = output_file, title = title, source = source, institution = institution, dims = StoA('lon', 'lat', 'sig', 'sigm'), dimsizes = (/imax, jmax, kmax, kmax + 1/), longnames = StoA('longitude', 'latitude', 'sigma at layer midpoints', 'sigma at layer end-points (half level)'), units = StoA('degree_east', 'degree_north', '1', '1') )                           ! (out)

  call HistoryPut( history = gthist, varname = 'lon', array = x_Lon )  ! (in)
  call HistoryPut( history = gthist, varname = 'lat', array = y_Lat  ) ! (in)
  call HistoryPut( history = gthist, varname = 'sig', array = z_Sigma ) ! (in)
  call HistoryPut( history = gthist, varname = 'sigm', array = r_Sigma ) ! (in)

  call HistoryAddAttr( history = gthist, varname = 'lon', attrname = 'standard_name', value = 'longitude' )                          ! (in)
  call HistoryAddAttr( history = gthist, varname = 'lat', attrname = 'standard_name', value = 'latitude' )                           ! (in)

  call HistoryAddAttr( history = gthist, varname = 'sig', attrname = 'standard_name', value = 'atmosphere_sigma_coordinate' )          ! (in)
  call HistoryAddAttr( history = gthist, varname = 'sigm', attrname = 'standard_name', value = 'atmosphere_sigma_coordinate' )          ! (in)
  call HistoryAddAttr( history = gthist, varname = 'sig', attrname = 'positive', value = 'down' )                            ! (in)
  call HistoryAddAttr( history = gthist, varname = 'sigm', attrname = 'positive', value = 'down' )                            ! (in)

  call HistoryAddVariable( history = gthist, varname = 'lon_weight', dims = StoA('lon'), longname = 'weight for integration in longitude', units = 'radian', xtype = 'double' )                ! (in)
  call HistoryAddAttr( history = gthist, varname = 'lon', attrname = 'gt_calc_weight', value = 'lon_weight' )                          ! (in)
  call HistoryPut( history = gthist, varname = 'lon_weight', array = x_Lon_Weight ) ! (in)

  call HistoryAddVariable( history = gthist, varname = 'lat_weight', dims = StoA('lat'), longname = 'weight for integration in latitude', units = 'radian', xtype = 'double' )               ! (in)
  call HistoryAddAttr( history = gthist, varname = 'lat', attrname = 'gt_calc_weight', value = 'lat_weight' )                          ! (in)
  call HistoryPut( history = gthist, varname = 'lat_weight', array = y_Lat_Weight ) ! (in)

  call HistoryAddVariable( history = gthist, varname = 'PressM', dims = StoA('lon', 'lat', 'sigm'), longname = 'air pressure', units = 'Pa', xtype = 'double' )      ! (in)
  call HistoryAddAttr( history = gthist, varname = 'PressM', attrname = 'standard_name', value = 'air_pressure' )                          ! (in)
  call HistoryPut( history = gthist, varname = 'PressM', array = xyr_Press ) ! (in)

  call HistoryAddVariable( history = gthist, varname = 'QVap', dims = StoA('lon', 'lat', 'sig'), longname = 'specific humidity', units = '1', xtype = 'double' )               ! (in)
  call HistoryAddAttr( history = gthist, varname = 'QVap', attrname = 'standard_name', value = 'specific_humidity' )                   ! (in)
  call HistoryPut( history = gthist, varname = 'QVap', array = xyz_QVap )    ! (in)

  call HistoryAddVariable( history = gthist, varname = 'QVapAvrLonLatSig', dims = StoA(''), longname = 'global mean specific humidity', units = '1', xtype = 'double' )               ! (in)
  call HistoryPut( history = gthist, varname = 'QVapAvrLonLatSig', array = (/ QVapAvrLonLatSig /) )        ! (in)

  call HistoryClose( history = gthist ) ! (inout)

end program phy_neg_moist_test_prepnc00

[Validate]