<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/LMDZPedia/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rkazeroni</id>
		<title>LMDZPedia - Contributions de l’utilisateur [fr]</title>
		<link rel="self" type="application/atom+xml" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/LMDZPedia/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rkazeroni"/>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/LMDZPedia/index.php/Sp%C3%A9cial:Contributions/Rkazeroni"/>
		<updated>2026-05-29T19:34:34Z</updated>
		<subtitle>Contributions de l’utilisateur</subtitle>
		<generator>MediaWiki 1.27.7</generator>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/LMDZPedia/index.php?title=LMDZ_Coding_conventions_and_guidelines&amp;diff=518</id>
		<title>LMDZ Coding conventions and guidelines</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/LMDZPedia/index.php?title=LMDZ_Coding_conventions_and_guidelines&amp;diff=518"/>
				<updated>2026-01-06T10:58:37Z</updated>
		
		<summary type="html">&lt;p&gt;Rkazeroni : Add link to GPU-Morphosis coding rules for Fortran codes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
Coding rules related to '''GPU porting with GPU-Morphosis''' are available on this [https://ipsl.pages.in2p3.fr/projets/traccs-gpu/gpu-morphosis/coding_rules/ webpage].&lt;br /&gt;
&lt;br /&gt;
== Generalities ==&lt;br /&gt;
&lt;br /&gt;
* '''IMPLICT NONE'''&lt;br /&gt;
* useful comments in all files (of course)&lt;br /&gt;
* fortran keywords in fortran files will be in '''UPPER''' case&lt;br /&gt;
* in the physics module, all '''SAVE''' variables should be declared as '''THREADPRIVATE''' (this includes all variables that are initialized in their declaration)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot; line&amp;gt;&lt;br /&gt;
  LOGICAL, SAVE :: first = .TRUE.&lt;br /&gt;
  !$OMP THREADPRIVATE(first)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* variables and functions included through modules should be explicitly defined through the '''USE ..., ONLY''' statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot; line&amp;gt;&lt;br /&gt;
USE ioipsl_getin_p_mod, ONLY : getin_p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Naming of modules ==&lt;br /&gt;
&lt;br /&gt;
Module names should have a '''lmdz_''' prefix. For example, the file '''lmdz_wave.F90''' would be a module containing one or more subroutines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot; line&amp;gt;&lt;br /&gt;
  MODULE lmdz_wave&lt;br /&gt;
  IMPLICIT NONE&lt;br /&gt;
&lt;br /&gt;
  CONTAINS&lt;br /&gt;
&lt;br /&gt;
  SUBROUTINE wave_init (...)&lt;br /&gt;
  ...&lt;br /&gt;
  END SUBROUTINE wave_init&lt;br /&gt;
&lt;br /&gt;
  SUBROUTINE wave_calc (...)&lt;br /&gt;
  ...&lt;br /&gt;
  END SUBROUTINE wave_calc&lt;br /&gt;
&lt;br /&gt;
  END MODULE lmdz_wave&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Beware: the renaming of already existing parametrization modules (to the '''lmdz_''' format) should only occur once they have been re-written to adhere to the coding conventions for parametrizations (see below) as we use it as a marker that the recoding work on that particular parametrization has been done.&lt;br /&gt;
&lt;br /&gt;
== Coding conventions for parametrizations ==&lt;br /&gt;
&lt;br /&gt;
Following different discussions among LMDZ developpers (summarized in one of our weekly meetings [https://lmdz.lmd.jussieu.fr/le-coin-des-developpeurs/cr-de-reunions/poihl/compte-rendus-poihl-2022/2022-05-16 here]), the following coding rules apply to the development of LMDZ parametrizations:&lt;br /&gt;
&lt;br /&gt;
* constants and variables that need to be initialized for all routines of the parametrization '''''param''''' should be declared and initialized in a specific initialisation module called '''lmdz_''param''_ini'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot; line&amp;gt;&lt;br /&gt;
MODULE lmdz_param_ini&lt;br /&gt;
REAL, SAVE :: cst1&lt;br /&gt;
!$OMPTREADPRIVATE cst1&lt;br /&gt;
...&lt;br /&gt;
END MODULE lmdz_param_ini&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* the routines associated to a parametrization can either be gathered in a unique module or each have their own module. The name of the module will reflect the parametrization the routine belongs to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot; line&amp;gt;&lt;br /&gt;
MODULE lmdz_param1_subroutine1&lt;br /&gt;
CONTAINS&lt;br /&gt;
SUBROUTINE param1_subroutine1&lt;br /&gt;
USE lmdz_param1_ini, ONLY : cst1&lt;br /&gt;
...&lt;br /&gt;
END SUBROUTINE param1_subroutine1&lt;br /&gt;
END MODULE lmdz_param1_subroutine1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* the first arguments of parametrization routines should be the dimensions of the domain (e.g. '''klon, klev''')&lt;br /&gt;
* all the variables in a routine must be 'properly' declared with '''TYPE''', '''DIMENSION''' and '''INTENT''' for arguments to the routine&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot; line&amp;gt;&lt;br /&gt;
MODULE lmdz_param1_subroutine1&lt;br /&gt;
CONTAINS&lt;br /&gt;
SUBROUTINE param1_subroutine1(klon, klev, ..., dtdwn, dqdwn, ..., dth, ...)&lt;br /&gt;
! Input arguments to routine&lt;br /&gt;
INTEGER, INTENT(IN) :: klon,klev&lt;br /&gt;
REAL, DIMENSION (klon, klev),     INTENT(IN)          :: dtdwn, dqdwn&lt;br /&gt;
...&lt;br /&gt;
! Output arguments&lt;br /&gt;
REAL, DIMENSION (klon, klev),     INTENT(OUT)         :: dth&lt;br /&gt;
...&lt;br /&gt;
! Local variables&lt;br /&gt;
REAL, DIMENSION(klon)                                 :: act&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* all dimensions of tables (e.g. '''nbsrf''') should be passed as arguments to the routine rather than passed through a module&lt;br /&gt;
&lt;br /&gt;
24 janvier 2025 à 17:37 (CET)&lt;br /&gt;
[[Category:HowTo]]&lt;br /&gt;
[[Category:Notes Techniques]]&lt;br /&gt;
[[Category:FAQ]]&lt;/div&gt;</summary>
		<author><name>Rkazeroni</name></author>	</entry>

	</feed>