Changeset 351 for XIOS


Ignore:
Timestamp:
06/27/12 18:25:24 (12 years ago)
Author:
ymipsl
Message:

Add zoom functionnality on vertical axis

YM

Location:
XIOS/trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/config/axis_attribute.conf

    r313 r351  
    66 
    77DECLARE_ATTRIBUTE(int,       size) 
     8DECLARE_ATTRIBUTE(int,       zoom_begin) 
     9DECLARE_ATTRIBUTE(int,       zoom_end) 
     10DECLARE_ATTRIBUTE(int,       zoom_size) 
    811DECLARE_ATTRIBUTE(ARRAY(double, 1), value) 
    912 
  • XIOS/trunk/src/node/axis.cpp

    r345 r351  
    5050   { 
    5151      if (this->isChecked) return; 
     52      if (this->size.isEmpty()) 
     53         ERROR("CAxis::checkAttributes(void)",<< "Attribut <size> of the axis must be specified") ; 
    5254      StdSize size = this->size.getValue(); 
     55       
     56      StdSize zoom_begin,zoom_end, zoom_size ; 
     57       
     58      zoom_begin = (this->zoom_begin.isEmpty()) ?  1 : this->zoom_begin.getValue() ; 
     59      zoom_end = (this->zoom_end.isEmpty()) ?  size : this->zoom_end.getValue() ;  
     60      zoom_size = (this->zoom_size.isEmpty()) ?  size : this->zoom_size.getValue() ; 
     61       
     62      if (this->zoom_begin.isEmpty()) zoom_begin=zoom_end-zoom_size+1 ; 
     63      if (this->zoom_end.isEmpty()) zoom_end=zoom_begin+zoom_size-1 ; 
     64      if (this->zoom_size.isEmpty()) zoom_size=zoom_end-zoom_begin+1 ; 
     65       
     66      if ( (zoom_begin < 1) || (zoom_begin > size) || (zoom_end<1) || (zoom_end>size) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) 
     67        ERROR("CAxis::checkAttributes(void)",<< "One or more attribut of <zoom_begin>, <zoom_end>, <zoom_size>, are not well specified") ; 
     68      this->zoom_begin.setValue(zoom_begin) ; 
     69      this->zoom_end.setValue(zoom_end) ; 
     70      this->zoom_size.setValue(zoom_size) ; 
     71       
    5372      StdSize true_size = value.getValue()->num_elements(); 
    5473      if (size != true_size) 
  • XIOS/trunk/src/node/grid.cpp

    r347 r351  
    101101   //--------------------------------------------------------------- 
    102102 
     103/* 
    103104   std::vector<StdSize> CGrid::getLocalShape(void) const 
    104105   { 
     
    107108      retvalue.push_back(domain->zoom_nj_loc.getValue()); 
    108109      if (this->withAxis) 
    109          retvalue.push_back(this->axis->size.getValue()); 
     110         retvalue.push_back(this->axis->zoom_size.getValue()); 
    110111      return (retvalue); 
    111112   } 
     113*/ 
    112114   //--------------------------------------------------------------- 
    113115    
     116/* 
    114117   StdSize CGrid::getLocalSize(void) const 
    115118   { 
     
    120123      return (retvalue); 
    121124   } 
    122     
    123    //--------------------------------------------------------------- 
    124  
     125*/ 
     126   //--------------------------------------------------------------- 
     127/* 
    125128   std::vector<StdSize> CGrid::getGlobalShape(void) const 
    126129   { 
     
    132135      return (retvalue); 
    133136   } 
    134    //--------------------------------------------------------------- 
    135     
     137*/ 
     138   //--------------------------------------------------------------- 
     139 
     140/*    
    136141   StdSize CGrid::getGlobalSize(void) const 
    137142   { 
     
    142147      return (retvalue); 
    143148   } 
    144  
     149*/ 
    145150   StdSize CGrid::getDataSize(void) const 
    146151   { 
     
    224229      const int ni   = domain->ni.getValue() , 
    225230                nj   = domain->nj.getValue() , 
    226                 size = (this->hasAxis()) ? axis->size.getValue() : 1 ; 
     231                size = (this->hasAxis()) ? axis->size.getValue() : 1 , 
     232                lbegin = (this->hasAxis()) ? axis->zoom_begin.getValue()-1 : 0 , 
     233                lend = (this->hasAxis()) ? axis->zoom_end.getValue()-1 : 0 ; 
    227234 
    228235 
     
    254261                                : (temp_j - 1) ; 
    255262 
    256             if ((i >= 0 && i < ni) && 
     263            if ((l >=lbegin && l<= lend) && 
     264                (i >= 0 && i < ni) && 
    257265                (j >= 0 && j < nj) && (*mask)[i][j]) 
    258266               indexCount++ ; 
     
    283291                                : (temp_j - 1) ; 
    284292 
    285             if ((i >= 0 && i < ni) && 
     293            if ((l >= lbegin && l <= lend) && 
     294                (i >= 0 && i < ni) && 
    286295                (j >= 0 && j < nj) && (*mask)[i][j]) 
    287296            { 
     
    294303               (*out_i_client)[indexCount]=i+domain->ibegin_client-1 ; 
    295304               (*out_j_client)[indexCount]=j+domain->jbegin_client-1 ; 
    296                (*out_l_client)[indexCount]=l ; 
     305               (*out_l_client)[indexCount]=l-lbegin ; 
    297306               indexCount++ ; 
    298307            } 
  • XIOS/trunk/src/node/grid.hpp

    r347 r351  
    7373         StdSize getDimension(void) const; 
    7474          
    75          StdSize getLocalSize(void) const; 
    76          StdSize getGlobalSize(void) const; 
     75//         StdSize getLocalSize(void) const; 
     76//         StdSize getGlobalSize(void) const; 
    7777         StdSize  getDataSize(void) const; 
    78          std::vector<StdSize> getLocalShape(void) const; 
    79          std::vector<StdSize> getGlobalShape(void) const; 
     78//         std::vector<StdSize> getLocalShape(void) const; 
     79//         std::vector<StdSize> getGlobalShape(void) const; 
    8080 
    8181         /// Entrées-sorties de champs /// 
  • XIOS/trunk/src/output/nc4_data_output.cpp

    r347 r351  
    225225         if (axis->IsWritten(this->filename)) return; 
    226226         axis->checkAttributes(); 
     227         StdSize zoom_size=axis->zoom_size.getValue() ; 
     228         StdSize zoom_begin=axis->zoom_begin.getValue()-1 ; 
     229          
    227230         std::vector<StdString> dims; 
    228231         StdString axisid = (!axis->name.isEmpty()) 
    229232                           ? axis->name.getValue() : axis->getId(); 
    230          SuperClassWriter::addDimension(axisid, axis->size.getValue()); 
     233         SuperClassWriter::addDimension(axisid, zoom_size); 
    231234         dims.push_back(axisid); 
    232235          
     
    254257 
    255258               SuperClassWriter::definition_end(); 
    256                SuperClassWriter::writeData(axis->value.getValue(), axisid, isCollective, 0); 
     259                
     260               ARRAY(double,1) axis_value=axis->value.getValue() ; 
     261               ARRAY_CREATE(value,double,1,[zoom_size]) ; 
     262               for(StdSize i = 0 ; i < zoom_size ; i++) (*value)[i]=(*axis_value)[i+zoom_begin] ; 
     263               SuperClassWriter::writeData(value, axisid, isCollective, 0); 
     264                
    257265               SuperClassWriter::definition_start(); 
    258266 
     
    490498         { 
    491499            CAxis* axis = grid->axis ; 
    492             ARRAY_CREATE(field_data3D,double,3,[domain->zoom_ni_srv][domain->zoom_nj_srv][axis->size.getValue()]) ; 
     500            ARRAY_CREATE(field_data3D,double,3,[domain->zoom_ni_srv][domain->zoom_nj_srv][axis->zoom_size.getValue()]) ; 
    493501            field->outputField(field_data3D); 
    494502            switch (SuperClass::type) 
     
    513521//                 start[2]=domain->zoom_ibegin_loc.getValue()-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_loc.getValue()-domain->zoom_jbegin.getValue() ; start[0]=0 ; 
    514522                   start[2]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; start[0]=0 ; 
    515                    count[2]=domain->zoom_ni_srv ; count[1]=domain->zoom_nj_srv ; count[0] = axis->size.getValue(); 
     523                   count[2]=domain->zoom_ni_srv ; count[1]=domain->zoom_nj_srv ; count[0] = axis->zoom_size.getValue(); 
    516524                 } 
    517525                 SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1,&start,&count ); 
  • XIOS/trunk/src/test/test_cs.f90

    r349 r351  
    3232  TYPE(xios_time)      :: dtime 
    3333  TYPE(xios_context) :: ctx_hdl 
    34   INTEGER,PARAMETER :: ni_glo=1000  
    35   INTEGER,PARAMETER :: nj_glo=1000  
     34  INTEGER,PARAMETER :: ni_glo=100  
     35  INTEGER,PARAMETER :: nj_glo=100  
     36  INTEGER,PARAMETER :: llm=3  
     37  DOUBLE PRECISION  :: lval(llm)=(/1.0,2.0,3.0/) 
    3638  TYPE(xios_field) :: field_hdl 
    3739  TYPE(xios_fieldgroup) :: fieldgroup_hdl 
     
    3941   
    4042   
    41   DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo,field_A_glo 
    42   DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:), lonvalue(:) ; 
     43  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo 
     44  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) 
     45  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), lonvalue(:) ; 
    4346  INTEGER :: ni,ibegin,iend,nj,jbegin,jend 
    44   INTEGER :: i,j,ts,n 
     47  INTEGER :: i,j,l,ts,n 
    4548   
    4649  CALL init_wait 
     50   
    4751   
    4852  DO j=1,nj_glo 
     
    5054      lon_glo(i,j)=(i-1)+(j-1)*ni_glo 
    5155      lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo 
    52       field_A_glo(i,j)=(i-1)+(j-1)*ni_glo 
     56      DO l=1,llm 
     57        field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l 
     58      ENDDO 
    5359    ENDDO 
    5460  ENDDO 
     
    6571  iend=ibegin+ni-1 ; jend=jbegin+nj-1 
    6672 
    67   ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2),lonvalue(ni*nj)) 
     73  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni*nj)) 
    6874  lon(:,:)=lon_glo(ibegin:iend,jbegin:jend) 
    6975  lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) 
    70   field_A(1:ni,1:nj)=field_A_glo(ibegin:iend,jbegin:jend) 
     76  field_A(1:ni,1:nj,:)=field_A_glo(ibegin:iend,jbegin:jend,:) 
    7177   
    7278 
     
    8288!  CALL xios_set_context_attr("test",start_date="01/01/2000 - 00:00:00") 
    8389  CALL xios_set_context_attr("test",calendar_type="Gregorian")  
     90  CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 
    8491  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 
    8592  !CALL xios_set_domain_attr("domain_A",zoom_ni=3,zoom_ibegin=3,zoom_nj=3,zoom_jbegin=6) 
     
    109116     
    110117    PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
    111     DO ts=1,24*100 
     118    DO ts=1,24*10 
    112119      CALL xios_update_calendar(ts) 
    113120      CALL xios_send_field("field_A",field_A) 
Note: See TracChangeset for help on using the changeset viewer.