1051
1052
1054
1055
1056
1057 integer, intent(in) :: ng, tile
1058 integer, intent(in) :: LBi, UBi, LBj, UBj
1059
1060
1061
1062 logical :: Cgrid
1063
1064 integer :: NposB, NposR, NposW
1065 integer :: Fcount, i, ifield, k, np, status
1066
1067 real(dp) :: scale
1068
1069 real(r8), dimension(Nstation(ng)) :: Xpos, Ypos, Zpos, psta
1070# ifdef SOLVE3D
1071# ifdef SEDIMENT
1072 real(r8), dimension(Nstation(ng)*Nbed) :: XposB, YposB, ZposB
1073 real(r8), dimension(Nstation(ng)*Nbed) :: bsta
1074# endif
1075 real(r8), dimension(Nstation(ng)*(N(ng))) :: XposR, YposR, ZposR
1076 real(r8), dimension(Nstation(ng)*(N(ng)+1)) :: XposW, YposW, ZposW
1077 real(r8), dimension(Nstation(ng)*(N(ng)+1)) :: rsta
1078# endif
1079
1080 real(r8), allocatable :: Ur2d(:,:)
1081 real(r8), allocatable :: Vr2d(:,:)
1082# ifdef SOLVE3D
1083 real(r8), allocatable :: Ur3d(:,:,:)
1084 real(r8), allocatable :: Vr3d(:,:,:)
1085# endif
1086
1087 character (len=*), parameter :: MyFile = &
1088 & __FILE__//", wrt_station_pio"
1089
1090 sourcefile=myfile
1091
1092
1093
1094
1095
1096 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1097
1098
1099
1100 sta(ng)%Rindex=sta(ng)%Rindex+1
1101 fcount=sta(ng)%Fcount
1102 sta(ng)%Nrec(fcount)=sta(ng)%Nrec(fcount)+1
1103
1104
1105
1106
1107# ifdef STATIONS_CGRID
1108 cgrid=.true.
1109# else
1110 cgrid=.false.
1111# endif
1112
1113
1114
1115 nposb=nstation(ng)*nbed
1116 nposr=nstation(ng)*n(ng)
1117 nposw=nstation(ng)*(n(ng)+1)
1118 DO i=1,nstation(ng)
1119 xpos(i)=scalars(ng)%SposX(i)
1120 ypos(i)=scalars(ng)%SposY(i)
1121 zpos(i)=1.0_r8
1122# ifdef SOLVE3D
1123 DO k=1,n(ng)
1124 np=k+(i-1)*n(ng)
1125 xposr(np)=scalars(ng)%SposX(i)
1126 yposr(np)=scalars(ng)%SposY(i)
1127 zposr(np)=real(k,r8)
1128 END DO
1129 DO k=0,n(ng)
1130 np=k+1+(i-1)*(n(ng)+1)
1131 xposw(np)=scalars(ng)%SposX(i)
1132 yposw(np)=scalars(ng)%SposY(i)
1133 zposw(np)=real(k,r8)
1134 END DO
1135# ifdef SEDIMENT
1136 DO k=1,nbed
1137 np=k+(i-1)*nbed
1138 xposb(np)=scalars(ng)%SposX(i)
1139 yposb(np)=scalars(ng)%SposY(i)
1140 zposb(np)=real(k,r8)
1141 END DO
1142# endif
1143# endif
1144 END DO
1145
1146
1147
1149 & trim(vname(1,idtime)), time(ng:), &
1150 & (/sta(ng)%Rindex/), (/1/), &
1151 & piofile = sta(ng)%pioFile, &
1152 & piovar = sta(ng)%pioVar(idtime)%vd)
1153 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1154
1155
1156
1157 IF (sout(idfsur,ng)) THEN
1158 scale=1.0_dp
1159 CALL extract_sta2d (ng, model, cgrid, idfsur, r2dvar, &
1160 & lbi, ubi, lbj, ubj, &
1161 & scale, ocean(ng)%zeta(:,:,kout), &
1162 & nstation(ng), xpos, ypos, psta)
1164 & trim(vname(1,idfsur)), psta, &
1165 & (/1,sta(ng)%Rindex/), &
1166 & (/nstation(ng),1/), &
1167 & piofile = sta(ng)%pioFile, &
1168 & piovar = sta(ng)%pioVar(idfsur)%vd)
1169 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1170 END IF
1171
1172
1173
1174
1175 IF (sout(idubar,ng)) THEN
1176 scale=1.0_dp
1177 CALL extract_sta2d (ng, model, cgrid, idubar, u2dvar, &
1178 & lbi, ubi, lbj, ubj, &
1179 & scale, ocean(ng)%ubar(:,:,kout), &
1180 & nstation(ng), xpos, ypos, psta)
1182 & trim(vname(1,idubar)), psta, &
1183 & (/1,sta(ng)%Rindex/), &
1184 & (/nstation(ng),1/), &
1185 & piofile = sta(ng)%pioFile, &
1186 & piovar = sta(ng)%pioVar(idubar)%vd)
1187 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1188 END IF
1189
1190
1191
1192 IF (sout(idvbar,ng)) THEN
1193 scale=1.0_dp
1194 CALL extract_sta2d (ng, model, cgrid, idvbar, v2dvar, &
1195 & lbi, ubi, lbj, ubj, &
1196 & scale, ocean(ng)%vbar(:,:,kout), &
1197 & nstation(ng), xpos, ypos, psta)
1199 & trim(vname(1,idvbar)), psta, &
1200 & (/1,sta(ng)%Rindex/), &
1201 & (/nstation(ng),1/), &
1202 & piofile = sta(ng)%pioFile, &
1203 & piovar = sta(ng)%pioVar(idvbar)%vd)
1204 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1205 END IF
1206
1207
1208
1209
1210 IF (sout(idu2de,ng).and.sout(idv2dn,ng)) THEN
1211 IF (.not.allocated(ur2d)) THEN
1212 allocate (ur2d(lbi:ubi,lbj:ubj))
1213 ur2d(lbi:ubi,lbj:ubj)=0.0_r8
1214 END IF
1215 IF (.not.allocated(vr2d)) THEN
1216 allocate (vr2d(lbi:ubi,lbj:ubj))
1217 vr2d(lbi:ubi,lbj:ubj)=0.0_r8
1218 END IF
1219 CALL uv_rotate2d (ng, tile, .false., .true., &
1220 & lbi, ubi, lbj, ubj, &
1221 & grid(ng) % CosAngler, &
1222 & grid(ng) % SinAngler, &
1223# ifdef MASKING
1224 & grid(ng) % rmask_full, &
1225# endif
1226 & ocean(ng) % ubar(:,:,kout), &
1227 & ocean(ng) % vbar(:,:,kout), &
1228 & ur2d, vr2d)
1229
1230 scale=1.0_dp
1231 CALL extract_sta2d (ng, model, cgrid, idu2de, r2dvar, &
1232 & lbi, ubi, lbj, ubj, &
1233 & scale, ur2d, &
1234 & nstation(ng), xpos, ypos, psta)
1236 & trim(vname(1,idu2de)), psta, &
1237 & (/1,sta(ng)%Rindex/), &
1238 & (/nstation(ng),1/), &
1239 & piofile = sta(ng)%pioFile, &
1240 & piovar = sta(ng)%pioVar(idu2de)%vd)
1241 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1242
1243 CALL extract_sta2d (ng, model, cgrid, idv2dn, r2dvar, &
1244 & lbi, ubi, lbj, ubj, &
1245 & scale, vr2d, &
1246 & nstation(ng), xpos, ypos, psta)
1248 & trim(vname(1,idv2dn)), psta, &
1249 & (/1,sta(ng)%Rindex/), &
1250 & (/nstation(ng),1/), &
1251 & piofile = sta(ng)%pioFile, &
1252 & piovar = sta(ng)%pioVar(idv2dn)%vd)
1253 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1254
1255 deallocate (ur2d)
1256 deallocate (vr2d)
1257 END IF
1258
1259# ifdef SOLVE3D
1260
1261
1262
1263 IF (sout(iduvel,ng)) THEN
1264 scale=1.0_dp
1265 CALL extract_sta3d (ng, model, cgrid, iduvel, u3dvar, &
1266 & lbi, ubi, lbj, ubj, 1, n(ng), &
1267 & scale, ocean(ng)%u(:,:,:,nout), &
1268 & nposr, xposr, yposr, zposr, rsta)
1270 & trim(vname(1,iduvel)), rsta, &
1271 & (/1,1,sta(ng)%Rindex/), &
1272 & (/n(ng),nstation(ng),1/), &
1273 & piofile = sta(ng)%pioFile, &
1274 & piovar = sta(ng)%pioVar(iduvel)%vd)
1275 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1276 END IF
1277
1278
1279
1280 IF (sout(idvvel,ng)) THEN
1281 scale=1.0_dp
1282 CALL extract_sta3d (ng, model, cgrid, idvvel, v3dvar, &
1283 & lbi, ubi, lbj, ubj, 1, n(ng), &
1284 & scale, ocean(ng)%v(:,:,:,nout), &
1285 & nposr, xposr, yposr, zposr, rsta)
1287 & trim(vname(1,idvvel)), rsta, &
1288 & (/1,1,sta(ng)%Rindex/), &
1289 & (/n(ng),nstation(ng),1/), &
1290 & piofile = sta(ng)%pioFile, &
1291 & piovar = sta(ng)%pioVar(idvvel)%vd)
1292 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1293 END IF
1294
1295
1296
1297
1298 IF (sout(idu3de,ng).and.sout(idv3dn,ng)) THEN
1299 IF (.not.allocated(ur3d)) THEN
1300 allocate (ur3d(lbi:ubi,lbj:ubj,n(ng)))
1301 ur3d(lbi:ubi,lbj:ubj,1:n(ng))=0.0_r8
1302 END IF
1303 IF (.not.allocated(vr3d)) THEN
1304 allocate (vr3d(lbi:ubi,lbj:ubj,n(ng)))
1305 vr3d(lbi:ubi,lbj:ubj,1:n(ng))=0.0_r8
1306 END IF
1307 CALL uv_rotate3d (ng, tile, .false., .true., &
1308 & lbi, ubi, lbj, ubj, 1, n(ng), &
1309 & grid(ng) % CosAngler, &
1310 & grid(ng) % SinAngler, &
1311# ifdef MASKING
1312 & grid(ng) % rmask_full, &
1313# endif
1314 & ocean(ng) % u(:,:,:,nout), &
1315 & ocean(ng) % v(:,:,:,nout), &
1316 & ur3d, vr3d)
1317
1318 scale=1.0_dp
1319 CALL extract_sta3d (ng, model, cgrid, idu3de, r3dvar, &
1320 & lbi, ubi, lbj, ubj, 1, n(ng), &
1321 & scale, ur3d, &
1322 & nposr, xposr, yposr, zposr, rsta)
1324 & trim(vname(1,idu3de)), rsta, &
1325 & (/1,1,sta(ng)%Rindex/), &
1326 & (/n(ng),nstation(ng),1/), &
1327 & piofile = sta(ng)%pioFile, &
1328 & piovar = sta(ng)%pioVar(idu3de)%vd)
1329 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1330
1331 CALL extract_sta3d (ng, model, cgrid, idv3dn, r3dvar, &
1332 & lbi, ubi, lbj, ubj, 1, n(ng), &
1333 & scale, vr3d, &
1334 & nposr, xposr, yposr, zposr, rsta)
1336 & trim(vname(1,idv3dn)), rsta, &
1337 & (/1,1,sta(ng)%Rindex/), &
1338 & (/n(ng),nstation(ng),1/), &
1339 & piofile = sta(ng)%pioFile, &
1340 & piovar = sta(ng)%pioVar(idv3dn)%vd)
1341 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1342
1343 deallocate (ur3d)
1344 deallocate (vr3d)
1345 END IF
1346
1347
1348
1349 IF (sout(idwvel,ng)) THEN
1350 scale=1.0_dp
1351 CALL extract_sta3d (ng, model, cgrid, idwvel, w3dvar, &
1352 & lbi, ubi, lbj, ubj, 0, n(ng), &
1353 & scale, ocean(ng)%wvel, &
1354 & nposw, xposw, yposw, zposw, rsta)
1356 & trim(vname(1,idwvel)), rsta, &
1357 & (/1,1,sta(ng)%Rindex/), &
1358 & (/n(ng)+1,nstation(ng),1/), &
1359 & piofile = sta(ng)%pioFile, &
1360 & piovar = sta(ng)%pioVar(idwvel)%vd)
1361 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1362 END IF
1363
1364
1365
1366 IF (sout(idovel,ng)) THEN
1367 scale=1.0_dp
1368 CALL extract_sta3d (ng, model, cgrid, idovel, w3dvar, &
1369 & lbi, ubi, lbj, ubj, 0, n(ng), &
1370 & scale, ocean(ng)%W, &
1371 & nposw, xposw, yposw, zposw, rsta)
1373 & trim(vname(1,idovel)), rsta, &
1374 & (/1,1,sta(ng)%Rindex/), &
1375 & (/n(ng)+1,nstation(ng),1/), &
1376 & piofile = sta(ng)%pioFile, &
1377 & piovar = sta(ng)%pioVar(idovel)%vd)
1378 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1379 END IF
1380
1381
1382
1383 DO i=1,nt(ng)
1384 ifield=idtvar(i)
1385 IF (sout(ifield,ng)) THEN
1386 scale=1.0_dp
1387 CALL extract_sta3d (ng, model, cgrid, ifield, r3dvar, &
1388 & lbi, ubi, lbj, ubj, 1, n(ng), &
1389 & scale, ocean(ng)%t(:,:,:,nout,i), &
1390 & nposr, xposr, yposr, zposr, rsta)
1392 & trim(vname(1,idtvar(i))), rsta, &
1393 & (/1,1,sta(ng)%Rindex/), &
1394 & (/n(ng),nstation(ng),1/), &
1395 & piofile = sta(ng)%pioFile, &
1396 & piovar = sta(ng)%pioTrc(i)%vd)
1397 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1398 END IF
1399 END DO
1400
1401
1402
1403 IF (sout(iddano,ng)) THEN
1404 scale=1.0_dp
1405 CALL extract_sta3d (ng, model, cgrid, iddano, r3dvar, &
1406 & lbi, ubi, lbj, ubj, 1, n(ng), &
1407 & scale, ocean(ng)%rho, &
1408 & nposr, xposr, yposr, zposr, rsta)
1410 & trim(vname(1,iddano)), rsta, &
1411 & (/1,1,sta(ng)%Rindex/), &
1412 & (/n(ng),nstation(ng),1/), &
1413 & piofile = sta(ng)%pioFile, &
1414 & piovar = sta(ng)%pioVar(iddano)%vd)
1415 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1416 END IF
1417
1418# ifdef LMD_SKPP
1419
1420
1421
1422 IF (sout(idhsbl,ng)) THEN
1423 scale=1.0_dp
1424 CALL extract_sta2d (ng, model, cgrid, idhsbl, r2dvar, &
1425 & lbi, ubi, lbj, ubj, &
1426 & scale, mixing(ng)%hsbl, &
1427 & nstation(ng), xpos, ypos, psta)
1429 & trim(vname(1,idhsbl)), psta, &
1430 & (/1,sta(ng)%Rindex/), &
1431 & (/nstation(ng),1/), &
1432 & piofile = sta(ng)%pioFile, &
1433 & piovar = sta(ng)%pioVar(idhsbl)%vd)
1434 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1435 END IF
1436# endif
1437# ifdef LMD_BKPP
1438
1439
1440
1441 IF (sout(idhbbl,ng)) THEN
1442 scale=1.0_dp
1443 CALL extract_sta2d (ng, model, cgrid, idhbbl, r2dvar, &
1444 & lbi, ubi, lbj, ubj, &
1445 & scale, mixing(ng)%hbbl, &
1446 & nstation(ng), xpos, ypos, psta)
1448 & trim(vname(1,idhbbl)), psta, &
1449 & (/1,sta(ng)%Rindex/), &
1450 & (/nstation(ng),1/), &
1451 & piofile = sta(ng)%pioFile, &
1452 & piovar = sta(ng)%pioVar(idhbbl)%vd)
1453 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1454 END IF
1455# endif
1456
1457
1458
1459 IF (sout(idvvis,ng)) THEN
1460 scale=1.0_dp
1461 CALL extract_sta3d (ng, model, cgrid, idvvis, w3dvar, &
1462 & lbi, ubi, lbj, ubj, 0, n(ng), &
1463 & scale, mixing(ng)%Akv, &
1464 & nposw, xposw, yposw, zposw, rsta)
1466 & trim(vname(1,idvvis)), rsta, &
1467 & (/1,1,sta(ng)%Rindex/), &
1468 & (/n(ng)+1,nstation(ng),1/), &
1469 & piofile = sta(ng)%pioFile, &
1470 & piovar = sta(ng)%pioVar(idvvis)%vd)
1471 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1472 END IF
1473
1474
1475
1476 IF (sout(idtdif,ng)) THEN
1477 scale=1.0_dp
1478 CALL extract_sta3d (ng, model, cgrid, idtdif, w3dvar, &
1479 & lbi, ubi, lbj, ubj, 0, n(ng), &
1480 & scale, mixing(ng)%Akt(:,:,:,itemp), &
1481 & nposw, xposw, yposw, zposw, rsta)
1483 & trim(vname(1,idtdif)), rsta, &
1484 & (/1,1,sta(ng)%Rindex/), &
1485 & (/n(ng)+1,nstation(ng),1/), &
1486 & piofile = sta(ng)%pioFile, &
1487 & piovar = sta(ng)%pioVar(idtdif)%vd)
1488 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1489 END IF
1490
1491# ifdef SALINITY
1492
1493
1494
1495 IF (sout(idsdif,ng)) THEN
1496 scale=1.0_dp
1497 CALL extract_sta3d (ng, model, cgrid, idsdif, w3dvar, &
1498 & lbi, ubi, lbj, ubj, 0, n(ng), &
1499 & scale, mixing(ng)%Akt(:,:,:,isalt), &
1500 & nposw, xposw, yposw, zposw, rsta)
1502 & trim(vname(1,idsdif)), rsta, &
1503 & (/1,1,sta(ng)%Rindex/), &
1504 & (/n(ng)+1,nstation(ng),1/), &
1505 & piofile = sta(ng)%pioFile, &
1506 & piovar = sta(ng)%pioVar(idsdif)%vd)
1507 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1508 END IF
1509# endif
1510# if defined GLS_MIXING || defined MY25_MIXING
1511
1512
1513
1514 IF (sout(idmtke,ng)) THEN
1515 scale=1.0_dp
1516 CALL extract_sta3d (ng, model, cgrid, idmtke, w3dvar, &
1517 & lbi, ubi, lbj, ubj, 0, n(ng), &
1518 & scale, mixing(ng)%tke(:,:,:,nout), &
1519 & nposw, xposw, yposw, zposw, rsta)
1521 & trim(vname(1,idmtke)), rsta, &
1522 & (/1,1,sta(ng)%Rindex/), &
1523 & (/n(ng)+1,nstation(ng),1/), &
1524 & piofile = sta(ng)%pioFile, &
1525 & piovar = sta(ng)%pioVar(idmtke)%vd)
1526 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1527 END IF
1528
1529
1530
1531 IF (sout(idmtls,ng)) THEN
1532 scale=1.0_dp
1533 CALL extract_sta3d (ng, model, cgrid, idmtls, w3dvar, &
1534 & lbi, ubi, lbj, ubj, 0, n(ng), &
1535 & scale, mixing(ng)%gls(:,:,:,nout), &
1536 & nposw, xposw, yposw, zposw, rsta)
1538 & trim(vname(1,idmtls)), rsta, &
1539 & (/1,1,sta(ng)%Rindex/), &
1540 & (/n(ng)+1,nstation(ng),1/), &
1541 & piofile = sta(ng)%pioFile, &
1542 & piovar = sta(ng)%pioVar(idmtls)%vd)
1543 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1544 END IF
1545# endif
1546# if defined BULK_FLUXES || defined ECOSIM || defined ATM_PRESS
1547
1548
1549
1550 IF (sout(idpair,ng)) THEN
1551 scale=1.0_dp
1552 CALL extract_sta2d (ng, model, cgrid, idpair, r2dvar, &
1553 & lbi, ubi, lbj, ubj, &
1554 & scale, forces(ng)%Pair, &
1555 & nstation(ng), xpos, ypos, psta)
1557 & trim(vname(1,idpair)), psta, &
1558 & (/1,sta(ng)%Rindex/), &
1559 & (/nstation(ng),1/), &
1560 & piofile = sta(ng)%pioFile, &
1561 & piovar = sta(ng)%pioVar(idpair)%vd)
1562 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1563 END IF
1564# endif
1565# if defined BULK_FLUXES || defined ECOSIM
1566
1567
1568
1569 IF (sout(iduair,ng)) THEN
1570 scale=1.0_dp
1571 CALL extract_sta2d (ng, model, cgrid, iduair, r2dvar, &
1572 & lbi, ubi, lbj, ubj, &
1573 & scale, forces(ng)%Uwind, &
1574 & nstation(ng), xpos, ypos, psta)
1576 & trim(vname(1,iduair)), psta, &
1577 & (/1,sta(ng)%Rindex/), &
1578 & (/nstation(ng),1/), &
1579 & piofile = sta(ng)%pioFile, &
1580 & piovar = sta(ng)%pioVar(iduair)%vd)
1581 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1582 END IF
1583
1584 IF (sout(idvair,ng)) THEN
1585 scale=1.0_dp
1586 CALL extract_sta2d (ng, model, cgrid, idvair, r2dvar, &
1587 & lbi, ubi, lbj, ubj, &
1588 & scale, forces(ng)%Vwind, &
1589 & nstation(ng), xpos, ypos, psta)
1591 & trim(vname(1,idvair)), psta, &
1592 & (/1,sta(ng)%Rindex/), &
1593 & (/nstation(ng),1/), &
1594 & piofile = sta(ng)%pioFile, &
1595 & piovar = sta(ng)%pioVar(idvair)%vd)
1596 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1597 END IF
1598
1599
1600
1601
1602 IF (sout(iduaie,ng).and.sout(idvain,ng)) THEN
1603 IF (.not.allocated(ur2d)) THEN
1604 allocate (ur2d(lbi:ubi,lbj:ubj))
1605 ur2d(lbi:ubi,lbj:ubj)=0.0_r8
1606 END IF
1607 IF (.not.allocated(vr2d)) THEN
1608 allocate (vr2d(lbi:ubi,lbj:ubj))
1609 vr2d(lbi:ubi,lbj:ubj)=0.0_r8
1610 END IF
1611 CALL uv_rotate2d (ng, tile, .false., .true., &
1612 & lbi, ubi, lbj, ubj, &
1613 & grid(ng) % CosAngler, &
1614 & grid(ng) % SinAngler, &
1615# ifdef MASKING
1616 & grid(ng) % rmask_full, &
1617# endif
1618 & forces(ng) % Uwind, &
1619 & forces(ng) % Vwind, &
1620 & ur2d, vr2d)
1621
1622 scale=1.0_dp
1623 CALL extract_sta2d (ng, model, cgrid, iduaie, r2dvar, &
1624 & lbi, ubi, lbj, ubj, &
1625 & scale, ur2d, &
1626 & nstation(ng), xpos, ypos, psta)
1628 & trim(vname(1,iduaie)), psta, &
1629 & (/1,sta(ng)%Rindex/), &
1630 & (/nstation(ng),1/), &
1631 & piofile = sta(ng)%pioFile, &
1632 & piovar = sta(ng)%pioVar(iduaie)%vd)
1633 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1634
1635 CALL extract_sta2d (ng, model, cgrid, idvain, r2dvar, &
1636 & lbi, ubi, lbj, ubj, &
1637 & scale, vr2d, &
1638 & nstation(ng), xpos, ypos, psta)
1640 & trim(vname(1,idvain)), psta, &
1641 & (/1,sta(ng)%Rindex/), &
1642 & (/nstation(ng),1/), &
1643 & piofile = sta(ng)%pioFile, &
1644 & piovar = sta(ng)%pioVar(idvain)%vd)
1645 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1646
1647 deallocate (ur2d)
1648 deallocate (vr2d)
1649 END IF
1650# endif
1651
1652
1653
1654 IF (sout(idtsur(itemp),ng)) THEN
1655 ifield=idtsur(itemp)
1656 scale=rho0*cp
1657 CALL extract_sta2d (ng, model, cgrid, ifield, r2dvar, &
1658 & lbi, ubi, lbj, ubj, &
1659 & scale, forces(ng)%stflx(:,:,itemp), &
1660 & nstation(ng), xpos, ypos, psta)
1662 & trim(vname(1,ifield)), psta, &
1663 & (/1,sta(ng)%Rindex/), &
1664 & (/nstation(ng),1/), &
1665 & piofile = sta(ng)%pioFile, &
1666 & piovar = sta(ng)%pioVar(ifield)%vd)
1667 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1668 END IF
1669
1670# ifdef SALINITY
1671
1672
1673
1674 IF (sout(idtsur(isalt),ng)) THEN
1675 ifield=idtsur(isalt)
1676 scale=1.0_dp
1677 CALL extract_sta2d (ng, model, cgrid, ifield, r2dvar, &
1678 & lbi, ubi, lbj, ubj, &
1679 & scale, forces(ng)%stflx(:,:,isalt), &
1680 & nstation(ng), xpos, ypos, psta)
1682 & trim(vname(1,ifield)), psta, &
1683 & (/1,sta(ng)%Rindex/), &
1684 & (/nstation(ng),1/), &
1685 & piofile = sta(ng)%pioFile, &
1686 & piovar = sta(ng)%pioVar(ifield)%vd)
1687 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1688 END IF
1689# endif
1690
1691# ifdef BULK_FLUXES
1692
1693
1694
1695 IF (sout(idlhea,ng)) THEN
1696 scale=rho0*cp
1697 CALL extract_sta2d (ng, model, cgrid, idlhea, r2dvar, &
1698 & lbi, ubi, lbj, ubj, &
1699 & scale, forces(ng)%lhflx, &
1700 & nstation(ng), xpos, ypos, psta)
1702 & trim(vname(1,idlhea)), psta, &
1703 & (/1,sta(ng)%Rindex/), &
1704 & (/nstation(ng),1/), &
1705 & piofile = sta(ng)%pioFile, &
1706 & piovar = sta(ng)%pioVar(idlhea)%vd)
1707 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1708 END IF
1709
1710
1711
1712 IF (sout(idshea,ng)) THEN
1713 scale=rho0*cp
1714 CALL extract_sta2d (ng, model, cgrid, idshea, r2dvar, &
1715 & lbi, ubi, lbj, ubj, &
1716 & scale, forces(ng)%shflx, &
1717 & nstation(ng), xpos, ypos, psta)
1719 & trim(vname(1,idshea)), psta, &
1720 & (/1,sta(ng)%Rindex/), &
1721 & (/nstation(ng),1/), &
1722 & piofile = sta(ng)%pioFile, &
1723 & piovar = sta(ng)%pioVar(idshea)%vd)
1724 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1725 END IF
1726
1727
1728
1729 IF (sout(idlrad,ng)) THEN
1730 scale=rho0*cp
1731 CALL extract_sta2d (ng, model, cgrid, idlrad, r2dvar, &
1732 & lbi, ubi, lbj, ubj, &
1733 & scale, forces(ng)%lrflx, &
1734 & nstation(ng), xpos, ypos, psta)
1736 & trim(vname(1,idlrad)), psta, &
1737 & (/1,sta(ng)%Rindex/), &
1738 & (/nstation(ng),1/), &
1739 & piofile = sta(ng)%pioFile, &
1740 & piovar = sta(ng)%pioVar(idlrad)%vd)
1741 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1742 END IF
1743
1744# endif
1745# ifdef SHORTWAVE
1746
1747
1748
1749 IF (sout(idsrad,ng)) THEN
1750 scale=rho0*cp
1751 CALL extract_sta2d (ng, model, cgrid, idsrad, r2dvar, &
1752 & lbi, ubi, lbj, ubj, &
1753 & scale, forces(ng)%srflx, &
1754 & nstation(ng), xpos, ypos, psta)
1756 & trim(vname(1,idsrad)), psta, &
1757 & (/1,sta(ng)%Rindex/), &
1758 & (/nstation(ng),1/), &
1759 & piofile = sta(ng)%pioFile, &
1760 & piovar = sta(ng)%pioVar(idsrad)%vd)
1761 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1762 END IF
1763# endif
1764# if defined EMINUSP && defined BULK_FLUXES
1765
1766
1767
1768 IF (sout(idempf,ng)) THEN
1769 scale=1.0_dp
1770 CALL extract_sta2d (ng, model, cgrid, idempf, r2dvar, &
1771 & lbi, ubi, lbj, ubj, &
1772 & scale, forces(ng)%stflux(:,:,isalt), &
1773 & nstation(ng), xpos, ypos, psta)
1775 & trim(vname(1,idempf)), psta, &
1776 & (/1,sta(ng)%Rindex/), &
1777 & (/nstation(ng),1/), &
1778 & piofile = sta(ng)%pioFile, &
1779 & piovar = sta(ng)%pioVar(idempf)%vd)
1780 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1781 END IF
1782
1783
1784
1785 IF (sout(idevap,ng)) THEN
1786 scale=1.0_dp
1787 CALL extract_sta2d (ng, model, cgrid, idevap, r2dvar, &
1788 & lbi, ubi, lbj, ubj, &
1789 & scale, forces(ng)%evap, &
1790 & nstation(ng), xpos, ypos, psta)
1792 & trim(vname(1,idevap)), psta, &
1793 & (/1,sta(ng)%Rindex/), &
1794 & (/nstation(ng),1/), &
1795 & piofile = sta(ng)%pioFile, &
1796 & piovar = sta(ng)%pioVar(idevap)%vd)
1797 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1798 END IF
1799
1800
1801
1802 IF (sout(idrain,ng)) THEN
1803 scale=1.0_dp
1804 CALL extract_sta2d (ng, model, cgrid, idrain, r2dvar, &
1805 & lbi, ubi, lbj, ubj, &
1806 & scale, forces(ng)%rain, &
1807 & nstation(ng), xpos, ypos, psta)
1809 & trim(vname(1,idrain)), psta, &
1810 & (/1,sta(ng)%Rindex/), &
1811 & (/nstation(ng),1/), &
1812 & piofile = sta(ng)%pioFile, &
1813 & piovar = sta(ng)%pioVar(idrain)%vd)
1814 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1815 END IF
1816# endif
1817# endif
1818
1819
1820
1821 IF (sout(idusms,ng)) THEN
1822 scale=rho0
1823 CALL extract_sta2d (ng, model, cgrid, idusms, u2dvar, &
1824 & lbi, ubi, lbj, ubj, &
1825 & scale, forces(ng)%sustr, &
1826 & nstation(ng), xpos, ypos, psta)
1828 & trim(vname(1,idusms)), psta, &
1829 & (/1,sta(ng)%Rindex/), &
1830 & (/nstation(ng),1/), &
1831 & piofile = sta(ng)%pioFile, &
1832 & piovar = sta(ng)%pioVar(idusms)%vd)
1833 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1834 END IF
1835
1836
1837
1838 IF (sout(idvsms,ng)) THEN
1839 scale=rho0
1840 CALL extract_sta2d (ng, model, cgrid, idvsms, v2dvar, &
1841 & lbi, ubi, lbj, ubj, &
1842 & scale, forces(ng)%svstr, &
1843 & nstation(ng), xpos, ypos, psta)
1845 & trim(vname(1,idvsms)), psta, &
1846 & (/1,sta(ng)%Rindex/), &
1847 & (/nstation(ng),1/), &
1848 & piofile = sta(ng)%pioFile, &
1849 & piovar = sta(ng)%pioVar(idvsms)%vd)
1850 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1851 END IF
1852
1853
1854
1855 IF (sout(idubms,ng)) THEN
1856 scale=-rho0
1857 CALL extract_sta2d (ng, model, cgrid, idubms, u2dvar, &
1858 & lbi, ubi, lbj, ubj, &
1859 & scale, forces(ng)%bustr, &
1860 & nstation(ng), xpos, ypos, psta)
1862 & trim(vname(1,idubms)), psta, &
1863 & (/1,sta(ng)%Rindex/), &
1864 & (/nstation(ng),1/), &
1865 & piofile = sta(ng)%pioFile, &
1866 & piovar = sta(ng)%pioVar(idubms)%vd)
1867 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1868 END IF
1869
1870
1871
1872 IF (sout(idvbms,ng)) THEN
1873 scale=-rho0
1874 CALL extract_sta2d (ng, model, cgrid, idvbms, v2dvar, &
1875 & lbi, ubi, lbj, ubj, &
1876 & scale, forces(ng)%bvstr, &
1877 & nstation(ng), xpos, ypos, psta)
1879 & trim(vname(1,idvbms)), psta, &
1880 & (/1,sta(ng)%Rindex/), &
1881 & (/nstation(ng),1/), &
1882 & piofile = sta(ng)%pioFile, &
1883 & piovar = sta(ng)%pioVar(idvbms)%vd)
1884 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1885 END IF
1886
1887# ifdef WET_DRY
1888
1889
1890
1891 IF (sout(idrwet,ng)) THEN
1892 scale=1.0_dp
1893 CALL extract_sta2d (ng, model, cgrid, idrwet, r2dvar, &
1894 & lbi, ubi, lbj, ubj, &
1895 & scale, grid(ng)%rmask_wet, &
1896 & nstation(ng), xpos, ypos, psta)
1898 & trim(vname(1,idrwet)), psta, &
1899 & (/1,sta(ng)%Rindex/), &
1900 & (/nstation(ng),1/), &
1901 & piofile = sta(ng)%pioFile, &
1902 & piovar = sta(ng)%pioVar(idrwet)%vd)
1903 END IF
1904
1905
1906
1907 IF (sout(iduwet,ng)) THEN
1908 scale=1.0_dp
1909 CALL extract_sta2d (ng, model, cgrid, iduwet, u2dvar, &
1910 & lbi, ubi, lbj, ubj, &
1911 & scale, grid(ng)%umask_wet, &
1912 & nstation(ng), xpos, ypos, psta)
1914 & trim(vname(1,iduwet)), psta, &
1915 & (/1,sta(ng)%Rindex/), &
1916 & (/nstation(ng),1/), &
1917 & piofile = sta(ng)%pioFile, &
1918 & piovar = sta(ng)%pioVar(iduwet)%vd)
1919 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1920 END IF
1921
1922
1923
1924 IF (sout(idvwet,ng)) THEN
1925 scale=1.0_dp
1926 CALL extract_sta2d (ng, model, cgrid, idvwet, v2dvar, &
1927 & lbi, ubi, lbj, ubj, &
1928 & scale, grid(ng)%vmask_wet, &
1929 & nstation(ng), xpos, ypos, psta)
1931 & trim(vname(1,idvwet)), psta, &
1932 & (/1,sta(ng)%Rindex/), &
1933 & (/nstation(ng),1/), &
1934 & piofile = sta(ng)%pioFile, &
1935 & piovar = sta(ng)%pioVar(idvwet)%vd)
1936 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1937 END IF
1938# endif
1939
1940# if defined BBL_MODEL || defined WAVES_OUTPUT
1941
1942
1943
1944
1945
1946 CALL bbl_wrt_station_pio (ng, model, tile, &
1947 & lbi, ubi, lbj, ubj, &
1948 & sout, sta)
1949 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1950# endif
1951
1952# ifdef ICE_MODEL
1953
1954
1955
1956
1957
1958 CALL ice_wrt_station_pio (ng, model, tile, &
1959 & lbi, ubi, lbj, ubj, &
1960 & sout, sta)
1961 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1962# endif
1963
1964# ifdef SEDIMENT
1965
1966
1967
1968
1969
1970 CALL sediment_wrt_station_pio (ng, model, tile, &
1971 & lbi, ubi, lbj, ubj, &
1972 & sout, sta)
1973 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1974# endif
1975
1976# if defined WEC || defined WEC_VF
1977
1978
1979
1980
1981
1982 CALL wec_wrt_station_pio (ng, model, tile, &
1983 & lbi, ubi, lbj, ubj, &
1984 & sout, sta)
1985 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
1986# endif
1987
1988
1989
1990
1991
1993
1994 RETURN
subroutine, public pio_netcdf_sync(ng, model, ncname, piofile)