7 ND, DM, NDM, IO, S, K, NP, TPSNOW, HPROGRAM)
67 USE modd_assim
, ONLY : lassim, cassim_isba, nvar, cvar, nobstype, nboutput, cobs
69 USE modd_agri
, ONLY : lagrip
71 USE modi_init_io_surf_n
73 USE modi_write_field_2d_patch
74 USE modi_write_field_1d_patch
75 USE modi_end_io_surf_n
87 CHARACTER(LEN=*),
DIMENSION(:),
INTENT(IN) :: HSELECT
88 LOGICAL,
INTENT(IN) :: OSNOWDIMNC
90 LOGICAL,
INTENT(IN) :: OPATCH_BUDGET
91 TYPE(
diag_t),
INTENT(INOUT) :: D
101 CHARACTER(LEN=6),
INTENT(IN) :: HPROGRAM
107 CHARACTER(LEN=1) :: YVAR, YOBS, YTIM
108 CHARACTER(LEN=12) :: YRECFM
109 CHARACTER(LEN=100):: YCOMMENT
110 CHARACTER(LEN=2) :: YLVL
111 CHARACTER(LEN=20) :: YFORM
113 REAL,
DIMENSION(SIZE(DM%XSWI,1)) :: ZMAX
114 INTEGER :: JL, JJ, JVAR, JOBS, JP, JI, JT, JK, ISIZE
116 REAL(KIND=JPRB) :: ZHOOK_HANDLE
122 IF (
lhook)
CALL dr_hook(
'WRITE_DIAG_MISC_ISBA_N',0,zhook_handle)
124 IF ( dm%LPROSNOW )
THEN 125 CALL init_io_surf_n(dtco, u, hprogram,
'NATURE',
'ISBA ',
'WRITE',
'ISBA_PROGNOSTIC.OUT.nc' 127 CALL init_io_surf_n(dtco, u, hprogram,
'NATURE',
'ISBA ',
'WRITE',
'ISBA_DIAGNOSTICS.OUT.nc' 132 IF (dm%LSURF_MISC_BUDGET)
THEN 142 ycomment=
'Halstead coefficient averaged over tile nature (-)' 143 CALL write_surf(hselect, hprogram,yrecfm,dm%XHV(:),iresp,hcomment=ycomment
149 ycomment=
'snow fraction over ground averaged over tile nature (-)' 150 CALL write_surf(hselect, hprogram,yrecfm,dm%XPSNG(:),iresp,hcomment=ycomment
153 ycomment=
'snow fraction over vegetation averaged over tile nature (-)' 154 CALL write_surf(hselect, hprogram,yrecfm,dm%XPSNV(:),iresp,hcomment=ycomment
157 ycomment=
'total snow fraction averaged over tile nature (-)' 158 CALL write_surf(hselect, hprogram,yrecfm,dm%XPSN(:),iresp,hcomment=ycomment
163 IF (tpsnow%SCHEME==
'3-L' .OR. tpsnow%SCHEME==
'CRO')
THEN 166 ycomment=
'total surface temperature (isba+snow) over tile nature' 167 CALL write_surf(hselect, hprogram,yrecfm,d%XTS(:),iresp,hcomment=ycomment
170 ycomment=
'total radiative surface temperature (isba+snow) over tile nature' 171 CALL write_surf(hselect, hprogram,yrecfm,s%XTSRAD_NAT(:),iresp,hcomment
178 IF(io%CISBA==
'DIF')
THEN 182 DO ji = 1,np%AL(jp)%NSIZE_P
183 jj = np%AL(jp)%NR_P(ji)
185 IF (np%AL(jp)%NWG_LAYER(ji)/=
nundef.AND.np%AL(jp)%NWG_LAYER(ji)>zmax
THEN 186 zmax(jj) = np%AL(jp)%NWG_LAYER(ji)
191 DO jj=1,
SIZE(dm%XSWI,1)
193 DO jl = 1,io%NGROUND_LAYER
203 DO jl=1,io%NGROUND_LAYER
205 WRITE(ylvl,
'(I2)') jl
207 yrecfm=
'SWI'//adjustl(ylvl(:len_trim(ylvl)))
208 yrecfm=yrecfm(:len_trim(yrecfm))//
'_ISBA' 209 yform=
'(A29,I1.1,A4)' 210 IF (jl >= 10) yform=
'(A29,I2.2,A4)' 211 WRITE(ycomment,fmt=yform)
'soil wetness index for layer ',jl,
' (-)' 212 CALL write_surf(hselect, hprogram,yrecfm,dm%XSWI(:,jl),iresp,hcomment
214 yrecfm=
'TSWI'//adjustl(ylvl(:len_trim(ylvl)))
215 yrecfm=yrecfm(:len_trim(yrecfm))//
'_ISBA' 216 yform=
'(A29,I1.1,A4)' 217 IF (jl >= 10) yform=
'(A29,I2.2,A4)' 218 WRITE(ycomment,fmt=yform)
'total swi (liquid+solid) for layer ',jl,
' (-)' 219 CALL write_surf(hselect, hprogram,yrecfm,dm%XTSWI(:,jl),iresp,hcomment
224 ycomment=
'soil wetness index over the soil column (-)' 225 CALL write_surf(hselect, hprogram,yrecfm,dm%XSOIL_SWI(:),iresp,hcomment
228 ycomment=
'total soil wetness index over the soil column (-)' 229 CALL write_surf(hselect, hprogram,yrecfm,dm%XSOIL_TSWI(:),iresp,hcomment
231 yrecfm=
'WGTOT_T_ISBA' 232 ycomment=
'total water content (liquid+solid) over the soil column (kg/m2)' 233 CALL write_surf(hselect, hprogram,yrecfm,dm%XSOIL_TWG(:),iresp,hcomment
236 ycomment=
'total ice content (solid) over the soil column (kg/m2)' 237 CALL write_surf(hselect, hprogram,yrecfm,dm%XSOIL_TWGI(:),iresp,hcomment
240 ycomment=
'total volumetric water content (liquid+solid) over the soil column (m3/m3)' 241 CALL write_surf(hselect, hprogram,yrecfm,dm%XSOIL_WG(:),iresp,hcomment
245 ycomment=
'total volumetric ice content (solid) over the soil column (m3/m3)' 246 CALL write_surf(hselect, hprogram,yrecfm,dm%XSOIL_WGI(:),iresp,hcomment
249 IF(io%CISBA==
'DIF')
THEN 251 IF (dm%LSURF_MISC_DIF)
THEN 253 yrecfm=
'TSWI_D2_ISBA' 254 ycomment=
'total soil wetness index over comparable FR-DG2 reservoir (-)' 255 CALL write_surf(hselect, hprogram,yrecfm,dm%XFRD2_TSWI(:),iresp,hcomment
258 ycomment=
'liquid water content over comparable FR-DG2 reservoir (m3/m3)' 259 CALL write_surf(hselect, hprogram,yrecfm,dm%XFRD2_TWG(:),iresp,hcomment
262 ycomment=
'ice content over comparable FR-DG2 reservoir (m3/m3)' 263 CALL write_surf(hselect, hprogram,yrecfm,dm%XFRD2_TWGI(:),iresp,hcomment
265 yrecfm=
'TSWI_D3_ISBA' 266 ycomment=
'total soil wetness index over comparable FR-DG3 reservoir (-)' 267 CALL write_surf(hselect, hprogram,yrecfm,dm%XFRD3_TSWI(:),iresp,hcomment
270 ycomment=
'liquid water content over comparable FR-DG3 reservoir (m3/m3)' 271 CALL write_surf(hselect, hprogram,yrecfm,dm%XFRD3_TWG(:),iresp,hcomment
274 ycomment=
'ice content over comparable FR-DG3 reservoir (m3/m3)' 275 CALL write_surf(hselect, hprogram,yrecfm,dm%XFRD3_TWGI(:),iresp,hcomment
280 ycomment=
'active layer thickness over permafrost (m)' 281 CALL write_surf(hselect, hprogram,yrecfm,dm%XALT(:),iresp,hcomment=ycomment
284 ycomment=
'frozen layer thickness over non-permafrost (m)' 285 CALL write_surf(hselect, hprogram,yrecfm,dm%XFLT(:),iresp,hcomment=ycomment
293 ycomment=
'Total_snow_reservoir (kg/m2)' 294 CALL write_surf(hselect, hprogram,yrecfm,dm%XTWSNOW(:),iresp,hcomment=ycomment
297 ycomment=
'Total_snow_depth (m)' 298 CALL write_surf(hselect, hprogram,yrecfm,dm%XTDSNOW(:),iresp,hcomment=ycomment
301 ycomment=
'Total_snow_temperature (K)' 302 CALL write_surf(hselect, hprogram,yrecfm,dm%XTTSNOW(:),iresp,hcomment=ycomment
304 IF (tpsnow%SCHEME==
'CRO' .AND. dm%LPROSNOW)
THEN 306 ycomment=
'accumulated snow thickness for past 1 days' 307 CALL write_surf(hselect,hprogram,
'SD_1DY_ISBA',dm%XSNDPT_1DY(:),iresp
309 ycomment=
'accumulated snow thickness for past 3 days' 310 CALL write_surf(hselect,hprogram,
'SD_3DY_ISBA',dm%XSNDPT_3DY(:),iresp
312 ycomment=
'accumulated snow thickness for past 5 days' 313 CALL write_surf(hselect,hprogram,
'SD_5DY_ISBA',dm%XSNDPT_5DY(:),iresp
315 ycomment=
'accumulated snow thickness for past 7 days' 316 CALL write_surf(hselect,hprogram,
'SD_7DY_ISBA',dm%XSNDPT_7DY(:),iresp
318 ycomment=
'accumulated snow water equivalent for past 1 days' 319 CALL write_surf(hselect,hprogram,
'SWE_1DY_ISBA',dm%XSNSWE_1DY(:),iresp
321 ycomment=
'accumulated snow water equivalent for past 3 days' 322 CALL write_surf(hselect,hprogram,
'SWE_3DY_ISBA',dm%XSNSWE_3DY(:),iresp
324 ycomment=
'accumulated snow water equivalent for past 5 days' 325 CALL write_surf(hselect,hprogram,
'SWE_5DY_ISBA',dm%XSNSWE_5DY(:),iresp
327 ycomment=
'accumulated snow water equivalent for past 7 days' 328 CALL write_surf(hselect,hprogram,
'SWE_7DY_ISBA',dm%XSNSWE_7DY(:),iresp
330 ycomment=
'Penetration of ram resistance sensor (2 daN)' 331 CALL write_surf(hselect,hprogram,
'RAMSOND_ISBA',dm%XSNRAM_SONDE(:),iresp
333 ycomment=
'Thickness of wet snow at the top of the snowpack' 334 CALL write_surf(hselect,hprogram,
'WET_TH_ISBA',dm%XSN_WETTHCKN(:),iresp
336 ycomment=
'Thickness of refrozen snow at the top of the snowpack' 337 CALL write_surf(hselect,hprogram,
'REFRZTH_ISBA',dm%XSN_REFRZNTHCKN(:
344 IF(io%CRUNOFF==
'SGH '.OR.io%CRUNOFF==
'DT92')
THEN 346 ycomment=
'Soil saturated fraction (-)' 347 CALL write_surf(hselect, hprogram,yrecfm,dm%XFSAT(:),iresp,hcomment=ycomment
350 IF(io%CRAIN==
'SGH ')
THEN 352 ycomment=
'fraction of the grid cell reached by the rainfall (-)' 353 CALL write_surf(hselect, hprogram,yrecfm,k%XMUF(:),iresp,hcomment=ycomment
362 ycomment=
'flood fraction over ground averaged over tile nature (-)' 363 CALL write_surf(hselect, hprogram,yrecfm,dm%XFFG(:),iresp,hcomment=ycomment
366 ycomment=
'flood fraction over vegetation averaged over tile nature (-)' 367 CALL write_surf(hselect, hprogram,yrecfm,dm%XFFV(:),iresp,hcomment=ycomment
370 ycomment=
'total flood fraction averaged over tile nature (-)' 371 CALL write_surf(hselect, hprogram,yrecfm,dm%XFF(:),iresp,hcomment=ycomment
374 ycomment=
'Grid-cell potential flood fraction (-)' 375 CALL write_surf(hselect, hprogram,yrecfm,k%XFFLOOD(:),iresp,hcomment
377 yrecfm=
'PIFLOOD_ISBA' 378 ycomment=
'Grid-cell Potential_floodplain_infiltration (kg/m2/s)' 379 CALL write_surf(hselect, hprogram,yrecfm,k%XPIFLOOD(:),iresp,hcomment
386 IF(io%CPHOTO/=
'NON'.OR.io%NPATCH>1)
THEN 388 ycomment=
'leaf area index (m2/m2)' 389 CALL write_surf(hselect, hprogram,yrecfm,dm%XLAI(:),iresp,hcomment=ycomment
398 ycomment=
'grid-cell fraction of water table to rise' 399 CALL write_surf(hselect, hprogram,yrecfm,k%XFWTD(:),iresp,hcomment=ycomment
402 ycomment=
'water table depth from RRM model or observation (m)' 403 CALL write_surf(hselect, hprogram,yrecfm,k%XWTD(:),iresp,hcomment=ycomment
409 isize = u%NSIZE_NATURE
413 IF(opatch_budget .AND. io%NPATCH>1)
THEN 419 DO jl=1,io%NGROUND_LAYER
421 WRITE(ylvl,
'(I2.0)') jl
423 yrecfm=
'SWI'//
trim(adjustl(ylvl(:)))//
'_' 424 yform=
'(A39,I1.1,A4)' 425 IF (jl >= 10) yform=
'(A39,I2.2,A4)' 426 WRITE(ycomment,fmt=yform)
'soil wetness index per patch for layer '' (-)' 429 np%AL(jp)%NR_P,ndm%AL(jp)%XSWI(:,jl),isize,s%XWORK_WR)
432 yrecfm=
'TSWI'//
trim(adjustl(ylvl(:)))//
'_' 433 yform=
'(A39,I1.1,A4)' 434 IF (jl >= 10) yform=
'(A39,I2.2,A4)' 435 WRITE(ycomment,fmt=yform)
'total swi (liquid+solid) per patch for layer '' (-)' 438 np%AL(jp)%NR_P,ndm%AL(jp)%XTSWI(:,jl),isize,s%XWORK_WR)
443 IF(io%CISBA==
'DIF')
THEN 447 ycomment=
'active layer thickness over permafrost per patch (m)' 448 WRITE(ycomment,fmt=yform)
'total swi (liquid+solid) per patch for layer '' (-)' 451 np%AL(jp)%NR_P,ndm%AL(jp)%XALT(:),isize,s%XWORK_WR)
455 ycomment=
'frozen layer thickness over non-permafrost per patch (m)' 458 np%AL(jp)%NR_P,ndm%AL(jp)%XFLT(:),isize,s%XWORK_WR)
467 ycomment=
'snow fraction per patch over ground ' 470 np%AL(jp)%NR_P,ndm%AL(jp)%XPSNG(:),isize,s%XWORK_WR)
474 ycomment=
'snow fraction per patch over vegetation' 477 np%AL(jp)%NR_P,ndm%AL(jp)%XPSNV(:),isize,s%XWORK_WR)
481 ycomment=
'total snow fraction per patch' 484 np%AL(jp)%NR_P,ndm%AL(jp)%XPSN(:),isize,s%XWORK_WR)
490 IF(io%CRUNOFF==
'SGH '.OR.io%CRUNOFF==
'DT92')
THEN 492 ycomment=
'Soil saturated fraction per patch (-)' 495 np%AL(jp)%NR_P,ndm%AL(jp)%XFSAT(:),isize,s%XWORK_WR)
505 ycomment=
'flood fraction per patch over ground ' 508 np%AL(jp)%NR_P,ndm%AL(jp)%XFFG(:),isize,s%XWORK_WR)
512 ycomment=
'flood fraction per patch over vegetation' 515 np%AL(jp)%NR_P,ndm%AL(jp)%XFFV(:),isize,s%XWORK_WR)
519 ycomment=
'total flood fraction per patch' 522 np%AL(jp)%NR_P,ndm%AL(jp)%XFF(:),isize,s%XWORK_WR)
531 IF (tpsnow%SCHEME==
'3-L' .OR. tpsnow%SCHEME==
'CRO')
THEN 534 ycomment=
'total surface temperature (isba+snow) per patch' 537 np%AL(jp)%NR_P,nd%AL(jp)%XTS(:),isize,s%XWORK_WR)
541 ycomment=
'total radiative surface temperature (isba+snow) per patch' 544 np%AL(jp)%NR_P,nd%AL(jp)%XTSRAD(:),isize,s%XWORK_WR)
553 ycomment=
'Halstead coefficient per patch' 556 np%AL(jp)%NR_P,ndm%AL(jp)%XHV(:),isize,s%XWORK_WR)
563 ycomment=
'X_Y_WSNOW_TOT (kg/m2) per patch' 566 np%AL(jp)%NR_P,ndm%AL(jp)%XTWSNOW(:),isize,s%XWORK_WR)
570 ycomment=
'X_Y_DSNOW_TOT (m) per patch' 573 np%AL(jp)%NR_P,ndm%AL(jp)%XTDSNOW(:),isize,s%XWORK_WR)
577 ycomment=
'X_Y_TSNOW_TOT (k) per patch' 580 np%AL(jp)%NR_P,ndm%AL(jp)%XTTSNOW(:),isize,s%XWORK_WR)
583 IF (tpsnow%SCHEME==
'CRO' .AND. dm%LPROSNOW)
THEN 585 ycomment=
'accumulated snow thickness for past 1 days per patch' 591 ycomment=
'accumulated snow thickness for past 3 days per patch' 597 ycomment=
'accumulated snow thickness for past 5 days per patch' 603 ycomment=
'accumulated snow thickness for past 7 days per patch' 609 ycomment=
'accumulated snow water equivalent for past 1 days per patch' 615 ycomment=
'accumulated snow water equivalent for past 3 days per patch' 621 ycomment=
'accumulated snow water equivalent for past 5 days per patch' 627 ycomment=
'accumulated snow water equivalent for past 7 days per patch' 633 ycomment=
'Penetration of ram resistance sensor (2 daN) per patch' 639 ycomment=
'Thickness of wet snow at the top of the snowpack per patch' 645 ycomment=
'Thickness of refrozen snow at the top of the snowpack per patch' 655 IF((opatch_budget.AND. io%NPATCH>1).OR.io%NPATCH==1)
THEN 657 IF ( osnowdimnc )
THEN 659 IF ( dm%LVOLUMETRIC_SNOWLIQ )
THEN 660 ycomment=
'snow liquid water (kg m-3)' 662 ycomment=
'snow liquid water (m)' 669 ycomment=
'snow temperature (K)' 675 ycomment=
'snow layer thickness' 678 'snow_layer',s%XWSN_WR
681 IF (tpsnow%SCHEME==
'CRO' .AND. dm%LPROSNOW)
THEN 683 ycomment=
'snow layer dendricity' 689 ycomment=
'snow layer sphericity' 695 ycomment=
'snow layer grain size' 701 ycomment=
'snow layer specific surface area' 707 ycomment=
'snow layer grain type' 713 ycomment=
'snow layer ram resistance' 719 ycomment=
'snow layer shear resistance' 729 DO jl=1,tpsnow%NLAYER
731 WRITE(ylvl,
'(I2)') jl
733 yrecfm=
'SNOWLIQ'//adjustl(ylvl(:len_trim(ylvl)))
734 yform=
'(A18,I1.1,A9)' 735 IF (jl >= 10) yform=
'(A18,I2.2,A9)' 736 IF ( dm%LVOLUMETRIC_SNOWLIQ )
THEN 737 WRITE(ycomment,yform)
'snow liquid water ',jl,
' (kg m-3)' 739 WRITE(ycomment,yform)
'snow liquid water ',jl,
' (m) ' 741 WRITE(ycomment,fmt=yform)
'snow liquid water',jl,
' (m)' 747 yrecfm=
'SNOWTEMP'//adjustl(ylvl(:len_trim(ylvl)))
748 yform=
'(A16,I1.1,A4)' 749 IF (jl >= 10) yform=
'(A16,I2.2,A4)' 750 WRITE(ycomment,fmt=yform)
'snow temperature',jl,
' (K)' 768 ycomment=
'irrigation threshold per patch' 771 np%AL(jp)%NR_P,ndm%AL(jp)%XSEUIL(:),isize,s%XWORK_WR)
782 np%AL(jp)%NR_P,ndm%AL(jp)%XFAPAR(:),isize,s%XWORK_WR)
789 np%AL(jp)%NR_P,ndm%AL(jp)%XFAPIR(:),isize,s%XWORK_WR)
793 ycomment=
'FAPAR_BS (-)' 796 np%AL(jp)%NR_P,ndm%AL(jp)%XFAPAR_BS(:),isize,s%XWORK_WR)
800 ycomment=
'FAPIR_BS (-)' 803 np%AL(jp)%NR_P,ndm%AL(jp)%XFAPIR_BS(:),isize,s%XWORK_WR)
807 ycomment=
'DFAPARC (-)' 810 np%AL(jp)%NR_P,ndm%AL(jp)%XDFAPARC(:),isize,s%XWORK_WR)
814 ycomment=
'DFAPIRC (-)' 817 np%AL(jp)%NR_P,ndm%AL(jp)%XDFAPIRC(:),isize,s%XWORK_WR)
821 ycomment=
'DLAI_EFFC (m2/m2)' 824 np%AL(jp)%NR_P,ndm%AL(jp)%XDLAI_EFFC(:),isize,s%XWORK_WR)
829 IF (lassim .AND. cassim_isba==
"EKF ")
THEN 832 CALL init_io_surf_n(dtco, u, hprogram,
'NATURE',
'ISBA ',
'WRITE',
'ISBA_ANALYSIS.OUT.nc' 835 WRITE(yvar,fmt=
'(I1.1)') jvar
836 yrecfm=
"ANA_INCR"//yvar
838 ycomment=
"Analysis increment for control variable "//
trim(cvar(jvar
844 WRITE(yvar,fmt=
'(I1.1)') jvar
846 WRITE(ytim,fmt=
'(I1.1)') jt
848 WRITE(yobs,fmt=
'(I1.1)') jobs
849 yrecfm=
"HO"//yobs//
"_"//yvar//
"_"//ytim
851 ycomment=
"Jacobian matrix for observation "//
trim(cobs(jobs))/
" and control variable " 862 WRITE(ytim,fmt=
'(I1.1)') jt
864 WRITE(yobs,fmt=
'(I1.1)') jobs
865 yrecfm=
"INNOV"//yobs//
"_"//ytim
867 ycomment=
"Innovation for observation "//
trim(cobs(jobs))
868 jk = (jt-1)*nobstype + jobs
869 CALL write_surf(hselect,hprogram,yrecfm,s%XINNOV(:,jk),iresp,hcomment
874 WRITE(ytim,fmt=
'(I1.1)') jt
876 WRITE(yobs,fmt=
'(I1.1)') jobs
877 yrecfm=
"RESID"//yobs//
"_"//ytim
879 ycomment=
"Residuals for observation "//
trim(cobs(jobs))
880 jk = (jt-1)*nobstype + jobs
881 CALL write_surf(hselect,hprogram,yrecfm,s%XRESID(:,jk),iresp,hcomment
893 IF (
lhook)
CALL dr_hook(
'WRITE_DIAG_MISC_ISBA_N',1,zhook_handle)
static const char * trim(const char *name, int *n)
subroutine write_field_1d_patch(HSELECT, HPROGRAM, HRECFM, HCOMMENT, KP, KMASK, PFIELD_IN, KSIZE, PWORK_WR)
integer, parameter nundef
subroutine write_field_2d_patch(HSELECT, HPROGRAM, HRECFM, HCOMMENT, KP, KMASK, PFIELD_IN, KSIZE, HNAM_DIM, PWORK_WR)
subroutine end_io_surf_n(HPROGRAM)
subroutine write_diag_misc_isba_n(DTCO, HSELECT, OSNOWDIMNC, U, O
subroutine init_io_surf_n(DTCO, U, HPROGRAM, HMASK, HSCHEME, HACTION