[4] | 1 | !> \file out_cptr_mod.f90 |
---|
| 2 | !! Module avec les routines d'ecriture et de lecture de fichiers cptr |
---|
| 3 | !< |
---|
| 4 | |
---|
| 5 | !> \namespace out_cptr |
---|
| 6 | !! This module gathers routines to read and write cptr files |
---|
| 7 | !! \author Vincent Peyaud |
---|
| 8 | !! \date janvier 2006 |
---|
| 9 | !! @note attention : en ecriture fichier runname.cptr |
---|
| 10 | !! @note en lecture fichier runname.CPTR |
---|
| 11 | !! @note il faut renommer le fichier ! |
---|
| 12 | !< |
---|
| 13 | !---------------------------------------------------------- |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | !> subroutine: read_recovery |
---|
| 17 | |
---|
| 18 | !!Reprise d'un fichier compteur |
---|
| 19 | !! Used module: - use module3D_phy |
---|
| 20 | !! - use netcdf |
---|
| 21 | !! - use io_netcdf_grisli |
---|
| 22 | !! - use tracer_vars |
---|
| 23 | !! |
---|
| 24 | ! |
---|
| 25 | !> |
---|
| 26 | |
---|
| 27 | subroutine read_recovery(icpt) !---- reprise d'un fichier compteur ----- |
---|
| 28 | |
---|
| 29 | use module3D_phy |
---|
| 30 | use netcdf |
---|
| 31 | use io_netcdf_grisli |
---|
| 32 | use tracer_vars !aurel neem |
---|
| 33 | implicit none |
---|
| 34 | |
---|
| 35 | character(len=20) :: titre |
---|
| 36 | integer :: nzzm |
---|
| 37 | integer :: icpt ! icompteur 1-> tout (topo, T, U) |
---|
| 38 | ! 2 -> tout sauf topo |
---|
| 39 | ! 3 -> tout sauf topo et eau basale |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | real,dimension(nx,ny) :: bidon !< sert à sauter les lectures de Ss,H,B,... |
---|
| 43 | |
---|
| 44 | ! Variables specifiques pour les fichier .nc |
---|
| 45 | |
---|
[6] | 46 | real*8, dimension(:,:), pointer :: tab => null() !< tableau 2d real ecrit dans le fichier |
---|
| 47 | real*8, dimension(:,:,:), pointer :: tab1 => null() !< tableau 3d real |
---|
| 48 | real*8, dimension(:,:,:), pointer :: tab1T => null() !< tableau 3d real pour la temperature |
---|
| 49 | real*8, dimension(:), pointer :: liste_time => null() |
---|
[4] | 50 | |
---|
| 51 | ! rappel de f90 |
---|
| 52 | ! reprcptr est un string (ici le nom du fichier recovery) |
---|
| 53 | ! index (reprcptr,'.cptr') renvoie : |
---|
| 54 | ! 0, si 'cptr' n'est pas dans reprcptr |
---|
| 55 | ! la position de la premiere occurence de cptr sinon |
---|
| 56 | |
---|
| 57 | if (ncdf_type.eq.0) call lect_netcdf_type !< pour lire la valeur de netcdf_type (machine dependant) |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | ascii_nc: if ((index(reprcptr,'.cptr').ne.0) .or.(index(reprcptr,'.CPTR').ne.0)) then !reprise fichier cptr |
---|
| 61 | |
---|
| 62 | if (itracebug.eq.1) call tracebug(' Entree dans routine read_recovery : ascii') |
---|
| 63 | |
---|
| 64 | open(num_forc,file=trim(reprcptr)) |
---|
| 65 | read(num_forc,*) time |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | ! temps de la reprise |
---|
| 69 | !----------------------- |
---|
| 70 | if (tbegin.gt.1.d9) then ! si tbegin est tres grand , on reprend le temps du cptr |
---|
| 71 | tbegin=time |
---|
| 72 | else |
---|
| 73 | time=tbegin |
---|
| 74 | endif |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | read(num_forc,*) titre |
---|
| 78 | read(num_forc,*) ni,nzz,nzzm,nxx,nyy |
---|
| 79 | read(num_forc,*) |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | if ((nxx.ne.nx).or.(nyy.ne.ny).or.(nzz.ne.nz) & |
---|
| 83 | .or.(nzzm.ne.nzm)) write(6,*) 'attention', & |
---|
| 84 | 'les tailles de tableaux ne sont pas compatibles' |
---|
| 85 | |
---|
| 86 | ! lecture des tableaux 2D |
---|
| 87 | read(num_forc,*) |
---|
| 88 | read(num_forc,*) |
---|
| 89 | |
---|
| 90 | lect_topo: if (icpt.eq.1) then ! lecture topo seulement si icompteur = 1 |
---|
| 91 | read(num_forc,*) S |
---|
| 92 | read(num_forc,*) |
---|
| 93 | |
---|
| 94 | read(num_forc,*) H |
---|
| 95 | read(num_forc,*) |
---|
| 96 | |
---|
| 97 | read(num_forc,*) B |
---|
| 98 | read(num_forc,*) |
---|
| 99 | |
---|
| 100 | read(num_forc,*) Bsoc |
---|
| 101 | read(num_forc,*) |
---|
| 102 | |
---|
| 103 | else |
---|
| 104 | read(num_forc,*) bidon |
---|
| 105 | read(num_forc,*) |
---|
| 106 | |
---|
| 107 | read(num_forc,*) bidon |
---|
| 108 | read(num_forc,*) |
---|
| 109 | |
---|
| 110 | read(num_forc,*) bidon |
---|
| 111 | read(num_forc,*) |
---|
| 112 | |
---|
| 113 | read(num_forc,*) bidon |
---|
| 114 | read(num_forc,*) |
---|
| 115 | |
---|
| 116 | end if lect_topo |
---|
| 117 | |
---|
| 118 | ! lecture temperature dans tous les cas |
---|
| 119 | read(num_forc,*) Ibase |
---|
| 120 | read(num_forc,*) |
---|
| 121 | |
---|
| 122 | read(num_forc,*) bmelt |
---|
| 123 | read(num_forc,*) |
---|
| 124 | |
---|
| 125 | lect_Hwater: if (icpt.ne.3) then ! pas de lecture Hwater si icompteur = 3 |
---|
| 126 | read(num_forc,*) Hwater |
---|
| 127 | read(num_forc,*) |
---|
| 128 | else |
---|
| 129 | read(num_forc,*) bidon |
---|
| 130 | read(num_forc,*) |
---|
| 131 | Hwater(:,:)=0. |
---|
| 132 | |
---|
| 133 | end if lect_Hwater |
---|
| 134 | |
---|
| 135 | ! lecture vitesses dans tous les cas. |
---|
| 136 | read(num_forc,*) Uxbar |
---|
| 137 | read(num_forc,*) |
---|
| 138 | |
---|
| 139 | read(num_forc,*) Uybar |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | ! tableaux 3d |
---|
| 143 | |
---|
| 144 | read(num_forc,*) |
---|
| 145 | read(num_forc,*) |
---|
| 146 | |
---|
| 147 | read(num_forc,*,end=22) T |
---|
| 148 | 22 continue |
---|
| 149 | |
---|
| 150 | read(num_forc,*,end=23) |
---|
| 151 | read(num_forc,*,end=23) |
---|
| 152 | |
---|
| 153 | read(num_forc,*,end=23) Ux |
---|
| 154 | 23 continue |
---|
| 155 | |
---|
| 156 | read(num_forc,*,end=24) |
---|
| 157 | read(num_forc,*,end=24) |
---|
| 158 | |
---|
| 159 | read(num_forc,*,end=24) Uy |
---|
| 160 | 24 continue |
---|
| 161 | |
---|
| 162 | ! aurel pour faire des cptr avec les traceurs : |
---|
| 163 | read(num_forc,*,end=25) |
---|
| 164 | read(num_forc,*,end=25) |
---|
| 165 | read(num_forc,*,end=25) Xdep_out !xdepk ou xdep ? a voir |
---|
| 166 | 25 continue |
---|
| 167 | |
---|
| 168 | read(num_forc,*,end=26) |
---|
| 169 | read(num_forc,*,end=26) |
---|
| 170 | read(num_forc,*,end=26) Ydep_out |
---|
| 171 | 26 continue |
---|
| 172 | |
---|
| 173 | read(num_forc,*,end=27) |
---|
| 174 | read(num_forc,*,end=27) |
---|
| 175 | read(num_forc,*,end=27) tdep_out |
---|
| 176 | 27 continue |
---|
| 177 | tdep_out(:,:,:)=tdep_out(:,:,:)+time |
---|
| 178 | |
---|
| 179 | close(num_forc) |
---|
| 180 | |
---|
| 181 | else if ((index(reprcptr,'.nc').ne.0)) then ! Modif hassine pour la reprise d'un fichier .nc |
---|
| 182 | |
---|
| 183 | if (itracebug.eq.1) call tracebug(' Entree dans routine read_recovery : netcdf') |
---|
| 184 | |
---|
| 185 | |
---|
| 186 | if (.not.associated(liste_time)) then |
---|
| 187 | allocate(liste_time(1)) |
---|
| 188 | end if |
---|
| 189 | if (.not.associated(tab)) then |
---|
| 190 | allocate(tab(nx,ny),tab1(nx,ny,nz),tab1T(nx,ny,nz+nzm)) |
---|
| 191 | end if |
---|
| 192 | |
---|
| 193 | call Read_ncdf_var('temps',TRIM(reprcptr),liste_time) |
---|
| 194 | |
---|
| 195 | ! temps de la reprise |
---|
| 196 | !----------------------- |
---|
| 197 | if (tbegin.gt.1.d9) then ! si tbegin est tres grand , on reprend le temps du .nc |
---|
| 198 | tbegin=liste_time(1) |
---|
| 199 | time = tbegin |
---|
| 200 | else |
---|
| 201 | time = tbegin |
---|
| 202 | endif |
---|
| 203 | |
---|
| 204 | if (itracebug.eq.1) write(num_tracebug,*) tbegin, liste_time(1) |
---|
| 205 | |
---|
| 206 | |
---|
| 207 | ! TBEGIN=liste_time(1)-liste_time(1) |
---|
| 208 | |
---|
| 209 | call Read_ncdf_dim('x' ,TRIM(reprcptr),nxx) |
---|
| 210 | call Read_ncdf_dim('y' ,TRIM(reprcptr),nyy) |
---|
| 211 | call Read_ncdf_dim('z' ,TRIM(reprcptr),nzz) |
---|
| 212 | call Read_ncdf_dim('zm',TRIM(reprcptr),nzzm) |
---|
| 213 | |
---|
| 214 | if ((nxx.ne.nx).or.(nyy.ne.ny).or.(nzz.ne.nz) & |
---|
| 215 | .or.(nzzm-nzz.ne.nzm)) write(6,*) 'attention', & |
---|
| 216 | 'les tailles de tableaux ne sont pas compatibles' |
---|
| 217 | |
---|
| 218 | ! lecture des tableaux 2D |
---|
| 219 | ! ----------------------------- |
---|
| 220 | |
---|
| 221 | if (icpt.eq.1) then ! lecture topo seulement si icompteur = 1 |
---|
| 222 | call Read_ncdf_var('S',TRIM(reprcptr),tab) |
---|
| 223 | S(:,:)=tab(:,:) |
---|
| 224 | call Read_ncdf_var('H',TRIM(reprcptr),tab) |
---|
| 225 | H(:,:)=tab(:,:) |
---|
| 226 | call Read_ncdf_var('B',TRIM(reprcptr),tab) |
---|
| 227 | B(:,:)=tab(:,:) |
---|
| 228 | call Read_ncdf_var('BSOC',TRIM(reprcptr),tab) |
---|
| 229 | Bsoc(:,:)=tab(:,:) |
---|
| 230 | end if |
---|
| 231 | |
---|
| 232 | ! lecture temperature dans tous les cas |
---|
| 233 | call Read_ncdf_var('IBASE',TRIM(reprcptr),tab) |
---|
| 234 | Ibase(:,:)=tab(:,:) |
---|
| 235 | call Read_ncdf_var('BMELT',TRIM(reprcptr),tab) |
---|
| 236 | Bmelt(:,:)=tab(:,:) |
---|
| 237 | |
---|
| 238 | if (icpt.ne.3) then ! pas de lecture Hwater si icompteur = 3 |
---|
| 239 | call Read_ncdf_var('HWATER',TRIM(reprcptr),tab) |
---|
| 240 | Hwater(:,:)=tab(:,:) |
---|
| 241 | else |
---|
| 242 | Hwater(:,:)=0. |
---|
| 243 | end if |
---|
| 244 | |
---|
| 245 | ! lecture vitesses dans tous les cas. |
---|
| 246 | call Read_ncdf_var('UXBAR',TRIM(reprcptr),tab) |
---|
| 247 | UXBAR(:,:)=tab(:,:) |
---|
| 248 | call Read_ncdf_var('UYBAR',TRIM(reprcptr),tab) |
---|
| 249 | UYBAR(:,:)=tab(:,:) |
---|
| 250 | |
---|
| 251 | do i=1,nx-1 |
---|
| 252 | do j=1,ny-1 |
---|
| 253 | oldu(i,j) = sqrt(((uxbar(i,j)+uxbar(i+1,j))/2)**2 & |
---|
| 254 | + ((uybar(i,j)+uybar(i,j+1))/2.)**2) |
---|
| 255 | end do |
---|
| 256 | end do |
---|
| 257 | |
---|
| 258 | ! tableaux 3D |
---|
| 259 | ! ----------------------------- |
---|
| 260 | |
---|
| 261 | call Read_ncdf_var('T',TRIM(reprcptr),tab1T) |
---|
| 262 | T(:,:,:)=tab1T(:,:,:) |
---|
| 263 | |
---|
| 264 | call Read_ncdf_var('UX',TRIM(reprcptr),tab1) |
---|
| 265 | Ux(:,:,:)=tab1(:,:,:) |
---|
| 266 | |
---|
| 267 | call Read_ncdf_var('UY',TRIM(reprcptr),tab1) |
---|
| 268 | Uy(:,:,:)=tab1(:,:,:) |
---|
| 269 | |
---|
| 270 | if (itracebug.eq.1) call tracebug('avant lectures variables traceur') |
---|
| 271 | |
---|
| 272 | |
---|
| 273 | call Read_ncdf_var('XDEP',TRIM(reprcptr),tab1) !aurel neem |
---|
| 274 | Xdep_out(:,:,:)=tab1(:,:,:) |
---|
| 275 | |
---|
| 276 | call Read_ncdf_var('YDEP',TRIM(reprcptr),tab1) |
---|
| 277 | Ydep_out(:,:,:)=tab1(:,:,:) |
---|
| 278 | |
---|
| 279 | call Read_ncdf_var('TDEP',TRIM(reprcptr),tab1) |
---|
| 280 | Tdep_out(:,:,:)=tab1(:,:,:)+time |
---|
| 281 | |
---|
| 282 | end if ascii_nc |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | do i=1,nx-1 |
---|
| 286 | do j=1,ny-1 |
---|
| 287 | oldu(i,j) = sqrt(((Uxbar(i,j)+Uxbar(i+1,j))/2)**2 & |
---|
| 288 | + ((Uybar(i,j)+Uybar(i,j+1))/2.)**2) |
---|
| 289 | end do |
---|
| 290 | end do |
---|
| 291 | |
---|
| 292 | |
---|
| 293 | ! moyenne de l'epaisseur et pentes |
---|
| 294 | do j=2,ny |
---|
| 295 | do i=2,nx |
---|
| 296 | Hmy(i,j)=(H(i,j)+H(i,j-1))/2. |
---|
| 297 | Hmx(i,j)=(H(i,j)+H(i-1,j))/2. |
---|
| 298 | Sdx(i,j)=(S(i,j)-S(i-1,j))/dx |
---|
| 299 | Sdy(i,j)=(S(i,j)-S(i,j-1))/dy |
---|
| 300 | end do |
---|
| 301 | end do |
---|
| 302 | |
---|
| 303 | do i=2,nx |
---|
| 304 | Hmx(i,1)=(H(i,1)+H(i-1,1))/2. |
---|
| 305 | end do |
---|
| 306 | do j=2,ny |
---|
| 307 | Hmy(1,j)=(H(1,j)+H(1,j-1))/2. |
---|
| 308 | end do |
---|
| 309 | |
---|
| 310 | ! vitesse a la base |
---|
| 311 | Uxflgz(:,:) = Ux(:,:,nz) |
---|
| 312 | Uyflgz(:,:) = Uy(:,:,nz) |
---|
| 313 | |
---|
[146] | 314 | debug_3D(:,:,120) = T(:,:,nz) + 273.15 |
---|
[4] | 315 | |
---|
| 316 | |
---|
| 317 | end subroutine read_recovery |
---|
| 318 | |
---|
| 319 | |
---|
| 320 | !> SUBROUTINE: read_no_recovery |
---|
| 321 | !!Pas de reprise d'un fichier compteur |
---|
| 322 | !> |
---|
| 323 | subroutine read_no_recovery |
---|
| 324 | use module3D_phy |
---|
| 325 | implicit none |
---|
| 326 | Real,Parameter :: Dzm=600 !< Grid Step In Mantle |
---|
| 327 | !Prop Thermique |
---|
| 328 | Real,Parameter :: Cm=1.04e8 |
---|
| 329 | |
---|
| 330 | !!!pas reprise : il faut initier les temperatures ds le socle |
---|
| 331 | |
---|
| 332 | ! temperature dans le socle lineaire avec le gradient geothermique |
---|
| 333 | do k=nz+1,nz+nzm |
---|
| 334 | do j=1,ny |
---|
| 335 | do i=1,nx |
---|
| 336 | T(i,j,k)=T(i,j,nz)-dzm*(k-nz)*ghf(i,j)/cm |
---|
| 337 | end do |
---|
| 338 | end do |
---|
| 339 | end do |
---|
| 340 | |
---|
| 341 | |
---|
| 342 | end subroutine read_no_recovery |
---|
| 343 | |
---|
| 344 | !---------------------------------------------------------- |
---|
| 345 | |
---|
| 346 | !---------------------------------------------------------- |
---|
| 347 | |
---|
| 348 | !> SUBROUTINE: out_recovery |
---|
| 349 | !! Sortie d'un fichier de reprise |
---|
| 350 | !! Attention : fichier en sortie .cptr ou fichier .nc |
---|
| 351 | !! used modules: - use module3D_phy |
---|
| 352 | !! - use netcdf |
---|
| 353 | !! - use io_netcdf_grisli |
---|
| 354 | !! - use util_recovery |
---|
| 355 | !! - use tracer_vars |
---|
| 356 | !> |
---|
| 357 | |
---|
| 358 | subroutine out_recovery(isortie) |
---|
| 359 | |
---|
| 360 | ! --------------------------------------------------------------- |
---|
| 361 | ! SORTIE COMPTEUR |
---|
| 362 | ! |
---|
| 363 | ! |
---|
| 364 | ! sortie qui stocke dans le fichier runname.cptr les variables |
---|
| 365 | ! S, H, B, HDOT, BDOT, et T plusieurs fois dans le programme |
---|
| 366 | ! (chaque nouvelle sortie ecrase la precedente) => |
---|
| 367 | ! on peut faire repartir le programme a partir de ce fichier, |
---|
| 368 | ! et donc du dernier pas de temps stocke |
---|
| 369 | ! |
---|
| 370 | ! Maintenant, il y a deux formats de fichiers possibles : |
---|
| 371 | ! ascii (isortie = 1) et netcdf (isortie = 2). |
---|
| 372 | ! --------------------------------------------------------------- |
---|
| 373 | |
---|
| 374 | use module3D_phy |
---|
| 375 | use netcdf |
---|
| 376 | use io_netcdf_grisli |
---|
| 377 | use util_recovery |
---|
| 378 | use tracer_vars ! aurel neem |
---|
| 379 | |
---|
| 380 | implicit none |
---|
| 381 | |
---|
| 382 | character(len=80) :: filin |
---|
| 383 | integer ncid,status |
---|
[8] | 384 | real*8, dimension(:,:), pointer :: tab => null() !< tableau 2d real ecrit dans le fichier |
---|
| 385 | real*8, dimension(:,:,:), pointer :: tab1 => null() !< tableau 3d real |
---|
| 386 | real*8, dimension(:,:,:), pointer :: tab1T => null() !< tableau 3d real pour la temperature |
---|
[4] | 387 | character(len=20),dimension(3) :: dimnames2d !< dimensions pour netcdf pour tableau 2d pour les noeud majeur |
---|
| 388 | character(len=20),dimension(4) :: dimnames3d !< pour 3d troisieme dim est nz |
---|
| 389 | character(len=20),dimension(4) :: dimnames3dT !< pour 3d troisieme dim est nz+nzm |
---|
[77] | 390 | ! integer :: nrecs=1 !< compteur pour les enregistrements temps des variables |
---|
| 391 | ! integer :: idef=0 !< pour savoir si la variable a ete definie ou non |
---|
[4] | 392 | integer :: isortie !< pour le choix de type de fichier en sortie |
---|
| 393 | |
---|
| 394 | if (itracebug.eq.1) call tracebug(' Entree dans routine out_recovery') |
---|
| 395 | |
---|
| 396 | call testout_recovery(filin) |
---|
| 397 | if (itracebug.eq.1) call tracebug(' Entree dans routine out_recovery 2') |
---|
| 398 | |
---|
| 399 | if (logic_out) then |
---|
| 400 | Select Case (Isortie) |
---|
| 401 | Case (1) ! sortie de type ascii |
---|
| 402 | |
---|
| 403 | filin=trim(filin)//'.cptr' |
---|
| 404 | open(num_file1,file=trim(filin)) |
---|
| 405 | |
---|
| 406 | write(num_file1,*) time_out(1), ' TIME ' |
---|
| 407 | write(num_file1,*) geoplace |
---|
| 408 | write(num_file1,*) nx*ny,nz,nzm,nx,ny |
---|
| 409 | write(num_file1,*) |
---|
| 410 | |
---|
| 411 | ! ecriture des tableaux 2D |
---|
| 412 | write(num_file1,*)' Tableaux 2D' |
---|
| 413 | write(num_file1,*)' Surface ' |
---|
| 414 | write(num_file1,*) S |
---|
| 415 | |
---|
| 416 | write(num_file1,*)' Epaisseur ' |
---|
| 417 | write(num_file1,*) H |
---|
| 418 | |
---|
| 419 | write(num_file1,*)' Base glace ' |
---|
| 420 | write(num_file1,*) B |
---|
| 421 | |
---|
| 422 | write(num_file1,*)' Socle ' |
---|
| 423 | write(num_file1,*) Bsoc |
---|
| 424 | |
---|
| 425 | write(num_file1,*)' Ibase ' |
---|
| 426 | write(num_file1,*) Ibase |
---|
| 427 | |
---|
| 428 | write(num_file1,*)' Bmelt ' |
---|
| 429 | write(num_file1,*) Bmelt |
---|
| 430 | |
---|
| 431 | write(num_file1,*)' Hwater ' |
---|
| 432 | write(num_file1,*) Hwater |
---|
| 433 | |
---|
| 434 | write(num_file1,*)' Uxbar ' |
---|
| 435 | write(num_file1,*) Uxbar |
---|
| 436 | |
---|
| 437 | write(num_file1,*)' Uybar ' |
---|
| 438 | write(num_file1,*) Uybar |
---|
| 439 | |
---|
| 440 | ! tableau 3D |
---|
| 441 | |
---|
| 442 | write(num_file1,*) |
---|
| 443 | write(num_file1,*) 'Temperature (3D y compris le socle)' |
---|
| 444 | write(num_file1,*) T(:,:,:) |
---|
| 445 | write(num_file1,*) |
---|
| 446 | |
---|
| 447 | write(num_file1,*) 'vitesse selon x' |
---|
| 448 | write(num_file1,*) Ux(:,:,:) |
---|
| 449 | write(num_file1,*) |
---|
| 450 | |
---|
| 451 | write(num_file1,*) 'vitesse selon y' |
---|
| 452 | write(num_file1,*) Uy(:,:,:) |
---|
| 453 | |
---|
| 454 | !aurel neem : traceurs dans le cptr |
---|
| 455 | |
---|
| 456 | write(num_file1,*) |
---|
| 457 | write(num_file1,*) 'origine de la glace en x' |
---|
| 458 | write(num_file1,*) xdep(:,:,:) |
---|
| 459 | |
---|
| 460 | write(num_file1,*) |
---|
| 461 | write(num_file1,*) 'origine de la glace en y' |
---|
| 462 | write(num_file1,*) ydep(:,:,:) |
---|
| 463 | |
---|
| 464 | write(num_file1,*) |
---|
| 465 | write(num_file1,*) 'age de la glace' |
---|
[32] | 466 | !tab1(:,:,:) = tdep(:,:,:) - time |
---|
| 467 | write(num_file1,*) tdep(:,:,:) - time ! note: on decide d'ecrire le temps 'relatif' |
---|
[4] | 468 | |
---|
| 469 | close(num_file1) |
---|
| 470 | |
---|
| 471 | |
---|
| 472 | Case (2) ! sortie de type netcdf |
---|
| 473 | |
---|
| 474 | if (.not.associated(tab)) then |
---|
| 475 | allocate(tab(nx,ny),tab1(nx,ny,nz),tab1T(nx,ny,nz+nzm)) |
---|
| 476 | end if |
---|
| 477 | filin=trim(filin)//'.nc' |
---|
| 478 | |
---|
| 479 | ! creation du fichier |
---|
| 480 | !------------------------ |
---|
| 481 | |
---|
| 482 | if (ncdf_type.eq.32) then |
---|
| 483 | status = nf90_create(TRIM(filin),NF90_WRITE,ncid) ! en 32 bits |
---|
| 484 | else if (ncdf_type.eq.64) then |
---|
| 485 | status = nf90_create(trim(filin),and(nf90_write,nf90_64bit_offset),ncid) ! sur r2d2 |
---|
| 486 | else |
---|
| 487 | write(6,*)'pb de lecture de netcdf_type dans out_cptr:', ncdf_type |
---|
| 488 | endif |
---|
| 489 | |
---|
| 490 | status = nf90_close(ncid) ! fermeture |
---|
| 491 | |
---|
| 492 | |
---|
| 493 | call initfile(nx,ny,nz,nzm,dimnames2d,dimnames3d,dimnames3dT,filin) ! initialise le fichier nc |
---|
| 494 | |
---|
| 495 | call write_ncdf_var('temps','time',trim(filin),time_out,'double') ! ecrit le temps du snapshot |
---|
| 496 | |
---|
| 497 | ! variables 2D |
---|
| 498 | |
---|
| 499 | tab(:,:)= S(:,:) |
---|
| 500 | call write_ncdf_var('S',dimnames2d,trim(filin),tab,'double') ! ecrit S |
---|
| 501 | |
---|
| 502 | tab(:,:)= H(:,:) |
---|
| 503 | call write_ncdf_var('H',dimnames2d,trim(filin),tab,'double') |
---|
| 504 | |
---|
| 505 | tab(:,:)= B(:,:) |
---|
| 506 | call write_ncdf_var('B',dimnames2d,trim(filin),tab,'double') |
---|
| 507 | |
---|
| 508 | tab(:,:)= Bsoc(:,:) |
---|
| 509 | call write_ncdf_var('BSOC',dimnames2d,trim(filin),tab,'double') |
---|
| 510 | |
---|
| 511 | tab(:,:)= IBASE(:,:) |
---|
| 512 | call write_ncdf_var('IBASE',dimnames2d,trim(filin),tab,'double') |
---|
| 513 | |
---|
| 514 | tab(:,:)= Bmelt(:,:) |
---|
| 515 | call write_ncdf_var('BMELT',dimnames2d,trim(filin),tab,'double') |
---|
| 516 | |
---|
| 517 | tab(:,:)= Hwater(:,:) |
---|
| 518 | call write_ncdf_var('HWATER',dimnames2d,trim(filin),tab,'double') |
---|
| 519 | |
---|
| 520 | tab(:,:)= UXBAR(:,:) |
---|
| 521 | call write_ncdf_var('UXBAR',dimnames2d,trim(filin),tab,'double') |
---|
| 522 | |
---|
| 523 | tab(:,:)= UYBAR(:,:) |
---|
| 524 | call write_ncdf_var('UYBAR',dimnames2d,trim(filin),tab,'double') |
---|
| 525 | |
---|
| 526 | ! variables 3D |
---|
| 527 | |
---|
| 528 | tab1T(:,:,:)= T(:,:,:) |
---|
| 529 | call write_ncdf_var('T',dimnames3dT,trim(filin),tab1T,'double') ! ecrit T |
---|
| 530 | |
---|
| 531 | tab1(:,:,:)= UX(:,:,:) |
---|
| 532 | call write_ncdf_var('UX',dimnames3d,trim(filin),tab1,'double') |
---|
| 533 | |
---|
| 534 | tab1(:,:,:)= UY(:,:,:) |
---|
| 535 | call write_ncdf_var('UY',dimnames3d,trim(filin),tab1,'double') |
---|
| 536 | |
---|
| 537 | ! variables 3D pour les traceurs (Aurel NEEM) |
---|
| 538 | ! attention ce sont les tabelaux _out qui ont les bonnes dimensions. |
---|
| 539 | |
---|
| 540 | tab1(:,:,:)=XDEP_out(:,:,:) |
---|
| 541 | call write_ncdf_var('XDEP',dimnames3d,trim(filin),tab1,'double') !aurel neem |
---|
| 542 | |
---|
| 543 | tab1(:,:,:)=YDEP_out(:,:,:) |
---|
| 544 | call write_ncdf_var('YDEP',dimnames3d,trim(filin),tab1,'double') |
---|
| 545 | |
---|
| 546 | tab1(:,:,:)=TDEP_out(:,:,:) - time |
---|
| 547 | call write_ncdf_var('TDEP',dimnames3d,trim(filin),tab1,'double') |
---|
| 548 | |
---|
| 549 | |
---|
| 550 | End Select |
---|
| 551 | End if |
---|
| 552 | end subroutine out_recovery |
---|
| 553 | |
---|
| 554 | !> subroutine initfile |
---|
| 555 | !! Initialise the netcdf file |
---|
| 556 | !! Used module: - use netcdf |
---|
| 557 | !! - use io_netcdf_grisli |
---|
| 558 | !! @param nxx dimension along x |
---|
| 559 | !! @param nyy dimension along y |
---|
| 560 | !! @param nzz dimension along z |
---|
| 561 | !! @param nzmm dimension along z for T |
---|
| 562 | !! @param fil_sortie name of the file to initialise |
---|
| 563 | !! @param dimnames2d dimensions for netcdf |
---|
| 564 | !> |
---|
| 565 | subroutine initfile(nxx,nyy,nzz,nzmm,& |
---|
| 566 | dimnames2d,dimnames3d,dimnames3dT,file) |
---|
| 567 | |
---|
| 568 | use netcdf |
---|
| 569 | use io_netcdf_grisli |
---|
| 570 | implicit none |
---|
| 571 | integer,intent(in) :: nxx !< dimension along x |
---|
| 572 | integer,intent(in) :: nyy !< dimension along y |
---|
| 573 | integer,intent(in) :: nzz !< dimension along z |
---|
| 574 | integer,intent(in) :: nzmm !< dimension along z in socle |
---|
| 575 | character(len=20),dimension(3) :: dimnames2d !< dimensions pour netcdf pour tableau 2d pour les noeud majeur |
---|
| 576 | character(len=20),dimension(4) :: dimnames3d !< pour 3d troisieme dim est nz |
---|
| 577 | character(len=20),dimension(4) :: dimnames3dT !< pour 3d troisieme dim est nz+nzm |
---|
| 578 | character(len=*) ::file !< name of the file to init |
---|
| 579 | ! initialisation |
---|
| 580 | call write_ncdf_dim('x',trim(file),nxx) !< dimensions des tableaux |
---|
| 581 | call write_ncdf_dim('y',trim(file),nyy) |
---|
| 582 | call write_ncdf_dim('z',trim(file),nzz) |
---|
| 583 | call write_ncdf_dim('zm',trim(file),nzz+nzmm) |
---|
| 584 | call write_ncdf_dim('time',trim(file),0) |
---|
| 585 | dimnames2d(1)='x' |
---|
| 586 | dimnames2d(2)='y' |
---|
| 587 | dimnames2d(3)='time' |
---|
| 588 | |
---|
| 589 | dimnames3d(1)='x' |
---|
| 590 | dimnames3d(2)='y' |
---|
| 591 | dimnames3d(3)='z' |
---|
| 592 | dimnames3d(4)='time' |
---|
| 593 | |
---|
| 594 | dimnames3dT(1)='x' |
---|
| 595 | dimnames3dT(2)='y' |
---|
| 596 | dimnames3dT(3)='zm' |
---|
| 597 | dimnames3dT(4)='time' |
---|
| 598 | |
---|
| 599 | end subroutine initfile |
---|
| 600 | |
---|
| 601 | |
---|
| 602 | !> SUBROUTINE: symetry_cptr |
---|
| 603 | !! Subroutine utilisee dans les experiences axysymetriques pour repartir d'un cptr dans lequel |
---|
| 604 | !! tous les champs sont axysmetriques ou symetriques par rapport a un axe |
---|
| 605 | !! Used module: - use module3D_phy |
---|
| 606 | !! @param iaxe symetrie par rapport a iaxe |
---|
| 607 | !! @param jaxe symetrie par rapport a jaxe |
---|
| 608 | !> |
---|
| 609 | |
---|
| 610 | subroutine symetry_cptr(iaxe,jaxe) |
---|
| 611 | use module3D_phy |
---|
| 612 | use tracer_vars |
---|
| 613 | implicit none |
---|
| 614 | integer :: iaxe |
---|
| 615 | integer :: jaxe |
---|
| 616 | integer :: jsym |
---|
| 617 | integer :: isym |
---|
| 618 | |
---|
| 619 | !symetrique par rapport à jaxe la référence est le bas. Pour l'instant seulement lui |
---|
| 620 | jsym=0 |
---|
| 621 | do j=jaxe+1,ny |
---|
| 622 | jsym=jsym+1 |
---|
| 623 | |
---|
| 624 | do i=1,nx |
---|
| 625 | S(i,j)=S(i,jaxe-jsym) |
---|
| 626 | H(i,j)=H(i,jaxe-jsym) |
---|
| 627 | B(i,j)=B(i,jaxe-jsym) |
---|
| 628 | Bsoc(i,j)=Bsoc(i,jaxe-jsym) |
---|
| 629 | Ibase(i,j)=Ibase(i,jaxe-jsym) |
---|
| 630 | Bmelt(i,j)=bmelt(i,jaxe-jsym) |
---|
| 631 | hwater(i,j)=hwater(i,jaxe-jsym) |
---|
| 632 | uxbar(i,j)=uxbar(i,jaxe-jsym) |
---|
| 633 | uybar(i,j)=-uybar(i,jaxe-jsym+1) ! attention different des autres |
---|
| 634 | ! a cause des staggered grids |
---|
| 635 | |
---|
| 636 | T(i,j,:)=T(i,jaxe-jsym,:) |
---|
| 637 | ux(i,j,:)=ux(i,jaxe-jsym,:) |
---|
| 638 | uy(i,j,:)=-uy(i,jaxe-jsym+1,:) ! different des autres |
---|
| 639 | |
---|
| 640 | XDEP(i,j,:)=XDEP(i,jaxe-jsym,:) |
---|
| 641 | YDEP(i,j,:)=YDEP(i,jaxe-jsym,:) |
---|
| 642 | TDEP(i,j,:)=TDEP(i,jaxe-jsym,:) |
---|
| 643 | |
---|
| 644 | end do |
---|
| 645 | end do |
---|
| 646 | return |
---|
| 647 | end subroutine symetry_cptr |
---|