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

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

Correcting value written on an distributed axis

+) Seperate writing value on axis in multiple file and one file case

Test
+) On curie
+) test_complet and test_client pass

  • Property svn:executable set to *
File size: 7.0 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=5
18  INTEGER,PARAMETER :: nj_glo=5
19  INTEGER,PARAMETER :: llm=5
20  INTEGER,PARAMETER :: llmInterPolated=5
21  DOUBLE PRECISION  :: lval(llm)=1, tsTemp, lvalInterPolated(llmInterPolated)=1
22  TYPE(xios_field) :: field_hdl
23  TYPE(xios_fieldgroup) :: fieldgroup_hdl
24  TYPE(xios_file) :: file_hdl
25  LOGICAL :: ok
26  LOGICAL,ALLOCATABLE :: mask_glo(:),mask(:)
27
28  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo
29  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm), lval_ni_glo(ni_glo), lval_nj_glo(nj_glo)
30  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), field_All_Axis(:,:,:), lonvalue(:) , &
31                                  field_Axis(:), lvaln(:), lval_ni(:), lval_nj(:), field_Two_Axis(:,:), lvalnInterp(:)
32  INTEGER :: ni,ibegin,iend,nj,jbegin,jend, nAxis, axisBegin, axisEnd, axisterpBegin, nAxisinterp, axisinterpEnd
33  INTEGER :: i,j,l,ts,n
34
35!!! MPI Initialization
36
37  CALL MPI_INIT(ierr)
38
39  CALL init_wait
40
41!!! XIOS Initialization (get the local communicator)
42
43  CALL xios_initialize(id,return_comm=comm)
44
45  CALL MPI_COMM_RANK(comm,rank,ierr)
46  CALL MPI_COMM_SIZE(comm,size,ierr)
47
48  DO j=1,nj_glo
49    DO i=1,ni_glo
50      lon_glo(i,j)=(i-1)+(j-1)*ni_glo
51      lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo
52      lval_ni_glo(i) = i-1
53      DO l=1,llm
54        field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l
55      ENDDO
56    ENDDO
57    lval_nj_glo(j) = j-1
58  ENDDO
59  ni=ni_glo ; ibegin=0
60
61  jbegin=0
62  CALL Distribute_index(jbegin, jend, nj, nj_glo, rank, size)
63
64  DO j=1,llm
65    lval(j) = j *10
66  ENDDO
67  axisBegin = 0
68  CALL Distribute_index(axisBegin, axisEnd, nAxis, llm, rank, size)
69
70  DO j=1,llmInterPolated
71    lvalInterPolated(j) = j * 12
72  ENDDO
73  axisterpBegin = 0
74  CALL Distribute_index(axisterpBegin, axisinterpEnd, nAxisinterp, llmInterPolated, rank, size)
75
76  ALLOCATE(field_A(0:ni+1,-1:nj+2,llm), field_Two_Axis(ni_glo,1:nj), field_Axis(nAxis), field_All_Axis(1:ni,1:nj,llm), &
77          lon(ni,nj),lat(ni,nj), lonvalue(ni*nj), &
78          lvaln(nAxis), lval_ni(ni), lval_nj(nj), lvalnInterp(nAxisinterp))
79
80  ALLOCATE(mask(nj))
81  DO i = 1, nj
82!    IF (MOD(i,2)>=0) THEN
83!      mask(i)=.FALSE.
84!    ELSE
85      mask(i)=.TRUE.
86!    ENDIF
87  ENDDO
88  lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1)
89  lat(:,:)=lat_glo(ibegin+1:iend+1,jbegin+1:jend+1)
90  field_A(1:ni,1:nj,:) = field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:)
91  field_Axis(1:nAxis)  = field_A_glo(1,1,axisBegin+1:axisEnd+1)
92  field_Two_Axis(:,1:nj)  = field_A_glo(:,jbegin+1:jend+1,1)
93  field_All_Axis(1:ni,1:nj,:) = field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:)
94
95  lvaln(1:nAxis) = lval(axisBegin+1:axisEnd+1)
96  lval_nj(1:nj) = lval_nj_glo(jbegin+1:jend+1);
97  lval_ni(1:ni) = lval_ni_glo(ibegin+1:iend+1);
98  lvalnInterp(1:nAxisinterp) = lvalInterPolated(axisterpBegin+1:axisinterpEnd+1)
99
100  CALL xios_context_initialize("test",comm)
101  CALL xios_get_handle("test",ctx_hdl)
102  CALL xios_set_current_context(ctx_hdl)
103
104  CALL xios_get_calendar_type(calendar_type)
105  PRINT *, "calendar_type = ", calendar_type
106
107  CALL xios_set_axis_attr("axis_A", size=ni_glo, ibegin=ibegin, ni=ni, value=lval_ni)
108  CALL xios_set_axis_attr("axis_B", size=nj_glo, ibegin=jbegin, ni=nj, value=lval_nj, mask=mask)
109  CALL xios_set_axis_attr("axis_C", size=llm, value=lval)
110  CALL xios_set_axis_attr("axis_D", size=llm, ibegin=axisBegin, ni=nAxis, value=lvaln)
111!  CALL xios_set_axis_attr("axis_D", size=llm, value=lval)
112  CALL xios_set_axis_attr("axis_G", size=llmInterPolated, value=lvalnInterp, ibegin=axisterpBegin, ni=nAxisinterp)
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  dtime%second = 3600
128  CALL xios_set_timestep(dtime)
129
130  ! The calendar is created as soon as the calendar type is defined. This way
131  ! calendar operations can be used before the context definition is closed
132  CALL xios_get_time_origin(date)
133  PRINT *, "--> year length = ", xios_get_year_length_in_seconds(date%year)
134  PRINT *, "--> day length = ", xios_get_day_length_in_seconds()
135  PRINT *, "time_origin = ", date
136  PRINT *, "xios_date_get_second_of_year(time_origin) = ", xios_date_get_second_of_year(date)
137  PRINT *, "xios_date_get_day_of_year(time_origin) = ", xios_date_get_day_of_year(date)
138  PRINT *, "xios_date_get_fraction_of_year(time_origin) = ", xios_date_get_fraction_of_year(date)
139  PRINT *, "xios_date_get_second_of_day(time_origin) = ", xios_date_get_second_of_day(date)
140  PRINT *, "xios_date_get_fraction_of_day(time_origin) = ", xios_date_get_fraction_of_day(date)
141  dtime%timestep = 1
142  dtime = 0.5 * dtime
143  PRINT *, "duration = ", dtime
144  date = date + 3 * (dtime + dtime)
145  PRINT *, "date = time_origin + 3 * (duration + duration) = ", date
146  PRINT *, "xios_date_convert_to_seconds(date) = ", xios_date_convert_to_seconds(date)
147  PRINT *, "xios_date_convert_to_seconds(date - 2.5h) = ", xios_date_convert_to_seconds(date - 2.5 * xios_hour)
148
149  ni=0 ; lonvalue(:)=0
150  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue)
151
152!  print *,"ni",ni
153!  print *,"lonvalue",lonvalue ;
154
155  CALL xios_is_defined_field_attr("field_A",enabled=ok)
156  PRINT *,"field_A : attribute enabled is defined ? ",ok
157  CALL xios_close_context_definition()
158
159  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A")
160  DO ts=1,24*10
161    CALL xios_update_calendar(ts)
162    CALL xios_send_field("field_A",field_A)
163    CALL xios_send_field("field_Axis",field_Axis)
164
165    CALL xios_send_field("field_Two_Axis",field_Two_Axis)
166    CALL xios_send_field("field_All_Axis",field_All_Axis)
167    tsTemp = ts
168    CALL xios_send_scalar("field_Scalar", tsTemp)
169    CALL wait_us(5000) ;
170  ENDDO
171
172  CALL xios_context_finalize()
173  CALL xios_finalize()
174
175  CALL MPI_FINALIZE(ierr)
176
177CONTAINS
178  SUBROUTINE  Test_Interpolate
179
180
181  END SUBROUTINE Test_Interpolate
182
183  SUBROUTINE Distribute_index(ibegin, iend, ni, nglob, rank, size)
184    INTEGER, INTENT(INOUT) :: ibegin, iend, ni
185    INTEGER, INTENT(IN)    :: nglob, rank, size
186    DO n=0,size-1
187      ni=nglob/size
188      IF (n<MOD(nglob,size)) ni=ni+1
189      IF (n==rank) exit
190      ibegin=ibegin+ni
191    ENDDO
192    iend=ibegin+ni-1
193  END SUBROUTINE Distribute_index
194END PROGRAM test_new_features
Note: See TracBrowser for help on using the repository browser.