cal_tools_m.f90 Source File



Files dependent on this one

sourcefile~~cal_tools_m.f90~~AfferentGraph sourcefile~cal_tools_m.f90 cal_tools_m.f90 sourcefile~regr_horiz_time_climoz_m.f90 regr_horiz_time_climoz_m.f90 sourcefile~regr_horiz_time_climoz_m.f90->sourcefile~cal_tools_m.f90 sourcefile~regr_horiz_time_climoz_m.f90~2 regr_horiz_time_climoz_m.f90 sourcefile~regr_horiz_time_climoz_m.f90~2->sourcefile~cal_tools_m.f90 sourcefile~limit_netcdf.f90 limit_netcdf.F90 sourcefile~limit_netcdf.f90->sourcefile~cal_tools_m.f90 sourcefile~physiq_mod.f90 physiq_mod.F90 sourcefile~physiq_mod.f90->sourcefile~regr_horiz_time_climoz_m.f90 sourcefile~etat0phys_netcdf.f90 etat0phys_netcdf.f90 sourcefile~etat0phys_netcdf.f90->sourcefile~regr_horiz_time_climoz_m.f90 sourcefile~ce0l.f90 ce0l.F90 sourcefile~ce0l.f90->sourcefile~limit_netcdf.f90 sourcefile~ce0l.f90->sourcefile~etat0phys_netcdf.f90 sourcefile~physiq_mod.f90~2 physiq_mod.F90 sourcefile~physiq_mod.f90~2->sourcefile~regr_horiz_time_climoz_m.f90 sourcefile~old_lmdz1d.f90 old_lmdz1d.f90 sourcefile~old_lmdz1d.f90->sourcefile~physiq_mod.f90 sourcefile~scm.f90 scm.f90 sourcefile~scm.f90->sourcefile~physiq_mod.f90 sourcefile~callphysiq_mod.f90 callphysiq_mod.f90 sourcefile~callphysiq_mod.f90->sourcefile~physiq_mod.f90 sourcefile~callphysiq_mod.f90~2 callphysiq_mod.f90 sourcefile~callphysiq_mod.f90~2->sourcefile~physiq_mod.f90 sourcefile~calfis.f90 calfis.f90 sourcefile~calfis.f90->sourcefile~callphysiq_mod.f90

Contents

Source Code


Source Code

MODULE cal_tools_m

  USE ioipsl, ONLY: ioconf_calendar, ioget_mon_len, lock_calendar,             &
                     ioget_calendar, ioget_year_len

CONTAINS

!-------------------------------------------------------------------------------
!
FUNCTION year_len(y,cal_in)
!
!-------------------------------------------------------------------------------
  IMPLICIT NONE
!-------------------------------------------------------------------------------
! Arguments:
  INTEGER                                :: year_len
  INTEGER,                    INTENT(IN) :: y
  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: cal_in
!-------------------------------------------------------------------------------
! Local variables:
  CHARACTER(LEN=20) :: cal_lmdz
!-------------------------------------------------------------------------------
  !--- No specified calendar: we need lmdz days number for current year
  IF(.NOT.PRESENT(cal_in)) THEN; year_len=ioget_year_len(y); RETURN; END IF

  !--- Get the lmdz calendar to reset at the end of the function
  CALL ioget_calendar(cal_lmdz)

  !--- Unlock calendar and set it to wanted one
  CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_in))

  !--- Get the number of days in this year
  year_len=ioget_year_len(y)

  !--- Back to original calendar
  CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_lmdz))

END FUNCTION year_len
!
!-------------------------------------------------------------------------------


!-------------------------------------------------------------------------------
!
FUNCTION mid_month(y,cal_in)
!
!-------------------------------------------------------------------------------
  IMPLICIT NONE
!-------------------------------------------------------------------------------
! Arguments:
  INTEGER,                    INTENT(IN) :: y           ! year
  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: cal_in      ! calendar
  REAL,                    DIMENSION(14) :: mid_month   ! mid-bins times
!-------------------------------------------------------------------------------
! Local variables:
  CHARACTER(LEN=20)      :: cal_lmdz          ! lmdz current calendar
  INTEGER, DIMENSION(14) :: tlen              ! months lengths (days)
  INTEGER                :: m                 ! months counter
  INTEGER                :: nd                ! number of days
!-------------------------------------------------------------------------------
  IF(PRESENT(cal_in)) THEN
    CALL ioget_calendar(cal_lmdz)             !--- Keep track of lmdz calendar
    CALL lock_calendar(.FALSE.)               !--- Unlock calendar
    CALL ioconf_calendar(TRIM(cal_in))        !--- Change calendar to "cal_in"
  END IF

  !--- Get the length of each month
  tlen(1 )=ioget_mon_len(y-1,12)
  DO m=1,12; tlen(m+1)=ioget_mon_len(y,m); END DO
  tlen(14)=ioget_mon_len(y+1, 1)

  !--- Mid-bins times
  mid_month(1)=-0.5*REAL(tlen(1))
  DO m=2,14; mid_month(m)=mid_month(m-1)+0.5*REAL(tlen(m-1)+tlen(m)); END DO

  IF(PRESENT(cal_in)) THEN
    CALL lock_calendar(.FALSE.)               !--- Unlock calendar
    CALL ioconf_calendar(TRIM(cal_lmdz))      !--- Restore original calendar
  END IF

END FUNCTION mid_month
!
!-------------------------------------------------------------------------------


END MODULE cal_tools_m
!
!*******************************************************************************