Subroutine vom_get_hourly_clim

808 : 
809 : 
810 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
811 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
812 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
813 : !*-----Climate and Calendar data reading--------------------------------
814 : 
815 :       subroutine vom_get_hourly_clim ()
816 :       use vom_vegwat_mod
817 :       implicit none
818 : 
819 :       INTEGER :: ii, i, h, oldh, stat
820 :       INTEGER :: dummyint1, dummyint2, dummyint3, dummyint4
821 :       LOGICAL :: exist
822 :       LOGICAL :: exist_daily
823 :       CHARACTER(len=99) :: str
824 : 
825 :       inquire(FILE=trim(adjustl(i_inputpath))// &
826 :               trim(adjustl(sfile_hourlyweather)), EXIST=exist)
827 : 
828 : !     * Creating hourly climate data from daily data
829 : 
830 :       inquire(FILE=trim(adjustl(i_inputpath))// &
831 :               trim(adjustl(sfile_dailyweather)), EXIST=exist_daily)
832 :       if (.not. exist_daily) then
833 :        stop "dailyweather.prn does not exist"
834 :       end if
835 : 
836 : 
837 :       if (.not. exist) then
838 :         open(kfile_dailyweather, FILE=trim(adjustl(i_inputpath))// &
839 :              trim(adjustl(sfile_dailyweather)),              &
840 :      &                           STATUS='old', IOSTAT=stat)
841 :         read(kfile_dailyweather,'(A)') str
842 :         if (LEN(TRIM(str)) .ne. 88) then
843 :           write(0,*) "ERROR: ", TRIM(sfile_dailyweather), ": Wrong file format"
844 :           stop
845 :         endif
846 :         do i = 1, c_maxday
847 :           read(kfile_dailyweather,'(4i8,7f8.2)') dayyear(i), fday(i),  &
848 :      &      fmonth(i), fyear(i), tairmax_d(i), tairmin_d(i), rain_d(i),&
849 :      &      srad_d(i), vp_d(i), press_d(i), ca_d(i)
850 :         enddo
851 :         close(kfile_dailyweather)
852 : 
853 : !       * Calculation of derived parameters
854 : 
855 :         call vom_calc_derived()
856 : 
857 :         if (i_write_h == 1) exist=.TRUE.
858 :       endif
859 : 
860 : !     * Reading hourly climate data if available
861 : 
862 :       if (exist) then
863 :         open(kfile_hourlyweather, FILE=trim(adjustl(i_inputpath))// &
864 :              trim(adjustl(sfile_hourlyweather)),            &
865 :      &                            STATUS='old', IOSTAT=stat)
866 :         read(kfile_hourlyweather,*)
867 :         ii = 1
868 :         oldh = 99
869 :         do i = 1, c_maxhour
870 :           read(kfile_hourlyweather,'(5i8,5e11.3)') h, dummyint1,       &
871 :      &      dummyint2, dummyint3, dummyint4, tair_h(i), vd_h(i),       &
872 :      &      par_h(i), rain_h(i), ca_h(i)
873 :           if (par_h(i) .lt. 0.d0) par_h(i) = 0.d0
874 :           ca_h(i) = ca_h(i) / 1.0d6
875 :           if (h .lt. oldh) then
876 :             dayyear(ii) = dummyint1
877 :             fday(ii)    = dummyint2
878 :             fmonth(ii)  = dummyint3
879 :             fyear(ii)   = dummyint4
880 :             ii = ii + 1
881 :           endif
882 :           oldh = h
883 :         enddo
884 :         close(kfile_hourlyweather)
885 :       endif
886 : 
887 :       return
888 :       end subroutine vom_get_hourly_clim