[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" |
---|
| 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 |
---|
| 30 | INTEGER :: i,j,l,ts,n, nb_pt |
---|
| 31 | |
---|
| 32 | !!! MPI Initialization |
---|
| 33 | |
---|
| 34 | CALL MPI_INIT(ierr) |
---|
[549] | 35 | |
---|
[486] | 36 | CALL init_wait |
---|
[549] | 37 | |
---|
[486] | 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) |
---|
[549] | 43 | CALL MPI_COMM_SIZE(comm,size_loc,ierr) |
---|
[486] | 44 | |
---|
[549] | 45 | |
---|
[486] | 46 | !########################################################################### |
---|
| 47 | ! Contexte ATM |
---|
| 48 | !########################################################################### |
---|
| 49 | |
---|
| 50 | !!! Initialisation des coordonnées globales et locales pour la grille réguliÚre |
---|
| 51 | |
---|
| 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 |
---|
[486] | 62 | |
---|
[554] | 63 | jbegin=0 |
---|
[486] | 64 | DO n=0,size_loc-1 |
---|
| 65 | nj=nj_glo/size_loc |
---|
| 66 | IF (n<MOD(nj_glo,size_loc)) nj=nj+1 |
---|
[549] | 67 | IF (n==rank) exit |
---|
[486] | 68 | jbegin=jbegin+nj |
---|
| 69 | ENDDO |
---|
[549] | 70 | |
---|
[486] | 71 | iend=ibegin+ni-1 ; jend=jbegin+nj-1 |
---|
| 72 | |
---|
[664] | 73 | ALLOCATE(lon(ni,nj),lat(ni,nj),field_A_atm(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_atm(1:ni,1:nj,:)=field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:) |
---|
[486] | 77 | |
---|
[549] | 78 | |
---|
[486] | 79 | !!! Context ATMOSPHERE |
---|
| 80 | |
---|
| 81 | CALL xios_context_initialize("atmosphere",comm) |
---|
| 82 | CALL xios_get_handle("atmosphere",ctx_hdl) |
---|
| 83 | CALL xios_set_current_context(ctx_hdl) |
---|
| 84 | |
---|
[549] | 85 | CALL xios_define_calendar(type="Gregorian", & |
---|
| 86 | start_date=xios_date(2000, 01, 01, 00, 00, 00), & |
---|
| 87 | time_origin=xios_date(1999, 01, 01, 15, 00, 00)) |
---|
| 88 | |
---|
[666] | 89 | CALL xios_set_axis_attr("axis_atm",n_glo=llm ,value=lval) ; |
---|
[787] | 90 | ! CALL xios_set_zoom_axis_attr("axis_atm_zoom",n=2); |
---|
[486] | 91 | |
---|
[664] | 92 | 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] | 93 | 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] | 94 | CALL xios_set_domain_attr("domain_atm",lonvalue_2D=lon,latvalue_2D=lat) |
---|
[486] | 95 | |
---|
| 96 | CALL xios_set_domain_attr("domain_atm_zoom",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) |
---|
| 97 | 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] | 98 | CALL xios_set_domain_attr("domain_atm_zoom",lonvalue_2D=lon,latvalue_2D=lat) |
---|
[787] | 99 | ! CALL xios_set_zoom_domain_attr("domain_atm_zoom",ibegin=39, ni=20, jbegin=39, nj=5) |
---|
[486] | 100 | |
---|
| 101 | !!! Activation du groupe field_definition |
---|
| 102 | |
---|
| 103 | CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) |
---|
| 104 | |
---|
[549] | 105 | !!! Création d un nouveau champ |
---|
[486] | 106 | |
---|
| 107 | CALL xios_get_handle("field_definition",fieldgroup_hdl) |
---|
| 108 | CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B_atm") |
---|
| 109 | |
---|
| 110 | !!! Heritage des attributs d un autre champ |
---|
| 111 | |
---|
[624] | 112 | CALL xios_set_attr(field_hdl,field_ref="field_A_atm_zoom",name="field_B_atm") |
---|
[549] | 113 | |
---|
[486] | 114 | !!! Affectation de ce nouveau champ au fichier avec un nouveau nom |
---|
| 115 | |
---|
| 116 | CALL xios_get_handle("output_atmosphere",file_hdl) |
---|
| 117 | CALL xios_add_child(file_hdl,field_hdl) |
---|
| 118 | CALL xios_set_attr(field_hdl,field_ref="field_B_atm",name="field_C_atm") |
---|
[549] | 119 | |
---|
[486] | 120 | !!! Definition du timestep |
---|
| 121 | |
---|
| 122 | dtime%second=3600 |
---|
[549] | 123 | CALL xios_set_timestep(timestep=dtime) |
---|
| 124 | |
---|
[486] | 125 | !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) |
---|
| 126 | |
---|
[664] | 127 | ni=0 ; lonvalue(:,:)=0 |
---|
| 128 | CALL xios_get_domain_attr("domain_atm",ni=ni,lonvalue_2D=lonvalue) |
---|
[549] | 129 | |
---|
[486] | 130 | PRINT *,"ni",ni |
---|
[664] | 131 | PRINT *,"lonvalue",lonvalue; |
---|
[486] | 132 | |
---|
| 133 | !!! Fin de la definition du contexte |
---|
| 134 | |
---|
| 135 | CALL xios_close_context_definition() |
---|
| 136 | |
---|
| 137 | !!! Test des valeurs des champs/fichiers |
---|
| 138 | |
---|
[549] | 139 | !!! Attribut defini ? |
---|
| 140 | |
---|
[486] | 141 | CALL xios_is_defined_field_attr("field_A_atm",enabled=ok) |
---|
| 142 | PRINT *,"field_A_atm : attribute enabled is defined ? ",ok |
---|
| 143 | |
---|
| 144 | !!! Recuperer la valeur d un attribut |
---|
[549] | 145 | |
---|
[486] | 146 | CALL xios_get_field_attr("field_A_atm",name=crname) |
---|
| 147 | PRINT *,"field_A_atm : attribute name is : ",TRIM(crname) |
---|
| 148 | |
---|
[549] | 149 | !!! Champ actif (besoin de fournir la valeur) ? |
---|
[486] | 150 | |
---|
| 151 | PRINT*,"field field_A_atm is active ? ",xios_field_is_active("field_A_atm") |
---|
| 152 | |
---|
| 153 | !!! Champ defini ? |
---|
| 154 | |
---|
| 155 | PRINT*,"field field_A_atm is valid ?",xios_is_valid_field("field_A_atm") |
---|
| 156 | |
---|
| 157 | |
---|
| 158 | !########################################################################### |
---|
| 159 | ! Contexte SRF |
---|
| 160 | !########################################################################### |
---|
| 161 | |
---|
| 162 | !!! Initialisation des coordonnées globales et locales pour la grille indexee (1 point sur 2) |
---|
| 163 | |
---|
| 164 | nb_pt=ni*nj/2 |
---|
| 165 | ALLOCATE(kindex(nb_pt),field_A_srf(nb_pt,llm)) |
---|
| 166 | DO i=1,nb_pt |
---|
| 167 | kindex(i)=2*i-1 |
---|
| 168 | ENDDO |
---|
[554] | 169 | field_A_srf(1:nb_pt,:)=RESHAPE(field_A_glo(ibegin+1:iend+1:2,jbegin+1:jend+1,:),(/ nb_pt,llm /)) |
---|
[486] | 170 | |
---|
| 171 | CALL xios_context_initialize("surface",comm) |
---|
| 172 | CALL xios_get_handle("surface",ctx_hdl) |
---|
| 173 | CALL xios_set_current_context(ctx_hdl) |
---|
| 174 | |
---|
[549] | 175 | CALL xios_define_calendar(type="Gregorian", & |
---|
| 176 | start_date=xios_date(2000, 01, 01, 00, 00, 00), & |
---|
| 177 | time_origin=xios_date(1999, 01, 01, 15, 00, 00)) |
---|
| 178 | |
---|
[666] | 179 | CALL xios_set_axis_attr("axis_srf",n_glo=llm ,value=lval) |
---|
[664] | 180 | 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] | 181 | CALL xios_set_domain_attr("domain_srf",data_dim=1, data_ibegin=0, data_ni=nb_pt) |
---|
[666] | 182 | CALL xios_set_domain_attr("domain_srf",data_i_index=kindex) |
---|
[664] | 183 | CALL xios_set_domain_attr("domain_srf",lonvalue_2D=lon,latvalue_2D=lat) |
---|
[486] | 184 | |
---|
[549] | 185 | !!! Création d un nouveau champ |
---|
[486] | 186 | |
---|
| 187 | CALL xios_get_handle("field_definition",fieldgroup_hdl) |
---|
| 188 | CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B_srf") |
---|
| 189 | |
---|
| 190 | !!! Heritage des attributs d un autre champ |
---|
| 191 | |
---|
| 192 | CALL xios_set_attr(field_hdl,field_ref="field_A_srf",name="field_B_srf") |
---|
[549] | 193 | |
---|
[486] | 194 | !!! Affectation de ce nouveau champ au fichier avec un nouveau nom |
---|
| 195 | |
---|
| 196 | CALL xios_get_handle("output_surface",file_hdl) |
---|
| 197 | CALL xios_add_child(file_hdl,field_hdl) |
---|
| 198 | CALL xios_set_attr(field_hdl,field_ref="field_B_srf",name="field_C_srf") |
---|
[549] | 199 | |
---|
[486] | 200 | !!! Definition du timestep |
---|
| 201 | |
---|
| 202 | dtime%second=1800 |
---|
[549] | 203 | CALL xios_set_timestep(timestep=dtime) |
---|
| 204 | |
---|
[486] | 205 | !!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalité) |
---|
| 206 | |
---|
[664] | 207 | ni=0 ; lonvalue(:,:)=0 |
---|
| 208 | CALL xios_get_domain_attr("domain_srf",ni=ni,lonvalue_2D=lonvalue) |
---|
[549] | 209 | |
---|
[486] | 210 | PRINT *,"ni",ni |
---|
| 211 | PRINT *,"lonvalue",lonvalue ; |
---|
| 212 | |
---|
| 213 | !!! Fin de la definition du contexte SRF |
---|
| 214 | |
---|
| 215 | CALL xios_close_context_definition() |
---|
| 216 | |
---|
| 217 | |
---|
| 218 | !#################################################################################### |
---|
| 219 | !!! Boucle temporelle |
---|
| 220 | !#################################################################################### |
---|
| 221 | |
---|
| 222 | DO ts=1,24*10 |
---|
| 223 | |
---|
| 224 | CALL xios_get_handle("atmosphere",ctx_hdl) |
---|
[549] | 225 | CALL xios_set_current_context(ctx_hdl) |
---|
[486] | 226 | |
---|
| 227 | !!! Mise a jour du pas de temps |
---|
| 228 | |
---|
| 229 | CALL xios_update_calendar(ts) |
---|
| 230 | |
---|
| 231 | !!! On donne la valeur du champ atm |
---|
| 232 | |
---|
| 233 | CALL xios_send_field("field_A_atm",field_A_atm) |
---|
| 234 | |
---|
| 235 | !!! On change de contexte |
---|
| 236 | |
---|
| 237 | CALL xios_get_handle("surface",ctx_hdl) |
---|
[549] | 238 | CALL xios_set_current_context(ctx_hdl) |
---|
[486] | 239 | |
---|
| 240 | !!! Mise a jour du pas de temps |
---|
| 241 | |
---|
| 242 | CALL xios_update_calendar(ts) |
---|
| 243 | |
---|
| 244 | !!! On donne la valeur du champ srf |
---|
| 245 | |
---|
| 246 | CALL xios_send_field("field_A_srf",field_A_srf) |
---|
| 247 | |
---|
| 248 | CALL wait_us(5000) ; |
---|
| 249 | ENDDO |
---|
| 250 | |
---|
| 251 | !#################################################################################### |
---|
| 252 | !!! Finalisation |
---|
| 253 | !#################################################################################### |
---|
| 254 | |
---|
| 255 | !!! Fin des contextes |
---|
[549] | 256 | |
---|
[486] | 257 | CALL xios_context_finalize() |
---|
| 258 | CALL xios_get_handle("atmosphere",ctx_hdl) |
---|
[549] | 259 | CALL xios_set_current_context(ctx_hdl) |
---|
[486] | 260 | CALL xios_context_finalize() |
---|
[549] | 261 | |
---|
[654] | 262 | DEALLOCATE(lon, lat, field_A_atm, lonvalue) |
---|
| 263 | DEALLOCATE(kindex, field_A_srf) |
---|
| 264 | |
---|
[486] | 265 | !!! Fin de XIOS |
---|
| 266 | |
---|
[655] | 267 | CALL MPI_COMM_FREE(comm, ierr) |
---|
| 268 | |
---|
[486] | 269 | CALL xios_finalize() |
---|
[549] | 270 | |
---|
[486] | 271 | CALL MPI_FINALIZE(ierr) |
---|
[549] | 272 | |
---|
[487] | 273 | END PROGRAM test_complete |
---|
[486] | 274 | |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | |
---|
[549] | 278 | |
---|
| 279 | |
---|