surface_data_test_prepnc00.f90

Path: prepare_data/surface_data_test_prepnc00.f90
Last Update: Wed Sep 19 18:36:19 +0900 2007

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

NetCDF file generation program for "surface_data_test"

Authors:Yasuhiro MORIKAWA
Version:$Id: surface_data_test_prepnc00.f90,v 1.4 2007-09-19 09:36:19 morikawa Exp $
Tag Name:$Name: dcpam4-20080624-1 $
Copyright:Copyright (C) GFD Dennou Club, 2007. All rights reserved.
License:See COPYRIGHT

Note that Japanese and English are described in parallel.

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

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

Methods

Included Modules

constants surface_data dc_test dc_types dc_string dc_args gt4_history

Public Instance methods

Main Program :

[Source]

program surface_data_test_prepnc00
  use constants, only: CONST, Create, Get
  use surface_data, only: SRFDAT, Create, Close, PutLine, initialized, GetAxes, GetData
  use dc_test, only: AssertEqual
  use dc_types, only: DP, STRING
  use dc_string, only: StoA
  use dc_args, only: ARGS, Open, HelpMsg, Option, Debug, Help, Strict, Close
  use gt4_history, only: GT_HISTORY, HistoryCreate, HistoryAddVariable, HistoryPut, HistoryClose, HistoryAddAttr
  implicit none

  !---------------------------------------------------------
  !  実験の表題, モデルの名称, 所属機関名
  !  Title of a experiment, name of model, sub-organ
  !---------------------------------------------------------
  character(*), parameter:: title = 'surface_data_test_prepnc00 $Name: dcpam4-20080624-1 $ :: ' // 'NetCDF file generation program for "surface_data_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:: nmax = 10         ! 最大全波数. 
                              ! Maximum truncated wavenumber
  integer:: imax = 32         ! 経度格子点数. 
                              ! Number of grid points in longitude
  integer:: jmax = 16         ! 緯度格子点数. 
                              ! Number of grid points in latitude

  !---------------------------------------------------------
  !  軸データ
  !  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

  !---------------------------------------------------------
  !  地表面データ
  !  surface data
  !---------------------------------------------------------
  real(DP), allocatable:: xy_SurfTemp (:,:)
                              ! 地表面温度. 
                              ! Surface temperature

  !---------------------------------------------------------
  !  データ入出力
  !  Data I/O
  !---------------------------------------------------------
  type(GT_HISTORY):: gthist_surface
  character(STRING):: default_output_file = 'surface_data_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

  type(CONST):: const_earth
  real(DP):: PI  ! $ \pi $ .    円周率.         Circular constant
  type(SRFDAT):: srf_dat00
continue

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

  !---------------------------------------------------------
  !  初期設定
  !  Initialization
  !---------------------------------------------------------
  call Create( srf_dat = srf_dat00, nmax = nmax, imax = imax, jmax = jmax, PI = PI ) ! (in)

  !---------------------------------------------------------
  !  データ取得
  !  Get 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( xy_SurfTemp(0:imax-1, 0:jmax-1) )
  call GetAxes( srf_dat = srf_dat00, x_Lon = x_Lon, x_Lon_Weight = x_Lon_Weight, y_Lat = y_Lat, y_Lat_Weight = y_Lat_Weight )  ! (out)
  call GetData( srf_dat = srf_dat00, xy_SurfTemp = xy_SurfTemp )      ! (out)

  !----------------------------------------------------------------
  !  データ出力
  !  Output data
  !----------------------------------------------------------------
  call HistoryCreate( history = gthist_surface, file = output_file, title = title, source = source, institution = institution, dims = StoA('lon', 'lat'), dimsizes = (/imax, jmax/), longnames = StoA('longitude', 'latitude'), units = StoA('degree_east', 'degree_north') )       ! (in)

  call HistoryPut( history = gthist_surface, varname = 'lon', array = x_Lon / PI * 180.0_DP ) ! (in)
  call HistoryPut( history = gthist_surface, varname = 'lat', array = y_Lat / PI * 180.0_DP ) ! (in)

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


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

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

  call HistoryAddVariable( history = gthist_surface, varname = 'SurfTemp', dims = StoA('lon', 'lat'), longname = 'Surface Temperature', units = 'K', xtype = 'double' )              ! (in)
  call HistoryAddAttr( history = gthist_surface, varname = 'SurfTemp', attrname = 'standard_name', value = 'surface_temperature' )                     ! (in)

  call HistoryPut( history = gthist_surface, varname = 'SurfTemp', array = xy_SurfTemp ) ! (in)

  call HistoryClose( history = gthist_surface ) ! (out)

end program surface_data_test_prepnc00

[Validate]