source: XIOS/dev/branch_yushan/src/test/test_client.f90 @ 1067

Last change on this file since 1067 was 1067, checked in by yushan, 7 years ago

server mode OK tested with test_complete

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 5.4 KB
RevLine 
[374]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
[549]10
[374]11  CHARACTER(len=*),PARAMETER :: id="client"
12  INTEGER :: comm
[537]13  TYPE(xios_duration) :: dtime
[794]14  CHARACTER(len=20) :: dtime_str
[545]15  TYPE(xios_date) :: date
[794]16  CHARACTER(len=20) :: date_str
[550]17  CHARACTER(len=15) :: calendar_type
[374]18  TYPE(xios_context) :: ctx_hdl
[723]19  INTEGER,PARAMETER :: ni_glo=100
20  INTEGER,PARAMETER :: nj_glo=100
[549]21  INTEGER,PARAMETER :: llm=5
[432]22  DOUBLE PRECISION  :: lval(llm)=1
[374]23  TYPE(xios_field) :: field_hdl
24  TYPE(xios_fieldgroup) :: fieldgroup_hdl
25  TYPE(xios_file) :: file_hdl
[432]26  LOGICAL :: ok
[549]27
[374]28  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo
29  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm)
[665]30  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), lonvalue(:,:) ;
[374]31  INTEGER :: ni,ibegin,iend,nj,jbegin,jend
32  INTEGER :: i,j,l,ts,n
33
[455]34!!! MPI Initialization
35
[374]36  CALL MPI_INIT(ierr)
37  CALL init_wait
[1067]38
39  CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr)
40  if(rank < 2) then
[1037]41 
[455]42  CALL xios_initialize(id,return_comm=comm)
[1037]43 
44  print*, "test_client xios_initialize OK"
[455]45
46  CALL MPI_COMM_RANK(comm,rank,ierr)
[1053]47  print*, "test_client MPI_COMM_RANK OK", rank
[549]48  CALL MPI_COMM_SIZE(comm,size,ierr)
[1053]49  print*, "test_client MPI_COMM_SIZE OK", size
[1037]50 
[549]51
[374]52  DO j=1,nj_glo
53    DO i=1,ni_glo
54      lon_glo(i,j)=(i-1)+(j-1)*ni_glo
55      lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo
56      DO l=1,llm
57        field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l
58      ENDDO
59    ENDDO
60  ENDDO
[554]61  ni=ni_glo ; ibegin=0
[374]62
[554]63  jbegin=0
[374]64  DO n=0,size-1
65    nj=nj_glo/size
66    IF (n<MOD(nj_glo,size)) nj=nj+1
[549]67    IF (n==rank) exit
[374]68    jbegin=jbegin+nj
69  ENDDO
[549]70
[374]71  iend=ibegin+ni-1 ; jend=jbegin+nj-1
72
[665]73  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni,nj))
[554]74  lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1)
75  lat(:,:)=lat_glo(ibegin+1:iend+1,jbegin+1:jend+1)
76  field_A(1:ni,1:nj,:)=field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:)
[1037]77 
78  CALL xios_context_initialize("test",comm)
[549]79
[374]80  CALL xios_get_handle("test",ctx_hdl)
[1037]81  print*, "Client xios_get_handle OK"
[374]82  CALL xios_set_current_context(ctx_hdl)
[1037]83  print*, "Client xios_set_current_handle OK" 
84 
85 
86 
87 
[549]88  CALL xios_get_calendar_type(calendar_type)
89  PRINT *, "calendar_type = ", calendar_type
90
[666]91  CALL xios_set_axis_attr("axis_A",n_glo=llm ,value=lval) ;
[664]92  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj,type='curvilinear')
[374]93  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4)
[668]94  CALL xios_set_domain_attr("domain_A",lonvalue_2D=lon,latvalue_2D=lat)
[374]95  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.)
[549]96
[374]97  CALL xios_get_handle("field_definition",fieldgroup_hdl)
98  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B")
99  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B")
[549]100
[374]101  CALL xios_get_handle("output",file_hdl)
102  CALL xios_add_child(file_hdl,field_hdl)
[624]103  CALL xios_set_attr(field_hdl,field_ref="field_A_zoom",name="field_C")
[1037]104 
[545]105  dtime%second = 3600
[549]106  CALL xios_set_timestep(dtime)
[1037]107  print*, "Client xios_set_timestep OK" 
[374]108
[549]109  ! The calendar is created as soon as the calendar type is defined. This way
110  ! calendar operations can be used before the context definition is closed
111  CALL xios_get_time_origin(date)
112  PRINT *, "--> year length = ", xios_get_year_length_in_seconds(date%year)
113  PRINT *, "--> day length = ", xios_get_day_length_in_seconds()
[794]114  CALL xios_date_convert_to_string(date, date_str)
115  PRINT *, "time_origin = ", date_str
[549]116  PRINT *, "xios_date_get_second_of_year(time_origin) = ", xios_date_get_second_of_year(date)
117  PRINT *, "xios_date_get_day_of_year(time_origin) = ", xios_date_get_day_of_year(date)
118  PRINT *, "xios_date_get_fraction_of_year(time_origin) = ", xios_date_get_fraction_of_year(date)
119  PRINT *, "xios_date_get_second_of_day(time_origin) = ", xios_date_get_second_of_day(date)
120  PRINT *, "xios_date_get_fraction_of_day(time_origin) = ", xios_date_get_fraction_of_day(date)
[545]121  dtime%timestep = 1
122  dtime = 0.5 * dtime
[794]123  CALL xios_duration_convert_to_string(dtime, dtime_str)
124  PRINT *, "duration = ", dtime_str
[545]125  date = date + 3 * (dtime + dtime)
[794]126  CALL xios_date_convert_to_string(date, date_str)
127  PRINT *, "date = time_origin + 3 * (duration + duration) = ", date_str
[545]128  PRINT *, "xios_date_convert_to_seconds(date) = ", xios_date_convert_to_seconds(date)
129  PRINT *, "xios_date_convert_to_seconds(date - 2.5h) = ", xios_date_convert_to_seconds(date - 2.5 * xios_hour)
[549]130
[665]131  ni=0 ; lonvalue(:,:)=0;
[668]132  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue_2D=lonvalue)
[545]133  print *,"ni",ni
[1037]134  !print *,"lonvalue",lonvalue;
[545]135
136  CALL xios_is_defined_field_attr("field_A",enabled=ok)
137  PRINT *,"field_A : attribute enabled is defined ? ",ok
[1037]138 
[545]139  CALL xios_close_context_definition()
[1037]140  print*, "xios_close_context_definition OK" 
[549]141
[545]142  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A")
[1056]143
144
145  call MPI_Barrier(comm, ierr)
146  PRINT*,"MPI_Barrier OK "
147
[1037]148  !DO ts=1,24*10
[1053]149  DO ts=1,6
[545]150    CALL xios_update_calendar(ts)
[1037]151    print*, "xios_update_calendar OK, ts = ", ts
[545]152    CALL xios_send_field("field_A",field_A)
[1037]153    print*, "xios_send_field OK, ts = ", ts
154    CALL wait_us(5000)
[545]155  ENDDO
[1037]156 
[545]157
[1057]158  CALL xios_context_finalize()
[1037]159  print*, "xios_context_finalize OK" 
[654]160
161  DEALLOCATE(lon, lat, field_A, lonvalue)
162
[655]163  CALL MPI_COMM_FREE(comm, ierr)
164
[545]165  CALL xios_finalize()
[549]166
[1067]167   else
168
169   CALL xios_init_server
170 
171   endif
172   
173
[374]174  CALL MPI_FINALIZE(ierr)
[549]175
[374]176END PROGRAM test_client
177
178
179
[549]180
181
Note: See TracBrowser for help on using the repository browser.