Changeset 369 for XIOS/trunk/src/test


Ignore:
Timestamp:
10/16/12 13:04:44 (12 years ago)
Author:
ymipsl
Message:

Major Update

  • redesign Type and attribute manipulation
  • add enumerate type and attribute
  • use blitz class array instead of boost class array

YM

Location:
XIOS/trunk/src/test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/test/test.cpp

    r343 r369  
    88#include "date.hpp" 
    99#include "calendar_util.hpp" 
     10//#include "test_enum.hpp" 
     11#include "type.hpp" 
     12//#include "axis.hpp" 
     13//#include "field.hpp" 
     14#include "declare_attribute.hpp" 
     15#include "attribute_map.hpp" 
     16#include "array_new.hpp" 
     17#include "attribute_array.hpp" 
     18#include "attribute_array_impl.hpp" 
     19 
     20 
    1021 
    1122using namespace std ; 
     
    1324using namespace boost::gregorian ; 
    1425using namespace xios; 
     26using namespace blitz; 
     27 
     28  class CEnum_color 
     29  { 
     30    public: 
     31    enum t_enum { rouge=0, vert, bleu} ; 
     32    static const char** getStr(void) { static const char * enumStr[] = { "rouge", "vert", "bleu" } ; return enumStr ; }    
     33    int getSize(void) { return 3 ; }    
     34  } ; 
     35 
     36#include "enum.hpp" 
     37#include "enum_impl.hpp" 
     38#include "enum_ref_impl.hpp" 
     39#include "attribute_enum.hpp" 
     40#include "attribute_enum_impl.hpp" 
     41 
     42template class CEnum<CEnum_color> ; 
     43template class CAttributeEnum<CEnum_color> ; 
     44 
    1545 
    1646int main(void) 
     
    1848//      ptime t(time_from_string("2012-02-30 15:24")) ; 
    1949//      std::cout << to_simple_string(t) << std::endl; 
    20       CGregorianCalendar MyCalendar("2011-03-01 00:00") ; 
    21       cout<<MyCalendar.getInitDate()<<endl; 
    22       cout<<MyCalendar.getCurrentDate()<<endl ; 
    23       cout<<MyCalendar.getCurrentDate()-1*Day<<endl ; 
     50  CGregorianCalendar MyCalendar("2011-03-01 00:00") ; 
     51  cout<<MyCalendar.getInitDate()<<endl; 
     52  cout<<MyCalendar.getCurrentDate()<<endl ; 
     53  cout<<MyCalendar.getCurrentDate()-1*Day<<endl ; 
     54       
     55  //CEnum<CEnum_color> MyEnum ; 
     56  //MyEnum.val=CEnum<CEnum_color>::rouge ; 
     57   
     58  CEnum_color::t_enum y; 
     59   
     60  CType<int> a(10) ; 
     61  CType<int> b ; 
     62   
     63  a=5 ; 
     64  b=10.5 ; 
     65  a=a+b ; 
     66  cout<<a<<endl ; 
     67  if (a==5) cout<<"a que coucou"<<endl ; 
     68  else if (a!=5) cout<<"a que pas coucou"<<endl ; 
     69   
     70  CType_ref<int> c(a); 
     71  cout<<c<<endl ; 
     72  a=3 ; 
     73  cout<<c<<endl ; 
     74//  c=b ; 
     75  cout<<c<<endl ; 
     76  b=4 ; 
     77  cout<<c<<endl ; 
     78  c.set_ref(b) ; 
     79  cout<<c<<endl ; 
     80  int x=c+c+a ; 
     81  cout<<x<<endl ; 
     82  
     83//  test::CAttributeTemplate<int> xx("toto") ; 
     84//  test::totoatt toto ; 
     85//  test::titiatt titi ; 
     86//  CAxis A ; 
     87//  CTest A ; 
     88//  CAxis B ; 
     89//    CField A ; 
     90//    cout<<xx.size()<<endl ; 
     91 
     92  CEnum<CEnum_color> color,color1 ; 
     93  color=CEnum<CEnum_color>::rouge ; 
     94  color1=color ; 
     95   
     96  if (color1==CEnum<CEnum_color>::rouge) cout<<"Rouge !!"<<endl ; 
     97  if (color1==color) cout<<"Rouge !!"<<endl ; 
     98  color=CEnum<CEnum_color>::bleu ; 
     99  
     100  if (color1==color) cout<<"Rouge !!"<<endl ; 
     101   
     102  cout<<color1.toString()<<endl ; 
     103  color1.fromString("vert ") ; 
     104  cout<<color1.toString()<<endl ; 
     105  
     106//  color1.fromString("jaune") ; 
     107  cout<<color1.toString()<<endl ; 
     108  cout<<sizeof(CEnum_color::t_enum)<<endl ;  
     109   
     110  CEnum_color::t_enum tt ; 
     111  tt=(CEnum_color::t_enum)1 ; 
     112  int ii=tt ; 
     113  cout<<ii<<endl ; 
     114   
     115  CAttributeEnum<CEnum_color> toto("toto",CEnum_color::rouge) ; 
     116  CAttributeEnum<CEnum_color> titi("titi",CEnum_color::vert) ; 
     117  cout<<toto.toString()<<endl ; 
     118  toto.fromString(" vert  ") ; 
     119  cout<<toto.toString()<<endl ; 
     120 
     121  tt=toto ; 
     122  cout<<tt<<endl ; 
     123  cout<<titi.toString()<<endl ; 
     124   
     125  if (titi==toto) cout<<"titi==toto"<<endl ; 
     126  else cout<<"titi!=toto"<<endl ; 
     127  titi=CEnum_color::rouge ; 
     128  if (titi==toto) cout<<"titi==toto"<<endl ; 
     129  else cout<<"titi!=toto"<<endl ; 
     130 
     131  CArray<int,2> A(2,2) ; 
     132  CArray<int,2> B(2,2) ; 
     133  A=1,2,3,4 ; 
     134  B = 1 ; 
     135  B+=A ; 
     136  cout<<B.toString()<<endl ; 
     137  cout<<A.toString()<<endl ; 
     138  string str="(0,1) x (0,1) [4 3 2 1]" ; 
     139  CArray<int,2> C ; 
     140  CBufferOut out(B.size()) ; 
     141   
     142  B.toBuffer(out) ; 
     143   
     144  CBufferIn in(out.begin,B.size()) ; 
     145  C.fromBuffer(in) ; 
     146   
     147  cout<<C<<endl ;  
     148   
     149  CAttributeArray<int,2> attr("toto") ; 
     150  attr.resize(2,2) ; 
     151  attr=C ; 
     152  cout<<"attr "<<attr<<endl ; 
     153  cout<<attr.toString()<<endl ; 
    24154  return 1 ;   
    25155} 
  • XIOS/trunk/src/test/test_cs.f90

    r351 r369  
    1010  CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr) 
    1111   
    12   IF (rank<8) THEN 
    13    CALL client("client",rank,8) 
     12  IF (rank<7) THEN 
     13   CALL client("client",rank,7) 
    1414  ELSE  
    1515    CALL server 
     
    9090  CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 
    9191  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 
    92   !CALL xios_set_domain_attr("domain_A",zoom_ni=3,zoom_ibegin=3,zoom_nj=3,zoom_jbegin=6) 
     92!  CALL xios_set_domain_attr("domain_A",zoom_ni=10,zoom_ibegin=5,zoom_nj=20,zoom_jbegin=10) 
    9393  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) 
    9494  CALL xios_set_domain_attr("domain_A",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/))) 
  • XIOS/trunk/src/test/test_xios.cpp

    r352 r369  
    1111#include "context_server.hpp" 
    1212#include "object_template.hpp" 
     13#include "array_new.hpp" 
    1314#include <mpi.h> 
    1415 
     
    2728   CBufferIn  bufferIn(&buff,sizeof(buff)) ; 
    2829   CMessage msg ; 
    29 /* 
    30    msg<<(int)3<<(int)2<<(int)1<<str ; 
    31 //   msg<<a<<b<<c ; 
    32    std::cout<<"message size : "<<msg.size()<<std::endl ; 
    33    str="turlututu" ; 
    34    bufferOut<<msg ; 
    35    msg.clear() ; 
    36    msg<<a<<b<<c<<str ; 
    37 //   bufferIn>>c>>b>>a>>str ; 
    38    bufferIn>>msg ; 
    39    std::cout<<a<<"  "<<b<<"  "<<c<<"  "<<str<<endl ; 
    40 */ 
    41 //   CAttributeTemplate<ARRAY(double,1)> tabIn ; 
    42  //  CAttributeTemplate<ARRAY(double,1)> tabOut ; 
    43    CAttributeTemplate<ARRAY(double,1)> tabIn("in") ; 
    44    CAttributeTemplate<ARRAY(double,1)> tabOut("out") ; 
    4530 
    46    ARRAY_CREATE(tab,double,1,[5]) ;  
    47  //   tab->resize(extents[5]) ; 
    48     (*tab)[0]=0 ; (*tab)[1]=1 ;(*tab)[2]=2 ; (*tab)[3]=3 ;(*tab)[4]=4 ; 
     31   CAttributeArray<double,1> tabIn("in") ; 
     32   CAttributeArray<double,1> tabOut("out") ; 
     33 
     34   CArray<double,1> tab(5) 
     35    tab=0,1,2,3,4 ; 
    4936    tabIn=tab ; 
    50     (*tab)[0]=4 ; (*tab)[1]=3 ;(*tab)[2]=2 ; (*tab)[3]=1 ;(*tab)[4]=0 ; 
     37    tab= 4,3,2,1,0 
    5138    tabOut=tab ; 
    5239//   tabOut=1 ; 
Note: See TracChangeset for help on using the changeset viewer.