source: branches/GRISLIv3/SOURCES/Ant40_files/output_anta40_mod-0.4.f90 @ 456

Last change on this file since 456 was 456, checked in by dumas, 6 months ago

Change time unit in ice core output to make file readable by ferret

File size: 21.8 KB
Line 
1!> \file output_anta_mod-0.4.f90
2!! Module de
3!<
4
5!> \namespace output_antarcti_mod
6!! Module de
7!! \author ...
8!! \date ...
9!! @note Used module
10!! @note   - use module3D_phy
11!<
12
13module  output_antarcti_mod
14
15use module3D_phy,only: ndisp,xlong,ylat,vol,np,hmax,b,s,acc,h,t,tbdot,ux,uy,uzk,uzsdot, &
16              hdot,bdot,hmean,num_ritz,tafor,sealevel,ts
17use geography, only: nx,ny,nz,geoplace,dirnameinp
18use runparam, only: dirnameout,runname
19use bilan_eau_mod
20use netcdf
21use io_netcdf_grisli
22use bilan_flux_mod
23
24implicit none
25     
26!real ::  vol ; !integer :: np
27integer :: nflot                      !< nbr de point flottant
28real ::  bmean                        !<
29real ::  accmean                      !< accumulation moyenne
30real ::  ablmean                      !< ablation moyenne
31real ::  calvmean                     !< moyenne calving
32real ::  ablbordmean                  !<
33real ::  bmeltmean                    !< moyenne fusion basale
34real ::  tbmean                       !< temperature basale moyenne
35real ::  tbdotmean                    !< moyenne variation / temps temperature basale
36real ::  vsmean                       !< vitesse de surface moyenne
37!real ::  vsdotmean                    !< moyenne variation / temps vitesse de surface
38!real ::  uzsmean   !!!! utilise ?     !< vitesse verticale de surface moyenne
39real ::  uzsdotmean                   !< moyenne variation / temps vitesse verticale de surface
40real ::  uzkmean                      !< moyenne vitesse verticale de surface
41real ::  hdotmean                     !< moyenne derivee / temps de h
42real ::  bdotmean                     !< moyenne bedrock derive / temps
43real ::  volf                         !< volume au dessus de la flottaison
44
45real :: lim                           !< Total ice mass
46real :: iareag                        !< surface posee
47real :: iareaf                        !< surface flottante
48real :: tendacabf                     !< Total SMB flux
49real :: tendlibmassbf                 !< Total Basal mass balance flux
50real :: tendlibmassbffl               !< Total Basal mass balance flux on floating ice
51real :: tendlicalvf                   !< Total calving flux
52real :: tendlifmassbf                 !< Total calving and ice front melting flux
53real :: tendligroundf                 !< Total grounding line flux
54
55real,dimension(nx,ny) :: corrsurf     !< facteur de correction de la surface
56!real,parameter :: ice_density=910.    !< densite de la glace pour conversion en masse
57
58! variables netcdf
59integer,parameter :: ncshortout=1 ! 1 sorties netcdf short initMIP
60integer,parameter :: nvar=10 ! nombre de variables dans le fichier de sortie temporel netcdf
61integer :: ncid
62integer :: status
63integer :: timeDimID
64integer :: timeVarID
65integer,dimension(nvar) :: varID
66integer :: nbtimeout  ! index time output
67real,dimension(nvar) :: var_shortoutput
68
69! variables netcdf icecore (ic)
70integer,parameter :: ncicecoreout=1 ! 1 sorties netcdf icecore / 0 no output
71integer :: nbic ! number of ice core site in output
72integer,parameter :: nvaric=10 ! nombre de variables dans le fichier ice core
73real,parameter :: dticecoreout=50. ! sorties ice core tous les dticecoreout
74integer :: ncidic
75integer :: timeDimIDic
76integer :: timeVarIDic
77integer :: stationDimIDic
78integer :: stationVarIDic
79integer :: station_strlenDimIDic
80integer :: lonVarIDic
81integer :: latVarIDic
82integer,dimension(nvaric) :: varIDic
83integer :: nbtimeoutic  ! index time output
84real,allocatable,dimension(:,:) :: var_icoutput
85character(len=100), allocatable, dimension(:) :: site_nameic
86integer, allocatable, dimension(:) :: iic,jic ! coordonnees i,j des sites ice core
87
88CONTAINS
89
90subroutine init_outshort
91
92double precision,dimension(:,:),pointer      :: tab               !< tableau 2d real pointer
93character(len=100),dimension(nvar) :: namevar ! name, standard_name, long_name, units
94character(len=100),dimension(nvar) :: standard_name
95character(len=100),dimension(nvar) :: long_name
96character(len=100),dimension(nvar) :: units
97
98! ice core variables
99character(len=100),allocatable,dimension(:) :: ic_name ! ice core name
100real,allocatable,dimension(:) :: ic_lon ! ice core lon
101real,allocatable,dimension(:) :: ic_lat ! ice core lat
102character(len=100),dimension(nvaric) :: namevaric ! name, standard_name, long_name, units
103character(len=100),dimension(nvaric) :: standard_nameic
104character(len=100),dimension(nvaric) :: long_nameic
105character(len=100),dimension(nvaric) :: unitsic
106integer :: err ! recuperation erreur
107integer :: ii,jj
108integer :: nloop ! nbr de tour dans la boucle while (evite boucle folle)
109real :: dist_lonlat, dist_lonlat_new, distance ! distance to lon lat ice core site
110integer :: i,j,k,l
111
112
113!ndisp sorite courte tous les ndisp
114NDISP=100
115
116
117if (ncshortout.eq.1) then  ! ecriture netcdf
118
119! lecture du fichier avec les corrections de surface
120  if (geoplace.eq.'ant16km') then
121      call Read_Ncdf_var('z',trim(DIRNAMEINP)//'/corrsurf-initMIP-16km.grd',tab)
122      corrsurf(:,:)=tab(:,:)
123  else
124      corrsurf(:,:)= 1.
125  end if
126
127  open(568,file=trim(dirsource)//'/Fichiers-parametres/short-ISMIPnc.dat',status='old')
128! lecture en-tete
129  read(568,*)
130  read(568,*)
131  read(568,*)
132  read(568,*)
133  read(568,*)
134! lecture des infos sur les variables :
135  do k=1,nvar
136    read(568,'(a100)') namevar(k)
137    read(568,'(a100)') standard_name(k)
138    read(568,'(a100)') long_name(k)
139    read(568,'(a100)') units(k)
140    read(568,*)
141  enddo
142  close(568)
143 
144! Fichier Netcdf initMIP
145! creation du fichier Netcdf :
146  status=nf90_create(path = trim(dirnameout)//'short'//runname//'.nc', cmode = nf90_clobber, ncid = ncid)
147  if (status /= nf90_noerr) call handle_err(status)
148
149! definition des dimension :
150  status=nf90_def_dim(ncid, name="time", len=NF90_UNLIMITED, dimid=timeDimID)
151  if (status /= nf90_noerr) call handle_err(status)
152  status=nf90_def_var(ncid, name="time", xtype=nf90_float, dimids=(/ timeDimID/), varid=timeVarID) 
153  if (status /= nf90_noerr) call handle_err(status)
154  status=nf90_put_att(ncid, timeVarID, "standard_name", "time")
155  if (status /= nf90_noerr) call handle_err(status)
156  status=nf90_put_att(ncid, timeVarID,"units", "years since 1995-01-01 00:00:00")
157  if (status /= nf90_noerr) call handle_err(status)
158  status=nf90_put_att(ncid, timeVarID,"calendar", "360_day")
159  if (status /= nf90_noerr) call handle_err(status)
160 
161! definition des variables de sortie :
162  do k=1,nvar  ! boucle sur le nbr de variable a definir
163    status=nf90_def_var(ncid, name=trim(namevar(k)), xtype=nf90_float, dimids= &
164          (/ timeDimID /), varid=varID(k))
165    if (status /= nf90_noerr) call handle_err(status)
166    status=nf90_put_att(ncid, varID(k), "standard_name", trim(standard_name(k)))
167    if (status /= nf90_noerr) call handle_err(status)
168    status=nf90_put_att(ncid, varID(k), "long_name", trim(long_name(k)))
169    if (status /= nf90_noerr) call handle_err(status)
170    status=nf90_put_att(ncid, varID(k), "units", trim(units(k)))
171    if (status /= nf90_noerr) call handle_err(status)
172  enddo
173
174! fin de la definition du fichier :
175  status=nf90_enddef(ncid)
176  if (status /= nf90_noerr) call handle_err(status)
177  nbtimeout = 0 ! initialisation compteur sorties axe time
178else ! pas de sortie netcdf et sans correction de surface
179  corrsurf(:,:)=1.
180endif
181
182
183if (ncicecoreout.eq.1) then  ! ecriture netcdf Ice Core
184! Fichier Netcdf ice core Antarctique
185! Lecture du fichier avec la liste des sites de forages
186! infos sur les variables :
187  open(568,file=trim(dirsource)//'/Fichiers-parametres/icecore-Ant.dat',status='old')
188  ! lecture en-tete
189  read(568,*)
190  read(568,*)
191  read(568,*)
192  read(568,*)
193  read(568,*)
194  ! lectuire du nombre de sites de forages:
195  read(568,*) nbic
196  read(568,*)
197  ! allocation des variables dependant du nombre de site de forage (nbic)
198  if (.not.allocated(iic)) then
199     allocate(iic(nbic),stat=err)
200     if (err/=0) then
201        print *,"erreur a l'allocation du tableau iic dans init_outshort",err
202        stop 4
203     end if
204  end if
205  if (.not.allocated(jic)) then
206     allocate(jic(nbic),stat=err)
207     if (err/=0) then
208        print *,"erreur a l'allocation du tableau jic dans init_outshort",err
209        stop 4
210     end if
211  end if
212  if (.not.allocated(ic_name)) then
213     allocate(ic_name(nbic),stat=err)
214     if (err/=0) then
215        print *,"erreur a l'allocation du tableau ic_name dans init_outshort",err
216        stop 4
217     end if
218  end if
219  if (.not.allocated(ic_lon)) then
220     allocate(ic_lon(nbic),stat=err)
221     if (err/=0) then
222        print *,"erreur a l'allocation du tableau ic_lon dans init_outshort",err
223        stop 4
224     end if
225  end if
226  if (.not.allocated(ic_lat)) then
227     allocate(ic_lat(nbic),stat=err)
228     if (err/=0) then
229        print *,"erreur a l'allocation du tableau ic_lat dans init_outshort",err
230        stop 4
231     end if
232  end if
233  if (.not.allocated(var_icoutput)) then
234     allocate(var_icoutput(nbic,nvaric),stat=err)
235     if (err/=0) then
236        print *,"erreur a l'allocation du tableau var_icoutput dans init_outshort",err
237        stop 4
238     end if
239  end if
240! lecture des infos sur les variables :
241  do k=1,nbic
242     read(568,'(a100)') ic_name(k)
243     !ic_name(k)=trim(ic_name(k))
244     read(568,*) ic_lon(k)
245     read(568,*) ic_lat(k)
246     read(568,*)
247  enddo
248 close(568)
249 ! recherche du point i,j correspondant aux coordonnées lon,lat de chaque site de forage
250 do k=1,nbic
251    dist_lonlat = 1.e7 ! initialisation
252    dist_lonlat_new = 1.e6 ! initialisation
253    ! on part du centre de la grille
254    !    iic(k)=int(nx/2)
255    !    jic(k)=int(ny/2)
256    iic(k)=6
257    jic(k)=6
258    nloop=0
259    do while (dist_lonlat_new .LT. dist_lonlat .AND. nloop .LT. 10000)
260       nloop=nloop+1
261       dist_lonlat = dist_lonlat_new
262       ii = iic(k)
263       jj = jic(k)
264       do j=max(jj-5,1),min(jj+5,ny)
265          do i=max(ii-5,1),min(ii+5,nx)
266             distance = abs(xlong(i,j) - ic_lon(k)) + abs(ylat(i,j) - ic_lat(k))
267             if (distance .LT. dist_lonlat) then
268                dist_lonlat_new = distance
269                iic(k) = i
270                jic(k) = j
271             endif
272          enddo
273       enddo
274    enddo
275    !print*,'init_outshort : ice core ', trim(ic_name(k)), nloop
276    !print*,'init_outshort lon,lat', ic_lon(k),ic_lat(k)
277    !print*,'init_outshort i,j',iic(k),jic(k)
278    !print*,'init_outshort lon lat GRISLI',xlong(iic(k),jic(k)),ylat(iic(k),jic(k))
279 enddo           
280         
281
282
283! creation du fichier Netcdf :
284  status=nf90_create(path = trim(dirnameout)//'icecore'//runname//'.nc', cmode = nf90_clobber, ncid = ncidic)
285  if (status /= nf90_noerr) call handle_err(status)
286
287  ! definition des dimension :
288  status=nf90_def_dim(ncidic, name="time", len=NF90_UNLIMITED, dimid=timeDimIDic)
289  if (status /= nf90_noerr) call handle_err(status)
290  status=nf90_def_var(ncidic, name="time", xtype=nf90_float, dimids=(/ timeDimIDic/), varid=timeVarIDic) 
291  if (status /= nf90_noerr) call handle_err(status)
292  status=nf90_put_att(ncidic, timeVarIDic, "standard_name", "time")
293  if (status /= nf90_noerr) call handle_err(status)
294  status=nf90_put_att(ncidic, timeVarIDic,"units", "years")
295  if (status /= nf90_noerr) call handle_err(status)
296  status=nf90_put_att(ncidic, timeVarIDic,"calendar", "360_day")
297  if (status /= nf90_noerr) call handle_err(status)
298 
299  ! dimension "station" Sites de forages
300  status=nf90_def_dim(ncidic, name="station", len=nbic, dimid=stationDimIDic)
301  if (status /= nf90_noerr) call handle_err(status)
302  status=nf90_def_dim(ncidic, name="name_strlen", len=len(ic_name(1)), dimid=station_strlenDimIDic)
303  if (status /= nf90_noerr) call handle_err(status)
304  status=nf90_def_var(ncidic, name="station_name", xtype=nf90_char, dimids=(/ station_strlenDimIDic, stationDimIDic /), varid=stationVarIDic) 
305  if (status /= nf90_noerr) call handle_err(status)
306  status=nf90_put_att(ncidic, stationVarIDic, "standard_name", "station_name")
307  if (status /= nf90_noerr) call handle_err(status)
308  status=nf90_put_att(ncidic, stationVarIDic, "long_name", "station name")
309  if (status /= nf90_noerr) call handle_err(status)
310  status=nf90_def_var(ncidic, name="lon", xtype=nf90_float, dimids=(/ stationDimIDic/), varid=lonVarIDic) 
311  if (status /= nf90_noerr) call handle_err(status)
312  status=nf90_put_att(ncidic, lonVarIDic, "standard_name", "longitude")
313  if (status /= nf90_noerr) call handle_err(status)
314  status=nf90_put_att(ncidic, lonVarIDic, "long_name", "station longitude")
315  if (status /= nf90_noerr) call handle_err(status)
316  status=nf90_def_var(ncidic, name="lat", xtype=nf90_float, dimids=(/ stationDimIDic/), varid=latVarIDic) 
317  if (status /= nf90_noerr) call handle_err(status)
318  status=nf90_put_att(ncidic, latVarIDic, "standard_name", "latitude")
319  if (status /= nf90_noerr) call handle_err(status)
320  status=nf90_put_att(ncidic, latVarIDic, "long_name", "station latitude")
321  if (status /= nf90_noerr) call handle_err(status)
322
323 
324! infos sur les variables :
325  open(568,file=trim(dirsource)//'/Fichiers-parametres/icecore-var.dat',status='old')
326! lecture en-tete
327  read(568,*)
328  read(568,*)
329  read(568,*)
330  read(568,*)
331  read(568,*)
332! lecture des infos sur les variables :
333  do l=1,nvaric
334    read(568,'(a100)') namevaric(l)
335    read(568,'(a100)') standard_nameic(l)
336    read(568,'(a100)') long_nameic(l)
337    read(568,'(a100)') unitsic(l)
338    read(568,*)
339 enddo
340 close(568)
341 
342! definition des variables de sortie :
343  do l=1,nvaric  ! boucle sur le nbr de variable a definir
344    status=nf90_def_var(ncidic, name=trim(namevaric(l)), xtype=nf90_float, dimids= &
345          (/ stationDimIDic, timeDimIDic /), varid=varIDic(l))
346    if (status /= nf90_noerr) call handle_err(status)
347    status=nf90_put_att(ncidic, varIDic(l), "standard_name", trim(standard_nameic(l)))
348    if (status /= nf90_noerr) call handle_err(status)
349    status=nf90_put_att(ncidic, varIDic(l), "long_name", trim(long_nameic(l)))
350    if (status /= nf90_noerr) call handle_err(status)
351    status=nf90_put_att(ncidic, varIDic(l), "units", trim(unitsic(l)))
352    if (status /= nf90_noerr) call handle_err(status)
353  enddo
354
355! fin de la definition du fichier :
356  status=nf90_enddef(ncidic)
357  if (status /= nf90_noerr) call handle_err(status)
358 
359  nbtimeoutic = 0 ! initialisation compteur sorties axe time
360  ! ecriture des noms des sites de forage dans la variable site :
361!  do k=1,nbic
362!     status=nf90_put_var(ncidic, stationVarIDic, trim(ic_name(k)),start=(/k/),count=(/1/))
363!     if (status /= nf90_noerr) call handle_err(status)
364!  enddo
365  !print*,'ic_name',ic_name   
366  status=nf90_put_var(ncidic, stationVarIDic, ic_name) !,start=(/1/),count=(/nbic/))
367  if (status /= nf90_noerr) call handle_err(status)
368
369  status=nf90_put_var(ncidic, lonVarIDic, ic_lon,start=(/1/),count=(/nbic/))
370  if (status /= nf90_noerr) call handle_err(status)
371     
372  status=nf90_put_var(ncidic, latVarIDic, ic_lat,start=(/1/),count=(/nbic/))
373  if (status /= nf90_noerr) call handle_err(status)
374!     print*, 'debug 2 init_outshort'
375endif
376
377
378
379end subroutine init_outshort
380
381
382
383!_________________________________________________________________________
384subroutine shortoutput
385
386! 1_initialization
387!------------------
388real ::  smax
389integer :: i,j,k,l
390
391      vol=0. 
392      np=0
393      nflot=0
394      hmax=0. 
395      smax=0.
396      bmean=0. 
397      accmean=0. 
398      ablmean=0. 
399      calvmean=0. 
400      ablbordmean=0.
401      bmeltmean=0.
402      tbmean=0.
403      tbdotmean=0.
404      vsmean=0.
405!      vsdotmean=0.
406!      uzsmean=0.
407      uzsdotmean=0.
408      uzkmean=0.
409      hdotmean=0.
410      bdotmean=0.
411      volf=0.
412      lim=0.
413      tendacabf=0.
414      iareag=0.
415      iareaf=0.
416      tendlicalvf=0.
417      tendligroundf=0.
418      tendlibmassbf=0.
419      tendlibmassbffl=0.
420      tendlifmassbf=0.
421! 2_preparing outputs
422!--------------------     
423    do j=1,ny
424      do i=1,nx
425        if (ice(i,j).eq.1) then ! point englace
426          if (.not.flot(i,j)) then ! point pose
427            np=np+1
428            vol=vol+h(i,j)
429            iareag=iareag+1.*corrsurf(i,j)                            ! surface englacee posee
430
431!         calcul de la hauteur au dessus de la flottaison
432            if (sealevel_2d(i,j)-B(i,j).le.0.) then    ! socle au dessus du niveau des mers
433              volf=volf+h(i,j)*corrsurf(i,j)                          ! volume au-dessus de la flottaison
434            else
435              volf=volf+(h(i,j)-row/ro*(sealevel_2d(i,j)-b(i,j)))*corrsurf(i,j) ! volume au-dessus de la flottaison
436            endif
437
438            if (h(i,j).gt.hmax) hmax=h(i,j) 
439            if (s(i,j).gt.smax) smax=s(i,j) 
440            bmean=bm(i,j)+bmean 
441            accmean=acc(i,j)+accmean
442            tbmean=tbmean+t(i,j,nz)
443            tbdotmean=tbdotmean+tbdot(i,j)
444            vsmean=vsmean+sqrt(ux(i,j,1)**2+uy(i,j,1)**2)
445!          vsdotmean=vsdotmean+vsdot(i,j)
446!          uzsmean=uzsmean+uz(i,j,1)
447            uzsdotmean=uzsdotmean+uzsdot(i,j)
448            uzkmean=uzkmean+uzk(i,j)
449            hdotmean=hdotmean+abs(hdot(i,j)) 
450            bdotmean=bdotmean+abs(bdot(i,j)) 
451            bmeltmean=bmeltmean+bmelt(i,j)
452          else ! point flottant
453            iareaf=iareaf+1.*corrsurf(i,j)                               ! surface flottante
454            tendlibmassbffl=tendlibmassbffl-bmelt_dtt(i,j)*corrsurf(i,j)/dtt_flux   ! fonte basale sur zone flottante
455          endif
456          lim=lim+h(i,j)*corrsurf(i,j)                                   ! volume total de glace
457          tendacabf=tendacabf+bm_dtt(i,j)*corrsurf(i,j)/dtt_flux              ! smb surface
458          tendlibmassbf=tendlibmassbf-bmelt_dtt(i,j)*corrsurf(i,j)/dtt_flux   ! fonte basale     
459        endif
460        tendlicalvf=tendlicalvf+calv_dtt(i,j)*corrsurf(i,j)/dtt_flux        ! calving
461        tendlifmassbf=tendlifmassbf+(calv_dtt(i,j)-ablbord_dtt(i,j))*corrsurf(i,j)/dtt_flux ! calving + ablbord (ablbord est positif)
462        tendligroundf=tendligroundf+grline_dtt(i,j)*corrsurf(i,j)/dtt_flux  ! flux a la grounding line
463      end do
464    end do
465
466
467      if (np.ne.0) then
468        hmean=vol/np 
469        vol=vol*dx*dy 
470        volf=volf*dx*dy*ice_density
471        bmean=bmean/np 
472        accmean=accmean/np 
473        ablmean=bmean-accmean 
474        calvmean=calvmean/np 
475        bmeltmean=bmeltmean/np
476        ablbordmean=ablbordmean/np
477        tbmean=tbmean/np
478        tbdotmean=tbdotmean/np
479        vsmean=vsmean/np
480!        vsdotmean=vsdotmean/np
481!        uzsmean=uzsmean/np
482        uzsdotmean=uzsdotmean/np
483        uzkmean=uzkmean/np
484        hdotmean=hdotmean/np
485      endif
486      lim=lim*dx*dy*ice_density
487      iareag=iareag*dx*dy 
488      iareaf=iareaf*dx*dy
489      tendacabf=tendacabf*dx*dy*ice_density/secyear
490      tendlibmassbf=tendlibmassbf*dx*dy*ice_density/secyear
491      tendlibmassbffl=tendlibmassbffl*dx*dy*ice_density/secyear
492      tendlicalvf=tendlicalvf*dx*dy*ice_density/secyear
493      tendlifmassbf=tendlifmassbf*dx*dy*ice_density/secyear
494      tendligroundf=tendligroundf*ice_density/secyear
495     
496     
497      bdotmean=bdotmean/nx/ny 
498
499
500! 2_writing outputs
501!------------------   
502!     **** short display ****
503
504        write(num_ritz,904) nt,time,tafor,sealevel,vol,volf,np, &
505          nint(hmean),nint(smax),                    &
506          bmean,tbmean,nint(vsmean),                 &
507                                  tbdotmean,hdotmean,dt,accmean, &
508                                  diff_H,water_bilan,sum(calv_dtt(:,:))/dtt_flux, &
509                                  sum(ablbord_dtt(:,:))/dtt_flux, &
510                                  sum(Bm_dtt(:,:))/dtt_flux,sum(bmelt_dtt(:,:))/dtt_flux
511
512
513903   format(i8,1x,f0.2,1x,f0.4,1x,f0.2,1x,2(e10.5,1x),i6,1x,i4,1x,i5,1x, &
514             f0.4,1x,f0.3,1x,i3,4(1x,e8.2),1x,f0.4,1x,f0.4) 
515904   format(i8,1x,f0.2,4(1x,e15.8),3(1x,i8),2(1x,e15.8),1x,i8,10(1x,e15.8))
516!940   format('%%%% ',a,'   time=',f8.0,' %%%%')
517
518
519if (ncshortout.eq.1) then  ! ecriture netcdf
520  ! Total ice mass
521  var_shortoutput(1)=lim
522  ! Mass above floatation
523  var_shortoutput(2)=volf
524  ! Grounded ice area
525  var_shortoutput(3)=iareag
526  ! Floating ice area
527  var_shortoutput(4)=iareaf
528  ! Total SMB flux
529  var_shortoutput(5)=tendacabf
530  ! Total Basal mass balance flux
531  var_shortoutput(6)=tendlibmassbf
532  ! Total Basal mass balance flux beneath floating ice
533  var_shortoutput(7)=tendlibmassbffl
534  ! Total calving flux
535  var_shortoutput(8)=tendlicalvf
536  ! Total calving and ice front melting flux
537  var_shortoutput(9)=tendlifmassbf
538  ! Total grounding line flux
539  var_shortoutput(10)=tendligroundf
540
541  nbtimeout=nbtimeout+1
542 
543  status=nf90_put_var(ncid, timeVarID, time, start=(/nbtimeout/))
544  if (status /= nf90_noerr) call handle_err(status)
545
546  do k=1,nvar  ! boucle sur le nbr de variable a ecrire
547    status=nf90_put_var(ncid, varID(k), var_shortoutput(k),start=(/nbtimeout/))
548    if (status /= nf90_noerr) call handle_err(status)
549  enddo
550  status=nf90_sync(ncid)
551  if (status /= nf90_noerr) call handle_err(status)
552endif
553
554
555! ecriture netcdf ice core output (tous les 50 ans)
556if (ncicecoreout.eq.1 .and. (mod(abs(time),dticecoreout).lt.dtmin)) then  ! ecriture netcdf
557   nbtimeoutic=nbtimeoutic+1
558   do k=1,nbic ! boucle sur les stations
559      ! Surface elevation
560      var_icoutput(k,1)=S(iic(k),jic(k))
561      ! Ice thickness
562      var_icoutput(k,2)=H(iic(k),jic(k))
563      ! Bedrock elevation
564      var_icoutput(k,3)=Bsoc(iic(k),jic(k))
565      ! Surface Mass Balance
566      var_icoutput(k,4)=Bm(iic(k),jic(k))
567      ! Basal melt
568      var_icoutput(k,5)=Bmelt(iic(k),jic(k))
569      ! Surface velocity in x
570      var_icoutput(k,6)=Uxbar(iic(k),jic(k))
571      ! Surface velocity in y
572      var_icoutput(k,7)=Uybar(iic(k),jic(k))
573      ! Velocity magnitude
574      var_icoutput(k,8)=sqrt(Uxbar(iic(k),jic(k))**2 + Uybar(iic(k),jic(k))**2)
575      ! Surface Temperature
576      var_icoutput(k,9)=Ts(iic(k),jic(k))
577      ! Accumulation
578      var_icoutput(k,10)=Acc(iic(k),jic(k))
579   enddo
580  ! ecriture de time
581   status=nf90_put_var(ncidic, timeVarIDic, time, start=(/nbtimeoutic/))
582   if (status /= nf90_noerr) call handle_err(status)
583   
584   do l=1,nvaric  ! boucle sur le nbr de variables a ecrire
585      status=nf90_put_var(ncidic, varIDic(l), var_icoutput(:,l),start=(/1,nbtimeoutic/))
586      if (status /= nf90_noerr) call handle_err(status)
587   enddo
588   status=nf90_sync(ncidic)
589   if (status /= nf90_noerr) call handle_err(status)
590endif
591
592
593
594end subroutine shortoutput
595
596subroutine handle_err(status)
597  integer, intent(in) :: status
598  if (status /= nf90_noerr) then
599     print*,trim(nf90_strerror(status))
600     stop "stopped"
601  end if
602end subroutine handle_err
603
604end module  output_antarcti_mod
Note: See TracBrowser for help on using the repository browser.