Changeset 4153 for TOOLS/MOSAIX/src/MOSAIX/interpol.f90
- Timestamp:
- 11/27/18 17:08:31 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/MOSAIX/src/MOSAIX/interpol.f90
r3940 r4153 16 16 INTEGER :: ni_src, nj_src !< Dimensions of the source grid 17 17 INTEGER :: ni_dst, nj_dst !< Dimensions of the source grid 18 REAL (kind=rl), ALLOCATABLE :: imask_src (:,:), imask_dst (:,:) 18 REAL (kind=rl), ALLOCATABLE :: imask_src (:,:), imask_dst (:,:), area_src(:,:), area_dst(:,:) 19 19 REAL (kind=rl), ALLOCATABLE :: lon_src(:,:), lat_src(:,:), field_src(:,:) 20 20 LOGICAL, ALLOCATABLE :: lmask_src (:,:), lmask_dst (:,:) 21 21 INTEGER :: nout = 0, jf 22 22 CHARACTER (LEN=20) :: nchar, type_src, type_dst 23 LOGICAL :: l_mask_src = .TRUE. , l_mask_dst = .TRUE. 23 LOGICAL :: l_mask_src = .TRUE. , l_mask_dst = .TRUE., l_use_area = .FALSE. 24 24 ! 25 25 REAL (kind=rl), PARAMETER :: rpi = ACOS ( -1.0_rl) … … 64 64 CALL getarg ( ja, cmd_arg ) 65 65 SELECT CASE ( TRIM (cmd_arg) ) 66 CASE ( '--mask_src=yes' ) ; l_mask_src = .TRUE. 67 CASE ( '--mask_src=no' ) ; l_mask_src = .FALSE. 68 CASE ( '--mask_dst=yes' ) ; l_mask_dst = .TRUE. 69 CASE ( '--mask_dst=no' ) ; l_mask_dst = .FALSE. 66 CASE ( '--mask_src=true' ) ; l_mask_src = .TRUE. 67 CASE ( '--mask_src=false' ) ; l_mask_src = .FALSE. 68 CASE ( '--mask_dst=true' ) ; l_mask_dst = .TRUE. 69 CASE ( '--mask_dst=false' ) ; l_mask_dst = .FALSE. 70 CASE ( '--use_area=true' ) ; l_use_area = .TRUE. 71 CASE ( '--use_area=no' ) ; l_use_area = .FALSE. 70 72 END SELECT 71 73 END DO … … 73 75 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- mask_src : ', 1L)" ) rank, l_mask_src 74 76 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- mask_dst : ', 1L)" ) rank, l_mask_dst 77 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- use_area : ', 1L)" ) rank, l_use_area 75 78 76 79 !< Context interpol_read : read masks 77 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- debutinterpol_read')" ) rank80 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Starting interpol_read')" ) rank 78 81 CALL xios_context_initialize ("interpol_read", comm) 79 82 CALL xios_get_handle ("interpol_read", ctx_hdl) 80 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- set current context interpol_read')" ) rank83 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Set current context interpol_read')" ) rank 81 84 CALL xios_set_current_context (ctx_hdl) 82 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- close context definition interpol_read')" ) rank85 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Close context definition interpol_read')" ) rank 83 86 CALL xios_close_context_definition () 84 87 85 88 !< Read characteristics of the source grid 86 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturedomain_src')" ) rank89 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_src')" ) rank 87 90 CALL xios_get_domain_attr ("domain_src", ni=ni_src, nj=nj_src) 88 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturedomain_src ', 6I9)") rank, ni_src, nj_src91 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_src ', 6I9)") rank, ni_src, nj_src 89 92 ALLOCATE ( lon_src (ni_src, nj_src), lat_src (ni_src, nj_src) ) 90 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturelon lat src ', 6I9)") rank, SIZE (lon_src), &93 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src ', 6I9)") rank, SIZE (lon_src), & 91 94 & SHAPE (lon_src), SIZE (lat_src), SHAPE (lat_src) 92 95 !! 93 96 ! 94 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturetype src ', 6I9)") rank97 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading type src ', 6I9)") rank 95 98 CALL xios_get_domain_attr ("domain_src", TYPE=type_src ) 96 99 SELECT CASE ( TRIM (type_src)) 97 100 CASE ( "rectilinear" ) 98 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturelon lat src rectilinear', 6I9)") rank101 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src rectilinear', 6I9)") rank 99 102 CALL xios_get_domain_attr ("domain_src", lonvalue_1d=lon_src(:,1), latvalue_1d=lat_src(1,:) ) 100 103 lon_src (:,:) = SPREAD ( lon_src(:,1), DIM=2, ncopies=nj_src) … … 102 105 CASE default 103 106 IF ( nj_src == 1 .AND. ni_src==1) THEN 104 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturelon lat src 2D ', 6I9)") rank107 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src 2D ', 6I9)") rank 105 108 CALL xios_get_domain_attr ("domain_src", lonvalue_2d=lon_src(:,:), latvalue_2d=lat_src(:,:) ) 106 109 ELSE IF ( nj_src == 1 ) THEN 107 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturelon lat src 1D ', 6I9)") rank110 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src 1D ', 6I9)") rank 108 111 CALL xios_get_domain_attr ("domain_src", lonvalue_1d=lon_src(:,1), latvalue_1d=lat_src(:,1) ) 109 112 ELSE 110 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturelon lat src 2D ', 6I9)") rank113 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src 2D ', 6I9)") rank 111 114 CALL xios_get_domain_attr ("domain_src", lonvalue_2d=lon_src(:,:), latvalue_2d=lat_src(:,:) ) 112 115 ENDIF 113 116 END SELECT 117 114 118 !< Read mask on the source grid 115 119 ALLOCATE ( imask_src (ni_src, nj_src), lmask_src (ni_src, nj_src) ) 116 120 IF ( l_mask_src ) THEN 117 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- receive field mask_src')" ) rank121 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Receive field mask_src')" ) rank 118 122 CALL xios_recv_field ("mask_src", imask_src) 119 123 lmask_src = .FALSE. … … 122 126 imask_src (:,:) = 1 ; lmask_src (:,:) = .TRUE. 123 127 ENDIF 124 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- counting mask_src : ', 1I8)" ) rank, COUNT(lmask_src) 128 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Counting mask_src : ', 1I8)" ) rank, COUNT(lmask_src) 129 130 !< Read area on the source grid 131 ALLOCATE ( area_src (ni_src, nj_src) ) 132 IF ( l_use_area ) THEN 133 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Receive field area_src')" ) rank 134 CALL xios_recv_field ("area_src", area_src) 135 ELSE 136 area_src (:,:) = 1 137 ENDIF 138 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Sum area_src : ', 2E15.3)" ) rank, SUM(area_src) !, SUM(area_src, mask=lmask_src) 125 139 126 140 !< Read mask on the destination grid 127 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturedomain_dst')" ) rank141 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_dst')" ) rank 128 142 CALL xios_get_domain_attr ("domain_dst", ni=ni_dst, nj=nj_dst) 129 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecturedomain_dst ', 6I7)") rank, ni_dst, nj_dst143 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_dst ', 6I7)") rank, ni_dst, nj_dst 130 144 ALLOCATE ( imask_dst (ni_dst, nj_dst), lmask_dst (ni_dst, nj_dst) ) 131 145 IF ( l_mask_dst ) THEN 132 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- receive field mask_dst')" ) rank146 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Receive field mask_dst')" ) rank 133 147 CALL xios_recv_field ("mask_dst", imask_dst) 134 148 lmask_dst = .FALSE. … … 139 153 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- counting mask_dst : ', 1I8)" ) rank, COUNT(lmask_dst) 140 154 141 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fin interpol_read (1)')") rank 155 !< Read area on the destination grid 156 ALLOCATE ( area_dst (ni_dst, nj_dst) ) 157 IF ( l_use_area ) THEN 158 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- receive field area_dst')" ) rank 159 CALL xios_recv_field ("area_dst", area_dst) 160 ELSE 161 area_dst (:,:) = 1.0 162 ENDIF 163 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Counting mask_dst : ', 2E15.3)" ) rank, SUM(area_dst) !, SUM(area_dst,mask=lmask_dst) 164 165 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- End interpol_read (1)')") rank 142 166 CALL xios_context_finalize () 143 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fininterpol_read (2)')") rank167 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- End interpol_read (2)')") rank 144 168 145 169 !< Context interpol run : generates weights, interpolate mask from source to destination 146 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- debutinterpol_run')" ) rank170 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Starting interpol_run')" ) rank 147 171 CALL xios_context_initialize ("interpol_run", comm) 148 172 CALL xios_get_handle ("interpol_run", ctx_hdl) 149 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- set context interpol_run')" ) rank173 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Set context interpol_run')" ) rank 150 174 CALL xios_set_current_context (ctx_hdl) 151 175 152 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- get attributes domain_src')" ) rank176 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Get attributes domain_src')" ) rank 153 177 IF ( l_mask_src ) CALL xios_set_domain_attr ("domain_src", mask_2d=lmask_src) 178 IF ( l_use_area ) CALL xios_set_domain_attr ("domain_src", area =area_src ) 179 !CALL xios_set_domain_attr ("domain_src", radius= 6371229.0 ) 154 180 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- get attributes domain_src')" ) rank 155 181 IF ( l_mask_dst ) CALL xios_set_domain_attr ("domain_dst", mask_2d=lmask_dst) 156 157 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- close context definition')" ) rank 182 IF ( l_use_area ) CALL xios_set_domain_attr ("domain_dst", area =area_dst ) 183 !CALL xios_set_domain_attr ("domain_dst", radius= 6371229.0 ) 184 185 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Close context definition')" ) rank 158 186 CALL xios_close_context_definition () 159 187 160 188 CALL xios_update_calendar (1) 161 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- send field mask_src')" ) rank189 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Send field mask_src')" ) rank 162 190 CALL xios_send_field ("mask_src", imask_src) 163 191 … … 166 194 167 195 DO jf = 1, 6 168 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- working on test case ', 1I2.2)" ) rank, jf196 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Working on test case ', 1I2.2)" ) rank, jf 169 197 SELECT CASE ( jf) 170 198 CASE ( 1) ; field_src (:,:) = REAL ( imask_src, kind=rl) … … 181 209 !!< 182 210 183 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fininterpol_run')" ) rank211 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- End interpol_run')" ) rank 184 212 CALL xios_context_finalize () 185 213 … … 193 221 CALL MPI_FINALIZE (ierr) 194 222 195 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fini')" ) rank223 WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- The end')" ) rank 196 224 197 225 END PROGRAM interpol
Note: See TracChangeset
for help on using the changeset viewer.