126 integer,
intent(out) :: rc
128 TYPE (esmf_gridcomp) :: model
132 character (len=*),
parameter :: myfile = &
133 & __FILE__//
", ATM_SetServices"
140 WRITE (
trac,
'(a,a,i0)')
'==> Entering ATM_SetServices', &
150 CALL nuopc_compderive (model, &
151 & nuopc_setservices, &
153 IF (esmf_logfounderror(rctocheck=rc, &
154 & msg=esmf_logerr_passthru, &
166 CALL nuopc_compsetentrypoint (model, &
167 & methodflag=esmf_method_initialize, &
168 & phaselabellist=(/
"IPDv00p1"/), &
169 & userroutine=regcm_initializep1, &
171 IF (esmf_logfounderror(rctocheck=rc, &
172 & msg=esmf_logerr_passthru, &
180 CALL nuopc_compsetentrypoint (model, &
181 & methodflag=esmf_method_initialize, &
182 & phaselabellist=(/
"IPDv00p2"/), &
183 & userroutine=regcm_initializep2, &
185 IF (esmf_logfounderror(rctocheck=rc, &
186 & msg=esmf_logerr_passthru, &
198 CALL nuopc_compspecialize (model, &
199 & speclabel=nuopc_label_datainitialize, &
202 IF (esmf_logfounderror(rctocheck=rc, &
203 & msg=esmf_logerr_passthru, &
211 CALL nuopc_compspecialize (model, &
212 & speclabel=nuopc_label_setclock, &
215 IF (esmf_logfounderror(rctocheck=rc, &
216 & msg=esmf_logerr_passthru, &
222# ifdef ESM_SETRUNCLOCK
227 CALL esmf_methodremove (model, &
228 & nuopc_label_setrunclock, &
230 IF (esmf_logfounderror(rctocheck=rc, &
231 & msg=esmf_logerr_passthru, &
237 CALL nuopc_compspecialize (model, &
238 & speclabel=nuopc_label_setrunclock, &
241 IF (esmf_logfounderror(rctocheck=rc, &
242 & msg=esmf_logerr_passthru, &
251 CALL nuopc_compspecialize (model, &
252 & speclabel=nuopc_label_checkimport, &
253 & specphaselabel=
"RunPhase1", &
256 IF (esmf_logfounderror(rctocheck=rc, &
257 & msg=esmf_logerr_passthru, &
265 CALL nuopc_compspecialize (model, &
266 & speclabel=nuopc_label_advance, &
269 IF (esmf_logfounderror(rctocheck=rc, &
270 & msg=esmf_logerr_passthru, &
280 CALL esmf_gridcompsetentrypoint (model, &
281 & methodflag=esmf_method_finalize, &
284 IF (esmf_logfounderror(rctocheck=rc, &
285 & msg=esmf_logerr_passthru, &
292 WRITE (
trac,
'(a,a,i0)')
'<== Exiting RegCM_SetServices', &
709 USE mod_dynparam ,
ONLY : calendar
710 USE mod_runparams,
ONLY : idate0, idate1, idate2, dtsec
711 USE mod_date,
ONLY : split_idate
715 integer,
intent(out) :: rc
717 TYPE (esmf_gridcomp) :: model
722 integer :: ref_year, start_year, stop_year
723 integer :: ref_month, start_month, stop_month
724 integer :: ref_day, start_day, stop_day
725 integer :: ref_hour, start_hour, stop_hour
726 integer :: ref_minute, start_minute, stop_minute
727 integer :: ref_second, start_second, stop_second
730 character (len= 20) :: calendar
731 character (len=160) :: message
733 character (len=*),
parameter :: myfile = &
734 & __FILE__//
", RegCM_SetClock"
736 TYPE (esmf_calkind_flag) :: caltype
737 TYPE (esmf_time) :: starttime
744 WRITE (
trac,
'(a,a,i0)')
'==> Entering RegCM_SetClock', &
755 IF (trim(calendar).eq.
'gregorian')
THEN
756 caltype=esmf_calkind_gregorian
757 ELSE IF ((calendar.eq.
'noleap').or.(calendar.eq.
'365_day'))
THEN
758 caltype=esmf_calkind_noleap
759 ELSE IF (calendar.eq.
'360_day')
THEN
760 caltype=esmf_calkind_360day
762 caltype=esmf_calkind_gregorian
766 & name=trim(calendar), &
768 IF (esmf_logfounderror(rctocheck=rc, &
769 & msg=esmf_logerr_passthru, &
777 CALL split_idate (idate0, ref_year, ref_month, ref_day, ref_hour)
790 IF (esmf_logfounderror(rctocheck=rc, &
791 & msg=esmf_logerr_passthru, &
799 CALL split_idate (idate1, start_year, start_month, start_day, &
813 IF (esmf_logfounderror(rctocheck=rc, &
814 & msg=esmf_logerr_passthru, &
822 CALL split_idate (idate2, stop_year, stop_month, stop_day, &
836 IF (esmf_logfounderror(rctocheck=rc, &
837 & msg=esmf_logerr_passthru, &
847 CALL esmf_gridcompget (model, &
850 IF (esmf_logfounderror(rctocheck=rc, &
851 & msg=esmf_logerr_passthru, &
861 IF (esmf_logfounderror(rctocheck=rc, &
862 & msg=esmf_logerr_passthru, &
880 & options=
"string", &
882 IF (esmf_logfounderror(rctocheck=rc, &
883 & msg=esmf_logerr_passthru, &
889 CALL esmf_timeprint (starttime, &
890 & options=
"string", &
892 IF (esmf_logfounderror(rctocheck=rc, &
893 & msg=esmf_logerr_passthru, &
899 message=
'Driver and RegCM start times do not match: '// &
900 &
'please check the config files.'
901 CALL esmf_logseterror (esmf_failure, rctoreturn=rc, &
909 & options=
"string", &
911 IF (esmf_logfounderror(rctocheck=rc, &
912 & msg=esmf_logerr_passthru, &
919 & options=
"string", &
921 IF (esmf_logfounderror(rctocheck=rc, &
922 & msg=esmf_logerr_passthru, &
928 message=
'Driver and RegCM stop times do not match: '// &
929 &
'please check the config files.'
930 CALL esmf_logseterror (esmf_failure, rctoreturn=rc, &
938 & options=
"calkindflag", &
940 IF (esmf_logfounderror(rctocheck=rc, &
941 & msg=esmf_logerr_passthru, &
948 & options=
"calkindflag", &
950 IF (esmf_logfounderror(rctocheck=rc, &
951 & msg=esmf_logerr_passthru, &
957 message=
'Driver and RegCM calendars do not match: '// &
958 &
'please check the config files.'
959 CALL esmf_logseterror (esmf_failure, rctoreturn=rc, &
971 timefrac=max(timefrac, &
973 & mask=
models(:)%IsActive))
976 IF (timefrac.lt.1)
THEN
978 IF (esmf_logfounderror(rctocheck=rc, &
979 & msg=esmf_logerr_passthru, &
995 IF (esmf_logfounderror(rctocheck=rc, &
996 & msg=esmf_logerr_passthru, &
1003 WRITE (
trac,
'(a,a,i0)')
'<== Exiting RegCM_SetClock', &
1118 integer,
intent(out) :: rc
1120 TYPE (esmf_gridcomp) :: model
1124 logical :: isvalid, atcorrecttime
1126 integer :: importcount, i, is, localpet, ng
1128 real (dp) :: tcurrentinseconds
1130 character (len=22) :: drivertimestring, fieldtimestring
1132 character (len=*),
parameter :: myfile = &
1133 & __FILE__//
", RegCM_CheckImport"
1135 character (ESMF_MAXSTR) :: string, fieldname
1136 character (ESMF_MAXSTR),
allocatable :: importnamelist(:)
1138 TYPE (esmf_clock) :: driverclock
1139 TYPE (esmf_field) :: field
1140 TYPE (esmf_time) :: starttime, currenttime
1141 TYPE (esmf_time) :: drivertime, fieldtime
1142 TYPE (esmf_timeinterval) ::
timestep
1143 TYPE (esmf_vm) :: vm
1150 WRITE (
trac,
'(a,a,i0)')
'==> Entering RegCM_CheckImport', &
1160 CALL nuopc_modelget (model, &
1161 & driverclock=driverclock, &
1163 IF (esmf_logfounderror(rctocheck=rc, &
1164 & msg=esmf_logerr_passthru, &
1166 & file=myfile))
THEN
1170 CALL esmf_gridcompget (model, &
1171 & localpet=localpet, &
1174 IF (esmf_logfounderror(rctocheck=rc, &
1175 & msg=esmf_logerr_passthru, &
1177 & file=myfile))
THEN
1185 CALL esmf_clockget (driverclock, &
1187 & starttime=starttime, &
1188 & currtime=drivertime, &
1190 IF (esmf_logfounderror(rctocheck=rc, &
1191 & msg=esmf_logerr_passthru, &
1193 & file=myfile))
THEN
1197 CALL esmf_timeget (drivertime, &
1198 & s_r8=tcurrentinseconds, &
1199 & timestringisofrac=drivertimestring, &
1201 IF (esmf_logfounderror(rctocheck=rc, &
1202 & msg=esmf_logerr_passthru, &
1204 & file=myfile))
THEN
1207 is=index(drivertimestring,
'T')
1208 IF (is.gt.0) drivertimestring(is:is)=
' '
1218 & itemcount=importcount, &
1220 IF (esmf_logfounderror(rctocheck=rc, &
1221 & msg=esmf_logerr_passthru, &
1223 & file=myfile))
THEN
1227 IF (.not.
allocated(importnamelist))
THEN
1228 allocate ( importnamelist(importcount) )
1232 & itemnamelist=importnamelist, &
1234 IF (esmf_logfounderror(rctocheck=rc, &
1235 & msg=esmf_logerr_passthru, &
1237 & file=myfile))
THEN
1245 field_loop :
DO i=1,importcount
1246 fieldname=trim(importnamelist(i))
1248 & itemname=trim(fieldname), &
1251 IF (esmf_logfounderror(rctocheck=rc, &
1252 & msg=esmf_logerr_passthru, &
1254 & file=myfile))
THEN
1261 CALL nuopc_gettimestamp (field, &
1262 & isvalid = isvalid, &
1263 & time = fieldtime, &
1265 IF (esmf_logfounderror(rctocheck=rc, &
1266 & msg=esmf_logerr_passthru, &
1268 & file=myfile))
THEN
1273 CALL esmf_timeget (fieldtime, &
1274 & timestringisofrac = fieldtimestring, &
1276 IF (esmf_logfounderror(rctocheck=rc, &
1277 & msg=esmf_logerr_passthru, &
1279 & file=myfile))
THEN
1282 is=index(fieldtimestring,
'T')
1283 IF (is.gt.0) fieldtimestring(is:is)=
' '
1285 IF (localpet.eq.0)
THEN
1286 WRITE (
cplout,10) trim(fieldname), &
1287 & trim(fieldtimestring), &
1288 & trim(drivertimestring)
1295 string=
'COAMPS_CheckImport - '//trim(fieldname)//
' field'
1296 currenttime=drivertime
1298 atcorrecttime=nuopc_isattime(field, &
1301 IF (esmf_logfounderror(rctocheck=rc, &
1302 & msg=esmf_logerr_passthru, &
1304 & file=myfile))
THEN
1308 IF (.not.atcorrecttime)
THEN
1310 & localpet, trim(string), rc)
1312 string=
'NUOPC INCOMPATIBILITY DETECTED: Import '// &
1313 &
'Fields not at correct time'
1314 CALL esmf_logseterror(esmf_rc_not_valid, &
1315 & msg=trim(string), &
1322 IF (
allocated(importnamelist))
deallocate (importnamelist)
1328 WRITE (
trac,
'(a,a,i0)')
'<== Exiting RegCM_CheckImport', &
1333 10
FORMAT (1x,
'RegCM_CheckImport - ',a,
':',t32,
'TimeStamp = ',a, &
1334 &
', DriverTime = ',a)
1348 USE mod_mppparam,
ONLY : ma
1349 USE mod_runparams,
ONLY : dxsq
1350 USE mod_atm_interface,
ONLY : mddom
1351 USE mod_dynparam,
ONLY : iy, jx, nproc, &
1352 & ide1, ide2, jde1, jde2, &
1353 & idi1, idi2, jdi1, jdi2, &
1354 & ice1, ice2, jce1, jce2
1358 integer,
intent(in) :: ng
1359 integer,
intent(out) :: rc
1361 TYPE (esmf_gridcomp),
intent(inout) :: model
1365 integer :: gtype, i, ivar, j
1366 integer :: localde, localdecount, localpet, petcount
1367 integer :: cpus_per_dim(2)
1369 integer (i4b),
pointer :: ptrm(:,:) => null()
1371 real (dp),
pointer :: ptra(:,:) => null()
1372 real (dp),
pointer :: ptrx(:,:) => null()
1373 real (dp),
pointer :: ptry(:,:) => null()
1375 character (len=40) :: name
1377 character (len=*),
parameter :: myfile = &
1378 & __FILE__//
", RegCM_SetGridArrays"
1380 TYPE (esmf_distgrid) :: distgrid
1381 TYPE (esmf_staggerloc) :: staggerloc
1382 TYPE (esmf_vm) :: vm
1389 WRITE (
trac,
'(a,a,i0)')
'==> Entering RegCM_SetGridArrays', &
1400 CALL esmf_gridcompget (model, &
1401 & localpet=localpet, &
1402 & petcount=petcount, &
1405 IF (esmf_logfounderror(rctocheck=rc, &
1406 & msg=esmf_logerr_passthru, &
1408 & file=myfile))
THEN
1416 IF (nproc.lt.4)
THEN
1418 cpus_per_dim(1)=nproc
1419 ELSE IF (nproc.ge.4)
THEN
1420 cpus_per_dim(2)=(nint(sqrt(dble(nproc)))/2)*2
1421 IF (iy.gt.int(1.5*dble(jx)))
THEN
1422 cpus_per_dim(2)=cpus_per_dim(2)-1
1423 DO WHILE (mod(nproc,cpus_per_dim(2)).ne.0)
1424 cpus_per_dim(2)=cpus_per_dim(2)-1
1426 ELSE IF (jx.gt.int(1.5*dble(iy)))
THEN
1427 cpus_per_dim(2)=cpus_per_dim(2)+1
1428 DO WHILE (mod(nproc,cpus_per_dim(2)).ne.0)
1429 cpus_per_dim(2)=cpus_per_dim(2)+1
1432 DO WHILE (mod(nproc,cpus_per_dim(2)).ne.0)
1433 cpus_per_dim(2)=cpus_per_dim(2)+1
1436 cpus_per_dim(1)=nproc/cpus_per_dim(2)
1448 distgrid=esmf_distgridcreate(minindex=(/ 1, 1 /), &
1449 & maxindex=(/ iy, jx /), &
1450 & regdecomp=cpus_per_dim, &
1452 IF (esmf_logfounderror(rctocheck=rc, &
1453 & msg=esmf_logerr_passthru, &
1455 & file=myfile))
THEN
1473 models(
iatmos)%grid(ng)=esmf_gridcreate(distgrid=distgrid, &
1474 & indexflag=esmf_index_global, &
1477 IF (esmf_logfounderror(rctocheck=rc, &
1478 & msg=esmf_logerr_passthru, &
1480 & file=myfile))
THEN
1489 & localdecount=localdecount, &
1491 IF (esmf_logfounderror(rctocheck=rc, &
1492 & msg=esmf_logerr_passthru, &
1494 & file=myfile))
THEN
1500 mesh_loop :
DO ivar=1,ubound(
models(
iatmos)%mesh, dim=1)
1506 staggerloc=esmf_staggerloc_center
1508 staggerloc=esmf_staggerloc_corner
1515 & staggerloc=staggerloc, &
1517 IF (esmf_logfounderror(rctocheck=rc, &
1518 & msg=esmf_logerr_passthru, &
1520 & file=myfile))
THEN
1527 & staggerloc=staggerloc, &
1528 & itemflag=esmf_griditem_mask, &
1530 IF (esmf_logfounderror(rctocheck=rc, &
1531 & msg=esmf_logerr_passthru, &
1533 & file=myfile))
THEN
1546 & staggerloc=staggerloc, &
1547 & itemflag=esmf_griditem_area, &
1549 IF (esmf_logfounderror(rctocheck=rc, &
1550 & msg=esmf_logerr_passthru, &
1552 & file=myfile))
THEN
1559 de_loop :
DO localde=0,localdecount-1
1562 & staggerloc=staggerloc, &
1563 & localde=localde, &
1566 IF (esmf_logfounderror(rctocheck=rc, &
1567 & msg=esmf_logerr_passthru, &
1569 & file=myfile))
THEN
1575 & staggerloc=staggerloc, &
1576 & localde=localde, &
1579 IF (esmf_logfounderror(rctocheck=rc, &
1580 & msg=esmf_logerr_passthru, &
1582 & file=myfile))
THEN
1587 & itemflag=esmf_griditem_mask, &
1588 & staggerloc=staggerloc, &
1589 & localde=localde, &
1592 IF (esmf_logfounderror(rctocheck=rc, &
1593 & msg=esmf_logerr_passthru, &
1595 & file=myfile))
THEN
1600 & itemflag=esmf_griditem_area, &
1601 & staggerloc=staggerloc, &
1602 & localde=localde, &
1605 IF (esmf_logfounderror(rctocheck=rc, &
1606 & msg=esmf_logerr_passthru, &
1608 & file=myfile))
THEN
1618 ptrx(i,j)=mddom%dlon(j,i)
1619 ptry(i,j)=mddom%dlat(j,i)
1624 IF (ma%has_bdyright)
THEN
1625 ptrx(:,jde2+1)=ptrx(:,jde2)+ &
1626 & (ptrx(:,jde2)-ptrx(:,jde2-1))
1627 ptry(:,jde2+1)=ptry(:,jde2)+ &
1628 & (ptry(:,jde2)-ptry(:,jde2-1))
1631 IF (ma%has_bdytop)
THEN
1632 ptrx(ide2+1,:)=ptrx(ide2,:)+ &
1633 & (ptrx(ide2,:)-ptrx(ide2-1,:))
1634 ptry(ide2+1,:)=ptry(ide2,:)+ &
1635 & (ptry(ide2,:)-ptry(ide2-1,:))
1640 ptrx(i,j)=mddom%xlon(j,i)
1641 ptry(i,j)=mddom%xlat(j,i)
1642 ptrm(i,j)=int(mddom%mask(j,i))
1647 IF (ma%has_bdyright)
THEN
1648 ptrx(:,jce2+1)=ptrx(:,jce2)+ &
1649 & (ptrx(:,jce2)-ptrx(:,jce2-1))
1650 ptry(:,jce2+1)=ptry(:,jce2)+ &
1651 & (ptry(:,jce2)-ptry(:,jce2-1))
1654 IF (ma%has_bdytop)
THEN
1655 ptrx(ice2+1,:)=ptrx(ice2,:)+ &
1656 & (ptrx(ice2,:)-ptrx(ice2-1,:))
1657 ptry(ice2+1,:)=ptry(ice2,:)+ &
1658 & (ptry(ice2,:)-ptry(ice2-1,:))
1664 IF (
associated(ptrx) )
nullify (ptrx)
1665 IF (
associated(ptry) )
nullify (ptry)
1666 IF (
associated(ptrm) )
nullify (ptrm)
1667 IF (
associated(ptra) )
nullify (ptra)
1675 & filename=
"regcm_"// &
1678 & staggerloc=staggerloc, &
1680 IF (esmf_logfounderror(rctocheck=rc, &
1681 & msg=esmf_logerr_passthru, &
1683 & file=myfile))
THEN
1691 CALL esmf_gridcompset (model, &
1694 IF (esmf_logfounderror(rctocheck=rc, &
1695 & msg=esmf_logerr_passthru, &
1697 & file=myfile))
THEN
1702 WRITE (
trac,
'(a,a,i0)')
'<== Exiting RegCM_SetGridArrays', &
1721 integer,
intent(in) :: ng
1722 integer,
intent(out) :: rc
1724 TYPE (esmf_gridcomp) :: model
1729 integer :: localde, localdecount
1730 integer :: localpet, petcount
1731 integer :: exportcount, importcount
1733 real (dp),
dimension(:,:),
pointer :: ptr2d => null()
1735 character (len=*),
parameter :: myfile = &
1736 & __FILE__//
", RegCM_SetStates"
1738 character (ESMF_MAXSTR),
allocatable :: exportnamelist(:)
1739 character (ESMF_MAXSTR),
allocatable :: importnamelist(:)
1741 TYPE (esmf_arrayspec) :: arrayspec2d
1742 TYPE (esmf_field) :: field
1743 TYPE (esmf_staggerloc) :: staggerloc
1744 TYPE (esmf_vm) :: vm
1751 WRITE (
trac,
'(a,a,i0)')
'==> Entering RegCM_SetStates', &
1763 CALL esmf_gridcompget (model, &
1764 & localpet=localpet, &
1765 & petcount=petcount, &
1768 IF (esmf_logfounderror(rctocheck=rc, &
1769 & msg=esmf_logerr_passthru, &
1771 & file=myfile))
THEN
1780 & localdecount=localdecount, &
1782 IF (esmf_logfounderror(rctocheck=rc, &
1783 & msg=esmf_logerr_passthru, &
1785 & file=myfile))
THEN
1793 CALL esmf_arrayspecset (arrayspec2d, &
1794 & typekind=esmf_typekind_r8, &
1797 IF (esmf_logfounderror(rctocheck=rc, &
1798 & msg=esmf_logerr_passthru, &
1800 & file=myfile))
THEN
1813 & itemcount=exportcount, &
1815 IF (esmf_logfounderror(rctocheck=rc, &
1816 & msg=esmf_logerr_passthru, &
1818 & file=myfile))
THEN
1824 IF (.not.
allocated(exportnamelist))
THEN
1825 allocate ( exportnamelist(exportcount) )
1828 & itemnamelist=exportnamelist, &
1830 IF (esmf_logfounderror(rctocheck=rc, &
1831 & msg=esmf_logerr_passthru, &
1833 & file=myfile))
THEN
1842 IF (nuopc_isconnected(
models(
iatmos)%ExportState(ng), &
1843 & fieldname=trim(exportnamelist(i)), &
1850 staggerloc=esmf_staggerloc_center
1852 staggerloc=esmf_staggerloc_corner
1859 & staggerloc=staggerloc, &
1860 & name=trim(exportnamelist(i)), &
1862 IF (esmf_logfounderror(rctocheck=rc, &
1863 & msg=esmf_logerr_passthru, &
1865 & file=myfile))
THEN
1872 DO localde=0,localdecount-1
1876 CALL esmf_fieldget (field, &
1877 & localde=localde, &
1878 & farrayptr=ptr2d, &
1880 IF (esmf_logfounderror(rctocheck=rc, &
1881 & msg=esmf_logerr_passthru, &
1883 & file=myfile))
THEN
1894 IF (
associated(ptr2d) )
nullify (ptr2d)
1902 IF (esmf_logfounderror(rctocheck=rc, &
1903 & msg=esmf_logerr_passthru, &
1905 & file=myfile))
THEN
1912 IF (localpet.eq.0)
THEN
1913 WRITE (
cplout,10) trim(exportnamelist(i)), &
1914 &
'Export State: ', &
1917 CALL esmf_stateremove (
models(
iatmos)%ExportState(ng), &
1918 & (/ trim(exportnamelist(i)) /), &
1920 IF (esmf_logfounderror(rctocheck=rc, &
1921 & msg=esmf_logerr_passthru, &
1923 & file=myfile))
THEN
1931 IF (
allocated(exportnamelist) )
deallocate (exportnamelist)
1944 & itemcount=importcount, &
1946 IF (esmf_logfounderror(rctocheck=rc, &
1947 & msg=esmf_logerr_passthru, &
1949 & file=myfile))
THEN
1955 IF (.not.
allocated(importnamelist))
THEN
1956 allocate (importnamelist(importcount))
1959 & itemnamelist=importnamelist, &
1961 IF (esmf_logfounderror(rctocheck=rc, &
1962 & msg=esmf_logerr_passthru, &
1964 & file=myfile))
THEN
1973 IF (nuopc_isconnected(
models(
iatmos)%ImportState(ng), &
1974 & fieldname=trim(importnamelist(i)), &
1981 staggerloc=esmf_staggerloc_center
1983 staggerloc=esmf_staggerloc_corner
1990 & staggerloc=staggerloc, &
1991 & name=trim(importnamelist(i)), &
1993 IF (esmf_logfounderror(rctocheck=rc, &
1994 & msg=esmf_logerr_passthru, &
1996 & file=myfile))
THEN
2003 DO localde=0,localdecount-1
2007 CALL esmf_fieldget (field, &
2008 & localde=localde, &
2009 & farrayptr=ptr2d, &
2011 IF (esmf_logfounderror(rctocheck=rc, &
2012 & msg=esmf_logerr_passthru, &
2014 & file=myfile))
THEN
2025 IF (
associated(ptr2d))
nullify (ptr2d)
2033 IF (esmf_logfounderror(rctocheck=rc, &
2034 & msg=esmf_logerr_passthru, &
2036 & file=myfile))
THEN
2043 IF (localpet.eq.0)
THEN
2044 WRITE (
cplout,10) trim(importnamelist(i)), &
2045 &
'Import State: ', &
2048 CALL esmf_stateremove (
models(
iatmos)%ImportState(ng), &
2049 & (/ trim(importnamelist(i)) /), &
2051 IF (esmf_logfounderror(rctocheck=rc, &
2052 & msg=esmf_logerr_passthru, &
2054 & file=myfile))
THEN
2062 IF (
allocated(importnamelist))
deallocate (importnamelist)
2067 WRITE (
trac,
'(a,a,i0)')
'<== Exiting RegCM_SetStates', &
2073 10
FORMAT (
'RegCM_SetStates - Removing field ''',a,
''' from ',a, &
2074 &
'''',a,
'''',/,18x,
'because it is not connected.')
2089 USE mod_runparams,
ONLY : ifrest, ktau, dtsrf
2093 integer,
intent(out) :: rc
2095 TYPE (esmf_gridcomp) :: model
2100 integer :: localpet, petcount, phase
2102 real (dp) :: tstr, tend
2104 character (len=*),
parameter :: myfile = &
2105 & __FILE__//
", RegCM_SetModelAdvance"
2107 character (ESMF_MAXSTR) :: str1, str2
2109 TYPE (esmf_clock) :: clock
2110 TYPE (esmf_state) :: exportstate, importstate
2111 TYPE (esmf_timeinterval) :: timefrom, timeto,
timestep
2112 TYPE (esmf_time) :: referencetime
2113 TYPE (esmf_time) :: currenttime, starttime, stoptime
2114 TYPE (esmf_vm) :: vm
2121 WRITE (
trac,
'(a,a,i0)')
'==> Entering RegCM_ModelAdvance', &
2133 CALL esmf_gridcompget (model, &
2134 & importstate=importstate, &
2135 & exportstate=exportstate, &
2137 & localpet=localpet, &
2138 & petcount=petcount, &
2139 & currentphase=phase, &
2142 IF (esmf_logfounderror(rctocheck=rc, &
2143 & msg=esmf_logerr_passthru, &
2145 & file=myfile))
THEN
2152 CALL esmf_clockget (clock, &
2154 & starttime=starttime, &
2155 & stoptime=stoptime, &
2156 & reftime=referencetime, &
2159 IF (esmf_logfounderror(rctocheck=rc, &
2160 & msg=esmf_logerr_passthru, &
2162 & file=myfile))
THEN
2176 CALL esmf_timeintervalget (timefrom, &
2179 IF (esmf_logfounderror(rctocheck=rc, &
2180 & msg=esmf_logerr_passthru, &
2182 & file=myfile))
THEN
2187 CALL esmf_timeintervalget (timeto, &
2190 IF (esmf_logfounderror(rctocheck=rc, &
2191 & msg=esmf_logerr_passthru, &
2193 & file=myfile))
THEN
2198 & (starttime.eq.currenttime))
THEN
2206 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
2210 CALL esmf_timeget (currenttime, &
2211 & timestringisofrac=str1, &
2213 IF (esmf_logfounderror(rctocheck=rc, &
2214 & msg=esmf_logerr_passthru, &
2216 & file=myfile))
THEN
2222 CALL esmf_timeget (currenttime+
timestep, &
2223 & timestringisofrac=str2, &
2225 IF (esmf_logfounderror(rctocheck=rc, &
2226 & msg=esmf_logerr_passthru, &
2228 & file=myfile))
THEN
2233 WRITE (
cplout,10) trim(str1), trim(str2), phase
2235 WRITE (
cplout,20) trim(str1), trim(str2), phase, tstr, tend
2243 IF ((currenttime.ne.reftime).or.restarted)
THEN
2248 IF (esmf_logfounderror(rctocheck=rc, &
2249 & msg=esmf_logerr_passthru, &
2251 & file=myfile))
THEN
2265 CALL regcm_run (tstr, tend)
2275 IF (esmf_logfounderror(rctocheck=rc, &
2276 & msg=esmf_logerr_passthru, &
2278 & file=myfile))
THEN
2286 WRITE (
trac,
'(a,a,i0)')
'<== Exiting RegCM_ModelAdvance', &
2291 10
FORMAT (
' Running RegCM Component: ',a,
' --> ',a,
' Phase: ',i1)
2292 20
FORMAT (
' Running RegCM Component: ',a,
' --> ',a,
' Phase: ',i1, &
2293 &
' [',f15.2,
'-', f15.2,
']')
2358 USE mod_update,
ONLY : importfields
2359 USE mod_dynparam,
ONLY : ici1, ici2, jci1, jci2
2363 integer,
intent(in) :: ng
2364 integer,
intent(out) :: rc
2366 TYPE (esmf_gridcomp) :: model
2370 integer :: id, ifld, i, is, j
2371 integer :: year, month, day, hour, minutes, seconds, sn, sd
2372 integer :: importcount
2373 integer :: localde, localdecount, localpet, petcount
2374 integer :: lbi, ubi, lbj, ubj
2375 integer :: iminp, imaxp, jminp, jmaxp
2377 real (dp) :: fseconds, timeindays, time_current
2379 real (dp) :: myfmax(2), myfmin(2), fmin(2), fmax(2), fval
2380 real (dp) :: scale, add_offset
2382 real (dp),
pointer :: ptr2d(:,:) => null()
2384 character (len=22 ) :: time_currentstring
2385 character (len=100) :: fieldname
2387 character (len=*),
parameter :: myfile = &
2388 & __FILE__//
", RegCM_Import"
2390 character (ESMF_MAXSTR) :: cname, ofile
2391 character (ESMF_MAXSTR),
allocatable :: importnamelist(:)
2393 TYPE (esmf_clock) :: clock
2394 TYPE (esmf_field) :: field
2395 TYPE (esmf_state) :: importstate
2396 TYPE (esmf_time) :: currenttime
2397 TYPE (esmf_vm) :: vm
2404 WRITE (
trac,
'(a,a,i0)')
'==> Entering RegCM_Import', &
2424 CALL esmf_gridcompget (model, &
2425 & importstate=importstate, &
2427 & localpet=localpet, &
2428 & petcount=petcount, &
2432 IF (esmf_logfounderror(rctocheck=rc, &
2433 & msg=esmf_logerr_passthru, &
2435 & file=myfile))
THEN
2444 & localdecount=localdecount, &
2446 IF (esmf_logfounderror(rctocheck=rc, &
2447 & msg=esmf_logerr_passthru, &
2449 & file=myfile))
THEN
2457 CALL esmf_clockget (clock, &
2458 & currtime=currenttime, &
2460 IF (esmf_logfounderror(rctocheck=rc, &
2461 & msg=esmf_logerr_passthru, &
2463 & file=myfile))
THEN
2467 CALL esmf_timeget (currenttime, &
2477 IF (esmf_logfounderror(rctocheck=rc, &
2478 & msg=esmf_logerr_passthru, &
2480 & file=myfile))
THEN
2484 CALL esmf_timeget (currenttime, &
2485 & s_r8=time_current, &
2486 & timestring=time_currentstring, &
2488 IF (esmf_logfounderror(rctocheck=rc, &
2489 & msg=esmf_logerr_passthru, &
2491 & file=myfile))
THEN
2494 fseconds=real(seconds,dp)+real(sn,dp)/real(sd,dp)
2495 timeindays=time_current/86400.0_dp
2496 is=index(time_currentstring,
'T')
2497 IF (is.gt.0) time_currentstring(is:is)=
' '
2504 & itemcount=importcount, &
2506 IF (esmf_logfounderror(rctocheck=rc, &
2507 & msg=esmf_logerr_passthru, &
2509 & file=myfile))
THEN
2513 IF (.not.
allocated(importnamelist))
THEN
2514 allocate ( importnamelist(importcount) )
2517 & itemnamelist=importnamelist, &
2519 IF (esmf_logfounderror(rctocheck=rc, &
2520 & msg=esmf_logerr_passthru, &
2522 & file=myfile))
THEN
2530 fld_loop :
DO ifld=1,importcount
2536 & trim(importnamelist(ifld)), &
2539 IF (esmf_logfounderror(rctocheck=rc, &
2540 & msg=esmf_logerr_passthru, &
2542 & file=myfile))
THEN
2549 de_loop :
DO localde=0,localdecount-1
2550 CALL esmf_fieldget (field, &
2551 & localde=localde, &
2552 & farrayptr=ptr2d, &
2554 IF (esmf_logfounderror(rctocheck=rc, &
2555 & msg=esmf_logerr_passthru, &
2557 & file=myfile))
THEN
2571 fval=ptr2d(iminp,jminp)
2579 SELECT CASE (trim(adjustl(importnamelist(ifld))))
2584 fieldname=trim(importnamelist(ifld))
2587 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2588 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2589 fval=scale*ptr2d(i,j)+add_offset
2590 myfmin(2)=min(myfmin(2),fval)
2591 myfmax(2)=max(myfmax(2),fval)
2592 importfields%sst(j,i)=fval
2596# if defined SEA_ICE || defined OCNICE
2603 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2604 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2605 fval=scale*ptr2d(i,j)+add_offset
2606 myfmin(2)=min(myfmin(2),fval)
2607 myfmax(2)=max(myfmax(2),fval)
2608 importfields%sit(j,i)=fval
2618 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2619 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2620 fval=scale*ptr2d(i,j)+add_offset
2621 myfmin(2)=min(myfmin(2),fval)
2622 myfmax(2)=max(myfmax(2),fval)
2623 importfields%msk(j,i)=fval
2632 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2633 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2634 fval=scale*ptr2d(i,j)+add_offset
2635 myfmin(2)=min(myfmin(2),fval)
2636 myfmax(2)=max(myfmax(2),fval)
2637 importfields%zo(j,i)=fval
2646 myfmin(1)=min(myfmin(1),ptr2d(i,j))
2647 myfmax(1)=max(myfmax(1),ptr2d(i,j))
2648 fval=scale*ptr2d(i,j)+add_offset
2649 myfmin(2)=min(myfmin(2),fval)
2650 myfmax(2)=max(myfmax(2),fval)
2651 importfields%ustar(j,i)=fval
2658 IF (localpet.eq.0)
THEN
2659 WRITE (
cplout,10) trim(importnamelist(ifld)), &
2662 rc=esmf_rc_not_found
2663 IF (esmf_logfounderror(rctocheck=rc, &
2664 & msg=esmf_logerr_passthru, &
2666 & file=myfile))
THEN
2674 IF (
associated(ptr2d))
nullify (ptr2d)
2679 CALL esmf_vmallreduce (vm, &
2680 & senddata=myfmin, &
2683 & reduceflag=esmf_reduce_min, &
2685 IF (esmf_logfounderror(rctocheck=rc, &
2686 & msg=esmf_logerr_passthru, &
2688 & file=myfile))
THEN
2692 CALL esmf_vmallreduce (vm, &
2693 & senddata=myfmax, &
2696 & reduceflag=esmf_reduce_max, &
2698 IF (esmf_logfounderror(rctocheck=rc, &
2699 & msg=esmf_logerr_passthru, &
2701 & file=myfile))
THEN
2707 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
2708 WRITE (
cplout,20) trim(importnamelist(ifld)), &
2709 & trim(time_currentstring), ng, &
2711 IF (scale.ne.1.0_dp)
THEN
2712 WRITE (
cplout,30) fmin(2), fmax(2), &
2713 &
' regcmScale = ', scale
2714 ELSE IF (add_offset.ne.0.0_dp)
THEN
2715 WRITE (
cplout,30) fmin(2), fmax(2), &
2716 &
' AddOffset = ', add_offset
2724 WRITE (ofile,40) ng, trim(importnamelist(ifld)), &
2725 & year, month, day, hour, minutes, seconds
2726 CALL esmf_fieldwrite (field, &
2728 & overwrite=.true., &
2730 IF (esmf_logfounderror(rctocheck=rc, &
2731 & msg=esmf_logerr_passthru, &
2733 & file=myfile))
THEN
2741 IF (
allocated(importnamelist))
deallocate (importnamelist)
2745 IF (importcount.gt.0)
THEN
2750 WRITE (
trac,
'(a,a,i0)')
'<== Exiting RegCM_Import', &
2756 10
FORMAT (/,2x,
'RegCM_Import - unable to find option to import: ', &
2757 & a,/,18x,
'check ''Import(atmos)'' in input script: ', a)
2758 20
FORMAT (2x,
'RegCM_Import - ESMF: importing field ''',a,
'''', &
2759 & t72,a,2x,
'Grid ',i2.2,/, &
2760 & 19x,
'(Dmin = ', 1p,e15.8,0p,
' Dmax = ',1p,e15.8,0p,
')')
2761 30
FORMAT (19x,
'(Cmin = ', 1p,e15.8,0p,
' Cmax = ',1p,e15.8,0p, &
2762 & a,1p,e15.8,0p,
')')
2763 40
FORMAT (
'regcm_',i2.2,
'_import_',a,
'_',i4.4,2(
'-',i2.2),
'_', &
2764 & i2.2,2(
'.',i2.2),
'.nc')
2777 USE mod_update,
ONLY : exportfields
2778 USE mod_dynparam,
ONLY : ici1, ici2, jci1, jci2
2782 integer,
intent(in) :: ng
2783 integer,
intent(out) :: rc
2785 TYPE (esmf_gridcomp) :: model
2789 integer :: ifld, i, is, j
2790 integer :: istr, iend, jstr, jend
2791 integer :: year, month, day, hour, minutes, seconds, sn, sd
2792 integer :: exportcount
2793 integer :: localde, localdecount, localpet, petcount
2795 real (dp),
parameter :: pi = 3.14159265358979323846_dp
2796 real (dp) :: fseconds, timeindays, time_current
2798 real (dp) :: myfmax(1), myfmin(1), fmin(1), fmax(1), fval
2800 real (dp),
pointer :: ptr2d(:,:) => null()
2802 character (len=22) :: time_currentstring
2804 character (len=*),
parameter :: myfile = &
2805 & __FILE__//
", RegCM_Export"
2807 character (ESMF_MAXSTR) :: cname, ofile
2808 character (ESMF_MAXSTR),
allocatable :: exportnamelist(:)
2810 TYPE (esmf_clock) :: clock
2811 TYPE (esmf_field) :: field
2812 TYPE (esmf_time) :: currenttime
2813 TYPE (esmf_vm) :: vm
2820 WRITE (
trac,
'(a,a,i0)')
'==> Entering RegCM_Export', &
2830 CALL esmf_gridcompget (model, &
2832 & localpet=localpet, &
2833 & petcount=petcount, &
2837 IF (esmf_logfounderror(rctocheck=rc, &
2838 & msg=esmf_logerr_passthru, &
2840 & file=myfile))
THEN
2849 & localdecount=localdecount, &
2851 IF (esmf_logfounderror(rctocheck=rc, &
2852 & msg=esmf_logerr_passthru, &
2854 & file=myfile))
THEN
2862 CALL esmf_clockget (clock, &
2863 & currtime=currenttime, &
2865 IF (esmf_logfounderror(rctocheck=rc, &
2866 & msg=esmf_logerr_passthru, &
2868 & file=myfile))
THEN
2872 CALL esmf_timeget (currenttime, &
2882 IF (esmf_logfounderror(rctocheck=rc, &
2883 & msg=esmf_logerr_passthru, &
2885 & file=myfile))
THEN
2889 CALL esmf_timeget (currenttime, &
2890 & s_r8=time_current, &
2891 & timestring=time_currentstring, &
2893 IF (esmf_logfounderror(rctocheck=rc, &
2894 & msg=esmf_logerr_passthru, &
2896 & file=myfile))
THEN
2899 fseconds=real(seconds,dp)+real(sn,dp)/real(sd,dp)
2900 timeindays=time_current/86400.0_dp
2901 is=index(time_currentstring,
'T')
2902 IF (is.gt.0) time_currentstring(is:is)=
' '
2909 & itemcount=exportcount, &
2911 IF (esmf_logfounderror(rctocheck=rc, &
2912 & msg=esmf_logerr_passthru, &
2914 & file=myfile))
THEN
2918 IF (.not.
allocated(exportnamelist))
THEN
2919 allocate ( exportnamelist(exportcount) )
2922 & itemnamelist=exportnamelist, &
2924 IF (esmf_logfounderror(rctocheck=rc, &
2925 & msg=esmf_logerr_passthru, &
2927 & file=myfile))
THEN
2936 CALL regcm_uvrot (exportfields%wndu, exportfields%wndv)
2937 CALL regcm_uvrot (exportfields%taux, exportfields%tauy)
2943 fld_loop :
DO ifld=1,exportcount
2948 & trim(exportnamelist(ifld)), &
2951 IF (esmf_logfounderror(rctocheck=rc, &
2952 & msg=esmf_logerr_passthru, &
2954 & file=myfile))
THEN
2961 de_loop :
DO localde=0,localdecount-1
2962 CALL esmf_fieldget (field, &
2963 & localde=localde, &
2964 & farrayptr=ptr2d, &
2966 IF (esmf_logfounderror(rctocheck=rc, &
2967 & msg=esmf_logerr_passthru, &
2969 & file=myfile))
THEN
2986 SELECT CASE (trim(adjustl(exportnamelist(ifld))))
2990 CASE (
'psfc',
'Pair')
2991 fval=exportfields%psfc(jstr,istr)
2996 fval=exportfields%psfc(j,i)
2997 myfmin(1)=min(myfmin(1),fval)
2998 myfmax(1)=max(myfmax(1),fval)
3005 CASE (
'tsfc',
'Tair')
3006 fval=exportfields%tsfc(jstr,istr)
3011 fval=exportfields%tsfc(j,i)
3012 myfmin(1)=min(myfmin(1),fval)
3013 myfmax(1)=max(myfmax(1),fval)
3020 CASE (
'qsfc',
'Hair')
3021 fval=exportfields%qsfc(jstr,istr)
3026 fval=exportfields%qsfc(j,i)
3027 myfmin(1)=min(myfmin(1),fval)
3028 myfmax(1)=max(myfmax(1),fval)
3035 CASE (
'lwrd',
'LWrad')
3036 fval=exportfields%lwrd(jstr,istr)
3041 fval=exportfields%lwrd(j,i)
3042 myfmin(1)=min(myfmin(1),fval)
3043 myfmax(1)=max(myfmax(1),fval)
3050 CASE (
'dlwrd',
'dLWrad',
'lwrad_down')
3051 fval=exportfields%dlwr(jstr,istr)
3056 fval=exportfields%dlwr(j,i)
3057 myfmin(1)=min(myfmin(1),fval)
3058 myfmax(1)=max(myfmax(1),fval)
3065 CASE (
'lhfx',
'LHfx')
3066 fval=exportfields%lhfx(jstr,istr)
3071 fval=exportfields%lhfx(j,i)
3072 myfmin(1)=min(myfmin(1),fval)
3073 myfmax(1)=max(myfmax(1),fval)
3081 fval=exportfields%shfx(jstr,istr)
3086 fval=exportfields%shfx(j,i)
3087 myfmin(1)=min(myfmin(1),fval)
3088 myfmax(1)=max(myfmax(1),fval)
3096 fval=exportfields%prec(jstr,istr)
3101 fval=exportfields%prec(j,i)
3102 myfmin(1)=min(myfmin(1),fval)
3103 myfmax(1)=max(myfmax(1),fval)
3110 CASE (
'Uwind',
'u10',
'wndu')
3111 fval=exportfields%wndu(jstr,istr)
3116 fval=exportfields%wndu(j,i)
3117 myfmin(1)=min(myfmin(1),fval)
3118 myfmax(1)=max(myfmax(1),fval)
3126 fval=exportfields%wndv(jstr,istr)
3131 fval=exportfields%wndv(j,i)
3132 myfmin(1)=min(myfmin(1),fval)
3133 myfmax(1)=max(myfmax(1),fval)
3141 fval=exportfields%swrd(jstr,istr)
3146 fval=exportfields%swrd(j,i)
3147 myfmin(1)=min(myfmin(1),fval)
3148 myfmax(1)=max(myfmax(1),fval)
3156 fval=exportfields%dswr(jstr,istr)
3161 fval=exportfields%dswr(j,i)
3162 myfmin(1)=min(myfmin(1),fval)
3163 myfmax(1)=max(myfmax(1),fval)
3171 fval=exportfields%rnof(jstr,istr)
3176 fval=exportfields%rnof(j,i)
3177 myfmin(1)=min(myfmin(1),fval)
3178 myfmax(1)=max(myfmax(1),fval)
3186 fval=exportfields%snof(jstr,istr)
3191 fval=exportfields%snof(j,i)
3192 myfmin(1)=min(myfmin(1),fval)
3193 myfmax(1)=max(myfmax(1),fval)
3201 fval=exportfields%taux(jstr,istr)
3206 fval=exportfields%taux(j,i)
3207 myfmin(1)=min(myfmin(1),fval)
3208 myfmax(1)=max(myfmax(1),fval)
3216 fval=exportfields%tauy(jstr,istr)
3221 fval=exportfields%tauy(j,i)
3222 myfmin(1)=min(myfmin(1),fval)
3223 myfmax(1)=max(myfmax(1),fval)
3231 fval=exportfields%wspd(jstr,istr)
3236 fval=exportfields%wspd(j,i)
3237 myfmin(1)=min(myfmin(1),fval)
3238 myfmax(1)=max(myfmax(1),fval)
3246 fval=atan2(exportfields%wndu(jstr,istr), &
3247 & exportfields%wndv(jstr,istr))
3252 fval=atan2(exportfields%wndu(j,i), &
3253 & exportfields%wndv(j,i))
3254 IF (dd.lt.0.0_r8) fval=fval+2.0_r8*pi
3255 myfmin(1)=min(myfmin(1),fval)
3256 myfmax(1)=max(myfmax(1),fval)
3264 fval=exportfields%nflx(jstr,istr)
3269 fval=exportfields%nflx(j,i)
3270 myfmin(1)=min(myfmin(1),fval)
3271 myfmax(1)=max(myfmax(1),fval)
3279 fval=exportfields%sflx(jstr,istr)
3284 fval=exportfields%sflx(j,i)
3285 myfmin(1)=min(myfmin(1),fval)
3286 myfmax(1)=max(myfmax(1),fval)
3294 fval=exportfields%snow(jstr,istr)
3299 fval=exportfields%snow(j,i)
3300 myfmin(1)=min(myfmin(1),fval)
3301 myfmax(1)=max(myfmax(1),fval)
3309 IF (localpet.eq.0)
THEN
3310 WRITE (
cplout,10) trim(adjustl(exportnamelist(ifld))), &
3313 rc=esmf_rc_not_found
3314 IF (esmf_logfounderror(rctocheck=rc, &
3315 & msg=esmf_logerr_passthru, &
3317 & file=myfile))
THEN
3325 IF (
associated(ptr2d))
nullify (ptr2d)
3330 CALL esmf_vmallreduce (vm, &
3331 & senddata=myfmin, &
3334 & reduceflag=esmf_reduce_min, &
3336 IF (esmf_logfounderror(rctocheck=rc, &
3337 & msg=esmf_logerr_passthru, &
3339 & file=myfile))
THEN
3343 CALL esmf_vmallreduce (vm, &
3344 & senddata=myfmax, &
3347 & reduceflag=esmf_reduce_max, &
3349 IF (esmf_logfounderror(rctocheck=rc, &
3350 & msg=esmf_logerr_passthru, &
3352 & file=myfile))
THEN
3358 IF ((
debuglevel.ge.0).and.(localpet.eq.0))
THEN
3359 WRITE (
cplout,20) trim(exportnamelist(ifld)), &
3360 & trim(time_currentstring), ng, &
3368 WRITE (ofile,30) ng, trim(exportnamelist(ifld)), &
3369 & year, month, day, hour, minutes, seconds
3370 CALL esmf_fieldwrite (field, &
3372 & overwrite=.true., &
3374 IF (esmf_logfounderror(rctocheck=rc, &
3375 & msg=esmf_logerr_passthru, &
3377 & file=myfile))
THEN
3385 IF (
allocated(exportnamelist))
deallocate(exportnamelist)
3389 IF (exportcount.gt.0)
THEN
3394 WRITE (
trac,
'(a,a,i0)')
'<== Exiting RegCM_Export', &
3400 10
FORMAT (/,2x,
'RegCM_Export - unable to find option to export: ', &
3401 & a,/,18x,
'check ''Export(atmos)'' in input script: ',a)
3402 20
FORMAT (2x,
'RegCM_Export - ESMF: exporting field ''',a,
'''', &
3403 & t72,a,2x,
'Grid ',i2.2,/, &
3404 & 19x,
'(Cmin = ', 1p,e15.8,0p,
' Cmax = ',1p,e15.8,0p,
')')
3405 30
FORMAT (
'regcm',i2.2,
'_export_',a,
'_',i4.4,2(
'-',i2.2),
'_', &
3406 & i2.2,2(
'.',i2.2),
'.nc')
3420 USE mod_constants,
ONLY : degrad
3421 USE mod_atm_interface,
ONLY : mddom
3422 USE mod_dynparam,
ONLY : iproj
3423 USE mod_dynparam,
ONLY : clon, clat, plon, plat, xcone
3424 USE mod_dynparam,
ONLY : ici1, ici2, jci1, jci2
3428 real (r8),
intent(inout) :: u(jci1:jci2,ici1:ici2)
3429 real (r8),
intent(inout) :: v(jci1:jci2,ici1:ici2)
3435 real (r8) :: x, xs, xc, d, us, vs, sindel, cosdel
3436 real (r8) :: pollam, polphi, polcphi, polsphi
3437 real (r8) :: zarg1, zarg2, znorm, zphi, zrla, zrlap
3439 character (len=*),
parameter :: myfile = &
3440 & __FILE__//
", RegCM_uvrot"
3447 WRITE (
trac,
'(a,a,i0)')
'==> Entering RegCM_uvrot', &
3454 IF ((iproj.eq.
'ROTMER').or.(iproj.eq.
'NORMER'))
THEN
3455 IF (plat.gt.0.0_r8)
THEN
3456 pollam=plon+180.0_r8
3462 IF (pollam.gt.180.0_r8) pollam=pollam-360.0_r8
3464 polcphi=dcos(degrad*polphi)
3465 polsphi=dsin(degrad*polphi)
3469 zphi=mddom%dlat(j,i)*degrad
3470 zrla=mddom%dlon(j,i)*degrad
3471 IF (mddom%dlat(j,i).gt.89.999999_r8) zrla=0.0_r8
3472 zrlap=pollam*degrad-zrla
3473 zarg1=polcphi*dsin(zrlap)
3474 zarg2=polsphi*cos(zphi)-polcphi*sin(zphi)*dcos(zrlap)
3475 znorm=1.0_r8/sqrt(zarg1**2+zarg2**2)
3479 us= u(j,i)*cosdel+v(j,i)*sindel
3480 vs=-u(j,i)*sindel+v(j,i)*cosdel
3491 IF (((clon.ge.0.0_r8).and.(mddom%xlon(j,i).ge.0.0_r8)).or. &
3492 & ((clon.lt.0.0_r8).and.(mddom%xlon(j,i).lt.0.0_r8)))
THEN
3493 x=(clon-mddom%xlon(j,i))*degrad*xcone
3495 IF (clon.ge.0.0_r8)
THEN
3496 IF (abs(clon-(mddom%xlon(j,i)+360.0_r8)).lt. &
3497 & abs(clon-mddom%xlon(j,i)))
THEN
3498 x=(clon-(mddom%xlon(j,i)+360.0d0))*degrad*xcone
3500 x=(clon-mddom%xlon(j,i))*degrad*xcone
3503 IF (abs(clon-(mddom%xlon(j,i)-360.0_r8)).lt. &
3504 & abs(clon-mddom%xlon(j,i)))
THEN
3505 x=(clon-(mddom%xlon(j,i)-360.0_r8))*degrad*xcone
3507 x=(clon-mddom%xlon(j,i))*degrad*xcone
3515 IF (clat.ge.0.0_r8)
THEN
3516 d=u(j,i)*xc-v(j,i)*xs
3517 v(j,i)=u(j,i)*xs+v(j,i)*xc
3520 d=u(j,i)*xc+v(j,i)*xs
3521 v(j,i)=v(j,i)*xc-u(j,i)*xs
3529 WRITE (
trac,
'(a,a,i0)')
'<== Exiting RegCM_uvrot', &