129 & LBi, UBi, LBj, UBj)
136 integer,
intent(in) :: ng, model, tile
137 integer,
intent(in) :: lbi, ubi, lbj, ubj
141 integer :: fcount, gfactor, gtype, i, itrc, status
145 character (len=*),
parameter :: myfile = &
146 & __FILE__//
", wrt_avg_nf90"
159# if defined WRITE_WATER && defined MASKING
167 avg(ng)%Rindex=
avg(ng)%Rindex+1
169 avg(ng)%Nrec(fcount)=
avg(ng)%Nrec(fcount)+1
183 & (/
avg(ng)%Rindex/), (/1/), &
184 & ncid =
avg(ng)%ncid, &
195 &
avg(ng)%Rindex, gtype, &
196 & lbi, ubi, lbj, ubj, scale, &
198 &
grid(ng) % rmask, &
201 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
211# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
220 &
avg(ng)%Rindex, gtype, &
221 & lbi, ubi, lbj, ubj, scale, &
223 &
grid(ng) % rmask, &
225 &
tides(ng) % zeta_detided)
226 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
244 &
avg(ng)%Rindex, gtype, &
245 & lbi, ubi, lbj, ubj, scale, &
247 &
grid(ng) % umask_avg, &
250 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
260# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
269 &
avg(ng)%Rindex, gtype, &
270 & lbi, ubi, lbj, ubj, scale, &
272 &
grid(ng) % umask_avg, &
274 &
tides(ng) % ubar_detided)
275 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
293 &
avg(ng)%Rindex, gtype, &
294 & lbi, ubi, lbj, ubj, scale, &
296 &
grid(ng) % vmask_avg, &
299 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
309# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
318 &
avg(ng)%Rindex, gtype, &
319 & lbi, ubi, lbj, ubj, scale, &
321 &
grid(ng) % vmask_avg, &
323 &
tides(ng) % vbar_detided)
324 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
342 &
avg(ng)%Rindex, gtype, &
343 & lbi, ubi, lbj, ubj, scale, &
345 &
grid(ng) % rmask_avg, &
348 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
365 &
avg(ng)%Rindex, gtype, &
366 & lbi, ubi, lbj, ubj, scale, &
368 &
grid(ng) % rmask_avg, &
371 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
381# if defined FORWARD_WRITE && defined SOLVE3D
390 &
avg(ng)%Rindex, gtype, &
391 & lbi, ubi, lbj, ubj, scale, &
393 &
grid(ng) % umask_avg, &
396 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
411 &
avg(ng)%Rindex, gtype, &
412 & lbi, ubi, lbj, ubj, scale, &
414 &
grid(ng) % umask_avg, &
417 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
432 &
avg(ng)%Rindex, gtype, &
433 & lbi, ubi, lbj, ubj, scale, &
435 &
grid(ng) % vmask_avg, &
438 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
453 &
avg(ng)%Rindex, gtype, &
454 & lbi, ubi, lbj, ubj, scale, &
456 &
grid(ng) % umask_avg, &
459 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
479 &
avg(ng)%Rindex, gtype, &
480 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
482 &
grid(ng) % umask_avg, &
485 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
495# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
504 &
avg(ng)%Rindex, gtype, &
505 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
507 &
grid(ng) % umask_avg, &
509 &
tides(ng) % u_detided)
510 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
528 &
avg(ng)%Rindex, gtype, &
529 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
531 &
grid(ng) % vmask_avg, &
534 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
544# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
553 &
avg(ng)%Rindex, gtype, &
554 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
556 &
grid(ng) % vmask_avg, &
558 &
tides(ng) % v_detided)
559 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
577 &
avg(ng)%Rindex, gtype, &
578 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
580 &
grid(ng) % rmask_avg, &
583 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
600 &
avg(ng)%Rindex, gtype, &
601 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
603 &
grid(ng) % rmask_avg, &
606 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
623 &
avg(ng)%Rindex, gtype, &
624 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
626 &
grid(ng) % rmask, &
629 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
646 &
avg(ng)%Rindex, gtype, &
647 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
649 &
grid(ng) % rmask, &
652 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
669 &
avg(ng)%Tid(itrc), &
670 &
avg(ng)%Rindex, gtype, &
671 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
673 &
grid(ng) % rmask, &
675 &
average(ng) % avgt(:,:,:,itrc))
676 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
688# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
698 &
avg(ng)%Rindex, gtype, &
699 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
701 &
grid(ng) % rmask, &
703 &
tides(ng) % t_detided(:,:,:,itrc))
704 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
724 &
avg(ng)%Rindex, gtype, &
725 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
727 &
grid(ng) % rmask, &
730 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
749 &
avg(ng)%Rindex, gtype, &
750 & lbi, ubi, lbj, ubj, scale, &
752 &
grid(ng) % rmask, &
755 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
774 &
avg(ng)%Rindex, gtype, &
775 & lbi, ubi, lbj, ubj, scale, &
777 &
grid(ng) % rmask, &
780 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
799 &
avg(ng)%Rindex, gtype, &
800 & lbi, ubi, lbj, ubj, scale, &
802 &
grid(ng) % pmask, &
805 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
822 &
avg(ng)%Rindex, gtype, &
823 & lbi, ubi, lbj, ubj, scale, &
825 &
grid(ng) % pmask, &
828 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
847 &
avg(ng)%Rindex, gtype, &
848 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
850 &
grid(ng) % pmask, &
853 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
870 &
avg(ng)%Rindex, gtype, &
871 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
873 &
grid(ng) % pmask, &
876 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
894 &
avg(ng)%Rindex, gtype, &
895 & lbi, ubi, lbj, ubj, scale, &
897 &
grid(ng) % rmask, &
900 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
917 &
avg(ng)%Rindex, gtype, &
918 & lbi, ubi, lbj, ubj, scale, &
920 &
grid(ng) % umask, &
923 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
940 &
avg(ng)%Rindex, gtype, &
941 & lbi, ubi, lbj, ubj, scale, &
943 &
grid(ng) % vmask, &
946 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
965 &
avg(ng)%Rindex, gtype, &
966 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
968 &
grid(ng) % umask, &
971 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
988 &
avg(ng)%Rindex, gtype, &
989 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
991 &
grid(ng) % vmask, &
994 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1011 &
avg(ng)%Rindex, gtype, &
1012 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1014 &
grid(ng) % umask, &
1017 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1034 &
avg(ng)%Rindex, gtype, &
1035 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1037 &
grid(ng) % rmask, &
1040 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1057 &
avg(ng)%Rindex, gtype, &
1058 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1060 &
grid(ng) % vmask, &
1063 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1081 &
avg(ng)%Rindex, gtype, &
1082 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1084 &
grid(ng) % rmask, &
1086 &
average(ng) % avgTT(:,:,:,i))
1087 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1106 &
avg(ng)%Rindex, gtype, &
1107 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1109 &
grid(ng) % umask, &
1111 &
average(ng) % avgHuonT(:,:,:,i))
1112 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1127 &
avg(ng)%Rindex, gtype, &
1128 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1130 &
grid(ng) % vmask, &
1132 &
average(ng) % avgHvomT(:,:,:,i))
1133 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1152 &
avg(ng)%Rindex, gtype, &
1153 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1155 &
grid(ng) % umask, &
1157 &
average(ng) % avgUT(:,:,:,i))
1158 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1173 &
avg(ng)%Rindex, gtype, &
1174 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
1176 &
grid(ng) % vmask, &
1178 &
average(ng) % avgVT(:,:,:,i))
1179 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1190# if defined LMD_MIXING || defined MY25_MIXING || defined GLS_MIXING
1199 &
avg(ng)%Rindex, gtype, &
1200 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
1202 &
grid(ng) % rmask, &
1205 & setfillval = .false.)
1206 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1223 &
avg(ng)%Rindex, gtype, &
1224 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
1226 &
grid(ng) % rmask, &
1229 & setfillval = .false.)
1230 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1249 &
avg(ng)%Rindex, gtype, &
1250 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
1252 &
grid(ng) % rmask, &
1255 & setfillval = .false.)
1256 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1267# if defined BULK_FLUXES || defined ECOSIM || defined ATM_PRESS
1276 &
avg(ng)%Rindex, gtype, &
1277 & lbi, ubi, lbj, ubj, scale, &
1279 &
grid(ng) % rmask, &
1282 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1292# if defined BULK_FLUXES
1301 &
avg(ng)%Rindex, gtype, &
1302 & lbi, ubi, lbj, ubj, scale, &
1304 &
grid(ng) % rmask, &
1307 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1317# if defined BULK_FLUXES || defined ECOSIM
1326 &
avg(ng)%Rindex, gtype, &
1327 & lbi, ubi, lbj, ubj, scale, &
1329 &
grid(ng) % rmask, &
1332 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1347 &
avg(ng)%Rindex, gtype, &
1348 & lbi, ubi, lbj, ubj, scale, &
1350 &
grid(ng) % rmask, &
1353 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1370 &
avg(ng)%Rindex, gtype, &
1371 & lbi, ubi, lbj, ubj, scale, &
1373 &
grid(ng) % rmask_avg, &
1376 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1391 &
avg(ng)%Rindex, gtype, &
1392 & lbi, ubi, lbj, ubj, scale, &
1394 &
grid(ng) % rmask_avg, &
1397 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1412# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
1413 defined opt_observations
1424 &
avg(ng)%Rindex, gtype, &
1425 & lbi, ubi, lbj, ubj, scale, &
1427 &
grid(ng) % rmask, &
1430 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1450 &
avg(ng)%Rindex, gtype, &
1451 & lbi, ubi, lbj, ubj, scale, &
1453 &
grid(ng) % rmask, &
1456 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1468# if defined BULK_FLUXES || defined FRC_COUPLING
1481 &
avg(ng)%Rindex, gtype, &
1482 & lbi, ubi, lbj, ubj, scale, &
1484 &
grid(ng) % rmask, &
1487 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1508 &
avg(ng)%Rindex, gtype, &
1509 & lbi, ubi, lbj, ubj, scale, &
1511 &
grid(ng) % rmask, &
1514 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1535 &
avg(ng)%Rindex, gtype, &
1536 & lbi, ubi, lbj, ubj, scale, &
1538 &
grid(ng) % rmask, &
1541 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1562 &
avg(ng)%Rindex, gtype, &
1563 & lbi, ubi, lbj, ubj, scale, &
1565 &
grid(ng) % rmask, &
1568 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1585 &
avg(ng)%Rindex, gtype, &
1586 & lbi, ubi, lbj, ubj, scale, &
1588 &
grid(ng) % rmask, &
1591 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1615 &
avg(ng)%Rindex, gtype, &
1616 & lbi, ubi, lbj, ubj, scale, &
1618 &
grid(ng) % rmask, &
1621 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1637# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
1638 defined opt_observations
1649 &
avg(ng)%Rindex, gtype, &
1650 & lbi, ubi, lbj, ubj, scale, &
1652 &
grid(ng) % umask, &
1655 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1669# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
1670 defined opt_observations
1681 &
avg(ng)%Rindex, gtype, &
1682 & lbi, ubi, lbj, ubj, scale, &
1684 &
grid(ng) % vmask, &
1687 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1701# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
1702 defined opt_observations
1713 &
avg(ng)%Rindex, gtype, &
1714 & lbi, ubi, lbj, ubj, scale, &
1716 &
grid(ng) % umask, &
1719 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1733# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
1734 defined opt_observations
1745 &
avg(ng)%Rindex, gtype, &
1746 & lbi, ubi, lbj, ubj, scale, &
1748 &
grid(ng) % vmask, &
1751 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1761# if (defined BBL_MODEL || defined WAVES_OUTPUT) && defined SOLVE3D
1768 & lbi, ubi, lbj, ubj, &
1773# if defined ICE_MODEL && defined SOLVE3D
1779 CALL ice_wrt_nf90 (ng, model, tile, &
1780 & lbi, ubi, lbj, ubj, &
1785# if defined SEDIMENT && defined SOLVE3D
1792 & lbi, ubi, lbj, ubj, &
1797# if defined WEC_VF && defined SOLVE3D
1803 CALL wec_wrt_nf90 (ng, model, tile, &
1804 & lbi, ubi, lbj, ubj, &
1817 10
FORMAT (2x,
'WRT_AVG_NF90 - writing averaged',t42,
'fields',t61,&
1819 &
'in record = ',i0,t92,i2.2)
1821 &
'in record = ',i0)
1823 20
FORMAT (/,
' WRT_AVG_NF90 - error while writing variable: ',a, &
1824 & /,16x,
'into averages NetCDF file for time record: ',i0)
1833 & LBi, UBi, LBj, UBj)
1840 integer,
intent(in) :: ng, model, tile
1841 integer,
intent(in) :: lbi, ubi, lbj, ubj
1845 integer :: fcount, i, itrc, status
1849 character (len=*),
parameter :: myfile = &
1850 & __FILE__//
", wrt_avg_pio"
1852 TYPE (io_desc_t),
pointer :: iodesc
1864 avg(ng)%Rindex=
avg(ng)%Rindex+1
1866 avg(ng)%Nrec(fcount)=
avg(ng)%Nrec(fcount)+1
1880 & (/
avg(ng)%Rindex/), (/1/), &
1881 & piofile =
avg(ng)%pioFile, &
1889 IF (
avg(ng)%pioVar(
idfsur)%dkind.eq.pio_double)
THEN
1898 & lbi, ubi, lbj, ubj, scale, &
1900 &
grid(ng) % rmask, &
1903 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1913# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
1919 IF (
avg(ng)%pioVar(
idfsud)%dkind.eq.pio_double)
THEN
1928 & lbi, ubi, lbj, ubj, scale, &
1930 &
grid(ng) % rmask, &
1932 &
tides(ng) % zeta_detided)
1933 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1948 IF (
avg(ng)%pioVar(
idubar)%dkind.eq.pio_double)
THEN
1957 & lbi, ubi, lbj, ubj, scale, &
1959 &
grid(ng) % umask_avg, &
1962 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
1972# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
1978 IF (
avg(ng)%pioVar(
idu2dd)%dkind.eq.pio_double)
THEN
1987 & lbi, ubi, lbj, ubj, scale, &
1989 &
grid(ng) % umask_avg, &
1991 &
tides(ng) % ubar_detided)
1992 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2007 IF (
avg(ng)%pioVar(
idvbar)%dkind.eq.pio_double)
THEN
2016 & lbi, ubi, lbj, ubj, scale, &
2018 &
grid(ng) % vmask_avg, &
2021 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2031# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
2037 IF (
avg(ng)%pioVar(
idv2dd)%dkind.eq.pio_double)
THEN
2046 & lbi, ubi, lbj, ubj, scale, &
2048 &
grid(ng) % vmask_avg, &
2050 &
tides(ng) % vbar_detided)
2051 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2066 IF (
avg(ng)%pioVar(
idu2de)%dkind.eq.pio_double)
THEN
2075 & lbi, ubi, lbj, ubj, scale, &
2077 &
grid(ng) % rmask_avg, &
2080 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2094 IF (
avg(ng)%pioVar(
idv2dn)%dkind.eq.pio_double)
THEN
2103 & lbi, ubi, lbj, ubj, scale, &
2105 &
grid(ng) % rmask_avg, &
2108 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2118# if defined FORWARD_WRITE && defined SOLVE3D
2124 IF (
avg(ng)%pioVar(
idufx1)%dkind.eq.pio_double)
THEN
2133 & lbi, ubi, lbj, ubj, scale, &
2135 &
grid(ng) % umask_avg, &
2138 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2150 IF (
avg(ng)%pioVar(
idufx2)%dkind.eq.pio_double)
THEN
2159 & lbi, ubi, lbj, ubj, scale, &
2161 &
grid(ng) % umask_avg, &
2164 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2176 IF (
avg(ng)%pioVar(
idvfx1)%dkind.eq.pio_double)
THEN
2185 & lbi, ubi, lbj, ubj, scale, &
2187 &
grid(ng) % vmask_avg, &
2190 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2202 IF (
avg(ng)%pioVar(
idvfx2)%dkind.eq.pio_double)
THEN
2211 & lbi, ubi, lbj, ubj, scale, &
2213 &
grid(ng) % umask_avg, &
2216 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2233 IF (
avg(ng)%pioVar(
iduvel)%dkind.eq.pio_double)
THEN
2242 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2244 &
grid(ng) % umask_avg, &
2247 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2257# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
2263 IF (
avg(ng)%pioVar(
idu3dd)%dkind.eq.pio_double)
THEN
2272 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2274 &
grid(ng) % umask_avg, &
2276 &
tides(ng) % u_detided)
2277 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2292 IF (
avg(ng)%pioVar(
idvvel)%dkind.eq.pio_double)
THEN
2301 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2303 &
grid(ng) % vmask_avg, &
2306 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2316# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
2322 IF (
avg(ng)%pioVar(
idv3dd)%dkind.eq.pio_double)
THEN
2331 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2333 &
grid(ng) % vmask_avg, &
2335 &
tides(ng) % v_detided)
2336 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2351 IF (
avg(ng)%pioVar(
idu3de)%dkind.eq.pio_double)
THEN
2360 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2362 &
grid(ng) % rmask_avg, &
2365 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2379 IF (
avg(ng)%pioVar(
idv3dn)%dkind.eq.pio_double)
THEN
2388 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2390 &
grid(ng) % rmask_avg, &
2393 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2407 IF (
avg(ng)%pioVar(
idovel)%dkind.eq.pio_double)
THEN
2416 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
2418 &
grid(ng) % rmask, &
2421 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2435 IF (
avg(ng)%pioVar(
idwvel)%dkind.eq.pio_double)
THEN
2444 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
2446 &
grid(ng) % rmask, &
2449 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2464 IF (
avg(ng)%pioTrc(itrc)%dkind.eq.pio_double)
THEN
2470 &
avg(ng)%pioTrc(itrc), &
2473 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2475 &
grid(ng) % rmask, &
2477 &
average(ng) % avgt(:,:,:,itrc))
2478 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2490# if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES)
2497 IF (
avg(ng)%pioVar(
idtrcd(itrc))%dkind.eq.pio_double)
THEN
2506 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2508 &
grid(ng) % rmask, &
2510 &
tides(ng) % t_detided(:,:,:,itrc))
2511 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2528 IF (
avg(ng)%pioVar(
iddano)%dkind.eq.pio_double)
THEN
2537 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2539 &
grid(ng) % rmask, &
2542 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2558 IF (
avg(ng)%pioVar(
idhsbl)%dkind.eq.pio_double)
THEN
2567 & lbi, ubi, lbj, ubj, scale, &
2569 &
grid(ng) % rmask, &
2572 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2588 IF (
avg(ng)%pioVar(
idhbbl)%dkind.eq.pio_double)
THEN
2597 & lbi, ubi, lbj, ubj, scale, &
2599 &
grid(ng) % rmask, &
2602 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2618 IF (
avg(ng)%pioVar(
id2dpv)%dkind.eq.pio_double)
THEN
2627 & lbi, ubi, lbj, ubj, scale, &
2629 &
grid(ng) % pmask, &
2632 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2646 IF (
avg(ng)%pioVar(
id2drv)%dkind.eq.pio_double)
THEN
2655 & lbi, ubi, lbj, ubj, scale, &
2657 &
grid(ng) % pmask, &
2660 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2676 IF (
avg(ng)%pioVar(
id3dpv)%dkind.eq.pio_double)
THEN
2685 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2687 &
grid(ng) % pmask, &
2690 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2704 IF (
avg(ng)%pioVar(
id3drv)%dkind.eq.pio_double)
THEN
2713 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2715 &
grid(ng) % pmask, &
2718 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2733 IF (
avg(ng)%pioVar(
idzzav)%dkind.eq.pio_double)
THEN
2742 & lbi, ubi, lbj, ubj, scale, &
2744 &
grid(ng) % rmask, &
2747 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2761 IF (
avg(ng)%pioVar(
idu2av)%dkind.eq.pio_double)
THEN
2770 & lbi, ubi, lbj, ubj, scale, &
2772 &
grid(ng) % umask, &
2775 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2789 IF (
avg(ng)%pioVar(
idv2av)%dkind.eq.pio_double)
THEN
2798 & lbi, ubi, lbj, ubj, scale, &
2800 &
grid(ng) % vmask, &
2803 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2819 IF (
avg(ng)%pioVar(
idhuav)%dkind.eq.pio_double)
THEN
2828 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2830 &
grid(ng) % umask, &
2833 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2847 IF (
avg(ng)%pioVar(
idhvav)%dkind.eq.pio_double)
THEN
2856 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2858 &
grid(ng) % vmask, &
2861 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2875 IF (
avg(ng)%pioVar(
iduuav)%dkind.eq.pio_double)
THEN
2884 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2886 &
grid(ng) % umask, &
2889 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2903 IF (
avg(ng)%pioVar(
iduvav)%dkind.eq.pio_double)
THEN
2912 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2914 &
grid(ng) % rmask, &
2917 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2931 IF (
avg(ng)%pioVar(
idvvav)%dkind.eq.pio_double)
THEN
2940 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2942 &
grid(ng) % vmask, &
2945 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2960 IF (
avg(ng)%pioVar(
idttav(i))%dkind.eq.pio_double)
THEN
2969 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
2971 &
grid(ng) % rmask, &
2973 &
average(ng) % avgTT(:,:,:,i))
2974 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
2990 IF (
avg(ng)%pioVar(
ihutav(i))%dkind.eq.pio_double)
THEN
2999 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
3001 &
grid(ng) % umask, &
3003 &
average(ng) % avgHuonT(:,:,:,i))
3004 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3016 IF (
avg(ng)%pioVar(
ihvtav(i))%dkind.eq.pio_double)
THEN
3025 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
3027 &
grid(ng) % vmask, &
3029 &
average(ng) % avgHvomT(:,:,:,i))
3030 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3046 IF (
avg(ng)%pioVar(
idutav(i))%dkind.eq.pio_double)
THEN
3055 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
3057 &
grid(ng) % umask, &
3059 &
average(ng) % avgUT(:,:,:,i))
3060 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3072 IF (
avg(ng)%pioVar(
idvtav(i))%dkind.eq.pio_double)
THEN
3081 & lbi, ubi, lbj, ubj, 1,
n(ng), scale, &
3083 &
grid(ng) % vmask, &
3085 &
average(ng) % avgVT(:,:,:,i))
3086 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3097# if defined LMD_MIXING || defined MY25_MIXING || defined GLS_MIXING
3103 IF (
avg(ng)%pioVar(
idvvis)%dkind.eq.pio_double)
THEN
3112 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
3114 &
grid(ng) % rmask, &
3117 & setfillval = .false.)
3118 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3132 IF (
avg(ng)%pioVar(
idtdif)%dkind.eq.pio_double)
THEN
3141 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
3143 &
grid(ng) % rmask, &
3146 & setfillval = .false.)
3147 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3163 IF (
avg(ng)%pioVar(
idsdif)%dkind.eq.pio_double)
THEN
3172 & lbi, ubi, lbj, ubj, 0,
n(ng), scale, &
3174 &
grid(ng) % rmask, &
3177 & setfillval = .false.)
3178 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3189# if defined BULK_FLUXES || defined ECOSIM || defined ATM_PRESS
3195 IF (
avg(ng)%pioVar(
idpair)%dkind.eq.pio_double)
THEN
3204 & lbi, ubi, lbj, ubj, scale, &
3206 &
grid(ng) % rmask, &
3209 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3219# if defined BULK_FLUXES
3225 IF (
avg(ng)%pioVar(
idtair)%dkind.eq.pio_double)
THEN
3234 & lbi, ubi, lbj, ubj, scale, &
3236 &
grid(ng) % rmask, &
3239 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3249# if defined BULK_FLUXES || defined ECOSIM
3255 IF (
avg(ng)%pioVar(
iduair)%dkind.eq.pio_double)
THEN
3264 & lbi, ubi, lbj, ubj, scale, &
3266 &
grid(ng) % rmask, &
3269 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3281 IF (
avg(ng)%pioVar(
idvair)%dkind.eq.pio_double)
THEN
3290 & lbi, ubi, lbj, ubj, scale, &
3292 &
grid(ng) % rmask, &
3295 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3309 IF (
avg(ng)%pioVar(
iduaie)%dkind.eq.pio_double)
THEN
3318 & lbi, ubi, lbj, ubj, scale, &
3320 &
grid(ng) % rmask_avg, &
3323 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3335 IF (
avg(ng)%pioVar(
idvain)%dkind.eq.pio_double)
THEN
3344 & lbi, ubi, lbj, ubj, scale, &
3346 &
grid(ng) % rmask_avg, &
3349 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3364# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
3365 defined opt_observations
3382 & lbi, ubi, lbj, ubj, scale, &
3384 &
grid(ng) % rmask, &
3387 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3413 & lbi, ubi, lbj, ubj, scale, &
3415 &
grid(ng) % rmask, &
3418 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3430# if defined BULK_FLUXES || defined FRC_COUPLING
3440 IF (
avg(ng)%pioVar(
idlhea)%dkind.eq.pio_double)
THEN
3449 & lbi, ubi, lbj, ubj, scale, &
3451 &
grid(ng) % rmask, &
3454 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3472 IF (
avg(ng)%pioVar(
idshea)%dkind.eq.pio_double)
THEN
3481 & lbi, ubi, lbj, ubj, scale, &
3483 &
grid(ng) % rmask, &
3486 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3504 IF (
avg(ng)%pioVar(
idlrad)%dkind.eq.pio_double)
THEN
3513 & lbi, ubi, lbj, ubj, scale, &
3515 &
grid(ng) % rmask, &
3518 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3536 IF (
avg(ng)%pioVar(
idevap)%dkind.eq.pio_double)
THEN
3545 & lbi, ubi, lbj, ubj, scale, &
3547 &
grid(ng) % rmask, &
3550 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3564 IF (
avg(ng)%pioVar(
idrain)%dkind.eq.pio_double)
THEN
3573 & lbi, ubi, lbj, ubj, scale, &
3575 &
grid(ng) % rmask, &
3578 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3599 IF (
avg(ng)%pioVar(
idsrad)%dkind.eq.pio_double)
THEN
3608 & lbi, ubi, lbj, ubj, scale, &
3610 &
grid(ng) % rmask, &
3613 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3629# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
3630 defined opt_observations
3638 IF (
avg(ng)%pioVar(
idusms)%dkind.eq.pio_double)
THEN
3647 & lbi, ubi, lbj, ubj, scale, &
3649 &
grid(ng) % umask, &
3652 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3666# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
3667 defined opt_observations
3675 IF (
avg(ng)%pioVar(
idvsms)%dkind.eq.pio_double)
THEN
3684 & lbi, ubi, lbj, ubj, scale, &
3686 &
grid(ng) % vmask, &
3689 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3703# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
3704 defined opt_observations
3712 IF (
avg(ng)%pioVar(
idubms)%dkind.eq.pio_double)
THEN
3721 & lbi, ubi, lbj, ubj, scale, &
3723 &
grid(ng) % umask, &
3726 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3740# if defined AD_SENSITIVITY || defined I4DVAR_ANA_SENSITIVITY || \
3741 defined opt_observations
3749 IF (
avg(ng)%pioVar(
idvbms)%dkind.eq.pio_double)
THEN
3758 & lbi, ubi, lbj, ubj, scale, &
3760 &
grid(ng) % vmask, &
3763 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
3773# if (defined BBL_MODEL || defined WAVES_OUTPUT) && defined SOLVE3D
3780 & lbi, ubi, lbj, ubj, &
3785# if defined ICE_MODEL && defined SOLVE3D
3791 CALL ice_wrt_pio (ng, model, tile, &
3792 & lbi, ubi, lbj, ubj, &
3797# if defined SEDIMENT && defined SOLVE3D
3804 & lbi, ubi, lbj, ubj, &
3809# if defined WEC_VF && defined SOLVE3D
3815 CALL wec_wrt_pio (ng, model, tile, &
3816 & lbi, ubi, lbj, ubj, &
3829 10
FORMAT (2x,
'WRT_AVG_PIO - writing averaged',t42,
'fields',t61,&
3831 &
'in record = ',i0,t92,i2.2)
3833 &
'in record = ',i0)
3835 20
FORMAT (/,
' WRT_AVG_PIO - error while writing variable: ',a, &
3836 & /,16x,
'into averages NetCDF file for time record: ',i0)