Back to OASIS3-MCT home

In oasis3-mct/lib/psmile/src/mod_oasis_method.F90/oasis_init_comp :

Management of the coupled and not coupled models using the optional coupled option of oasis_init_comp:
  

SUBROUTINE oasis_init_comp(mynummod,cdnam,kinfo,coupled)

   !------------------------
   !--- Gather model names from all tasks to generate active model list
   !--- Check that the coupled flag from all tasks is consistent for a given model or abort
   !--- Size of compnm is ic_lvar
   !------------------------

   compnm = trim(cdnam)
   allocate(compnmlist(mpi_size_world))
   allocate(coupledlist(mpi_size_world))
   call MPI_GATHER(compnm, ic_lvar, MPI_CHARACTER, compnmlist, ic_lvar, MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr)
   call MPI_GATHER(oasis_coupled, 1, MPI_LOGICAL, coupledlist, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)

   ! Get only one model name and if coupled or not from compnm and coupledlist :
   prism_modnam(prism_nmodels) = trim(compnmlist(n))
   prism_modcpl(prism_nmodels) = coupledlist(n)

   call oasis_mpi_bcast(prism_nmodels,MPI_COMM_WORLD,subname//' prism_nmodels')    ! prism_nmodels is the total number of coupled models
   call oasis_mpi_bcast(prism_amodels,MPI_COMM_WORLD,subname//' prism_amodels')   
! prism_amodels is the total number of uncoupled models
   call oasis_mpi_bcast(prism_modnam ,MPI_COMM_WORLD,subname//' prism_modnam')   ! store the name of all the models
   call oasis_mpi_bcast(prism_modcpl ,MPI_COMM_WORLD,subname//' prism_modcpl')      ! store de coupling status (if at least one proc is in the coupling
                                                                                                                                                       ! then the model is coupling, if no proc of a model is in the coupling
                                                                                                                                                       ! then the model is not oupling

#ifdef use_comm_MPI1

   ! Set mpi_comm_local based on compid : mpi_comm_local to the model with all its procs
   ikey = 0
   icolor = compid
   call MPI_COMM_SPLIT(MPI_COMM_WORLD,icolor,ikey,mpi_comm_local,ierr)

   ! Set mpi_comm_global based on oasis_coupled flag (in OASIS3-MCT_2.0 mpi_comm_global =
MPI_COMM_WORLD)
   ! Then in OASIS3-MCT_3.0 keep only the proc coupling in the global comm => this is the reason why the proc that are not coupling must not call def_partition and def_var
   ikey = 0
   icolor = 1
   if (.not.oasis_coupled) icolor = 0
   call MPI_COMM_SPLIT(MPI_COMM_WORLD,icolor,ikey,mpi_comm_global,ierr)

* ALL tasks of a given model must call oasis_init_comp with the same value of the optional coupled argument (where the default is true).  if a model calls oasis_comp_init with coupled=.false., then that model does NOT need to make any more calls to any oasis interfaces.

* If a model calls oasis_comp_init with coupled=.true. (which is the default value), then that component must at least call oasis_enddef and oasis_terminate even if no fields are coupled which means that ALL tasks on all coupled components must call oasis_enddef and oasis_terminate.

* If a model is defining coupling fields, oasis_def_partition and oasis_def_var must be called on all tasks that are involved in the coupling of that field.  oasis_def_partition defines the local partition and oasis_def_var returns a var_id that is used later in the get/put interface.  The order of the definition of partitions or variables does not need to be the same on all tasks. Tasks not involved in the coupling of a particular field may call oasis_def_partition and oasis_def_var.

* If a model is coupling a field, then oasis_get and oasis_put must be called on all tasks involved in coupling.  The order of the fields is important and must be consistent across different tasks. oasis_get and oasis_put should NOT be called on tasks for variables where oasis_def_var was not called as no var_id will be established on those tasks for that variable.

*
If there are more than one component in one executable, defined each with one oasis_init_comp, they will be defined concurrently with respect to tasks within that executable.

* Coupling now possible within a component (one oasis_init_comp), on overlapping, partly overlapping, or non overlapping tasks inside this component and sharing this oasis_init_comp. There will be one oasis_init_comp, but some oasis_def_partition, oasis_def_var, oasis_put and oasis_get in the tasks of the principal component depending if they are coupling or not . User must make sure not to deadlock when coupling within a component. Puts must be executed before gets for coupling within a component on overlapping tasks.

* OASIS3-MCT_3.0 can not give communicators to a subset of tasks inside a component. Communicators needed in a component have to be created and managed by the model itself.