subroutine input_ifc ! ***************************************************************** wjr ! reads initial field conditions (IFC) file (Version: 1.0) ! ! Edit History ! Fri Oct 8 16:54:30 CDT 2004 - LEW ! based upon "inpsub.for" routine ! include 'p1werm.inc' include 'wpath.inc' include 'm1subr.inc' include 'm1sim.inc' include 'm1geo.inc' include 'm1flag.inc' include 'm1dbug.inc' include 's1layr.inc' include 's1surf.inc' include 's1phys.inc' include 's1agg.inc' include 's1dbh.inc' include 's1dbc.inc' include 's1sgeo.inc' include 'h1hydro.inc' include 'h1scs.inc' include 'h1db1.inc' include 'file.fi' include 'command.inc' !declarations for commandline args ! + + + LOCAL COMMON BLOCKS + + + include 'main/main.inc' ! + + + LOCAL VARIABLES + + + integer lay character line*512 integer isr integer max_typeidx !Maximum number of lines to read in real temp ! + + + FUNCTION DECLARATIONS + + + real plant_wat_g ! integer linnum, typeidx data linnum /0/, typeidx /0/ max_typeidx = 51 ! new ifc format (additional parms) isr = 1 ! can only handle a soil IFC file for a single subregion (#1) call fopenk (lui1, sinfil, 'old') ! open IFC file ! Check to see if this is a new "versioned" IFC file read (lui1,'(a)',err=901) line if (line(1:12) .ne. 'Version: 1.0') then close (lui1) call inpsub return end if ! Read "Version 1.0" IFC soil file contents 100 if (typeidx .eq. max_typeidx) go to 200 ! done reading IFC file linnum = linnum + 1 read (lui1,'(a)',err=901) line ! print *, 'We are on line #', linnum, 'line = ', line if (line(1:1) .eq. '#') go to 100 ! skip comment lines !use case statement to appropriately assign values typeidx = typeidx + 1 select case (typeidx) case (1) ! Soil ID string am0sid(isr) = line case (2) ! Local Phase string read(line,*,err=902) am0localphase(isr) case (3) ! Taxonomy string read(line,*,err=902) am0tax(isr) case (4) ! NRCS Soil Loss Tolerance (t/ac/yr) read(line,*,err=902) SoilLossTol(isr) ! read IP surface physical properties case (5) ! Dry soil albedo (fraction) read(line,*,err=902) asfald(isr) case (6) ! Slope gradient (m/m) ! set default outflow height to zero (minimum depression storage) ahzoutflow(isr) = 0.0 ! check value read in from weps.run if( amrslp(isr) .lt. -1.5 ) then ! weps.run specifies a level basin with no runoff amrslp(isr) = 0.0 ! set outflow height of 1/2 meter (minimum depression storage) ahzoutflow(isr) = 0.5 else if( amrslp(isr) .lt. 0.0 ) then ! no value entered by user (from weps.run) read(line,*,err=902) amrslp(isr) ! check subregion slope value for validity if( amrslp(isr) .lt. 0.0 ) then ! no valid value found in IFC file either, set default value of 1% amrslp(isr) = 0.01 end if else ! value from weps.run being used, throw away soil value read(line,*,err=902) temp end if case (7) ! Surface frag cover (area fraction) read(line,*,err=902) SFCov(isr) case (8) ! Depth to bedrock (mm) read(line,*,err=902) bedrock_depth(isr) case (9) ! Depth to root restricting layer (mm) read(line,*,err=902) restrict_depth(isr) ! read IP soil layer number and thickness case (10) ! Number of soil layers read(line,*,err=902) nslay(isr) case (11) ! Soil layer thickness (mm) read(line,*,err=902) (aszlyt(lay,isr), lay=1,nslay(isr)) ! read IP soil physical properties case (12) ! Sand fraction (kg/kg) read(line,*,err=902) (asfsan(lay,isr), lay=1,nslay(isr)) case (13) ! Silt fraction (kg/kg) read(line,*,err=902) (asfsil(lay,isr), lay=1,nslay(isr)) case (14) ! Clay fraction (kg/kg) read(line,*,err=902) (asfcla(lay,isr), lay=1,nslay(isr)) case (15) ! Rock fragments fraction (m^3/m^3) read(line,*,err=902) (asvroc(lay,isr), lay=1,nslay(isr)) case (16) ! Very course sand fraction (kg/kg) read(line,*,err=902) (asfvcs(lay,isr), lay=1,nslay(isr)) case (17) ! Course sand fraction (kg/kg) read(line,*,err=902) (asfcs(lay,isr), lay=1,nslay(isr)) case (18) ! Medium sand fraction (kg/kg) read(line,*,err=902) (asfms(lay,isr), lay=1,nslay(isr)) case (19) ! Fine sand fraction (kg/kg) read(line,*,err=902) (asffs(lay,isr), lay=1,nslay(isr)) case (20) ! Very fine sand fraction (kg/kg) read(line,*,err=902) (asfvfs(lay,isr), lay=1,nslay(isr)) case (21) ! Bulk density [wet or 1/3 bar] (Mg/m^3) read(line,*,err=902) (asdwblk(lay,isr), lay=1,nslay(isr)) ! read IP soil chemical properties case (22) ! Organic matter (kg/kg) read(line,*,err=902) (asfom(lay,isr), lay=1,nslay(isr)) case (23) ! PH (0-14) read(line,*,err=902) (as0ph(lay,isr), lay=1,nslay(isr)) case (24) ! Calcium Carbonate Equiv [CaCO3] (kg/kg) read(line,*,err=902) (asfcce(lay,isr), lay=1,nslay(isr)) case (25) ! Cation Exchange Capacity [CEC] (meq/100g) read(line,*,err=902) (asfcec(lay,isr), lay=1,nslay(isr)) case (26) ! Linear extensibility ((Mg/m^3)/(Mg/m^3)) read(line,*,err=902) (asfcle(lay,isr), lay=1,nslay(isr)) ! read IC aggregate properties case (27) ! ASD GMD (mm) read(line,*,err=902) (aslagm(lay,isr), lay=1,nslay(isr)) case (28) ! ASD GSD read(line,*,err=902) (as0ags(lay,isr), lay=1,nslay(isr)) case (29) ! Maximum agg. size (mm) read(line,*,err=902) (aslagx(lay,isr), lay=1,nslay(isr)) case (30) ! Minimum agg. size (mm) read(line,*,err=902) (aslagn(lay,isr), lay=1,nslay(isr)) case (31) ! Aggregate density (Mg/m^3) read(line,*,err=902) (asdagd(lay,isr), lay=1,nslay(isr)) case (32) ! Dry aggregate stability (ln(J/m^2)) read(line,*,err=902) (aseags(lay,isr), lay=1,nslay(isr)) ! read IC crust properties case (33) ! Crust thickness (mm) read(line,*,err=902) aszcr(isr) case (34) ! Crust density (Mg/m^3) read(line,*,err=902) asdcr(isr) case (35) ! Crust stability (ln(J/m^2)) read(line,*,err=902) asecr(isr) case (36) ! Crust surface frction (m^2/m^2) read(line,*,err=902) asfcr(isr) case (37) ! Mass of loose material on crust (kg/m^2) read(line,*,err=902) asmlos(isr) case (38) ! Fraction of loose material on crust (m^2/m^2) read(line,*,err=902) asflos(isr) ! read IC surface roughness properties case (39) ! Random roughness (mm) read(line,*,err=902) aslrr(isr) aslrro(isr) = aslrr(isr) ! init after-tillage RR case (40) ! Ridge orientation (deg) read(line,*,err=902) asargo(isr) case (41) ! Ridge height (mm) read(line,*,err=902) aszrgh(isr) case (42) ! Ridge spacing (mm) read(line,*,err=902) asxrgs(isr) case (43) ! Ridge width (mm) read(line,*,err=902) asxrgw(isr) ! this is where dike height and spacing should be read in. ! they are not, but need to be initialized. ! case (??) asxdks(isr) = 0.0 asxdkh(isr) = 0.0 ! read IC soil hydrologic properties ! All SWC values are converted to mass basis as they are the "independent variables" in WEPS case (44) ! Initial BD value (Mg/m^3) read(line,*,err=902) (asdblk(lay,isr), lay=1,nslay(isr)) do lay=1,nslay(isr) asdblk0(lay,isr) = asdblk(lay,isr) ! init previous day BD end do case (45) ! Initial SWC (m^3/m^3) read(line,*,err=902) (ahrwc(lay,isr), lay=1,nslay(isr)) do lay=1,nslay(isr) ! Convert to mass basis (kg/kg) ahrwc(lay,isr) = ahrwc(lay,isr) / asdblk(lay,isr) ! (using "initial" bd value) end do ! read soil hydrologic (water release curve) properties ! All can be overridden if "Saxton" method is specified (wc_type == 3) case (46) ! Saturated SWC (m^3/m^3) read(line,*,err=902) (ahrwcs(lay,isr), lay=1,nslay(isr)) do lay=1,nslay(isr) ! Convert to mass basis (kg/kg) ahrwcs(lay,isr) = ahrwcs(lay,isr) / asdblk(lay,isr) ! (using "initial" bd value) end do case (47) ! Field Capacity SWC (m^3/m^3) read(line,*,err=902) (ahrwcf(lay,isr), lay=1,nslay(isr)) do lay=1,nslay(isr) ! Convert to mass basis (kg/kg) ahrwcf(lay,isr) = ahrwcf(lay,isr) / asdblk(lay,isr) ! (using "initial" bd value) end do case (48) ! Wilting Point SWC (m^3/m^3) read(line,*,err=902) (ahrwcw(lay,isr), lay=1,nslay(isr)) do lay=1,nslay(isr) ! Convert to mass basis (kg/kg) ahrwcw(lay,isr) = ahrwcw(lay,isr) / asdblk(lay,isr) ! (using "initial" bd value) end do ! read more soil hydrologic (water release curve) properties ! All three can be reset if "Walter Rawls" method is specified (wc_type == 4) ! CB and Air Entry Pot. values possibly reset if "Walter Rawls" method not specified case (49) ! Soil CB value read(line,*,err=902) (ah0cb(lay,isr), lay=1,nslay(isr)) case (50) ! Air Entry Potential (J/kg) read(line,*,err=902) (aheaep(lay,isr), lay=1,nslay(isr)) case (51) ! Saturated Hydraulic Conductivity (m/s) read(line,*,err=902) (ahrsk(lay,isr), lay=1,nslay(isr)) end select goto 100 ! reading of subregion IFC elements complete 200 continue ! initialize new variables not read in from ifc file do lay = 1, nslay(isr) ahfredsat(lay,isr) = 0.0 end do ! Set layer thickness of the soils as is appropriate for the simulation call spllay_ifc() ! Wet Albedo (calculate from dry albedo) asfalw(isr) = asfald(isr)/((1.33**2.)*(1-asfald(isr))+asfald(isr)) ! Settled Bulk Density and Particle Density (texture based calculation) call proptext( nslay(isr), asfcla(1,isr), asfsan(1,isr), & & asfom(1,isr), asdsblk(1,isr), asdpart(1,isr) ) do lay=1,nslay(isr) ! make sure settled bd is greater than or equal to wet bulk density if( asdsblk(lay,isr).lt.asdwblk(lay,isr) ) then write(*,*) 'WARNING: settled bd (',asdsblk(lay,isr), & ! NOTE: Changed to "WARNING" so message & ') < wet bd (',asdwblk(lay,isr),'), sbd = wbd' !wouldn't display in GUI popup Warning dialog box asdsblk(lay,isr) = asdwblk(lay,isr) endif end do ! calculate (or recalculate) additional values from soil basic properties do lay=1,nslay(isr) ! command line switch, changes to IFC values if( wc_type.eq.0 ) then ! This is OK, this is the way values are now read in continue ! Ifc inputs are 1/3bar(vol), 15bar(vol), convert both to (grav) else if( wc_type.eq.1 ) then ! Ifc inputs are 1/3bar(vol), 15bar(grav), convert 1/3bar(vol) to (grav) ! Print out warning/error message about invalid commandline argument for this soil IFC file version write(*,*) 'Warning: -S1 (wc_type=1) is invalid commandline & &argument for this soil file, ignoring flag' else if( wc_type.eq.2 ) then ! Ifc inputs are 1/3bar(grav), 15bar(grav), no conversion necessary ! Print out warning/error message about invalid commandline argument for this soil IFC file version write(*,*) 'Warning: -S2 (wc_type=2) is invalid commandline & &argument for this soil file, ignoring flag' else if( wc_type.eq.3 ) then ! Default method. It resets many input values ! Use texture based calculation of 1/3bar(vol), 15bar(vol) and bulk ! density and convert to (grav). Using Saxton Method call propsaxt(asfsan(lay,isr), asfcla(lay,isr), & & ahrwcs(lay,isr), & & ahrwcf(lay,isr), ahrwcw(lay,isr) ) ! use volumetric saturation to calculate bulk density asdwblk(lay,isr) = (1.0-ahrwcs(lay,isr)) * asdpart(lay,isr) ! Returned values are 1/3bar(vol), 15bar(vol), convert both to (grav) ahrwcf(lay,isr) = ahrwcf(lay,isr) / asdwblk(lay,isr) ahrwcw(lay,isr) = ahrwcw(lay,isr) / asdwblk(lay,isr) end if end do do lay=1,nslay(isr) ! set saturation based on definition ! ahrwcs(lay,isr) = 1.0/asdblk(lay,isr)-1.0/asdpart(lay,isr) ! Is this based on gravimetric values? if(ahrwcs(lay,isr).lt.ahrwcf(lay,isr)) then write(*,*) 'WARNING: Layer, Field Capacity > Saturation', & ! NOTE: Changed to "WARNING" so message & lay, ahrwcf(lay,isr), ahrwcs(lay,isr) !wouldn't display in GUI popup Warning dialog box ! ahrwcf(lay,isr) = ahrwcs(lay,isr) endif ! output for soil file screening ! write(*,1000) sinfil,lay,aszlyt(lay,isr), ! & asfsan(lay,isr),asfcla(lay,isr),asfom(lay,isr), ! & asdwblk(lay,isr),asdblk(lay,isr),ahrwcs(lay,isr), ! & ahrwcf(lay,isr),ahrwcw(lay,isr), ! & ahrwcf(lay,isr)-ahrwcw(lay,isr), ! & 1.0 - asdwblk(lay,isr)/asdpart(lay,isr), ! & ahrwcf(lay,isr)*asdwblk(lay,isr), ! & ahrwcw(lay,isr)*asdwblk(lay,isr), ! & ahrwcf(lay,isr)*asdwblk(lay,isr)- ! & ahrwcw(lay,isr)*asdwblk(lay,isr) end do if( wc_type.eq.4 ) then ! use texture based calculations from Rawls to set all soil ! water properties. call param_prop_bc( & & nslay(isr), aszlyd(1,isr), asdblk(1,isr), asdpart(1,isr), & & asfcla(1,isr), asfsan(1,isr), asfom(1,isr), asfcec(1,isr),& & ahrwcs(1,isr), ahrwcf(1,isr), ahrwcw(1,isr),ahrwcr(1,isr),& & ahrwca(1,isr), ah0cb(1,isr), aheaep(1,isr), ahrsk(1,isr), & & ahfredsat(1,isr) ) ! do lay=1,nslay(isr) ! ! set soil to field capacity not wilting point ! ahrwc(lay,isr) = ahrwcf(lay,isr) ! end do else ! set matrix potential parameters to match 1/3 bar and 15 bar water contents call param_pot_bc( nslay(isr), asdblk(1,isr), asdpart(1,isr), & & ahrwcf(1,isr), ahrwcw(1,isr), & & asfcla(1,isr), asfom(1,isr), & & ah0cb(1,isr), aheaep(1,isr) ) end if !! used with output for soil file screening ! 1000 format(a50,1x,i2,f7.0,20f7.4) ! stop ! write out the soil water capacity plant available by depth write(*,*) 'inpsub:total 500mm', & & plant_wat_g( 0.0, 500.0, ahrwcf(1,isr), ahrwcw(1,isr), & & asdblk(1,isr), aszlyt(1,isr), nslay(isr) ), & & plant_wat_g( 500.0, 1000.0, ahrwcf(1,isr), ahrwcw(1,isr), & & asdblk(1,isr), aszlyt(1,isr), nslay(isr) ), & & plant_wat_g( 1000.0, 1500.0, ahrwcf(1,isr), ahrwcw(1,isr), & & asdblk(1,isr), aszlyt(1,isr), nslay(isr) ) ! some soil characteristic values for crop nutirent effects ! were originally planned and then dropped and are not included in ! layer splitting. A Debug full debug compile complains ! that these values are not initialized when they are mixed as ! part of management process. they are initialized here to avoid ! removing them from mix and invert do lay = 1, nslay(isr) ! I've removed them from the mix and invert functions. However, they might still be ! used in (hopefully) dead crop code. ascmg(lay,isr) = 0.0 ascna(lay,isr) = 0.0 asfesp(lay,isr) = 0.0 asfnoh(lay,isr) = 0.0 asfpoh(lay,isr) = 0.0 asfpsp(lay,isr) = 0.0 ! obsolete variables removed from "versioned" ifc files ! Can't not initialize them here because crop apparently is still using them somewhere asfsmb(lay,isr) = 0.0 asrsar(lay,isr) = 0.0 asftan(lay,isr) = 0.0 asftap(lay,isr) = 0.0 end do close (lui1) ! ! call dmpall('wrk.dmp') return 901 write(*,9001) trim(sinfil), linnum, trim(line) 9001 format(' Error in v1 IFC file ',a,' on line #',i4,' ',a) call exit(1) 902 write(*,9002) trim(sinfil), linnum, typeidx, trim(line) 9002 format(' Error in v1 IFC file ',a,' on line #',i4,'(',i2,') ',a) call exit(1) stop end