The OASIS Coupler Forum

  HOME

Remapping between identical grids in CHIMERE-WRF

Up to Transformations and interpolations

Posted by Anonymous at November 25 2014

Hi,

I am working on the coupled model CHIMERE-WRF. The source and the target grids are the same. I would like to create the remapping file rmp_src_to_dst_interpolation.nc without doing any interpolation. I created this file using the BILINEAR interpolation of SCRIPR but I have an error in the dimension of the CHIMERE grid in the remapping file (3713 values instead of 30720 which is the global size of the grid). Do you have any explanation ?

Below is the namcouple I use to create the file rmp_src_to_dst_interpolation.nc :

SENDCHO3 RECVCHO3 1 3600 1 FCHO3.nc EXPOUT

30720 1 30720 1 chim twrf

R 0 R 0

SCRIPR

BILINEAR LR SCALAR LATLON 1

Thanks, Best regards, Adrien

Posted by Anonymous at November 26 2014

Hello Adrien,

You will find below a small fortran program (and an example of how to compile it) that creates a weight file for "identical" interpolation. You must use this weight file with the "MAPPING" namcouple option, instead of SCRIPR.

Best regards, Eric

--------------------------------------------PROGRAM  make_oasis_weights

     use netcdf

     character(len=300)               :: c_argument
     integer*4                          :: nb_grid_point, i
     integer*4                          :: dimids(4), il_file_id, il_var_id(5)
     integer*4,allocatable,dimension(:) :: tmp
     real(8),allocatable,dimension(:,:) :: tmp2

  call getarg( 1, c_argument )
  read(c_argument,'(i9)') nb_grid_point

            status = nf90_create("oasis_weight.nc", NF90_CLOBBER, il_file_id)
            status = nf90_def_dim(il_file_id, "num_wgts", 1, dimids(1))
            status = nf90_def_dim(il_file_id, "num_links", nb_grid_point, dimids(2))
            status = nf90_def_dim(il_file_id, "dst_grid_size", nb_grid_point, dimids(3))
            status = nf90_def_dim(il_file_id, "src_grid_size", nb_grid_point, dimids(4))
            status = nf90_def_var(il_file_id, "src_address", NF90_INT, dimids(2), il_var_id(1))
            status = nf90_def_var(il_file_id, "dst_address", NF90_INT, dimids(2), il_var_id(2))
            status = nf90_def_var(il_file_id, "remap_matrix", NF90_DOUBLE, dimids(1:2), il_var_id(3))
            status = nf90_def_var(il_file_id, "dst_grid_area", NF90_DOUBLE, dimids(3), il_var_id(4))
            status = nf90_def_var(il_file_id, "src_grid_area", NF90_DOUBLE, dimids(4), il_var_id(5))
            status = nf90_enddef(il_file_id)

        ALLOCATE (tmp(nb_grid_point))
        ALLOCATE (tmp2(1,nb_grid_point))

        DO i = 1, nb_grid_point
           tmp(i) = i
        ENDDO

            tmp2 = 1.

            status = nf90_put_var(il_file_id, il_var_id(1), tmp)
            status = nf90_put_var(il_file_id, il_var_id(2), tmp)
            status = nf90_put_var(il_file_id, il_var_id(3), tmp2)
            status = nf90_put_var(il_file_id, il_var_id(4), RESHAPE ( tmp2, (/ nb_grid_point /) ) )
            status = nf90_put_var(il_file_id, il_var_id(5), RESHAPE ( tmp2, (/ nb_grid_point /) ) )
            status = nf90_close(il_file_id)

END PROGRAM  make_oasis_weights

mpiifort make_oasis_weight.f90 -o make_oasis_weight.exe -O2 -xAVX -I/opt/softs/libraries/ICC13.1.4.183/netcdf-4.3.0/include -L/opt/softs/libraries/ICC13.1.4.183/netcdf-4.3.0/lib -lnetcdf -lnetcdff
---------------------------------------------------

Posted by Anonymous at November 27 2014

Dear Adrien,

When two grids are identical with the same name there is no need to calculate any remapping file.

By the way, if you want to create a remapping file between two identical grids, you could also use the DISTWGT remapping with one neighbour (see the User Guide https://oasis.cerfacs.fr/wp-content/uploads/sites/114/2021/02/GLOBC-Valcke_TR_OASIS3-MCT_2.0_2013.pdf, section 4.3).

Best regards,
Laure
Reply to this