PROGRAM start_archive2icosa USE xios USE mod_wait USE netcdf IMPLICIT NONE INCLUDE "mpif.h" INTEGER :: rank INTEGER :: size INTEGER :: ierr CHARACTER(len=*),PARAMETER :: id="client" INTEGER :: comm TYPE(xios_duration) :: dtime CHARACTER(len=15) :: calendar_type TYPE(xios_context) :: ctx_hdl INTEGER :: n,l INTEGER :: src_ibegin, src_iend, src_topo_ibegin, src_topo_iend INTEGER :: src_jbegin, src_jend, src_topo_jbegin, src_topo_jend INTEGER :: src_ni, src_ni_glo, src_topo_ni, src_topo_ni_glo INTEGER :: src_nj, src_nj_glo, src_topo_nj, src_topo_nj_glo INTEGER :: src_nlev ! number of vertical layers INTEGER :: src_nq=7 ! number of tracers INTEGER :: src_nt=1 ! number of time steps INTEGER :: src_nsoil=18 ! number of soil layers ! INTEGER :: src_nslope=1 ! number of subslope DOUBLE PRECISION,ALLOCATABLE :: lev_values(:) ! vertical axis DOUBLE PRECISION,ALLOCATABLE :: lev_p1_values(:) ! vertical axis DOUBLE PRECISION,ALLOCATABLE :: nq_values(:) ! tracer # axis DOUBLE PRECISION,ALLOCATABLE :: soil_layers_values(:) ! soil axis ! DOUBLE PRECISION,ALLOCATABLE :: subslope_values(:) ! subslope axis DOUBLE PRECISION,ALLOCATABLE :: src_lon(:) ! mesh center coordinate DOUBLE PRECISION,ALLOCATABLE :: src_lat(:) DOUBLE PRECISION,ALLOCATABLE :: src_ap(:) DOUBLE PRECISION,ALLOCATABLE :: src_bp(:) DOUBLE PRECISION,ALLOCATABLE :: src_controle(:) DOUBLE PRECISION,ALLOCATABLE :: src_field_2D(:,:) ! DOUBLE PRECISION,ALLOCATABLE :: src_field_2D_subslope(:,:,:) DOUBLE PRECISION,ALLOCATABLE :: src_pk(:,:) DOUBLE PRECISION,ALLOCATABLE :: src_field_3D(:,:,:) DOUBLE PRECISION,ALLOCATABLE :: src_pressure(:,:,:) DOUBLE PRECISION,ALLOCATABLE :: src_theta_rhodz(:,:,:) DOUBLE PRECISION,ALLOCATABLE :: src_topo_lon(:) ! mesh center coordinate DOUBLE PRECISION,ALLOCATABLE :: src_topo_lat(:) DOUBLE PRECISION,ALLOCATABLE :: src_topo(:,:) DOUBLE PRECISION,ALLOCATABLE :: src_field_3D_soil(:,:,:) ! 3D grid in soil, for tsoil et inertia ! DOUBLE PRECISION,ALLOCATABLE :: src_field_3D_soil_subslope(:,:,:,:) ! 3D grid in soil, for tsoil et inertia DOUBLE PRECISION,ALLOCATABLE :: src_soil_layers(:) ! soil_depth DOUBLE PRECISION,ALLOCATABLE :: src_field_3D_p1(:,:,:) !q2 field CHARACTER(LEN=*),PARAMETER :: src_file="start_archive_nc4.nc" CHARACTER(LEN=*),PARAMETER :: src_topo_file="surface_nc4.nc" CHARACTER(LEN=*),PARAMETER :: dst_coord_file="start_icosa_ref.nc" CHARACTER(LEN=*),PARAMETER :: src_controle_file="startphy_icosa_ref.nc" CHARACTER(LEN=*),PARAMETER :: output_start_file="start_icosa_prefinalize.nc" CHARACTER(LEN=*),PARAMETER :: output_startfi_file="startfi_prefinalize.nc" DOUBLE PRECISION,ALLOCATABLE :: dst_lon(:),dst_lat(:) DOUBLE PRECISION,ALLOCATABLE :: dst_boundslon(:,:) ! mesh corner coordinates DOUBLE PRECISION,ALLOCATABLE :: dst_boundslat(:,:) INTEGER :: dst_ibegin !, dst_iend INTEGER :: dst_ni, dst_ni_glo INTEGER :: dst_nvertex INTEGER :: ncid INTEGER :: dimids(5) INTEGER :: varid INTEGER :: div, remain INTEGER :: ts ! time step # DOUBLE PRECISION,PARAMETER :: pi=acos(-1.d0) DOUBLE PRECISION :: gravity,kappa,preff ! Tracers CHARACTER(LEN=11) :: i_trac,format_string INTEGER :: i !!! MPI Initialization CALL MPI_INIT(ierr) CALL init_wait !!! XIOS Initialization (get the local communicator) CALL xios_initialize(id,return_comm=comm) ! get local rank of MPI process CALL MPI_COMM_RANK(comm,rank,ierr) ! get total number of MPI processes CALL MPI_COMM_SIZE(comm,size,ierr) !!! Open files and load sizes and coordinates ierr=NF90_OPEN(src_topo_file, NF90_NOWRITE, ncid) ierr=NF90_INQ_VARID(ncid,"zMOL",varid) ierr=NF90_INQUIRE_VARIABLE(ncid, varid,dimids=dimids) write(*,*) "rank=",rank,"dimids=",dimids ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(1), len=src_topo_ni_glo) ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(2), len=src_topo_nj_glo) write(*,*) "rank=",rank," src_topo_ni_glo=",src_topo_ni_glo ! longitude write(*,*) "rank=",rank," src_topo_nj_glo=",src_topo_nj_glo ! latitude ! assume domain splitup with MPI only along latitudes src_topo_ni=src_topo_ni_glo src_topo_ibegin=0 src_topo_iend=src_topo_ibegin+src_ni-1 write(*,*) "rank=",rank," src_topo_ni=",src_topo_ni src_topo_jbegin=0 DO n=0,size-1 src_topo_nj=src_topo_nj_glo/size IF (n