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

Last change on this file since 624 was 624, checked in by mhnguyen, 6 years ago

Final tests of zoom and inverse on axis

+) Modify test_client and test_complete to work with new grid definition
+) Correct some bugs causing memory leak
+) Clean abundant code
+) Add more comments to new files

Test
+) On Curie
+) test_client and test_complete pass with correct results

  • Property svn:executable set to *
File size: 6.4 KB
Line 
1PROGRAM test_new_features
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_duration) :: dtime
14  TYPE(xios_date) :: date
15  CHARACTER(len=15) :: calendar_type
16  TYPE(xios_context) :: ctx_hdl
17  INTEGER,PARAMETER :: ni_glo=100
18  INTEGER,PARAMETER :: nj_glo=100
19  INTEGER,PARAMETER :: llm=5
20  DOUBLE PRECISION  :: lval(llm)=1, tsTemp
21  TYPE(xios_field) :: field_hdl
22  TYPE(xios_fieldgroup) :: fieldgroup_hdl
23  TYPE(xios_file) :: file_hdl
24  LOGICAL :: ok
25  LOGICAL,ALLOCATABLE :: mask_glo(:),mask(:)
26
27  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo
28  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm), lval_ni_glo(ni_glo), lval_nj_glo(nj_glo)
29  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), field_All_Axis(:,:,:), lonvalue(:) , field_Axis(:), lvaln(:), lval_ni(:), lval_nj(:), field_Two_Axis(:,:)
30  INTEGER :: ni,ibegin,iend,nj,jbegin,jend, nAxis, axisBegin, axisEnd
31  INTEGER :: i,j,l,ts,n
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      lval_ni_glo(i) = i-1
51      DO l=1,llm
52        field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l
53      ENDDO
54    ENDDO
55    lval_nj_glo(j) = j-1
56  ENDDO
57  ni=ni_glo ; ibegin=0
58
59  jbegin=0
60  DO n=0,size-1
61    nj=nj_glo/size
62    IF (n<MOD(nj_glo,size)) nj=nj+1
63    IF (n==rank) exit
64    jbegin=jbegin+nj
65  ENDDO
66  iend=ibegin+ni-1 ; jend=jbegin+nj-1
67
68  axisBegin = 0
69  nAxis = llm
70!  DO n=0, size -1
71!    nAxis = llm/size
72!    IF (n<MOD(llm,size)) nAxis=nAxis+1
73!    IF (n==rank) exit
74!    axisBegin=axisBegin+nAxis
75!  ENDDO
76  axisEnd=axisBegin+nAxis-1
77
78  DO i=1,llm
79    lval(i) = i
80  ENDDO
81
82
83  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni*nj), field_Axis(nAxis), field_All_Axis(1:ni,1:nj,llm), lvaln(nAxis), lval_ni(ni), lval_nj(nj), field_Two_Axis(ni_glo,1:nj))
84  ALLOCATE(mask(nj))
85  DO i = 1, nj
86!    IF (MOD(i,2)>=0) THEN
87!      mask(i)=.FALSE.
88!    ELSE
89      mask(i)=.TRUE.
90!    ENDIF
91  ENDDO
92  lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1)
93  lat(:,:)=lat_glo(ibegin+1:iend+1,jbegin+1:jend+1)
94  field_A(1:ni,1:nj,:) = field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:)
95  field_Axis(1:nAxis)  = field_A_glo(1,1,axisBegin+1:axisEnd+1)
96  field_All_Axis(1:ni,1:nj,:) = field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:)
97  field_Two_Axis(:,1:nj)  = field_A_glo(:,jbegin+1:jend+1,1)
98  lvaln(1:nAxis) = lval(axisBegin+1:axisEnd+1)
99  lval_nj(1:nj) = lval_nj_glo(jbegin+1:jend+1);
100  lval_ni(1:ni) = lval_ni_glo(ibegin+1:iend+1);
101
102  CALL xios_context_initialize("test",comm)
103  CALL xios_get_handle("test",ctx_hdl)
104  CALL xios_set_current_context(ctx_hdl)
105
106  CALL xios_get_calendar_type(calendar_type)
107  PRINT *, "calendar_type = ", calendar_type
108
109  CALL xios_set_axis_attr("axis_A", size=ni_glo, ibegin=ibegin, ni=ni, value=lval_ni)
110  CALL xios_set_axis_attr("axis_B", size=nj_glo, ibegin=jbegin, ni=nj, value=lval_nj, mask=mask)
111  CALL xios_set_axis_attr("axis_C", size=llm, value=lval)
112  CALL xios_set_axis_attr("axis_D", size=llm, ibegin=axisBegin, ni=nAxis, value=lvaln)
113  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj)
114  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4)
115  CALL xios_set_domain_attr("domain_A",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/)))
116!  CALL xios_set_domain_attr("domain_A",zoom_ibegin=40, zoom_ni=20, zoom_jbegin=40, zoom_nj=10)
117  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.)
118
119  CALL xios_get_handle("field_definition",fieldgroup_hdl)
120  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B")
121  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B")
122
123  CALL xios_get_handle("output",file_hdl)
124  CALL xios_add_child(file_hdl,field_hdl)
125  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C")
126!
127!  CALL xios_get_handle("output_All_Axis",file_hdl)
128!  CALL xios_add_child(file_hdl,field_hdl)
129!  CALL xios_set_attr(field_hdl,field_ref="field_All_Axis",name="field_C")
130
131  dtime%second = 3600
132  CALL xios_set_timestep(dtime)
133
134  ! The calendar is created as soon as the calendar type is defined. This way
135  ! calendar operations can be used before the context definition is closed
136  CALL xios_get_time_origin(date)
137  PRINT *, "--> year length = ", xios_get_year_length_in_seconds(date%year)
138  PRINT *, "--> day length = ", xios_get_day_length_in_seconds()
139  PRINT *, "time_origin = ", date
140  PRINT *, "xios_date_get_second_of_year(time_origin) = ", xios_date_get_second_of_year(date)
141  PRINT *, "xios_date_get_day_of_year(time_origin) = ", xios_date_get_day_of_year(date)
142  PRINT *, "xios_date_get_fraction_of_year(time_origin) = ", xios_date_get_fraction_of_year(date)
143  PRINT *, "xios_date_get_second_of_day(time_origin) = ", xios_date_get_second_of_day(date)
144  PRINT *, "xios_date_get_fraction_of_day(time_origin) = ", xios_date_get_fraction_of_day(date)
145  dtime%timestep = 1
146  dtime = 0.5 * dtime
147  PRINT *, "duration = ", dtime
148  date = date + 3 * (dtime + dtime)
149  PRINT *, "date = time_origin + 3 * (duration + duration) = ", date
150  PRINT *, "xios_date_convert_to_seconds(date) = ", xios_date_convert_to_seconds(date)
151  PRINT *, "xios_date_convert_to_seconds(date - 2.5h) = ", xios_date_convert_to_seconds(date - 2.5 * xios_hour)
152
153  ni=0 ; lonvalue(:)=0
154  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue)
155
156!  print *,"ni",ni
157!  print *,"lonvalue",lonvalue ;
158
159  CALL xios_is_defined_field_attr("field_A",enabled=ok)
160  PRINT *,"field_A : attribute enabled is defined ? ",ok
161  CALL xios_close_context_definition()
162
163  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A")
164  DO ts=1,24*10
165    CALL xios_update_calendar(ts)
166    CALL xios_send_field("field_A",field_A)
167    CALL xios_send_field("field_Axis",field_Axis)
168
169    CALL xios_send_field("field_Two_Axis",field_Two_Axis)
170    CALL xios_send_field("field_All_Axis",field_All_Axis)
171!    tsTemp = ts
172!    CALL xios_send_scalar("field_Scalar", tsTemp)
173    CALL wait_us(5000) ;
174  ENDDO
175
176  CALL xios_context_finalize()
177  CALL xios_finalize()
178
179  CALL MPI_FINALIZE(ierr)
180
181END PROGRAM test_new_features
182
183
184
185
186
Note: See TracBrowser for help on using the repository browser.