- Timestamp:
- 06/22/23 17:12:00 (12 months ago)
- Location:
- branches/GRISLIv3/SOURCES
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GRISLIv3/SOURCES/Ant40_files/output_anta40_mod-0.4.f90
r275 r435 62 62 integer,dimension(nvar) :: varID 63 63 integer :: nbtimeout ! index time output 64 65 64 real,dimension(nvar) :: var_shortoutput 66 65 66 ! variables netcdf icecore (ic) 67 integer,parameter :: ncicecoreout=1 ! 1 sorties netcdf icecore / 0 no output 68 integer :: nbic ! number of ice core site in output 69 integer,parameter :: nvaric=10 ! nombre de variables dans le fichier ice core 70 real,parameter :: dticecoreout=50. ! sorties ice core tous les dticecoreout 71 integer :: ncidic 72 integer :: timeDimIDic 73 integer :: timeVarIDic 74 integer :: stationDimIDic 75 integer :: stationVarIDic 76 integer :: station_strlenDimIDic 77 integer :: lonVarIDic 78 integer :: latVarIDic 79 integer,dimension(nvaric) :: varIDic 80 integer :: nbtimeoutic ! index time output 81 real,allocatable,dimension(:,:) :: var_icoutput 82 character(len=100), allocatable, dimension(:) :: site_nameic 83 integer, allocatable, dimension(:) :: iic,jic ! coordonnees i,j des sites ice core 67 84 68 85 CONTAINS … … 75 92 character(len=100),dimension(nvar) :: long_name 76 93 character(len=100),dimension(nvar) :: units 94 95 ! ice core variables 96 character(len=100),allocatable,dimension(:) :: ic_name ! ice core name 97 real,allocatable,dimension(:) :: ic_lon ! ice core lon 98 real,allocatable,dimension(:) :: ic_lat ! ice core lat 99 character(len=100),dimension(nvaric) :: namevaric ! name, standard_name, long_name, units 100 character(len=100),dimension(nvaric) :: standard_nameic 101 character(len=100),dimension(nvaric) :: long_nameic 102 character(len=100),dimension(nvaric) :: unitsic 103 integer :: err ! recuperation erreur 104 integer :: ii,jj 105 integer :: nloop ! nbr de tour dans la boucle while (evite boucle folle) 106 real :: dist_lonlat, dist_lonlat_new, distance ! distance to lon lat ice core site 107 108 77 109 78 110 !ndisp sorite courte tous les ndisp … … 106 138 enddo 107 139 close(568) 140 108 141 ! Fichier Netcdf initMIP 109 142 ! creation du fichier Netcdf : … … 136 169 enddo 137 170 138 ! fin de la definition du f chier :171 ! fin de la definition du fichier : 139 172 status=nf90_enddef(ncid) 140 173 if (status /= nf90_noerr) call handle_err(status) … … 143 176 corrsurf(:,:)=1. 144 177 endif 178 179 180 if (ncicecoreout.eq.1) then ! ecriture netcdf Ice Core 181 ! Fichier Netcdf ice core Antarctique 182 ! Lecture du fichier avec la liste des sites de forages 183 ! infos sur les variables : 184 open(568,file=trim(dirsource)//'/Fichiers-parametres/icecore-Ant.dat',status='old') 185 ! lecture en-tete 186 read(568,*) 187 read(568,*) 188 read(568,*) 189 read(568,*) 190 read(568,*) 191 ! lectuire du nombre de sites de forages: 192 read(568,*) nbic 193 read(568,*) 194 ! allocation des variables dependant du nombre de site de forage (nbic) 195 if (.not.allocated(iic)) then 196 allocate(iic(nbic),stat=err) 197 if (err/=0) then 198 print *,"erreur a l'allocation du tableau iic dans init_outshort",err 199 stop 4 200 end if 201 end if 202 if (.not.allocated(jic)) then 203 allocate(jic(nbic),stat=err) 204 if (err/=0) then 205 print *,"erreur a l'allocation du tableau jic dans init_outshort",err 206 stop 4 207 end if 208 end if 209 if (.not.allocated(ic_name)) then 210 allocate(ic_name(nbic),stat=err) 211 if (err/=0) then 212 print *,"erreur a l'allocation du tableau ic_name dans init_outshort",err 213 stop 4 214 end if 215 end if 216 if (.not.allocated(ic_lon)) then 217 allocate(ic_lon(nbic),stat=err) 218 if (err/=0) then 219 print *,"erreur a l'allocation du tableau ic_lon dans init_outshort",err 220 stop 4 221 end if 222 end if 223 if (.not.allocated(ic_lat)) then 224 allocate(ic_lat(nbic),stat=err) 225 if (err/=0) then 226 print *,"erreur a l'allocation du tableau ic_lat dans init_outshort",err 227 stop 4 228 end if 229 end if 230 if (.not.allocated(var_icoutput)) then 231 allocate(var_icoutput(nbic,nvaric),stat=err) 232 if (err/=0) then 233 print *,"erreur a l'allocation du tableau var_icoutput dans init_outshort",err 234 stop 4 235 end if 236 end if 237 ! lecture des infos sur les variables : 238 do k=1,nbic 239 read(568,'(a100)') ic_name(k) 240 !ic_name(k)=trim(ic_name(k)) 241 read(568,*) ic_lon(k) 242 read(568,*) ic_lat(k) 243 read(568,*) 244 enddo 245 close(568) 246 ! recherche du point i,j correspondant aux coordonnées lon,lat de chaque site de forage 247 do k=1,nbic 248 dist_lonlat = 1.e7 ! initialisation 249 dist_lonlat_new = 1.e6 ! initialisation 250 ! on part du centre de la grille 251 ! jj=int(ny/2) 252 ! ii=int(nx/2) 253 jj=6 254 ii=6 255 nloop=0 256 do while (dist_lonlat_new .LT. dist_lonlat .AND. nloop .LT. 10000) 257 nloop=nloop+1 258 dist_lonlat = dist_lonlat_new 259 ii = iic(k) 260 jj = jic(k) 261 do j=max(jj-5,1),min(jj+5,ny) 262 do i=max(ii-5,1),min(ii+5,nx) 263 distance = abs(xlong(i,j) - ic_lon(k)) + abs(ylat(i,j) - ic_lat(k)) 264 if (distance .LT. dist_lonlat) then 265 dist_lonlat_new = distance 266 iic(k) = i 267 jic(k) = j 268 endif 269 enddo 270 enddo 271 enddo 272 print*,'init_outshort : ice core ', trim(ic_name(k)), nloop 273 print*,'init_outshort lon,lat', ic_lon(k),ic_lat(k) 274 print*,'init_outshort i,j',iic(k),jic(k) 275 print*,'init_outshort lon lat GRISLI',xlong(iic(k),jic(k)),ylat(iic(k),jic(k)) 276 enddo 277 278 279 280 ! creation du fichier Netcdf : 281 status=nf90_create(path = trim(dirnameout)//'icecore'//runname//'.nc', cmode = nf90_clobber, ncid = ncidic) 282 if (status /= nf90_noerr) call handle_err(status) 283 284 ! definition des dimension : 285 status=nf90_def_dim(ncidic, name="time", len=NF90_UNLIMITED, dimid=timeDimIDic) 286 if (status /= nf90_noerr) call handle_err(status) 287 status=nf90_def_var(ncidic, name="time", xtype=nf90_float, dimids=(/ timeDimIDic/), varid=timeVarIDic) 288 if (status /= nf90_noerr) call handle_err(status) 289 status=nf90_put_att(ncidic, timeVarIDic, "standard_name", "time") 290 if (status /= nf90_noerr) call handle_err(status) 291 status=nf90_put_att(ncidic, timeVarIDic,"units", "years since 0000-01-01 00:00:00") 292 if (status /= nf90_noerr) call handle_err(status) 293 status=nf90_put_att(ncidic, timeVarIDic,"calendar", "360_day") 294 if (status /= nf90_noerr) call handle_err(status) 295 296 ! dimension "station" Sites de forages 297 status=nf90_def_dim(ncidic, name="station", len=nbic, dimid=stationDimIDic) 298 if (status /= nf90_noerr) call handle_err(status) 299 status=nf90_def_dim(ncidic, name="name_strlen", len=len(ic_name(1)), dimid=station_strlenDimIDic) 300 if (status /= nf90_noerr) call handle_err(status) 301 status=nf90_def_var(ncidic, name="station_name", xtype=nf90_char, dimids=(/ station_strlenDimIDic, stationDimIDic /), varid=stationVarIDic) 302 if (status /= nf90_noerr) call handle_err(status) 303 status=nf90_put_att(ncidic, stationVarIDic, "standard_name", "station_name") 304 if (status /= nf90_noerr) call handle_err(status) 305 status=nf90_put_att(ncidic, stationVarIDic, "long_name", "station name") 306 if (status /= nf90_noerr) call handle_err(status) 307 status=nf90_def_var(ncidic, name="lon", xtype=nf90_float, dimids=(/ stationDimIDic/), varid=lonVarIDic) 308 if (status /= nf90_noerr) call handle_err(status) 309 status=nf90_put_att(ncidic, lonVarIDic, "standard_name", "longitude") 310 if (status /= nf90_noerr) call handle_err(status) 311 status=nf90_put_att(ncidic, lonVarIDic, "long_name", "station longitude") 312 if (status /= nf90_noerr) call handle_err(status) 313 status=nf90_def_var(ncidic, name="lat", xtype=nf90_float, dimids=(/ stationDimIDic/), varid=latVarIDic) 314 if (status /= nf90_noerr) call handle_err(status) 315 status=nf90_put_att(ncidic, latVarIDic, "standard_name", "latitude") 316 if (status /= nf90_noerr) call handle_err(status) 317 status=nf90_put_att(ncidic, latVarIDic, "long_name", "station latitude") 318 if (status /= nf90_noerr) call handle_err(status) 319 320 321 ! infos sur les variables : 322 open(568,file=trim(dirsource)//'/Fichiers-parametres/icecore-var.dat',status='old') 323 ! lecture en-tete 324 read(568,*) 325 read(568,*) 326 read(568,*) 327 read(568,*) 328 read(568,*) 329 ! lecture des infos sur les variables : 330 do l=1,nvaric 331 read(568,'(a100)') namevaric(l) 332 read(568,'(a100)') standard_nameic(l) 333 read(568,'(a100)') long_nameic(l) 334 read(568,'(a100)') unitsic(l) 335 read(568,*) 336 enddo 337 close(568) 338 339 ! definition des variables de sortie : 340 do l=1,nvaric ! boucle sur le nbr de variable a definir 341 status=nf90_def_var(ncidic, name=trim(namevaric(l)), xtype=nf90_float, dimids= & 342 (/ stationDimIDic, timeDimIDic /), varid=varIDic(l)) 343 if (status /= nf90_noerr) call handle_err(status) 344 status=nf90_put_att(ncidic, varIDic(l), "standard_name", trim(standard_nameic(l))) 345 if (status /= nf90_noerr) call handle_err(status) 346 status=nf90_put_att(ncidic, varIDic(l), "long_name", trim(long_nameic(l))) 347 if (status /= nf90_noerr) call handle_err(status) 348 status=nf90_put_att(ncidic, varIDic(l), "units", trim(unitsic(l))) 349 if (status /= nf90_noerr) call handle_err(status) 350 status=nf90_put_att(ncidic, varIDic(l), "coordinates", "lon lat") 351 if (status /= nf90_noerr) call handle_err(status) 352 enddo 353 354 ! fin de la definition du fichier : 355 status=nf90_enddef(ncidic) 356 if (status /= nf90_noerr) call handle_err(status) 357 358 nbtimeoutic = 0 ! initialisation compteur sorties axe time 359 ! ecriture des noms des sites de forage dans la variable site : 360 ! do k=1,nbic 361 ! status=nf90_put_var(ncidic, stationVarIDic, trim(ic_name(k)),start=(/k/),count=(/1/)) 362 ! if (status /= nf90_noerr) call handle_err(status) 363 ! enddo 364 print*,'ic_name',ic_name 365 status=nf90_put_var(ncidic, stationVarIDic, ic_name) !,start=(/1/),count=(/nbic/)) 366 if (status /= nf90_noerr) call handle_err(status) 367 368 status=nf90_put_var(ncidic, lonVarIDic, ic_lon,start=(/1/),count=(/nbic/)) 369 if (status /= nf90_noerr) call handle_err(status) 370 371 status=nf90_put_var(ncidic, latVarIDic, ic_lat,start=(/1/),count=(/nbic/)) 372 if (status /= nf90_noerr) call handle_err(status) 373 ! print*, 'debug 2 init_outshort' 374 endif 375 376 145 377 146 378 end subroutine init_outshort … … 319 551 320 552 553 ! ecriture netcdf ice core output (tous les 50 ans) 554 if (ncicecoreout.eq.1 .and. (mod(abs(time),dticecoreout).lt.dtmin)) then ! ecriture netcdf 555 nbtimeoutic=nbtimeoutic+1 556 do k=1,nbic ! boucle sur les stations 557 ! Surface elevation 558 var_icoutput(k,1)=S(iic(k),jic(k)) 559 ! Ice thickness 560 var_icoutput(k,2)=H(iic(k),jic(k)) 561 ! Bedrock elevation 562 var_icoutput(k,3)=Bsoc(iic(k),jic(k)) 563 ! Surface Mass Balance 564 var_icoutput(k,4)=Bm(iic(k),jic(k)) 565 ! Basal melt 566 var_icoutput(k,5)=Bmelt(iic(k),jic(k)) 567 ! Surface velocity in x 568 var_icoutput(k,6)=Uxbar(iic(k),jic(k)) 569 ! Surface velocity in y 570 var_icoutput(k,7)=Uybar(iic(k),jic(k)) 571 ! Velocity magnitude 572 var_icoutput(k,8)=sqrt(Uxbar(iic(k),jic(k))**2 + Uybar(iic(k),jic(k))**2) 573 ! Surface Temperature 574 var_icoutput(k,9)=Ts(iic(k),jic(k)) 575 ! Accumulation 576 var_icoutput(k,10)=Acc(iic(k),jic(k)) 577 enddo 578 ! ecriture de time 579 status=nf90_put_var(ncidic, timeVarIDic, time, start=(/nbtimeoutic/)) 580 if (status /= nf90_noerr) call handle_err(status) 581 582 do l=1,nvaric ! boucle sur le nbr de variables a ecrire 583 status=nf90_put_var(ncidic, varIDic(l), var_icoutput(:,l),start=(/1,nbtimeoutic/)) 584 if (status /= nf90_noerr) call handle_err(status) 585 enddo 586 status=nf90_sync(ncidic) 587 if (status /= nf90_noerr) call handle_err(status) 588 endif 589 590 591 321 592 end subroutine shortoutput 322 593
Note: See TracChangeset
for help on using the changeset viewer.