[487] | 1 | PROGRAM test_complete |
---|
[486] | 2 | |
---|
| 3 | USE xios |
---|
| 4 | USE mod_wait |
---|
| 5 | IMPLICIT NONE |
---|
| 6 | INCLUDE "mpif.h" |
---|
[1134] | 7 | INTEGER :: rank, size |
---|
[486] | 8 | INTEGER :: size_loc |
---|
| 9 | INTEGER :: ierr |
---|
[549] | 10 | |
---|
[486] | 11 | CHARACTER(len=*),PARAMETER :: id="client" |
---|
| 12 | INTEGER :: comm |
---|
[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 |
---|
[1134] | 30 | INTEGER :: i,j,l,ts,n, nb_pt, provided |
---|
[486] | 31 | |
---|
| 32 | !!! MPI Initialization |
---|
| 33 | |
---|
[1134] | 34 | CALL MPI_INIT_THREAD(3, provided, ierr) |
---|
| 35 | if(provided .NE. 3) then |
---|
| 36 | print*, "provided thread level = ", provided |
---|
| 37 | call MPI_Abort() |
---|
| 38 | endif |
---|
[549] | 39 | |
---|
[1134] | 40 | |
---|
| 41 | |
---|
[486] | 42 | CALL init_wait |
---|
[549] | 43 | |
---|
[1134] | 44 | CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) |
---|
| 45 | CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr) |
---|
| 46 | if(rank < size-1) then |
---|
| 47 | |
---|
[486] | 48 | !!! XIOS Initialization (get the local communicator) |
---|
| 49 | |
---|
| 50 | CALL xios_initialize(id,return_comm=comm) |
---|
| 51 | |
---|
| 52 | CALL MPI_COMM_RANK(comm,rank,ierr) |
---|
[549] | 53 | CALL MPI_COMM_SIZE(comm,size_loc,ierr) |
---|
[486] | 54 | |
---|
[549] | 55 | |
---|
[486] | 56 | !########################################################################### |
---|
| 57 | ! Contexte ATM |
---|
| 58 | !########################################################################### |
---|
| 59 | |
---|
| 60 | !!! Initialisation des coordonnées globales et locales pour la grille réguliÚre |
---|
| 61 | |
---|
| 62 | DO j=1,nj_glo |
---|
| 63 | DO i=1,ni_glo |
---|
| 64 | lon_glo(i,j)=(i-1)+(j-1)*ni_glo |
---|
| 65 | lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo |
---|
| 66 | DO l=1,llm |
---|
| 67 | field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l |
---|
| 68 | ENDDO |
---|
| 69 | ENDDO |
---|
| 70 | ENDDO |
---|
[554] | 71 | ni=ni_glo ; ibegin=0 |
---|
[486] | 72 | |
---|
[554] | 73 | jbegin=0 |
---|
[486] | 74 | DO n=0,size_loc-1 |
---|
| 75 | nj=nj_glo/size_loc |
---|
| 76 | IF (n<MOD(nj_glo,size_loc)) nj=nj+1 |
---|
[549] | 77 | IF (n==rank) exit |
---|
[486] | 78 | jbegin=jbegin+nj |
---|
| 79 | ENDDO |
---|
[549] | 80 | |
---|
[486] | 81 | iend=ibegin+ni-1 ; jend=jbegin+nj-1 |
---|
| 82 | |
---|
[664] | 83 | ALLOCATE(lon(ni,nj),lat(ni,nj),field_A_atm(0:ni+1,-1:nj+2,llm),lonvalue(ni,nj)) |
---|
[554] | 84 | lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1) |
---|
| 85 | lat(:,:)=lat_glo(ibegin+1:iend+1,jbegin+1:jend+1) |
---|
| 86 | field_A_atm(1:ni,1:nj,:)=field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:) |
---|
[486] | 87 | |
---|
[549] | 88 | |
---|
[486] | 89 | !!! Context ATMOSPHERE |
---|
| 90 | |
---|
| 91 | CALL xios_context_initialize("atmosphere",comm) |
---|
| 92 | CALL xios_get_handle("atmosphere",ctx_hdl) |
---|
| 93 | CALL xios_set_current_context(ctx_hdl) |
---|
| 94 | |
---|
[549] | 95 | CALL xios_define_calendar(type="Gregorian", & |
---|
| 96 | start_date=xios_date(2000, 01, 01, 00, 00, 00), & |
---|
| 97 | time_origin=xios_date(1999, 01, 01, 15, 00, 00)) |
---|
| 98 | |
---|
[666] | 99 | CALL xios_set_axis_attr("axis_atm",n_glo=llm ,value=lval) ; |
---|
[787] | 100 | ! CALL xios_set_zoom_axis_attr("axis_atm_zoom",n=2); |
---|
[486] | 101 | |
---|
[664] | 102 | 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] | 103 | 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] | 104 | CALL xios_set_domain_attr("domain_atm",lonvalue_2D=lon,latvalue_2D=lat) |
---|
[486] | 105 | |
---|
| 106 | CALL xios_set_domain_attr("domain_atm_zoom",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) |
---|
| 107 | 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] | 108 | CALL xios_set_domain_attr("domain_atm_zoom",lonvalue_2D=lon,latvalue_2D=lat) |
---|
[787] | 109 | ! CALL xios_set_zoom_domain_attr("domain_atm_zoom",ibegin=39, ni=20, jbegin=39, nj=5) |
---|
[486] | 110 | |
---|
| 111 | !!! Activation du groupe field_definition |
---|
| 112 | |
---|
| 113 | CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) |
---|
| 114 | |
---|
[549] | 115 | !!! Création d un nouveau champ |
---|
[486] | 116 | |
---|
| 117 | CALL xios_get_handle("field_definition",fieldgroup_hdl) |
---|
| 118 | CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B_atm") |
---|
| 119 | |
---|
| 120 | !!! Heritage des attributs d un autre champ |
---|
| 121 | |
---|
[624] | 122 | CALL xios_set_attr(field_hdl,field_ref="field_A_atm_zoom",name="field_B_atm") |
---|
[549] | 123 | |
---|
[486] | 124 | !!! Affectation de ce nouveau champ au fichier avec un nouveau nom |
---|
| 125 | |
---|
| 126 | CALL xios_get_handle("output_atmosphere",file_hdl) |
---|
| 127 | CALL xios_add_child(file_hdl,field_hdl) |
---|
| 128 | CALL xios_set_attr(field_hdl,field_ref="field_B_atm",name="field_C_atm") |
---|
[549] | 129 | |
---|
[486] | 130 | !!! Definition du timestep |
---|
| 131 | |
---|
| 132 | dtime%second=3600 |
---|
[549] | 133 | CALL xios_set_timestep(timestep=dtime) |
---|
| 134 | |
---|
[486] | 135 | !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) |
---|
| 136 | |
---|
[664] | 137 | ni=0 ; lonvalue(:,:)=0 |
---|
| 138 | CALL xios_get_domain_attr("domain_atm",ni=ni,lonvalue_2D=lonvalue) |
---|
[549] | 139 | |
---|
[486] | 140 | PRINT *,"ni",ni |
---|
[664] | 141 | PRINT *,"lonvalue",lonvalue; |
---|
[486] | 142 | |
---|
| 143 | !!! Fin de la definition du contexte |
---|
| 144 | |
---|
| 145 | CALL xios_close_context_definition() |
---|
| 146 | |
---|
| 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 | |
---|
| 172 | !!! Initialisation des coordonnées globales et locales pour la grille indexee (1 point sur 2) |
---|
| 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) |
---|
| 182 | CALL xios_get_handle("surface",ctx_hdl) |
---|
| 183 | CALL xios_set_current_context(ctx_hdl) |
---|
| 184 | |
---|
[549] | 185 | CALL xios_define_calendar(type="Gregorian", & |
---|
| 186 | start_date=xios_date(2000, 01, 01, 00, 00, 00), & |
---|
| 187 | time_origin=xios_date(1999, 01, 01, 15, 00, 00)) |
---|
| 188 | |
---|
[666] | 189 | CALL xios_set_axis_attr("axis_srf",n_glo=llm ,value=lval) |
---|
[664] | 190 | 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] | 191 | CALL xios_set_domain_attr("domain_srf",data_dim=1, data_ibegin=0, data_ni=nb_pt) |
---|
[666] | 192 | CALL xios_set_domain_attr("domain_srf",data_i_index=kindex) |
---|
[664] | 193 | CALL xios_set_domain_attr("domain_srf",lonvalue_2D=lon,latvalue_2D=lat) |
---|
[486] | 194 | |
---|
[549] | 195 | !!! Création d un nouveau champ |
---|
[486] | 196 | |
---|
| 197 | CALL xios_get_handle("field_definition",fieldgroup_hdl) |
---|
| 198 | CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B_srf") |
---|
| 199 | |
---|
| 200 | !!! Heritage des attributs d un autre champ |
---|
| 201 | |
---|
| 202 | CALL xios_set_attr(field_hdl,field_ref="field_A_srf",name="field_B_srf") |
---|
[549] | 203 | |
---|
[486] | 204 | !!! Affectation de ce nouveau champ au fichier avec un nouveau nom |
---|
| 205 | |
---|
| 206 | CALL xios_get_handle("output_surface",file_hdl) |
---|
| 207 | CALL xios_add_child(file_hdl,field_hdl) |
---|
| 208 | CALL xios_set_attr(field_hdl,field_ref="field_B_srf",name="field_C_srf") |
---|
[549] | 209 | |
---|
[486] | 210 | !!! Definition du timestep |
---|
| 211 | |
---|
| 212 | dtime%second=1800 |
---|
[549] | 213 | CALL xios_set_timestep(timestep=dtime) |
---|
| 214 | |
---|
[486] | 215 | !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) |
---|
| 216 | |
---|
[664] | 217 | ni=0 ; lonvalue(:,:)=0 |
---|
| 218 | CALL xios_get_domain_attr("domain_srf",ni=ni,lonvalue_2D=lonvalue) |
---|
[549] | 219 | |
---|
[486] | 220 | PRINT *,"ni",ni |
---|
| 221 | PRINT *,"lonvalue",lonvalue ; |
---|
| 222 | |
---|
| 223 | !!! Fin de la definition du contexte SRF |
---|
| 224 | |
---|
| 225 | CALL xios_close_context_definition() |
---|
| 226 | |
---|
| 227 | |
---|
| 228 | !#################################################################################### |
---|
| 229 | !!! Boucle temporelle |
---|
| 230 | !#################################################################################### |
---|
| 231 | |
---|
[1134] | 232 | DO ts=1,24*2 |
---|
| 233 | !DO ts=1,24 |
---|
[486] | 234 | |
---|
| 235 | CALL xios_get_handle("atmosphere",ctx_hdl) |
---|
[549] | 236 | CALL xios_set_current_context(ctx_hdl) |
---|
[486] | 237 | |
---|
| 238 | !!! Mise a jour du pas de temps |
---|
| 239 | |
---|
| 240 | CALL xios_update_calendar(ts) |
---|
| 241 | |
---|
| 242 | !!! On donne la valeur du champ atm |
---|
| 243 | |
---|
| 244 | CALL xios_send_field("field_A_atm",field_A_atm) |
---|
| 245 | |
---|
| 246 | !!! On change de contexte |
---|
| 247 | |
---|
| 248 | CALL xios_get_handle("surface",ctx_hdl) |
---|
[549] | 249 | CALL xios_set_current_context(ctx_hdl) |
---|
[486] | 250 | |
---|
| 251 | !!! Mise a jour du pas de temps |
---|
| 252 | |
---|
| 253 | CALL xios_update_calendar(ts) |
---|
| 254 | |
---|
| 255 | !!! On donne la valeur du champ srf |
---|
| 256 | |
---|
| 257 | CALL xios_send_field("field_A_srf",field_A_srf) |
---|
| 258 | |
---|
| 259 | CALL wait_us(5000) ; |
---|
| 260 | ENDDO |
---|
| 261 | |
---|
| 262 | !#################################################################################### |
---|
| 263 | !!! Finalisation |
---|
| 264 | !#################################################################################### |
---|
| 265 | |
---|
| 266 | !!! Fin des contextes |
---|
[549] | 267 | |
---|
[1134] | 268 | |
---|
| 269 | CALL xios_get_handle("surface",ctx_hdl) |
---|
| 270 | |
---|
[549] | 271 | CALL xios_set_current_context(ctx_hdl) |
---|
[486] | 272 | CALL xios_context_finalize() |
---|
[549] | 273 | |
---|
[1134] | 274 | print *, "xios_context_finalize(surface)" |
---|
| 275 | |
---|
| 276 | CALL xios_get_handle("atmosphere",ctx_hdl) |
---|
| 277 | |
---|
| 278 | CALL xios_set_current_context(ctx_hdl) |
---|
| 279 | |
---|
| 280 | CALL xios_context_finalize() |
---|
| 281 | |
---|
| 282 | print *, "xios_context_finalize(atmosphere)" |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | !!! Fin de XIOS |
---|
| 287 | |
---|
| 288 | |
---|
| 289 | |
---|
| 290 | CALL xios_finalize() |
---|
| 291 | |
---|
[654] | 292 | DEALLOCATE(lon, lat, field_A_atm, lonvalue) |
---|
| 293 | DEALLOCATE(kindex, field_A_srf) |
---|
| 294 | |
---|
[1134] | 295 | print *, "Client : xios_finalize " |
---|
[486] | 296 | |
---|
[655] | 297 | CALL MPI_COMM_FREE(comm, ierr) |
---|
| 298 | |
---|
[1134] | 299 | else |
---|
[549] | 300 | |
---|
[1134] | 301 | CALL xios_init_server |
---|
| 302 | print *, "Server : xios_finalize " |
---|
| 303 | |
---|
| 304 | endif |
---|
| 305 | |
---|
| 306 | |
---|
[486] | 307 | CALL MPI_FINALIZE(ierr) |
---|
[549] | 308 | |
---|
[487] | 309 | END PROGRAM test_complete |
---|
[486] | 310 | |
---|
| 311 | |
---|
| 312 | |
---|
| 313 | |
---|
[549] | 314 | |
---|
| 315 | |
---|