Add diagnostic in SURFEX-Crocus

Depending of the science involved, it could be done in different parts of the SURFEX-Crocus code.
We imagine here the simpliest way for a first try, following an existing diagnostic ACC_RAT which is define on each layer of the snowpack.

Files to modify (a minima) :


What are these routines, what are me modifying inside ?

In this script, we declare the "ISBA Diagnostic" variable.
The nature of this variable is TYPE.
You can imagine the TYPE as a vector and you are adding a new coordinate to this vector.
In this script, the name of ISBA_Diagnostic is DMI. The way to access to a coordinate is via the % sign : DMI%XVAR_NEWDIAG.
If your diagnostic dimension is (number of points, number of layers), you can follow ACC_RAT for the declaration of your new diagnostic

In this script, this is the initialisation of ISBA_Diagnostic, named DMA.
So we are working on DMA%XVAR_NEWDIAG
For a (number of points, number of layers) diagnostic, you can follow ACC_RAT also.
Beware, there are two dimensions possible : KLUA and KLUAP which depends on the behaviour of your diagnostic regarding to SURFEX Patches -> be sure that the existing diagnostic you are following has the same behaviour and dimensions.

In this script, you’re starting to work with ISBA_Diagnostic (named DMK here):
  • initialise DMK%XVAR_NEWDIAG( :, : ) = XUNDEF
  • define a local variable ZP_XVAR_NEWDIAG
  • call snowcro_diag.F90 with the local variable (Of course, for specific diagnostic, the calculus could be done in another part of the code and maybe you would have to modify snowcro.F90 or another script).
  • put the returning value in DMK%XVAR_NEWDIAG
    As always, you can follow ACC_RAT to see what happens and how.

This is the science part : you have to calculate NEW_DIAG with the fields you need.
Of course, you have to declare this new variable as INOUT and to put it in the call of the script.

This is the script for writing in PRO file. (you can follow ACC_RAT)
  • change the YCOMMENT (long name: "my beautiful new diag for good science")
  • change the short name 'VAR_NEWDIAG' and name the variable (lot of % everywhere but you only have to put XVAR_NEWDIAG instead of XACC_RAT if you are copying this diag)

Now, you have to compile SURFEX and to test it (do not forget to add your diagnostic in the CSELECT of the namelist).