Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#168 closed task (fixed)

structure of main subroutines

Reported by: jgipsl Owned by: jgipsl
Priority: major Milestone: IPSLCM6.v1
Component: Model architecture Version: trunc
Keywords: Cc:

Description

The current structure

In sechiba_main, currently each subroutine _main is called 3 times : for the initialization part, in the time loop, and for the finalization part. As the same argument list is used, it is difficult to know after the initialization part which variables that have been initialised. For example, a variable which is declared INTENT(OUT) in slowproc_main, is not necessary initialized at the first call. To be sure if this is the case, often you need to go into stomate_main and look carefully to know if it is calculated also in the initialisation phase. In sechiba_main, currently the structure is :

SURBOURINE sechiba_main						

IF l_first_sechiba THEN						
	CALL sechiba_init(..)							
	CALL restget(..)

	CALL slowproc_main							
	CALL diffuco_main							
	CALL enerbil_main							
	CALL hydrolc_main / CALL hydrol_main					
	CALL condveg_main							
	CALL thermosoil_main							
	If routing CALL routing_main						

	RETURN
END IF										

CALL sechiba_var_init  ! (Initialize variables at each time step)
CALL diffuco_main								
CALL enerbil_main								
CALL hydrolc_main/hydrol_main							
CALL enerbil_fusion
CALL condveg_main								
CALL thermosoil_main								
If routing CALL routing_main							
CALL slowproc_main								
CALL sechiba_end     ! (Update temperature in the end of each time step)

IF ldrestart_write THEN							
	CALL diffuco_main							
	CALL enerbil_main							
	CALL hydrolc_main/hydrol_main						
	CALL condveg_main							
	CALL thermosoil_main							
	If routing CALL routing_main						
	CALL slowproc_main							
END IF

END SUBROUTINE sechiba_main							

New proposition

We here propose to extract the initialisation phase from the _main subroutines so that sechiba_main calls different subroutines in the 3 different stages.

SUBROUTINE sechiba_main

IF l_first_sechiba THEN						
	CALL sechiba_init(..)							
	CALL restget(..)

	CALL slowproc_initialize							
	CALL diffuco_initialize						
	CALL enerbil_initialize						
	CALL hydrolc_initialize / CALL hydrol_initialize					
	CALL condveg_initialize			
	CALL thermosoil_initialize						
	If routing CALL routing_initialize						

	RETURN
END IF										

CALL sechiba_var_init  ! (Initialize variables at each time step)
CALL diffuco_main								
CALL enerbil_main								
CALL hydrolc_main/hydrol_main							
CALL enerbil_fusion
CALL condveg_main								
CALL thermosoil_main								
If routing CALL routing_main							
CALL slowproc_main								
CALL sechiba_end     ! (Update temperature in the end of each time step)

IF ldrestart_write THEN							
	CALL diffuco_finalize							
	CALL enerbil_finalize						
	CALL hydrolc_finalize/hydrol_finalize						
	CALL condveg_finialize				
	CALL thermosoil_finalize							
	If routing CALL routing_finalize						
	CALL slowproc_finalize							
END IF

END SUBROUTINE sechiba_main			

NB: The suffix _initialize and _finialize are long but choosen as that because _init, _end already exist in several modules.

Later, the same splitting can be done for sechiba_main and intersurf_main. But it will be done later. The first splitting as proposed in this ticket will not change the behaviour from coupled models or the driver side.

Jan, Josefine

Change History (8)

comment:1 Changed 9 years ago by jgipsl

In enerbil module, the new subroutine enerbil_initialize will contain directly the contents of enerbil_init and a call to enerbil_t2mdiag. In other words, the current subroutines enerbil_init and enerbil_var_init will be replaced by enerbil_initialize.

comment:2 Changed 9 years ago by jgipsl

In condveg module:
merged subroutine condveg_init and condveg_var_init into new subroutine condveg_initialize (as for enerbil).

comment:3 Changed 9 years ago by jgipsl

In diffuco module:

  • merged subroutine diffuco_init into diffuco_initialize.
  • some questions about initialization of qsatt, raero and q_cdrag: they are not initialized if they are not found in restart file. Added warning for now.

comment:4 Changed 9 years ago by jgipsl

In thermosoil:
merged thermosoil_init in new routine thermosoil_initialize but kept thermosoil_var_init seperated (at least for now). thermosoil_var_init contains initialization of thermal properties.

comment:5 Changed 9 years ago by jgipsl

Done in rev [2581].

comment:6 Changed 9 years ago by jgipsl

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

comment:7 Changed 9 years ago by jgipsl

sechiba_main also done:
Now also sechiba_main is separated into sechiba_initialize, sechiba_main and sechiba_finalize in commit rev [2595].

comment:8 Changed 9 years ago by jgipsl

intersurf_main also done:
Now also intersurf_main_2d and intersurf_gahtered done. See commit rev [2605].

For backward compatibility with LMDZ, intersurf_initialize_gathered can be called from LMDZ but if it is not done, then intersurf_main_gathered will call it at first call.

Note: See TracTickets for help on using tickets.