Path: | prepare_data/surface_data_test.f90 |
Last Update: | Wed Sep 19 18:36:19 JST 2007 |
Authors: | Yasuhiro MORIKAWA |
Version: | $Id: surface_data_test.f90,v 1.5 2007/09/19 09:36:19 morikawa Exp $ |
Tag Name: | $Name: dcpam4-20071012 $ |
Copyright: | Copyright (C) GFD Dennou Club, 2007. All rights reserved. |
License: | See COPYRIGHT |
Note that Japanese and English are described in parallel.
surface_data モジュールの動作テストを行うためのプログラムです. このプログラムがコンパイルできること, および実行時に プログラムが正常終了することを確認してください.
This program checks the operation of "surface_data" module. Confirm compilation and execution of this program.
Main Program : |
program surface_data_test use constants, only: CONST, Create, Get use surface_data, only: SRFDAT, Create, Close, PutLine, initialized, GetAxes, GetData 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 use gt4_history, only: HistoryGet implicit none !--------------------------------------------------------- ! 実験の表題, モデルの名称, 所属機関名 ! Title of a experiment, name of model, sub-organ !--------------------------------------------------------- character(*), parameter:: title = 'surface_data_test $Name: dcpam4-20071012 $ :: ' // 'Test program of "surface_data" 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:: 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 real(DP), allocatable:: x_LonAns (:) ! 経度. Longitude real(DP), allocatable:: x_Lon_WeightAns (:) ! 経度積分用座標重み. ! Weight for integration in longitude real(DP), allocatable:: y_LatAns (:) ! 緯度. Latitude real(DP), allocatable:: y_Lat_WeightAns (:) ! 緯度積分用座標重み. ! Weight for integration in latitude !--------------------------------------------------------- ! 地表面データ ! surface data !--------------------------------------------------------- real(DP), allocatable:: xy_SurfTemp (:,:) ! 地表面温度. ! Surface temperature real(DP), allocatable:: xy_SurfTempAns (:,:) !--------------------------------------------------------- ! 作業変数 ! 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 type(SRFDAT):: srf_dat00, srf_dat01 logical:: err continue !--------------------------------------------------------- ! コマンドライン引数の処理 ! Command line arguments handling !--------------------------------------------------------- call Open( arg ) call HelpMsg( arg, 'Title', title ) call HelpMsg( arg, 'Usage', './surface_data_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 ) !--------------------------------------------------------- ! 物理定数の設定 ! Configure a physical constant !--------------------------------------------------------- call Create( constant = const_earth ) ! (inout) call Get( constant = const_earth, PI = PI ) ! (out) !--------------------------------------------------------- ! 正答の取得 ! Get correct answer !--------------------------------------------------------- allocate( x_LonAns (0:imax-1) ) allocate( x_Lon_WeightAns (0:imax-1) ) allocate( y_LatAns (0:jmax-1) ) allocate( y_Lat_WeightAns (0:jmax-1) ) call HistoryGet( file = 'surface_data_test00.nc', varname = 'lon', array = x_LonAns ) ! (out) call HistoryGet( file = 'surface_data_test00.nc', varname = 'lon_weight', array = x_Lon_WeightAns ) ! (out) call HistoryGet( file = 'surface_data_test00.nc', varname = 'lat', array = y_LatAns ) ! (out) call HistoryGet( file = 'surface_data_test00.nc', varname = 'lat_weight', array = y_Lat_WeightAns ) ! (out) x_LonAns = x_LonAns * PI / 180.0_DP y_LatAns = y_LatAns * PI / 180.0_DP allocate( xy_SurfTempAns (0:imax-1, 0:jmax-1) ) call HistoryGet( file = 'surface_data_test00.nc', varname = 'SurfTemp', array = xy_SurfTempAns ) ! (out) !--------------------------------------------------------- ! 初期設定テスト ! Initialization test !--------------------------------------------------------- call Create( srf_dat = srf_dat00, nmax = nmax, imax = imax, jmax = jmax, PI = PI ) ! (in) call AssertEqual( 'initialization test 1', answer = .true., check = initialized(srf_dat00) ) call PutLine( srf_dat = srf_dat00 ) ! (in) !--------------------------------------------------------- ! 軸データテスト ! Axes data test !--------------------------------------------------------- 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) ) 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 AssertEqual( 'longitude test 1', answer = x_LonAns, check = x_Lon, significant_digits = 7, ignore_digits = -15 ) call AssertEqual( 'weight for integration in longitude test 1', answer = x_Lon_WeightAns, check = x_Lon_Weight, significant_digits = 15, ignore_digits = -15 ) call AssertEqual( 'latitude test 1', answer = y_LatAns, check = y_Lat, significant_digits = 7, ignore_digits = -15 ) call AssertEqual( 'weight for integration in latitude test 1', answer = y_Lat_WeightAns, check = y_Lat_Weight, significant_digits = 15, ignore_digits = -15 ) !--------------------------------------------------------- ! 地表面温度テスト ! Surface temperature test !--------------------------------------------------------- allocate( xy_SurfTemp (0:imax-1, 0:jmax-1) ) call GetData( srf_dat = srf_dat00, xy_SurfTemp = xy_SurfTemp ) ! (out) call AssertEqual( 'surface temperature test 1', answer = xy_SurfTempAns, check = xy_SurfTemp, significant_digits = 15, ignore_digits = -15 ) !--------------------------------------------------------- ! 終了処理テスト ! Termination test !--------------------------------------------------------- call Close( srf_dat = srf_dat00 ) ! (inout) call AssertEqual( 'termination test 1', answer = .false., check = initialized(srf_dat00) ) call PutLine( srf_dat = srf_dat00 ) ! (in) !--------------------------------------------------------- ! NAMELIST 読み込みテスト ! NAMELIST loading test !--------------------------------------------------------- call Create( srf_dat = srf_dat01, nmax = nmax, imax = imax, jmax = jmax, nmlfile = VAL_namelist, err = err ) ! (in) call AssertEqual( 'NAMELIST loading test 1', answer = .true., check = err ) call PutLine( srf_dat = srf_dat01 ) ! (in) end program surface_data_test