Opened 8 years ago

Closed 8 years ago

#110 closed enhancement (fixed)

Splitting too long modules in src_parameters

Reported by: jgipsl Owned by: jgipsl
Priority: major Milestone: ORCHIDEE 2.0
Component: Model architecture Version: trunc
Keywords: Cc:

Description

Problem
In src_parameters the modules are very long and in some cases this causes probleme with circular dependency problem.

For exemple the module constantes can not be used in one of the modules that it self is using. One of these modules is mod_orchidee_para. This means that mod_orchidee_para can not use constantes and also all modules that are used in mod_orchidee_para can not use constantes, etc.. This is the case also if the key word ONLY is employed. When a module is in a USE statement, it has to be compiled before the module including the USE statement.

Proposed solution
The solution is to move the upper part containing the declaration of the variables into a new module. This new module can be called without dependency problem (but of course it is not possible to use it correctly before the variables have been initialized). The original module will contain a USE to the new module. The original USE of the modules will be unchanged. Only the modules containg subroutines are effected : constantes.f90, pft_parameters.f90 and constantes_soil.f90.

Exemple of the module constantes.f90

The structure of the module constantes.f90 before changes :

MODULE constantes

  USE defprec
  USE ioipsl_para, ONLY : getin_p, ipslerr_p
  USE mod_orchidee_para, ONLY : numout

  IMPLICIT NONE

  ! Declaration part

  ! FLAGS 
  !
  TYPE control_type
    LOGICAL :: river_routing      !! activate river routing (true/false)
    LOGICAL :: hydrol_cwrr        !! activate 11 layers hydrolgy model (true/false)
    LOGICAL :: do_floodplains
    ...
    LOGICAL :: ok_bbgfertil_NOx   !! calculate NOx emissions with bbg fertilizing effect (true/false)
    LOGICAL :: ok_cropsfertil_NOx !! calculate NOx emissions with fertilizers use (true/false)
  END TYPE control_type

  !-
  TYPE(control_type), SAVE :: control  !! Flags that (de)activate parts of the model
!$OMP THREADPRIVATE(control)
  LOGICAL, SAVE :: OFF_LINE_MODE = .FALSE.  !! ORCHIDEE detects if it is coupled with a GCM or 
                                           
...

! Contains part with subroutines
  CONTAINS
 SUBROUTINE config_stomate_parameters
     
...
   
  END SUBROUTINE config_dgvm_parameters
END MODULE constantes

After modifications a new module called constantes_var.f90 will contain the upper part, the declaration part :

MODULE constantes_var

  USE defprec

  IMPLICIT NONE

  ! Declaration part

  ! FLAGS 
  !
  TYPE control_type
    LOGICAL :: river_routing      !! activate river routing (true/false)
    LOGICAL :: hydrol_cwrr        !! activate 11 layers hydrolgy model (true/false)
    LOGICAL :: do_floodplains
    ...
    LOGICAL :: ok_bbgfertil_NOx   !! calculate NOx emissions with bbg fertilizing effect (true/false)
    LOGICAL :: ok_cropsfertil_NOx !! calculate NOx emissions with fertilizers use (true/false)
  END TYPE control_type

  !-
  TYPE(control_type), SAVE :: control  !! Flags that (de)activate parts of the model
!$OMP THREADPRIVATE(control)
  LOGICAL, SAVE :: OFF_LINE_MODE = .FALSE.  !! ORCHIDEE detects if it is coupled with a GCM or 
                                           
  ...
END MODULE constantes_var

and the constantes.f90 will contain USE constantes_var and all the CONTAINS part :

MODULE constantes

  USE defprec
  USE ioipsl_para, ONLY : getin_p, ipslerr_p
  USE mod_orchidee_para, ONLY : numout
  USE constantes_var

  IMPLICIT NONE

! Contains part with subroutines
  CONTAINS
 SUBROUTINE config_stomate_parameters
     
...
   
  END SUBROUTINE config_dgvm_parameters
END MODULE constantes

Change History (1)

comment:1 Changed 8 years ago by jgipsl

  • Resolution set to fixed
  • Status changed from new to closed

Done in commit [1475] but please do not use this version as a type mistake was introduced. Use [1476] instead.

Note that this modification do not change the way of using the original modules. But it offers a possibility to use the new modules where the origianal can not be used.

Note: See TracTickets for help on using tickets.