       subroutine pl_write_parms_cal
      
       use maximum_data_module
       use calibration_data_module
       use hydrograph_module
       use hru_module, only : hru
       use input_file_module
       use plant_module
       
       implicit none        
      
       character (len=80) :: titldum   !           |title of file
       character (len=80) :: header    !           |header of file
       integer :: eof                  !           |end of file
       logical :: i_exist              !none       |check to determine if file exists
       integer :: mreg                 !none       |end of loop
       integer :: i                    !none       |counter
       integer :: ilum
       integer :: ilum_mx
       integer :: isp                  !none       |counter 
       integer :: ielem1               !none       |counter 
       integer :: iihru                !none       |counter  
       integer :: ihru                 !none       |counter 
       integer :: nspu                 !           | 
       integer :: ipl                  !           | 
       
       mreg = 0
       eof = 0

       open (107,file="plant_parms.cal",recl = 1500)

        write (107,*) "Calibrated plant parameter file"
        write (107,*) db_mx%plcal_reg
        write (107,*) "header"

      do i = 1, db_mx%plcal_reg

        write (107,*) pl_prms(i)%name, pl_prms(i)%lum_num, pl_prms(i)%parms, "  0"  
        write (107,*) "header"

        !! read landscape soft calibration data for each land use and parameter
        if (pl_prms(i)%lum_num > 0) then
          ilum_mx = pl_prms(i)%lum_num * pl_prms(i)%parms
          do ilum = 1, ilum_mx
            select case (pl_prms(i)%prm(ilum)%var)
              case ("pest_stress")
                if (plcal(i)%lum(ilum)%prm%pest_stress > 0.) then
                  pl_prms(i)%prm(ilum)%init_val = plcal(i)%lum(ilum)%prm%pest_stress
                end if
              case ("lai_pot")
                pl_prms(i)%prm(ilum)%init_val = pl_prms(i)%prm(ilum)%init_val + plcal(i)%lum(ilum-pl_prms(i)%lum_num)%prm%lai_pot
                pl_prms(i)%prm(ilum)%init_val = amin1 (pl_prms(i)%prm(ilum)%init_val, pl_prms(i)%prm(ilum)%up)
                pl_prms(i)%prm(ilum)%init_val = Max (pl_prms(i)%prm(ilum)%init_val, pl_prms(i)%prm(ilum)%lo)
              case ("harv_idx")
                pl_prms(i)%prm(ilum)%init_val = pl_prms(i)%prm(ilum)%init_val + plcal(i)%lum(ilum-2*pl_prms(i)%lum_num)%prm%harv_idx
                pl_prms(i)%prm(ilum)%init_val = amin1 (pl_prms(i)%prm(ilum)%init_val, pl_prms(i)%prm(ilum)%up)
                pl_prms(i)%prm(ilum)%init_val = Max (pl_prms(i)%prm(ilum)%init_val, pl_prms(i)%prm(ilum)%lo)
            end select
            !! write parameters to file
            write (107,*) pl_prms(i)%prm(ilum)
          end do
        end if 

      end do    !mreg

       close(107)
       return
       end subroutine pl_write_parms_cal