664 integer,
intent(out) :: rc
666 TYPE (esmf_gridcomp) :: model
670 integer :: ig, is, ng
671 integer :: ref_year, start_year, stop_year
672 integer :: ref_month, start_month, stop_month
673 integer :: ref_day, start_day, stop_day
674 integer :: ref_hour, start_hour, stop_hour
675 integer :: ref_minute, start_minute, stop_minute
676 integer :: ref_second, start_second, stop_second
680 character (len= 22) :: calendar
681 character (len= 22) :: starttimestring, stoptimestring
682 character (len=160) :: message
684 character (len=*),
parameter :: myfile = &
685 & __FILE__//
", WRF_SetClock"
687 TYPE (esmf_calkind_flag) :: caltype
688 TYPE (esmf_clock) :: clock
695 WRITE (
trac,
'(a,a,i0)')
'==> Entering WRF_SetClock', &
706 CALL esmf_gridcompget (model, &
707 & localpet=localpet, &
709 IF (esmf_logfounderror(rctocheck=rc, &
710 & msg=esmf_logerr_passthru, &
721 IF (trim(calendar).eq.
'gregorian')
THEN
722 caltype=esmf_calkind_gregorian
724 caltype=esmf_calkind_gregorian
728 & name=trim(calendar), &
730 IF (esmf_logfounderror(rctocheck=rc, &
731 & msg=esmf_logerr_passthru, &
740 CALL nl_get_simulation_start_year (ng, ref_year)
741 CALL nl_get_simulation_start_month (ng, ref_month)
742 CALL nl_get_simulation_start_day (ng, ref_day)
743 CALL nl_get_simulation_start_hour (ng, ref_hour)
744 CALL nl_get_simulation_start_minute (ng, ref_minute)
745 CALL nl_get_simulation_start_second (ng, ref_second)
756 IF (esmf_logfounderror(rctocheck=rc, &
757 & msg=esmf_logerr_passthru, &
766 CALL nl_get_start_year (ng, start_year)
767 CALL nl_get_start_month (ng, start_month)
768 CALL nl_get_start_day (ng, start_day)
769 CALL nl_get_start_hour (ng, start_hour)
770 CALL nl_get_start_minute (ng, start_minute)
771 CALL nl_get_start_second (ng, start_second)
782 IF (esmf_logfounderror(rctocheck=rc, &
783 & msg=esmf_logerr_passthru, &
789# ifdef REGRESS_STARTCLOCK
799 & timestringisofrac=starttimestring, &
801 IF (esmf_logfounderror(rctocheck=rc, &
802 & msg=esmf_logerr_passthru, &
810 & timestringisofrac=starttimestring, &
812 IF (esmf_logfounderror(rctocheck=rc, &
813 & msg=esmf_logerr_passthru, &
819 is=index(starttimestring,
'T')
820 IF (is.gt.0) starttimestring(is:is)=
' '
826 CALL nl_get_end_year (ng, stop_year)
827 CALL nl_get_end_month (ng, stop_month)
828 CALL nl_get_end_day (ng, stop_day)
829 CALL nl_get_end_hour (ng, stop_hour)
830 CALL nl_get_end_minute (ng, stop_minute)
831 CALL nl_get_end_second (ng, stop_second)
842 IF (esmf_logfounderror(rctocheck=rc, &
843 & msg=esmf_logerr_passthru, &
850 & timestringisofrac=stoptimestring, &
852 IF (esmf_logfounderror(rctocheck=rc, &
853 & msg=esmf_logerr_passthru, &
858 is=index(stoptimestring,
'T')
859 IF (is.gt.0) stoptimestring(is:is)=
' '
869 timefrac=max(timefrac, &
871 & mask=
models(:)%IsActive))
874 IF (timefrac.lt.1)
THEN
876 IF (esmf_logfounderror(rctocheck=rc, &
877 & msg=esmf_logerr_passthru, &
896 IF (esmf_logfounderror(rctocheck=rc, &
897 & msg=esmf_logerr_passthru, &
906 CALL esmf_gridcompset (model, &
909 IF (esmf_logfounderror(rctocheck=rc, &
910 & msg=esmf_logerr_passthru, &
921 IF (esmf_logfounderror(rctocheck=rc, &
922 & msg=esmf_logerr_passthru, &
939 & starttimestring)
THEN
940 IF (localpet.eq.0)
THEN
941 WRITE (
cplout,10)
'WRF Start Time: ', &
943 &
'Driver Start Time: ', &
944 & trim(starttimestring), &
947 message=
'Driver and WRF start times do not match: '// &
948 &
'please check the config files.'
949 CALL esmf_logseterror (esmf_failure, rctoreturn=rc, &
956 IF (localpet.eq.0)
THEN
957 WRITE (
cplout,10)
'WRF Stop Time: ', &
959 &
'Driver Stop Time: ', &
963 message=
'Driver and WRF stop times do not match: '// &
964 &
'please check the config files.'
965 CALL esmf_logseterror (esmf_failure, rctoreturn=rc, &
972 IF (localpet.eq.0)
THEN
973 WRITE (
cplout,10)
'WRF Calendar: ', &
975 &
'Driver Calendar: ', &
979 message=
'Driver and WRF calendars do not match: '// &
980 &
'please check the config files.'
981 CALL esmf_logseterror (esmf_failure, rctoreturn=rc, &
987 WRITE (
trac,
'(a,a,i0)')
'<== Exiting WRF_SetClock', &
992 10
FORMAT (/,1x,a,a,/,1x,a,a,/,1x,a)
1334 USE module_domain,
ONLY : domain, &
1339 integer,
intent(out) :: rc
1341 TYPE (domain),
intent(in) :: grid
1342 TYPE (esmf_gridcomp),
intent(inout) :: model
1346 integer :: i, j, k, ng
1347 integer :: gtype, ivar
1348 integer :: ids, ide, jds, jde, kds, kde
1349 integer :: ims, ime, jms, jme, kms, kme
1350 integer :: ips, ipe, jps, jpe, kps, kpe
1352 integer :: istrd, iendd, jstrd, jendd
1353 integer :: istrm, iendm, jstrm, jendm
1354 integer :: istrp, iendp, jstrp, jendp
1356 integer :: localpet, petcount, node
1357 integer :: localde, localdecount
1358 integer :: numprocsx, numprocsy
1359 integer :: lbi, ubi, lbj, ubj
1360 integer :: clb(2), cub(2), elb(2), eub(2), tlb(2), tub(2)
1361 integer :: minindex(2), maxindex(2)
1363 integer,
allocatable :: ipatchstarts(:), jpatchstarts(:)
1364 integer,
allocatable :: ipatchends(:), jpatchends(:)
1365 integer,
allocatable :: deblocklist(:,:,:)
1367 integer (i4b),
pointer :: ptrm(:,:) => null()
1369 real (dp),
pointer :: ptra(:,:) => null()
1370 real (dp),
pointer :: ptrx(:,:) => null()
1371 real (dp),
pointer :: ptry(:,:) => null()
1373 character (len=40) :: name
1375 character (len=*),
parameter :: myfile = &
1376 & __FILE__//
", WRF_SetGridArrays"
1378 TYPE (esmf_distgrid) :: distgrid
1379 TYPE (esmf_staggerloc) :: staggerloc
1380 TYPE (esmf_vm) :: vm
1387 WRITE (
trac,
'(a,a,i0)')
'==> Entering WRF_SetGridArrays', &
1398 CALL esmf_gridcompget (model, &
1399 & localpet=localpet, &
1400 & petcount=petcount, &
1403 IF (esmf_logfounderror(rctocheck=rc, &
1404 & msg=esmf_logerr_passthru, &
1406 & file=myfile))
THEN
1419 CALL get_ijk_from_grid (grid, ids, ide, jds, jde, kds, kde, &
1420 & ims, ime, jms, jme, kms, kme, &
1421 & ips, ipe, jps, jpe, kps, kpe)
1446 IF (.not.
allocated(ipatchstarts))
THEN
1447 allocate (ipatchstarts(0:petcount-1))
1449 IF (.not.
allocated(jpatchstarts))
THEN
1450 allocate (jpatchstarts(0:petcount-1))
1453 CALL esmf_vmallgatherv (vm, &
1454 & senddata=(/ips/), &
1456 & recvdata=ipatchstarts, &
1457 & recvcounts =(/(1, k=0, petcount-1)/), &
1458 & recvoffsets=(/(k, k=0, petcount-1)/), &
1460 IF (esmf_logfounderror(rctocheck=rc, &
1461 & msg=esmf_logerr_passthru, &
1463 & file=myfile))
THEN
1467 CALL esmf_vmallgatherv (vm, &
1468 & senddata=(/jps/), &
1470 & recvdata=jpatchstarts, &
1471 & recvcounts =(/(1, k=0, petcount-1)/), &
1472 & recvoffsets=(/(k, k=0, petcount-1)/), &
1474 IF (esmf_logfounderror(rctocheck=rc, &
1475 & msg=esmf_logerr_passthru, &
1477 & file=myfile))
THEN
1483 DO node=0,petcount-1
1484 IF (ips.eq.ipatchstarts(node))
THEN
1485 numprocsy=numprocsy+1
1487 IF (jps.eq.jpatchstarts(node))
THEN
1488 numprocsx=numprocsx+1
1494 IF (.not.
allocated(ipatchends))
THEN
1495 allocate (ipatchends(0:petcount-1))
1497 IF (.not.
allocated(jpatchends))
THEN
1498 allocate (jpatchends(0:petcount-1))
1501 CALL esmf_vmallgatherv (vm, &
1502 & senddata=(/min(ide-1,ipe)/), &
1504 & recvdata=ipatchends, &
1505 & recvcounts =(/(1, k=0, petcount-1)/), &
1506 & recvoffsets=(/(k, k=0, petcount-1)/), &
1508 IF (esmf_logfounderror(rctocheck=rc, &
1509 & msg=esmf_logerr_passthru, &
1511 & file=myfile))
THEN
1515 CALL esmf_vmallgatherv (vm, &
1516 & senddata=(/min(jde-1,jpe)/), &
1518 & recvdata=jpatchends, &
1519 & recvcounts =(/(1, k=0, petcount-1)/), &
1520 & recvoffsets=(/(k, k=0, petcount-1)/), &
1522 IF (esmf_logfounderror(rctocheck=rc, &
1523 & msg=esmf_logerr_passthru, &
1525 & file=myfile))
THEN
1533 IF (.not.
allocated(deblocklist))
THEN
1534 allocate (deblocklist(2,2,petcount))
1538 deblocklist(1,1,node)=ipatchstarts(node-1)
1539 deblocklist(2,1,node)=jpatchstarts(node-1)
1540 deblocklist(1,2,node)=ipatchends(node-1)
1541 deblocklist(2,2,node)=jpatchends(node-1)
1544 im=maxval(ipatchends)
1545 jm=maxval(jpatchends)
1549 distgrid=esmf_distgridcreate(minindex=minindex, &
1550 & maxindex=maxindex, &
1551 & deblocklist=deblocklist, &
1553 IF (esmf_logfounderror(rctocheck=rc, &
1554 & msg=esmf_logerr_passthru, &
1556 & file=myfile))
THEN
1562 IF ((localpet.eq.0).and.(
debuglevel.gt.0))
THEN
1564 & numprocsx, numprocsy
1566 WRITE (
cplout,20) node-1, deblocklist(1,1,node), &
1567 & deblocklist(1,2,node), &
1568 & deblocklist(2,1,node), &
1569 & deblocklist(2,2,node)
1572 IF (
allocated(deblocklist))
deallocate (deblocklist)
1574# ifdef DATA_COUPLING
1583 IF (esmf_logfounderror(rctocheck=rc, &
1584 & msg=esmf_logerr_passthru, &
1586 & file=myfile))
THEN
1605 models(
iatmos)%grid(ng)=esmf_gridcreate(distgrid=distgrid, &
1606 & coordsys=esmf_coordsys_sph_deg, &
1607 & coordtypekind=esmf_typekind_r8, &
1608 & indexflag=esmf_index_global, &
1611 IF (esmf_logfounderror(rctocheck=rc, &
1612 & msg=esmf_logerr_passthru, &
1614 & file=myfile))
THEN
1623 & localdecount=localdecount, &
1625 IF (esmf_logfounderror(rctocheck=rc, &
1626 & msg=esmf_logerr_passthru, &
1628 & file=myfile))
THEN
1634 mesh_loop :
DO ivar=1,ubound(
models(
iatmos)%mesh, dim=1)
1640 staggerloc=esmf_staggerloc_center
1647 & staggerloc=staggerloc, &
1649 IF (esmf_logfounderror(rctocheck=rc, &
1650 & msg=esmf_logerr_passthru, &
1652 & file=myfile))
THEN
1659 & staggerloc=staggerloc, &
1660 & itemflag=esmf_griditem_mask, &
1662 IF (esmf_logfounderror(rctocheck=rc, &
1663 & msg=esmf_logerr_passthru, &
1665 & file=myfile))
THEN
1678 & staggerloc=staggerloc, &
1679 & itemflag=esmf_griditem_area, &
1681 IF (esmf_logfounderror(rctocheck=rc, &
1682 & msg=esmf_logerr_passthru, &
1684 & file=myfile))
THEN
1691 de_loop :
DO localde=0,localdecount-1
1694 & staggerloc=staggerloc, &
1695 & localde=localde, &
1697 & exclusivelbound=elb, &
1698 & exclusiveubound=eub, &
1699 & computationallbound=clb, &
1700 & computationalubound=cub, &
1701 & totallbound=tlb, &
1702 & totalubound=tub, &
1704 IF (esmf_logfounderror(rctocheck=rc, &
1705 & msg=esmf_logerr_passthru, &
1707 & file=myfile))
THEN
1713 & staggerloc=staggerloc, &
1714 & localde=localde, &
1716 & exclusivelbound=elb, &
1717 & exclusiveubound=eub, &
1718 & computationallbound=clb, &
1719 & computationalubound=cub, &
1720 & totallbound=tlb, &
1721 & totalubound=tub, &
1723 IF (esmf_logfounderror(rctocheck=rc, &
1724 & msg=esmf_logerr_passthru, &
1726 & file=myfile))
THEN
1731 & itemflag=esmf_griditem_mask, &
1732 & staggerloc=staggerloc, &
1733 & localde=localde, &
1736 IF (esmf_logfounderror(rctocheck=rc, &
1737 & msg=esmf_logerr_passthru, &
1739 & file=myfile))
THEN
1744 & itemflag=esmf_griditem_area, &
1745 & staggerloc=staggerloc, &
1746 & localde=localde, &
1749 IF (esmf_logfounderror(rctocheck=rc, &
1750 & msg=esmf_logerr_passthru, &
1752 & file=myfile))
THEN
1766 ptrx(i,j)=real(grid%xlong(i,j),dp)
1767 ptry(i,j)=real(grid%xlat(i,j),dp)
1768 ptrm(i,j)=int(grid%landmask(i,j))
1769 ptra(i,j)=real(grid%dx*grid%dy,dp)
1776 IF (
associated(ptrx) )
nullify (ptrx)
1777 IF (
associated(ptry) )
nullify (ptry)
1778 IF (
associated(ptrm) )
nullify (ptrm)
1779 IF (
associated(ptra) )
nullify (ptra)
1787 & filename=
"wrf_"// &
1790 & staggerloc=staggerloc, &
1792 IF (esmf_logfounderror(rctocheck=rc, &
1793 & msg=esmf_logerr_passthru, &
1795 & file=myfile))
THEN
1803 CALL esmf_gridcompset (model, &
1806 IF (esmf_logfounderror(rctocheck=rc, &
1807 & msg=esmf_logerr_passthru, &
1809 & file=myfile))
THEN
1814 WRITE (
trac,
'(a,a,i0)')
'<== Exiting WRF_SetGridArrays', &
1820 10
FORMAT (3x,
'WRF_DistGrid - Grid = ',i2.2,
',',3x,
'Mesh = ',a,
',', &
1821 & 3x,
'Partition = ',i0,
' x ',i0)
1822 20
FORMAT (18x,
'node = ',i0,t32,
'Istr = ',i0,t45,
'Iend = ',i0, &
1823 & t58,
'Jstr = ',i0,t71,
'Jend = ',i0)
1837 USE module_domain,
ONLY : domain, &
1842 integer,
intent(out) :: rc
1844 TYPE (domain),
intent(in) :: grid
1845 TYPE (esmf_gridcomp) :: model
1849 integer :: i, id, ng
1850 integer :: localde, localdecount
1851 integer :: localpet, petcount
1852 integer :: exportcount, importcount
1854 real (dp),
dimension(:,:),
pointer :: ptr2d => null()
1856 character (len=*),
parameter :: myfile = &
1857 & __FILE__//
", WRF_SetStates"
1859 character (ESMF_MAXSTR),
allocatable :: exportnamelist(:)
1860 character (ESMF_MAXSTR),
allocatable :: importnamelist(:)
1862 TYPE (esmf_arrayspec) :: arrayspec2d
1863 TYPE (esmf_field) :: field
1864 TYPE (esmf_staggerloc) :: staggerloc
1871 WRITE (
trac,
'(a,a,i0)')
'==> Entering WRF_SetStates', &
1883 CALL esmf_gridcompget (model, &
1884 & localpet=localpet, &
1885 & petcount=petcount, &
1887 IF (esmf_logfounderror(rctocheck=rc, &
1888 & msg=esmf_logerr_passthru, &
1890 & file=myfile))
THEN
1900 & localdecount=localdecount, &
1902 IF (esmf_logfounderror(rctocheck=rc, &
1903 & msg=esmf_logerr_passthru, &
1905 & file=myfile))
THEN
1913 CALL esmf_arrayspecset (arrayspec2d, &
1914 & typekind=esmf_typekind_r8, &
1917 IF (esmf_logfounderror(rctocheck=rc, &
1918 & msg=esmf_logerr_passthru, &
1920 & file=myfile))
THEN
1933 & itemcount=exportcount, &
1935 IF (esmf_logfounderror(rctocheck=rc, &
1936 & msg=esmf_logerr_passthru, &
1938 & file=myfile))
THEN
1944 IF (.not.
allocated(exportnamelist))
THEN
1945 allocate ( exportnamelist(exportcount) )
1948 & itemnamelist=exportnamelist, &
1950 IF (esmf_logfounderror(rctocheck=rc, &
1951 & msg=esmf_logerr_passthru, &
1953 & file=myfile))
THEN
1962 IF (nuopc_isconnected(
models(
iatmos)%ExportState(ng), &
1963 & fieldname=trim(exportnamelist(i)), &
1970 staggerloc=esmf_staggerloc_center
1972 staggerloc=esmf_staggerloc_corner
1974 staggerloc=esmf_staggerloc_edge1
1976 staggerloc=esmf_staggerloc_edge2
1983 & indexflag=esmf_index_global, &
1984 & staggerloc=staggerloc, &
1985 & name=trim(exportnamelist(i)), &
1987 IF (esmf_logfounderror(rctocheck=rc, &
1988 & msg=esmf_logerr_passthru, &
1990 & file=myfile))
THEN
1997 DO localde=0,localdecount-1
2001 CALL esmf_fieldget (field, &
2002 & localde=localde, &
2003 & farrayptr=ptr2d, &
2005 IF (esmf_logfounderror(rctocheck=rc, &
2006 & msg=esmf_logerr_passthru, &
2008 & file=myfile))
THEN
2019 IF (
associated(ptr2d) )
nullify (ptr2d)
2027 IF (esmf_logfounderror(rctocheck=rc, &
2028 & msg=esmf_logerr_passthru, &
2030 & file=myfile))
THEN
2037 IF (localpet.eq.0)
THEN
2038 WRITE (
cplout,10) trim(exportnamelist(i)), &
2039 &
'Export State: ', &
2042 CALL esmf_stateremove (
models(
iatmos)%ExportState(ng), &
2043 & (/ trim(exportnamelist(i)) /), &
2045 IF (esmf_logfounderror(rctocheck=rc, &
2046 & msg=esmf_logerr_passthru, &
2048 & file=myfile))
THEN
2056 IF (
allocated(exportnamelist) )
deallocate (exportnamelist)
2069 & itemcount=importcount, &
2071 IF (esmf_logfounderror(rctocheck=rc, &
2072 & msg=esmf_logerr_passthru, &
2074 & file=myfile))
THEN
2080 IF (.not.
allocated(importnamelist))
THEN
2081 allocate (importnamelist(importcount))
2084 & itemnamelist=importnamelist, &
2086 IF (esmf_logfounderror(rctocheck=rc, &
2087 & msg=esmf_logerr_passthru, &
2089 & file=myfile))
THEN
2098 IF (nuopc_isconnected(
models(
iatmos)%ImportState(ng), &
2099 & fieldname=trim(importnamelist(i)), &
2106 staggerloc=esmf_staggerloc_center
2108 staggerloc=esmf_staggerloc_corner
2110 staggerloc=esmf_staggerloc_edge1
2112 staggerloc=esmf_staggerloc_edge2
2119 & indexflag=esmf_index_global, &
2120 & staggerloc=staggerloc, &
2121 & name=trim(importnamelist(i)), &
2123 IF (esmf_logfounderror(rctocheck=rc, &
2124 & msg=esmf_logerr_passthru, &
2126 & file=myfile))
THEN
2133 DO localde=0,localdecount-1
2137 CALL esmf_fieldget (field, &
2138 & localde=localde, &
2139 & farrayptr=ptr2d, &
2141 IF (esmf_logfounderror(rctocheck=rc, &
2142 & msg=esmf_logerr_passthru, &
2144 & file=myfile))
THEN
2155 IF (
associated(ptr2d))
nullify (ptr2d)
2163 IF (esmf_logfounderror(rctocheck=rc, &
2164 & msg=esmf_logerr_passthru, &
2166 & file=myfile))
THEN
2173 IF (localpet.eq.0)
THEN
2174 WRITE (
cplout,10) trim(importnamelist(i)), &
2175 &
'Import State: ', &
2178 CALL esmf_stateremove (
models(
iatmos)%ImportState(ng), &
2179 & trim(importnamelist(i)), &
2181 IF (esmf_logfounderror(rctocheck=rc, &
2182 & msg=esmf_logerr_passthru, &
2184 & file=myfile))
THEN
2192 IF (
allocated(importnamelist))
deallocate (importnamelist)
2197 WRITE (
trac,
'(a,a,i0)')
'<== Exiting WRF_SetStates', &
2203 10
FORMAT (
'WRF_SetStates - Removing field ''',a,
''' from ',a, &
2204 &
'''',a,
'''',/,16x,
'because it is not connected.')
2599 USE module_domain,
ONLY : domain, &
2604 integer,
intent(out) :: rc
2606 TYPE (domain),
pointer :: grid
2608 TYPE (esmf_gridcomp) :: model
2612 logical :: got_sst(2), got_vec(2,2)
2614 integer :: id, ifld, i, is, j, ng
2615 integer :: year, month, day, hour, minutes, seconds, sn, sd
2616 integer :: importcount
2617 integer :: localde, localdecount, localpet, petcount
2618 integer :: lbi, ubi, lbj, ubj
2619 integer :: iminp, imaxp, jminp, jmaxp
2620 integer :: ids, ide, jds, jde, kds, kde
2621 integer :: ims, ime, jms, jme, kms, kme
2622 integer :: ips, ipe, jps, jpe, kps, kpe
2623 integer :: sst_index(2), vec_index(2,2)
2625 real (dp) :: fseconds, timeindays, time_current
2626 real (dp) :: myfmax(2), myfmin(2), fmin(2), fmax(2), fval
2627 real (dp) :: scale, add_offset
2629 real (dp),
pointer :: ptr2d(:,:)
2631 real (dp),
allocatable :: dat_sst(:,:), ocn_sst(:,:)
2632 real (dp),
allocatable :: dat_vec(:,:,:), ocn_vec(:,:,:)
2634 character (len=22 ) :: time_currentstring
2636 character (len=*),
parameter :: myfile = &
2637 & __FILE__//
", WRF_Import"
2639 character (ESMF_MAXSTR) :: fieldname
2640 character (ESMF_MAXSTR) :: cname, ofile
2641 character (ESMF_MAXSTR) :: sst_name(2), vec_name(2,2)
2642 character (ESMF_MAXSTR),
allocatable :: importnamelist(:)
2644 TYPE (esmf_clock) :: clock
2645 TYPE (esmf_field) :: field
2646 TYPE (esmf_state) :: importstate
2647 TYPE (esmf_time) :: currenttime
2648 TYPE (esmf_vm) :: vm
2655 WRITE (
trac,
'(a,a,i0)')
'==> Entering WRF_Import', &
2670 IF (grid%ed31.eq.imaxp)
THEN
2673 IF (grid%ed33.eq.jmaxp)
THEN
2683 CALL get_ijk_from_grid (grid, ids, ide, jds, jde, kds, kde, &
2684 & ims, ime, jms, jme, kms, kme, &
2685 & ips, ipe, jps, jpe, kps, kpe)
2691 CALL esmf_gridcompget (model, &
2692 & importstate=importstate, &
2694 & localpet=localpet, &
2695 & petcount=petcount, &
2699 IF (esmf_logfounderror(rctocheck=rc, &
2700 & msg=esmf_logerr_passthru, &
2702 & file=myfile))
THEN
2712 & localdecount=localdecount, &
2714 IF (esmf_logfounderror(rctocheck=rc, &
2715 & msg=esmf_logerr_passthru, &
2717 & file=myfile))
THEN
2725 CALL esmf_clockget (clock, &
2726 & currtime=currenttime, &
2728 IF (esmf_logfounderror(rctocheck=rc, &
2729 & msg=esmf_logerr_passthru, &
2731 & file=myfile))
THEN
2735 CALL esmf_timeget (currenttime, &
2745 IF (esmf_logfounderror(rctocheck=rc, &
2746 & msg=esmf_logerr_passthru, &
2748 & file=myfile))
THEN
2752 CALL esmf_timeget (currenttime, &
2753 & s_r8=time_current, &
2754 & timestring=time_currentstring, &
2756 IF (esmf_logfounderror(rctocheck=rc, &
2757 & msg=esmf_logerr_passthru, &
2759 & file=myfile))
THEN
2762 fseconds=real(seconds,dp)+real(sn,dp)/real(sd,dp)
2763 timeindays=time_current/86400.0_dp
2764 is=index(time_currentstring,
'T')
2765 IF (is.gt.0) time_currentstring(is:is)=
' '
2772 & itemcount=importcount, &
2774 IF (esmf_logfounderror(rctocheck=rc, &
2775 & msg=esmf_logerr_passthru, &
2777 & file=myfile))
THEN
2781 IF (.not.
allocated(importnamelist))
THEN
2782 allocate ( importnamelist(importcount) )
2785 & itemnamelist=importnamelist, &
2787 IF (esmf_logfounderror(rctocheck=rc, &
2788 & msg=esmf_logerr_passthru, &
2790 & file=myfile))
THEN
2803 fld_loop :
DO ifld=1,importcount
2809 & trim(importnamelist(ifld)), &
2812 IF (esmf_logfounderror(rctocheck=rc, &
2813 & msg=esmf_logerr_passthru, &
2815 & file=myfile))
THEN
2822 de_loop :
DO localde=0,localdecount-1
2823 CALL esmf_fieldget (field, &
2824 & localde=localde, &
2825 & farrayptr=ptr2d, &
2827 IF (esmf_logfounderror(rctocheck=rc, &
2828 & msg=esmf_logerr_passthru, &
2830 & file=myfile))
THEN
2849 fieldname=adjustl(importnamelist(ifld))
2851 SELECT CASE (trim(fieldname))
2856 IF (.not.
allocated(ocn_sst))
THEN
2857 allocate ( ocn_sst(lbi:ubi,lbj:ubj) )
2860 IF (.not.
allocated(dat_sst))
THEN
2861 allocate ( dat_sst(lbi:ubi,lbj:ubj) )
2866 sst_name(1)=trim(fieldname)
2869 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
2870 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2871 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2872 fval=scale*ptr2d(i,j)+add_offset
2873 myfmin(2)=min(myfmin(2),fval)
2874 myfmax(2)=max(myfmax(2),fval)
2882 CASE (
'Usur',
'Vsur')
2883 IF (.not.
allocated(ocn_vec))
THEN
2884 allocate ( ocn_vec(lbi:ubi,lbj:ubj,2) )
2887 IF (.not.
allocated(dat_vec))
THEN
2888 allocate ( dat_vec(lbi:ubi,lbj:ubj,2) )
2892 IF (trim(fieldname).eq.
'Usur')
THEN
2895 vec_name(1,1)=trim(fieldname)
2898 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
2899 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2900 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2901 fval=scale*ptr2d(i,j)+add_offset
2902 myfmin(2)=min(myfmin(2),fval)
2903 myfmax(2)=max(myfmax(2),fval)
2911 vec_name(2,1)=trim(fieldname)
2914 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
2915 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2916 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2917 fval=scale*ptr2d(i,j)+add_offset
2918 myfmin(2)=min(myfmin(2),fval)
2919 myfmax(2)=max(myfmax(2),fval)
2929 CASE (
'dsst',
'dSST')
2930 IF (.not.
allocated(ocn_sst))
THEN
2931 allocate ( ocn_sst(lbi:ubi,lbj:ubj) )
2934 IF (.not.
allocated(dat_sst))
THEN
2935 allocate ( dat_sst(lbi:ubi,lbj:ubj) )
2940 sst_name(2)=trim(fieldname)
2943 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
2944 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2945 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2946 fval=scale*ptr2d(i,j)+add_offset
2947 myfmin(2)=min(myfmin(2),fval)
2948 myfmax(2)=max(myfmax(2),fval)
2956 CASE (
'dUsur',
'dVsur')
2957 IF (.not.
allocated(ocn_vec))
THEN
2958 allocate ( ocn_vec(lbi:ubi,lbj:ubj,2) )
2961 IF (.not.
allocated(dat_vec))
THEN
2962 allocate ( dat_vec(lbi:ubi,lbj:ubj,2) )
2966 IF (trim(fieldname).eq.
'dUsur')
THEN
2969 vec_name(1,2)=trim(fieldname)
2972 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
2973 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2974 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2975 fval=scale*ptr2d(i,j)+add_offset
2976 myfmin(2)=min(myfmin(2),fval)
2977 myfmax(2)=max(myfmax(2),fval)
2985 vec_name(2,2)=trim(fieldname)
2988 IF (abs(ptr2d(i,j)).lt.
tol_dp)
THEN
2989 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2990 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2991 fval=scale*ptr2d(i,j)+add_offset
2992 myfmin(2)=min(myfmin(2),fval)
2993 myfmax(2)=max(myfmax(2),fval)
3003 IF (localpet.eq.0)
THEN
3004 WRITE (
cplout,10) trim(importnamelist(ifld)), &
3007 rc=esmf_rc_not_found
3008 IF (esmf_logfounderror(rctocheck=rc, &
3009 & msg=esmf_logerr_passthru, &
3011 & file=myfile))
THEN
3019 IF (
associated(ptr2d))
nullify (ptr2d)
3024 CALL esmf_vmallreduce (vm, &
3025 & senddata=myfmin, &
3028 & reduceflag=esmf_reduce_min, &
3030 IF (esmf_logfounderror(rctocheck=rc, &
3031 & msg=esmf_logerr_passthru, &
3033 & file=myfile))
THEN
3037 CALL esmf_vmallreduce (vm, &
3038 & senddata=myfmax, &
3041 & reduceflag=esmf_reduce_max, &
3043 IF (esmf_logfounderror(rctocheck=rc, &
3044 & msg=esmf_logerr_passthru, &
3046 & file=myfile))
THEN
3052 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
3053 WRITE (
cplout,20) trim(importnamelist(ifld)), &
3054 & trim(time_currentstring), ng, &
3056 IF (scale.ne.1.0_dp)
THEN
3057 WRITE (
cplout,30) fmin(2), fmax(2), &
3058 &
' wrfScale = ', scale
3059 ELSE IF (add_offset.ne.0.0_dp)
THEN
3060 WRITE (
cplout,30) fmin(2), fmax(2), &
3061 &
' AddOffset = ', add_offset
3069 WRITE (ofile,40) ng, trim(importnamelist(ifld)), &
3070 & year, month, day, hour, minutes, seconds
3071 CALL esmf_fieldwrite (field, &
3073 & overwrite=.true., &
3075 IF (esmf_logfounderror(rctocheck=rc, &
3076 & msg=esmf_logerr_passthru, &
3078 & file=myfile))
THEN
3086 IF (any(got_sst))
THEN
3088 & got_sst, sst_index, sst_name, &
3089 & lbi, ubi, lbj, ubj, &
3090 & ocn_sst, dat_sst, &
3092 IF (esmf_logfounderror(rctocheck=rc, &
3093 & msg=esmf_logerr_passthru, &
3095 & file=myfile))
THEN
3102 IF (any(got_vec))
THEN
3104 & got_vec, vec_index, vec_name, &
3105 & lbi, ubi, lbj, ubj, 2, &
3106 & ocn_vec, dat_vec, &
3108 IF (esmf_logfounderror(rctocheck=rc, &
3109 & msg=esmf_logerr_passthru, &
3111 & file=myfile))
THEN
3120 IF (
allocated(importnamelist))
deallocate (importnamelist)
3121 IF (
allocated(ocn_sst))
deallocate (ocn_sst)
3122 IF (
allocated(dat_sst))
deallocate (dat_sst)
3126 IF (importcount.gt.0)
THEN
3131 WRITE (
trac,
'(a,a,i0)')
'<== Exiting WRF_Import', &
3137 10
FORMAT (/,5x,
'WRF_Import - unable to find option to import: ', &
3138 & a,/,18x,
'check ''Import(atmos)'' in input script: ', a)
3139 20
FORMAT (5x,
'WRF_Import - ESMF: importing field ''',a,
'''', &
3140 & t72,a,2x,
'Grid ',i2.2,/, &
3141 & 19x,
'(InpMin = ', 1p,e15.8,0p,
' InpMax = ',1p,e15.8,0p, &
3143 30
FORMAT (19x,
'(OutMin = ', 1p,e15.8,0p,
' OutMax = ',1p,e15.8,0p, &
3144 & 1x,a,1p,e15.8,0p,
')')
3145 40
FORMAT (
'wrf_',i2.2,
'_import_',a,
'_',i4.4,2(
'-',i2.2),
'_', &
3146 & i2.2,2(
'.',i2.2),
'.nc')
3152 & got, ifield, FieldName, &
3153 & LBi, UBi, LBj, UBj, &
3193 USE module_domain,
ONLY : domain
3198 logical,
intent(in) :: got(2)
3200 integer,
intent(in) :: ifield(2)
3201 integer,
intent(in) :: LBi, UBi, LBj, UBj
3202 integer,
intent(out) :: rc
3204 real (dp),
intent(in) :: Focn(LBi:UBi,LBj:UBj)
3205 real (dp),
intent(in) :: Fdat(LBi:UBi,LBj:UBj)
3207 character (len=*),
intent(in) :: FieldName(:)
3209 TYPE (domain),
pointer :: grid
3210 TYPE (ESMF_GridComp) :: model
3214 logical :: got_dat, got_ocn
3215 logical :: DebugWrite(2) = (/ .false., .false. /)
3217 integer :: i, ic, is, j, ng
3218 integer :: year, month, day, hour, minutes, seconds, sN, SD
3219 integer :: LakeValue, LandValue
3220 integer :: localDE, localDEcount, localPET, PETcount
3221 integer :: IminP, ImaxP, JminP, JmaxP
3223 real (dp) :: Fseconds, TimeInDays, Time_Current
3225 real (dp) :: Fval, MyFmax(3), MyFmin(3), Fmin(3), Fmax(3)
3227 real (dp),
pointer :: ptr2d(:,:) => null()
3229 real (KIND(grid%sst)),
pointer :: Fout(:,:) => null()
3231 character (len=22 ) :: Time_CurrentString
3233 character (len=*),
parameter :: MyFile = &
3234 & __FILE__//
", WRF_ProcessImport_scalar"
3236 character (ESMF_MAXSTR) :: cname, fld_string, ofile
3238 TYPE (ESMF_ArraySpec) :: arraySpec2d
3239 TYPE (ESMF_Clock) :: clock
3240 TYPE (ESMF_Field) :: Fmerge
3241 TYPE (ESMF_StaggerLoc) :: staggerLoc
3242 TYPE (ESMF_Time) :: CurrentTime
3243 TYPE (ESMF_VM) :: vm
3250 WRITE (
trac,
'(a,a,i0)')
'==> Entering WRF_ProcessImport_scalar',&
3260 CALL esmf_gridcompget (model, &
3262 & localpet=localpet, &
3263 & petcount=petcount, &
3267 IF (esmf_logfounderror(rctocheck=rc, &
3268 & msg=esmf_logerr_passthru, &
3270 & file=myfile))
THEN
3280 & localdecount=localdecount, &
3282 IF (esmf_logfounderror(rctocheck=rc, &
3283 & msg=esmf_logerr_passthru, &
3285 & file=myfile))
THEN
3291 CALL esmf_clockget (clock, &
3292 & currtime=currenttime, &
3294 IF (esmf_logfounderror(rctocheck=rc, &
3295 & msg=esmf_logerr_passthru, &
3297 & file=myfile))
THEN
3301 CALL esmf_timeget (currenttime, &
3311 IF (esmf_logfounderror(rctocheck=rc, &
3312 & msg=esmf_logerr_passthru, &
3314 & file=myfile))
THEN
3318 CALL esmf_timeget (currenttime, &
3319 & s_r8=time_current, &
3320 & timestring=time_currentstring, &
3322 IF (esmf_logfounderror(rctocheck=rc, &
3323 & msg=esmf_logerr_passthru, &
3325 & file=myfile))
THEN
3328 fseconds=real(seconds,dp)+real(sn,dp)/real(sd,dp)
3329 timeindays=time_current/86400.0_dp
3330 is=index(time_currentstring,
'T')
3331 IF (is.gt.0) time_currentstring(is:is)=
' '
3339 CALL esmf_arrayspecset (arrayspec2d, &
3340 & typekind=esmf_typekind_r8, &
3343 IF (esmf_logfounderror(rctocheck=rc, &
3344 & msg=esmf_logerr_passthru, &
3346 & file=myfile))
THEN
3355 IF (.not.got_dat.and.got_ocn)
THEN
3356 debugwrite(1)=
models(
iatmos)%ImportField(ifield(1))%debug_write
3357 fld_string=trim(fieldname(1))
3358 ELSE IF (.not.got_ocn.and.got_dat)
THEN
3359 debugwrite(2)=
models(
iatmos)%ImportField(ifield(2))%debug_write
3360 fld_string=trim(fieldname(2))
3361 ELSE IF (got_ocn.and.got_dat)
THEN
3362 debugwrite(1)=
models(
iatmos)%ImportField(ifield(1))%debug_write
3363 debugwrite(2)=
models(
iatmos)%ImportField(ifield(2))%debug_write
3364 fld_string=trim(fieldname(1))//
'-'//trim(fieldname(2))
3366 staggerloc=esmf_staggerloc_center
3370 & staggerloc=staggerloc, &
3371 & name=trim(fld_string), &
3373 IF (esmf_logfounderror(rctocheck=rc, &
3374 & msg=esmf_logerr_passthru, &
3376 & file=myfile))
THEN
3382 CALL esmf_fieldget (fmerge, &
3383 & farrayptr=ptr2d, &
3385 IF (esmf_logfounderror(rctocheck=rc, &
3386 & msg=esmf_logerr_passthru, &
3388 & file=myfile))
THEN
3399 SELECT CASE (
lowercase(trim(fld_string)))
3400 CASE (
'sst',
'dsst',
'sst-dsst',
'dsst-sst')
3403 IF (localpet.eq.0)
THEN
3406 rc=esmf_rc_not_found
3407 IF (esmf_logfounderror(rctocheck=rc, &
3408 & msg=esmf_logerr_passthru, &
3410 & file=myfile))
THEN
3421 IF (grid%ed31.eq.imaxp)
THEN
3424 IF (grid%ed33.eq.jmaxp)
THEN
3445 IF (.not.got_dat.and.got_ocn)
THEN
3450 IF ((int(grid%landmask(i,j)).ne.landvalue).and. &
3451 & (int(grid%lakemask(i,j)).ne.lakevalue))
THEN
3452 fout(i,j)=real(focn(i,j), kind(grid%sst))
3454 ptr2d(i,j)=real(fout(i,j), dp)
3455 myfmin(1)=min(myfmin(1),fout(i,j))
3456 myfmax(1)=max(myfmax(1),fout(i,j))
3459 ELSE IF (.not.got_ocn.and.got_dat)
THEN
3464 IF ((int(grid%landmask(i,j)).ne.landvalue).and. &
3465 & (int(grid%lakemask(i,j)).ne.lakevalue))
THEN
3466 fout(i,j)=real(fdat(i,j), kind(grid%sst))
3468 ptr2d(i,j)=real(fout(i,j), dp)
3469 myfmin(1)=min(myfmin(1),fout(i,j))
3470 myfmax(1)=max(myfmax(1),fout(i,j))
3479 IF (got_ocn.and.got_dat)
THEN
3492 IF ((int(grid%landmask(i,j)).ne.landvalue).and. &
3493 & (int(grid%lakemask(i,j)).ne.lakevalue))
THEN
3494 IF (abs(fdat(i,j)).lt.
tol_dp)
THEN
3495 myfmin(2)=min(myfmin(2),fdat(i,j))
3496 myfmax(2)=max(myfmax(2),fdat(i,j))
3498 IF (abs(focn(i,j)).lt.
tol_dp)
THEN
3499 myfmin(1)=min(myfmin(1),focn(i,j))
3500 myfmax(1)=max(myfmax(1),focn(i,j))
3504 fout(i,j)=real(fval, kind(grid%sst))
3505 ptr2d(i,j)=real(fval, dp)
3506 myfmin(3)=min(myfmin(3),fval)
3507 myfmax(3)=max(myfmax(3),fval)
3516 IF (got_ocn.and.got_dat)
THEN
3521 CALL esmf_vmallreduce (vm, &
3522 & senddata=myfmin, &
3525 & reduceflag=esmf_reduce_min, &
3527 IF (esmf_logfounderror(rctocheck=rc, &
3528 & msg=esmf_logerr_passthru, &
3530 & file=myfile))
THEN
3534 CALL esmf_vmallreduce (vm, &
3535 & senddata=myfmax, &
3538 & reduceflag=esmf_reduce_max, &
3540 IF (esmf_logfounderror(rctocheck=rc, &
3541 & msg=esmf_logerr_passthru, &
3543 & file=myfile))
THEN
3549 IF (got_ocn.and.got_dat)
THEN
3550 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
3551 WRITE (
cplout,20) trim(fld_string), &
3552 & trim(time_currentstring), ng, &
3553 & fmin(1), fmax(1), &
3554 & fmin(2), fmax(2), &
3558 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
3559 WRITE (
cplout,30) fmin(1), fmax(1)
3565 IF ((
debuglevel.ge.3).and.any(debugwrite))
THEN
3566 WRITE (ofile,40) ng, trim(fld_string), &
3567 & year, month, day, hour, minutes, seconds
3568 CALL esmf_fieldwrite (fmerge, &
3570 & overwrite=.true., &
3572 IF (esmf_logfounderror(rctocheck=rc, &
3573 & msg=esmf_logerr_passthru, &
3575 & file=myfile))
THEN
3583 IF (
associated(ptr2d))
nullify (ptr2d)
3584 IF (
associated(fout ))
nullify (fout)
3588 CALL esmf_fielddestroy (fmerge, &
3589 & nogarbage=.false., &
3591 IF (esmf_logfounderror(rctocheck=rc, &
3592 & msg=esmf_logerr_passthru, &
3594 & file=myfile))
THEN
3599 WRITE (
trac,
'(a,a,i0)')
'<== Exiting WRF_ProcessImport_scalar',&
3605 10
FORMAT (/,5x,
'WRF_ProcessImport - ', &
3606 &
'unable to find option to import: ',a, &
3607 & /,25x,
'check ''Import(atmos)'' in input script: ',a)
3608 20
FORMAT (1x,
' WRF_ProcessImport - ESMF: merging field ''',a,
'''', &
3609 & t72,a,2x,
'Grid ',i2.2, &
3610 & /,19x,
'(OcnMin = ', 1p,e15.8,0p, &
3611 &
' OcnMax = ', 1p,e15.8,0p,
')', &
3612 & /,19x,
'(DatMin = ', 1p,e15.8,0p, &
3613 &
' DatMax = ', 1p,e15.8,0p,
')', &
3614 & /,19x,
'(OutMin = ', 1p,e15.8,0p, &
3615 &
' OutMax = ', 1p,e15.8,0p,
')')
3616 30
FORMAT (19x,
'(OutMin = ', 1p,e15.8,0p, &
3617 &
' OutMax = ', 1p,e15.8,0p,
') WRF_ProcessImport')
3618 40
FORMAT (
'wrf_',i2.2,
'_merged_',a,
'_',i4.4,2(
'-',i2.2),
'_', &
3619 & i2.2,2(
'.',i2.2),
'.nc')
3625 & got, ifield, FieldName, &
3626 & LBi, UBi, LBj, UBj, UBk, &
3672 USE module_domain,
ONLY : domain
3677 integer,
intent(in) :: LBi, UBi, LBj, UBj, UBk
3678 integer,
intent(in) :: ifield(2,UBk)
3679 integer,
intent(out) :: rc
3681 logical,
intent(in) :: got(2,UBk)
3683 real (dp),
intent(in) :: Focn(LBi:UBi,LBj:UBj,UBk)
3684 real (dp),
intent(in) :: Fdat(LBi:UBi,LBj:UBj,UBk)
3686 character (len=*),
intent(in) :: FieldName(2,UBk)
3688 TYPE (domain),
pointer :: grid
3689 TYPE (ESMF_GridComp) :: model
3693 logical :: got_dat, got_ocn
3694 logical :: DebugWrtU(2) = (/ .false., .false. /)
3695 logical :: DebugWrtv(2) = (/ .false., .false. /)
3697 integer :: i, ic, is, j, ng
3698 integer :: year, month, day, hour, minutes, seconds, sN, SD
3699 integer :: LakeValue, LandValue
3700 integer :: localDE, localDEcount, localPET, PETcount
3701 integer :: IminP, ImaxP, JminP, JmaxP
3703 real (dp) :: Fseconds, TimeInDays, Time_Current
3705 real (dp) :: MyUmax(3), MyUmin(3), Umin(3), Umax(3), Uval
3706 real (dp) :: MyVmax(3), MyVmin(3), Vmin(3), Vmax(3), Vval
3708 real (dp),
parameter :: MaxOcnVelocity = 10.0_dp
3710 real (dp),
pointer :: ptrU2d(:,:) => null()
3711 real (dp),
pointer :: ptrV2d(:,:) => null()
3713 real (KIND(grid%uoce)),
pointer :: Uout(:,:) => null()
3714 real (KIND(grid%voce)),
pointer :: Vout(:,:) => null()
3716 character (len=22 ) :: Time_CurrentString
3718 character (len=*),
parameter :: MyFile = &
3719 & __FILE__//
", WRF_ProcessImport_vector"
3721 character (ESMF_MAXSTR) :: cname, ofile, U_string, V_string
3723 TYPE (ESMF_ArraySpec) :: arraySpec2d
3724 TYPE (ESMF_Clock) :: clock
3725 TYPE (ESMF_Field) :: Umerge, Vmerge
3726 TYPE (ESMF_StaggerLoc) :: staggerLoc
3727 TYPE (ESMF_Time) :: CurrentTime
3728 TYPE (ESMF_VM) :: vm
3735 WRITE (
trac,
'(a,a,i0)')
'==> Entering WRF_ProcessImport_vector',&
3745 CALL esmf_gridcompget (model, &
3747 & localpet=localpet, &
3748 & petcount=petcount, &
3752 IF (esmf_logfounderror(rctocheck=rc, &
3753 & msg=esmf_logerr_passthru, &
3755 & file=myfile))
THEN
3765 & localdecount=localdecount, &
3767 IF (esmf_logfounderror(rctocheck=rc, &
3768 & msg=esmf_logerr_passthru, &
3770 & file=myfile))
THEN
3776 CALL esmf_clockget (clock, &
3777 & currtime=currenttime, &
3779 IF (esmf_logfounderror(rctocheck=rc, &
3780 & msg=esmf_logerr_passthru, &
3782 & file=myfile))
THEN
3786 CALL esmf_timeget (currenttime, &
3796 IF (esmf_logfounderror(rctocheck=rc, &
3797 & msg=esmf_logerr_passthru, &
3799 & file=myfile))
THEN
3803 CALL esmf_timeget (currenttime, &
3804 & s_r8=time_current, &
3805 & timestring=time_currentstring, &
3807 IF (esmf_logfounderror(rctocheck=rc, &
3808 & msg=esmf_logerr_passthru, &
3810 & file=myfile))
THEN
3813 fseconds=real(seconds,dp)+real(sn,dp)/real(sd,dp)
3814 timeindays=time_current/86400.0_dp
3815 is=index(time_currentstring,
'T')
3816 IF (is.gt.0) time_currentstring(is:is)=
' '
3824 CALL esmf_arrayspecset (arrayspec2d, &
3825 & typekind=esmf_typekind_r8, &
3828 IF (esmf_logfounderror(rctocheck=rc, &
3829 & msg=esmf_logerr_passthru, &
3831 & file=myfile))
THEN
3837 got_ocn=got(1,1).and.got(1,2)
3838 got_dat=got(2,1).and.got(2,2)
3840 IF (.not.got_dat.and.got_ocn)
THEN
3841 debugwrtu(1)=
models(
iatmos)%ImportField(ifield(1,1))%debug_write
3842 debugwrtv(1)=
models(
iatmos)%ImportField(ifield(1,2))%debug_write
3843 u_string=trim(fieldname(1,1))
3844 v_string=trim(fieldname(1,2))
3845 ELSE IF (.not.got_ocn.and.got_dat)
THEN
3846 debugwrtu(2)=
models(
iatmos)%ImportField(ifield(2,1))%debug_write
3847 debugwrtv(2)=
models(
iatmos)%ImportField(ifield(2,2))%debug_write
3848 u_string=trim(fieldname(2,1))
3849 v_string=trim(fieldname(2,2))
3850 ELSE IF (got_ocn.and.got_dat)
THEN
3851 debugwrtu(1)=
models(
iatmos)%ImportField(ifield(1,1))%debug_write
3852 debugwrtv(1)=
models(
iatmos)%ImportField(ifield(1,2))%debug_write
3853 debugwrtu(2)=
models(
iatmos)%ImportField(ifield(2,1))%debug_write
3854 debugwrtv(2)=
models(
iatmos)%ImportField(ifield(2,2))%debug_write
3855 u_string=trim(fieldname(1,1))//
'-'//trim(fieldname(1,2))
3856 v_string=trim(fieldname(2,1))//
'-'//trim(fieldname(2,2))
3858 staggerloc=esmf_staggerloc_center
3862 & staggerloc=staggerloc, &
3863 & name=trim(u_string), &
3865 IF (esmf_logfounderror(rctocheck=rc, &
3866 & msg=esmf_logerr_passthru, &
3868 & file=myfile))
THEN
3874 & staggerloc=staggerloc, &
3875 & name=trim(v_string), &
3877 IF (esmf_logfounderror(rctocheck=rc, &
3878 & msg=esmf_logerr_passthru, &
3880 & file=myfile))
THEN
3886 CALL esmf_fieldget (umerge, &
3887 & farrayptr=ptru2d, &
3889 IF (esmf_logfounderror(rctocheck=rc, &
3890 & msg=esmf_logerr_passthru, &
3892 & file=myfile))
THEN
3897 CALL esmf_fieldget (vmerge, &
3898 & farrayptr=ptrv2d, &
3900 IF (esmf_logfounderror(rctocheck=rc, &
3901 & msg=esmf_logerr_passthru, &
3903 & file=myfile))
THEN
3916 CASE (
'usur',
'dusur',
'usur-dusur',
'dusur-usur')
3919 IF (localpet.eq.0)
THEN
3922 rc=esmf_rc_not_found
3923 IF (esmf_logfounderror(rctocheck=rc, &
3924 & msg=esmf_logerr_passthru, &
3926 & file=myfile))
THEN
3932 CASE (
'vsur',
'dvsur',
'vsur-dvsur',
'dvsur-vsur')
3935 IF (localpet.eq.0)
THEN
3938 rc=esmf_rc_not_found
3939 IF (esmf_logfounderror(rctocheck=rc, &
3940 & msg=esmf_logerr_passthru, &
3942 & file=myfile))
THEN
3953 IF (grid%ed31.eq.imaxp)
THEN
3956 IF (grid%ed33.eq.jmaxp)
THEN
3977 IF (.not.got_dat.and.got_ocn)
THEN
3984 IF ((int(grid%landmask(i,j)).ne.landvalue).and. &
3985 & (int(grid%lakemask(i,j)).ne.lakevalue))
THEN
3986 uout(i,j)=real(focn(i,j,1), kind(grid%uoce))
3987 vout(i,j)=real(focn(i,j,2), kind(grid%voce))
3989 ptru2d(i,j)=real(uout(i,j), dp)
3990 ptrv2d(i,j)=real(vout(i,j), dp)
3991 myumin(1)=min(myumin(1),uout(i,j))
3992 myumax(1)=max(myumax(1),uout(i,j))
3993 myvmin(1)=min(myvmin(1),vout(i,j))
3994 myvmax(1)=max(myvmax(1),vout(i,j))
3997 ELSE IF (.not.got_ocn.and.got_dat)
THEN
4004 IF ((int(grid%landmask(i,j)).ne.landvalue).and. &
4005 & (int(grid%lakemask(i,j)).ne.lakevalue))
THEN
4006 uout(i,j)=real(fdat(i,j,1), kind(grid%uoce))
4007 vout(i,j)=real(fdat(i,j,2), kind(grid%voce))
4009 ptru2d(i,j)=real(uout(i,j), dp)
4010 ptrv2d(i,j)=real(vout(i,j), dp)
4011 myumin(1)=min(myumin(1),uout(i,j))
4012 myumax(1)=max(myumax(1),uout(i,j))
4013 myvmin(1)=min(myvmin(1),vout(i,j))
4014 myvmax(1)=max(myvmax(1),vout(i,j))
4023 IF (got_ocn.and.got_dat)
THEN
4038 IF ((int(grid%landmask(i,j)).ne.landvalue).and. &
4039 & (int(grid%lakemask(i,j)).ne.lakevalue))
THEN
4040 IF ((abs(fdat(i,j,1)).lt.maxocnvelocity).and. &
4041 & (abs(fdat(i,j,2)).lt.maxocnvelocity))
THEN
4042 myumin(2)=min(myumin(2),fdat(i,j,1))
4043 myumax(2)=max(myumax(2),fdat(i,j,1))
4044 myvmin(2)=min(myvmin(2),fdat(i,j,2))
4045 myvmax(2)=max(myvmax(2),fdat(i,j,2))
4048 IF ((abs(focn(i,j,1)).lt.maxocnvelocity).and. &
4049 & (abs(focn(i,j,2)).lt.maxocnvelocity))
THEN
4050 myumin(1)=min(myumin(1),focn(i,j,1))
4051 myumax(1)=max(myumax(1),focn(i,j,1))
4052 myvmin(1)=min(myvmin(1),focn(i,j,2))
4053 myvmax(1)=max(myvmax(1),focn(i,j,2))
4059 uout(i,j)=real(uval, kind(grid%uoce))
4060 vout(i,j)=real(vval, kind(grid%voce))
4061 ptru2d(i,j)=real(uval, dp)
4062 ptrv2d(i,j)=real(vval, dp)
4063 myumin(3)=min(myumin(3),uval)
4064 myumax(3)=max(myumax(3),uval)
4065 myvmin(3)=min(myvmin(3),vval)
4066 myvmax(3)=max(myvmax(3),vval)
4075 IF (got_ocn.and.got_dat)
THEN
4081 CALL esmf_vmallreduce (vm, &
4082 & senddata=myumin, &
4085 & reduceflag=esmf_reduce_min, &
4087 IF (esmf_logfounderror(rctocheck=rc, &
4088 & msg=esmf_logerr_passthru, &
4090 & file=myfile))
THEN
4094 CALL esmf_vmallreduce (vm, &
4095 & senddata=myumax, &
4098 & reduceflag=esmf_reduce_max, &
4100 IF (esmf_logfounderror(rctocheck=rc, &
4101 & msg=esmf_logerr_passthru, &
4103 & file=myfile))
THEN
4107 CALL esmf_vmallreduce (vm, &
4108 & senddata=myvmin, &
4111 & reduceflag=esmf_reduce_min, &
4113 IF (esmf_logfounderror(rctocheck=rc, &
4114 & msg=esmf_logerr_passthru, &
4116 & file=myfile))
THEN
4120 CALL esmf_vmallreduce (vm, &
4121 & senddata=myvmax, &
4124 & reduceflag=esmf_reduce_max, &
4126 IF (esmf_logfounderror(rctocheck=rc, &
4127 & msg=esmf_logerr_passthru, &
4129 & file=myfile))
THEN
4135 IF (got_ocn.and.got_dat)
THEN
4136 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
4137 WRITE (
cplout,20) trim(u_string), &
4138 & trim(time_currentstring), ng, &
4139 & umin(1), umax(1), &
4140 & umin(2), umax(2), &
4142 WRITE (
cplout,20) trim(v_string), &
4143 & trim(time_currentstring), ng, &
4144 & vmin(1), vmax(1), &
4145 & vmin(2), vmax(2), &
4149 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
4150 WRITE (
cplout,30) umin(1), umax(1)
4151 WRITE (
cplout,30) vmin(1), vmax(1)
4157 IF ((
debuglevel.ge.3).and.any(debugwrtu))
THEN
4158 WRITE (ofile,40) ng, trim(u_string), &
4159 & year, month, day, hour, minutes, seconds
4160 CALL esmf_fieldwrite (umerge, &
4162 & overwrite=.true., &
4164 IF (esmf_logfounderror(rctocheck=rc, &
4165 & msg=esmf_logerr_passthru, &
4167 & file=myfile))
THEN
4172 IF ((
debuglevel.ge.3).and.any(debugwrtv))
THEN
4173 WRITE (ofile,40) ng, trim(v_string), &
4174 & year, month, day, hour, minutes, seconds
4175 CALL esmf_fieldwrite (vmerge, &
4177 & overwrite=.true., &
4179 IF (esmf_logfounderror(rctocheck=rc, &
4180 & msg=esmf_logerr_passthru, &
4182 & file=myfile))
THEN
4190 IF (
associated(ptru2d))
nullify (ptru2d)
4191 IF (
associated(ptrv2d))
nullify (ptrv2d)
4192 IF (
associated(uout ))
nullify (uout)
4193 IF (
associated(vout ))
nullify (vout)
4197 CALL esmf_fielddestroy (umerge, &
4198 & nogarbage=.false., &
4200 IF (esmf_logfounderror(rctocheck=rc, &
4201 & msg=esmf_logerr_passthru, &
4203 & file=myfile))
THEN
4207 CALL esmf_fielddestroy (vmerge, &
4208 & nogarbage=.false., &
4210 IF (esmf_logfounderror(rctocheck=rc, &
4211 & msg=esmf_logerr_passthru, &
4213 & file=myfile))
THEN
4218 WRITE (
trac,
'(a,a,i0)')
'<== Exiting WRF_ProcessImport_vector',&
4224 10
FORMAT (/,5x,
'WRF_ProcessImport - ', &
4225 &
'unable to find option to import: ',a, &
4226 & /,25x,
'check ''Import(atmos)'' in input script: ',a)
4227 20
FORMAT (1x,
' WRF_ProcessImport - ESMF: merging field ''',a,
'''', &
4228 & t72,a,2x,
'Grid ',i2.2, &
4229 & /,19x,
'(OcnMin = ', 1p,e15.8,0p, &
4230 &
' OcnMax = ', 1p,e15.8,0p,
')', &
4231 & /,19x,
'(DatMin = ', 1p,e15.8,0p, &
4232 &
' DatMax = ', 1p,e15.8,0p,
')', &
4233 & /,19x,
'(OutMin = ', 1p,e15.8,0p, &
4234 &
' OutMax = ', 1p,e15.8,0p,
')')
4235 30
FORMAT (19x,
'(OutMin = ', 1p,e15.8,0p, &
4236 &
' OutMax = ', 1p,e15.8,0p,
') WRF_ProcessImport')
4237 40
FORMAT (
'wrf_',i2.2,
'_merged_',a,
'_',i4.4,2(
'-',i2.2),
'_', &
4238 & i2.2,2(
'.',i2.2),
'.nc')
4251 USE module_domain,
ONLY : domain
4258 integer,
intent(out) :: rc
4260 TYPE (domain),
intent(in) :: grid
4261 TYPE (esmf_gridcomp) :: model
4265 integer :: ifld, i, is, j, ng
4266 integer :: istr, iend, jstr, jend
4267 integer :: year, month, day, hour, minutes, seconds, sn, sd
4268 integer :: lakevalue, landvalue
4269 integer :: exportcount
4270 integer :: localde, localdecount, localpet, petcount
4272 integer :: mean_interval
4275 real (dp),
parameter :: eps = 1.0e-10_dp
4276 real (dp),
parameter :: stbolt = 5.67051e-8_dp
4277 real (dp),
parameter :: z1 = 3.0_dp
4279 real (dp) :: fseconds, timeindays, time_current
4280 real (dp) :: cff1, cff2, cff3, f1, scale
4281 real (dp) :: myfmax(1), myfmin(1), fmin(1), fmax(1), fval
4283 real (dp),
pointer :: ptr2d(:,:) => null()
4285 character (len=22) :: time_currentstring
4287 character (len=35) :: istring
4289 character (len=*),
parameter :: myfile = &
4290 & __FILE__//
", WRF_Export"
4292 character (ESMF_MAXSTR) :: cname, ofile
4293 character (ESMF_MAXSTR),
allocatable :: exportnamelist(:)
4295 TYPE (esmf_clock) :: clock
4296 TYPE (esmf_field) :: field
4297 TYPE (esmf_state) :: exportstate
4298 TYPE (esmf_time) :: currenttime
4299 TYPE (esmf_vm) :: vm
4306 WRITE (
trac,
'(a,a,i0)')
'==> Entering WRF_Export', &
4316 CALL esmf_gridcompget (model, &
4317 & exportstate=exportstate, &
4319 & localpet=localpet, &
4320 & petcount=petcount, &
4324 IF (esmf_logfounderror(rctocheck=rc, &
4325 & msg=esmf_logerr_passthru, &
4327 & file=myfile))
THEN
4337 & localdecount=localdecount, &
4339 IF (esmf_logfounderror(rctocheck=rc, &
4340 & msg=esmf_logerr_passthru, &
4342 & file=myfile))
THEN
4358 CALL esmf_clockget (clock, &
4359 & currtime=currenttime, &
4361 IF (esmf_logfounderror(rctocheck=rc, &
4362 & msg=esmf_logerr_passthru, &
4364 & file=myfile))
THEN
4368 CALL esmf_timeget (currenttime, &
4378 IF (esmf_logfounderror(rctocheck=rc, &
4379 & msg=esmf_logerr_passthru, &
4381 & file=myfile))
THEN
4385 CALL esmf_timeget (currenttime, &
4386 & s_r8=time_current, &
4387 & timestring=time_currentstring, &
4389 IF (esmf_logfounderror(rctocheck=rc, &
4390 & msg=esmf_logerr_passthru, &
4392 & file=myfile))
THEN
4395 fseconds=real(seconds,dp)+real(sn,dp)/real(sd,dp)
4396 timeindays=time_current/86400.0_dp
4397 is=index(time_currentstring,
'T')
4398 IF (is.gt.0) time_currentstring(is:is)=
' '
4426 IF (grid%mean_diag.ne.1)
THEN
4427 IF (localpet.eq.0)
THEN
4428 WRITE (
cplout,10)
'namelist &time_control, mean_diag = ', &
4429 & grid%mean_diag,
uppercase(
'wrf_timeavg')
4431 rc=esmf_rc_not_valid
4432 IF (esmf_logfounderror(rctocheck=rc, &
4433 & msg=esmf_logerr_passthru, &
4435 & file=myfile))
THEN
4443 IF (grid%mean_diag_interval.gt.0)
THEN
4444 istring=
'namelist: mean_diag_interval = '
4445 mean_interval=grid%mean_diag_interval*60
4446 ELSE IF (grid%mean_diag_interval_s.gt.0)
THEN
4447 istring=
'namelist: mean_diag_interval_s = '
4448 mean_interval=grid%mean_diag_interval_s
4449 ELSE IF (grid%mean_diag_interval_m.gt.0)
THEN
4450 istring=
'namelist: mean_diag_interval_m = '
4451 mean_interval=grid%mean_diag_interval_m*60
4452 ELSE IF (grid%mean_diag_interval_h.gt.0)
THEN
4453 istring=
'namelist: mean_diag_interval_h = '
4454 mean_interval=grid%mean_diag_interval_h*3600
4455 ELSE IF (grid%mean_diag_interval_d.gt.0)
THEN
4456 istring=
'namelist: mean_diag_interval_d = '
4457 mean_interval=grid%mean_diag_interval_d*86400
4458 ELSE IF (grid%mean_diag_interval_mo.gt.0)
THEN
4459 istring=
'namelist: mean_diag_interval_mo = '
4460 mean_interval=grid%mean_diag_interval_mo*30*86400
4464 IF (localpet.eq.0)
THEN
4465 WRITE (
cplout,20) trim(istring), &
4470 rc=esmf_rc_val_wrong
4471 IF (esmf_logfounderror(rctocheck=rc, &
4472 & msg=esmf_logerr_passthru, &
4474 & file=myfile))
THEN
4486 & itemcount=exportcount, &
4488 IF (esmf_logfounderror(rctocheck=rc, &
4489 & msg=esmf_logerr_passthru, &
4491 & file=myfile))
THEN
4495 IF (.not.
allocated(exportnamelist))
THEN
4496 allocate ( exportnamelist(exportcount) )
4499 & itemnamelist=exportnamelist, &
4501 IF (esmf_logfounderror(rctocheck=rc, &
4502 & msg=esmf_logerr_passthru, &
4504 & file=myfile))
THEN
4512 fld_loop :
DO ifld=1,exportcount
4517 & trim(exportnamelist(ifld)), &
4520 IF (esmf_logfounderror(rctocheck=rc, &
4521 & msg=esmf_logerr_passthru, &
4523 & file=myfile))
THEN
4530 de_loop :
DO localde=0,localdecount-1
4531 CALL esmf_fieldget (field, &
4532 & localde=localde, &
4533 & farrayptr=ptr2d, &
4535 IF (esmf_logfounderror(rctocheck=rc, &
4536 & msg=esmf_logerr_passthru, &
4538 & file=myfile))
THEN
4541 istr=lbound(ptr2d,1)
4542 iend=ubound(ptr2d,1)
4543 jstr=lbound(ptr2d,2)
4544 jend=ubound(ptr2d,2)
4557 SELECT CASE (trim(adjustl(exportnamelist(ifld))))
4562 CASE (
'psfc',
'Pair')
4568 fval=real(grid%psfc_mean(i,j),dp)* &
4569 & exp((9.81_dp*real(grid%ht(i,j),dp))/ &
4570 & (287.0_dp*real(grid%t2_mean(i,j),dp)* &
4571 & (1.0_dp+0.61_dp*real(grid%q2_mean(i,j),dp))))
4573 fval=real(grid%psfc(i,j),dp)* &
4574 & exp((9.81_dp*real(grid%ht(i,j),dp))/ &
4575 & (287.0_dp*real(grid%t2(i,j),dp)* &
4576 & (1.0_dp+0.61_dp*real(grid%q2(i,j),dp))))
4578 myfmin(1)=min(myfmin(1),fval)
4579 myfmax(1)=max(myfmax(1),fval)
4586 CASE (
'tsfc',
'Tair')
4592 fval=real(grid%t2_mean(i,j),dp)
4594 fval=real(grid%t2(i,j),dp)
4596 myfmin(1)=min(myfmin(1),fval)
4597 myfmax(1)=max(myfmax(1),fval)
4614 cff1=real(grid%psfc_mean(i,j),dp)/ &
4615 & (exp((9.81_dp*2.0_dp)/ &
4616 & (287.0_dp*real(grid%t2_mean(i,j),dp))))
4617 fval=real(grid%q2_mean(i,j),dp)*cff1/ &
4618 & (real(grid%q2_mean(i,j),dp)* &
4619 & (1.0_dp-0.622_dp)+0.622_dp)
4621 cff1=real(grid%psfc(i,j),dp)/ &
4622 & (exp((9.81_dp*2.0_dp)/ &
4623 & (287.0_dp*real(grid%t2(i,j),dp))))
4624 fval=real(grid%q2(i,j),dp)*cff1/ &
4625 & (real(grid%q2(i,j),dp)* &
4626 & (1.0_dp-0.622_dp)+0.622_dp)
4628 myfmin(1)=min(myfmin(1),fval)
4629 myfmax(1)=max(myfmax(1),fval)
4639 CASE (
'qsfc',
'Qair')
4645 cff1=real(grid%psfc_mean(i,j),dp)/ &
4646 & (exp((9.81_dp*2.0_dp)/ &
4647 & (287.0_dp*real(grid%t2_mean(i,j),dp))))
4648 cff2=real(grid%q2_mean(i,j),dp)*cff1/ &
4649 & (real(grid%q2_mean(i,j),dp)* &
4650 & (1.0_dp-0.622_dp)+0.622_dp)
4652 & exp((17.67_dp*(real(grid%t2_mean(i,j),dp)- &
4654 & ((real(grid%t2_mean(i,j),dp)-273.15_dp)+ &
4657 cff1=real(grid%psfc(i,j),dp)/ &
4658 & (exp((9.81_dp*2.0_dp)/ &
4659 & (287.0_dp*real(grid%t2(i,j),dp))))
4660 cff2=real(grid%q2(i,j),dp)*cff1/ &
4661 & (real(grid%q2(i,j),dp)* &
4662 & (1.0_dp-0.622_dp)+0.622_dp)
4664 & exp((17.67_dp*(real(grid%t2(i,j),dp)- &
4666 & ((real(grid%t2(i,j),dp)-273.15_dp)+ &
4670 myfmin(1)=min(myfmin(1),fval)
4671 myfmax(1)=max(myfmax(1),fval)
4714 CASE (
'nflx',
'shflux')
4722 fval=(real(grid%swdnb_mean(i,j),dp)- &
4723 REAL(grid%swupb_mean(i,j),dp))+ &
4724 & (REAL(grid%glw_mean(i,j),dp)- &
4725 & REAL(grid%lwupb_mean(i,j),dp))- &
4726 & REAL(grid%lh_mean (i,j),dp)- &
4727 & REAL(grid%hfx_mean(i,j),dp)
4729 fval=(real(grid%swdnb(i,j),dp)- &
4730 & real(grid%swupb(i,j),dp))+ &
4731 & (real(grid%glw(i,j),dp)- &
4732 & real(grid%lwupb(i,j),dp))- &
4733 & real(grid%lh (i,j),dp)- &
4734 & real(grid%hfx(i,j),dp)
4736# ifdef ONLY_OCEAN_FLUXES
4737 IF ((int(grid%landmask(i,j)).ne.landvalue))
THEN
4738 myfmin(1)=min(myfmin(1),fval)
4739 myfmax(1)=max(myfmax(1),fval)
4745 myfmin(1)=min(myfmin(1),fval)
4746 myfmax(1)=max(myfmax(1),fval)
4755 CASE (
'lwrd',
'LWrad')
4761 fval=real(grid%glw_mean(i,j),dp)- &
4762 & real(grid%lwupb_mean(i,j),dp)
4764 fval=real(grid%glw(i,j),dp)- &
4765 & real(grid%lwupb(i,j),dp)
4767 myfmin(1)=min(myfmin(1),fval)
4768 myfmax(1)=max(myfmax(1),fval)
4775 CASE (
'dlwrd',
'dLWrad',
'lwrad_down')
4781 fval=real(grid%glw_mean(i,j),dp)
4783 fval=real(grid%glw(i,j),dp)
4785 myfmin(1)=min(myfmin(1),fval)
4786 myfmax(1)=max(myfmax(1),fval)
4794 CASE (
'swrd',
'SWrad')
4800 fval=real(grid%swdnb_mean(i,j),dp)- &
4801 & real(grid%swupb_mean(i,j),dp)
4803 fval=real(grid%swdnb(i,j),dp)- &
4804 & real(grid%swupb(i,j),dp)
4806 myfmin(1)=min(myfmin(1),fval)
4807 myfmax(1)=max(myfmax(1),fval)
4814 CASE (
'dswrd',
'dSWrad')
4820 fval=real(grid%swdnb_mean(i,j),dp)
4822 fval=real(grid%swdnb(i,j),dp)
4824 myfmin(1)=min(myfmin(1),fval)
4825 myfmax(1)=max(myfmax(1),fval)
4832 CASE (
'lhfx',
'LHfx')
4843 fval=scale*real(grid%lh_mean(i,j),dp)
4845 fval=scale*real(grid%lh(i,j),dp)
4847 myfmin(1)=min(myfmin(1),fval)
4848 myfmax(1)=max(myfmax(1),fval)
4855 CASE (
'shfx',
'SHfx')
4866 fval=scale*real(grid%hfx_mean(i,j),dp)
4868 fval=scale*real(grid%hfx(i,j),dp)
4870 myfmin(1)=min(myfmin(1),fval)
4871 myfmax(1)=max(myfmax(1),fval)
4883 fval=real(grid%qfx(i,j),dp)- &
4884 & (real(grid%raincv(i,j),dp)+ &
4885 & real(grid%rainncv(i,j),dp))/real(grid%dt,dp)
4886 myfmin(1)=min(myfmin(1),fval)
4887 myfmax(1)=max(myfmax(1),fval)
4899 fval=(real(grid%raincv(i,j),dp)+ &
4900 & real(grid%rainncv(i,j),dp))/real(grid%dt,dp)
4901 myfmin(1)=min(myfmin(1),fval)
4902 myfmax(1)=max(myfmax(1),fval)
4915 fval=real(grid%qfx(i,j),dp)
4916 myfmin(1)=min(myfmin(1),fval)
4917 myfmax(1)=max(myfmax(1),fval)
4929 fval=real(grid%cldfra(i,1,j),dp)
4930 myfmin(1)=min(myfmin(1),fval)
4931 myfmax(1)=max(myfmax(1),fval)
4942 CASE (
'taux',
'taux10',
'sustr')
4947 cff1=1.0_dp/(real(grid%alt(i,1,j),dp)+eps)
4950 & (real(grid%u_2(i ,1,j ),dp)+ &
4951 & real(grid%u_2(i+1,1,j ),dp)))**2+ &
4953 & (real(grid%v_2(i ,1,j ),dp)+ &
4954 & real(grid%v_2(i ,1,j+1),dp)))**2)+ &
4956 cff3=0.5_dp*((real(grid%u_2(i ,1,j ),dp)+ &
4957 & real(grid%u_2(i+1,1,j ),dp))* &
4958 & real(grid%cosa(i,j),dp)- &
4959 & (real(grid%v_2(i ,1,j ),dp)+ &
4960 & real(grid%v_2(i ,1,j+1),dp))* &
4961 & real(grid%sina(i,j),dp))
4962 fval=cff1*cff2*(real(grid%ust(i,j),dp)**2)*cff3
4963# ifdef ONLY_OCEAN_FLUXES
4964 IF ((int(grid%landmask(i,j)).ne.landvalue))
THEN
4965 myfmin(1)=min(myfmin(1),fval)
4966 myfmax(1)=max(myfmax(1),fval)
4972 myfmin(1)=min(myfmin(1),fval)
4973 myfmax(1)=max(myfmax(1),fval)
4981 CASE (
'tauy',
'tauy10',
'svstr')
4986 cff1=1.0_dp/(real(grid%alt(i,1,j),dp)+eps)
4989 & (real(grid%u_2(i ,1,j),dp)+ &
4990 & real(grid%u_2(i+1,1,j),dp)))**2+ &
4992 & (real(grid%v_2(i,1,j ),dp)+ &
4993 & real(grid%v_2(i,1,j+1),dp)))**2)+ &
4995 cff3=0.5_dp*((real(grid%v_2(i,1,j ),dp)+ &
4996 & real(grid%v_2(i,1,j+1),dp))* &
4997 & real(grid%cosa(i,j),dp)+ &
4998 & (real(grid%u_2(i ,1,j),dp)+ &
4999 & real(grid%u_2(i+1,1,j),dp))* &
5000 & real(grid%sina(i,j),dp))
5001 fval=cff1*cff2*(real(grid%ust(i,j),dp)**2)*cff3
5002# ifdef ONLY_OCEAN_FLUXES
5003 IF ((int(grid%landmask(i,j)).ne.landvalue))
THEN
5004 myfmin(1)=min(myfmin(1),fval)
5005 myfmax(1)=max(myfmax(1),fval)
5011 myfmin(1)=min(myfmin(1),fval)
5012 myfmax(1)=max(myfmax(1),fval)
5025 fval=1.0_dp/(real(grid%alt(i,1,j),dp)+eps)
5026 myfmin(1)=min(myfmin(1),fval)
5027 myfmax(1)=max(myfmax(1),fval)
5035 CASE (
'Uwind_sbl',
'u_2')
5040 fval=0.5_dp*((real(grid%u_2(i ,1,j ),dp)+ &
5041 & real(grid%u_2(i+1,1,j ),dp))* &
5042 & real(grid%cosa(i,j),dp)- &
5043 & (real(grid%v_2(i ,1,j ),dp)+ &
5044 & real(grid%v_2(i ,1,j+1),dp))* &
5045 & real(grid%sina(i,j),dp))
5046 myfmin(1)=min(myfmin(1),fval)
5047 myfmax(1)=max(myfmax(1),fval)
5055 CASE (
'Vwind_sbl',
'v_2')
5060 fval=0.5_dp*((real(grid%v_2(i,1,j ),dp)+ &
5061 & real(grid%v_2(i,1,j+1),dp))* &
5062 & real(grid%cosa(i,j),dp)+ &
5063 & (real(grid%u_2(i ,1,j),dp)+ &
5064 & real(grid%u_2(i+1,1,j),dp))* &
5065 & real(grid%sina(i,j),dp))
5066 myfmin(1)=min(myfmin(1),fval)
5067 myfmax(1)=max(myfmax(1),fval)
5075 CASE (
'Uwind',
'u10',
'wndu')
5081 fval=real(grid%u10_mean(i,j),dp)* &
5082 & real(grid%cosa(i,j),dp)- &
5083 & real(grid%v10_mean(i,j),dp)* &
5084 & real(grid%sina(i,j),dp)
5086 fval=real(grid%u10(i,j),dp)* &
5087 & real(grid%cosa(i,j),dp)- &
5088 & real(grid%v10(i,j),dp)* &
5089 & real(grid%sina(i,j),dp)
5091 myfmin(1)=min(myfmin(1),fval)
5092 myfmax(1)=max(myfmax(1),fval)
5100 CASE (
'Vwind',
'v10',
'wndv')
5106 fval=real(grid%v10_mean(i,j),dp)* &
5107 & real(grid%cosa(i,j),dp)+ &
5108 & real(grid%u10_mean(i,j),dp)* &
5109 & real(grid%sina(i,j),dp)
5111 fval=real(grid%v10(i,j),dp)* &
5112 & real(grid%cosa(i,j),dp)+ &
5113 & real(grid%u10(i,j),dp)* &
5114 & real(grid%sina(i,j),dp)
5116 myfmin(1)=min(myfmin(1),fval)
5117 myfmax(1)=max(myfmax(1),fval)
5130 fval=real(grid%ust(i,j),dp)
5131# ifdef ONLY_OCEAN_FLUXES
5132 IF ((int(grid%landmask(i,j)).ne.landvalue))
THEN
5133 myfmin(1)=min(myfmin(1),fval)
5134 myfmax(1)=max(myfmax(1),fval)
5140 myfmin(1)=min(myfmin(1),fval)
5141 myfmax(1)=max(myfmax(1),fval)
5150 IF (localpet.eq.0)
THEN
5151 WRITE (
cplout,30) trim(adjustl(exportnamelist(ifld))), &
5154 rc=esmf_rc_not_found
5155 IF (esmf_logfounderror(rctocheck=rc, &
5156 & msg=esmf_logerr_passthru, &
5158 & file=myfile))
THEN
5166 IF (
associated(ptr2d))
nullify (ptr2d)
5171 CALL esmf_vmallreduce (vm, &
5172 & senddata=myfmin, &
5175 & reduceflag=esmf_reduce_min, &
5177 IF (esmf_logfounderror(rctocheck=rc, &
5178 & msg=esmf_logerr_passthru, &
5180 & file=myfile))
THEN
5184 CALL esmf_vmallreduce (vm, &
5185 & senddata=myfmax, &
5188 & reduceflag=esmf_reduce_max, &
5190 IF (esmf_logfounderror(rctocheck=rc, &
5191 & msg=esmf_logerr_passthru, &
5193 & file=myfile))
THEN
5199 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
5200 WRITE (
cplout,40) trim(exportnamelist(ifld)), &
5201 & trim(time_currentstring), ng, &
5209 WRITE (ofile,50) ng, trim(exportnamelist(ifld)), &
5210 & year, month, day, hour, minutes, seconds
5211 CALL esmf_fieldwrite (field, &
5213 & overwrite=.true., &
5215 IF (esmf_logfounderror(rctocheck=rc, &
5216 & msg=esmf_logerr_passthru, &
5218 & file=myfile))
THEN
5226 IF (
allocated(exportnamelist))
deallocate(exportnamelist)
5230 IF (exportcount.gt.0)
THEN
5235 WRITE (
trac,
'(a,a,i0)')
'<== Exiting WRF_Export', &
5242 10
FORMAT (/,5x,
'WRF_Export - illegal configuration: ',a, &
5243 & /,18x,a,
' CPP option requires ''mean_diag = 1'' in ', &
5244 &
'input ''namelist''',/,18x,
'for time-averaged fluxes.')
5245 20
FORMAT (/,5x,
'WRF_Export - inconsistent input parameters:', &
5246 & /,18x,a,1x,i0,/,18x,a,
': TimeStep = ',i0)
5248 30
FORMAT (/,5x,
'WRF_Export - unable to find option to export: ', &
5249 & a,/,18x,
'check ''Export(atmos)'' in input script: ',a)
5250 40
FORMAT (5x,
'WRF_Export - ESMF: exporting field ''',a,
'''', &
5251 & t72,a,2x,
'Grid ',i2.2,/, &
5252 & 19x,
'(OutMin = ', 1p,e15.8,0p,
' OutMax = ',1p,e15.8,0p, &
5254 50
FORMAT (
'wrf_',i2.2,
'_export_',a,
'_',i4.4,2(
'-',i2.2),
'_', &
5255 & i2.2,2(
'.',i2.2),
'.nc')