1 | PROGRAM test_cs |
---|
2 | IMPLICIT NONE |
---|
3 | INCLUDE "mpif.h" |
---|
4 | INTEGER :: rank |
---|
5 | INTEGER :: size |
---|
6 | INTEGER :: ierr |
---|
7 | |
---|
8 | CALL MPI_INIT(ierr) |
---|
9 | CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) |
---|
10 | CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr) |
---|
11 | |
---|
12 | IF (rank<11) THEN |
---|
13 | CALL client("client",rank,11) |
---|
14 | ELSE |
---|
15 | CALL server |
---|
16 | ENDIF |
---|
17 | |
---|
18 | |
---|
19 | CALL MPI_FINALIZE(ierr) |
---|
20 | |
---|
21 | END PROGRAM test_cs |
---|
22 | |
---|
23 | SUBROUTINE client(id,rank,size) |
---|
24 | USE xios |
---|
25 | USE mod_wait |
---|
26 | IMPLICIT NONE |
---|
27 | INCLUDE 'mpif.h' |
---|
28 | CHARACTER(len=*) :: id |
---|
29 | INTEGER :: rank |
---|
30 | INTEGER :: size |
---|
31 | INTEGER :: comm |
---|
32 | TYPE(xios_duration) :: dtime |
---|
33 | TYPE(xios_context) :: ctx_hdl |
---|
34 | INTEGER,PARAMETER :: ni_glo=100 |
---|
35 | INTEGER,PARAMETER :: nj_glo=100 |
---|
36 | INTEGER,PARAMETER :: llm=3 |
---|
37 | DOUBLE PRECISION :: lval(llm)=(/1.0,2.0,3.0/) |
---|
38 | TYPE(xios_field) :: field_hdl |
---|
39 | TYPE(xios_fieldgroup) :: fieldgroup_hdl |
---|
40 | TYPE(xios_file) :: file_hdl |
---|
41 | |
---|
42 | |
---|
43 | DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo |
---|
44 | DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) |
---|
45 | DOUBLE PRECISION,ALLOCATABLE :: lon(:),lat(:),field_A(:,:), lonvalue(:) ; |
---|
46 | LOGICAL,ALLOCATABLE :: mask(:,:) |
---|
47 | INTEGER :: ni,ibegin,iend,nj,jbegin,jend,data_ibegin,data_ni |
---|
48 | INTEGER :: i,j,k,l,ts,n,nij_begin |
---|
49 | |
---|
50 | |
---|
51 | CALL init_wait |
---|
52 | |
---|
53 | |
---|
54 | DO j=1,nj_glo |
---|
55 | DO i=1,ni_glo |
---|
56 | lon_glo(i,j)=(i-1)+(j-1)*ni_glo |
---|
57 | lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo |
---|
58 | DO l=1,llm |
---|
59 | field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l |
---|
60 | ENDDO |
---|
61 | ENDDO |
---|
62 | ENDDO |
---|
63 | ni=ni_glo ; ibegin=1 |
---|
64 | |
---|
65 | |
---|
66 | nij_begin=1 |
---|
67 | DO n=0,size-1 |
---|
68 | data_ni=(ni_glo*nj_glo)/size |
---|
69 | IF (n < MOD (ni_glo*nj_glo,size)) data_ni=data_ni+1 |
---|
70 | IF (n==rank) THEN |
---|
71 | ibegin=1 ; iend=ni_glo ; ni=iend-ibegin+1 |
---|
72 | jbegin=(nij_begin-1)/ni_glo +1 |
---|
73 | jend=MOD(nij_begin-1 + data_ni-1,ni_glo) +1 |
---|
74 | nj = jend-jbegin+1 |
---|
75 | data_ibegin=MOD(nij_begin-1,ni_glo) |
---|
76 | exit |
---|
77 | ELSE |
---|
78 | nij_begin=nij_begin+data_ni |
---|
79 | ENDIF |
---|
80 | ENDDO |
---|
81 | |
---|
82 | |
---|
83 | ALLOCATE(lon(ni),lat(nj),field_A(data_ni,llm),lonvalue(ni*nj)) |
---|
84 | ALLOCATE(mask(ni,nj)) |
---|
85 | lon(:)=lon_glo(ibegin:iend,1) |
---|
86 | lat(:)=lat_glo(1,jbegin:jend) |
---|
87 | |
---|
88 | DO k=1,data_ni |
---|
89 | n=k-1+(jbegin-1)*ni_glo+data_ibegin |
---|
90 | i=MOD(n,ni_glo)+1 |
---|
91 | j=n/ni_glo+1 |
---|
92 | field_A(k,:)=field_A_glo(i,j,:) |
---|
93 | ENDDO |
---|
94 | |
---|
95 | mask(:,:)=.TRUE. |
---|
96 | mask(1:ni,6)=.TRUE. |
---|
97 | |
---|
98 | |
---|
99 | CALL xios_initialize(id,return_comm=comm) |
---|
100 | |
---|
101 | CALL xios_context_initialize("test",comm) |
---|
102 | CALL xios_get_handle("test",ctx_hdl) |
---|
103 | 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") |
---|
110 | CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; |
---|
111 | 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) |
---|
113 | CALL xios_set_domain_attr("domain_A",data_dim=1, data_ibegin=data_ibegin, data_ni=data_ni) |
---|
114 | CALL xios_set_domain_attr("domain_A",lonvalue=lon,latvalue=lat) |
---|
115 | ! CALL xios_set_domain_attr("domain_A",mask=mask) |
---|
116 | CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) |
---|
117 | |
---|
118 | CALL xios_get_handle("field_definition",fieldgroup_hdl) |
---|
119 | CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") |
---|
120 | CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") |
---|
121 | |
---|
122 | CALL xios_get_handle("output",file_hdl) |
---|
123 | CALL xios_add_child(file_hdl,field_hdl) |
---|
124 | CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C") |
---|
125 | |
---|
126 | |
---|
127 | dtime%second=3600 |
---|
128 | CALL xios_set_context_attr("test", timestep=dtime) |
---|
129 | |
---|
130 | ! ni=0 ; lonvalue(:)=0 |
---|
131 | ! CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue=lonvalue) |
---|
132 | |
---|
133 | ! print *,"ni",ni |
---|
134 | ! print *,"lonvalue",lonvalue ; |
---|
135 | |
---|
136 | CALL xios_close_context_definition() |
---|
137 | |
---|
138 | PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") |
---|
139 | DO ts=1,24*10 |
---|
140 | CALL xios_update_calendar(ts) |
---|
141 | CALL xios_send_field("field_A",field_A) |
---|
142 | CALL wait_us(5000) ; |
---|
143 | ENDDO |
---|
144 | |
---|
145 | CALL xios_context_finalize() |
---|
146 | CALL xios_finalize() |
---|
147 | |
---|
148 | END SUBROUTINE client |
---|
149 | |
---|
150 | |
---|
151 | |
---|
152 | SUBROUTINE server |
---|
153 | USE xios |
---|
154 | IMPLICIT NONE |
---|
155 | |
---|
156 | CALL xios_init_server |
---|
157 | |
---|
158 | END SUBROUTINE server |
---|
159 | |
---|
160 | |
---|
161 | |
---|