source: XIOS/trunk/src/test/test_new_features.f90 @ 540

Last change on this file since 540 was 540, checked in by mhnguyen, 10 years ago

Reorganizing structure of grid

+) Grid doesn't have domain_ref and axis_ref anymore.
All domain and axis of a grid must be inside grid (These domain and axis can be defined or refer to others)
+) Grid contains list of domain and axis
+) Reorder some functions to make sure new functionlities work

Test
+) On Curie
+) Mode attached and detached
+) Only test_new_features
+) Passed

File size: 3.7 KB
Line 
1PROGRAM test_client
2
3  USE xios
4  USE mod_wait
5  IMPLICIT NONE
6  INCLUDE "mpif.h"
7  INTEGER :: rank
8  INTEGER :: size
9  INTEGER :: ierr
10
11  CHARACTER(len=*),PARAMETER :: id="client"
12  INTEGER :: comm
13  TYPE(xios_time)      :: dtime
14  TYPE(xios_context) :: ctx_hdl
15  INTEGER,PARAMETER :: ni_glo=5
16  INTEGER,PARAMETER :: nj_glo=5
17  INTEGER,PARAMETER :: llm=5
18  DOUBLE PRECISION  :: lval(llm)=1
19  DOUBLE PRECISION  :: lval2(llm)=1
20  TYPE(xios_field) :: field_hdl
21  TYPE(xios_fieldgroup) :: fieldgroup_hdl
22  TYPE(xios_file) :: file_hdl
23  LOGICAL :: ok
24
25  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo
26!  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm,llm)
27!  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:,:), lonvalue(:) ;
28  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm)
29  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), lonvalue(:) ;
30  INTEGER :: ni,ibegin,iend,nj,jbegin,jend
31  INTEGER :: i,j,l,ts,n,k
32
33!!! MPI Initialization
34
35  CALL MPI_INIT(ierr)
36
37  CALL init_wait
38
39!!! XIOS Initialization (get the local communicator)
40
41  CALL xios_initialize(id,return_comm=comm)
42
43  CALL MPI_COMM_RANK(comm,rank,ierr)
44  CALL MPI_COMM_SIZE(comm,size,ierr)
45
46  DO j=1,nj_glo
47    DO i=1,ni_glo
48      lon_glo(i,j)=(i-1)+(j-1)*ni_glo
49      lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo
50      DO l=1,llm
51!        DO k=1,llm
52!          field_A_glo(i,j,l,k)=(i-1)+(j-1)*ni_glo+10000*l+100000*k
53!        ENDDO
54        field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l
55      ENDDO
56    ENDDO
57  ENDDO
58  ni=ni_glo ; ibegin=1
59
60  jbegin=1
61  DO n=0,size-1
62    nj=nj_glo/size
63    IF (n<MOD(nj_glo,size)) nj=nj+1
64    IF (n==rank) exit
65    jbegin=jbegin+nj
66  ENDDO
67
68  iend=ibegin+ni-1 ; jend=jbegin+nj-1
69
70  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))
72  lon(:,:)=lon_glo(ibegin:iend,jbegin:jend)
73  lat(:,:)=lat_glo(ibegin:iend,jbegin:jend)
74  field_A(1:ni,1:nj,:)=field_A_glo(ibegin:iend,jbegin:jend,:)
75
76  CALL xios_context_initialize("test",comm)
77  CALL xios_get_handle("test",ctx_hdl)
78  CALL xios_set_current_context(ctx_hdl)
79
80  CALL xios_set_context_attr("test",calendar_type="Gregorian")
81  CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ;
82  CALL xios_set_axis_attr("axis_B",size=llm ,value=lval2) ;
83  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj)
84  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4)
85  CALL xios_set_domain_attr("domain_A",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/)))
86  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.)
87
88  CALL xios_get_handle("field_definition",fieldgroup_hdl)
89  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B")
90  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B")
91
92  CALL xios_get_handle("output",file_hdl)
93  CALL xios_add_child(file_hdl,field_hdl)
94  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C")
95
96
97    dtime%second=3600
98    CALL xios_set_timestep(dtime)
99
100    ni=0 ; lonvalue(:)=0
101    CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue)
102
103    print *,"ni",ni
104    print *,"lonvalue",lonvalue ;
105
106    CALL xios_is_defined_field_attr("field_A",enabled=ok)
107    PRINT *,"field_A : attribute enabled is defined ? ",ok
108    CALL xios_close_context_definition()
109
110    PRINT*,"field field_A is active ? ",xios_field_is_active("field_A")
111    DO ts=1,24*10
112      CALL xios_update_calendar(ts)
113      CALL xios_send_field("field_A",field_A)
114      CALL wait_us(5000) ;
115    ENDDO
116
117    CALL xios_context_finalize()
118    CALL xios_finalize()
119
120  CALL MPI_FINALIZE(ierr)
121
122END PROGRAM test_client
123
124
125
126
127
Note: See TracBrowser for help on using the repository browser.