1548 integer,
intent(in) :: ng, tile
1549 integer,
intent(out) :: rc
1551 TYPE (esmf_gridcomp),
intent(inout) :: model
1555 integer :: mytile, gtype, i, ivar, j, node
1556 integer :: istr, iend, jstr, jend
1557 integer :: istrr, iendr, jstrr, jendr
1558 integer :: localde, localdecount
1559 integer :: staggeredgelwidth(2)
1560 integer :: staggeredgeuwidth(2)
1562 integer,
allocatable :: deblocklist(:,:,:)
1563 integer (i4b),
pointer :: ptrm(:,:) => null()
1565 real (
dp),
pointer :: ptra(:,:) => null()
1566 real (
dp),
pointer :: ptrx(:,:) => null()
1567 real (
dp),
pointer :: ptry(:,:) => null()
1569 character (len=*),
parameter :: myfile = &
1570 & __FILE__//
", ROMS_SetGridArrays"
1572 TYPE (esmf_distgrid) :: distgrid
1573 TYPE (esmf_staggerloc) :: staggerloc
1580 WRITE (
trac,
'(a,a,i0)')
'==> Entering ROMS_SetGridArrays', &
1591 istrr=
bounds(ng)%IstrR(tile)
1592 iendr=
bounds(ng)%IendR(tile)
1593 jstrr=
bounds(ng)%JstrR(tile)
1594 jendr=
bounds(ng)%JendR(tile)
1596 istr=
bounds(ng)%Istr(tile)
1597 iend=
bounds(ng)%Iend(tile)
1598 jstr=
bounds(ng)%Jstr(tile)
1599 jend=
bounds(ng)%Jend(tile)
1626 IF (.not.
allocated(deblocklist))
THEN
1630 deblocklist(1,1,mytile+1)=
bounds(ng)%Istr(mytile)
1631 deblocklist(1,2,mytile+1)=
bounds(ng)%Iend(mytile)
1632 deblocklist(2,1,mytile+1)=
bounds(ng)%Jstr(mytile)
1633 deblocklist(2,2,mytile+1)=
bounds(ng)%Jend(mytile)
1643 distgrid=esmf_distgridcreate(minindex=(/ 1, 1 /), &
1644 & maxindex=(/
lm(ng),
mm(ng) /), &
1645 & deblocklist=deblocklist, &
1647 IF (esmf_logfounderror(rctocheck=rc, &
1648 & msg=esmf_logerr_passthru, &
1650 & file=myfile))
THEN
1660 WRITE (
cplout,20) mytile-1, deblocklist(1,1,mytile), &
1661 & deblocklist(1,2,mytile), &
1662 & deblocklist(2,1,mytile), &
1663 & deblocklist(2,2,mytile)
1666 IF (
allocated(deblocklist))
deallocate (deblocklist)
1690 models(
iroms)%grid(ng)=esmf_gridcreate(distgrid=distgrid, &
1691 & gridedgelwidth=(/2,2/), &
1692 & gridedgeuwidth=(/2,2/), &
1693 & indexflag=esmf_index_global, &
1696 IF (esmf_logfounderror(rctocheck=rc, &
1697 & msg=esmf_logerr_passthru, &
1699 & file=myfile))
THEN
1708 & localdecount=localdecount, &
1710 IF (esmf_logfounderror(rctocheck=rc, &
1711 & msg=esmf_logerr_passthru, &
1713 & file=myfile))
THEN
1719 mesh_loop :
DO ivar=1,ubound(
models(
iroms)%mesh, dim=1)
1725 staggerloc=esmf_staggerloc_center
1726 staggeredgelwidth=(/1,1/)
1727 staggeredgeuwidth=(/1,1/)
1729 staggerloc=esmf_staggerloc_corner
1730 staggeredgelwidth=(/1,1/)
1731 staggeredgeuwidth=(/2,2/)
1733 staggerloc=esmf_staggerloc_edge1
1734 staggeredgelwidth=(/1,1/)
1735 staggeredgeuwidth=(/2,1/)
1737 staggerloc=esmf_staggerloc_edge2
1738 staggeredgelwidth=(/1,1/)
1739 staggeredgeuwidth=(/1,2/)
1746 & staggerloc=staggerloc, &
1747 & staggeredgelwidth=staggeredgelwidth, &
1748 & staggeredgeuwidth=staggeredgeuwidth, &
1750 IF (esmf_logfounderror(rctocheck=rc, &
1751 & msg=esmf_logerr_passthru, &
1753 & file=myfile))
THEN
1762 & staggerloc=staggerloc, &
1763 & itemflag=esmf_griditem_mask, &
1765 IF (esmf_logfounderror(rctocheck=rc, &
1766 & msg=esmf_logerr_passthru, &
1768 & file=myfile))
THEN
1778 & staggerloc=staggerloc, &
1779 & itemflag=esmf_griditem_area, &
1781 IF (esmf_logfounderror(rctocheck=rc, &
1782 & msg=esmf_logerr_passthru, &
1784 & file=myfile))
THEN
1791 de_loop :
DO localde=0,localdecount-1
1794 & localde=localde, &
1795 & staggerloc=staggerloc, &
1798 IF (esmf_logfounderror(rctocheck=rc, &
1799 & msg=esmf_logerr_passthru, &
1801 & file=myfile))
THEN
1807 & localde=localde, &
1808 & staggerloc=staggerloc, &
1811 IF (esmf_logfounderror(rctocheck=rc, &
1812 & msg=esmf_logerr_passthru, &
1814 & file=myfile))
THEN
1819 & localde=localde, &
1820 & staggerloc=staggerloc, &
1821 & itemflag=esmf_griditem_mask, &
1824 IF (esmf_logfounderror(rctocheck=rc, &
1825 & msg=esmf_logerr_passthru, &
1827 & file=myfile))
THEN
1832 & localde=localde, &
1833 & staggerloc=staggerloc, &
1834 & itemflag=esmf_griditem_area, &
1837 IF (esmf_logfounderror(rctocheck=rc, &
1838 & msg=esmf_logerr_passthru, &
1840 & file=myfile))
THEN
1851 ptrx(i,j)=
grid(ng)%lonr(i,j)
1852 ptry(i,j)=
grid(ng)%latr(i,j)
1854 ptrm(i,j)=int(
grid(ng)%rmask(i,j))
1858 ptra(i,j)=
grid(ng)%om_r(i,j)*
grid(ng)%on_r(i,j)
1865 ptrx(i,j)=
grid(ng)%lonp(i,j)
1866 ptry(i,j)=
grid(ng)%latp(i,j)
1868 ptrm(i,j)=int(
grid(ng)%pmask(i,j))
1872 ptra(i,j)=
grid(ng)%om_p(i,j)*
grid(ng)%on_p(i,j)
1877 IF (tile.lt.
ntilei(ng))
THEN
1878 ptrx(:,jstr-1)=2.0_dp*ptrx(:,jstr)-ptrx(:,jstr+1)
1879 ptry(:,jstr-1)=2.0_dp*ptry(:,jstr)-ptry(:,jstr+1)
1880 ptrm(:,jstr-1)=ptrm(:,jstr)
1881 ptra(:,jstr-1)=ptra(:,jstr)
1885 IF (mod(tile,
ntilei(ng)).eq.0)
THEN
1886 ptrx(istr-1,:)=2.0_dp*ptrx(istr,:)-ptrx(istr+1,:)
1887 ptry(istr-1,:)=2.0_dp*ptry(istr,:)-ptry(istr+1,:)
1888 ptrm(istr-1,:)=ptrm(istr,:)
1889 ptra(istr-1,:)=ptra(istr,:)
1894 ptrx(:,jend+2)=2.0_dp*ptrx(:,jend+1)-ptrx(:,jend)
1895 ptry(:,jend+2)=2.0_dp*ptry(:,jend+1)-ptry(:,jend)
1896 ptrm(:,jend+2)=ptrm(:,jend+1)
1897 ptra(:,jend+2)=ptra(:,jend+1)
1901 IF (mod(tile+1,
ntilei(ng)).eq.0)
THEN
1902 ptrx(iend+2,:)=2.0_dp*ptrx(iend+1,:)-ptrx(iend,:)
1903 ptry(iend+2,:)=2.0_dp*ptry(iend+1,:)-ptry(iend,:)
1904 ptrm(iend+2,:)=ptrm(iend+1,:)
1905 ptra(iend+2,:)=ptra(iend+1,:)
1911 ptrx(i,j)=
grid(ng)%lonu(i,j)
1912 ptry(i,j)=
grid(ng)%latu(i,j)
1914 ptrm(i,j)=int(
grid(ng)%umask(i,j))
1918 ptra(i,j)=
grid(ng)%om_u(i,j)*
grid(ng)%on_u(i,j)
1923 IF (mod(tile,
ntilei(ng)).eq.0)
THEN
1924 ptrx(istr-1,:)=2.0_dp*ptrx(istr,:)-ptrx(istr+1,:)
1925 ptry(istr-1,:)=2.0_dp*ptry(istr,:)-ptry(istr+1,:)
1926 ptrm(istr-1,:)=ptrm(istr,:)
1927 ptra(istr-1,:)=ptra(istr,:)
1931 IF (mod(tile+1,
ntilei(ng)).eq.0)
THEN
1932 ptrx(iend+2,:)=2.0_dp*ptrx(iend+1,:)-ptrx(iend,:)
1933 ptry(iend+2,:)=2.0_dp*ptry(iend+1,:)-ptry(iend,:)
1934 ptrm(iend+2,:)=ptrm(iend+1,:)
1935 ptra(iend+2,:)=ptra(iend+1,:)
1941 ptrx(i,j)=
grid(ng)%lonv(i,j)
1942 ptry(i,j)=
grid(ng)%latv(i,j)
1944 ptrm(i,j)=int(
grid(ng)%vmask(i,j))
1948 ptra(i,j)=
grid(ng)%om_v(i,j)*
grid(ng)%on_v(i,j)
1953 IF (tile.lt.
ntilei(ng))
THEN
1954 ptrx(:,jstr-1)=2.0_dp*ptrx(:,jstr)-ptrx(:,jstr+1)
1955 ptry(:,jstr-1)=2.0_dp*ptry(:,jstr)-ptry(:,jstr+1)
1956 ptrm(:,jstr-1)=ptrm(:,jstr)
1957 ptra(:,jstr-1)=ptra(:,jstr)
1962 ptrx(:,jend+2)=2.0_dp*ptrx(:,jend+1)-ptrx(:,jend)
1963 ptry(:,jend+2)=2.0_dp*ptry(:,jend+1)-ptry(:,jend)
1964 ptrm(:,jend+2)=ptrm(:,jend+1)
1965 ptra(:,jend+2)=ptra(:,jend+1)
1971 IF (
associated(ptrx) )
nullify (ptrx)
1972 IF (
associated(ptry) )
nullify (ptry)
1973 IF (
associated(ptrm) )
nullify (ptrm)
1974 IF (
associated(ptra) )
nullify (ptra)
1982 & filename=
"roms_"// &
1985 & staggerloc=staggerloc, &
1987 IF (esmf_logfounderror(rctocheck=rc, &
1988 & msg=esmf_logerr_passthru, &
1990 & file=myfile))
THEN
1998 CALL esmf_gridcompset (model, &
2001 IF (esmf_logfounderror(rctocheck=rc, &
2002 & msg=esmf_logerr_passthru, &
2004 & file=myfile))
THEN
2009 WRITE (
trac,
'(a,a,i0)')
'<== Exiting ROMS_SetGridArrays', &
2015 10
FORMAT (/,
'ROMS Domain Decomposition:',/,25(
'='),/, &
2016 /,2x,
'ROMS_DistGrid - Grid = ',i2.2,
',',3x,
'Mesh = ',a, &
2017 &
',',3x,
'Partition = ',i0,
' x ',i0)
2018 20
FORMAT (18x,
'node = ',i0,t32,
'Istr = ',i0,t45,
'Iend = ',i0, &
2019 & t58,
'Jstr = ',i0,t71,
'Jend = ',i0)
2035 integer,
intent(in) :: ng, tile
2036 integer,
intent(out) :: rc
2038 TYPE (esmf_gridcomp) :: model
2043 integer :: localde, localdecount, localpet
2044 integer :: exportcount, importcount
2045 integer :: staggeredgelwidth(2)
2046 integer :: staggeredgeuwidth(2)
2048 real (
dp),
dimension(:,:),
pointer :: ptr2d => null()
2050 character (len=10) :: attlist(1)
2052 character (len=*),
parameter :: myfile = &
2053 & __FILE__//
", ROMS_SetStates"
2055 character (ESMF_MAXSTR),
allocatable :: exportnamelist(:)
2056 character (ESMF_MAXSTR),
allocatable :: importnamelist(:)
2058 TYPE (esmf_arrayspec) :: arrayspec2d
2059 TYPE (esmf_field) :: field
2060 TYPE (esmf_staggerloc) :: staggerloc
2061 TYPE (esmf_vm) :: vm
2068 WRITE (
trac,
'(a,a,i0)')
'==> Entering ROMS_SetStates', &
2080 CALL esmf_gridcompget (model, &
2081 & localpet=localpet, &
2084 IF (esmf_logfounderror(rctocheck=rc, &
2085 & msg=esmf_logerr_passthru, &
2087 & file=myfile))
THEN
2096 & localdecount=localdecount, &
2098 IF (esmf_logfounderror(rctocheck=rc, &
2099 & msg=esmf_logerr_passthru, &
2101 & file=myfile))
THEN
2109 CALL esmf_arrayspecset (arrayspec2d, &
2110 & typekind=esmf_typekind_r8, &
2113 IF (esmf_logfounderror(rctocheck=rc, &
2114 & msg=esmf_logerr_passthru, &
2116 & file=myfile))
THEN
2128 CALL esmf_stateget (
models(
iroms)%ExportState(ng), &
2129 & itemcount=exportcount, &
2131 IF (esmf_logfounderror(rctocheck=rc, &
2132 & msg=esmf_logerr_passthru, &
2134 & file=myfile))
THEN
2140 IF (.not.
allocated(exportnamelist))
THEN
2141 allocate ( exportnamelist(exportcount) )
2143 CALL esmf_stateget (
models(
iroms)%ExportState(ng), &
2144 & itemnamelist=exportnamelist, &
2146 IF (esmf_logfounderror(rctocheck=rc, &
2147 & msg=esmf_logerr_passthru, &
2149 & file=myfile))
THEN
2155 DO ifld=1,exportcount
2158 IF (nuopc_isconnected(
models(
iroms)%ExportState(ng), &
2159 & fieldname=trim(exportnamelist(ifld)), &
2166 staggerloc=esmf_staggerloc_center
2168 staggerloc=esmf_staggerloc_corner
2170 staggerloc=esmf_staggerloc_edge1
2172 staggerloc=esmf_staggerloc_edge2
2179 & indexflag=esmf_index_global, &
2180 & staggerloc=staggerloc, &
2181 & name=trim(exportnamelist(ifld)), &
2183 IF (esmf_logfounderror(rctocheck=rc, &
2184 & msg=esmf_logerr_passthru, &
2186 & file=myfile))
THEN
2193 DO localde=0,localdecount-1
2197 CALL esmf_fieldget (field, &
2198 & localde=localde, &
2199 & farrayptr=ptr2d, &
2201 IF (esmf_logfounderror(rctocheck=rc, &
2202 & msg=esmf_logerr_passthru, &
2204 & file=myfile))
THEN
2215 IF (
associated(ptr2d) )
nullify (ptr2d)
2220 CALL nuopc_realize (
models(
iroms)%ExportState(ng), &
2223 IF (esmf_logfounderror(rctocheck=rc, &
2224 & msg=esmf_logerr_passthru, &
2226 & file=myfile))
THEN
2233 IF (localpet.eq.0)
THEN
2234 WRITE (
cplout,10) trim(exportnamelist(ifld)), &
2235 &
'Export State: ', &
2238 CALL esmf_stateremove (
models(
iroms)%ExportState(ng), &
2239 & (/ trim(exportnamelist(ifld)) /), &
2241 IF (esmf_logfounderror(rctocheck=rc, &
2242 & msg=esmf_logerr_passthru, &
2244 & file=myfile))
THEN
2252 IF (
allocated(exportnamelist) )
deallocate (exportnamelist)
2264 CALL esmf_stateget (
models(
iroms)%ImportState(ng), &
2265 & itemcount=importcount, &
2267 IF (esmf_logfounderror(rctocheck=rc, &
2268 & msg=esmf_logerr_passthru, &
2270 & file=myfile))
THEN
2276 IF (.not.
allocated(importnamelist))
THEN
2277 allocate (importnamelist(importcount))
2279 CALL esmf_stateget (
models(
iroms)%ImportState(ng), &
2280 & itemnamelist=importnamelist, &
2282 IF (esmf_logfounderror(rctocheck=rc, &
2283 & msg=esmf_logerr_passthru, &
2285 & file=myfile))
THEN
2291 DO ifld=1,importcount
2294 IF (nuopc_isconnected(
models(
iroms)%ImportState(ng), &
2295 & fieldname=trim(importnamelist(ifld)), &
2302 staggerloc=esmf_staggerloc_center
2304 staggerloc=esmf_staggerloc_corner
2306 staggerloc=esmf_staggerloc_edge1
2308 staggerloc=esmf_staggerloc_edge2
2316 & indexflag=esmf_index_global, &
2317 & staggerloc=staggerloc, &
2318 & name=trim(importnamelist(ifld)), &
2320 IF (esmf_logfounderror(rctocheck=rc, &
2321 & msg=esmf_logerr_passthru, &
2323 & file=myfile))
THEN
2327# ifdef TIME_INTERP_NOT
2332 CALL esmf_attributeadd (field, &
2333 & convention=
'ESMF', &
2334 & purpose=
'General', &
2336 IF (esmf_logfounderror(rctocheck=rc, &
2337 & msg=esmf_logerr_passthru, &
2339 & file=myfile))
THEN
2343 attlist(1)=
'TimeInterp'
2344 CALL esmf_attributeadd (field, &
2345 & convention=
'CustomConvention', &
2346 & purpose=
'General', &
2348 & attrlist=attlist, &
2349 & nestconvention=
'ESMF', &
2350 & nestpurpose=
'General', &
2352 IF (esmf_logfounderror(rctocheck=rc, &
2353 & msg=esmf_logerr_passthru, &
2355 & file=myfile))
THEN
2363 DO localde=0,localdecount-1
2367 CALL esmf_fieldget (field, &
2368 & localde=localde, &
2369 & farrayptr=ptr2d, &
2371 IF (esmf_logfounderror(rctocheck=rc, &
2372 & msg=esmf_logerr_passthru, &
2374 & file=myfile))
THEN
2385 IF (
associated(ptr2d))
nullify (ptr2d)
2390 CALL nuopc_realize (
models(
iroms)%ImportState(ng), &
2393 IF (esmf_logfounderror(rctocheck=rc, &
2394 & msg=esmf_logerr_passthru, &
2396 & file=myfile))
THEN
2403 IF (localpet.eq.0)
THEN
2404 WRITE (
cplout,10) trim(importnamelist(ifld)), &
2405 &
'Import State: ', &
2408 CALL esmf_stateremove (
models(
iroms)%ImportState(ng), &
2409 & (/ trim(importnamelist(ifld)) /), &
2411 IF (esmf_logfounderror(rctocheck=rc, &
2412 & msg=esmf_logerr_passthru, &
2414 & file=myfile))
THEN
2422 IF (
allocated(importnamelist))
deallocate (importnamelist)
2427 WRITE (
trac,
'(a,a,i0)')
'<== Exiting ROMS_SetStates', &
2432 10
FORMAT (1x,
'ROMS_SetStates - Removing field ''',a,
''' from ',a, &
2433 &
'''',a,
'''',/,18x,
'because it is not connected.')
2755 integer,
intent(in) :: ng
2756 integer,
intent(out) :: rc
2758 TYPE (esmf_gridcomp) :: model
2762 logical :: loadit, ispresent
2763 logical :: got_stress(2), got_wind(2)
2764# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
2765 logical :: got_rhoair, got_wstar, got_wind_sbl(2)
2768 integer :: istr, iend, jstr, jend
2769 integer :: istrr, iendr, jstrr, jendr
2770 integer :: lbi, ubi, lbj, ubj
2771 integer :: importcount, tindex
2772 integer :: localde, localdecount, localpet, tile
2773 integer :: year, month, day, hour, minutes, seconds, sn, sd
2774 integer :: gtype, id, ifield, ifld, i, is, j
2777 integer,
save :: record = 0
2780 real (
dp),
parameter :: eps = 1.0e-10_dp
2782 real (
dp) :: timeindays, time_current, tmin, tmax, tstr, tend
2784 real (
dp) :: mytimeindays
2786 real (
dp) :: fseconds, romsclocktime
2787 real (
dp) :: mytintrp(2), myvtime(2)
2789 real (
dp) :: myfmax(2), myfmin(2), fmin(2), fmax(2), fval
2790 real (
dp) :: add_offset, romsscale, scale, cff1, cff2, cff3
2791 real (
dp) :: freshwaterscale, stressscale, tracerfluxscale
2792# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
2793 real (
dp) :: urel, vrel, wmag, wrel
2795 real (
dp) :: attvalues(14)
2797 real (
dp),
pointer :: ptr2d(:,:) => null()
2799# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
2800 real (
dp),
allocatable :: rhoair(:,:), wstar(:,:)
2801 real (
dp),
allocatable :: uwrk(:,:), vwrk(:,:)
2802 real (
dp),
allocatable :: xwind(:,:), ywind(:,:)
2804 real (
dp),
allocatable :: ustress(:,:), vstress(:,:)
2805 real (
dp),
allocatable :: uwind(:,:), vwind(:,:)
2807 character (len=22) :: mydate(2)
2809 character (len=22) :: mydatestring(1,1,1)
2811 character (len=22) :: time_currentstring
2812 character (len=40) :: attname
2814 character (len=*),
parameter :: myfile = &
2815 & __FILE__//
", ROMS_Import"
2817 character (ESMF_MAXSTR) :: cname, ofile
2818 character (ESMF_MAXSTR),
allocatable :: importnamelist(:)
2820 TYPE (esmf_attpack) :: attpack
2821 TYPE (esmf_clock) :: clock
2822 TYPE (esmf_field) :: field
2823 TYPE (esmf_time) :: currenttime
2824 TYPE (esmf_vm) :: vm
2836 WRITE (
trac,
'(a,a,i0)')
'==> Entering ROMS_Import', &
2846 CALL esmf_gridcompget (model, &
2848 & localpet=localpet, &
2852 IF (esmf_logfounderror(rctocheck=rc, &
2853 & msg=esmf_logerr_passthru, &
2855 & file=myfile))
THEN
2864 & localdecount=localdecount, &
2866 IF (esmf_logfounderror(rctocheck=rc, &
2867 & msg=esmf_logerr_passthru, &
2869 & file=myfile))
THEN
2882 istrr=
bounds(ng)%IstrR(tile)
2883 iendr=
bounds(ng)%IendR(tile)
2884 jstrr=
bounds(ng)%JstrR(tile)
2885 jendr=
bounds(ng)%JendR(tile)
2887 istr=
bounds(ng)%Istr(tile)
2888 iend=
bounds(ng)%Iend(tile)
2889 jstr=
bounds(ng)%Jstr(tile)
2890 jend=
bounds(ng)%Jend(tile)
2896 CALL esmf_clockget (clock, &
2897 & currtime=currenttime, &
2899 IF (esmf_logfounderror(rctocheck=rc, &
2900 & msg=esmf_logerr_passthru, &
2902 & file=myfile))
THEN
2906 CALL esmf_timeget (currenttime, &
2916 IF (esmf_logfounderror(rctocheck=rc, &
2917 & msg=esmf_logerr_passthru, &
2919 & file=myfile))
THEN
2923 CALL esmf_timeget (currenttime, &
2924 & s_r8=time_current, &
2925 & timestring=time_currentstring, &
2927 IF (esmf_logfounderror(rctocheck=rc, &
2928 & msg=esmf_logerr_passthru, &
2930 & file=myfile))
THEN
2933 timeindays=time_current/86400.0_dp
2934 is=index(time_currentstring,
'T')
2935 IF (is.gt.0) time_currentstring(is:is)=
' '
2943 fseconds=real(seconds,
dp)+real(sn,
dp)/real(sd,
dp)
2944 CALL roms_clock (year, month, day, hour, minutes, fseconds, &
2951 CALL esmf_stateget (
models(
iroms)%ImportState(ng), &
2952 & itemcount=importcount, &
2954 IF (esmf_logfounderror(rctocheck=rc, &
2955 & msg=esmf_logerr_passthru, &
2957 & file=myfile))
THEN
2961 IF (.not.
allocated(importnamelist))
THEN
2962 allocate ( importnamelist(importcount) )
2964 CALL esmf_stateget (
models(
iroms)%ImportState(ng), &
2965 & itemnamelist=importnamelist, &
2967 IF (esmf_logfounderror(rctocheck=rc, &
2968 & msg=esmf_logerr_passthru, &
2970 & file=myfile))
THEN
2992 got_stress(1:2)=.false.
2993 got_wind(1:2)=.false.
2994# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
2997 got_wind_sbl(1:2)=.false.
3002 fld_loop :
DO ifld=1,importcount
3007 CALL esmf_stateget (
models(
iroms)%ImportState(ng), &
3008 & trim(importnamelist(ifld)), &
3011 IF (esmf_logfounderror(rctocheck=rc, &
3012 & msg=esmf_logerr_passthru, &
3014 & file=myfile))
THEN
3031 & start=(/
iroms,id,record/), &
3035 rc=esmf_rc_file_read
3042 & start=(/1,
iroms,id,record/), &
3043 & total=(/22,1,1,1/))
3046 rc=esmf_rc_file_read
3050 & mydatestring(1,1,1)
3053 &
rclock%DateNumber, mytimeindays, &
3054 & start=(/
iroms,id,record/), &
3058 rc=esmf_rc_file_read
3065 & start=(/
iroms,id,record/), &
3069 rc=esmf_rc_file_read
3076 & start=(/
iroms,id,record/), &
3080 rc=esmf_rc_file_read
3087 & start=(/
iroms,id,record/), &
3091 rc=esmf_rc_file_read
3098 & start=(/
iroms,id,record/), &
3102 rc=esmf_rc_file_read
3108 & start=(/
iroms,id,record/), &
3112 rc=esmf_rc_file_read
3119 & start=(/
iroms,id,record/), &
3123 rc=esmf_rc_file_read
3132 de_loop :
DO localde=0,localdecount-1
3133 CALL esmf_fieldget (field, &
3134 & localde=localde, &
3135 & farrayptr=ptr2d, &
3137 IF (esmf_logfounderror(rctocheck=rc, &
3138 & msg=esmf_logerr_passthru, &
3140 & file=myfile))
THEN
3144# ifdef TIME_INTERP_NOT_WORKING
3148 CALL esmf_attributegetattpack (field, &
3149 &
'CustomConvention', &
3152 & attpack=attpack, &
3153 & ispresent=ispresent, &
3155 IF (esmf_logfounderror(rctocheck=rc, &
3156 & msg=esmf_logerr_passthru, &
3158 & file=myfile))
THEN
3164 CALL esmf_attributeget (field, &
3165 & name=
'TimeInterp', &
3166 & valuelist=attvalues, &
3167 & attpack=attpack, &
3168 & ispresent=ispresent, &
3170 IF (esmf_logfounderror(rctocheck=rc, &
3171 & msg=esmf_logerr_passthru, &
3173 & file=myfile))
THEN
3192 add_offset =
models(
iroms)%ImportField(id)%add_offset
3199 mytintrp(1)=
models(
iroms)%ImportField(id)%Tintrp(1)
3200 mytintrp(2)=
models(
iroms)%ImportField(id)%Tintrp(2)
3201 myvtime(1) =
models(
iroms)%ImportField(id)%Vtime(1)
3202 myvtime(2) =
models(
iroms)%ImportField(id)%Vtime(2)
3203 mydate(1) =
models(
iroms)%ImportField(id)%DateString(1)
3204 mydate(2) =
models(
iroms)%ImportField(id)%DateString(2)
3210 freshwaterscale=1.0_dp/
rho0
3211 stressscale=1.0_dp/
rho0
3212 tracerfluxscale=1.0_dp/(
rho0*
cp)
3214 fval=ptr2d(istrr,jstrr)
3220 SELECT CASE (trim(adjustl(importnamelist(ifld))))
3222# if defined BULK_FLUXES || defined ECOSIM || defined ATM_PRESS
3226 CASE (
'psfc',
'Pair',
'Pmsl')
3230 tindex=3-
iinfo(8,ifield,ng)
3233 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3234 fval=scale*ptr2d(i,j)+add_offset
3238 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3239 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3240 myfmin(2)=min(myfmin(2),fval)
3241 myfmax(2)=max(myfmax(2),fval)
3243 forces(ng)%PairG(i,j,tindex)=fval
3245 forces(ng)%Pair(i,j)=fval
3250 IF (localde.eq.localdecount-1)
THEN
3253 & lbi, ubi, lbj, ubj, &
3257 & lbi, ubi, lbj, ubj, &
3264# if defined BULK_FLUXES || defined ECOSIM || \
3265 (defined shortwave && defined ana_srflux && defined albedo)
3269 CASE (
'tsfc',
'Tair')
3273 tindex=3-
iinfo(8,ifield,ng)
3276 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3277 fval=scale*ptr2d(i,j)+add_offset
3281 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3282 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3283 myfmin(2)=min(myfmin(2),fval)
3284 myfmax(2)=max(myfmax(2),fval)
3286 forces(ng)%TairG(i,j,tindex)=fval
3288 forces(ng)%Tair(i,j)=fval
3293 IF (localde.eq.localdecount-1)
THEN
3296 & lbi, ubi, lbj, ubj, &
3300 & lbi, ubi, lbj, ubj, &
3307# if defined BULK_FLUXES || defined ECOSIM
3317 tindex=3-
iinfo(8,ifield,ng)
3320 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3321 fval=scale*ptr2d(i,j)+add_offset
3325 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3326 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3327 myfmin(2)=min(myfmin(2),fval)
3328 myfmax(2)=max(myfmax(2),fval)
3330 forces(ng)%HairG(i,j,tindex)=fval
3332 forces(ng)%Hair(i,j)=fval
3337 IF (localde.eq.localdecount-1)
THEN
3340 & lbi, ubi, lbj, ubj, &
3344 & lbi, ubi, lbj, ubj, &
3351# if defined BULK_FLUXES
3355 CASE (
'Hair',
'qsfc')
3359 tindex=3-
iinfo(8,ifield,ng)
3362 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3363 fval=scale*ptr2d(i,j)+add_offset
3367 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3368 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3369 myfmin(2)=min(myfmin(2),fval)
3370 myfmax(2)=max(myfmax(2),fval)
3372 forces(ng)%HairG(i,j,tindex)=fval
3374 forces(ng)%Hair(i,j)=fval
3379 IF (localde.eq.localdecount-1)
THEN
3382 & lbi, ubi, lbj, ubj, &
3386 & lbi, ubi, lbj, ubj, &
3393# if defined BULK_FLUXES
3397 CASE (
'lwrd',
'LWrad')
3398 romsscale=tracerfluxscale
3401 tindex=3-
iinfo(8,ifield,ng)
3404 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3405 fval=scale*ptr2d(i,j)+add_offset
3409 myfmin(1)=min(myfmin(1),fval)
3410 myfmax(1)=max(myfmax(1),fval)
3412 myfmin(2)=min(myfmin(2),fval)
3413 myfmax(2)=max(myfmax(2),fval)
3415 forces(ng)%lrflxG(i,j,tindex)=fval
3417 forces(ng)%lrflx(i,j)=fval
3422 IF (localde.eq.localdecount-1)
THEN
3425 & lbi, ubi, lbj, ubj, &
3429 & lbi, ubi, lbj, ubj, &
3436# if defined BULK_FLUXES && defined LONGWAVE_OUT
3441 CASE (
'dlwr',
'dLWrad',
'lwrad_down')
3442 romsscale=tracerfluxscale
3445 tindex=3-
iinfo(8,ifield,ng)
3448 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3449 fval=scale*ptr2d(i,j)+add_offset
3453 myfmin(1)=min(myfmin(1),fval)
3454 myfmax(1)=max(myfmax(1),fval)
3456 myfmin(2)=min(myfmin(2),fval)
3457 myfmax(2)=max(myfmax(2),fval)
3459 forces(ng)%lrflxG(i,j,tindex)=fval
3461 forces(ng)%lrflx(i,j)=fval
3466 IF (localde.eq.localdecount-1)
THEN
3469 & lbi, ubi, lbj, ubj, &
3473 & lbi, ubi, lbj, ubj, &
3480# if defined BULK_FLUXES
3484 CASE (
'prec',
'rain')
3488 tindex=3-
iinfo(8,ifield,ng)
3491 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3492 fval=scale*ptr2d(i,j)+add_offset
3496 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3497 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3498 myfmin(2)=min(myfmin(2),fval)
3499 myfmax(2)=max(myfmax(2),fval)
3501 forces(ng)%rainG(i,j,tindex)=fval
3503 forces(ng)%rain(i,j)=fval
3508 IF (localde.eq.localdecount-1)
THEN
3511 & lbi, ubi, lbj, ubj, &
3515 & lbi, ubi, lbj, ubj, &
3522# if defined BULK_FLUXES || defined ECOSIM
3527 CASE (
'wndu',
'Uwind')
3528 IF (.not.
allocated(uwind))
THEN
3529 allocate ( uwind(lbi:ubi,lbj:ubj) )
3536 tindex=3-
iinfo(8,ifield,ng)
3539 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3540 fval=scale*ptr2d(i,j)+add_offset
3544 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3545 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3546 myfmin(2)=min(myfmin(2),fval)
3547 myfmax(2)=max(myfmax(2),fval)
3549 forces(ng)%UwindG(i,j,tindex)=fval
3556 IF (localde.eq.localdecount-1)
THEN
3559 & lbi, ubi, lbj, ubj, &
3563 & lbi, ubi, lbj, ubj, &
3570# if defined BULK_FLUXES || defined ECOSIM
3575 CASE (
'wndv',
'Vwind')
3576 IF (.not.
allocated(vwind))
THEN
3577 allocate ( vwind(lbi:ubi,lbj:ubj) )
3584 tindex=3-
iinfo(8,ifield,ng)
3587 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3588 fval=scale*ptr2d(i,j)+add_offset
3592 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3593 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3594 myfmin(2)=min(myfmin(2),fval)
3595 myfmax(2)=max(myfmax(2),fval)
3597 forces(ng)%VwindG(i,j,tindex)=fval
3604 IF (localde.eq.localdecount-1)
THEN
3607 & lbi, ubi, lbj, ubj, &
3611 & lbi, ubi, lbj, ubj, &
3618# if defined SHORTWAVE
3622 CASE (
'swrd',
'swrad',
'SWrad',
'SWrad_daily')
3623 romsscale=tracerfluxscale
3626 tindex=3-
iinfo(8,ifield,ng)
3629 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3630 fval=scale*ptr2d(i,j)+add_offset
3634 myfmin(1)=min(myfmin(1),fval)
3635 myfmax(1)=max(myfmax(1),fval)
3637 myfmin(2)=min(myfmin(2),fval)
3638 myfmax(2)=max(myfmax(2),fval)
3640 forces(ng)%srflxG(i,j,tindex)=fval
3642 forces(ng)%srflx(i,j)=fval
3647 IF (localde.eq.localdecount-1)
THEN
3650 & lbi, ubi, lbj, ubj, &
3654 & lbi, ubi, lbj, ubj, &
3661# if !defined BULK_FLUXES
3667 CASE (
'lwr',
'LWrad')
3668 romsscale=tracerfluxscale
3671 tindex=3-
iinfo(8,ifield,ng)
3674 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3675 fval=scale*ptr2d(i,j)+add_offset
3679 myfmin(1)=min(myfmin(1),fval)
3680 myfmax(1)=max(myfmax(1),fval)
3682 myfmin(2)=min(myfmin(2),fval)
3683 myfmax(2)=max(myfmax(2),fval)
3684 forces(ng)%lrflx(i,j)=fval
3692 CASE (
'dlwr',
'dLWrad',
'lwrad_down')
3693 romsscale=tracerfluxscale
3696 tindex=3-
iinfo(8,ifield,ng)
3699 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3700 fval=scale*ptr2d(i,j)+add_offset
3704 myfmin(1)=min(myfmin(1),fval)
3705 myfmax(1)=max(myfmax(1),fval)
3707 myfmin(2)=min(myfmin(2),fval)
3708 myfmax(2)=max(myfmax(2),fval)
3709 forces(ng)%lrflx(i,j)=fval
3717 CASE (
'latent',
'LHfx')
3718 romsscale=tracerfluxscale
3722 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3723 fval=scale*ptr2d(i,j)+add_offset
3727 myfmin(1)=min(myfmin(1),fval)
3728 myfmax(1)=max(myfmax(1),fval)
3730 myfmin(2)=min(myfmin(2),fval)
3731 myfmax(2)=max(myfmax(2),fval)
3732 forces(ng)%lhflx(i,j)=fval
3740 CASE (
'sensible',
'SHfx')
3741 romsscale=tracerfluxscale
3745 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3746 fval=scale*ptr2d(i,j)+add_offset
3750 myfmin(1)=min(myfmin(1),fval)
3751 myfmax(1)=max(myfmax(1),fval)
3753 myfmin(2)=min(myfmin(2),fval)
3754 myfmax(2)=max(myfmax(2),fval)
3755 forces(ng)%shflx(i,j)=fval
3761 CASE (
'nflx',
'shflux')
3762 romsscale=tracerfluxscale
3765 tindex=3-
iinfo(8,ifield,ng)
3768 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3769 fval=scale*ptr2d(i,j)+add_offset
3773 myfmin(1)=min(myfmin(1),fval)
3774 myfmax(1)=max(myfmax(1),fval)
3776 myfmin(2)=min(myfmin(2),fval)
3777 myfmax(2)=max(myfmax(2),fval)
3786 IF (localde.eq.localdecount-1)
THEN
3789 & lbi, ubi, lbj, ubj, &
3793 & lbi, ubi, lbj, ubj, &
3800# if !defined BULK_FLUXES && defined SALINITY
3804 CASE (
'sflx',
'swflux')
3805 romsscale=freshwaterscale
3808 tindex=3-
iinfo(8,ifield,ng)
3811 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3812 fval=scale*ptr2d(i,j)+add_offset
3816 myfmin(1)=min(myfmin(1),fval)
3817 myfmax(1)=max(myfmax(1),fval)
3819 myfmin(2)=min(myfmin(2),fval)
3820 myfmax(2)=max(myfmax(2),fval)
3829 IF (localde.eq.localdecount-1)
THEN
3832 & lbi, ubi, lbj, ubj, &
3836 & lbi, ubi, lbj, ubj, &
3843# if !defined BULK_FLUXES
3848 CASE (
'taux',
'sustr')
3849 IF (.not.
allocated(ustress))
THEN
3850 allocate ( ustress(lbi:ubi,lbj:ubj) )
3853 got_stress(1)=.true.
3854 romsscale=stressscale
3857 tindex=3-
iinfo(8,ifield,ng)
3860 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3861 fval=scale*ptr2d(i,j)+add_offset
3865 myfmin(1)=min(myfmin(1),fval)
3866 myfmax(1)=max(myfmax(1),fval)
3868 myfmin(2)=min(myfmin(2),fval)
3869 myfmax(2)=max(myfmax(2),fval)
3871 forces(ng)%sustrG(i,j,tindex)=fval
3877 IF (localde.eq.localdecount-1)
THEN
3880 & lbi, ubi, lbj, ubj, &
3884 & lbi, ubi, lbj, ubj, &
3890# if !defined BULK_FLUXES
3895 CASE (
'tauy',
'svstr')
3896 IF (.not.
allocated(vstress))
THEN
3897 allocate ( vstress(lbi:ubi,lbj:ubj) )
3900 got_stress(2)=.true.
3901 romsscale=stressscale
3904 tindex=3-
iinfo(8,ifield,ng)
3907 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3908 fval=scale*ptr2d(i,j)+add_offset
3912 myfmin(1)=min(myfmin(1),fval)
3913 myfmax(1)=max(myfmax(1),fval)
3915 myfmin(2)=min(myfmin(2),fval)
3916 myfmax(2)=max(myfmax(2),fval)
3918 forces(ng)%svstrG(i,j,tindex)=fval
3924 IF (localde.eq.localdecount-1)
THEN
3927 & lbi, ubi, lbj, ubj, &
3931 & lbi, ubi, lbj, ubj, &
3937# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
3942 IF (.not.
allocated(rhoair))
THEN
3943 allocate ( rhoair(lbi:ubi,lbj:ubj) )
3950 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3951 fval=scale*ptr2d(i,j)+add_offset
3955 myfmin(1)=min(myfmin(1),fval)
3956 myfmax(1)=max(myfmax(1),fval)
3958 myfmin(2)=min(myfmin(2),fval)
3959 myfmax(2)=max(myfmax(2),fval)
3963 IF (localde.eq.localdecount-1)
THEN
3966 & lbi, ubi, lbj, ubj, &
3970 & lbi, ubi, lbj, ubj, &
3980 IF (.not.
allocated(xwind))
THEN
3981 allocate ( xwind(lbi:ubi,lbj:ubj) )
3984 got_wind_sbl(1)=.true.
3988 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
3989 fval=scale*ptr2d(i,j)+add_offset
3993 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3994 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3996 myfmin(2)=min(myfmin(2),fval)
3997 myfmax(2)=max(myfmax(2),fval)
4001 IF (localde.eq.localdecount-1)
THEN
4004 & lbi, ubi, lbj, ubj, &
4008 & lbi, ubi, lbj, ubj, &
4018 IF (.not.
allocated(ywind))
THEN
4019 allocate ( ywind(lbi:ubi,lbj:ubj) )
4022 got_wind_sbl(2)=.true.
4026 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
4027 fval=scale*ptr2d(i,j)+add_offset
4031 myfmin(1)=min(myfmin(1),ptr2d(i,j))
4032 myfmax(1)=max(myfmax(1),ptr2d(i,j))
4034 myfmin(2)=min(myfmin(2),fval)
4035 myfmax(2)=max(myfmax(2),fval)
4039 IF (localde.eq.localdecount-1)
THEN
4042 & lbi, ubi, lbj, ubj, &
4046 & lbi, ubi, lbj, ubj, &
4056 IF (.not.
allocated(wstar))
THEN
4057 allocate ( wstar(lbi:ubi,lbj:ubj) )
4064 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
4065 fval=scale*ptr2d(i,j)+add_offset
4069 myfmin(1)=min(myfmin(1),ptr2d(i,j))
4070 myfmax(1)=max(myfmax(1),ptr2d(i,j))
4072 myfmin(2)=min(myfmin(2),fval)
4073 myfmax(2)=max(myfmax(2),fval)
4077 IF (localde.eq.localdecount-1)
THEN
4080 & lbi, ubi, lbj, ubj, &
4084 & lbi, ubi, lbj, ubj, &
4094 IF (localpet.eq.0)
THEN
4095 WRITE (
cplout,10) trim(importnamelist(ifld)), &
4096 & trim(time_currentstring), &
4102 rc=esmf_rc_not_found
4110 WRITE (
cplout,20) localpet, localde, &
4111 & lbound(ptr2d,dim=1), ubound(ptr2d,dim=1), &
4112 & lbound(ptr2d,dim=2), ubound(ptr2d,dim=2), &
4113 & istrr, iendr, jstrr, jendr
4119 IF (
associated(ptr2d))
nullify (ptr2d)
4124 CALL esmf_vmallreduce (vm, &
4125 & senddata=myfmin, &
4128 & reduceflag=esmf_reduce_min, &
4130 IF (esmf_logfounderror(rctocheck=rc, &
4131 & msg=esmf_logerr_passthru, &
4133 & file=myfile))
THEN
4137 CALL esmf_vmallreduce (vm, &
4138 & senddata=myfmax, &
4141 & reduceflag=esmf_reduce_max, &
4143 IF (esmf_logfounderror(rctocheck=rc, &
4144 & msg=esmf_logerr_passthru, &
4146 & file=myfile))
THEN
4152 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
4153 WRITE (
cplout,30) trim(importnamelist(ifld)), &
4155 & trim(mydate(tindex)), ng, &
4156 & fmin(1), fmax(1), tindex
4158 & trim(time_currentstring), ng, &
4161 IF (romsscale.ne.1.0_dp)
THEN
4162 WRITE (
cplout,40) fmin(2), fmax(2), &
4163 &
' romsScale = ', romsscale
4164 ELSE IF (add_offset.ne.0.0_dp)
THEN
4165 WRITE (
cplout,40) fmin(2), fmax(2), &
4166 &
' AddOffset = ', add_offset
4176 linfo(1,ifield,ng)=.true.
4177 linfo(3,ifield,ng)=.false.
4178 iinfo(1,ifield,ng)=gtype
4179 iinfo(8,ifield,ng)=tindex
4180 finfo(1,ifield,ng)=tmin
4181 finfo(2,ifield,ng)=tmax
4182 finfo(3,ifield,ng)=tstr
4183 finfo(4,ifield,ng)=tend
4184 finfo(8,ifield,ng)=fmin(1)
4185 finfo(9,ifield,ng)=fmax(1)
4186 vtime(tindex,ifield,ng)=myvtime(tindex)
4187 tintrp(tindex,ifield,ng)=mytintrp(tindex)*86400.0_dp
4195 WRITE (ofile,50) ng, trim(importnamelist(ifld)), &
4196 & year, month, day, hour, minutes, seconds
4197 CALL esmf_fieldwrite (field, &
4199 & overwrite=.true., &
4201 IF (esmf_logfounderror(rctocheck=rc, &
4202 & msg=esmf_logerr_passthru, &
4204 & file=myfile))
THEN
4211# if defined BULK_FLUXES || defined ECOSIM
4215 IF (got_wind(1).and.got_wind(2))
THEN
4217 & lbi, ubi, lbj, ubj, &
4224# if !defined BULK_FLUXES
4229 IF (got_stress(1).and.got_stress(2))
THEN
4231 & lbi, ubi, lbj, ubj, &
4232 & ustress, vstress, &
4234 deallocate (ustress)
4235 deallocate (vstress)
4238# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
4257 IF (got_rhoair.and.got_wstar.and. &
4258 & got_wind_sbl(1).and.got_wind_sbl(2))
THEN
4259 IF (.not.
allocated(uwrk))
THEN
4260 allocate ( uwrk(lbi:ubi,lbj:ubj) )
4263 IF (.not.
allocated(vwrk))
THEN
4264 allocate ( vwrk(lbi:ubi,lbj:ubj) )
4269 & lbi, ubi, lbj, ubj, &
4276 romsscale=stressscale
4277 urel=xwind(i,j)-uwrk(i,j)
4278 vrel=ywind(i,j)-vwrk(i,j)
4279 wmag=sqrt(xwind(i,j)*xwind(i,j)+ &
4280 & ywind(i,j)*ywind(i,j))
4281 wrel=sqrt(urel*urel+vrel*vrel)
4282 cff1=romsscale*rhoair(i,j)
4283 cff2=wstar(i,j)*wstar(i,j)/(wmag*wmag+eps)
4287 myfmin(1)=min(myfmin(1),uwrk(i,j))
4288 myfmin(2)=min(myfmin(2),vwrk(i,j))
4289 myfmax(1)=max(myfmax(1),uwrk(i,j))
4290 myfmax(2)=max(myfmax(2),vwrk(i,j))
4299 & lbi, ubi, lbj, ubj, &
4309 CALL esmf_vmallreduce (vm, &
4310 & senddata=myfmin, &
4313 & reduceflag=esmf_reduce_min, &
4315 IF (esmf_logfounderror(rctocheck=rc, &
4316 & msg=esmf_logerr_passthru, &
4318 & file=myfile))
THEN
4322 CALL esmf_vmallreduce (vm, &
4323 & senddata=myfmax, &
4326 & reduceflag=esmf_reduce_max, &
4328 IF (esmf_logfounderror(rctocheck=rc, &
4329 & msg=esmf_logerr_passthru, &
4331 & file=myfile))
THEN
4335 IF (localpet.eq.0)
THEN
4336 WRITE (
cplout,60)
'sustr', &
4337 & trim(time_currentstring), ng, &
4338 & fmin(1)/stressscale, &
4339 & fmax(1)/stressscale
4340 WRITE (
cplout,40) fmin(1), fmax(1), &
4341 &
' romsScale = ', stressscale
4343 WRITE (
cplout,60)
'svstr', &
4344 & trim(time_currentstring), ng, &
4345 & fmin(2)/stressscale, &
4346 & fmax(2)/stressscale
4347 WRITE (
cplout,40) fmin(2), fmax(2), &
4348 &
' romsScale = ', stressscale
4356 IF (
allocated(importnamelist))
deallocate (importnamelist)
4360 IF (importcount.gt.0)
THEN
4365 WRITE (
trac,
'(a,a,i0)')
'<== Exiting ROMS_Import', &
4371 10
FORMAT (/,3x,
' ROMS_Import - unable to find option to import: ', &
4372 & a,t72,a,/,18x,
'check ''Import(roms)'' in input script: ', &
4374 20
FORMAT (18x,
'PET/DE [',i3.3,
'/',i2.2,
'], Pointer Size: ',4i8, &
4375 & /,36x,
'Tiling Range: ',4i8)
4376 30
FORMAT (3x,
' ROMS_Import - ESMF: importing field ''',a,
'''', &
4377 & t72,a,2x,
'Grid ',i2.2, &
4379 & /,19x,
'(InpMin = ', 1p,e15.8,0p,
' InpMax = ',1p,e15.8,0p, &
4380 &
' SnapshotIndex = ',i1,
')')
4382 & /,19x,
'(InpMin = ', 1p,e15.8,0p,
' InpMax = ',1p,e15.8,0p, &
4385 40
FORMAT (19x,
'(OutMin = ', 1p,e15.8,0p,
' OutMax = ',1p,e15.8,0p, &
4386 & 1x,a,1p,e15.8,0p,
')')
4387 50
FORMAT (
'roms_',i2.2,
'_import_',a,
'_',i4.4,2(
'-',i2.2),
'_', &
4388 & i2.2,2(
'.',i2.2),
'.nc')
4389 60
FORMAT (3x,
' ROMS_Import - ESMF: computing field ''',a,
'''', &
4390 & t72,a,2x,
'Grid ',i2.2, &
4391 & /,19x,
'(InpMin = ', 1p,e15.8,0p,
' InpMax = ',1p,e15.8,0p, &
4407 integer,
intent(in) :: ng
4408 integer,
intent(out) :: rc
4410 TYPE (esmf_gridcomp) :: model
4414 logical :: get_barotropic
4415 logical :: get_surfacecurrent
4417 integer :: istr, iend, jstr, jend
4418 integer :: istrr, iendr, jstrr, jendr
4419 integer :: lbi, ubi, lbj, ubj
4420 integer :: exportcount
4421 integer :: localde, localdecount, localpet, tile
4422 integer :: year, month, day, hour, minutes, seconds, sn, sd
4423 integer :: ifld, i, is, j
4425 real (
dp) :: fmin(1), fmax(1), fval, myfmin(1), myfmax(1)
4427 real (
dp),
pointer :: ptr2d(:,:) => null()
4429 real (
dp),
allocatable :: ubar(:,:), vbar(:,:)
4430 real (
dp),
allocatable :: usur(:,:), vsur(:,:)
4432 character (len=22) :: time_currentstring
4434 character (len=:),
allocatable :: fldname
4436 character (len=*),
parameter :: myfile = &
4437 & __FILE__//
", ROMS_Export"
4439 character (ESMF_MAXSTR) :: cname, ofile
4440 character (ESMF_MAXSTR),
allocatable :: exportnamelist(:)
4442 TYPE (esmf_field) :: field
4443 TYPE (esmf_time) :: currenttime
4444 TYPE (esmf_vm) :: vm
4451 WRITE (
trac,
'(a,a,i0)')
'==> Entering ROMS_Export', &
4461 CALL esmf_gridcompget (model, &
4462 & localpet=localpet, &
4466 IF (esmf_logfounderror(rctocheck=rc, &
4467 & msg=esmf_logerr_passthru, &
4469 & file=myfile))
THEN
4478 & localdecount=localdecount, &
4480 IF (esmf_logfounderror(rctocheck=rc, &
4481 & msg=esmf_logerr_passthru, &
4483 & file=myfile))
THEN
4496 istrr=
bounds(ng)%IstrR(tile)
4497 iendr=
bounds(ng)%IendR(tile)
4498 jstrr=
bounds(ng)%JstrR(tile)
4499 jendr=
bounds(ng)%JendR(tile)
4501 istr=
bounds(ng)%Istr(tile)
4502 iend=
bounds(ng)%Iend(tile)
4503 jstr=
bounds(ng)%Jstr(tile)
4504 jend=
bounds(ng)%Jend(tile)
4511 & currtime=currenttime, &
4513 IF (esmf_logfounderror(rctocheck=rc, &
4514 & msg=esmf_logerr_passthru, &
4516 & file=myfile))
THEN
4520 CALL esmf_timeget (currenttime, &
4529 & timestring=time_currentstring, &
4531 IF (esmf_logfounderror(rctocheck=rc, &
4532 & msg=esmf_logerr_passthru, &
4534 & file=myfile))
THEN
4537 is=index(time_currentstring,
'T')
4538 IF (is.gt.0) time_currentstring(is:is)=
' '
4544 CALL esmf_stateget (
models(
iroms)%ExportState(ng), &
4545 & itemcount=exportcount, &
4547 IF (esmf_logfounderror(rctocheck=rc, &
4548 & msg=esmf_logerr_passthru, &
4550 & file=myfile))
THEN
4554 IF (.not.
allocated(exportnamelist))
THEN
4555 allocate ( exportnamelist(exportcount) )
4558 CALL esmf_stateget (
models(
iroms)%ExportState(ng), &
4559 & itemnamelist=exportnamelist, &
4561 IF (esmf_logfounderror(rctocheck=rc, &
4562 & msg=esmf_logerr_passthru, &
4564 & file=myfile))
THEN
4572 get_barotropic=.true.
4573 get_surfacecurrent=.true.
4575 fld_loop :
DO ifld=1,exportcount
4579 CALL esmf_stateget (
models(
iroms)%ExportState(ng), &
4580 & trim(exportnamelist(ifld)), &
4583 IF (esmf_logfounderror(rctocheck=rc, &
4584 & msg=esmf_logerr_passthru, &
4586 & file=myfile))
THEN
4593 de_loop :
DO localde=0,localdecount-1
4594 CALL esmf_fieldget (field, &
4595 & localde=localde, &
4596 & farrayptr=ptr2d, &
4598 IF (esmf_logfounderror(rctocheck=rc, &
4599 & msg=esmf_logerr_passthru, &
4601 & file=myfile))
THEN
4614 SELECT CASE (trim(adjustl(exportnamelist(ifld))))
4617# if defined EXCLUDE_SPONGE && \
4618 (defined data_coupling &&
4631# if defined EXCLUDE_SPONGE && \
4632 (defined data_coupling &&
4634 &
mixing(ng)%diff_factor(i,j).gt.1.0_dp)
THEN
4639 IF (
grid(ng)%rmask(i,j).gt.0.0_r8)
THEN
4640 myfmin(1)=min(myfmin(1),fval)
4641 myfmax(1)=max(myfmax(1),fval)
4644 myfmin(1)=min(myfmin(1),fval)
4645 myfmax(1)=max(myfmax(1),fval)
4651 IF (
grid(ng)%rmask(i,j).gt.0.0_r8)
THEN
4652 myfmin(1)=min(myfmin(1),fval)
4653 myfmax(1)=max(myfmax(1),fval)
4656 myfmin(1)=min(myfmin(1),fval)
4657 myfmax(1)=max(myfmax(1),fval)
4673 IF (
grid(ng)%rmask(i,j).gt.0.0_r8)
THEN
4674 myfmin(1)=min(myfmin(1),fval)
4675 myfmax(1)=max(myfmax(1),fval)
4678 myfmin(1)=min(myfmin(1),fval)
4679 myfmax(1)=max(myfmax(1),fval)
4688 CASE (
'Ubar',
'Vbar')
4690 & exportnamelist(ifld)), &
4691 &
noerror, __line__, myfile))
THEN
4692 rc=esmf_rc_not_found
4696 IF (get_barotropic)
THEN
4697 get_barotropic=.false.
4698 IF (.not.
allocated(ubar))
THEN
4699 allocate ( ubar(lbi:ubi,lbj:ubj) )
4702 IF (.not.
allocated(vbar))
THEN
4703 allocate ( vbar(lbi:ubi,lbj:ubj) )
4707 & lbi, ubi, lbj, ubj, &
4713 IF (fldname.eq.
'Ubar')
THEN
4717 myfmin(1)=min(myfmin(1),fval)
4718 myfmax(1)=max(myfmax(1),fval)
4727 myfmin(1)=min(myfmin(1),fval)
4728 myfmax(1)=max(myfmax(1),fval)
4737 CASE (
'Usur',
'Vsur')
4739 & exportnamelist(ifld)), &
4740 &
noerror, __line__, myfile))
THEN
4741 rc=esmf_rc_not_found
4745 IF (get_surfacecurrent)
THEN
4746 get_surfacecurrent=.false.
4747 IF (.not.
allocated(ubar))
THEN
4748 allocate ( usur(lbi:ubi,lbj:ubj) )
4751 IF (.not.
allocated(vbar))
THEN
4752 allocate ( vsur(lbi:ubi,lbj:ubj) )
4756 & lbi, ubi, lbj, ubj, &
4762 IF (fldname.eq.
'Usur')
THEN
4766 myfmin(1)=min(myfmin(1),fval)
4767 myfmax(1)=max(myfmax(1),fval)
4776 myfmin(1)=min(myfmin(1),fval)
4777 myfmax(1)=max(myfmax(1),fval)
4791 fval=
grid(ng)%h(i,j)
4792 myfmin(1)=min(myfmin(1),fval)
4793 myfmax(1)=max(myfmax(1),fval)
4802 CASE (
'mask_rho',
'rmask',
'msk')
4807 IF (
grid(ng)%rmask(i,j).gt.0.0_r8)
THEN
4809 IF (
grid(ng)%rmask(i,j).ne. &
4810 &
grid(ng)%rmask_wet(i,j))
THEN
4811 ptr2d(i,j)=
grid(ng)%rmask_wet(i,j)
4813 ptr2d(i,j)=
grid(ng)%rmask(i,j)
4816 ptr2d(i,j)=
grid(ng)%rmask(i,j)
4818 myfmin(1)=min(myfmin(1),ptr2d(i,j))
4819 myfmax(1)=max(myfmax(1),ptr2d(i,j))
4828 IF (localpet.eq.0)
THEN
4829 WRITE (
cplout,10) trim(adjustl(exportnamelist(ifld))), &
4832 rc=esmf_rc_not_found
4833 IF (esmf_logfounderror(rctocheck=rc, &
4834 & msg=esmf_logerr_passthru, &
4836 & file=myfile))
THEN
4844 IF (
associated(ptr2d))
nullify (ptr2d)
4849 CALL esmf_vmallreduce (vm, &
4850 & senddata=myfmin, &
4853 & reduceflag=esmf_reduce_min, &
4855 IF (esmf_logfounderror(rctocheck=rc, &
4856 & msg=esmf_logerr_passthru, &
4858 & file=myfile))
THEN
4862 CALL esmf_vmallreduce (vm, &
4863 & senddata=myfmax, &
4866 & reduceflag=esmf_reduce_max, &
4868 IF (esmf_logfounderror(rctocheck=rc, &
4869 & msg=esmf_logerr_passthru, &
4871 & file=myfile))
THEN
4875 IF (localpet.eq.0)
THEN
4876 WRITE (
cplout,20) trim(exportnamelist(ifld)), &
4877 & trim(time_currentstring), ng, &
4884 &
models(
iroms)%ExportField(ifld)%debug_write)
THEN
4885 WRITE (ofile,30) ng, trim(exportnamelist(ifld)), &
4886 year, month, day, hour, minutes, seconds
4887 CALL esmf_fieldwrite (field, &
4889 & overwrite=.true., &
4891 IF (esmf_logfounderror(rctocheck=rc, &
4892 & msg=esmf_logerr_passthru, &
4894 & file=myfile))
THEN
4902 IF (
allocated(exportnamelist))
deallocate (exportnamelist)
4906 IF (exportcount.gt.0)
THEN
4911 WRITE (
trac,
'(a,a,i0)')
'<== Exiting ROMS_Export', &
4917 10
FORMAT (/,3x,
' ROMS_Export - unable to find option to export: ', &
4918 & a,/,18x,
'check ''Export(roms)'' in input script: ',a)
4919 20
FORMAT (3x,
' ROMS_Export - ESMF: exporting field ''',a,
'''', &
4920 & t72,a,2x,
'Grid ',i2.2,/, &
4921 & 18x,
'(OutMin = ', 1p,e15.8,0p,
' OutMax = ',1p,e15.8,0p, &
4923 30
FORMAT (
'roms_',i2.2,
'_export_',a,
'_',i4.4,2(
'-',i2.2),
'_', &
4924 & i2.2,2(
'.',i2.2),
'.nc')