= How to add a new flag = === Declare the new flag === For consistency reasons new flags are to be declared in a structure. First, you need to declare the new flag as a logical in ../modeles/ORCHIDEE/src_parameter/constantes.f90 in the existing control type block. Variables declared in constantes.f90 are global {{{ TYPE control_type LOGICAL :: ok_NameOfNewFlag !! Explanation of new flag END TYPE control_type }}} Next, you store the flags in a common variable named 'control'. This is done in ../modeles/ORCHIDEE/src_sechiba/sechiba.f90 in the subroutine sechiba_init {{{ control%ok_NameOfNewFlag = control_in%ok_NameOfNewFlag }}} [[BR]] === Read the flag from the parameter file === The flag can be read in the routine where you need it, if the flag is shared among routines you can read it in the first common routine. Quite a few flags that control the flow of th emodel are read in intersurf.f90. Document the flag using the default keywords (see below). An example is shown for the flag called control%ok_functional_allocation {{{ !Config Key = STOMATE_FUNCTIONAL_ALLOCATION !Config Desc = use Friedlingstein etal. 1999 or Zaehle et al 2010 for allocation !Config Def = n !Config Help = set to TRUE if functional allocation is to be activated ! control_flags%ok_functional_allocation = .FALSE. CALL getin_p('STOMATE_FUNCTIONAL_ALLOCATION',control_flags%ok_functional_allocation) WRITE(*,*) 'Allocation is based on plant structure: ',control_flags%ok_functional_allocation }}} [[BR]] [[BR]] = How to add a variable to history.nc = Define the variable in intersurf.f90, check whether the correct operators (i.e. ave) and history level i.e. (4) are defined more information on 'histdef' and 'histwrite' can be found on the documentation page of this wiki {{{ ! total living biomass CALL histdef (hist_id_stom, & & TRIM("Fruit_M "), & & TRIM("Fruit biomass "), & & TRIM("gC/m^2/pft "), iim,jjm, hist_hori_id, & & nvm,1,nvm, hist_PFTaxis_id,32, ave(4), dt, hist_dt) }}} When the variable has the value that need to written to the history file add a statement to the one below {{{ CALL histwrite (hist_id_stomate, 'FRUIT_M', itime, & biomass(:,:,ifruit), npts*nvm, horipft_index) }}} [[BR]] [[BR]] = How to find a segmentation error = === Compilation for checking array dimension === Segmentation errors indicate issues with the memory which are often caused by ill-defined array dimensions. The dimension of your arrays can be checked by changing the settings of the compiler. Note that compiling will take longer but that running the code will take a lot longer! Run the code on a single point test-case to avoid wasting computing resources. open the make file AA_make.gdef in the utility folder {{{ emacs ../util/AA_make.gdef }}} adjust the settings of the compiler by adding 'check bounds'. The example is for a compilation on obelix {{{ #-Q- lxiv8 F_O = -O -check bounds $(F_D) $(F_P) -I$(MODDIR) -module $(MODDIR) }}} remove the previous make file {{{ /modeles/ORCHIDEE_OL/make clean }}} install the new make file with the 'check bounds' option {{{ ./../../util/ins_make }}} and compile {{{ /../modeles/ORCHIDEE_OL/make }}} [[BR]] [[BR]] = How to write a shell script = === A super simple script for recurring tasks === We want to make a script that deletes all the history and restart files from ORCHIDEE so that we can run the next simulation within the same file structure. We will call the command 'clean'. open an editor for the command name i.e. clean {{{ emacs ../bin/clean.sh }}} Write the linux commands in the editor. {{{ #!/bin/bash rm -f ../Output/*_history.nc ../Restart/*_out.nc ../bin/output.txt }}} Save the file and change the permissions so the file can be executed {{{ chmod +x clean.sh }}} you can now type 'clean.sh' to execute the linux commands in the file clean.sh