GCC Code Coverage Report


Directory: ./
File: phys/create_limit_unstruct.f90
Date: 2022-01-11 19:19:34
Exec Total Coverage
Lines: 0 2 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 MODULE create_limit_unstruct_mod
2 PRIVATE
3 INTEGER, PARAMETER :: lmdep=12
4
5 PUBLIC create_limit_unstruct
6
7 CONTAINS
8
9
10 SUBROUTINE create_limit_unstruct
11 USE dimphy
12 END SUBROUTINE create_limit_unstruct
13
14
15 SUBROUTINE time_interpolation(ndays,field_in,calendar,field_out)
16 USE pchsp_95_m, only: pchsp_95
17 USE pchfe_95_m, only: pchfe_95
18 USE arth_m, only: arth
19 USE dimphy, ONLY : klon
20 USE ioipsl, ONLY : ioget_year_len
21 USE time_phylmdz_mod, ONLY : annee_ref
22 USE mod_phys_lmdz_para
23 IMPLICIT NONE
24 INCLUDE "iniprint.h"
25
26 INTEGER, INTENT(IN) :: ndays
27 REAL, INTENT(IN) :: field_in(klon,lmdep)
28 CHARACTER(LEN=*),INTENT(IN) :: calendar
29 REAL, INTENT(OUT) :: field_out(klon,ndays)
30
31 INTEGER :: ndays_in
32 REAL :: timeyear(lmdep)
33 REAL :: yder(lmdep)
34 INTEGER :: ij,ierr, n_extrap
35 LOGICAL :: skip
36
37 CHARACTER (len = 50) :: modname = 'create_limit_unstruct.time_interpolation'
38 CHARACTER (len = 80) :: abort_message
39
40
41 IF (is_omp_master) ndays_in=year_len(annee_ref, calendar)
42 CALL bcast_omp(ndays_in)
43 IF (is_omp_master) timeyear=mid_months(annee_ref, calendar, lmdep)
44 CALL bcast_omp(timeyear)
45
46 n_extrap = 0
47 skip=.FALSE.
48 DO ij=1,klon
49 yder = pchsp_95(timeyear, field_in(ij, :), ibeg=2, iend=2, vc_beg=0., vc_end=0.)
50 CALL pchfe_95(timeyear, field_in(ij, :), yder, skip, arth(0., real(ndays_in) / ndays, ndays), field_out(ij, :), ierr)
51 if (ierr < 0) then
52 abort_message='error in pchfe_95'
53 CALL abort_physic(modname,abort_message,1)
54 endif
55 n_extrap = n_extrap + ierr
56 END DO
57
58 IF (n_extrap /= 0) then
59 WRITE(lunout,*) "get_2Dfield pchfe_95: n_extrap = ", n_extrap
60 ENDIF
61
62
63 END SUBROUTINE time_interpolation
64 !-------------------------------------------------------------------------------
65 !
66 FUNCTION year_len(y,cal_in)
67 !
68 !-------------------------------------------------------------------------------
69 USE ioipsl, ONLY : ioget_calendar,ioconf_calendar,lock_calendar,ioget_year_len
70 IMPLICIT NONE
71 !-------------------------------------------------------------------------------
72 ! Arguments:
73 INTEGER :: year_len
74 INTEGER, INTENT(IN) :: y
75 CHARACTER(LEN=*), INTENT(IN) :: cal_in
76 !-------------------------------------------------------------------------------
77 ! Local variables:
78 CHARACTER(LEN=20) :: cal_out ! calendar (for outputs)
79 !-------------------------------------------------------------------------------
80 !--- Getting the input calendar to reset at the end of the function
81 CALL ioget_calendar(cal_out)
82
83 !--- Unlocking calendar and setting it to wanted one
84 CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_in))
85
86 !--- Getting the number of days in this year
87 year_len=ioget_year_len(y)
88
89 !--- Back to original calendar
90 CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_out))
91
92 END FUNCTION year_len
93 !
94 !-------------------------------------------------------------------------------
95
96
97 !-------------------------------------------------------------------------------
98 !
99 FUNCTION mid_months(y,cal_in,nm)
100 !
101 !-------------------------------------------------------------------------------
102 USE ioipsl, ONLY : ioget_calendar,ioconf_calendar,lock_calendar,ioget_mon_len
103 IMPLICIT NONE
104 !-------------------------------------------------------------------------------
105 ! Arguments:
106 INTEGER, INTENT(IN) :: y ! year
107 CHARACTER(LEN=*), INTENT(IN) :: cal_in ! calendar
108 INTEGER, INTENT(IN) :: nm ! months/year number
109 REAL, DIMENSION(nm) :: mid_months ! mid-month times
110 !-------------------------------------------------------------------------------
111 ! Local variables:
112 CHARACTER(LEN=99) :: mess ! error message
113 CHARACTER(LEN=20) :: cal_out ! calendar (for outputs)
114 INTEGER, DIMENSION(nm) :: mnth ! months lengths (days)
115 INTEGER :: m ! months counter
116 INTEGER :: nd ! number of days
117 INTEGER :: k
118 !-------------------------------------------------------------------------------
119 nd=year_len(y,cal_in)
120
121 IF(nm==12) THEN
122
123 !--- Getting the input calendar to reset at the end of the function
124 CALL ioget_calendar(cal_out)
125
126 !--- Unlocking calendar and setting it to wanted one
127 CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_in))
128
129 !--- Getting the length of each month
130 DO m=1,nm; mnth(m)=ioget_mon_len(y,m); END DO
131
132 !--- Back to original calendar
133 CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_out))
134
135 ELSE IF(MODULO(nd,nm)/=0) THEN
136 WRITE(mess,'(a,i3,a,i3,a)')'Unconsistent calendar: ',nd,' days/year, but ',&
137 nm,' months/year. Months number should divide days number.'
138 CALL abort_physic('mid_months',TRIM(mess),1)
139
140 ELSE
141 mnth=(/(m,m=1,nm,nd/nm)/)
142 END IF
143
144 !--- Mid-months times
145 mid_months(1)=0.5*REAL(mnth(1))
146 DO k=2,nm
147 mid_months(k)=mid_months(k-1)+0.5*REAL(mnth(k-1)+mnth(k))
148 END DO
149
150 END FUNCTION mid_months
151
152
153 END MODULE create_limit_unstruct_mod
154