[487] | 1 | PROGRAM test_complete |
---|
[486] | 2 | |
---|
| 3 | USE xios |
---|
| 4 | USE mod_wait |
---|
| 5 | IMPLICIT NONE |
---|
| 6 | INCLUDE "mpif.h" |
---|
| 7 | INTEGER :: rank |
---|
| 8 | INTEGER :: size_loc |
---|
| 9 | INTEGER :: ierr |
---|
[549] | 10 | |
---|
[486] | 11 | CHARACTER(len=*),PARAMETER :: id="client" |
---|
[1067] | 12 | INTEGER :: comm, comm2 |
---|
[537] | 13 | TYPE(xios_duration) :: dtime |
---|
[486] | 14 | TYPE(xios_context) :: ctx_hdl |
---|
| 15 | INTEGER,PARAMETER :: ni_glo=100 |
---|
[549] | 16 | INTEGER,PARAMETER :: nj_glo=100 |
---|
| 17 | INTEGER,PARAMETER :: llm=5 |
---|
[486] | 18 | DOUBLE PRECISION :: lval(llm)=1 |
---|
| 19 | TYPE(xios_field) :: field_hdl |
---|
| 20 | TYPE(xios_fieldgroup) :: fieldgroup_hdl |
---|
| 21 | TYPE(xios_file) :: file_hdl |
---|
| 22 | LOGICAL :: ok |
---|
| 23 | CHARACTER(len=256) :: crname |
---|
| 24 | |
---|
| 25 | DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo |
---|
| 26 | DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) |
---|
[664] | 27 | DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A_atm(:,:,:), field_A_srf(:,:), lonvalue(:,:) |
---|
[486] | 28 | INTEGER, ALLOCATABLE :: kindex(:) |
---|
| 29 | INTEGER :: ni,ibegin,iend,nj,jbegin,jend |
---|
| 30 | INTEGER :: i,j,l,ts,n, nb_pt |
---|
| 31 | |
---|
| 32 | !!! MPI Initialization |
---|
| 33 | |
---|
| 34 | CALL MPI_INIT(ierr) |
---|
[549] | 35 | |
---|
[1069] | 36 | CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | |
---|
[486] | 40 | CALL init_wait |
---|
[549] | 41 | |
---|
[1069] | 42 | if (rank <2) then |
---|
| 43 | |
---|
[486] | 44 | !!! XIOS Initialization (get the local communicator) |
---|
| 45 | |
---|
| 46 | CALL xios_initialize(id,return_comm=comm) |
---|
| 47 | |
---|
| 48 | CALL MPI_COMM_RANK(comm,rank,ierr) |
---|
[549] | 49 | CALL MPI_COMM_SIZE(comm,size_loc,ierr) |
---|
[486] | 50 | |
---|
[549] | 51 | |
---|
[486] | 52 | !########################################################################### |
---|
| 53 | ! Contexte ATM |
---|
| 54 | !########################################################################### |
---|
| 55 | |
---|
[1067] | 56 | !!! Initialisation des coordonnes globales et locales pour la grille rgulire |
---|
[486] | 57 | |
---|
| 58 | DO j=1,nj_glo |
---|
| 59 | DO i=1,ni_glo |
---|
| 60 | lon_glo(i,j)=(i-1)+(j-1)*ni_glo |
---|
| 61 | lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo |
---|
| 62 | DO l=1,llm |
---|
| 63 | field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l |
---|
| 64 | ENDDO |
---|
| 65 | ENDDO |
---|
| 66 | ENDDO |
---|
[554] | 67 | ni=ni_glo ; ibegin=0 |
---|
[486] | 68 | |
---|
[554] | 69 | jbegin=0 |
---|
[486] | 70 | DO n=0,size_loc-1 |
---|
| 71 | nj=nj_glo/size_loc |
---|
| 72 | IF (n<MOD(nj_glo,size_loc)) nj=nj+1 |
---|
[549] | 73 | IF (n==rank) exit |
---|
[486] | 74 | jbegin=jbegin+nj |
---|
| 75 | ENDDO |
---|
[549] | 76 | |
---|
[486] | 77 | iend=ibegin+ni-1 ; jend=jbegin+nj-1 |
---|
| 78 | |
---|
[664] | 79 | ALLOCATE(lon(ni,nj),lat(ni,nj),field_A_atm(0:ni+1,-1:nj+2,llm),lonvalue(ni,nj)) |
---|
[554] | 80 | lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1) |
---|
| 81 | lat(:,:)=lat_glo(ibegin+1:iend+1,jbegin+1:jend+1) |
---|
| 82 | field_A_atm(1:ni,1:nj,:)=field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:) |
---|
[486] | 83 | |
---|
[549] | 84 | |
---|
[486] | 85 | !!! Context ATMOSPHERE |
---|
| 86 | |
---|
| 87 | CALL xios_context_initialize("atmosphere",comm) |
---|
[1069] | 88 | ! print*, "init context atmosphere comm = ", comm |
---|
[1067] | 89 | |
---|
[486] | 90 | CALL xios_get_handle("atmosphere",ctx_hdl) |
---|
| 91 | CALL xios_set_current_context(ctx_hdl) |
---|
| 92 | |
---|
[549] | 93 | CALL xios_define_calendar(type="Gregorian", & |
---|
| 94 | start_date=xios_date(2000, 01, 01, 00, 00, 00), & |
---|
| 95 | time_origin=xios_date(1999, 01, 01, 15, 00, 00)) |
---|
| 96 | |
---|
[666] | 97 | CALL xios_set_axis_attr("axis_atm",n_glo=llm ,value=lval) ; |
---|
[787] | 98 | ! CALL xios_set_zoom_axis_attr("axis_atm_zoom",n=2); |
---|
[486] | 99 | |
---|
[664] | 100 | CALL xios_set_domain_attr("domain_atm",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj, type='curvilinear') |
---|
[486] | 101 | CALL xios_set_domain_attr("domain_atm",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) |
---|
[664] | 102 | CALL xios_set_domain_attr("domain_atm",lonvalue_2D=lon,latvalue_2D=lat) |
---|
[486] | 103 | |
---|
| 104 | CALL xios_set_domain_attr("domain_atm_zoom",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) |
---|
| 105 | CALL xios_set_domain_attr("domain_atm_zoom",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) |
---|
[664] | 106 | CALL xios_set_domain_attr("domain_atm_zoom",lonvalue_2D=lon,latvalue_2D=lat) |
---|
[787] | 107 | ! CALL xios_set_zoom_domain_attr("domain_atm_zoom",ibegin=39, ni=20, jbegin=39, nj=5) |
---|
[486] | 108 | |
---|
| 109 | !!! Activation du groupe field_definition |
---|
| 110 | |
---|
| 111 | CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) |
---|
| 112 | |
---|
[1067] | 113 | !!! Cration d un nouveau champ |
---|
[486] | 114 | |
---|
| 115 | CALL xios_get_handle("field_definition",fieldgroup_hdl) |
---|
| 116 | CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B_atm") |
---|
| 117 | |
---|
| 118 | !!! Heritage des attributs d un autre champ |
---|
| 119 | |
---|
[624] | 120 | CALL xios_set_attr(field_hdl,field_ref="field_A_atm_zoom",name="field_B_atm") |
---|
[549] | 121 | |
---|
[486] | 122 | !!! Affectation de ce nouveau champ au fichier avec un nouveau nom |
---|
| 123 | |
---|
| 124 | CALL xios_get_handle("output_atmosphere",file_hdl) |
---|
| 125 | CALL xios_add_child(file_hdl,field_hdl) |
---|
| 126 | CALL xios_set_attr(field_hdl,field_ref="field_B_atm",name="field_C_atm") |
---|
[549] | 127 | |
---|
[486] | 128 | !!! Definition du timestep |
---|
| 129 | |
---|
| 130 | dtime%second=3600 |
---|
[549] | 131 | CALL xios_set_timestep(timestep=dtime) |
---|
| 132 | |
---|
[1067] | 133 | !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalit) |
---|
[486] | 134 | |
---|
[664] | 135 | ni=0 ; lonvalue(:,:)=0 |
---|
| 136 | CALL xios_get_domain_attr("domain_atm",ni=ni,lonvalue_2D=lonvalue) |
---|
[549] | 137 | |
---|
[1058] | 138 | !PRINT *,"ni",ni |
---|
| 139 | !PRINT *,"lonvalue",lonvalue; |
---|
[486] | 140 | |
---|
| 141 | !!! Fin de la definition du contexte |
---|
| 142 | |
---|
| 143 | CALL xios_close_context_definition() |
---|
| 144 | |
---|
[1069] | 145 | ! print *, "xios_close_context_definition(atmosphere)" |
---|
[1058] | 146 | |
---|
[486] | 147 | !!! Test des valeurs des champs/fichiers |
---|
| 148 | |
---|
[549] | 149 | !!! Attribut defini ? |
---|
| 150 | |
---|
[486] | 151 | CALL xios_is_defined_field_attr("field_A_atm",enabled=ok) |
---|
| 152 | PRINT *,"field_A_atm : attribute enabled is defined ? ",ok |
---|
| 153 | |
---|
| 154 | !!! Recuperer la valeur d un attribut |
---|
[549] | 155 | |
---|
[486] | 156 | CALL xios_get_field_attr("field_A_atm",name=crname) |
---|
| 157 | PRINT *,"field_A_atm : attribute name is : ",TRIM(crname) |
---|
| 158 | |
---|
[549] | 159 | !!! Champ actif (besoin de fournir la valeur) ? |
---|
[486] | 160 | |
---|
| 161 | PRINT*,"field field_A_atm is active ? ",xios_field_is_active("field_A_atm") |
---|
| 162 | |
---|
| 163 | !!! Champ defini ? |
---|
| 164 | |
---|
| 165 | PRINT*,"field field_A_atm is valid ?",xios_is_valid_field("field_A_atm") |
---|
| 166 | |
---|
| 167 | |
---|
| 168 | !########################################################################### |
---|
| 169 | ! Contexte SRF |
---|
| 170 | !########################################################################### |
---|
| 171 | |
---|
[1067] | 172 | !!! Initialisation des coordonnes globales et locales pour la grille indexee (1 point sur 2) |
---|
[486] | 173 | |
---|
| 174 | nb_pt=ni*nj/2 |
---|
| 175 | ALLOCATE(kindex(nb_pt),field_A_srf(nb_pt,llm)) |
---|
| 176 | DO i=1,nb_pt |
---|
| 177 | kindex(i)=2*i-1 |
---|
| 178 | ENDDO |
---|
[554] | 179 | field_A_srf(1:nb_pt,:)=RESHAPE(field_A_glo(ibegin+1:iend+1:2,jbegin+1:jend+1,:),(/ nb_pt,llm /)) |
---|
[486] | 180 | |
---|
| 181 | CALL xios_context_initialize("surface",comm) |
---|
[1069] | 182 | ! print*, "init context surface comm = ", comm |
---|
[1067] | 183 | |
---|
[486] | 184 | CALL xios_get_handle("surface",ctx_hdl) |
---|
| 185 | CALL xios_set_current_context(ctx_hdl) |
---|
| 186 | |
---|
[549] | 187 | CALL xios_define_calendar(type="Gregorian", & |
---|
| 188 | start_date=xios_date(2000, 01, 01, 00, 00, 00), & |
---|
| 189 | time_origin=xios_date(1999, 01, 01, 15, 00, 00)) |
---|
| 190 | |
---|
[666] | 191 | CALL xios_set_axis_attr("axis_srf",n_glo=llm ,value=lval) |
---|
[664] | 192 | CALL xios_set_domain_attr("domain_srf",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj, type='curvilinear') |
---|
[486] | 193 | CALL xios_set_domain_attr("domain_srf",data_dim=1, data_ibegin=0, data_ni=nb_pt) |
---|
[666] | 194 | CALL xios_set_domain_attr("domain_srf",data_i_index=kindex) |
---|
[664] | 195 | CALL xios_set_domain_attr("domain_srf",lonvalue_2D=lon,latvalue_2D=lat) |
---|
[486] | 196 | |
---|
[1067] | 197 | !!! Cration d un nouveau champ |
---|
[486] | 198 | |
---|
| 199 | CALL xios_get_handle("field_definition",fieldgroup_hdl) |
---|
| 200 | CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B_srf") |
---|
| 201 | |
---|
| 202 | !!! Heritage des attributs d un autre champ |
---|
| 203 | |
---|
| 204 | CALL xios_set_attr(field_hdl,field_ref="field_A_srf",name="field_B_srf") |
---|
[549] | 205 | |
---|
[486] | 206 | !!! Affectation de ce nouveau champ au fichier avec un nouveau nom |
---|
| 207 | |
---|
| 208 | CALL xios_get_handle("output_surface",file_hdl) |
---|
| 209 | CALL xios_add_child(file_hdl,field_hdl) |
---|
| 210 | CALL xios_set_attr(field_hdl,field_ref="field_B_srf",name="field_C_srf") |
---|
[549] | 211 | |
---|
[486] | 212 | !!! Definition du timestep |
---|
| 213 | |
---|
| 214 | dtime%second=1800 |
---|
[549] | 215 | CALL xios_set_timestep(timestep=dtime) |
---|
| 216 | |
---|
[1067] | 217 | !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalit) |
---|
[486] | 218 | |
---|
[664] | 219 | ni=0 ; lonvalue(:,:)=0 |
---|
| 220 | CALL xios_get_domain_attr("domain_srf",ni=ni,lonvalue_2D=lonvalue) |
---|
[549] | 221 | |
---|
[1058] | 222 | !PRINT *,"ni",ni |
---|
| 223 | !PRINT *,"lonvalue",lonvalue ; |
---|
[486] | 224 | |
---|
| 225 | !!! Fin de la definition du contexte SRF |
---|
| 226 | |
---|
| 227 | CALL xios_close_context_definition() |
---|
| 228 | |
---|
[1069] | 229 | ! print *, "xios_close_context_definition(surface)" |
---|
[486] | 230 | |
---|
[1058] | 231 | |
---|
[486] | 232 | !#################################################################################### |
---|
| 233 | !!! Boucle temporelle |
---|
| 234 | !#################################################################################### |
---|
| 235 | |
---|
[1067] | 236 | DO ts=1,24*10 |
---|
| 237 | !DO ts=1,24 |
---|
[486] | 238 | |
---|
| 239 | CALL xios_get_handle("atmosphere",ctx_hdl) |
---|
[549] | 240 | CALL xios_set_current_context(ctx_hdl) |
---|
[486] | 241 | |
---|
| 242 | !!! Mise a jour du pas de temps |
---|
| 243 | |
---|
| 244 | CALL xios_update_calendar(ts) |
---|
| 245 | |
---|
| 246 | !!! On donne la valeur du champ atm |
---|
| 247 | |
---|
| 248 | CALL xios_send_field("field_A_atm",field_A_atm) |
---|
| 249 | |
---|
| 250 | !!! On change de contexte |
---|
| 251 | |
---|
| 252 | CALL xios_get_handle("surface",ctx_hdl) |
---|
[549] | 253 | CALL xios_set_current_context(ctx_hdl) |
---|
[486] | 254 | |
---|
| 255 | !!! Mise a jour du pas de temps |
---|
| 256 | |
---|
| 257 | CALL xios_update_calendar(ts) |
---|
| 258 | |
---|
| 259 | !!! On donne la valeur du champ srf |
---|
| 260 | |
---|
| 261 | CALL xios_send_field("field_A_srf",field_A_srf) |
---|
| 262 | |
---|
| 263 | CALL wait_us(5000) ; |
---|
[1058] | 264 | |
---|
| 265 | |
---|
[486] | 266 | ENDDO |
---|
| 267 | |
---|
[1069] | 268 | ! print *, "end temporal loop" |
---|
[1058] | 269 | |
---|
[486] | 270 | !#################################################################################### |
---|
| 271 | !!! Finalisation |
---|
| 272 | !#################################################################################### |
---|
| 273 | |
---|
| 274 | !!! Fin des contextes |
---|
[549] | 275 | |
---|
[1067] | 276 | !print *, "start : xios_context_finalize(surface)" |
---|
[1058] | 277 | |
---|
| 278 | CALL xios_get_handle("surface",ctx_hdl) |
---|
[1067] | 279 | !print *, "xios_get_handle (surface) OK" |
---|
[1058] | 280 | CALL xios_set_current_context(ctx_hdl) |
---|
[1067] | 281 | !print *, "xios_set_current_context (surface) OK" |
---|
[486] | 282 | CALL xios_context_finalize() |
---|
[1058] | 283 | |
---|
[1069] | 284 | ! print *, "xios_context_finalize(surface)" |
---|
[1058] | 285 | |
---|
[1067] | 286 | CALL xios_get_handle("atmosphere",ctx_hdl) |
---|
| 287 | ! !print *, "xios_get_handle (atmosphere) OK" |
---|
| 288 | CALL xios_set_current_context(ctx_hdl) |
---|
| 289 | ! !print *, "xios_set_current_context (atmosphere) OK" |
---|
| 290 | CALL xios_context_finalize() |
---|
[549] | 291 | |
---|
[1069] | 292 | ! print *, "xios_context_finalize(atmosphere)" |
---|
[1058] | 293 | |
---|
[654] | 294 | DEALLOCATE(lon, lat, field_A_atm, lonvalue) |
---|
[1067] | 295 | ! DEALLOCATE(kindex, field_A_srf) |
---|
[654] | 296 | |
---|
[486] | 297 | !!! Fin de XIOS |
---|
| 298 | |
---|
[655] | 299 | CALL MPI_COMM_FREE(comm, ierr) |
---|
| 300 | |
---|
[486] | 301 | CALL xios_finalize() |
---|
[549] | 302 | |
---|
[1069] | 303 | print *, "Client : xios_finalize " |
---|
[1058] | 304 | |
---|
[1069] | 305 | else |
---|
| 306 | CALL xios_init_server |
---|
| 307 | |
---|
| 308 | print *, "Server : xios_finalize " |
---|
| 309 | endif |
---|
| 310 | |
---|
[486] | 311 | CALL MPI_FINALIZE(ierr) |
---|
[549] | 312 | |
---|
[487] | 313 | END PROGRAM test_complete |
---|
[486] | 314 | |
---|
| 315 | |
---|
| 316 | |
---|
| 317 | |
---|
[549] | 318 | |
---|
| 319 | |
---|