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

Last change on this file since 587 was 587, checked in by mhnguyen, 7 years ago

Correcting some issues because of merging code

+) Correct Fortran interface
+) Make a new interface for function sending a scalar

Test
+) On Curie:
+) Mode attached and connected
+) test_client and test_complete are correct

  • Property svn:executable set to *
File size: 5.7 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
26  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo
27  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm), lval_ni(ni_glo), lval_nj(nj_glo)
28  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), field_All_Axis(:,:,:), lonvalue(:) , field_Axis(:)
29  INTEGER :: ni,ibegin,iend,nj,jbegin,jend, nAxis, axisBegin, axisEnd
30  INTEGER :: i,j,l,ts,n
31
32!!! MPI Initialization
33
34  CALL MPI_INIT(ierr)
35
36  CALL init_wait
37
38!!! XIOS Initialization (get the local communicator)
39
40  CALL xios_initialize(id,return_comm=comm)
41
42  CALL MPI_COMM_RANK(comm,rank,ierr)
43  CALL MPI_COMM_SIZE(comm,size,ierr)
44
45  DO j=1,nj_glo
46    DO i=1,ni_glo
47      lon_glo(i,j)=(i-1)+(j-1)*ni_glo
48      lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo
49      lval_ni(i) = i-1
50      DO l=1,llm
51        field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l
52      ENDDO
53    ENDDO
54    lval_nj(j) = j-1
55  ENDDO
56  ni=ni_glo ; ibegin=0
57
58  jbegin=0
59  DO n=0,size-1
60    nj=nj_glo/size
61    IF (n<MOD(nj_glo,size)) nj=nj+1
62    IF (n==rank) exit
63    jbegin=jbegin+nj
64  ENDDO
65  iend=ibegin+ni-1 ; jend=jbegin+nj-1
66
67  axisBegin = 0
68  nAxis = llm
69!  DO n=0, size -1
70!    nAxis = llm/size
71!    IF (n<MOD(llm,size)) nAxis=nAxis+1
72!    IF (n==rank) exit
73!    axisBegin=axisBegin+nAxis
74!  ENDDO
75  axisEnd=axisBegin+nAxis-1
76
77  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))
78  lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1)
79  lat(:,:)=lat_glo(ibegin+1:iend+1,jbegin+1:jend+1)
80  field_A(1:ni,1:nj,:) = field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:)
81  field_Axis(1:nAxis)  = field_A_glo(1,1,axisBegin+1:axisEnd+1)
82  field_All_Axis(1:ni,1:nj,:) = field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:)
83
84  CALL xios_context_initialize("test",comm)
85  CALL xios_get_handle("test",ctx_hdl)
86  CALL xios_set_current_context(ctx_hdl)
87
88  CALL xios_get_calendar_type(calendar_type)
89  PRINT *, "calendar_type = ", calendar_type
90
91  CALL xios_set_axis_attr("axis_A", size=ni_glo, ibegin=ibegin, ni=ni, value=lval_ni)
92  CALL xios_set_axis_attr("axis_B", size=nj_glo, ibegin=jbegin, ni=nj, value=lval_nj)
93  CALL xios_set_axis_attr("axis_C", size=llm, value=lval)
94  CALL xios_set_axis_attr("axis_D", size=llm, ibegin=axisBegin, ni=nAxis, value=lval)
95  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj)
96  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4)
97  CALL xios_set_domain_attr("domain_A",lonvalue=RESHAPE(lon,(/ni*nj/)),latvalue=RESHAPE(lat,(/ni*nj/)))
98  CALL xios_set_domain_attr("domain_A",zoom_ibegin=40, zoom_ni=20, zoom_jbegin=40, zoom_nj=10)
99  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.)
100
101  CALL xios_get_handle("field_definition",fieldgroup_hdl)
102  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B")
103  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B")
104
105  CALL xios_get_handle("output",file_hdl)
106  CALL xios_add_child(file_hdl,field_hdl)
107  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C")
108
109  CALL xios_get_handle("output_All_Axis",file_hdl)
110  CALL xios_add_child(file_hdl,field_hdl)
111  CALL xios_set_attr(field_hdl,field_ref="field_All_Axis",name="field_C")
112
113  dtime%second = 3600
114  CALL xios_set_timestep(dtime)
115
116  ! The calendar is created as soon as the calendar type is defined. This way
117  ! calendar operations can be used before the context definition is closed
118  CALL xios_get_time_origin(date)
119  PRINT *, "--> year length = ", xios_get_year_length_in_seconds(date%year)
120  PRINT *, "--> day length = ", xios_get_day_length_in_seconds()
121  PRINT *, "time_origin = ", date
122  PRINT *, "xios_date_get_second_of_year(time_origin) = ", xios_date_get_second_of_year(date)
123  PRINT *, "xios_date_get_day_of_year(time_origin) = ", xios_date_get_day_of_year(date)
124  PRINT *, "xios_date_get_fraction_of_year(time_origin) = ", xios_date_get_fraction_of_year(date)
125  PRINT *, "xios_date_get_second_of_day(time_origin) = ", xios_date_get_second_of_day(date)
126  PRINT *, "xios_date_get_fraction_of_day(time_origin) = ", xios_date_get_fraction_of_day(date)
127  dtime%timestep = 1
128  dtime = 0.5 * dtime
129  PRINT *, "duration = ", dtime
130  date = date + 3 * (dtime + dtime)
131  PRINT *, "date = time_origin + 3 * (duration + duration) = ", date
132  PRINT *, "xios_date_convert_to_seconds(date) = ", xios_date_convert_to_seconds(date)
133  PRINT *, "xios_date_convert_to_seconds(date - 2.5h) = ", xios_date_convert_to_seconds(date - 2.5 * xios_hour)
134
135  ni=0 ; lonvalue(:)=0
136  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue)
137
138!  print *,"ni",ni
139!  print *,"lonvalue",lonvalue ;
140
141  CALL xios_is_defined_field_attr("field_A",enabled=ok)
142  PRINT *,"field_A : attribute enabled is defined ? ",ok
143  CALL xios_close_context_definition()
144
145  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A")
146  DO ts=1,24*10
147    CALL xios_update_calendar(ts)
148    CALL xios_send_field("field_A",field_A)
149    CALL xios_send_field("field_Axis",field_Axis)
150    CALL xios_send_field("field_All_Axis",field_All_Axis)
151    tsTemp = ts
152    CALL xios_send_scalar("field_Scalar", tsTemp)
153    CALL wait_us(5000) ;
154  ENDDO
155
156  CALL xios_context_finalize()
157  CALL xios_finalize()
158
159  CALL MPI_FINALIZE(ierr)
160
161END PROGRAM test_new_features
162
163
164
165
166
Note: See TracBrowser for help on using the repository browser.