Changeset 549 for XIOS/trunk/src/test


Ignore:
Timestamp:
01/26/15 14:39:26 (9 years ago)
Author:
rlacroix
Message:

Revised calendar functionalities:

  • the calendar is now configured from a specific calendar child node of the context in the XML configuration file. Example: <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-29 15:00:00" timestep="1h" />
  • the calendar type should now be configured when defining the start time and/or the time origin.
  • the start time and the time origin are now optional, 0000-01-01 00:00:00 will be used by default. It is also possible to define them partially. For example, 2015 and 2014-12 are valid dates corresponding respectively to 2015-01-01 00:00:00 and 2014-12-01 00:00:00.
  • an optional duration offset can be added to the start date and time origin. For example, it's possible to define the date 2015-01-12 12:00:00 as 2015-01-11 + 36h or 2015-01-11 12:00:00 + 1d. The duration format is the same as the time step. Being that the date is optional, it is possible to only use a duration (for example + 42s is the same as 0000-01-01 00:00:00 + 42s). An error will be raised if a duration based on the time step is used before the time step was configured. For example, the following would cause an error: <calendar type="Gregorian" start_date="+ 1ts" /> but <calendar type="Gregorian" start_date="+ 1ts" timestep="0.5h" /> would not.
  • new Fortran interface to define the calendar:
    • xios_define_calendar(type[, timestep, start_date, time_origin]) will create a calendar when none had previously been defined. Only the type argument is mandatory, the rest is optional. Calendar operations on dates and durations are possible as soon as the calendar is created (either using this procedure or directly from the XML configuration file).
    • the following getter and setter procedures are available: xios_set_timestep, xios_set_start_date, xios_set_time_origin, xios_get_calendar_type, xios_get_timestep, xios_get_start_date, xios_get_time_origin.
  • new Fortran interface to interact with the calendar: xios_update_calendar, xios_get_current_date, xios_get_year_length_in_seconds, xios_get_day_length_in_seconds.
  • new Fortran interface for date conversion: xios_date_get_second_of_year, xios_date_get_day_of_year, xios_date_get_fraction_of_year, xios_date_get_second_of_day, xios_date_get_fraction_of_day.
  • two new placeholders are available to format the file name when splitting the output (split_freq_format attribute):
    • %S the number of seconds since the time origin
    • %D the integral number of days since the time origin
Location:
XIOS/trunk/src/test
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/test/test_client.f90

    r545 r549  
    88  INTEGER :: size 
    99  INTEGER :: ierr 
    10    
     10 
    1111  CHARACTER(len=*),PARAMETER :: id="client" 
    1212  INTEGER :: comm 
    1313  TYPE(xios_duration) :: dtime 
    1414  TYPE(xios_date) :: date 
     15  CHARACTER(len=10) :: calendar_type 
    1516  TYPE(xios_context) :: ctx_hdl 
    1617  INTEGER,PARAMETER :: ni_glo=100 
    17   INTEGER,PARAMETER :: nj_glo=100  
    18   INTEGER,PARAMETER :: llm=5  
     18  INTEGER,PARAMETER :: nj_glo=100 
     19  INTEGER,PARAMETER :: llm=5 
    1920  DOUBLE PRECISION  :: lval(llm)=1 
    2021  TYPE(xios_field) :: field_hdl 
     
    2223  TYPE(xios_file) :: file_hdl 
    2324  LOGICAL :: ok 
    24    
     25 
    2526  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo 
    2627  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) 
     
    3233 
    3334  CALL MPI_INIT(ierr) 
    34    
     35 
    3536  CALL init_wait 
    36   
     37 
    3738!!! XIOS Initialization (get the local communicator) 
    3839 
     
    4041 
    4142  CALL MPI_COMM_RANK(comm,rank,ierr) 
    42   CALL MPI_COMM_SIZE(comm,size,ierr)   
    43    
     43  CALL MPI_COMM_SIZE(comm,size,ierr) 
     44 
    4445  DO j=1,nj_glo 
    4546    DO i=1,ni_glo 
     
    5758    nj=nj_glo/size 
    5859    IF (n<MOD(nj_glo,size)) nj=nj+1 
    59     IF (n==rank) exit  
     60    IF (n==rank) exit 
    6061    jbegin=jbegin+nj 
    6162  ENDDO 
    62    
     63 
    6364  iend=ibegin+ni-1 ; jend=jbegin+nj-1 
    6465 
     
    6768  lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) 
    6869  field_A(1:ni,1:nj,:)=field_A_glo(ibegin:iend,jbegin:jend,:) 
    69    
     70 
    7071  CALL xios_context_initialize("test",comm) 
    7172  CALL xios_get_handle("test",ctx_hdl) 
    7273  CALL xios_set_current_context(ctx_hdl) 
    73    
    74   CALL xios_set_context_attr("test",calendar_type="Gregorian")  
     74 
     75  CALL xios_get_calendar_type(calendar_type) 
     76  PRINT *, "calendar_type = ", calendar_type 
     77 
    7578  CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 
    7679  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 
     
    7881  CALL xios_set_domain_attr("domain_A",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/))) 
    7982  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 
    80    
     83 
    8184  CALL xios_get_handle("field_definition",fieldgroup_hdl) 
    8285  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") 
    8386  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") 
    84    
     87 
    8588  CALL xios_get_handle("output",file_hdl) 
    8689  CALL xios_add_child(file_hdl,field_hdl) 
    8790  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C") 
    88      
    89   
     91 
    9092  dtime%second = 3600 
    91   CALL xios_set_context_attr("test", timestep=dtime) 
     93  CALL xios_set_timestep(dtime) 
    9294 
    93   ! Create the calendar before closing the context definition 
    94   ! so that calendar operations can be used 
    95   CALL xios_set_calendar() 
    96   CALL xios_get_context_attr("test", time_origin=date) 
     95  ! The calendar is created as soon as the calendar type is defined. This way 
     96  ! calendar operations can be used before the context definition is closed 
     97  CALL xios_get_time_origin(date) 
     98  PRINT *, "--> year length = ", xios_get_year_length_in_seconds(date%year) 
     99  PRINT *, "--> day length = ", xios_get_day_length_in_seconds() 
    97100  PRINT *, "time_origin = ", date 
     101  PRINT *, "xios_date_get_second_of_year(time_origin) = ", xios_date_get_second_of_year(date) 
     102  PRINT *, "xios_date_get_day_of_year(time_origin) = ", xios_date_get_day_of_year(date) 
     103  PRINT *, "xios_date_get_fraction_of_year(time_origin) = ", xios_date_get_fraction_of_year(date) 
     104  PRINT *, "xios_date_get_second_of_day(time_origin) = ", xios_date_get_second_of_day(date) 
     105  PRINT *, "xios_date_get_fraction_of_day(time_origin) = ", xios_date_get_fraction_of_day(date) 
    98106  dtime%timestep = 1 
    99107  dtime = 0.5 * dtime 
     
    103111  PRINT *, "xios_date_convert_to_seconds(date) = ", xios_date_convert_to_seconds(date) 
    104112  PRINT *, "xios_date_convert_to_seconds(date - 2.5h) = ", xios_date_convert_to_seconds(date - 2.5 * xios_hour) 
    105    
     113 
    106114  ni=0 ; lonvalue(:)=0 
    107115  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue) 
    108    
     116 
    109117  print *,"ni",ni 
    110118  print *,"lonvalue",lonvalue ; 
     
    113121  PRINT *,"field_A : attribute enabled is defined ? ",ok 
    114122  CALL xios_close_context_definition() 
    115    
     123 
    116124  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
    117125  DO ts=1,24*10 
     
    123131  CALL xios_context_finalize() 
    124132  CALL xios_finalize() 
    125    
     133 
    126134  CALL MPI_FINALIZE(ierr) 
    127    
     135 
    128136END PROGRAM test_client 
    129137 
    130138 
    131    
    132139 
    133    
     140 
     141 
  • XIOS/trunk/src/test/test_complete.f90

    r537 r549  
    88  INTEGER :: size_loc 
    99  INTEGER :: ierr 
    10    
     10 
    1111  CHARACTER(len=*),PARAMETER :: id="client" 
    1212  INTEGER :: comm 
    13   TYPE(xios_date)      :: start_date, time_origin 
    1413  TYPE(xios_duration)  :: dtime 
    1514  TYPE(xios_context) :: ctx_hdl 
    1615  INTEGER,PARAMETER :: ni_glo=100 
    17   INTEGER,PARAMETER :: nj_glo=100  
    18   INTEGER,PARAMETER :: llm=5  
     16  INTEGER,PARAMETER :: nj_glo=100 
     17  INTEGER,PARAMETER :: llm=5 
    1918  DOUBLE PRECISION  :: lval(llm)=1 
    2019  TYPE(xios_field) :: field_hdl 
     
    3433 
    3534  CALL MPI_INIT(ierr) 
    36    
     35 
    3736  CALL init_wait 
    38   
     37 
    3938!!! XIOS Initialization (get the local communicator) 
    4039 
     
    4241 
    4342  CALL MPI_COMM_RANK(comm,rank,ierr) 
    44   CALL MPI_COMM_SIZE(comm,size_loc,ierr)   
    45    
     43  CALL MPI_COMM_SIZE(comm,size_loc,ierr) 
     44 
    4645 
    4746!########################################################################### 
     
    6665    nj=nj_glo/size_loc 
    6766    IF (n<MOD(nj_glo,size_loc)) nj=nj+1 
    68     IF (n==rank) exit  
     67    IF (n==rank) exit 
    6968    jbegin=jbegin+nj 
    7069  ENDDO 
    71    
     70 
    7271  iend=ibegin+ni-1 ; jend=jbegin+nj-1 
    7372 
     
    7675  lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) 
    7776  field_A_atm(1:ni,1:nj,:)=field_A_glo(ibegin:iend,jbegin:jend,:) 
    78   
     77 
    7978 
    8079!!! Context ATMOSPHERE 
     
    8382  CALL xios_get_handle("atmosphere",ctx_hdl) 
    8483  CALL xios_set_current_context(ctx_hdl) 
    85    
    86   CALL xios_set_context_attr("atmosphere",calendar_type="Gregorian") 
    87   start_date = xios_date(2000, 01, 01, 00, 00, 00) 
    88   CALL xios_set_context_attr("atmosphere",start_date=start_date) 
    89   time_origin = xios_date(1999, 01, 01, 15, 00, 00) 
    90   CALL xios_set_context_attr("atmosphere",time_origin=time_origin) 
     84 
     85  CALL xios_define_calendar(type="Gregorian", & 
     86                            start_date=xios_date(2000, 01, 01, 00, 00, 00), & 
     87                            time_origin=xios_date(1999, 01, 01, 15, 00, 00)) 
    9188 
    9289  CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; 
     
    104101  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 
    105102 
    106 !!! Création d un nouveau champ  
     103!!! Création d un nouveau champ 
    107104 
    108105  CALL xios_get_handle("field_definition",fieldgroup_hdl) 
     
    112109 
    113110  CALL xios_set_attr(field_hdl,field_ref="field_A_atm",name="field_B_atm") 
    114    
     111 
    115112!!! Affectation de ce nouveau champ au fichier avec un nouveau nom 
    116113 
     
    118115  CALL xios_add_child(file_hdl,field_hdl) 
    119116  CALL xios_set_attr(field_hdl,field_ref="field_B_atm",name="field_C_atm") 
    120      
     117 
    121118!!! Definition du timestep 
    122119 
    123120  dtime%second=3600 
    124   CALL xios_set_context_attr("atmosphere", timestep=dtime) 
    125      
     121  CALL xios_set_timestep(timestep=dtime) 
     122 
    126123!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 
    127124 
    128125  ni=0 ; lonvalue(:)=0 
    129126  CALL xios_get_domain_attr("domain_atm",ni=ni,lonvalue=lonvalue) 
    130      
     127 
    131128  PRINT *,"ni",ni 
    132129  PRINT *,"lonvalue",lonvalue ; 
     
    137134 
    138135!!! Test des valeurs des champs/fichiers 
    139    
    140   !!! Attribut defini ?  
     136 
     137  !!! Attribut defini ? 
    141138 
    142139  CALL xios_is_defined_field_attr("field_A_atm",enabled=ok) 
     
    144141 
    145142  !!! Recuperer la valeur d un attribut 
    146    
     143 
    147144  CALL xios_get_field_attr("field_A_atm",name=crname) 
    148145  PRINT *,"field_A_atm : attribute name is : ",TRIM(crname) 
    149146 
    150   !!! Champ actif (besoin de fournir la valeur) ?  
     147  !!! Champ actif (besoin de fournir la valeur) ? 
    151148 
    152149    PRINT*,"field field_A_atm is active ? ",xios_field_is_active("field_A_atm") 
     
    173170  CALL xios_get_handle("surface",ctx_hdl) 
    174171  CALL xios_set_current_context(ctx_hdl) 
    175    
    176   CALL xios_set_context_attr("surface",calendar_type="Gregorian") 
    177   start_date = xios_date(2000, 01, 01, 00, 00, 00) 
    178   CALL xios_set_context_attr("surface",start_date=start_date) 
    179   time_origin = xios_date(1999, 01, 01, 15, 00, 00) 
    180   CALL xios_set_context_attr("surface",time_origin=time_origin) 
     172 
     173  CALL xios_define_calendar(type="Gregorian", & 
     174                            start_date=xios_date(2000, 01, 01, 00, 00, 00), & 
     175                            time_origin=xios_date(1999, 01, 01, 15, 00, 00)) 
    181176 
    182177  CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 
     
    186181  CALL xios_set_domain_attr("domain_srf",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/))) 
    187182 
    188 !!! Création d un nouveau champ  
     183!!! Création d un nouveau champ 
    189184 
    190185  CALL xios_get_handle("field_definition",fieldgroup_hdl) 
     
    194189 
    195190  CALL xios_set_attr(field_hdl,field_ref="field_A_srf",name="field_B_srf") 
    196    
     191 
    197192!!! Affectation de ce nouveau champ au fichier avec un nouveau nom 
    198193 
     
    200195  CALL xios_add_child(file_hdl,field_hdl) 
    201196  CALL xios_set_attr(field_hdl,field_ref="field_B_srf",name="field_C_srf") 
    202      
     197 
    203198!!! Definition du timestep 
    204199 
    205200  dtime%second=1800 
    206   CALL xios_set_context_attr("surface", timestep=dtime) 
    207      
     201  CALL xios_set_timestep(timestep=dtime) 
     202 
    208203!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 
    209204 
    210205  ni=0 ; lonvalue(:)=0 
    211206  CALL xios_get_domain_attr("domain_srf",ni=ni,lonvalue=lonvalue) 
    212      
     207 
    213208  PRINT *,"ni",ni 
    214209  PRINT *,"lonvalue",lonvalue ; 
     
    226221 
    227222      CALL xios_get_handle("atmosphere",ctx_hdl) 
    228       CALL xios_set_current_context(ctx_hdl)     
     223      CALL xios_set_current_context(ctx_hdl) 
    229224 
    230225!!! Mise a jour du pas de temps 
     
    239234 
    240235      CALL xios_get_handle("surface",ctx_hdl) 
    241       CALL xios_set_current_context(ctx_hdl)     
     236      CALL xios_set_current_context(ctx_hdl) 
    242237 
    243238!!! Mise a jour du pas de temps 
     
    257252 
    258253!!! Fin des contextes 
    259      
     254 
    260255    CALL xios_context_finalize() 
    261256    CALL xios_get_handle("atmosphere",ctx_hdl) 
    262     CALL xios_set_current_context(ctx_hdl)     
     257    CALL xios_set_current_context(ctx_hdl) 
    263258    CALL xios_context_finalize() 
    264      
     259 
    265260!!! Fin de XIOS 
    266261 
    267262    CALL xios_finalize() 
    268    
     263 
    269264    CALL MPI_FINALIZE(ierr) 
    270    
     265 
    271266  END PROGRAM test_complete 
    272267 
    273268 
    274269 
    275    
    276  
    277    
     270 
     271 
     272 
  • XIOS/trunk/src/test/test_cs.f90

    r537 r549  
    55  INTEGER :: size 
    66  INTEGER :: ierr 
    7    
     7 
    88  CALL MPI_INIT(ierr) 
    99  CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) 
    1010  CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr) 
    11    
     11 
    1212  IF (rank<11) THEN 
    1313   CALL client("client",rank,11) 
    14   ELSE  
     14  ELSE 
    1515    CALL server 
    1616  ENDIF 
    17    
    18    
     17 
     18 
    1919  CALL MPI_FINALIZE(ierr) 
    20    
     20 
    2121END PROGRAM test_cs 
    2222 
     
    3232  TYPE(xios_duration) :: dtime 
    3333  TYPE(xios_context) :: ctx_hdl 
    34   INTEGER,PARAMETER :: ni_glo=100  
    35   INTEGER,PARAMETER :: nj_glo=100  
    36   INTEGER,PARAMETER :: llm=3  
     34  INTEGER,PARAMETER :: ni_glo=100 
     35  INTEGER,PARAMETER :: nj_glo=100 
     36  INTEGER,PARAMETER :: llm=3 
    3737  DOUBLE PRECISION  :: lval(llm)=(/1.0,2.0,3.0/) 
    3838  TYPE(xios_field) :: field_hdl 
    3939  TYPE(xios_fieldgroup) :: fieldgroup_hdl 
    4040  TYPE(xios_file) :: file_hdl 
    41    
    42    
     41 
     42 
    4343  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo 
    4444  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) 
     
    4747  INTEGER :: ni,ibegin,iend,nj,jbegin,jend,data_ibegin,data_ni 
    4848  INTEGER :: i,j,k,l,ts,n,nij_begin 
    49    
    50    
     49 
     50 
    5151  CALL init_wait 
    52    
    53    
     52 
     53 
    5454  DO j=1,nj_glo 
    5555    DO i=1,ni_glo 
     
    6363  ni=ni_glo ; ibegin=1 
    6464 
    65    
     65 
    6666  nij_begin=1 
    6767  DO n=0,size-1 
     
    7070    IF (n==rank) THEN 
    7171      ibegin=1 ; iend=ni_glo ; ni=iend-ibegin+1 
    72       jbegin=(nij_begin-1)/ni_glo +1  
     72      jbegin=(nij_begin-1)/ni_glo +1 
    7373      jend=MOD(nij_begin-1 + data_ni-1,ni_glo) +1 
    7474      nj = jend-jbegin+1 
     
    7979    ENDIF 
    8080  ENDDO 
    81    
     81 
    8282 
    8383  ALLOCATE(lon(ni),lat(nj),field_A(data_ni,llm),lonvalue(ni*nj)) 
     
    9292    field_A(k,:)=field_A_glo(i,j,:) 
    9393  ENDDO 
    94    
     94 
    9595  mask(:,:)=.TRUE. 
    9696  mask(1:ni,6)=.TRUE. 
    97    
     97 
    9898 
    9999  CALL xios_initialize(id,return_comm=comm) 
     
    102102  CALL xios_get_handle("test",ctx_hdl) 
    103103  CALL xios_set_current_context(ctx_hdl) 
    104    
    105   CALL xios_set_context_attr("test",calendar_type="Gregorian")  
    106   CALL xios_set_context_attr("test",calendar_type="Gregorian")  
    107   CALL xios_set_context_attr("test",calendar_type="Gregorian")  
    108 !  CALL xios_set_context_attr("test",start_date="01/01/2000 - 00:00:00") 
    109   CALL xios_set_context_attr("test",calendar_type="Gregorian")  
     104 
     105! CALL xios_define_calendar(type="Gregorian") 
     106! CALL xios_set_start_date(start_date=xios_date(2000, 01, 01, 00, 00, 00)) 
    110107  CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 
    111108  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, iend=iend,jbegin=jbegin,jend=jend) 
    112 !  CALL xios_set_domain_attr("domain_A",zoom_ni=10,zoom_ibegin=5,zoom_nj=nj_glo,zoom_jbegin=1) 
     109! CALL xios_set_domain_attr("domain_A",zoom_ni=10,zoom_ibegin=5,zoom_nj=nj_glo,zoom_jbegin=1) 
    113110  CALL xios_set_domain_attr("domain_A",data_dim=1, data_ibegin=data_ibegin, data_ni=data_ni) 
    114111  CALL xios_set_domain_attr("domain_A",lonvalue=lon,latvalue=lat) 
    115 !  CALL xios_set_domain_attr("domain_A",mask=mask) 
     112! CALL xios_set_domain_attr("domain_A",mask=mask) 
    116113  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 
    117    
     114 
    118115  CALL xios_get_handle("field_definition",fieldgroup_hdl) 
    119116  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") 
    120117  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") 
    121    
     118 
    122119  CALL xios_get_handle("output",file_hdl) 
    123120  CALL xios_add_child(file_hdl,field_hdl) 
    124121  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C") 
    125      
    126   
     122 
     123 
    127124    dtime%second=3600 
    128     CALL xios_set_context_attr("test", timestep=dtime) 
    129      
     125    CALL xios_set_timestep(timestep=dtime) 
     126 
    130127!    ni=0 ; lonvalue(:)=0 
    131128!    CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue) 
    132      
     129 
    133130!    print *,"ni",ni 
    134131!    print *,"lonvalue",lonvalue ; 
    135132 
    136133    CALL xios_close_context_definition() 
    137      
     134 
    138135    PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
    139136    DO ts=1,24*10 
     
    142139      CALL wait_us(5000) ; 
    143140    ENDDO 
    144    
     141 
    145142    CALL xios_context_finalize() 
    146143    CALL xios_finalize() 
    147       
     144 
    148145  END SUBROUTINE client 
    149    
    150146 
    151    
     147 
     148 
    152149  SUBROUTINE server 
    153150  USE xios 
    154151  IMPLICIT NONE 
    155    
     152 
    156153    CALL xios_init_server 
    157   
     154 
    158155  END SUBROUTINE server 
    159    
    160156 
    161    
     157 
     158 
  • XIOS/trunk/src/test/test_new_features.f90

    r543 r549  
    6969 
    7070  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni*nj)) 
    71 !  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm,llm),lonvalue(ni*nj)) 
     71! ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm,llm),lonvalue(ni*nj)) 
    7272  lon(:,:)=lon_glo(ibegin:iend,jbegin:jend) 
    7373  lat(:,:)=lat_glo(ibegin:iend,jbegin:jend) 
     
    7878  CALL xios_set_current_context(ctx_hdl) 
    7979 
    80   CALL xios_set_context_attr("test",calendar_type="Gregorian") 
     80! CALL xios_define_calendar(type="Gregorian") 
    8181  CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 
    82 !  CALL xios_set_axis_attr("axis_B",size=llm ,value=lval2) ; 
     82! CALL xios_set_axis_attr("axis_B",size=llm ,value=lval2) ; 
    8383  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 
    8484  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) 
     
    9696 
    9797    dtime%second=3600 
    98     CALL xios_set_context_attr("test", timestep=dtime) 
     98!   CALL xios_set_timestep(timestep=dtime) 
    9999 
    100100    ni=0 ; lonvalue(:)=0 
  • XIOS/trunk/src/test/test_unstruct_complete.f90

    r537 r549  
    88  INTEGER :: mpi_size 
    99  INTEGER :: ierr 
    10    
     10 
    1111  CHARACTER(len=*),PARAMETER :: id="client" 
    1212  INTEGER :: comm 
    1313  TYPE(xios_duration) :: dtime 
    1414  TYPE(xios_context) :: ctx_hdl 
    15   INTEGER, PARAMETER :: nlon=60  
     15  INTEGER, PARAMETER :: nlon=60 
    1616  INTEGER, PARAMETER :: nlat=30 
    1717  INTEGER,PARAMETER :: ni_glo=100 
    18   INTEGER,PARAMETER :: nj_glo=100  
    19   INTEGER,PARAMETER :: llm=5  
     18  INTEGER,PARAMETER :: nj_glo=100 
     19  INTEGER,PARAMETER :: llm=5 
    2020  DOUBLE PRECISION  :: lval(llm)=1 
    2121  TYPE(xios_field) :: field_hdl 
     
    2323  TYPE(xios_file) :: file_hdl 
    2424  LOGICAL :: ok 
    25    
     25 
    2626  DOUBLE PRECISION,ALLOCATABLE :: lon_glo(:),lat_glo(:) 
    2727  DOUBLE PRECISION,ALLOCATABLE :: bounds_lon_glo(:,:),bounds_lat_glo(:,:) 
     
    4242  INTEGER,ALLOCATABLE :: data_i_index(:) 
    4343  DOUBLE PRECISION,ALLOCATABLE :: field_A_compressed(:,:) 
    44    
     44 
    4545  CALL xios_initialize(id,return_comm=comm) 
    4646  CALL MPI_COMM_RANK(comm,mpi_rank,ierr) 
    4747  CALL MPI_COMM_SIZE(comm,mpi_size,ierr) 
    48    
     48 
    4949  CALL init_wait 
    50    
     50 
    5151  ncell_glo=0 
    5252  DO j=1,nlat 
     
    5555    ncell_glo=ncell_glo+n 
    5656  ENDDO 
    57    
     57 
    5858  ALLOCATE(lon_glo(ncell_glo)) 
    5959  ALLOCATE(lat_glo(ncell_glo)) 
     
    6363  ALLOCATE(field_A_glo(ncell_glo,llm)) 
    6464  ALLOCATE(mask_glo(ncell_glo)) 
    65     
     65 
    6666  ind=0 
    6767  DO j=1,nlat 
     
    7070    if (j==nlat) PRINT*,"--- ",n 
    7171    IF (n<8) n=8 
    72      
     72 
    7373    DO i=1,n 
    7474      ind=ind+1 
     
    7676      ilon=i-0.5 
    7777      ilat=j-0.5 
    78        
     78 
    7979      lat_glo(ind)= 90-(ilat*180./nlat) 
    8080      lon_glo(ind)= (ilon*360./n) 
    81        
    82   
     81 
     82 
    8383      bounds_lat_glo(1,ind)= 90-((ilat-0.5)*180./nlat) 
    8484      bounds_lon_glo(1,ind)=((ilon-0.5)*360./n) 
    85        
     85 
    8686      bounds_lat_glo(2,ind)= 90-((ilat-0.5)*180./nlat) 
    87       bounds_lon_glo(2,ind)=((ilon+0.5)*360./n)  
    88            
     87      bounds_lon_glo(2,ind)=((ilon+0.5)*360./n) 
     88 
    8989      bounds_lat_glo(3,ind)= 90-((ilat+0.5)*180./nlat) 
    90       bounds_lon_glo(3,ind)=((ilon+0.5)*360./n)      
     90      bounds_lon_glo(3,ind)=((ilon+0.5)*360./n) 
    9191 
    9292      bounds_lat_glo(4,ind)= 90-((ilat+0.5)*180./nlat) 
    9393      bounds_lon_glo(4,ind)=((ilon-0.5)*360./n) 
    94        
     94 
    9595    ENDDO 
    9696  ENDDO 
     
    9999  rank=(mpi_size-1)/2 
    100100  ncell_x=sqrt(ncell_glo*1./mpi_size) 
    101    
     101 
    102102  j1=nlat/2 
    103103  DO WHILE(rank>=0) 
     
    106106    n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 
    107107    np = MIN(n/ncell_x,rank+1) ; 
    108     if (j2==1) np=rank+1  
    109      
     108    if (j2==1) np=rank+1 
     109 
    110110    PRINT *,"domain ",j2,j1,rank,np ; 
    111     DO j=j2,j1   
     111    DO j=j2,j1 
    112112      n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 
    113113      IF (n<8) n=8 
    114114      DO i=1,n 
    115115        ind=list_ind(i,j) 
    116         IF ( (i-1) < MOD(n,np)*(n/np+1)) THEN  
     116        IF ( (i-1) < MOD(n,np)*(n/np+1)) THEN 
    117117          i_index_glo(ind) = rank - (i-1)/(n/np+1) 
    118         ELSE  
     118        ELSE 
    119119          i_index_glo(ind) = rank-(MOD(n,np)+ (i-1-MOD(n,np)*(n/np+1))/(n/np)) 
    120120        ENDIF 
     
    124124    j1=j2-1 
    125125  ENDDO 
    126          
     126 
    127127  rank=(mpi_size-1)/2+1 
    128128  ncell_x=sqrt(ncell_glo*1./mpi_size) 
    129    
     129 
    130130  j1=nlat/2+1 
    131131  DO WHILE(rank<=mpi_size-1) 
     
    134134    n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 
    135135    np = MIN(n/ncell_x,mpi_size-rank) ; 
    136     if (j2==nlat) np=mpi_size-rank  
    137      
     136    if (j2==nlat) np=mpi_size-rank 
     137 
    138138    PRINT *,"domain ",j2,j1,rank,np ; 
    139     DO j=j1,j2   
     139    DO j=j1,j2 
    140140      n=NINT(COS(Pi/2-(j-0.5)*PI/nlat)*nlon) 
    141141      IF (n<8) n=8 
    142142      DO i=1,n 
    143143        ind=list_ind(i,j) 
    144         IF ( (i-1) < MOD(n,np)*(n/np+1)) THEN  
     144        IF ( (i-1) < MOD(n,np)*(n/np+1)) THEN 
    145145          i_index_glo(ind) = rank + (i-1)/(n/np+1) 
    146         ELSE  
     146        ELSE 
    147147          i_index_glo(ind) = rank+(MOD(n,np)+ (i-1-MOD(n,np)*(n/np+1))/(n/np)) 
    148148        ENDIF 
     
    152152    j1=j2+1 
    153153  ENDDO 
    154      
     154 
    155155  ncell=0 
    156156  DO ind=1,ncell_glo 
     
    183183    ENDIF 
    184184  ENDDO 
    185    
     185 
    186186  ALLOCATE(field_A_compressed(data_n_index,llm)) 
    187187  ALLOCATE(data_i_index(data_n_index)) 
     
    194194    ENDIF 
    195195  ENDDO 
    196        
    197    
    198    
     196 
    199197  CALL xios_context_initialize("surface",comm) 
    200198  CALL xios_get_handle("surface",ctx_hdl) 
    201199  CALL xios_set_current_context(ctx_hdl) 
    202    
     200 
     201  CALL xios_define_calendar(type="Julian", & 
     202                            start_date=xios_date(2012, 03, 01, 15, 00, 00), & 
     203                            time_origin=xios_date(2012, 02, 29, 15, 00, 00)) 
     204 
    203205  CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 
    204206  CALL xios_set_domain_attr("domain_srf",ni_glo=ncell_glo, ni=ncell, ibegin=1, i_index=RESHAPE(i_index,(/ncell,1/) )) 
     
    206208  CALL xios_set_domain_attr("domain_srf",lonvalue=lon,latvalue=lat) 
    207209  CALL xios_set_domain_attr("domain_srf", nvertex=4, bounds_lon=bounds_lon, bounds_lat=bounds_lat ) 
    208      
    209   
     210 
     211 
    210212  dtime%second=3600 
    211213  CALL xios_set_context_attr("surface", timestep=dtime) 
    212214  CALL xios_close_context_definition() 
    213      
     215 
    214216   DO ts=1,24*10 
    215217     CALL xios_update_calendar(ts) 
    216218     CALL xios_send_field("field_A_srf",field_A_compressed) 
    217219    ENDDO 
    218    
     220 
    219221    CALL xios_context_finalize() 
    220222    CALL xios_finalize() 
    221    
     223 
    222224  END PROGRAM test_unstruct_complete 
    223225 
    224226 
    225    
    226  
    227    
     227 
     228 
     229 
  • XIOS/trunk/src/test/test_xios_interface.f90

    r537 r549  
    9696  CALL xios_set_current_context(ctx_hdl) 
    9797 
    98   CALL xios_set_context_attr("atmosphere",calendar_type="Gregorian") 
    99   start_date = xios_date(2000, 01, 01, 00, 00, 00) 
    100   CALL xios_set_context_attr("atmosphere",start_date=start_date) 
    101   time_origin = xios_date(1999, 01, 01, 15, 00, 00) 
    102   CALL xios_set_context_attr("atmosphere",time_origin=time_origin) 
     98  CALL xios_define_calendar(type="Gregorian", & 
     99                            start_date=xios_date(2000, 01, 01, 00, 00, 00), & 
     100                            time_origin=xios_date(1999, 01, 01, 15, 00, 00)) 
    103101 
    104102  CALL xios_set_axis_attr("axis_atm",size=llm ,value=lval) ; 
     
    131129 
    132130  dtime%second=3600 
    133   CALL xios_set_context_attr("atmosphere", timestep=dtime) 
     131  CALL xios_set_timestep(timestep=dtime) 
    134132 
    135133!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 
     
    183181  CALL xios_set_current_context(ctx_hdl) 
    184182 
    185   CALL xios_set_context_attr("surface",calendar_type="Gregorian") 
    186   start_date = xios_date(2000, 01, 01, 00, 00, 00) 
    187   CALL xios_set_context_attr("surface",start_date=start_date) 
    188   time_origin = xios_date(1999, 01, 01, 15, 00, 00) 
    189   CALL xios_set_context_attr("surface",time_origin=time_origin) 
     183  CALL xios_define_calendar(type="Gregorian", & 
     184                            start_date=xios_date(2000, 01, 01, 00, 00, 00), & 
     185                            time_origin=xios_date(1999, 01, 01, 15, 00, 00)) 
    190186 
    191187  CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 
     
    213209 
    214210  dtime%second=1800 
    215   CALL xios_set_context_attr("surface", timestep=dtime) 
     211  CALL xios_set_timestep(timestep=dtime) 
    216212 
    217213!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) 
Note: See TracChangeset for help on using the changeset viewer.