Skip to content

Commit 1fe7734

Browse files
committed
Add choice for 1D or 2D soil parameters in output
1 parent 34b1b77 commit 1fe7734

File tree

1 file changed

+150
-88
lines changed

1 file changed

+150
-88
lines changed

src/offline/cable_output.F90

Lines changed: 150 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,61 +1147,121 @@ SUBROUTINE open_output_file(dels, soil, veg, bgc, rough, met)
11471147
IF(output%isoil) CALL define_ovar(ncid_out, opid%isoil, &
11481148
'isoil', '-', 'Soil type', patchout%isoil, 'integer', &
11491149
xID, yID, zID, landID, patchID)
1150-
IF(output%bch) CALL define_ovar(ncid_out, opid%bch, &
1151-
! 'bch', '-', 'Parameter b, Campbell eqn 1985', patchout%bch, 'real', &
1152-
! replaced above by below - rk4417 - phase2
1153-
'bch', '-', 'Parameter b, Campbell eqn 1985', patchout%bch, soilID,'soil', &
1154-
xID, yID, zID, landID, patchID)
1155-
IF(output%clay) CALL define_ovar(ncid_out, opid%clay, &
1156-
! 'clay', '-', 'Fraction of soil which is clay', patchout%clay, 'real', &
1157-
! replaced above by below - rk4417 - phase2
1150+
IF(output%bch) THEN
1151+
IF (cable_user%gw_model) THEN
1152+
CALL define_ovar(ncid_out, opid%bch, &
1153+
'bch', '-', 'Parameter b, Campbell eqn 1985', patchout%bch, soilID,'soil', &
1154+
xID, yID, zID, landID, patchID)
1155+
ELSE
1156+
CALL define_ovar(ncid_out, opid%bch, &
1157+
'bch', '-', 'Parameter b, Campbell eqn 1985', patchout%bch, 'real', &
1158+
xID, yID, zID, landID, patchID)
1159+
END IF
1160+
END IF
1161+
IF(output%clay) THEN
1162+
IF (cable_user%gw_model) THEN
1163+
CALL define_ovar(ncid_out, opid%clay, &
11581164
'clay', '-', 'Fraction of soil which is clay', patchout%clay, soilID,'soil', &
11591165
xID, yID, zID, landID, patchID)
1160-
IF(output%sand) CALL define_ovar(ncid_out, opid%sand, &
1161-
! 'sand', '-', 'Fraction of soil which is sand', patchout%sand, 'real', &
1162-
! replaced above by below - rk4417 - phase2
1166+
ELSE
1167+
CALL define_ovar(ncid_out, opid%clay, &
1168+
'clay', '-', 'Fraction of soil which is clay', patchout%clay, 'real', &
1169+
xID, yID, zID, landID, patchID)
1170+
END IF
1171+
END IF
1172+
IF(output%sand) THEN
1173+
IF (cable_user%gw_model) THEN
1174+
CALL define_ovar(ncid_out, opid%sand, &
11631175
'sand', '-', 'Fraction of soil which is sand', patchout%sand, soilID,'soil', &
11641176
xID, yID, zID, landID, patchID)
1165-
IF(output%silt) CALL define_ovar(ncid_out, opid%silt, &
1166-
! 'silt', '-', 'Fraction of soil which is silt', patchout%silt, 'real', &
1167-
! replaced above by below - rk4417 - phase2
1177+
ELSE
1178+
CALL define_ovar(ncid_out, opid%sand, &
1179+
'sand', '-', 'Fraction of soil which is sand', patchout%sand, 'real', &
1180+
xID, yID, zID, landID, patchID)
1181+
END IF
1182+
END IF
1183+
IF(output%silt) THEN
1184+
IF (cable_user%gw_model) THEN
1185+
CALL define_ovar(ncid_out, opid%silt, &
11681186
'silt', '-', 'Fraction of soil which is silt', patchout%silt, soilID,'soil', &
11691187
xID, yID, zID, landID, patchID)
1170-
IF(output%ssat) CALL define_ovar(ncid_out, opid%ssat, &
1171-
'ssat', '-', 'Fraction of soil volume which is water @ saturation', &
1172-
! patchout%ssat, 'real', xID, yID, zID, landID, patchID)
1173-
! replaced above by below - rk4417 - phase2
1174-
patchout%ssat, soilID,'soil', xID, yID, zID, landID, patchID)
1175-
IF(output%sfc) CALL define_ovar(ncid_out, opid%sfc, &
1176-
'sfc', '-', 'Fraction of soil volume which is water @ field capacity', &
1177-
! patchout%sfc, 'real', xID, yID, zID, landID, patchID)
1178-
! replaced above by below - rk4417 - phase2
1179-
patchout%sfc, soilID,'soil', xID, yID, zID, landID, patchID)
1180-
IF(output%swilt) CALL define_ovar(ncid_out, opid%swilt, &
1181-
'swilt', '-', 'Fraction of soil volume which is water @ wilting point', &
1182-
! patchout%swilt, 'real', xID, yID, zID, landID, patchID)
1183-
! replaced above by below - rk4417 - phase2
1184-
patchout%swilt, soilID,'soil', xID, yID, zID, landID, patchID)
1185-
IF(output%hyds) CALL define_ovar(ncid_out, opid%hyds, &
1186-
'hyds', 'm/s', 'Hydraulic conductivity @ saturation', &
1187-
! patchout%hyds, 'real', xID, yID, zID, landID, patchID)
1188-
! replaced above by below - rk4417 - phase2
1189-
patchout%hyds, soilID,'soil', xID, yID, zID, landID, patchID)
1190-
IF(output%sucs) CALL define_ovar(ncid_out, opid%sucs, &
1191-
'sucs', 'm', 'Suction @ saturation', &
1192-
! patchout%sucs, 'real', xID, yID, zID, landID, patchID)
1193-
! replaced above by below - rk4417 - phase2
1194-
patchout%sucs, soilID,'soil', xID, yID, zID, landID, patchID)
1188+
ELSE
1189+
CALL define_ovar(ncid_out, opid%silt, &
1190+
'silt', '-', 'Fraction of soil which is silt', patchout%silt, 'real', &
1191+
xID, yID, zID, landID, patchID)
1192+
END IF
1193+
END IF
1194+
IF(output%ssat) THEN
1195+
IF (cable_user%gw_model) THEN
1196+
CALL define_ovar(ncid_out, opid%ssat, &
1197+
'ssat', '-', 'Fraction of soil volume which is water @ saturation', &
1198+
patchout%ssat, soilID,'soil', xID, yID, zID, landID, patchID)
1199+
ELSE
1200+
CALL define_ovar(ncid_out, opid%ssat, &
1201+
'ssat', '-', 'Fraction of soil volume which is water @ saturation', &
1202+
patchout%ssat, 'real', xID, yID, zID, landID, patchID)
1203+
END IF
1204+
END IF
1205+
IF(output%sfc) THEN
1206+
IF (cable_user%gw_model) THEN
1207+
CALL define_ovar(ncid_out, opid%sfc, &
1208+
'sfc', '-', 'Fraction of soil volume which is water @ field capacity', &
1209+
patchout%sfc, soilID,'soil', xID, yID, zID, landID, patchID)
1210+
ELSE
1211+
CALL define_ovar(ncid_out, opid%sfc, &
1212+
'sfc', '-', 'Fraction of soil volume which is water @ field capacity', &
1213+
patchout%sfc, 'real', xID, yID, zID, landID, patchID)
1214+
END IF
1215+
END IF
1216+
IF(output%swilt) THEN
1217+
IF (cable_user%gw_model) THEN
1218+
CALL define_ovar(ncid_out, opid%swilt, &
1219+
'swilt', '-', 'Fraction of soil volume which is water @ wilting point', &
1220+
patchout%swilt, soilID,'soil', xID, yID, zID, landID, patchID)
1221+
ELSE
1222+
CALL define_ovar(ncid_out, opid%swilt, &
1223+
'swilt', '-', 'Fraction of soil volume which is water @ wilting point', &
1224+
patchout%swilt, 'real', xID, yID, zID, landID, patchID)
1225+
END IF
1226+
END IF
1227+
IF(output%hyds) THEN
1228+
IF (cable_user%gw_model) THEN
1229+
CALL define_ovar(ncid_out, opid%hyds, &
1230+
'hyds', 'm/s', 'Hydraulic conductivity @ saturation', &
1231+
patchout%hyds, soilID,'soil', xID, yID, zID, landID, patchID)
1232+
ELSE
1233+
CALL define_ovar(ncid_out, opid%hyds, &
1234+
'hyds', 'm/s', 'Hydraulic conductivity @ saturation', &
1235+
patchout%hyds, 'real', xID, yID, zID, landID, patchID)
1236+
END IF
1237+
END IF
1238+
IF(output%sucs) THEN
1239+
IF (cable_user%gw_model) THEN
1240+
! gw_model uses sucs_vec that is a 2D variable
1241+
CALL define_ovar(ncid_out, opid%sucs, &
1242+
'sucs', 'm', 'Suction @ saturation', &
1243+
patchout%sucs, soilID,'soil', xID, yID, zID, landID, patchID)
1244+
ELSE
1245+
CALL define_ovar(ncid_out, opid%sucs, &
1246+
'sucs', 'm', 'Suction @ saturation', &
1247+
patchout%sucs, 'real', xID, yID, zID, landID, patchID)
1248+
END IF
1249+
END IF
11951250
IF(output%css) CALL define_ovar(ncid_out, opid%css, &
11961251
'css', 'J/kg/C', 'Heat capacity of soil minerals', &
11971252
! patchout%css, 'real', xID, yID, zID, landID, patchID)
1198-
! replaced above by below - rk4417 - phase2
11991253
patchout%css, soilID,'soil', xID, yID, zID, landID, patchID)
1200-
IF(output%rhosoil) CALL define_ovar(ncid_out, &
1201-
opid%rhosoil, 'rhosoil', 'kg/m^3', 'Density of soil minerals', &
1202-
! patchout%rhosoil, 'real', xID, yID, zID, landID, patchID)
1203-
! replaced above by below - rk4417 - phase2
1204-
patchout%rhosoil, soilID,'soil', xID, yID, zID, landID, patchID)
1254+
IF(output%rhosoil) THEN
1255+
IF (cable_user%gw_model) THEN
1256+
CALL define_ovar(ncid_out, &
1257+
opid%rhosoil, 'rhosoil', 'kg/m^3', 'Density of soil minerals', &
1258+
patchout%rhosoil, soilID,'soil', xID, yID, zID, landID, patchID)
1259+
ELSE
1260+
CALL define_ovar(ncid_out, &
1261+
opid%rhosoil, 'rhosoil', 'kg/m^3', 'Density of soil minerals', &
1262+
patchout%rhosoil, 'real', xID, yID, zID, landID, patchID)
1263+
END IF
1264+
END IF
12051265
IF(output%rs20) CALL define_ovar(ncid_out, opid%rs20, &
12061266
'rs20', '-', 'Soil respiration coefficient at 20C', &
12071267
patchout%rs20, 'real', xID, yID, zID, landID, patchID)
@@ -1463,55 +1523,59 @@ SUBROUTINE open_output_file(dels, soil, veg, bgc, rough, met)
14631523
out_settings%dimswitch = "integer"
14641524
CALL check_and_write(output%isoil, opid%isoil, &
14651525
'isoil', REAL(soil%isoilm, 4), ranges%isoil, patchout%isoil, out_settings)
1466-
out_settings%dimswitch = "real"
1467-
CALL check_and_write(output%bch, opid%bch, &
1468-
! 'bch', REAL(soil%bch, 4), ranges%bch, patchout%bch, out_settings)
1469-
! replaced above by below - rk4417 - phase2
1526+
1527+
IF (cable_user%gw_model) THEN
1528+
out_settings%dimswitch = "soil"
1529+
1530+
CALL check_and_write(output%bch, opid%bch, &
14701531
'bch', REAL(soil%bch_vec, 4), ranges%bch, patchout%bch, out_settings)
1471-
CALL check_and_write(output%clay, opid%clay, &
1472-
! 'clay', REAL(soil%clay, 4), ranges%clay, patchout%clay, out_settings)
1473-
! replaced above by below - rk4417 - phase2
1532+
CALL check_and_write(output%clay, opid%clay, &
14741533
'clay', REAL(soil%clay_vec, 4), ranges%clay, patchout%clay, out_settings)
1475-
CALL check_and_write(output%sand, opid%sand, &
1476-
! 'sand', REAL(soil%sand, 4), ranges%sand, patchout%sand, out_settings)
1477-
! replaced above by below - rk4417 - phase2
1478-
'sand', REAL(soil%sand_vec, 4), ranges%sand, patchout%sand, out_settings)
1479-
CALL check_and_write(output%silt, opid%silt, &
1480-
! 'silt', REAL(soil%silt, 4), ranges%silt, patchout%silt, out_settings)
1481-
! replaced above by below - rk4417 - phase2
1534+
CALL check_and_write(output%sand, opid%sand, &
1535+
'sand', REAL(soil%sand_vec, 4), ranges%sand, patchout%sand, out_settings)
1536+
CALL check_and_write(output%silt, opid%silt, &
14821537
'silt', REAL(soil%silt_vec, 4), ranges%silt, patchout%silt, out_settings)
1483-
CALL check_and_write(output%css, opid%css, &
1484-
! 'css', REAL(soil%css, 4), ranges%css, patchout%css, out_settings)
1485-
! replaced above by below - rk4417 - phase2
1538+
CALL check_and_write(output%css, opid%css, &
14861539
'css', REAL(soil%css_vec, 4), ranges%css, patchout%css, out_settings)
1487-
CALL check_and_write(output%rhosoil, &
1488-
! opid%rhosoil, 'rhosoil',REAL(soil%rhosoil,4), &
1489-
! replaced above by below - rk4417 - phase2
1540+
CALL check_and_write(output%rhosoil, &
14901541
opid%rhosoil, 'rhosoil',REAL(soil%rhosoil_vec,4), &
14911542
ranges%rhosoil, patchout%rhosoil, out_settings)
1492-
CALL check_and_write(output%hyds, opid%hyds, &
1493-
! 'hyds', REAL(soil%hyds, 4), ranges%hyds, patchout%hyds, out_settings)
1494-
! replaced above by below - rk4417 - phase2
1543+
CALL check_and_write(output%hyds, opid%hyds, &
14951544
'hyds', REAL(soil%hyds_vec, 4), ranges%hyds, patchout%hyds, out_settings)
1496-
CALL check_and_write(output%sucs, opid%sucs, &
1497-
! 'sucs', REAL(soil%sucs, 4), ranges%sucs, patchout%sucs, out_settings)
1498-
! replaced above by below - rk4417 - phase2
1545+
CALL check_and_write(output%sucs, opid%sucs, &
14991546
'sucs', REAL(soil%sucs_vec, 4), ranges%sucs, patchout%sucs, out_settings)
1500-
CALL check_and_write(output%rs20, opid%rs20, &
1501-
'rs20', REAL(veg%rs20, 4), ranges%rs20, patchout%rs20, out_settings)
1502-
! 'rs20',REAL(soil%rs20,4),ranges%rs20,patchout%rs20,out_settings)
1503-
CALL check_and_write(output%ssat, opid%ssat, &
1504-
! 'ssat', REAL(soil%ssat, 4), ranges%ssat, patchout%ssat, out_settings)
1505-
! replaced above by below - rk4417 - phase2
1547+
CALL check_and_write(output%ssat, opid%ssat, &
15061548
'ssat', REAL(soil%ssat_vec, 4), ranges%ssat, patchout%ssat, out_settings)
1507-
CALL check_and_write(output%sfc, opid%sfc, &
1508-
! 'sfc', REAL(soil%sfc, 4), ranges%sfc, patchout%sfc, out_settings)
1509-
! replaced above by below - rk4417 - phase2
1549+
CALL check_and_write(output%sfc, opid%sfc, &
15101550
'sfc', REAL(soil%sfc_vec, 4), ranges%sfc, patchout%sfc, out_settings)
1511-
CALL check_and_write(output%swilt, opid%swilt, &
1512-
! 'swilt', REAL(soil%swilt, 4), ranges%swilt, patchout%swilt, out_settings)
1513-
! replaced above by below - rk4417 - phase2
1551+
CALL check_and_write(output%swilt, opid%swilt, &
15141552
'swilt', REAL(soil%swilt_vec, 4), ranges%swilt, patchout%swilt, out_settings)
1553+
ELSE
1554+
out_settings%dimswitch = "real"
1555+
CALL check_and_write(output%bch, opid%bch, &
1556+
'bch', REAL(soil%bch, 4), ranges%bch, patchout%bch, out_settings)
1557+
CALL check_and_write(output%clay, opid%clay, &
1558+
'clay', REAL(soil%clay, 4), ranges%clay, patchout%clay, out_settings)
1559+
CALL check_and_write(output%sand, opid%sand, &
1560+
'sand', REAL(soil%sand, 4), ranges%sand, patchout%sand, out_settings)
1561+
CALL check_and_write(output%silt, opid%silt, &
1562+
'silt', REAL(soil%silt, 4), ranges%silt, patchout%silt, out_settings)
1563+
CALL check_and_write(output%css, opid%css, &
1564+
'css', REAL(soil%css, 4), ranges%css, patchout%css, out_settings)
1565+
CALL check_and_write(output%rhosoil, &
1566+
opid%rhosoil, 'rhosoil',REAL(soil%rhosoil,4), &
1567+
ranges%rhosoil, patchout%rhosoil, out_settings)
1568+
CALL check_and_write(output%hyds, opid%hyds, &
1569+
'hyds', REAL(soil%hyds, 4), ranges%hyds, patchout%hyds, out_settings)
1570+
CALL check_and_write(output%sucs, opid%sucs, &
1571+
'sucs', REAL(soil%sucs, 4), ranges%sucs, patchout%sucs, out_settings)
1572+
CALL check_and_write(output%ssat, opid%ssat, &
1573+
'ssat', REAL(soil%ssat, 4), ranges%ssat, patchout%ssat, out_settings)
1574+
CALL check_and_write(output%sfc, opid%sfc, &
1575+
'sfc', REAL(soil%sfc, 4), ranges%sfc, patchout%sfc, out_settings)
1576+
CALL check_and_write(output%swilt, opid%swilt, &
1577+
'swilt', REAL(soil%swilt, 4), ranges%swilt, patchout%swilt, out_settings)
1578+
END IF
15151579

15161580
! CALL check_and_write(output%slope ,ncid_out, opid%slope, &
15171581
! 'slope', REAL(soil%slope, 4), ranges%slope, patchout%slope, out_settings)
@@ -1528,7 +1592,6 @@ SUBROUTINE open_output_file(dels, soil, veg, bgc, rough, met)
15281592
out_settings%dimswitch = "soil"
15291593
CALL check_and_write(output%zse, opid%zse, &
15301594
! 'zse', SPREAD(REAL(soil%zse, 4), 1, mp),ranges%zse, &
1531-
! replaced above by below - rk4417 - phase2
15321595
'zse', REAL(soil%zse_vec, 4),ranges%zse, &
15331596
patchout%zse, out_settings)! no spatial dim at present
15341597

@@ -1558,6 +1621,9 @@ SUBROUTINE open_output_file(dels, soil, veg, bgc, rough, met)
15581621
ENDIF
15591622
CALL check_and_write(output%rp20, opid%rp20, &
15601623
'rp20', REAL(veg%rp20, 4),ranges%rp20, patchout%rp20, out_settings)
1624+
CALL check_and_write(output%rs20, opid%rs20, &
1625+
'rs20', REAL(veg%rs20, 4), ranges%rs20, patchout%rs20, out_settings)
1626+
! 'rs20',REAL(soil%rs20,4),ranges%rs20,patchout%rs20,out_settings)
15611627
! Ticket #56
15621628
CALL check_and_write(output%g0, opid%g0, &
15631629
'g0', REAL(veg%g0, 4),ranges%g0, patchout%g0, out_settings)
@@ -1640,13 +1706,11 @@ SUBROUTINE open_output_file(dels, soil, veg, bgc, rough, met)
16401706

16411707
CALL check_and_write(output%params .AND. cable_user%gw_model, opid%SatFracmax, &
16421708
! 'SatFracmax', SPREAD(REAL(gw_params%MaxSatFraction,4),1,mp), &
1643-
! replaced above by below - rk4417 - phase2
16441709
'SatFracmax', SPREAD(REAL(SQRT(gw_params%MaxSatFraction),4),1,mp), &
16451710
ranges%gw_default, patchout%SatFracmax, out_settings) ! note specially for ranges%gw_default that I have instead (/0.0,1000000.0/) - rk4417 - phase2
16461711

16471712
CALL check_and_write(output%params .AND. cable_user%gw_model, opid%Qhmax, &
16481713
! 'Qhmax', SPREAD(REAL(gw_params%MaxHorzDrainRate, 4),1,mp), &
1649-
! replaced above by below - rk4417 - phase2
16501714
'Qhmax', REAL(soil%qhz_max, 4), &
16511715
ranges%gw_default, patchout%Qhmax, out_settings) ! note specially for ranges%gw_default that I have instead (/0.0,1000000.0/) - rk4417 - phase2
16521716

@@ -1657,13 +1721,11 @@ SUBROUTINE open_output_file(dels, soil, veg, bgc, rough, met)
16571721

16581722
CALL check_and_write(output%params .AND. cable_user%gw_model, opid%HKefold, &
16591723
! 'HKefold', SPREAD(REAL(gw_params%hkrz, 4),1,mp), &
1660-
! replaced above by below - rk4417 - phase2
16611724
'HKefold', REAL(soil%hkrz, 4), &
16621725
ranges%gw_default, patchout%HKefold, out_settings) ! note specially for ranges%gw_default that I have instead (/0.0,1000000.0/) - rk4417 - phase2
16631726

16641727
CALL check_and_write(output%params .AND. cable_user%gw_model, opid%HKdepth, &
16651728
! 'HKdepth', SPREAD(REAL(gw_params%zdepth, 4),1,mp), &
1666-
! replaced above by below - rk4417 - phase2
16671729
'HKdepth', REAL(soil%zdepth, 4), &
16681730
ranges%gw_default, patchout%HKdepth, out_settings) ! note specially for ranges%gw_default that I have instead (/0.0,1000000.0/) - rk4417 - phase2
16691731
END IF ! line inserted by rk4417 - phase2

0 commit comments

Comments
 (0)